<?php 
 $cc=0;
      
  require_once "labClass.php";
  
  $con = new labClass();
 
  ?>
  LPO CUSTOMER RECORDS
  <table>
  <tr>
    <td>
    <sup id="tr"></sup>
    <label for="cname" class="form-label">Search/Sort by: Name:</label>
   <input class="form-control" list="cnames" name="cname" id="cname" onchange="processData();">
   <datalist id="cnames">
    <?php
     $Q= $con->getCusListBcN();
     if ($Q->rowCount()>0) {
     $lb=
     $Q->fetchAll();
     foreach ($lb as $key => $l) {
      
      ?>
      <option value="<?php echo  $l["cname"];?>">  
             <?php
            
           }
           }
 
      ?>
      </datalist>

      </td>
        <td>
    <sup id="trp"></sup>
    <label for="phone" class="form-label">Phone:</label>
   <input class="form-control" list="phones" name="phone" id="phone" onchange="processDataP();">
   <datalist id="phones">
    <?php
     $Q= $con->getCusListBcP();
     if ($Q->rowCount()>0) {
     $lb=$Q->fetchAll();
     foreach ($lb as $key => $l) {
      
      ?>
      <option value="<?php echo  $l["phone"];?>">  
             <?php
            
           }
           }
 
      ?>
      </datalist>

      </td>
      <td>
         <sup id="trs"></sup>
    <label for="street" class="form-label">Street:</label>
   <input class="form-control" list="streets" name="street" id="street" onchange="processDataS();">
   <datalist id="streets">
    <?php
     $Q= $con->getCusListBcS();
     if ($Q->rowCount()>0) {
     $lb= $Q->fetchAll();
     foreach ($lb as $key => $l) {
      
      ?>
      <option value="<?php echo  $l["address"];?>">  
             <?php
            
           }
           }
 
      ?>
      </datalist>
      </td>
      <td>
         <sup id="trw"></sup>
    <label for="ward" class="form-label">Ward:</label>
   <input class="form-control" list="wards" name="ward" id="ward" onchange="processDataW();">
   <datalist id="wards">
    <?php
     $Q= $con->getCusListBcW();
     if ($Q->rowCount()>0) {
     $lb=$Q->fetchAll();
     foreach ($lb as $key => $l) {
      
      ?>
      <option value="<?php echo  $l["ward"];?>">  
             <?php
            
           }
           }
 
      ?>
      </datalist>
      </td>
      <td>
         <sup id="trd"></sup>
    <label for="district" class="form-label">District:</label>
   <input class="form-control" list="districts" name="district" id="district" onchange="processDataD();">
   <datalist id="districts">
    <?php
     $Q= $con->getCusListBcD();
     if ($Q->rowCount()>0) {
     $lb=$Q->fetchAll();
     foreach ($lb as $key => $l) {
      
      ?>
      <option value="<?php echo  $l["district"];?>">  
             <?php
            
           }
           }
 
      ?>
      </datalist>
      </td>
      <td>
         <sup id="trr"></sup>
    <label for="region" class="form-label">Region:</label>
   <input class="form-control" list="regions" name="region" id="region" onchange="processDataR();">
   <datalist id="regions">
    <?php
     $Q= $con->getCusListBcR();
     if ($Q->rowCount()>0) {
     $lb=$Q->fetchAll();
     foreach ($lb as $key => $l) {
      
      ?>
      <option value="<?php echo  $l["region"];?>">  
             <?php
            
           }
           }
 
      ?>
      </datalist>
      </td>
       
    </tr>
  </table>
  <div class="container-fluid " id="dpl">
  <table class="table"> 
  <th>
        <small><h6>S/N</h6></small>
      </th>

      <th>
        <small><h6>NAME CUSTOMER</h6></small>
      </th>
       <th>
        <small><h6>STREET</h6></small>
      </th>
       <th>
        <small><h6>WARD</h6></small>
      </th>
       <th>
        <small><h6>DISTRICT</h6></small>
      </th>
       <th>
        <small><h6>REGION</h6></small>
      </th>
      <th>
        <small><h6>PHONE NO</h6></small>
      </th>
     
      <th>
        <small><h6>DATE REGISTERED</h6></small>
      </th>
      
<?php
 
 $chkp= $con->getCus(); 
    
     
if ($chkp->rowCount()>0) {

  $chp=$chkp->fetchAll();
 foreach ($chp as $key => $p) {
    $recID=$p['recID'];
      $cc++; 
     
        ?>
   
  <tr>
   <td width="5%">
       <input type="hidden" name="recID<?php echo $cc;?>" id="recID<?php echo $cc;?>" value="<?php echo $p['recID'];?>"/>
    <!--<div class="input-group">
    <span class="input-group-text">-->

      <?php
          echo $cc;
       ?>  
      </td>
  <td width="30%">
  <a href="#" onclick=" var cname=document.getElementById('cn<?php echo $cc;?>').innerHTML;  if( cname!='') { $.post('pharmSsRFromCNLPO.php',{cname:cname},function(data){$('#dpl').html(data).show();}); } else{alert('Valide item detail required!..');}"><sup id="cn<?php echo $cc;?>"><?php echo $p['cname'];?></sup></a> 
  </td>
  <td>
  <?php echo $p['address'];?>
  </td> 
   <td>
  <?php echo $p['ward'];?>  
  </td>
   <td>
   <?php echo $p['district'];?> 
  </td>
   <td>
   <?php echo $p['region'];?>
  </td>
  <td>
    <?php echo $p['phone'];?>   
  </td>
  <td> 
   <?php echo $p['regD'];?>      
  </td>
</tr>
 
  <?php
}
$cc=0;
 ?>
 </table>
</div> 
 <?php
}
?>
<script type="text/javascript">

  function processDataP(){ 
var ecc=0; 
var  phone=document.getElementById('phone').value; 
$.trim(phone); 
var cname='';
var street='';
var ward='';
var district=''; 
var region='';
  //FIRST NAME VALIDATION
  
if(phone==""){ 

         ecc++;
         document.getElementById('trp').innerHTML="Item phone no is required!..";

             }
else{

document.getElementById('trp').innerHTML="";
    }
  
    if(ecc==0)
    { 
        $.post("pharmCusBySpecLPO.php",
          {phone:phone,cname:cname,street:street,ward:ward,district:district,region:region},
          function(data){
      $('#dpl').html(data).show();

    });
    }
 
} 
  function processDataR(){ 
var ecc=0; 
var  region=document.getElementById('region').value; 
$.trim(region); 
var cname='';
var street='';
var ward='';
var district=''; 
var phone='';
  //FIRST NAME VALIDATION
  
if(region==""){ 

         ecc++;
         document.getElementById('trr').innerHTML="Item region is required!..";

             }
else{

document.getElementById('trr').innerHTML="";
    }
  
    if(ecc==0)
    { 
        $.post("pharmCusBySpecLPO.php",
          {cname:cname,street:street,ward:ward,district:district,region:region},
          function(data){
      $('#dpl').html(data).show();

    });
    }
 
} 
  function processDataD(){ 
var ecc=0; 
var  district=document.getElementById('district').value; 
$.trim(district);  
var cname='';
var street='';
var ward=''; 
var region=''; 
var phone='';
  //FIRST NAME VALIDATION
  
if(district==""){ 

         ecc++;
         document.getElementById('trd').innerHTML="Item customer is required!..";

             }
else{

document.getElementById('trd').innerHTML="";
    }
  
    if(ecc==0)
    { 
        $.post("pharmCusBySpecLPO.php",
          {cname:cname,street:street,ward:ward,district:district,region:region},
          function(data){
      $('#dpl').html(data).show();

    });
    }
 
} 
  function processDataW(){ 
var ecc=0; 
var ward =document.getElementById('ward').value; 
$.trim(ward);  
var cname='';
var street=''; 
var district='';
var region=''; 
var phone='';
  //FIRST NAME VALIDATION
  
if(ward==""){ 

         ecc++;
         document.getElementById('trw').innerHTML="Item ward is required!..";

             }
else{

document.getElementById('trw').innerHTML="";
    }
  
    if(ecc==0)
    { 
        $.post("pharmCusBySpecLPO.php",
          {cname:cname,street:street,ward:ward,district:district,region:region},
          function(data){
      $('#dpl').html(data).show();

    });
    }
 
} 
function processDataS(){ 
var ecc=0; 
var  street=document.getElementById('street').value; 
$.trim(street);  
var cname=''; 
var ward='';
var district='';
var region=''; 
var phone='';
  //FIRST NAME VALIDATION
  
if(street==""){ 

         ecc++;
         document.getElementById('trs').innerHTML="Item street is required!..";

             }
else{

document.getElementById('trs').innerHTML="";
    }
  
    if(ecc==0)
    { 
        $.post("pharmCusBySpecLPO.php",
          {cname:cname,street:street,ward:ward,district:district,region:region},
          function(data){
      $('#dpl').html(data).show();

    });
    }
 
} 
function processData(){ 
var ecc=0; 
var cname =document.getElementById('cname').value; 
$.trim(cname);   
var street='';
var ward='';
var district='';
var region='';
var phone='';
  //FIRST NAME VALIDATION
  
if(cname==""){ 

         ecc++;
         document.getElementById('tr').innerHTML="Item customer is required!..";

             }
else{

document.getElementById('tr').innerHTML="";
    }
  
    if(ecc==0)
    { 
        $.post("pharmCusBySpecLPO.php",
          {cname:cname,street:street,ward:ward,district:district,region:region},
          function(data){
      $('#dpl').html(data).show();

    });
    }
 
} 

 </script>