<?php 
include 'connection.php';
session_start();
if (!isset($_SESSION['is_logged_in'])) {
    header("Location:login.php");
    die();
    }
function randomPassword() {
    $alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    $pass = array(); //remember to declare $pass as an array
    $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
    for ($i = 0; $i < 5; $i++) {
        $n = rand(0, $alphaLength);
        $pass[] = $alphabet[$n];
    }
    return implode($pass); //turn the array into a string
}

	date_default_timezone_set('Asia/Calcutta');
$today = date("d/m/y");
$today1 = date("d-m-Y");
$today2 = date("Y-m-d");
$received_time = date("Y-m-d H:i:s");

$currentyear = date("Y");
$currentmonth = date("m");

if($currentmonth>03) { 
$cuyear = date("Y");
$cuyear1 = date("y")+1;
} 
else { 
$cuyear = date("Y")-1;
$cuyear1 =  date("y");
} 
$f_year = "$cuyear"."-"."$cuyear1";


$unique_id = randomPassword();	

$querylogin = "select * from  mst_users where user_name = '". $_SESSION["LOGIN_NAME"]."' AND password = '".$_SESSION["EMPLOYEE_PASSWORD"]."'";
$resultlogin = mysqli_query($conn,$querylogin);
while($row=mysqli_fetch_array($resultlogin))
{
$user_name = $row['user_name'];
$user_id09 = $row['user_id'];
$login_type = $row['login_type'];

}	
?>



<?php
$cust_po_more_product_id=$_POST['cust_po_more_product_id'];
$customer_po_id=$_POST['customer_po_id'];











date_default_timezone_set('Asia/Calcutta');

$today = date("Y-m-d");

$time = date("Y-m-d H:i:s");

$currentyear = date("Y");

$currentmonth = date("m");



if($currentmonth>03) { 

$cuyear = date("Y");

$cuyear1 = date("y")+1;

} 

else { 

$cuyear = date("Y")-1;

$cuyear1 =  date("y");

} 

$f_year = "$cuyear"."-"."$cuyear1";


$query2="select * from customer_po_more_product_02 where cust_po_more_product_id='".$_REQUEST['cust_po_more_product_id']."' and customer_po_id = '".$_REQUEST['customer_po_id']."' AND customer_id = '".$_REQUEST['customer_id']."' AND deleted !='YES' ORDER BY  cust_po_more_product_id ASC";
$result=mysqli_query($conn,$query2);
while($row=mysqli_fetch_array($result))

		{ 
		
		
$bal_po_qty01=$row['bal_po_qty'];

$despatch_qty=$row['despatch_qty'];
 
}
//$bal_po_qty=$bal_po_qty01-$close_weight;



 $query1_PO = "update customer_po_more_product_02 set closed_qty='$bal_po_qty01',bal_po_qty='0'  WHERE customer_po_id ='".$_REQUEST['customer_po_id']."' and cust_po_more_product_id='".$_REQUEST['cust_po_more_product_id']."'" ;
//echo $query1;
$r1PO=mysqli_query($conn,$query1_PO);
?>


<script>
javascript:window.location.href="closed_customer_po.php?customer_po_id=<?php echo $_REQUEST['customer_po_id'];?>&&customer_id=<?php echo $_REQUEST['customer_id']?>";
</script>
<?php

