 <?php 
 
if( isset($_POST['shopid']) && isset($_POST['owniD']))
  {
  require_once('../buda_pharmacy_class.php');
  $pcon= new buda_pharmacy_class();
 $shopid=$_POST['shopid'];
 $ownID=$_POST['owniD']; 
 $searchValue=$_POST['searchValue'];
//////////////////
 ////////////// 
$getS=$pcon->getSelectedShopOther($shopid);
 if ($getS->rowCount()>0) {
  $shop=$getS->fetch();
 }
    
      
?> 
 
  
 
   <!--NEW USER REGISTRATION FORM, DISPLAYED BY DEFAULTS IN PAGE LOAD-->


<center>
 

<table border="1" style="border-color:white;" id="reg_form_table">
  <tr>
      <td id="td_height" ><label id="inner_top">S/N</label></td>
      <td id="td_height" ><label id="inner_top">NAME</label></td> <td><label id="inner_top">WEIGHT / VOLUME</label></td>
              <td><label id="inner_top">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  ><label id="inner_top">SELLING CURRENCY</label></td>
                <td id="td_height" ><label id="inner_top">BEST SUPPLY</label></td>
                <td  ><label id="inner_top">OPERATION</label></td> 
 
 
                </tr>  

 <input class="hi" type="hidden" name="owniDs" id="owniDs" value="<?php echo $ownID;?>">


   <input class="hi" type="hidden" name="shopids" id="shopids"  value="<?php echo $shopid;?>">


 <?php 
 $cc=0;
    $item=$pcon->getItemBySearch($searchValue);
    if ($item->rowCount()>0) {
    $pm=$item->fetchAll();
    foreach ($pm as $key => $p) {
      $itemid=$p['itemid'];
      $chk= $pcon->getThisShopItemPrice($itemid,$shopid,$ownID);
      $c=$chk->fetch();
      if ( $chk->rowCount()>0) {
       
      $cc++;
     
        ?>
   <tr>
      
     <td colspan="8" align="right">
       <sup id="rdn<?php echo $cc;?>"></sup>
     </td>
   </tr>
  <tr>
  <td >
 
     <?php
          echo $p['s_no'];
       ?>
  </td>
  <td >
 
     <?php
          echo $p['itemname'];
       ?>
  </td> 
  <td >
 
     <?php
          echo $p['itemtype'];
       ?>
  </td> 

  <td >
 
        <?php
            echo $p['itemcategory'];
         ?>
    </td> 
    <!-- <td >
 
        <?php
            //echo $p['vendor'];
         ?>
    </td> 
     <td >
 
        <?php
           // echo $p['description'];
         ?>
    </td> -->


  <!-- <td id="reg_form_table_cell">

        <input type="hidden" name="itemid<?php/* echo $cc;?>" id="itemid<?php echo $cc;?>" value="<?php echo $c['itemID'];?>"/>
         <input type="text" disabled="true" name="itemcost<?php echo $cc;?>" id="itemcost<?php echo $cc;?>" class="prof_info" value="<?php echo $c['buyprice'];?>" /><br/>
         
  </td>
  

  

  <td id="reg_form_table_cell">

    
         <select disabled ="false" name="currency<?php echo $cc;?>" id="currency<?php echo $cc;?>" class="prof_info">
          <option value="<?php echo $c['currency'];?>"><?php echo $c['currency'];?></option>
          <option value="TZS">TZS</option>
          <option value="USD">USD</option>
         </select>  
  </td>
  
 

  <td>
     <input type="submit"  name="postEdit<?php echo $cc;?>" id="postEdit<?php echo $cc;?>" value="Edit" id="submit" onclick="document.getElementById('itemcost<?php echo $cc;?>').disabled=false;document.getElementById('currency<?php echo $cc;?>').disabled=false;$('#postEdit<?php echo $cc;?>').hide();$('#postUpdate<?php echo $cc;?>').show();" />


        <input type="submit" class="hi" name="postUpdate<?php echo $cc;?>" id="postUpdate<?php echo $cc;?>"value="Update" id="submit" onclick="var shopid=$('#shopids').val();var ownID=$('#owniDs').val();var currency=$('#currency<?php echo $cc;?>').val();var itemcost=$('#itemcost<?php echo $cc;?>').val(); var itemid =$('#itemid<?php echo $cc;?>').val();if(currency!='' && itemcost!='') {$.post('updateStockPro.php',{itemid:itemid,owniD:ownID,currency:currency,shopid:shopid,itemcost:itemcost},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});document.getElementById('itemcost<?php echo $cc;?>').disabled=true;document.getElementById('currency<?php echo $cc;?>').disabled=true;$('#postUpdate<?php echo $cc;?>').hide();$('#postEdit<?php echo $cc;?>').show();} else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Valide price and currency required!..';}" />
  </td>-->*/?>






<!---///////////////////////////-->


<td id="reg_form_table_cell">

        <input type="hidden" name="itemid<?php echo $cc;?>" id="itemid<?php echo $cc;?>" value="<?php echo $c['itemID'];?>"/>
         <input type="text" disabled="true" name="itemcost<?php echo $cc;?>" id="itemcost<?php echo $cc;?>" class="prof_info" value="<?php echo $c['buyprice'];?>" /><br/>
         
          
         
  </td>
  

  

  <td id="reg_form_table_cell">

    
         <!--<select disabled ="false" name="currency<?php //echo $cc;?>" id="currency<?php // echo $cc;?>" class="prof_info"/>
          <option value="<?php //echo // $c['currency'];?>"><?php // echo $c['currency'];?></option>
          <option value="TZS">TZS</option>
          <option value="USD">USD</option>
         </select> --> 
         
          <select disabled ="false" name="currency<?php echo $cc;?>" id="currency<?php echo $cc;?>" class="prof_info">
          <option value="<?php echo $c['currency'];?>"><?php echo $c['currency'];?></option>
          <option value="TZS">TZS</option>
          <option value="USD">USD</option>
  </td>
  
   <td id="reg_form_table_cell">

        <input type="hidden" name="itemid<?php echo $cc;?>" id="itemid<?php echo $cc;?>" value="<?php echo $c['itemID'];?>"/>
         <input type="text" disabled="true" name="bestsupply<?php echo $cc;?>" id="bestsupply<?php echo $cc;?>" class="prof_info" value="<?php echo $c['bestsupply'];?>" /><br/>
         
  </td>

  <td>
     <input type="submit"  name="postEdit<?php echo $cc;?>" id="postEdit<?php echo $cc;?>" value="Edit" id="submit" onclick="document.getElementById('bestsupply<?php echo $cc;?>').disabled=false;document.getElementById('itemcost<?php echo $cc;?>').disabled=false;document.getElementById('currency<?php echo $cc;?>').disabled=false;$('#postEdit<?php echo $cc;?>').hide();$('#postUpdate<?php echo $cc;?>').show();" />


        <input type="submit" class="hi" name="postUpdate<?php echo $cc;?>" id="postUpdate<?php echo $cc;?>"value="Update" id="submit" onclick="var shopid=$('#shopids').val();var ownID=$('#owniDs').val();var currency=$('#currency<?php echo $cc;?>').val();var bestsupply=$('#bestsupply<?php echo $cc;?>').val();var itemcost=$('#itemcost<?php echo $cc;?>').val(); var itemid =$('#itemid<?php echo $cc;?>').val();if(currency!='' && itemcost!='' && bestsupply!='') {$.post('updateStockPro.php',{bestsupply:bestsupply,itemid:itemid,owniD:ownID,currency:currency,shopid:shopid,itemcost:itemcost},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});document.getElementById('bestsupply<?php echo $cc;?>').disabled=true;document.getElementById('itemcost<?php echo $cc;?>').disabled=true;document.getElementById('currency<?php echo $cc;?>').disabled=true;$('#postUpdate<?php echo $cc;?>').hide();$('#postEdit<?php echo $cc;?>').show();} else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Valide price and currency required!..';}" />
  </td>

<!--//////////////////////////////-->
</tr>
 
 
</form>
  <?php
}
}
 $cc=0;

 ?>
</table>
  
</center>
 <?php

    }
    else{
    echo "No item match!";
  }
  }
  else{
    echo "Error while processing!";
  }
  ?>
 





