<?php




			session_start();


if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {
	header ("Location: ../login.php");
}
		


?>


<?php
require 'config.php';

			 $db_handle = mysqli_connect(DB_SERVER, DB_USER, DB_PASS);
			 $database = $_SESSION['database'];
			$db_found = mysqli_select_db($db_handle, $database);
			
	
 $product_id = $_POST['product_id'];
	 
    $product_name = $_POST['product'];
	echo $unit_q = $_POST['unit_q'] ;
	echo $add_q = $_POST['add_q'] ;
	echo $total_q = $unit_q+$add_q;
	$unit_p = $_POST['unit_p'] ;
	

$branch_key = $_SESSION['branch_key'];

$app_code = $_SESSION['app_code'];


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







 $service = $_POST['service'] ;

$automanage = $_POST['automanage'] ;



$expiry_date = $_POST['expiry_date'] ;

 $unite = $_POST['unite'] ;
	
	
	
	if($service == 'product')
	{
	
	$description =   'Added '.$add_q. $unite.' of '.$product_name.' by '.$_SESSION['name'].' that will expire '.$expiry_date;
	
	}



else if($service == 'service')
	{
	
	$description =   'Added '.$product_name.' services'.' by '.$_SESSION['name'];
	
	}
	else{
		
		$description =   'Added '.$product_name.' of '.$add_q.' by '.$_SESSION['name'];
	}





	
	$unit_c = $_POST['unit_c'] ;
	$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );

		
	$SQl_update = "UPDATE product_table SET unit_q = '$total_q', product_name= '$product_name',  unit_p = '$unit_p', unit_c= '$unit_c', auto_manage = '$automanage' , expiry_date = '$expiry_date'   WHERE product_id = '$product_id' ";
	
	mysqli_query($db_found,$SQl_update);




	$SQL = $db_found->prepare("INSERT INTO bmhistory (product_name,auto_manage, time,date,user_id,branch_key,app_code,service,expiry_date) VALUES (?,?,?,?,?,?,?,?,?)");
			$SQL->bind_param('sssssssss', $description,$automanage, $time, $date,$_SESSION['user_id'],$branch_key,$app_code,$service,$expiry_date );
			$SQL->execute();








	
//		echo  "operation successfull";

	header ("Location: inventory_ac.php");







	  
	  




?>






	<html>
		
			<title>Delete_script</title>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->	
		 <link href="css/bootstrap-4.4.1.css" rel="stylesheet">
		
		
		
	<head>



	</head>
		
		
		
		
		<style>
		
		
				.loader {
  border: 16px solid #f3f3f3;
  border-radius: 50%;
  border-top: 16px solid blue;
  border-right: 16px solid green;
  border-bottom: 16px solid red;
  border-left: 16px solid pink;
  width: 120px;
  height: 120px;
  -webkit-animation: spin 2s linear infinite;
  animation: spin 1s linear infinite;
}

@-webkit-keyframes spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
		
		</style>
		
		
		
		
		
	<body >

			
	<div class="jumbotron" style="text-align: center">
		
		
		<h3><b><span style="color: #EC0408">Are you sure you want to DELETE this transaction?</b></h3>
		</span> <br> Transaction ID
		
		
		
			<table style="margin: auto;width: 100%" >
					<form action="record_delete.php" method="post">
		
	<tr>
				<td>
				
		 				<input type="submit" value="NO" class="btn btn-danger" style= "width:100%; height: 70px" name = "NO" >
					
				</td>
					
				<td>
					
		 			<a href="delet.php">	<input type="button"  value="YES" class="btn btn-danger" style= "width:100%; height: 70px"  > </a>
				</td>
	
	</tr>
	</form>
			
			</table>
	
		
			</div>
			
	

	</body>
	</html>

