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

if( isset($_POST['shopid']) && isset($_POST['owniD']))
  {
 $shopid=$_POST['shopid'];
 $ownID=$_POST['owniD']; 
//////////////////
 ////////////// 
$getS=$myAgrocon->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');
  ?>
 
<label id="reg_form_tile_label">Sell item from stock the list!.. </label></p/> 
 
  <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">
    
    
    
    
    <!---////////////ALPHABETICAL SORT///////////---->
    <tr>
        <td colspan="9">
          <table   width="100%" >
        <tr>
           <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
    
           </td>
    
    
           <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
    
           </td>
           
           
           <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
           
           
           <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
    
           </td>
           
           
           <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
    
           </td>
           
           
           <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
    
           </td>
           
           
           <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
           <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
           
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
            <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
    
           </td>
           
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
           
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
            <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           
    
           </td>
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
           </td>
            <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
    
           </td>
           
            <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
    
           </td>
           
            <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
    
           </td>
            <td>
    
      
             <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
    
           </td>
           
       </tr>
    
    </table>   
            
        </td>
    </tr>
    
    
    
    
    
    <!---//////////ALPHABETICAL SORT END--->
    
  <tr>
   
      <td style="width:30%;" id="td_height" ><label id="inner_top">NAME</label>
      
       <form action="itemSalePointStaff.php" method="post">

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

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

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

                 </form>
      
      
      </td>  
 
 
             <td id="td_height" ><label id="inner_top">BUYING PRICE</label></td>
                
            <td id="td_height" ><label id="inner_top">SALE PRICE</label></td>
            
            <td id="td_height" ><label id="inner_top">CURRENT STOCK</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">EDIT DETAIL</label></td> -->
 
               <td id="td_height" ><label id="inner_top">NEW SALE</label></td>
               
               <td id="td_height" ><label id="inner_top">DATE </label></td>
               <td colspan="2" id="td_height" ><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;
   
    $post=$_POST['post'];
    if($post=="Order by sn"){
      $chkp= $myAgrocon->getAllItemCheck();
      }
      else if($post=="Order by name"){
        $chkp= $myAgrocon->getOrderNameAllItemCheck();
      }
    
       
      else if($post=="A" ||  $post=="B"  ||   $post=="C"  ||  $post=="D"  ||   $post=="E"  ||    $post=="F"  || $post=="G"  ||  $post=="H"  || $post=="I"  || $post=="J"  || $post=="K"  || $post=="L"  ||  $post=="M"  ||  $post=="N"  ||   $post=="P"  || $post=="O"   || $post=="Q"  || $post=="R"  ||$post=="S"  || $post=="T"  || $post=="U"  || $post=="V"  ||  $post=="W"  || $post=="X"  || $post=="Y"  ||  $post=="Z" ){
        $chkp= $myAgrocon->getNameByFLetterItemCheck($post);
        
        }
    else{
       $chkp= $myAgrocon->getAllItemCheck();//getShopItemPrices($shopid,$ownID);
       
        }
     
  if ( $chkp->rowCount()>0) {
       $chp=$chkp->fetchAll();
    
    foreach ($chp as $key => $p) {

    $itemid=$p['itemid'];
    $item=$myAgrocon->getCheckedShopItemPrices($itemid,$shopid,$ownID);//getThisItem($itemid);
    if ($item->rowCount()>0) {
    $c=$item->fetch();
      $itemcost=$c['buyprice']; 
      $cc++;
     
        ?>
   <tr>
      
     <td colspan="10" align="right">
       <sup id="rdn<?php echo $cc;?>"></sup>
     </td>
   </tr>
  <tr>
   
  <td valign="top" >
 
     <textarea style="width:95%;height:50px;text-align:left;" type="text"  name="itemname<?php echo $cc;?>" id="itemname<?php echo $cc;?>" disabled="true"/>
        <?php echo $p['itemname'];?>
 </textarea>
  </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="number" disabled="true" min="1" step="1" oninput="validity.valid||(value='');" 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">

        <input type="hidden" name="itemid<?php echo $cc;?>" id="itemid<?php echo $cc;?>" value="<?php echo $c['itemID'];?>"/>
        <input type="number" disabled="true" min="1" step="1" oninput="validity.valid||(value='');"  name="scost<?php echo $cc;?>" id="scost<?php echo $cc;?>" class="prof_info"  value="<?php echo $c['price'];?>"/><br/>
         
  </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="number" disabled="true" min="1" step="1" oninput="validity.valid||(value='');" name="cquantity<?php echo $cc;?>" id="cquantity<?php echo $cc;?>" class="prof_info"  value="<?php echo $c['quantity'];?>" /><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>
  
   
  
 <?php /* <td>
     <input type="submit"  name="postEdit<?php echo $cc;?>" id="postEdit<?php echo $cc;?>" value="Edit" id="submit" onclick="document.getElementById('scost<?php echo $cc;?>').disabled=false;document.getElementById('itemcost<?php echo $cc;?>').disabled=false;document.getElementById('currency<?php echo $cc;?>').disabled=false;" />
  </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="number" min="1" step="1" oninput="validity.valid||(value='');" name="quantity<?php echo $cc;?>" id="quantity<?php echo $cc;?>" class="prof_info" /><br/>
         
 </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="date" value="<?php echo date("Y-m-d");?>" name="dateBought<?php echo $cc;?>" id="dateBought<?php echo $cc;?>" class="prof_info" /><br/>
         
  </td>
  <td>
     

        <input type="submit"   name="qUpdate<?php echo $cc;?>" id="qUpdate<?php echo $cc;?>"value="Sell" id="submit" onclick="var itemname=$('#itemname<?php echo $cc;?>').val(); var cquantity=$('#cquantity<?php echo $cc;?>').val();var quantity=$('#quantity<?php echo $cc;?>').val(); if(parseInt(quantity)>parseInt(cquantity)){document.getElementById('rdn<?php echo $cc;?>').innerHTML='Invalid item quantity!..'; }else{var shopid=$('#shopids').val();var ownID=$('#owniDs').val();var dateBought=$('#dateBought<?php echo $cc;?>').val(); var scost = $('#scost<?php echo $cc;?>').val();cquantity = parseInt(cquantity) - parseInt(quantity);document.getElementById('cquantity<?php echo $cc;?>').value=cquantity;var currency=$('#currency<?php echo $cc;?>').val();var itemcost=$('#itemcost<?php echo $cc;?>').val(); var itemid =$('#itemid<?php echo $cc;?>').val();if(itemname!='' && cquantity!='' && quantity!=''&& currency!='' && scost!='' && itemcost!='' && dateBought!='' ) {$.post('saleItemPro.php',{itemname:itemname,dateBought:dateBought,cquantity:cquantity,quantity:quantity,scost:scost, itemid:itemid,owniD:ownID,currency:currency,shopid:shopid,itemcost:itemcost},function(data){$('#rdn<?php echo $cc;?>').html(data).show();document.getElementById('quantity<?php echo $cc;?>').value='';});} else{document.getElementById('rdn<?php echo $cc;?>').innerHTML='Valide and complete detail required!..';}}" />
  </td> 
  <?php /*
  !--<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> 
    --*/?>

 

</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('searchMyStockItemForSell.php',{searchValue:searchValue,shopid:shopid,owniD:ownID},function(data){
      $('#result').html(data);

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




