<?php
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["vendor_id"])) {
	$query = $_POST["vendor_id"];
}

switch ($command) {

	case "movies":
		$out = GetMovies($query);
		break;

}

echo $out;




function GetMovies($query)
{

	$retVal = "[]";
	$objVendorMgmt = new VendorMgmt();


	if (strlen($query) > 0) {
		$condition = " AND vendor_orgname like '" . $query . "%'";
	}


	$result = $objVendorMgmt->getAllRecords(0, 0, $condition, "", "");
	$total = dbRows($result);

	$i = 0;

	$movies = array("count" => $total, "movies" => array());

	while ($row = dbAssoc($result)) {
		$movies["movies"][$i] = $row;
		$i++;
	}

	return json_encode($movies);
}
?>