<?php
  /**** this section displays users details*****/
  session_start();
  include_once('../../config/class.php');
  $con = new DB;
  $user_id=$_SESSION['user_id'];
?>
 <table id="order-listing" class="table table-striped table-bordered table-sm">
                    <thead>
                      <tr>
                        <th>#</th>
                        <th>Sacco Name</th>
                        <th>Location</th>
                        <th>Contact</th>
                        <th>Email</th>
                        <th>Phone</th>
                        <th>Action</th>
                      </tr>
                    </thead>
<?php
    $query = $con->getRows('saccos a, regions b', array('where'=>'a.region_id=b.region_id','order_by'=>'sacco_name asc'));
    echo"<tbody>";
    $i=0;
    if(!empty($query)){
        foreach($query as $row) {
        $i++;
        echo "
        <tr>
            <td>".$i."</td>
        <td>".$row['sacco_name']."<br>".$row['region_name']."</td>
        <td>".$row['location']."</td>
        <td>".$row['contact_person']."</td>
        <td>".$row['email']."</td>
        <td>".$row['phone']."</td>
        <td>"; ?>
        <div class="btn-toolbar mb-2 mb-md-0">
                <div class="btn-group mr-2 ">
                    <a href="update-sacco.php?id=<?php echo $row["sacco_id"]; ?>"  class="btn btn-sm btn-outline-primary"><i class="icon icon-edit"></i> Edit</a>

                    <button class="btn btn-sm btn-outline-danger btn_delete" data-id3="<?php echo $row["sacco_id"]; ?>" ><i class="icon icon-trash"></i> Delete</button>
                </div>
                </div>

        <?php echo" </td>
        </tr>"
        ;
        }
    }
    echo"</tbody>";
?>
</table>




 <script>
    (function($) {
      'use strict';
      $(function() {
        $('#order-listing').DataTable({
          "aLengthMenu": [
          [5, 10, 15, -1],
          [5, 10, 15, "All"]
          ],
          "iDisplayLength": 10
        });
      });
    })(jQuery);
  </script>
