<?php
ini_set("display_errors", true);
ini_set("html_errors", true);
require "../commonincludefiles.php";
error_reporting(1);


$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 "movies":
   $out = GetMovies($query);
    break;
		
}

echo $out;



$condition = "";
function GetMovies($query) {
    
  $retVal = "[]";
	$objInquiryMgmt = new InquiryMgmt();

  if (strlen($query) > 0) {
	$condition .= " AND inquierorg_name like '%" . $query . "%' OR customer_id like '%" . $query . "%'"; 
  }
  
	$result = $objInquiryMgmt->getAllRecords(0,0,$condition,$order_field,$order_type) ;
		
	$num = dbRows($result);
	
	$i = 0;   
	
	$movies = array("count" => $num, "movies" => array());
	
	while ($row = dbAssoc($result)) {    
		$movies["movies"][$i] = $row;    
		$i++;  
	}   
	
	return json_encode($movies); 
}

?>