
 <!-- DataTables -->
 <link rel="stylesheet" href="<link rel="stylesheet" 
	href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap.min.css">">

<div class="content-wrapper">








<section class="content">
  <div class="row">


    <div class="col-md-12">
      <div class="box">
      <?php

      if($alert=="ok") {

        if(!$success=="ok"){
          ?>
          <div class='alert alert-danger alert-dismissible'>
                      <button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×</button>
                      <h4><i class='icon fa fa-ban'></i> Error!</h4>
                      <?= $message; ?>
                    </div>

          <?php
      } else {
        ?>
        <div class="alert alert-success alert-dismissible">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
          <h4><i class="icon fa fa-check"></i> Success!</h4>
          <?= $message; ?>
        </div>

        <?php
      }
      }
       ?>
        <div class="box-header with-border">
          <h3 class="box-title"><?= $this->lang->line('Utilisateurs simples'); ?></h3>
        </div>
        <!-- /.box-header -->
        <div class="box-body" style="overflow-x:auto;">

          <?php

$result=$list;

if($result!=false){

$numrows=$result->num_rows();
$num = 0;
if ($numrows > 0) {


?>


              <table id="listeMembres" class="table table-bordered table-striped">
                  <thead>
                      <tr class="label-primary">
                          <th><?= $this->lang->line('Nom'); ?></th>
                          <th><?= $this->lang->line('Pays'); ?></th>
                          <th><?= $this->lang->line('Adresse'); ?></th>
                          <th><?= $this->lang->line('Reseau'); ?></th>
                          <th><?= $this->lang->line('Email'); ?></th>
                          <th><?= $this->lang->line('Solde'); ?></th>
                          <th><?= $this->lang->line('Téléphone'); ?></th>
                          <th><?= $this->lang->line('Modifier'); ?></th>
                          <th><?= $this->lang->line('Supprimer'); ?></th>
                      </tr>
                  </thead>
                  <tbody>


                      <?php
$site_url = base_url();
                      $url = base_url('Listes_members/modif');
// output data of each row
foreach($result->result() as $row) {
$num++;
echo "<tr>

<td>$row->lastname </td>
<td>$row->country</td>
<td>$row->adresse</td>
<td>$row->network</td>
<td>$row->email </td>
<td> $row->solde</td>
<td>$row->phone</td>
<td>
    <a id='modal-497395".$num."' href='#modal-container-497395".$num."' class='btn btn-app' role='button' role='button' data-toggle='modal'><i class='fa fa-edit'></i>".$this->lang->line('Modifier')."</a>
    <div class='modal fade' id='modal-container-497395".$num."' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>
        <div class='modal-dialog'>
            <div class='modal-content'>
                <div class='modal-body'>
                  <h4 class='modal-title' id='myModalLabel'>".$this->lang->line('Mettre à jour des informations')."<hr class='colorgraph'></h4>
                    <form action='$url' id='form-horizontal'   method='POST' >
                        <div class='control-group'>
                            <label class='control-label' for='inputEmail' >".$this->lang->line('Nom')."</label>
                            <div class='controls'>
                                <input id='nom' type='text' name='nom' class='form-control input-sm' value='$row->lastname'/>
                            </div>
                        </div>
                        <div class='control-group'>
                            <label class='control-label' for='inputEmail' >".$this->lang->line('Adresse')."</label>
                            <div class='controls'>
                                <input id='adresse' type='text' name='adresse' class='form-control input-sm' value='$row->adresse'/>
                            </div>
                        </div>
                        <div class='control-group'>
                            <label class='control-label' for='inputEmail'>".$this->lang->line('Reseau')."</label>
                            <div class='controls'>
                                <input id='inputEmail' type='text' name='reso' class='form-control input-sm' value='$row->network' readonly/>
                            </div>
                        </div>
                        <div class='control-group'>
                            <label class='control-label' for='inputEmail'>".$this->lang->line('code membre')."</label>
                            <div class='controls'>
                                 <input id='inputEmail' type='text' name='cmbre' class='form-control input-sm' value='$row->user_id' readonly>
                            </div>
                        </div>
                        <div class='control-group'>
                            <label class='control-label' for='inputEmail'>".$this->lang->line('Email')."</label>
                            <div class='controls'>
                                <input id='inputEmail' type='email' name='email' class='form-control input-sm' value='$row->email'/>
                            </div>
                        </div>
                        <div class='control-group'>
                            <label class='control-label' for='inputEmail' >".$this->lang->line('Téléphone')."</label>
                            <div class='controls'>
                                <input id='inputEmail' type='text' name='tel' class='form-control input-sm' value='$row->phone' readonly/>
                            </div>
                        </div>
                        <hr class='colorgraph'>
                        <input name='modifbtn' type='Submit' class='btn btn-primary' value='Sauvegarder'/>

&nbsp;
<button type='button' class='btn btn-default' data-dismiss='modal'>
  ".$this->lang->line('Fermer')."
</button>
</form>
</div>
</div>
</div>
</div>



</td>

<td>
<a href='#myModal-1".$num."' role='button' class='btn btn-app btn-danger' data-toggle='modal'><i class='fa fa-remove'></i>".$this->lang->line('Supprimer')."</a>
<div class='modal fade' id='myModal-1".$num."' tabindex='-1' role='dialog' aria-labelledby='myModalLabel' aria-hidden='true'>



<div class='modal-dialog'>
  <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'>".$this->lang->line('Confirmer la suppression')."</h4>
    </div>
    <div class='modal-body'>
      <p class='error-text'><i class='icon-warning-sign modal-icon'></i>".$this->lang->line('Message suppression')." ". $row->phone."?</p>
    </div>
    <div class='modal-footer'>
      <button type='button' class='btn btn-default pull-left' data-dismiss='modal'>".$this->lang->line('Fermer')."</button>
      <a href='".$site_url."Listes_members/suppr/?recordId=".$row->phone."' role='button' class='btn btn-danger'>
      ".$this->lang->line('Supprimer')."</a>
    </div>
  </div>
  <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>




</td>
 </tr>";
}
?>


                      <?php
} else {
echo "1 results";
}




?>


</tbody>
<tfoot>
    <tr>
        <th><?= $this->lang->line('Nom'); ?></th>
        <th><?= $this->lang->line('Pays'); ?></th>
        <th><?= $this->lang->line('Adresse'); ?></th>
        <th><?= $this->lang->line('Reseau'); ?></th>
        <th><?= $this->lang->line('Email'); ?></th>
        <th><?= $this->lang->line('Solde'); ?></th>
        <th><?= $this->lang->line('Téléphone'); ?></th>
        <th><?= $this->lang->line('Modifier'); ?></th>
        <th><?= $this->lang->line('Supprimer'); ?></th>
    </tr>
</tfoot>
              </table>

<?php
    }else{
        echo "Aucun utilisateur simple à afficher";
    }
?>
        </div>
        <!-- /.box-body -->

      </div>
      <!-- /.box -->


    </div>
    <!-- /.col -->

  </div>
  <!-- /.row -->

  </section>

  </div>
  <!-- jQuery 2.2.4 -->
  <script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>

  <!-- Bootstrap 3.3.7 -->
  <script src="<?= base_url('bower_components/bootstrap/dist/js/bootstrap.min.js') ?>"></script>
  <!-- DataTables -->
  <script src="<?= base_url('bower_components/datatables.net/js/jquery.dataTables.min.js') ?>"></script>
  <script src="<?= base_url('bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js') ?>"></script>
  <!-- SlimScroll -->
  <script src="<?= base_url('bower_components/jquery-slimscroll/jquery.slimscroll.min.js') ?>"></script>
  <!-- FastClick -->
  <script src="<?= base_url('bower_components/fastclick/lib/fastclick.js') ?>"></script>
  <!-- AdminLTE App -->
  <script src="<?= base_url('dist/js/adminlte.min.js') ?>"></script>
  <!-- AdminLTE for demo purposes -->
  <script src="<?= base_url('dist/js/demo.js') ?>"></script>

  <script>
    $(function () {
      $('#listeMembres').DataTable()

    })
  </script>

 <script type='text/javascript'>
     $(document).ready(function(){

         $('#pays').change(function(){
             var pays = $(this).val();
             $.ajax({
                 url:'<?= base_url('Admin/getHypByPays')?>',
                 type: 'post',
                 data: {pays: pays},
                 dataType: 'json',
                 success: function(data){
                     var len = data.length;


                     if(len > 0){

                         var select = document.getElementById('hyper');
                         if(select===null){
                             var grpPays = document.getElementById('grp-pays');
                             $(grpPays).empty();
                             $(grpPays).append("<select class='form-control input-lg' name='hyper' required id='hyper'></select>");
                             select = document.getElementById('hyper');
                         }
                         $(select).empty();

                         for (var i in data) {
                             $(select).append('<option value=' + data[i].code_membre + '>' + data[i].lastname +'-' + data[i].network + ' ('+ data[i].code_membre +')</option>');
                         }

                         var code = data[0].code_membre;

                         $.ajax({
                             url:'<?= base_url('Admin/getVilleByHyp')?>',
                             type: 'post',
                             data: {code: code,pays:pays},
                             dataType: 'json',
                             success: function(list){
                                 var len = list.length;

                                 if(len > 0){

                                     var select = document.getElementById('ville');
                                     if(select===null){
                                         var grpVille = document.getElementById('grp-ville');
                                         $(grpVille).empty();
                                         $(grpVille).append("<select class='form-control input-lg' name='ville' required id='ville'></select>");
                                         select = document.getElementById('ville');
                                     }
                                     $(select).empty();

                                     for (var i in list) {
                                         $(select).append('<option value=' + list[i].town_id + '>' + list[i].town +'</option>');
                                     }


                                 }else{

                                     var select = document.getElementById('ville');
                                     $(select).empty();

                                 }

                             }
                         });


                     }else{

                         var select = document.getElementById('hyper');
                         $(select).empty();

                         var select2 = document.getElementById('ville');
                         $(select2).empty();
                     }

                 }
             });
         });

         $('#hyper').change(function(){
             var code = $(this).val();
             $.ajax({
                 url:'<?= base_url('Admin/getVilleByHyp')?>',
                 type: 'post',
                 data: {code: code},
                 dataType: 'json',
                 success: function(list){
                     var len = list.length;

                     if(len > 0){

                         var select = document.getElementById('ville');
                         $(select).empty();

                         for (var i in list) {
                             $(select).append('<option value=' + list[i].town_id + '>' + list[i].town +'</option>');
                         }

                     }else{

                         var select = document.getElementById('ville');
                         $(select).empty();

                     }

                 }
             });
         });
     });
 </script>
