<?php ob_start(); session_start();  if(!isset($_SESSION['sales'])){ header('location:login.php'); die();}
// include 'dbconn.php';
// include 'inc/functions.php';
$results=get_user();
include 'xyz.php';



   ?>
<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Outlet App</title>

 <?php include 'inc/toplinks.php'; ?>
</head>

<body id="page-top">

    <!-- Page Wrapper -->
    <div id="wrapper">


            <?php  include 'inc/menus.php';  ?>


        <!-- End of Sidebar -->

        <?php include 'inc/top.php';   ?>
                <!-- End of Topbar -->

                <!-- Begin Page Content -->
                <div class="container-fluid">

                    <!-- Page Heading -->
                   <?php  include 'inc/greet.php';  ?><br>
                   
                    <!-- DataTales Example -->
                    <div class="card shadow mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between bg-primary text-white"><h6 class="m-0 font-weight-bold text-white"># Customer Base </h6><div class="dropdown no-arrow">
<a class="dropdown-toggle" href="#" role="button" id="dropdownMenuLink"data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-ellipsis-v fa-sm fa-fw text-gray-400"></i></a>=<div class="dropdown-menu dropdown-menu-right shadow animated--fade-in" aria-labelledby="dropdownMenuLink"><a class="dropdown-item" href="#" data-toggle="modal" data-target="#view_cust_set"><i class="fa fa-filter text-dark"> Filter</i></a><a class="dropdown-item" href="#" id="export"><i class="fa fa-file text-dark"> Export</i></a></div></div></div>
                        <div class="card-body">
                            <div class="table-responsive">
<?php  include 'process.php';  ?>
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
     <div class="row" style="">

    <?php  
if(isset($_POST['sendFilter'])){ $filter = 1;
if(!empty($_POST['eqCourse'])){ $selCrs =' and cus_type='.$_POST['eqCourse'].'';  }else{
    $selCrs ='';
}
if(!empty($_POST['month'])){ $month =' and month='.$_POST['month'].'';  }else{
    $month ='';
}
if(!empty($_POST['year'])){ $year =' and year='.$_POST['year'].'';  }else{
    $year ='';
}
$query = ("SELECT * FROM customers where id!='' $selCrs $month $year ");
    }else{ $query ="SELECT * FROM customers ORDER by id DESC";

}
     ?>
</div>




<thead><tr><th>#</th><th>Name</th><th>Sex</th><th>Phone</th><th>Address</th><th>Cus Type</th><th>Date</th><th>TP</th><th>By</th>
    <th>Action</th></tr></thead>

<?php
$count=1;
foreach(QueryDB($query)as $reg_std){?>
<tbody><tr><td class="small text-dark"><?php echo $count++; ?></td><td class="small text-dark"><?php echo $reg_std['frm_name'];  ?></td><td class="small text-dark"><?php echo $reg_std['gender'];  ?></td>
 <td class="small text-dark"><?php echo $reg_std['frm_phone'];  ?><br><?php echo $reg_std['frm_email'];  ?></td>
 <td class="small text-dark"><?php echo $reg_std['address'];  ?>,<?php echo $reg_std['state'].','.$reg_std['country'];  ?></td><td class="small text-dark"><?php  echo get_cus_type($reg_std['cus_type']);  ?></td>
 <td class="small text-dark"><?php  echo ($reg_std['frm_date']);  ?></td><td class="small text-dark"><?php  echo QueryDB("SELECT COUNT(*) FROM payment where cus_id='".$reg_std['id']."'  ")->fetchColumn();  ?></td>
<td class="small text-dark"><?php  echo get_staff_name($reg_std['staff_code']);  ?></td><td class="small text-dark"><a  data-toggle="modal" class="btn btn-primary small text-dark" style="padding:4px;" data-target="#addReged<?php echo $count; ?>"><i class="fa fa-edit text-white"></i></a>&nbsp;&nbsp; <a href="?view_selCus=<?php echo $reg_std['id']; ?>" title="View Purchase" class="btn btn-dark small text-white" style="padding:3px;"><i class="fa fa-eye"></i></a></td></tr>

<!--Add a Registratin-->
<div class="modal fade" id="addReged<?php echo $count; ?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"><div class="modal-dialog" role="document">
<div class="modal-content"><div class="modal-header bg-secondary text-white"><h5 class="modal-title " id="exampleModalLabel">#Edit Customer - <span class="text-warning"><?php echo $reg_std['frm_name']; ?></span></h5>
   
<button class="close" type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button></div><div class="modal-body"><form action="" method="POST"><div class="row"><div class="form-group col-md-12"><input type="text" name="eqName" value="<?php echo $reg_std['frm_name'];  ?>" class="form-control" required placeholder="Full Name"></div><div class="form-group col-md-6"><input type="text" name="eqPhone" class="form-control" required placeholder="Phone Number" maxlength="11" minlength="11" value="<?php echo $reg_std['frm_phone'];  ?>"></div>
<div class="form-group col-md-6"><input type="text" name="eqEmail" class="form-control"  placeholder="Email" value="<?php echo $reg_std['frm_email'];  ?>"></div><div class="form-group col-md-6"><select class="form-control" required name="prog_type" >
<option value="">--Customer Type-</option> <?php   foreach(QueryDB("SELECT * FROM category") as $crs){?><option value="<?php echo $crs['id'];  ?>" <?php  if($crs['id']==$reg_std['cus_type']){echo 'selected';}  ?>><?php echo $crs['type'];  ?></option><?php }?></select></div>
<div class="form-group col-md-6"><select class="form-control" required name="eqSex">
  <option value="">--Sex-</option>  <option value="M" <?php  if($reg_std['gender']=='M'){echo 'selected';}  ?>>Male</option> <option value="F"  <?php  if($reg_std['gender']=='F'){echo 'selected';}  ?>>Female</option> </select></div><div class="form-group col-md-12"><textarea class="form-control" name="eqAddress" placeholder="Address"><?php echo $reg_std['address'];  ?></textarea></div><div class="form-group col-md-12"> <input type="hidden" name="where" value="<?php echo $reg_std['id'];  ?>">
<input type="submit" name="EditReg" value="modify" class="form-control btn btn-secondary">
</div></div></form>    </div><div class="modal-footer"><button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button></div></div></div></div>
<?php  } ?>

                                        
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                </div>
                <!-- /.container-fluid -->

            </div>
            <!-- End of Main Content -->



<?php include 'inc/foot.php';  include 'inc/bottom.php';include 'inc/modals.php';include 'js/foot_links.php';  ?>
</body>

</html>