<?php 
 
 
 require("buda_myStock_class.php");
 $mcon = new  buda_myStock_class();

  $searchValue=$_POST['searchValue'];
 	$dD=$mcon->getItemBySearch($searchValue); 
  if($dD->rowCount()>0){
  $roN=$dD->fetchAll(); 
?>
<center>

<table border="1" id="output" style="border-color:white;">
    
            <tr class="tr1"><td id="td_height" ><label id="inner_top">NAME</label></td>WEIGHT / VOLUME<td><label id="inner_top">CATEGORY</label></td>
              <td><label id="inner_top">SHOP CATEGORY</label></td>

               <!-- <td id="td_height" ><label id="inner_top">MANUFACTURE/VENDOR</label></td>


                <td id="td_height" ><label id="inner_top">DESCRIPTION</label></td>-->
 
 
                <td id="td_height" ><label id="inner_top">PRICE</label></td>  
            <td colspan="2" id="td_height" ><label id="inner_top">ORDER PLACEMENT</label></td>
 
            </tr> 
           

 <?php 

  $shopid=$_POST['shopid'];
  $ownerD=$_POST['ownerD'];
  $ownID=$_POST['owniD'];
   require("../buda_connect.php");
   $con = new connect_class();
    $Acc=$con->getMyProfile($ownID); 
  if ($Acc->rowCount()>0)
     {
      $sAc=$Acc->fetch();
      $status=$sAc['accStatus'];
     }else{
      header("location:../home.php");
     } 
      ?><input type="hidden" name="accstatus" id="accstatus" value="<?php echo $status;?>"/>
      <?php
  $cc=0;
   foreach ($roN as $key => $rowN){
   $cc++; 
      $itemid=$rowN['itemid']; 
      $pD=$mcon->getThisShopItemPriceOther($itemid,$shopid,$ownerD);
      if($pD->rowCount()>0){
      $prowN=$pD->fetch();
      //foreach ($proN as $key => $prowN){ 
      //$nsD=$mcon->getShopName($shopid);

     // $nsroN=$nsD->fetch();
          
  
        ?>
 
 <tr class="tr2">
  <td id="td_height">

<!--<form action="itemMoreDetailOtherIn.php" method="post">
<input class="hi" type="hidden" name="owniD"  value="<?php// echo $ownID;?>"/>

<input class="hi" type="hidden" name="ownerD"  value="<?php //echo $prowN['ownerid'];?>"/>

<input class="hi" type="hidden" name="shopid"  value="<?php// echo $prowN['shopid'];?>"/>

<input class="hi" type="hidden" name="itemid"  value="<?php //echo $prowN["itemID"];?>"/>

<input class="hdf" type="submit" value="<?php //echo $rowN["itemname"];?>" name="post"/>

 </form>--><label id="inner_lab"> <?php echo $rowN["itemname"];?></label></td>

     <td><label id="inner_lab"><?php echo $rowN["itemtype"];?> </label></td>

     <td id="td_height" ><label id="inner_lab"><?php echo $rowN["itemcategory"];?> </label></td>

     <!--<td><label id="inner_lab"><?php //echo $rowN["vendor"];?> </label></td>

     <td><label id="inner_lab"><?php //echo $rowN["description"];?> </label></td>
-->
     <td >
     <input type="text" name="costs<?php echo $cc;?>"  id="costs<?php echo $cc;?>"  disabled="true" value="<?php echo $prowN["price"];?> " style="background-color:#edf1ff;;border:0px; color:#2f74a6;font-size:14px;font-weight:bold;width:50px;" >
    </td>
  
     </td>
  <td id="td_height">
     Quantity<br>  
     <sup id="rdns<?php echo $cc;?>"></sup>
        <input type="hidden" name="itemids<?php echo $cc;?>" id="itemids<?php echo $cc;?>" value="<?php echo $rowN['itemid'];?>"/>
         <input type="text" name="quantitys<?php echo $cc;?>" id="quantitys<?php echo $cc;?>" class="prof_info" /><br/>
         
  </td>
     <td id="td_height">
  <div style="position:relative;float:right; width:100px;background:green;border-radius:5px; display:none;" id="popups<?php echo $cc;?>" >

    <label style="color:#edf1ff;"> Total price:</label> <input type="text" name="prices<?php echo $cc;?>"  id="prices<?php echo $cc;?>"  disabled="true"   style="background-color:green;border:0px; color:#edf1ff;font-size:14px;font-weight:bold;width:95%;" >
    
        <input type="submit"   name="posts" value="CheckOut" id="submits" 

         style="background-color:green;border:0px; color:#2f74ff;font-size:14px;font-weight:bold;cursor:pointer;"

           onclick="var status=$('#accstatus').val(); if(status=='Active'){var shopid=$('#shopid').val();var ownID=$('#owniD').val(); var batchID=$('#batchID').val(); var quantity=$('#quantitys<?php echo $cc;?>').val();var cost=$('#prices<?php echo $cc;?>').val(); var itemid =$('#itemids<?php echo $cc;?>').val();if(quantity!='') {$.post('orderPro.php',{itemid:itemid,owniD:ownID,shopid:shopid,quantity:quantity,cost:cost,batchID:batchID},function(data){$('#ordercart').html(data).show();}); $('#posts<?php echo $cc;?>').show(); $('#popups<?php echo $cc;?>').hide();} else{document.getElementById('rdns<?php echo $cc;?>').innerHTML='Valide quantity required!..';}} else{
            document.getElementById('rdns<?php echo $cc;?>').innerHTML='Verification of your account is needed..Please sent your identity card photocopy via email:buda.co.tz@gmail.com or whatAp number:255 758 912 113 for account verification!..';
           }" />

           <input type="submit"   name="cancels" value="Cancel" id="cancels" 

         style="background-color:green;border:0px; color:red;font-size:14px;font-weight:bold;cursor:pointer;"

          onclick="document.getElementById('quantitys<?php echo $cc;?>').value=''; document.getElementById('prices<?php echo $cc;?>').value='';  $('#posts<?php echo $cc;?>').show(); $('#popups<?php echo $cc;?>').hide();" />
        </div>

        <input type="submit"   name="posts<?php echo $cc;?>" value="Order now" id="posts<?php echo $cc;?>" class="spos"  

          onclick="var cost=$('#costs<?php echo $cc;?>').val();  var quantity=$('#quantitys<?php echo $cc;?>').val(); var nC =/[0-9]/i; var i=0, j=0; if(quantity==''){ document.getElementById('rdns<?php echo $cc;?>').innerHTML='Quantity are required!..';}else{for(i=0;i<quantity.length;i++){if(!quantity[i].match(nC)){
             j++;}} if(j>0){ document.getElementById('rdns<?php echo $cc;?>').innerHTML='Quantity typed with error!..';}else{ document.getElementById('rdns<?php echo $cc;?>').innerHTML='';var tp=cost*quantity;$('#posts<?php echo $cc;?>').hide(); $('#popups<?php echo $cc;?>').show();document.getElementById('prices<?php echo $cc;?>').value=tp;
              }
   }
 
    j=0, i=0;
          " />
  </td>

   </tr> 
      
 
   
<?php
  
}

}
$cc=0;
?>
      
        </table>

        </center>
          
<?php


}//CLOSE IF OF BUTTON POST
  
 else{
?>
<center>
     <table class ="roomtab">
  


          <tr class="tr2">
            <td colspan="2" align="center"><label id="min_lab"><?php echo $searchValue;?> not found!..</label></td>
          </tr>

     </table>
  </center>
<?php

}

?>