<?php
session_start();

	include("connectp.php");
	date_default_timezone_set("Asia/Singapore");
	$mdate= date('Y-m-d H:i:s');
	$mdate1= date('Y-m-d');
	
	$par3 = $_GET['trolleymid'];
	
	$data=0;
	
	if(isset($_GET["trolleymid"]) && !empty($_GET["trolleymid"]))
	{
		if(($_SESSION['linkariseutype']=='Admin') || ($_SESSION['linkariseutype']=='User'))
		{
			$partymid=$_SESSION['linkariseumid'];
			
			$query4 = "select trolleytareweight from res_jobwork_detail where trolleymid=:trolleymid ";
			$stmt4 = $db7->prepare($query4);
			$stmt4->bindValue(':trolleymid', "$par3");
			/* $stmt4->bindValue(':crateconstartdate', "$mdate1");
	        $stmt4->bindValue(':crateconenddate', "$mdate1"); */
			$stmt4->execute();
			if ($stmt4->rowCount() > 0)
			{
				while($rt4 = $stmt4->fetch(PDO::FETCH_ASSOC))
				{
					$data = $rt4['trolleytareweight'];
					break;
				}
			}
			else
			{
				$query4 = "select trolleytareweight from res_trolley_master where trolleymid=:trolleymid";
				$stmt4 = $db7->prepare($query4);
				$stmt4->bindValue(':trolleymid', "$par3");
				$stmt4->execute();
				if ($stmt4->rowCount() > 0)
				{
					while($rt4 = $stmt4->fetch(PDO::FETCH_ASSOC))
					{
						$data = $rt4['trolleytareweight'];
						break;
					}
				}
			}
		}
		else
		{
			$partymid=$_SESSION['currentcustomer'];
			
			$query4 = "select crateconditemrate from res_customerratecontract_detail where itemmid=:itemmid and cratecontractmid in(select cratecontractmid from res_customerratecontract_master where partymid=$partymid and crateconstatus='Active')";
			$stmt4 = $db7->prepare($query4);
			$stmt4->bindValue(':itemmid', "$par3");
			/* $stmt4->bindValue(':crateconstartdate', "$mdate1");
	        $stmt4->bindValue(':crateconenddate', "$mdate1"); */
			$stmt4->execute();
			if ($stmt4->rowCount() > 0)
			{
				while($rt4 = $stmt4->fetch(PDO::FETCH_ASSOC))
				{
					$data = $rt4['crateconditemrate'];
					break;
				}
			}
			else
			{
				$query4 = "select trolleytareweight from res_trolley_master where trolleymid=:trolleymid";
				$stmt4 = $db7->prepare($query4);
				$stmt4->bindValue(':trolleymid', "$par3");
				$stmt4->execute();
				if ($stmt4->rowCount() > 0)
				{
					while($rt4 = $stmt4->fetch(PDO::FETCH_ASSOC))
					{
						$data = $rt4['trolleytareweight'];
						break;
					}
				}
			}
		}
	}
	echo trim($data);
?>
