	<?php
	session_start();
	require_once 'db_connection.php'; 
	$user_id = $_SESSION['user_id'];
	$status = $_POST['status'];
	$line_total = $_POST['line_total'];

	if($line_total==0 && $status==1){
		echo "Not found line items to hold";
	}elseif ($line_total>0 && $status==0) {
		echo "Cannot unhold a bill, there are few lines on cart..";
	}else{ 

	$sql1 = "SELECT * FROM mobiletemporarycart WHERE orderid=0 AND user_id='$user_id' AND hold=1 ";
	$resultset = $conn->query($sql1);
	if ($resultset->num_rows > 0 && $status==1) {
		echo 'Already hold a bill, You can hold 1 bill at once...';
	}else{

		$sql = "UPDATE mobiletemporarycart SET hold='$status' WHERE orderid=0 AND user_id='$user_id' ";
		if ($conn->query($sql) === TRUE) {
			echo "Holded";
		} else {
			echo "Error updating record: " . $conn->error;
		}

	}





} 
	?>
