 <?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=$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');
  ?>
 
 
  
  
    <ul><li> <label id="main_lab"> ITEM SALE REPORT BY DATE OR ID HERE</label></li></ul> 
       <fieldset id="new_visitors_reg_form">
       <center>

           <sup>
               <?php
               $id="";
               $sdate= "";
               $edate= "";
               $post=$_POST['post'];
              
               
               if ($post=="Range of date")
                {$sdate= $_POST['sdate'];
               $edate= $_POST['edate'];
                  if($sdate=="" ||  $edate=="")
                  {
                  echo "Date range required!";
                  }
               }


                if ($post=="Date")
                {
               $sdate= $_POST['sdate'];
               $edate= $_POST['edate'];
                  if($sdate=="")
                  {
                  echo "Date required!";
                  }
               }

               if ($post=="Search")
                {
                  if($id=="")
                  {
                  echo "Item or order id required!";
                  }
               }
               ?>
            </sup>
        </center>
          <form action="saleReport.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;?>">
 

                              <label id="main_lab">Select date:</label>

                              <input  type="date" name="sdate" value="<?php echo $sdate;?>" >


                              <label style="padding-left:24%">

                              <input  type="date" name="edate" value="<?php echo $edate;?>"  >

                              </label><p/>

                              <label id="main_lab">Search by:</label>

                              <input class="pos" type="submit" value="Date" name="post"  >
                         
                             <label style="padding-left:27%">

                              <input class="pos" type="submit" value="Range of date" name="post">

                            </label><p/>


                              <label id="main_lab">Search by item id and order id:</label>

                              <input class="ssinput" type="text" value="" name="id"  >
                         
                            <label>

                              <input class="pos" type="submit" value="Search" name="post">

                            </label>

          </form>
        </fieldset>
  
  
   
<div id="result">
<table border="1" style="border-color:white;" id="reg_form_table">
    
    
    
    
    <!---////////////ALPHABETICAL SORT///////////---->
    <tr>
        <td colspan="8">
          <table   width="100%" >
        <tr>
           <td>
    
      
             <form action="saleReport.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="A" name="post">

                 </form>
    
           </td>
    
    
           <td>
    
      
             <form action="saleReport.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="B" name="post">

                 </form>
    
           </td>
           
           
           <td>
    
    
      
             <form action="saleReport.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="C" name="post">

                 </form>
           </td>
           
           
           
           <td>
    
      
             <form action="saleReport.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="D" name="post">

                 </form>
    
           </td>
           
           
           <td>
    
      
             <form action="saleReport.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="E" name="post">

                 </form>
    
           </td>
           
           
           <td>
    
      
             <form action="saleReport.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="F" name="post">

                 </form>
    
           </td>
           
           
           <td>
    
    
      
             <form action="saleReport.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="G" name="post">

                 </form>
           </td>
           
           <td>
    
    
      
             <form action="saleReport.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="H" name="post">

                 </form>
           </td>
           
           
            <td>
    
    
      
             <form action="saleReport.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="I" name="post">

                 </form>
           </td>
           
            <td>
    
      
             <form action="saleReport.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="J" name="post">

                 </form>
    
           </td>
           
            <td>
    
    
      
             <form action="saleReport.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="K" name="post">

                 </form>
           </td>
            <td>
    
    
      
             <form action="saleReport.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="L" name="post">

                 </form>
           </td>
           
           
            <td>
    
    
      
             <form action="saleReport.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="M" name="post">

                 </form>
           </td>
            <td>
    
    
      
             <form action="saleReport.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="N" name="post">

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="saleReport.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="O" name="post">

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="saleReport.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="P" name="post">

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="saleReport.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="Q" name="post">

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="saleReport.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="R" name="post">

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="saleReport.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="S" name="post">

                 </form>
           </td>
           
            <td>
    
      
             <form action="saleReport.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="T" name="post">

                 </form>
           
    
           </td>
            <td>
    
    
      
             <form action="saleReport.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="U" name="post">

                 </form>
           </td>
           
            <td>
    
    
      
             <form action="saleReport.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="V" name="post">

                 </form>
           </td>
            <td>
    
      
             <form action="saleReport.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="W" name="post">

                 </form>
    
           </td>
           
            <td>
    
      
             <form action="saleReport.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="X" name="post">

                 </form>
    
           </td>
           
            <td>
    
      
             <form action="saleReport.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="Y" name="post">

                 </form>
    
           </td>
            <td>
    
      
             <form action="saleReport.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="Z" name="post">

                 </form>
    
           </td>
           
       </tr>
    
    </table>   
            
        </td>
    </tr>
    
    
    
    
    
    <!---//////////ALPHABETICAL SORT END--->
    
  <tr>
    
      <td id="td_height" ><label id="inner_top">NAME</label>
      
       <form action="saleReport.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 id="td_height" ><label id="inner_top">UNIT BUYING PRICE</label></td>
                
            <td id="td_height" ><label id="inner_top">UNIT SALE PRICE</label></td>
            
            <td id="td_height" ><label id="inner_top"> QUANTITY</label></td>
            
           <td id="td_height" ><label id="inner_top">UNIT BUYING PRICE</label></td>
                
           <td id="td_height" ><label id="inner_top">UNIT SALE PRICE</label></td>
            
           <td  ><label id="inner_top">PROFIT</label></td>
                 
           
           <td id="td_height" ><label id="inner_top"> DATE SOLD</label></td>
                <!--<td ><label id="inner_top">EDIT DETAIL</label></td> 
 
               <td id="td_height" ><label id="inner_top">NEW ENTRY</label></td>
               
               <td id="td_height" ><label id="inner_top">DATE </label></td>
               <td colspan="2" id="td_height" ><label id="inner_top">UPDATE / DELETE </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 
  
    $sdate="";
    $edate="";
    $totalBuy=0;
    $totalSale=0;
     $cc=0;
      
    if($post=="Order by sn"){
     $item= $myAgrocon->getAllItemSoldCheck();//getAllItemCheck();
      }
      else if($post=="Order by name"){
       $item= $myAgrocon->getAllItemSoldCheck();//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" ){
        $item= $myAgrocon->getNameByFLetterItemSoldCheck($post);//getNameByFLetterItemCheck($post);
        
        }
   
     else if ($post=="Range of date")
         {
          if (isset($_POST['sdate']) && isset($_POST['edate'])) {
         
           $sdate= $_POST['sdate'];
           $edate= $_POST['edate']; 
           
           $item=$myAgrocon->getMyShopSaleByRange($shopid,$sdate,$edate);//getMyShopOrderByRange($shopid,$sdate,$edate); 
           }
        }
      
      else if ($post=="Date")
       
        {
         if (isset($_POST['sdate'])) {
         
           $sdate= $_POST['sdate']; 
           $item=$myAgrocon->getMyShopSaleByDate($shopid,$sdate);//getMyShopOrderByDate($shopid,$sdate);
          }
        }
    
     else{
       $item= $myAgrocon->getAllItemSoldCheck();//getAllItemCheck();//getShopItemPrices($shopid,$ownID);
       
        }
     
      
    if ($item->rowCount()>0) {
    $ci=$item->fetchAll();
    foreach ($ci as $key => $c) { 
      $cc++;
     
        ?>
   <tr>
      
     <td colspan="8" align="right">
       <sup id="rdn<?php echo $cc;?>"></sup>
     </td>
   </tr>
  <tr>
 
  <td >
 
     <?php
          echo $c['itemName'];
      ?>
  </td> 
  
    
      <td >
 
        <?php
            echo $c['buyprice'];
         ?>
    </td> 
     <td >
 
        <?php
            echo $c['price'];
         ?>
    </td> 
    <td >
 
        <?php
            echo $c['quantity'];
         ?>
    </td> 
    <td >
 
        <?php
            echo $c['buyprice']*$c['quantity'].$c['currency'];
            $totalBuy=$totalBuy+ $c['buyprice']*$c['quantity'];
         ?>
    </td> 
    <td >
 
        <?php
            echo $c['price']*$c['quantity'].$c['currency'];
            $totalSale=$totalSale+ $c['price']*$c['quantity'];
            $ccc=$c['currency'];
         ?>
    </td>
    <td >
 
        <?php
            echo ($c['price']*$c['quantity'])- ($c['buyprice']*$c['quantity']).$c['currency'];
         ?>
    </td>
     
    <td>
        <?php
        echo $c['dateSold'];
         ?>
    </td>
     
 

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

 ?>
 <tr>
     <td colspan="4" align="right">
         Total
     </td>
     
       <td >
 
        <?php
            echo  $totalBuy.$ccc;
         ?>
    </td> 
    <td >
 
        <?php
            echo $totalSale.$ccc;
         ?>
    </td>
      <td colspan="3">
         <?php
            echo ($totalSale-$totalBuy).$ccc;
         ?>
     </td>
 </tr>
</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');
?>




