<?php include 'class/utilisateur.class.php'; ?> <!DOCTYPE html> <html lang="en"> <head> <?php include 'header.php';?> </head> <body> <div id="wrapper"> <?php include 'menu.php'; ?> <?php if (!(isset($_GET['statut']))){if (!(he_can('TTUSERS'))) {echo "<script>location.href = '403.php';</script>";}}?> <?php if (isset($_GET['statut'])){if (!(he_can('STATUTUSERS'))) {echo "<script>location.href = '403.php';</script>";}}?> <?php $utman = new UtilisateurManager($db); $message =''; $class_msg=''; if(isset ($_POST['op'])) { if($_POST['op'] == "delete") { $utman->delete((int) $_POST['id']); $message = "L'utilisateur <i>(ID = ".$_POST['id'].")</i> à été supprimée!."; $class_msg="alert alert-info"; } if($_POST['op'] == "edit") { $maj= array(); $maj['id']=(int) $_POST['id']; $maj['cin']=(int) $_POST['cin']; $maj['nom']=$_POST['nom']; $maj['email']=$_POST['email']; if ($_POST['ancemail']!=$_POST['email']) { if ($utman->existe($_POST['email']) == 'oui') {$message = "Cette adresse mail (".$_POST['email'].") existe déjà!";$class_msg="alert alert-danger"; }} if(isset ($_POST['changepass'])) {$maj['passwd']= md5($_POST['passwd']);} $maj['tel']=$_POST['tel']; $maj['pv']=$_POST['pv']; $maj['statut']=$_POST['statut']; $maj['desc']=htmlspecialchars($_POST['desc'], ENT_QUOTES); if ($message =='') {$utman->update($maj); $message = "Vos modifications ont été effectuées avec succès!."; $class_msg="alert alert-warning"; $utm = $utman->get ((int) $_SESSION['GDEAL']['user']['id']); $_SESSION['GDEAL']['user']['id'] = $utm->id(); $_SESSION['GDEAL']['user']['nom'] = $utm->nom(); $_SESSION['GDEAL']['user']['statut'] = $utm->statut(); } } if($_POST['op'] == "add") { $add= array(); $add['cin']=(int) $_POST['cin']; $add['nom']=$_POST['nom']; $add['email']=$_POST['email']; if ($utman->existe($_POST['email']) == 'oui') {$message = "Cette adresse mail (".$_POST['email'].") existe déjà!";$class_msg="alert alert-danger"; } $add['passwd']= md5($_POST['passwd']); $add['tel']=$_POST['tel']; $add['pv']=$_POST['pv']; $add['statut']=$_POST['statut']; $add['desc']=htmlspecialchars($_POST['desc'], ENT_QUOTES); if ($message =='') {$idadd = $utman->add($add); $message = "Utlisateurs ajoutée avec succès <i>(ID = ".$idadd.")</i>!."; $class_msg="alert alert-success"; $utm = $utman->get ((int) $_SESSION['GDEAL']['user']['id']); $_SESSION['GDEAL']['user']['id'] = $utm->id(); $_SESSION['GDEAL']['user']['nom'] = $utm->nom(); $_SESSION['GDEAL']['user']['statut'] = $utm->statut(); } } } $header = 'Utilisateurs'; $libelle = "Liste de toutes les Utilisateurs"; $liste = $utman->getList(); if (isset($_GET['statut'])) {$libelle = "Liste de toutes les ".$statut_code[$_GET['statut']]."s";$liste = $utman->getList($_GET['statut']);$header=$statut_code[$_GET['statut']]."s";} ?> <!-- Page Content --> <div id="page-wrapper"> <div class="container-fluid"> <div class="row"> <div class="col-lg-12"> <h1 class="page-header"><?php echo $header;?></h1> </div> <div class="col-lg-12"> <a href="#" data-toggle="modal" data-target="#add"><i class="glyphicon glyphicon-plus"></i> Ajouter</a> </div> <!-- /.col-lg-12 --> </div> <!-- /.row --> <!-- /.row --> <div class="row"> <div class="col-lg-12"> <div class="panel panel-default"> <div class="panel-heading"> <?php echo $libelle;?> </div> <!-- /.panel-heading --> <div class="panel-body"> <?php if ($message !='') {echo '<div class="'.$class_msg.'" role="alert"><i class="fas fa-exclamation-circle"></i> '.$message.'</div>';} ?> <div class="dataTable_wrapper"> <table class="table table-striped table-bordered table-hover" id="dataTables-user" cellspacing="0" width="100%"> <thead> <tr> <th>ID</th> <th>Nom</th> <th>Email</th> <th>Statut</th> <th>Option</th> </tr> </thead> <tbody> <?php foreach ($liste as $usr) { ?> <tr class="odd gradeX"> <td class="center"><?php echo $usr->id();?></td> <td><?php echo $usr->nom();?></td> <td><?php echo $usr->email();?></td> <td ><?php echo $statut_code[$usr->statut()];?></td> <td class="center"> <!-- Single button --> <div class="btn-group"> <button type="button" class="btn btn-info btn-xs dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Option <span class="caret"></span> </button> <ul class="dropdown-menu"> <li><a href="#" data-toggle="modal" data-target="#show<?php echo $usr->id();?>"><i class="glyphicon glyphicon-eye-open"></i> Afficher</a></li> <li><a href="#" data-toggle="modal" data-target="#edit<?php echo $usr->id();?>"><i class="glyphicon glyphicon-pencil"></i> Modifier</a></li> <li role="separator" class="divider"></li> <form name='frmdel<?php echo $usr->id();?>' id='frmdel<?php echo $usr->id();?>' action='' method='post'> <?php echo "<input type='hidden' name='id' value = '".$usr->id()."'>"; echo "<input type='hidden' name='op' value = 'delete'>"; ?> </form> <li><a onclick="if (confirm('Voulez vous vraiment supprimer cet Utilisateur ( ID = <?php echo $usr->id();?>)?')) {document.forms['frmdel<?php echo $usr->id();?>'].submit(); return false;}" href="#"><i class="glyphicon glyphicon-remove"></i> Supprimer</a></li> </ul> </div> <div class="modal fade modal-info" id="show<?php echo $usr->id();?>" data-easein="perspectiveDownIn" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" id="myModalLabel"><?php echo $usr->id();?> : <?php echo $usr->nom();?></h4> </div> <div class="modal-body"> <table class="table table-striped"> <tbody> <tr> <th width='25%'>CIN</th> <td><?php echo $usr->cin();?></td> </tr> <tr> <th>Email</th> <td><?php echo $usr->email();?></td> </tr> <tr> <th>Téléphone</th> <td><?php echo $usr->tel();?></td> </tr> <tr> <th>Point de Vente</th> <td><?php echo $usr->pv();?></td> </tr> <tr> <th>Type de Compte</th> <td><?php echo $statut_code[$usr->statut()];?></td> </tr> <tr> <th>Autres Informations</th> <td><?php echo $usr->desc();?></td> </tr> </tbody> </table> </div> <div class="modal-footer"> <button type="button" class="btn btn-info" data-dismiss="modal">Fermer</button> </div> </div> </div> </div> <div class="modal fade modal-warning" id="edit<?php echo $usr->id();?>" data-easein="flipYIn" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" id="myModalLabel"><?php echo $usr->id();?> : <?php echo $usr->nom();?></h4> </div> <div class="modal-body" style="padding:0;"> <table class="table table-striped"> <form name='frm' id='frm' action='' method='post'> <?php echo "<input type='hidden' name='id' value = '".$usr->id()."'>"; echo "<input type='hidden' name='ancemail' value = '".$usr->email()."'>"; echo "<input type='hidden' name='op' value = 'edit'>"; ?> <tbody> <tr> <th width='25%'>ID</th> <td><?php echo $usr->id();?></td> </tr> <tr> <th>CIN</th> <td><?php echo "<input type='text' class='form-control' name='cin' pattern='^[0-9]{7,9}$' value = '".$usr->cin()."' placeholder='Le numéro de cin' title='Le numéro de cin doit être composer de 8 chiffres'>";?></td> </tr> <tr> <th>Nom * </th> <td><?php echo "<input type='text' class='form-control' name='nom' pattern='^[a-zA-Z0-9àâçéèêëîïôûùüÿñæœ _+-.,!@#$%^&*();\/|<>]{3,70}$' value = '".$usr->nom()."' placeholder='Le nom' title='Le nom doit être composer des lettres de taille varie entre 4 et 70 carractére' required>";?></td> </tr> <tr> <th>Email *</th> <td><?php echo "<input type='email' class='form-control' name='email' value = '".$usr->email()."' placeholder='L \'adresse mail' required>";?></td> </tr> <tr> <th>Mot de Passe *</th> <td style="display: flex;"> <?php echo "<input style='margin: auto;width: 40px;' type='checkBox' name='changepass' id='changepass' value='on' class='form-control' onClick=\" if (this.checked) document.getElementById('passwd".$usr->id()."').disabled = false; else document.getElementById('passwd".$usr->id()."').disabled = true; \" title='Cocher pour définir une nouvelle mot de passe.'><label for='changepass' ></label> <input type='text' class='form-control' id='passwd".$usr->id()."' name='passwd' pattern='^[a-zA-Z0-9àâçéèêëîïôûùüÿñæœ _+-.,!@#$%^&*();\/|<>]{8,30}' placeholder='le Mot de passe' title='Le mot de passe doit être composer des chiffres et des lettres et de taille varie entre 8 et 30 carractéres.' disabled required>"; ?> </td> </tr> <tr> <th>Téléphone</th> <td><?php echo "<input type='text' class='form-control' name='tel' pattern='^[0-9 +]{8,20}$' value = '".$usr->tel()."' placeholder='Le numéro de téléphone' title='Le numéro de télépohne doit être composer entre 8 et 20 chiffres'>";?></td> </tr> <tr> <th>Point de Vente</th> <td><?php echo "<input type='text' class='form-control' name='pv' pattern='^[a-zA-Z0-9àâçéèêëîïôûùüÿñæœ _+-.,!@#$%^&*();\/|<>]{3,70}$' value = '".$usr->pv()."' placeholder='La point de vente' title='La point de vente doit être composer des lettres de taille varie entre 4 et 70 carractére' >";?></td> </tr> <tr> <th>Type de Compte</th> <td> <select id="statut<?php echo $usr->id();?>" name="statut" class="form-control" <?php if ($_SESSION['GDEAL']['user']['statut'] != 1) echo "disabled";?> > <?php for($i=1;$i< count($statut_code);$i++) {echo "<option value=".$i.">".$statut_code[$i]."</option>";} ?> </select> <script>document.getElementById("statut<?php echo $usr->id();?>").value = "<?php echo $usr->statut(); ?>";</script> </td> </tr> <tr> <th>Autres Informations</th> <td><textarea class="form-control" name="desc" rows="3"><?php echo $usr->desc();?></textarea></td> </tr> </tbody> </table> </div> <div class="modal-footer"> <button type="button" class="btn btn-warning" data-dismiss="modal">Fermer</button> <button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> Enregistrer</button> </form> </div> </div> </div> </div> </td> </tr> <?php }?> </tbody> </table> </div> <!-- /.table-responsive --> </div> <!-- /.panel-body --> </div> <!-- /.panel --> </div> <!-- /.col-lg-12 --> </div> </div> <!-- /.container-fluid --> </div> <!-- /#page-wrapper --> </div> <!-- /#wrapper --> <div class="modal fade modal-primary" id="add" tabindex="-1" data-easein="flipXIn" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" id="myModalLabel">Ajouter Un Utilisateur</h4> </div> <div class="modal-body" > <table class="table table-striped"> <form name='frm' id='frm' action='' method='post'> <?php echo "<input type='hidden' name='op' value = 'add'>"; ?> <tbody> <tr> <th>CIN</th> <td><?php echo "<input type='text' class='form-control' name='cin' pattern='^[0-9]{7,9}$' placeholder='Le numéro de cin' title='Le numéro de cin doit être composer de 8 chiffres'>";?></td> </tr> <tr> <th>Nom * </th> <td><?php echo "<input type='text' class='form-control' name='nom' pattern='^[a-zA-Z0-9àâçéèêëîïôûùüÿñæœ _+-.,!@#$%^&*();\/|<>]{3,70}$' placeholder='Le nom' title='Le nom doit être composer des lettres de taille varie entre 4 et 70 carractére' required>";?></td> </tr> <tr> <th>Email *</th> <td><?php echo "<input type='email' class='form-control' name='email' placeholder='L `adresse mail' required>";?></td> </tr> <tr> <th>Mot de Passe *</th> <td> <?php echo "<input type='text' class='form-control' id='passwd' name='passwd' pattern='^[a-zA-Z0-9àâçéèêëîïôûùüÿñæœ _+-.,!@#$%^&*();\/|<>]{8,30}' placeholder='le Mot de passe' title='Le mot de passe doit être composer des chiffres et des lettres et de taille varie entre 8 et 30 carractéres.' required>"; ?> </td> </tr> <tr> <th>Téléphone</th> <td><?php echo "<input type='text' class='form-control' name='tel' pattern='^[0-9 +]{8,20}$' placeholder='Le numéro de téléphone' title='Le numéro de télépohne doit être composer entre 8 et 20 chiffres'>";?></td> </tr> <tr> <th>Point de Vente</th> <td><?php echo "<input type='text' class='form-control' name='pv' pattern='^[a-zA-Z0-9àâçéèêëîïôûùüÿñæœ _+-.,!@#$%^&*();\/|<>]{3,70}$' placeholder='La point de vente' title='La point de vente doit être composer des lettres de taille varie entre 4 et 70 carractére' >";?></td> </tr> <tr> <th>Type de Compte</th> <td> <select name="statut" class="form-control" > <?php for($i=1;$i< count($statut_code);$i++) {echo "<option value=".$i.">".$statut_code[$i]."</option>";} ?> </select> </td> </tr> <tr> <th>Autres Informations</th> <td><textarea class="form-control" name="desc" rows="3"></textarea></td> </tr> </tbody> </table> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Fermer</button> <button type="submit" class="btn btn-primary"><i class="fas fa-save"></i> Enregistrer</button> </form> </div> </div> </div> </div> <!-- jQuery --> <script src="../bower_components/jquery/dist/jquery.min.js"></script> <!-- Bootstrap Core JavaScript --> <script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script> <!-- Metis Menu Plugin JavaScript --> <script src="../bower_components/metisMenu/dist/metisMenu.min.js"></script> <!-- Custom Theme JavaScript --> <script src="../dist/js/sb-admin-2.js"></script> <!-- Page-Level Demo Scripts - Tables - Use for reference --> <link href="../datatable/jquery.dataTables.css" rel="stylesheet"> <link href="../datatable/responsive.dataTables.css" rel="stylesheet"> <script src="../datatable/jquery.dataTables.js"></script> <script src="../datatable/dataTables.responsive.js"></script> <script src='../js/velocity.min.js'></script> <script src='../js/velocity.ui.min.js'></script> <script> $.extend( $.fn.dataTable.defaults, { responsive: true } ); $(document).ready(function() { $('#dataTables-user').DataTable( { "language": { "sProcessing": "Traitement en cours...", "sSearch": "Rechercher&nbsp;:", "sLengthMenu": "Afficher _MENU_ &eacute;l&eacute;ments", "sInfo": "Affichage de l'&eacute;l&eacute;ment _START_ &agrave; _END_ sur _TOTAL_ &eacute;l&eacute;ments", "sInfoEmpty": "Affichage de l'&eacute;l&eacute;ment 0 &agrave; 0 sur 0 &eacute;l&eacute;ment", "sInfoFiltered": "(filtr&eacute; de _MAX_ &eacute;l&eacute;ments au total)", "sInfoPostFix": "", "sLoadingRecords": "Chargement en cours...", "sZeroRecords": "Aucun &eacute;l&eacute;ment &agrave; afficher", "sEmptyTable": "Aucune donn&eacute;e disponible dans le tableau", "oPaginate": { "sFirst": "Premier", "sPrevious": "Pr&eacute;c&eacute;dent", "sNext": "Suivant", "sLast": "Dernier" }, "oAria": { "sSortAscending": ": activer pour trier la colonne par ordre croissant", "sSortDescending": ": activer pour trier la colonne par ordre d&eacute;croissant" } } } ); } ); // add the animation to the modal $( ".modal" ).each(function(index) { $(this).on('show.bs.modal', function (e) { var open = $(this).attr('data-easein'); if(open == 'shake') { $('.modal-dialog').velocity('callout.' + open); } else if(open == 'pulse') { $('.modal-dialog').velocity('callout.' + open); } else if(open == 'tada') { $('.modal-dialog').velocity('callout.' + open); } else if(open == 'flash') { $('.modal-dialog').velocity('callout.' + open); } else if(open == 'bounce') { $('.modal-dialog').velocity('callout.' + open); } else if(open == 'swing') { $('.modal-dialog').velocity('callout.' + open); }else { $('.modal-dialog').velocity('transition.' + open); } }); }); </script> </body> </html>