 <?php 
   require_once("../head2Alts.php");
   if(isset($_POST['post']) || isset($_POST['submit']))
 {

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


<center>
  <?php
   require_once('shopNavLink.php');
  ?>
<!--<ul id="lipad">
        
                <li>
                 <form action="selectedShopItemDetail.php" method="post">

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


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

                    <input  class="spos" type="submit" value="<?php //echo $shop['shopname'];?>" name="post">

                 </form>

                </li>
   
             

                <li>
                 <form action="myShopIemListView.php" method="post">

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


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

                    <input  class="spos" type="submit" value="My stock" name="post">

                 </form>

                </li>
   
              <li>

        
                <form action="newshopitempost.php" method="post">

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


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

 

                      <input  class="spos" type="submit" value="New item" name="post">

                 </form>

          </li>

          <li>
        
                <form action="OrderToMyShop.php" method="post">

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


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

 

                      <input  class="spos" type="submit" value="New order" name="post">

                 </form>

       </li>

       <li>
        
                <form action="shopWorkersProfile.php" method="post">

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


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

 

                      <input  class="spos" type="submit" value="Workers" name="post"  >

                 </form>

       </li>
  </ul>-->

   
 
<label id="reg_form_tile_label">You can specify the price and selling currency to add the item in your stock from the list!.. </label></p/> 
<!--<form name="new_user_registration" id="new_user_registration" action="newshopitempost.php" method="POST" autocomplete="on" enctype="multipart/form-data">-->
  <table width="60%">
    <tr>
  <td  align="center">
    
      <form action="defaultShopingCenter.php" method="post">

            <label id="search_lab">
                       <i>
                          Search item here:-
                      </i> 
             </label>
                      <input type="text" class="hotel_info" height="25px" name="searchValue" id="searchValue"  onkeyup ="submision()">
                        <input class="hi" type="hidden" name="owniD" id="owniD" value="<?php echo $ownID;?>">


                      <input class="hi" type="hidden" name="shopid" id="shopid" value="<?php echo $shop['shopid'];?>">
 
                      <br/><i>You can search by name and category.</i>

            
      </form>
        
  </td>
</tr>
  </table>
<div id="result">
<table border="1" style="border-color:white;" id="reg_form_table">
  <tr><td id="td_height" ><label id="inner_top">NAME</label></td> <td><label id="inner_top">TYPE</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  colspan="2" ><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;
   $chk= $scon->getShopItemPrices($shopid,$ownID);
      if ( $chk->rowCount()>0) {
       $ch=$chk->fetchAll();
    
    foreach ($ch as $key => $c) {

    $itemid=$c['itemID'];
    $item=$scon->getThisItem($itemid);
    if ($item->rowCount()>0) {
    $p=$item->fetch();
      
      $cc++;
     
        ?>
   <tr>
      
     <td colspan="8" align="right">
       <sup id="rdn<?php echo $cc;?>"></sup>
     </td>
   </tr>
  <tr>
 
  <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  width="40%" align="justify" >
 
        <?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 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> 
    

    <td>
      


        <input type="submit"  name="postDelete<?php echo $cc;?>" id="postDelete<?php echo $cc;?>"value="Delete" id="submit" onclick="var shopid=$('#shopids').val();var ownID=$('#owniDs').val();  var itemid =$('#itemid<?php echo $cc;?>').val(); $.post('deleteItemFromStock.php',{ itemid:itemid,owniD:ownID, shopid:shopid},function(data){$('#rdn<?php echo $cc;?>').html(data).show();});  " />
  </td> 

<?php 
/*
  <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['price'];?>" /><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>
*/
?>
</tr>
 
 
</form>
  <?php
}
}
 $cc=0;

 ?>
</table>
</div> 
</center>
 <?php
}
    }
    else{
    echo "NETWORK ERROR!";
  }
  }
  else{
    echo "NETWORK ERROR!";
  }
  ?>
<script>

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

    var shopid=$('#shopid').val();

    var ownID=$('#owniD').val();
 ;
    $('#result').empty();
    $.post('searchMystockItemForEditing.php',{searchValue:searchValue,shopid:shopid,owniD:ownID},function(data){
      $('#result').html(data);

    });
  }
 
 
</script>
<?php
 require_once('../footerIns.php');
?>




