<?php 
 $cc=0;
      
  require_once "labClass.php";
  
  $con = new labClass();
  
 $chkp= $con->getCusDepoList(); 
    ?>
     <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>
    
       
    </tr>
  </table>
   CUSTOMER DEPOSIT:
   <div id="dpl">
  <table class="table"> 
  <th>
        <small><h6>S/N</h6></small>
      </th>

      <th>
        <small><h6>NAME CUSTOMER</h6></small>
      </th>
      
      <th>
        <small><h6>C/DEPOSIT</h6></small>
      </th>
     
     <th>
        <small><h6>RETURN AMOUNT</h6></small>
      </th>
      <th>
        <small><h6>ACTION</h6></small>
      </th>
 
      
<?php
if ($chkp->rowCount()>0) {

  $chp=$chkp->fetchAll();
 foreach ($chp as $key => $p) {
    $recID=$p['recID'];
      $cc++; 
     
        ?>
 <tr>
     <td colspan="8">
       <sup id="rdn<?php echo $cc;?>" class="text-danger" ></sup>
     </td>
   </tr> 
  <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%">
         <textarea style="background-color:white; height:30px; width:95%;" disabled="true" name="cname<?php echo $cc;?>" id="cname<?php echo $cc;?>"><?php echo $p['cname']."(".$p['phone'].")";?></textarea> 
  </td>
  
  
  <td>
    <input type="number" style="background-color:white;border-radius:12px; width:100%;" disabled="true" name="depo<?php echo $cc;?>" id="depo<?php echo $cc;?>"  value="<?php echo $p['deposit'];?>" />   
  </td>
  <td>
    <input type="number" style="background-color:white;border-radius:12px; width:100%;"   name="depon<?php echo $cc;?>" id="depon<?php echo $cc;?>"  value="" />   
  </td>
  
  <td> 
        <input type="submit" name="adds<?php echo $cc;?>" id="adds<?php echo $cc;?>" value="Save" id="submit" onclick="var sdate=$('#sdate').val(); var user=$('#user').val();recID=$('#recID<?php echo $cc;?>').val(); var depon=$('#depon<?php echo $cc;?>').val(); var depo=$('#depo<?php echo $cc;?>').val(); var cname=$('#cname<?php echo $cc;?>').val();  if(recID!=''&& depo!=''&& depon!=''&& sdate!=''  && cname!=''&& user!='') { $.post('pharmcusDepositRevsPro.php',{depon:depon,depo:depo,user:user,recID:recID, cname:cname,sdate:sdate},function(data){$('#rdn<?php echo $cc;?>').html(data).show();}); } else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Valide item detail required!..';}" />
   
   
</tr> 
  <?php
}
$cc=0;
}
?>
  
 </table>
 </div>
 <script type="text/javascript">

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

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

             }
else{

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

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

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

             }
else{

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

    });
    }
 
} 

 </script>