<?php
require_once ("varables.php");

$myJSON["ordreport"]=array();
$myJSON['success']="0";

if(isset($_POST["nekot"]) && isset($_POST["an1d"])
&& isset($_POST["dateaz"])&& isset($_POST["dateta"]))
{
	$vid = $_POST["an1d"];
	$az = $_POST["dateaz"];
	$ta = $_POST["dateta"];

    $connect = @mysqli_connect($hostname,$username,$password,$database);
    if($connect)
    {
        @mysqli_query($connect,"SET CHARACTER SET utf8;");
		$query_all = "SELECT ".$tbl_orders.".endprice,".$tbl_customer.".C_name,".$tbl_orders.".date, tbl_orderstate.ordstate FROM ".$tbl_orders.", ".$tbl_customer.",tbl_orderstate WHERE ".$tbl_orders.".C_id = ".$tbl_customer.".id AND ".$tbl_orders.".V_id ='".$vid."' AND ".$tbl_orders.".V_id = '".$vid."' AND ".$tbl_orders.".localed = tbl_orderstate.id AND ".$tbl_orders.".type != 'K' AND (".$tbl_orders.".date BETWEEN '".$az."' AND '".$ta."') ORDER BY ".$tbl_orders.".date DESC";
			$result = @mysqli_query($connect,$query_all);
			if($result){
				while($row = @mysqli_fetch_assoc($result))	{
					array_push($myJSON["ordreport"], $row);
				}
				$myJSON['success']="200";
			}
				else {
					$myJSON['success']=@mysqli_error($connect);
			 }




	}
	 else
		 $myJSON['success']="402";
}
echo json_encode($myJSON);
?>
