
 <div class="container mt-3" style="width:100%;">

 <div class="container mt-3" style="width:100%;">
<!--SEARCH BOX-->
   <div class="row">
    <div class="col">
      <h6>ADD TOOL KIT USED:</h6>
    <div class="form-floating mb-3 mt-3"> 
      <input type="text" onkeyup ="submision()" class="form-control" id="tname" style="width:74%; height:20px;" placeholder="Test name" name="tname" required>
       <label for="tname">Search for test:</label> 
    </div>
</div> 
</div>

<!-- SEARCH BOX END-->

</div>

 </div>
 <div id="dispR">
   
 <?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>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="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(iQty)-parseInt(nQty); 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('addLabToolkitUsedPro.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
}
?>
</div>

 

 <script>

  function submision(){
    
    var searchValue=$('#tname').val();

    
 ;
    $('#dispR').empty();
    $.post('addLabToolkitUsedSearch.php',{searchValue:searchValue},function(data){
      $('#dispR').html(data);

    });
  }
 

 
 function saveData(){ 
var ecc=0; 
var iname =document.getElementById('iname').value; 
$.trim(iname);
var submit =document.getElementById('submit').value;

var iQty =document.getElementById('iQty').value; 
  
var vN =/[\(A-Za-z)]/g; 

var nV =/[a-z\s]/i;
  var j=0,k=0, g=0,i=0;

                                                         //FIRST NAME VALIDATION
  
if(  iQty==""){ 

         ecc++;
             document.getElementById('q').innerHTML="Quantity is required!..";
 

               }
else{

document.getElementById('q').innerHTML="";
    }
     
if(  iname==""){ 

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

               }
else{

document.getElementById('in').innerHTML="";
    }
  
    if(ecc==0)
    { 
        $.post("toolkitRegPro.php",
          {submit:submit,iname:iname,iQty:iQty},
          function(data){
      $('#disp').html(data).show();

    });
    }
 
} 
 
 
</script>