<?php  
error_reporting(E_ERROR | E_PARSE);
	include("../connect.php");
	$par1=$_GET['mobile'];
	$par2=$_GET['password'];
	$par3=$_GET['pref_id'];
	$par4=$_GET['hotelid'];
	$par5=$_GET['trolleyId'];
	$par6=$_GET['trolleyBarcode'];
	$par7=$_GET['tweight'];
	$par8=$_GET['ItemId'];
	$par9=$_GET['Itemname'];
	$par10=$_GET['ItemQty'];
	$par11=$_GET['ItemUnit'];
	$par12=$_GET['ItemDetail'];


	$response = array();
	$posts = array();
	
	
	date_default_timezone_set("Asia/Singapore");
	$mdate= date('Y/m/d H:i:s');
	$myObj2 = new stdClass();
    $eve1 = "SELECT * FROM res_user_master where  userloginid='$par1' and userpassword='$par2' and userstatus='Active' and userdesignation='User' limit 0,1";
	$re1 = mysqli_query($conn,$eve1);
																	
		if(mysqli_num_rows($re1) > 0)
	{
		//$result="1";
		$query1 = "select * from res_jobwork_detail where trolleymid=$par5 and orderdrandomid='$par3'";
		$stmt1=mysqli_query($conn,$query1);
		
		$jobworkdid="";
		
			while($rt1 = mysqli_fetch_assoc($stmt1))
			{
				$jobworkdid=$rt1['jobworkdid'];
				$tareweight=$rt1['trolleytareweight'];
			}
															
		$netweight=$par7-$tareweight;
		
		 $evenewpass11 = "update res_jobwork_detail set trolleygrossweight=$par7,trolleynetweight = $netweight where trolleymid=$par5 and orderdrandomid='$par3'";
		$renewpass11 = mysqli_query($conn, $evenewpass11);
		
		 $eve19 = "SELECT jobworkdid FROM res_jobworkitem_detail where  jobworkdid = $jobworkdid and itemid = $par8";
		$re19 = mysqli_query($conn,$eve19);
																	
		if(mysqli_num_rows($re19) > 0)
		{
			$evenewpass = "update res_jobworkitem_detail set itemqty = itemqty + $par10,itemdetail = '$par12' where jobworkdid = $jobworkdid and itemid = $par8";
			$renewpass = mysqli_query($conn, $evenewpass);	
		}
		else
		{
			$evenewpass = "insert into res_jobworkitem_detail (jobworkdid,itemid,itemname,itemqty,itemdetail) values ($jobworkdid,'$par8','$par9','$par10','$par12')";
			$renewpass = mysqli_query($conn, $evenewpass);	
		}
		 
		$result="1";
		$msg = "Success";
		
		$newResponse[] = array('result'=> $result,'msg'=> $msg);
	$posts = ["item" => $newResponse];
		$response['posts'] = $posts;
		echo stripslashes(json_encode( $posts));

	}
   else
   {
		$result="0";
		$msg="Failure";
		
		$newResponse[] = array('result'=> $result,'msg'=> $msg);
	$posts = ["item" => $newResponse];
		$response['posts'] = $posts;
		echo stripslashes(json_encode( $posts));
   }
	mysqli_close($conn);
?>
