<?php
require "../commonincludefiles.php";

$condition="";

$inquiry_id= Escape($_POST['inquiry_id']);
$district_id= Escape($_POST['district_id']);
$satartdate= Escape($_POST['satartdate']);
$enddate = Escape($_POST['enddate']);

if($inquiry_id !="") {
	
	$condition .= " AND inquiry_id='".$inquiry_id."'"; 
}
if($district_id !="") {
	
	$condition .= " AND district_id='".$district_id."'"; 
}
if($satartdate !="") {
	
	$satartdate = substr($satartdate, 0, -9);
    $condition .= " AND appointmentdate >= '$satartdate' ";  
	
	
	/*2010-07-21T00:00:00
	$satartdate = $_POST['satartdate'],"Y-m-d","d/m/Y");
    $condition .= " AND appointmentdate >= '$satartdate' ";  */
}
if($enddate !="") {

	$enddate =  substr($enddate, 0, -9);
	 $condition .= " AND appointmentdate <= '$enddate' "; 
	
	 /*$enddate = DateConversion($_POST['enddate'],"Y-m-d","d/m/Y");
	 $condition .= " AND appointmentdate <= '$enddate' ";  */
} 

    $objInquiryMgmt = new InquiryMgmt();  
	//echo $condition;
	$result = $objInquiryMgmt->getAllRecords(0,0,$condition,$order_field,$order_type) ;
		
	 $num = dbRows($result);
	
	$i = 0;   
	
	$distictData = array("total" => $num, "griddata" => array());

				$temparray = array();
				while($row = dbArray($result)){
				
					$temparray["inquiry_id"]  = $row["inquiry_id"];
					$temparray["inquierorg_name"]   = $row["inquierorg_name"];
					$temparray["inquier_address"]  = $row["inquier_address"];
					$temparray["district_id"]   = $row["district_id"];
					$temparray["inquier_phoneno"]  ="Ph.No : ".$row["inquier_phoneno"]."<br/>Mob.No : ".$row["inquier_mobileno"]."<br/>Fax No : ".$row["inquier_faxno"]."<br/>";
					$temparray["inquier_mobileno"]  = $row["inquier_mobileno"];
					$temparray["inquier_faxno"]   = $row["inquier_faxno"];
					$temparray["inquier_email"]  = $row["inquier_email"];
					$temparray["inquier_url"]   = $row["inquier_url"];
					$temparray["contactperson"]   = $row["contactperson"];
					$temparray["appointmentdate"]   = $row["appointmentdate"];
					$temparray["appointmenttime"]  = $row["appointmenttime"];
					$temparray["comment"]   = $row["comment"];
					$temparray["product_ids"]  = $row["product_ids"];
					$temparray["company_id"]   = $row["company_id"];
					
					//print_r($temparray);
					 $distictData['griddata'][$i] = $temparray;   
					 $i++;
			}
			
			echo json_encode($distictData);	


?>