<?php 
 $cc=0;
      
 
if(isset($_POST["searchValue"]))

{

  $searchValue= $_POST['searchValue'];
            //CHECKING ENDS HERE

  require_once "labClass.php";
  
  $con = new labClass();
  
 $chkp= $con->getItemBySearchStore($searchValue); 
    
     
if ($chkp->rowCount()>0) {

  $chp=$chkp->fetchAll();
  ?>
  <table class="table"> 
  <th>
        <small><h6>S/N</h6></small>
      </th>

      <th>
        <small><h6>ITEM NAME</h6></small>
      </th>
       <th>
        <small><h6>STOCK</h6></small>
      </th>
      
      <th>
        <small><h6>P. PRICE</h6></small>
      </th>
      <th>
        <small><h6>S. PRICE</h6></small>
      </th>
     <th>
        <small><h6>WHY DUMP</h6></small>
      </th>
       <th>
        <small><h6>NO DEFECT</h6></small>
      </th>
        <th>
        <small><h6>DUMP</h6></small>
       
      </th>
       
<?php
 foreach ($chp as $key => $p) {
    $itemID=$p['itemID'];
      $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="itemD<?php echo $cc;?>" id="itemD<?php echo $cc;?>" value="<?php echo $p['itemID'];?>"/>
    <!--<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="inam<?php echo $cc;?>" id="inam<?php echo $cc;?>"><?php echo $p['iname'];?></textarea> 
  </td>
  <td>
  <input type="number" style="background-color:white;border-radius:12px; width:100%;" disabled="true" name="iQt<?php echo $cc;?>" id="iQt<?php echo $cc;?>"  value="<?php echo $p['iqty'];?>" />
  </td> 
  <td>
    <input type="number" style="background-color:white;border-radius:12px; width:100%;" disabled="true" name="iprice<?php echo $cc;?>" id="iprice<?php echo $cc;?>"  value="<?php echo $p['ipprice'];?>" />   
  </td>
  <td>
   <input type="number" style="background-color:white;border-radius:12px; width:100%;" disabled="true" name="sprice<?php echo $cc;?>" id="sprice<?php echo $cc;?>"  value="<?php echo $p['isprice'];?>" />  
  </td>
   <td>
    <input type="text" style="background-color:white;border-radius:12px; width:100%;"  name="defect<?php echo $cc;?>" id="defect<?php echo $cc;?>" />
  </td>
  <td>
    <input type="number" style="background-color:white;border-radius:12px; width:100%;"  name="nQt<?php echo $cc;?>" id="nQt<?php echo $cc;?>" />
  </td>
  <td> 
        <input type="submit" name="add<?php echo $cc;?>" id="add<?php echo $cc;?>" value="Dump" id="submit" onclick="var sdate=$('#sdate').val(); var user=$('#user').val();isprice=$('#sprice<?php echo $cc;?>').val();var defect=$('#defect<?php echo $cc;?>').val(); var iname=$('#inam<?php echo $cc;?>').val();ipprice=$('#iprice<?php echo $cc;?>').val(); var iqty=$('#iQt<?php echo $cc;?>').val(); var nQty=$('#nQt<?php echo $cc;?>').val(); var itemID =$('#itemD<?php echo $cc;?>').val();var tQty=0; tQty=parseInt(iqty)-parseInt(nQty); if(itemID!=''&& sdate!=''&& isprice!='' && defect!=''&& iname!=''&& user!='' && nQty!='' && ipprice!='' && iqty!='' && nQty <= iqty && nQty > 0) {document.getElementById('iQt<?php echo $cc;?>').value=tQty;document.getElementById('nQt<?php echo $cc;?>').value='';document.getElementById('defect<?php echo $cc;?>').value=''; $.post('storeDumpSearchPro.php',{defect:defect,user:user,itemID:itemID,tQty:tQty,nQty:nQty,isprice:isprice,ipprice:ipprice,iname:iname,sdate:sdate},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});} else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Valide item detail required!..';}" />
  </td>
  
</tr> 
  <?php
}
$cc=0;
 ?> 
 <?php
}
}
   

  ?>