<?php 
 $cc=0;
     
  require_once "labClass.php";
  
  $con = new labClass();
  
 $chkp= $con->getToolKitList(); 
    
     
if ($chkp->rowCount()>0) {

  $chp=$chkp->fetchAll();
  ?> 
 <div class="row">
      <div class="col">
        <small><h6>S/N-ITEM NAME</h6></small>
      </div>
       <div class="col">
        <small><h6>CURRENT QTY</h6></small>
      </div>
      <div class="col">
        <small><h6>EDIT</h6></small>
      </div>
       <div class="col">
        <small><h6>ADD QTY</h6></small>
      </div>
        <div class="col">
        <small><h6>SAVE</h6></small>
      </div>
    </div>

   
  <?php

 foreach ($chp as $key => $p) {

    $testID=$p['toolID'];
    
      $cc++; 
     
        ?>


 <div class="row">
      
     <div class="col">
       <sup id="rdn<?php echo $cc;?>" class="text-danger" ></sup>
     </div>
   </div> 
  <div class="row">
  
 
  
   <div class="col justify-content-center" >

       <input type="hidden" name="toolID<?php echo $cc;?>" id="toolID<?php echo $cc;?>" value="<?php echo $p['toolID'];?>"/>
    <!--<div class="input-group">
    <span class="input-group-text">-->

      <?php
          echo $cc;
       ?>  
         .<textarea style="height:30px; width:90%;" disabled="true" name="iname<?php echo $cc;?>" id="iname<?php echo $cc;?>"><?php echo $p['tName'];?></textarea><br/>
         
  
  </div>
  

  <div class="col">
        <input type="number" style="width:100%;" disabled="true" name="iQty<?php echo $cc;?>" id="iQty<?php echo $cc;?>"  value="<?php echo $p['tQty'];?>" />
  </div> 
    
  <div class="col">
     <input type="submit"  name="postEdit<?php echo $cc;?>" id="postEdit<?php echo $cc;?>" value="Edit" id="submit" onclick="document.getElementById('iname<?php echo $cc;?>').disabled=false;$('#postEdit<?php echo $cc;?>').hide();$('#postUpdate<?php echo $cc;?>').show();" />


        <input type="submit" style="display:none;" name="postUpdate<?php echo $cc;?>" id="postUpdate<?php echo $cc;?>"value="Update" id="submit" onclick="  var iname=$('#iname<?php echo $cc;?>').val(); var toolID =$('#toolID<?php echo $cc;?>').val();if(toolID!=''  && iname!='') {$.post('updateToolKitD.php',{toolID:toolID,iname:iname},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});document.getElementById('iname<?php echo $cc;?>').disabled=true;$('#postUpdate<?php echo $cc;?>').hide();$('#postEdit<?php echo $cc;?>').show();} else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Valide item detail required!..';}" />
  </div>
    
      <div class="col">
        <input type="number" style="width:100%;"  name="nQty<?php echo $cc;?>" id="nQty<?php echo $cc;?>" />
  </div>
  <div class="col"> 


        <input type="submit" name="add<?php echo $cc;?>" id="add<?php echo $cc;?>" value="Add" id="submit" onclick=" var iname=$('#iname<?php echo $cc;?>').val(); var iQty=$('#iQty<?php echo $cc;?>').val(); var nQty=$('#nQty<?php echo $cc;?>').val(); var toolID =$('#toolID<?php echo $cc;?>').val();var tQty=0; tQty=parseInt(nQty)+parseInt(iQty); if(toolID!='' && iname!='' && nQty!='' && iQty!='' && nQty > 0 && tQty > 0) {document.getElementById('iQty<?php echo $cc;?>').value=tQty;document.getElementById('nQty<?php echo $cc;?>').value=''; $.post('updateToolKitQty.php',{toolID:toolID,iQty:iQty,nQty:nQty,iname:iname,tQty:tQty},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});} else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Valide item detail required!..';}" />
  </div>
 
</div> 
 
  <?php
//}
}
  $cc=0;

 ?> 
 <?php
}
   

  ?>