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

{

  $searchValue= $_POST['searchValue'];
                       //CHECKING ENDS HERE
  require_once "labClass.php";
  
  $con = new labClass();
  
 $chkp= $con->getItemBySearch($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>CATEGORY</h6></small>
      </th>
      
      <th>
        <small><h6>P. PRICE</h6></small>
      </th>
      <th>
        <small><h6>S. PRICE</h6></small>
      </th>

       <th>
        <small><h6>ADD QTY</h6></small>
      </th>
        <th>
        <small><h6>SAVE</h6></small>
       
      </th>
      <th>
        <small><h6>EDIT</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="text" style="background-color:white;border-radius:12px; width:100%;" disabled="true" name="icat<?php echo $cc;?>" id="icat<?php echo $cc;?>"  value="<?php echo $p['icat'];?>" />
  </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="date" style="background-color:white;border-radius:12px; width:100%;"  name="exp<?php echo $cc;?>" id="exp<?php echo $cc;?>" />
  </td>
  <td> 
        <input type="submit" name="add<?php echo $cc;?>" id="add<?php echo $cc;?>" value="Add" id="submit" onclick="var sdate=$('#sdate').val();var agentid = document.getElementById('ph').innerHTML; var user=$('#user').val();expd=$('#exp<?php echo $cc;?>').val();icat=$('#icat<?php echo $cc;?>').val();isprice=$('#sprice<?php echo $cc;?>').val(); var iname=$('#inam<?php echo $cc;?>').val();ipprice=$('#iprice<?php echo $cc;?>').val();    if(expd!=''&& icat!=''&& agentid!=''&& sdate!=''&& isprice!='' && iname!=''&& user!=''  && ipprice!='' ) {$.post('pharmNewAgentPro.php',{expd:expd,icat:icat,agentid:agentid,user:user,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>
   <td>
     <input type="submit"  name="postEdit<?php echo $cc;?>" id="postEdit<?php echo $cc;?>" value="Edit" id="submit" onclick="var itemID =$('#itemD<?php echo $cc;?>').val();var iname =$('#inam<?php echo $cc;?>').val();$.post('pharItemEditF.php',{itemID:itemID, iname:iname},function(data){$('#disp').html(data).show();});" />
  </td>
</tr> 
  <?php
}
$cc=0;
 ?> 
 <?php
}
}
   

  ?>