<?php include 'topmost.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 'toplinks.php'; ?>
</head>

<body id="page-top">

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


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


        <!-- End of Sidebar -->

        <?php include 'top.php';   ?>
 
                <div class="container-fluid">

                    <!-- Page Heading -->
                   <?php  include '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 frm_month='.$_POST['month'].'';  }else{
    $month ='';
}
if(!empty($_POST['year'])){ $year =' and frm_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>Branch</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 @get_branch_name($reg_std['branch']);  ?></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  if($reg_std['staff_code']=='online'){ echo 'Online';}else{ 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'];  ?>">


<div class=" form-group  col-md-12 mb-2">
<select onchange="toggleLGA(this);" name="pcountry" id="state" class="form-control" required>
<option value="" selected="selected">- Select State-</option>
<option value="Abia" <?php if($reg_std['country']=='Abia'){ echo 'selected';}  ?>>Abia</option>
<option value="Adamawa" <?php if($reg_std['country']=='Abia'){ echo 'selected';}  ?> >Adamawa</option>
<option value="AkwaIbom" <?php if($reg_std['country']=='AkwaIbom'){ echo 'selected';}  ?> >AkwaIbom</option>
<option value="Anambra" <?php if($reg_std['country']=='Anambra'){ echo 'selected';}  ?> >Anambra</option>
<option value="Bauchi" <?php if($reg_std['country']=='Bauchi'){ echo 'selected';}  ?> >Bauchi</option>
<option value="Bayelsa" <?php if($reg_std['country']=='Bayelsa'){ echo 'selected';}  ?> >Bayelsa</option>
<option value="Benue" <?php if($reg_std['country']=='Benue'){ echo 'selected';}  ?> >Benue</option>
<option value="Borno" <?php if($reg_std['country']=='Borno'){ echo 'selected';}  ?> >Borno</option>
<option value="Cross River" <?php if($reg_std['country']=='Cross River'){ echo 'selected';}  ?> >Cross River</option>
<option value="Delta" <?php if($reg_std['country']=='Delta'){ echo 'selected';}  ?> >Delta</option>
<option value="Ebonyi" <?php if($reg_std['country']=='Ebonyi'){ echo 'selected';}  ?> >Ebonyi</option>
<option value="Edo" <?php if($reg_std['country']=='Edo'){ echo 'selected';}  ?> >Edo</option>
<option value="Ekiti" <?php if($reg_std['country']=='Ekiti'){ echo 'selected';}  ?> >Ekiti</option>
<option value="Enugu" <?php if($reg_std['country']=='Enugu'){ echo 'selected';}  ?> >Enugu</option>
<option value="FCT" <?php if($reg_std['country']=='FCT'){ echo 'selected';}  ?> >FCT</option>
<option value="Gombe" <?php if($reg_std['country']=='Gombe'){ echo 'selected';}  ?> >Gombe</option>
<option value="Imo" <?php if($reg_std['country']=='Imo'){ echo 'selected';}  ?> >Imo</option>
<option value="Jigawa" <?php if($reg_std['country']=='Jigawa'){ echo 'selected';}  ?> >Jigawa</option>
<option value="Kaduna" <?php if($reg_std['country']=='Kaduna'){ echo 'selected';}  ?> >Kaduna</option>
<option value="Kano" <?php if($reg_std['country']=='Kano'){ echo 'selected';}  ?> >Kano</option>
<option value="Katsina" <?php if($reg_std['country']=='Katsina'){ echo 'selected';}  ?> >Katsina</option>
<option value="Kebbi" <?php if($reg_std['country']=='Kebbi'){ echo 'selected';}  ?> >Kebbi</option>
<option value="Kogi" <?php if($reg_std['country']=='Kogi'){ echo 'selected';}  ?> >Kogi</option>
<option value="Kwara" <?php if($reg_std['country']=='Kwara'){ echo 'selected';}  ?> >Kwara</option>
<option value="Lagos" <?php if($reg_std['country']=='Lagos'){ echo 'selected';}  ?> >Lagos</option>
<option value="Nasarawa" <?php if($reg_std['country']=='Nasarawa'){ echo 'selected';}  ?> >Nasarawa</option>
<option value="Niger" <?php if($reg_std['country']=='Niger'){ echo 'selected';}  ?> >Niger</option>
<option value="Ogun" <?php if($reg_std['country']=='Ogun'){ echo 'selected';}  ?> >Ogun</option>
<option value="Ondo" <?php if($reg_std['country']=='Ondo'){ echo 'selected';}  ?> >Ondo</option>
<option value="Osun" <?php if($reg_std['country']=='Osun'){ echo 'selected';}  ?> >Osun</option>
<option value="Oyo" <?php if($reg_std['country']=='Oyo'){ echo 'selected';}  ?> >Oyo</option>
<option value="Plateau" <?php if($reg_std['country']=='Plateau'){ echo 'selected';}  ?> >Plateau</option>
<option value="Rivers" <?php if($reg_std['country']=='Rivers'){ echo 'selected';}  ?> >Rivers</option>
<option value="Sokoto" <?php if($reg_std['country']=='Sokoto'){ echo 'selected';}  ?> >Sokoto</option>
<option value="Taraba" <?php if($reg_std['country']=='Taraba'){ echo 'selected';}  ?> >Taraba</option>
<option value="Yobe" <?php if($reg_std['country']=='Yobe'){ echo 'selected';}  ?> >Yobe</option>
<option value="Zamfara" <?php if($reg_std['country']=='Zamfara'){ echo 'selected';}  ?> >Zamafara</option>
            </select>
          </div>

          <div class="form-group col-md-12 mb-2">
           
            <select name="pstate" id="lga" class="form-control select-lga" required>
    <option value="<?php echo $reg_std['state']; ?>"><?php echo $reg_std['state']; ?></option>
            </select>
          </div>




<div class="form-group col-md-12"><label>Change Branch</label><select name="itemBranch" class="form-control col-md-12"  style="width:100%;" required><option value="">-Select-</option><?php foreach(QueryDB("SELECT * FROM branch where status=1 ORDER BY shrt_name ASC  ") as $rows){?>
    <option value="<?php echo $rows['id']; ?>" <?php if($rows['id']==$reg_std['branch']){ echo 'selected';}  ?>><?php echo $rows['shrt_name']; ?></option><?php } ?></select></div>

<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 'bottom_most.php'; ?>
</body>

</html>