<?php
	include "../actions/dbPDO.php";
	$dd   = $_POST["contract_id"];
	$output = array();
	$sql = $db->prepare("SELECT customers.cust_name , customers.phone , customers.phone2 ,
						 cars.kind , concat(cars.letters,' ',cars.numbers)as mmh , cars.model , contracts.contract_id
						FROM customers , cars , contracts
						WHERE contracts.carid = cars.carid
						AND 	contracts.cust_id = customers.cust_id
						AND 	contracts.cont_status != 2
						AND 	contracts.contract_id = ? LIMIT 1");
	$sql->bindParam(1,$dd);
	$sql->execute();
  if($sql->rowCount()>0){$row = $sql->fetch(PDO::FETCH_ASSOC);
		$output["cust_name"]  = $row["cust_name"];
		$output["phone"]   		= $row["phone"];
    $output["phone2"]     = $row["phone2"];
		$output["kind"] 			= $row["kind"];
		$output["numbers"]    = $row["mmh"];
    $output["model"]			= $row["model"];
	}else{$output["cust_name"]="تأكد من رقم العقد" ;}
	echo json_encode($output);
?>
