 <?php
if($_POST["itemID"] && $_POST["iname"])
{ 
     
    $iname= $_POST['iname']; 
    $itemID= $_POST['itemID'];  
  //CHECKING ENDS HER
  require_once"labClass.php";
  $con=new labClass();
  $Q= $con->getThisItemBID($itemID,$iname);
  if($Q->rowCount()>0)
    {
  $p=$Q->fetch();
 ?>
 <div class="container mt-3" style="width:100%;">
<div id="disR"></div>
 <div  class="mt-4 p-5 bg-white text-dark rounded">
  <h6>Item editing:</h6> 
     
    <div class="row">
    <div class="col" >
        <sup class="text-danger" id="q"> </sup>
        <input type="hidden" name="itemID" id="itemID" value="<?php echo $p['itemID'];?>"/>
        <input type="hidden" id="iname0"  value="<?php echo $p['iname'];?>" name="iname0" required>
      <label for="iname">Name:</label>  
      <input type="text" class="form-control" id="iname" style="width:100%; height:35px; border-radius:12px; " value="<?php echo $p['iname'];?>" placeholder="Item name" name="iname" required>
      <sup class="text-danger" id="in"> </sup>
    </div>
     
    <div class="col" >
      <label for="icat">Category:</label>  
      <input type="text" class="form-control" id="icat" style="width:100%; height:35px; border-radius:12px; " placeholder="Category" name="icat" value="<?php echo $p['icat'];?>" required>
      <sup class="text-danger" id="ic"> </sup>
    </div>
    
  
   
 <div class="col" >
      <label for="ipprice">Purchase:</label>  
      <input type="number" class="form-control" id="ipprice" style="width:100%; height:35px; border-radius:12px; " placeholder="Purchase price" name="ipprice" value="<?php echo $p['ipprice'];?>" required>
      <sup class="text-danger" id="ip"> </sup>
    </div>
 </div>
<div class="row">
<div class="col" >
      <label for="isprice">Sales:</label>  
      <input type="number" class="form-control" id="isprice" style="width:100%; height:35px; border-radius:12px; " placeholder="Sales price" name="isprice" value="<?php echo $p['isprice'];?>" required>
      <sup class="text-danger" id="is"> </sup>
    </div>
    <div class="col"> 
      <label for="iQty">Qty:</label> 
      <input style="width:100%; height:35px; border-radius:12px;"  type="number" disabled="true" class="form-control"   id="iQty" placeholder="Item Qty" name="iQty" value="<?php echo $p['iqty'];?>" required>
     
    </div>
     <div class="col"> 
      <label for="expd">Expired:</label> 
      <input style="width:100%; height:35px; border-radius:12px;"  type="date" class="form-control"   id="expd" value="<?php echo $p['expd'];?>" placeholder="Expired" name="expd" required>
     <sup class="text-danger" id="ex"> </sup>
    </div>
    </div>
  <table class="table" border="0"><tr> <td> 
      <label for="wsprice">Whole sell:</label>  
      <input type="number" class="form-control" id="wsprice" style="width:100%; height:35px; border-radius:12px; " placeholder="Whole sells" name="wsprice" value="<?php echo $p['wsprice'];?>" required>
      <sup class="text-danger" id="ws"> </sup>
      

  </td><td width="80%" align="right">
  <button type="submit" class="btn btn-primary" id="submit" value="Submit" name="submit"  style="height:60px;" onclick="saveData()">Submit</button>
</div>

 </div>
 <div id="dispR">
 </div>
 <?php 
  
     }
  else{
       ?>
        <h6 class="text-danger">Item does not exist!..</h6>
       <?php
       }
       }
  else{
       ?>
       <h6 class="text-danger">All field required!..</h6>
       <?php
       }
?>
  
   
      

 

 <script>
function saveData(){ 
var ecc=0; 
var iname =document.getElementById('iname').value;
var inam0 =document.getElementById('iname0').value; 
$.trim(iname);
var icat =document.getElementById('icat').value; 
$.trim(icat);
var ipprice =document.getElementById('ipprice').value; 
$.trim(ipprice);
var isprice =document.getElementById('isprice').value; 
$.trim(isprice);
var wsprice =document.getElementById('wsprice').value; 
$.trim(wsprice);
var expd =document.getElementById('expd').value; 
$.trim(expd);
var itemID =document.getElementById('itemID').value; 
 
var submit =document.getElementById('submit').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(icat==""){ 

         ecc++;
         document.getElementById('ic').innerHTML="Category is required!..";

            }
else{
document.getElementById('ic').innerHTML="";
    }
 
if(ipprice==""){ 

         ecc++;
         document.getElementById('ip').innerHTML="Purchase price is required!..";

            }
else{
document.getElementById('ip').innerHTML="";
    }
if(isprice==""){ 

         ecc++;
         document.getElementById('is').innerHTML="Sales price is required!..";

            }
else{
document.getElementById('is').innerHTML="";
    }
    if(wsprice==""){ 

         ecc++;
         document.getElementById('ws').innerHTML="Whole sell price is required!..";

            }
else{
document.getElementById('ws').innerHTML="";
    }
if(expd==""){ 

         ecc++;
         document.getElementById('ex').innerHTML="Expire date is required!..";

            }
else{
document.getElementById('ex').innerHTML="";
    }
if(itemID==""){ 
         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("pharmUpdateDPro.php",
          {submit:submit,iname:iname,inam0:inam0,itemID:itemID,expd:expd,icat:icat,isprice:isprice,ipprice:ipprice,wsprice:wsprice},
          function(data){
      $('#disR').html(data).show();

    });
    }
 
} 
 
 
</script>
 