<?php 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
 $cc=0;
      
  require_once "labClass.php";
  
  $con = new labClass();
if($_POST["cname"])
{
 $cname=$_POST["cname"]; 
 $chkp= $con->getThisCusRecByN($cname); 
}
 
if($_POST["phone"])
{
 $phone=$_POST["phone"]; 
 $chkp= $con->getThisCusRecByP($phone); 
} 
if ($chkp->rowCount()>0) {

  $chp=$chkp->fetchAll();
  ?>
  CUSTOMER DEPOSIT WITHDRAW:
 
  <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>DESCRIPTION</h6></small>
      </th>
     
       <th>
        <small><h6>AMOUNT TO WITHDRAW(WHOLE)</h6></small>
      </th>
       <th>
        <small><h6>QTY</h6></small>
      </th>
      <th>
        <small><h6>AMOUNT TO WITHDRAW(RETAIL)</h6></small>
      </th>
      <th>
        <small><h6>ACTION</h6></small>
      </th>
      
<?php
 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'];?></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 class="form-control" id="descrip<?php echo $cc;?>" name="descrip<?php echo $cc;?>" list="inames" onchange="var iname=$('#descrip<?php echo $cc;?>').val(); $.post('getAmount.php',{iname:iname},function(data){
      $('#dsp<?php echo $cc;?>').html(data);});">
<datalist id="inames">
<?php
 $Q= $con->getDrugList();
 if ($Q->rowCount()>0) {
 $lb=$Q->fetchAll();
     foreach ($lb as $key => $l){
      ?>
      <option value="<?php echo  $l["iname"];?>">  
             <?php
           }
           }
      ?></datalist>
  </td>
  <td colspan="3">
 <div class="row" id="dsp<?php echo $cc;?>">
    
  </div>
  </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 hqty=document.getElementById('hqty').innerHTML;var qty=$('#qty').val(); var user=$('#user').val();var recID=$('#recID<?php echo $cc;?>').val(); var wdepon=0; wdepon=$('#wPrice').val(); var depon=0; depon=$('#tPrice').val();alert(depon); alert(wdepon);var depo= 0;depo=$('#depo<?php echo $cc;?>').val(); var iname=$('#descrip<?php echo $cc;?>').val(); var cname=$('#cname<?php echo $cc;?>').val();  if(recID!=''&& depo!='' && depon!=''&& iname!=''&& sdate!=''  && cname!='' && qty!='' && hqty!='' && user!=''&& parseFloat(hqty)>=parseFloat(qty)  && parseFloat(depon) >= parseFloat(wdepon) && parseFloat(depo)>=(parseFloat(depon)*parseFloat(qty))) { $.post('pharmcusDwithDroPro.php',{qty:qty,iname:iname,depon:depon,depo:depo,user:user,recID:recID, cname:cname,sdate:sdate},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});document.getElementById('depo<?php echo $cc;?>').value=parseFloat(depo)-(parseFloat(depon)*parseFloat(qty)); } else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Invalid detail required!..';}" />
   
   
</tr> 
  <?php
}
$cc=0;
 ?> 
 <?php
}
  
  ?>
   <script>
 
function getCusN(){
    
    var iname=$('#descrip').val();
    //alert(iname);
    $('#dsp').empty();
    $.post('getAmount.php',{iname:iname},function(data){
      $('#dsp').html(data);});
     
  }
     </script>     