<?php session_start();
if($_SESSION["user_id"]==true) {
} else {?><script> window.location.href='login/'; </script> <?php } 

include("connection.php");
error_reporting(E_ERROR | E_PARSE); 
 $pagename = basename($_SERVER['PHP_SELF']);

 $bill_no=$_REQUEST["bill_no"];


 $bill=mysqli_query($con,"select * from onshop where `bill_no`='".$bill_no."' and `status`='active' and `bill_status`='pending' "); $billr=mysqli_fetch_array($bill,MYSQLI_ASSOC);
  $billn=mysqli_num_rows($bill);

?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!-- /Added by HTTrack --><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--
<link type="text/css" rel="stylesheet" href="javax.faces.resource/themeab55.css?ln=primefaces-aristo" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/dist-butterfaces-bootstrap.min4e5d.css?ln=butterfaces-dist-css" />
-->
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/default.css" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/cssLayout.css" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/bootstrap.css" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/popup.css" />
<link type="text/css" rel="stylesheet" href="javax.faces.resource/css/menu.css" />
<!--
<script type="text/javascript" src="javax.faces.resource/butterfaces-all-with-jquery-and-bootstrap-bundle.min686a.js?ln=butterfaces-dist-bundle-js"></script>
<script type="text/javascript" src="javax.faces.resource/js/jquery-3.4.0.min.js"></script>
<script type="text/javascript" src="javax.faces.resource/js/bootstrap.js"></script>
<script type="text/javascript" src="javax.faces.resource/js/jquery-1.11.2.js"></script>
<script type="text/javascript" src="javax.faces.resource/js/jssor.slider-27.5.0.min.js"></script>
<script type="text/javascript" src="javax.faces.resource/jquery8490.js?ln=js"></script>
<script type="text/javascript" src="javax.faces.resource/menu8490.js?ln=js"></script>
<script type="text/javascript" src="javax.faces.resource/js/canvasjs.min.js"></script>
        
  -->     
        <script type="text/javascript">
            $(function() {
                $('ul.nav li.dropdown').hover(function() {
                    $(this).find('.dropdown-menu').stop(true, true).delay(100).fadeIn(500);
                }, function() {
                    $(this).find('.dropdown-menu').stop(true, true).delay(100).fadeOut(500);
                });
            });
        </script>
        <script type="text/javascript">
            $(function() {
                $("#notice").fadeIn("slow").append('');
                $(".dismis").click(function() {
                    $("#notice").fadeOut("slow");
                });
            });
        </script>
		
<script>
function lfn_SelectSection(p_Class)
    {
        document.getElementById('cusname').disabled=false;
		
  
        $.ajax({
		
                    type: "GET",
                    url: "ajax_location.html?classID=" + p_Class,
                    success: function(state) {
                    document.getElementById('cusname').innerHTML=state;    
					
                    }
        });
		
	 
		
		
    }

</script>
<style> 
        input.largerCheckbox { 
            width: 20px; 
            height: 20px; 
			
        } 
    </style> 
        <title>Katha O Cafe</title></head><body>

        <div id="top">


                    <div class="container-fluid text-center" style="margin-left: 5px"> 
                        <div class="row">
                            <div class="col-sm-1">
							<!-- Logo -->
							
							
                            </div>                           
                                       
                           
                        </div>
                    </div>

                    <!-- Menu start  -->

                    <nav class="navbar navbar-expand-lg header-m" role="navigation">
                        <div class="container-fluid">
                            <div class="navbar-header">
                                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                                    <span class="sr-only">Toggle navigation</span>
                                    <span class="icon-bar" style="background-color: #fff;"></span>
                                    <span class="icon-bar" style="background-color: #fff;"></span>
                                    <span class="icon-bar" style="background-color: #fff;"></span>
                                </button>
                                <a class="navbar-brand" href="#"></a>
                            </div>

                            <!-- Collect the nav links, forms, and other content for toggling -->
                            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                                <?php include("include/header.php"); ?>
                            </div>

                            <!-- /.navbar-collapse -->
                        </div>
                        <!-- /.container-fluid -->
                    </nav>

        </div>

        <div id="content" class="center_content " style="background-image:url(wall.jpg)">

                    <div class="container-fluid text-center">    
                        <div class="row">
                            <div class="col-sm-2" style="padding-right: 0px;">
							
							
							
							
							
                                 <?php include("include/left.php"); ?>
 
 
 
 
                                    

                                </div>

                            </div>

                            <div class="col-sm-8" style="padding-right: 2px; padding-left:2px;">

                                <div class="row" >
                                    <div class="col-sm-12" >

                                        <div class="panel panel-primary" style="background-color: rgb(186,233,254);border: 1px solid #000; margin-bottom: 0px; background-image:url(wall.jpg)">
                                            <div class="panel-heading" style="font-size: 20px; font-family: serif; background-color: #007de8; color:#CCFF00"> <b>Add Product Quantity</b></div>
                                            <div class="panel-body" style="text-align: justify;padding-bottom: 0px; padding-top: 6px;"><p style="font-family: Cambria;"><strong>
					 
<?php $id=$_REQUEST["id"]; $q=mysqli_query($con,"select * from product where `id`='".$id."'"); $qr=mysqli_fetch_array($q,MYSQLI_ASSOC); ?>					 
<form method="post">
<table border="0" width="100%">
<tr height="30"><td width="20%"><b>Product Name</b> </td><td width="30%"><font color="#0000FF"><b><i><?php echo $qr["product_name"]; ?></i></b></font></td><td rowspan="5"><img src="<?php echo $qr['photo']; ?>" width="150"></td></tr>
<tr height="30"><td><b>Company Name</b> </td><td><font color="#0000FF"><b><i><?php echo $qr["company"]; ?></i></b></font></td></tr>
<tr height="30"><td><b>Size</b> </td><td><font color="#0000FF"><b><i><?php  echo $tv= $qr["volume"]; ?> <?php echo $qr["unit"];  $p= $billr['mrp']; ?></i></b></font></td></tr>
<tr height="30"><td><b>Entry Date</b> </td><td><input type="date" name="doe" required > </td></tr>
<tr height="30">
  <td><strong>Expense Quantity </strong></td>
  <td><input type="text" name="g_quantity" id="g_quantity" onChange="g_stock()" style="width:70px;" value="0" required> <?php $c_g_s= $qr["g_quantity"]; ?> <input type="text" value="<?php echo $c_g_s; ?> " id="g_quantity2" style="display:none"></td></tr>
  
<tr height="30"><td><?php if($_REQUEST["path"]=="Kitchen") {?> <b>Send to Counter </b><?php } else {?> <b>Counter Stock</b> <?php  } ?></td><td colspan="2"><input type="text" name="quantity" style="width:70px;" value="0" id="quantity" onKeyUp="c_stock()" disabled="disabled"> 

<font color="red">Curent Counter Stock :  <input type="text" style="width:35px;" value="<?php echo $qr["quantity"]; ?>" id="counter_s" disabled="disabled">  <input type="hidden" style="width:35px;" value="<?php echo $qr["quantity"]; ?>" id="final" name="final"><input type="hidden" style="width:35px;" value="<?php echo $qr["quantity"]; ?>" id="counter_s_"></font> 
 <?php if($_REQUEST["path"]=="Kitchen") { } else { ?> <!-- <font color="red">Curent Counter Stock :  <input type="text" style="width:35px;" value="<?php echo $qr["quantity"]; ?>" id="counter_s" disabled="disabled"> <input type="text" style="width:35px;display:none" value="<?php echo $qr["quantity"]; ?>" id="counter_s_"></font> --> <?php } ?>
</td>
</tr>
<tr height="50"><td> </td><td> <input type="submit" name="save" value="Submit" style="width:70px;"></td><td></td></tr>
<tr height="80"><td><a href="product_list.php?id=<?php echo $_REQUEST['path']; ?>"><img src="back.png" width="70"></a> </td><td>  </td><td></td></tr>
</table>
</form>
<script>
function g_stock() {
//var bn1=Number(document.getElementById("g_quantity").value);
//var bn2=Number(document.getElementById("g_quantity2").value);
var bn1=Number(document.getElementById("g_quantity").value); //changable
var cs=Number(document.getElementById("counter_s_").value); // from url
var bn2=Number(document.getElementById("counter_s").value);
var bn3=(bn1-cs)*-1;
if(bn1!=0) { document.getElementById("quantity").value=bn1*-1;
	   document.getElementById("counter_s").value=bn3; document.getElementById("final").value=bn3; } else { document.getElementById("quantity").value="0";  document.getElementById("counter_s").value="<?php echo $_REQUEST['cstock']; ?>"; }
	   
	   
  
}
function c_stock() {
var bn1=Number(document.getElementById("quantity").value);
var bn2=Number(document.getElementById("g_quantity2").value);
var cs=Number(document.getElementById("counter_s_").value); // from url
var bn3=bn2-bn1;
var bn4=cs+bn1;
	   document.getElementById("g_quantity3").value=bn3;
	 document.getElementById("counter_s").value=bn4;  
	   
}
</script>
<hr>	
Last entry date : <?php echo $qr["last_update"]; ?>
			

<?php   if(isset($_POST["save"]))
        {
		 
		 $id=$_REQUEST["id"];
$b=mysqli_query($con,"select * from product where `id`='".$id."'  "); $i=1; $br=mysqli_fetch_array($b,MYSQLI_ASSOC);	
		 $product_name=$br["product_name"];	
           $company=$br["company"];
		   $mrp=$br["mrp"];	
		   $price=$br["price"];	
		   $doe=$_POST["doe"];
		   $quantity=$_POST["quantity"];
		   $g_quantity=$_POST["g_quantity"];
		   $volume=$br["volume"];
		   $cp=$br["curent_peg"];
		   $ml=$_POST["ml"];
		   //$cp=($volume-$ml)+$cp;
		   $cp=$volume-$ml;
		   $gg_quantity=$g_quantity;
		    if($g_quantity=="0") { 
			$g_quantity=$c_g_s;
		   } else {
			   $g_quantity=$g_quantity+$c_g_s;
		   }
		   $t_g_quantity=$g_quantity - $quantity;
		   $unit=$br["unit"];	
		   	
		   $photo=$br["photo"];
		   $category=$br["category"];	
		   $qnty=$br["quantity"];
		   $p=$br["mrp"];
		   $q=	$quantity+$qnty;
		   $rs=$p*$quantity;
		   $date=date('d-m-Y');
		  $final_quantity=$_POST["g_quantity"];
		  $final=$_POST["final"];
		  if($_REQUEST["type"]=="Kitchen") { 
		       mysqli_query($con,"insert into kitchen_exp (`product_id`,`date`,`exp_date`,`exp_unit`,`price`,`status`) values ('".$id."','".$date."','".$doe."','".$final_quantity."','".$rs."','')");

		   } else {

		   }	
		   // mysqli_query($con,"insert into purchase (`product_name`,`company`,`mrp`,`price`,`doe`,`unit`,`volume`,`photo`,`category`,`quantity`,`g_quantity`) values('".$product_name."','".$company."','".$mrp."','".$price."','".$doe."','".$unit."','".$volume."','".$photo."','".$category."','".$final_quantity."','".$gg_quantity."')");		   				
mysqli_query($con,"update product set `quantity`='".$final."',`g_quantity`='".$t_g_quantity."',`last_update`='".$date."',`curent_peg`='".$cp."' where `id`='".$id."'");					
 if($_REQUEST["path"]=="Kitchen") {
 
     
 } else {}

?><script>
alert("Entry Success");
window.location.href="product_list.php?id=<?php echo $_REQUEST['type']; ?>";</script><?php 	
	
		}?>				 
<p>&nbsp;</p>					 
				
					 
					 
					 
	<!--				 					
											 <select name="class" id="class" class="form-control" onChange="lfn_SelectSection(this.value);">
                                            <option value="">--- Please Select Class ----</option>
                                             <option value="A">A</option>
											 <option value="B">B</option>
											 <option value="C">C</option>
                                             </select>
											Section
											 <select type="text" name="secname" id="secname" class="form-control" >
                                        	<option value="0">------select Section_o------</option>

                                        </select> -->	
										
                                                    </strong></p></div>
                                        </div>



                                    </div>
                                </div>

                            <!--   <div class="well" style="padding: 5px;background-color: rgb(186,233,254); border: 1px solid #000; margin-bottom: 1px;">
                                    <div class="row">
                                        
                                        
                                       
                                        
                                        
                                        
                                    </div> 
                                </div>-->
                                <div class="row">
                                   <!-- <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: antiquewhite;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/school-educatione0f8.png?ln=img" width="50" />  </div>
                                            <div class="panel-footer" style="padding: 1px 2px; background-color: #007de8; font-size: 13px;"><a href="../e_Pension/AdminLogin.html"> School Education Department Users</a>  </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: #7c5a5e;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/villagee0f8.png?ln=img" width="50" /></div>
                                            <div class="panel-footer" style="padding: 1px 2px;background-color: #007de8; font-size: 13px;"><a href="../e_Pension/AdminLogin.html">P &amp; R D Department Users</a>  </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: #f6f191;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/librarye0f8.png?ln=img" width="50" /></div>
                                            <div class="panel-footer" style="padding: 1px 2px;background-color: #007de8; font-size: 13px;"><a href="../e_Pension/AdminLogin.html">UD &amp; MA Department Users</a>  </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: #fff;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/images6e0f8.png?ln=img" width="50" /></div>
                                            <div class="panel-footer" style="padding: 1px 2px;background-color: #007de8; font-size: 13px;"><a href="../e_Pension/AdminLogin.html"> MEE &amp; LS Department Users</a>  </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: #ffdc6a;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/treasurye0f8.png?ln=img" width="50" /></div>
                                            <div class="panel-footer" style="padding: 10px 5px;background-color: #007de8; font-size: 13px;"><a href="../e_Pension/AdminLogin.html">Treasury Users</a>  </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-2">
                                        <div class="panel panel-primary" style="background-color: #5cfef2;">
                                            <div class="panel-body" style="border: 1px solid #000"><img src="javax.faces.resource/users-groupe0f8.png?ln=img" width="50" /></div>
                                            <div class="panel-footer" style="padding: 1px 2px;background-color: #007de8; font-size: 12px;"><a href="../e_Pension/AdminLogin.html">Other Departments Users</a>  </div>
                                        </div>
                                    </div>    -->
                                </div>
                            
                               

                            </div>
                            <div class="col-sm-2" style="padding-left:0px;">
							
							
							 <?php include("include/right.php"); ?>
                                
                            </div>                     
                        </div>

                    </div>
</form>
        </div>


        <?php include("include/footer.php"); ?>
		

		
		
		</body>



</html>