<?php
	require "../commonincludefiles.php";
	$condition="";
	
	if($_POST["customerinvoice_id"]!="") {
		
		$objCustomerInvoiceProductMgmt = new CustomerInvoiceProductMgmt();  
		
			$condition .= " AND customerinvoice_id =".Escape($_POST["customerinvoice_id"])."";
			$result = $objCustomerInvoiceProductMgmt->getAllRecords(0,0,$condition,$order_field,$order_type) ;
		
		
		$num = dbRows($result);
		$i = 0;   
		if(dbRows($result) > 0){
			$temparray = array();
			while($row = dbArray($result)){

				$temparray["id"]  		  = "Invoice";
				$temparray["ip"]  		  =$i;
				$temparray["product_name"]  		  = $row["product_id"];
				$temparray["product_qty"]   	  = $row["product_qty"];
				$temparray["product_rate"] = $row["product_rate"];
				$griddata[$i] = $temparray;   
				$i++;
			}		
			echo '{"total":"'.$num.'","griddata":'.json_encode($griddata).'}';				
		} 
	}
?>
