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

if( isset($_POST['shopid']) && isset($_POST['owniD'])  && isset($_POST['ownerid']))
  {
 $shopid=$_POST['shopid'];
 $ownID=$_POST['owniD'];
 $ownerid=$_POST['ownerid']; 
//////////////////
 ////////////// 
$getS=$pcon->getSelectedShopOther($shopid);
 if ($getS->rowCount()>0) {
  $shop=$getS->fetch();
 }
    
        /////////////////

 

      
?> 
 
  
 
  <!--NEW USER REGISTRATION FORM, DISPLAYED BY DEFAULTS IN PAGE LOAD-->


<center>

 
   
 
<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">S/NO</label>
      
      
      <form action="newshopitempostStaff.php" method="post">

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


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

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

                 </form>
      
      </td>
      <td id="td_height" ><label id="inner_top">NAME</label>
      
      <form action="newshopitempostStaff.php" method="post">

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


                     <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><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 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;
  //$pcon->getItemPriceUpdate();
  
  
     $post=$_POST['post'];
     if($post=="Order by sn"){
      $item= $pcon->getAllItemCheck();
      }
      else if($post=="Order by name"){
         $item= $pcon->getOrderNameAllItemCheck();
      }
    else{
        $item= $pcon->getAllItemCheck();//getShopItemPrices($shopid,$ownID);
        }
  
  
  
  
  ////////////////
    //$item=$pcon->getItem();
    if ($item->rowCount()>0) {
    $pm=$item->fetchAll();
    foreach ($pm as $key => $p) {
      $itemid=$p['itemid'];
      $chk= $pcon->getThisShopItemPrice($itemid,$shopid,$ownID);
      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 $p['itemid'];?>"/>
         <input type="text" name="itemcost<?php echo $cc;?>" id="itemcost<?php echo $cc;?>" class="prof_info" /><br/>
         
  </td>
  
  <td id="reg_form_table_cell">

    
         <select name="currency<?php echo $cc;?>" id="currency<?php echo $cc;?>" class="prof_info"/>
        <!--  <option value="">select</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 $p['itemid'];?>"/>
         <input type="text" name="bestsupply<?php echo $cc;?>" id="bestsupply<?php echo $cc;?>" class="prof_info" /><br/>
         
  </td>

  <td   >
        <input type="submit"  name="post" value="add" 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 bestsupply=$('#bestsupply<?php echo $cc;?>').val(); var itemid =$('#itemid<?php echo $cc;?>').val();if(currency!='' && itemcost!='' && bestsupply !='') {$.post('createStockPro.php',{itemid:itemid,bestsupply:bestsupply,owniD:ownID,currency:currency,shopid:shopid,itemcost:itemcost},function(data){$('#rdn<?php echo $cc;?>').html(data).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>
</tr>
 
 
 
  <?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('searchItemForAddingInMyStock.php',{searchValue:searchValue,shopid:shopid,owniD:ownID},function(data){
      $('#result').html(data);

    });
  }
/*$(document).ready(function(){
 
$("#new_user_registration").on('submit',function(e){

// e.preventDefault(); ;  
var itemcost=document.getElementById('itemcost').value;
$.trim(itemcost);  

var currency=document.getElementById('currency').value;
$.trim(currency);
  
 
var vN =/[\(A-Za-z)]/g;
var nV =/[a-z\s]/i;
var nR =/[\sA-Za-z0-9]/i;
var nC =/[0-9]/i;
var j=0,k=0, g=0,i=0;
                      //////IMAGE VALIDATION
 
                                                         //ITEM COST DESTINATION VALIDATION
var nC =/[0-9]/i;
if(itemcost=="" || currency==""){
 e.preventDefault();

document.getElementById('rdn').innerHTML="Both price and currency are required!..";
 
 
              }
 else{

     for(i=0;i<itemcost.length;i++)
       {
         if(!itemcost[i].match(nC))
          {
             j++;

           }
        }
      
       if(j>0){
        e.preventDefault();

        document.getElementById('rdn').innerHTML="Item typed with error!.."; 
              }
         else{

        document.getElementById('rdn').innerHTML="";

              }
   }
 
    j=0, i=0;
                                    ///DESTINATION DISTANCE FROM LOCATION  
      
 
                                                                            ///ROOM ID VALIDATION
  
  
}
);
}
);  
    */
 
</script>


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


