<?php
	require "../commonincludefiles.php";
	
	$command = "";
	$out = "";
	$query = "";

	if(isset($_POST["cmd"])) {
		$command = $_POST["cmd"];
	}
	if (isset($_POST["query"])) {
		$query = $_POST["query"];
	}
	if (isset($_POST["inquiry_id"])) {
		$query = $_POST["inquiry_id"];
	}

	switch ($command) {
		case "quotation":
   			$out = GetMovies($query);
    		break;
	}

	echo utf8_encode($out);

	function GetMovies($query){
		$retVal = "[]";
		$objQuotationMgmt = new QuotationMgmt();
		if(strlen($query) > 0){
			$condition .= " "; 
  		}
  		$result = $objQuotationMgmt->inquiry_getAllRecords(0,0,$condition,$order_field,$order_type) ;
		$num = dbRows($result);
		$i = 0;   
		if(dbRows($result) > 0){
			$temparray = array();
			while($row = dbArray($result)){
				$temparray["inquiry_id"] 		= $row["inquiry_id"];
				$temparray["inquierorg_name"]   = $row["inquierorg_name"];
				$temparray["inquierorg_name1"]   = $row["customer_id"];
				  
				$temparray["inquier_address"]  	= $row["inquier_address"];
				$temparray["contactperson"]   	= $row["contactperson"];
				$temparray["appointmentdate"]  	= $row["appointmentdate"];
				$temparray["appointmenttime"]	= $row["appointmenttime"];
				$temparray["product_ids"]  		= $row["product_ids"];
				$griddata[$i] = $temparray;   
				$i++;
			}	
			
			echo '{"total":"'.$num.'","quotation":'.json_encode($griddata).'}';				
		}  
	}
?>