<?PHP

session_start();
$privilage = $_SESSION['privilage'];

echo $txnid= $_GET['txnId'];



$branch_key = $_SESSION['branch_key'];


$app_code = $_SESSION['app_code'];











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);
			



if($privilage == "Priviledge" or $privilage == "Sales Rep" or $privilage == "Sales Rep" or $privilage == "Receptionist" or $privilage == "Inventory Manager" or $privilage == "Secetary"/*or $privilage == "Manager"*/)
	{
	
	header ("Location: not_authorized.php");
	
}






else if(isset($_POST['A']))
{
	 
    $name = $_POST['name'];
	$type = $_POST['type'];
	
	
	$unit_c = $_POST['unit_c'] ;
	//$bundle_q = $_POST['bundle_q'] ;
	//$bundle_p = $_POST['bundle_p'] ;
	
	
	 $date = date("Y-m-d");
	$time = date("h-i-s");

	

	$db_found = new mysqli(DB_SERVER, DB_USER, DB_PASS, $database );

		/*
			$SQL = $db_found->prepare("INSERT INTO product_table (product_name, unit_q, unit_p,bundle_q,bundle_p,user_id) VALUES (?,?,?,?,?,?)");
			$SQL->bind_param('ssssss', $product_name, $unit_q,$unit_p,$bundle_q,$bundle_p,$_SESSION['user_id'] );
			$SQL->execute();
			header ("Location: inventory_ac.php");
			
			
		*/
	
	$SQL = $db_found->prepare("INSERT INTO fixed_cost (name,type,amount,time,date,branch_key,app_code) VALUES (?,?,?,?,?,?,?)");
			$SQL->bind_param('sssssss', $name,$type,$unit_c,$time,$date,$branch_key,$app_code);
			$SQL->execute();
			header ("Location: setup_ac.php");
		echo  "operation successfull";




}




 else if($db_found){
	 


	
	$SQL = "DELETE FROM fixed_cost WHERE product_id=$txnid";
   $query_del = mysqli_query($db_handle, $SQL);
	
	  
	 header ("Location: setup_ac.php");

	  
  }
	
else{
	
	echo "database not found";
}

	  

?>






	<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>
	<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<?php echo $txnid;?>
		
		
		
			<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>
