<?
include_once("modules/EcmProductReports/vtigerConnector.php");

$vc=new vtigerConnector();
$wc[]="purchaseorder.tracking_no!=''";
$vc->pp=99999;
$vc->where=@implode(" and ",$wc);

$vc->getData();
$cnt=$vc->getCount();
$data=$vc->data;

$vd=$data;
foreach($vd as $v){
	if(mysql_num_rows(mysql_query("select id from ecmproducts where product_category_id is not null and product_category_id!='' and code like '".$v['productcode']."' and deleted='0'"))==0){
		$a[]=array("name"=>$v['productname'],"code"=>$v['productcode'],"qty"=>$v['quantity'],"price"=>$v['listprice']);
	}
}
foreach($a as $aa){
	echo $aa['code']." ".$aa['name'].", qty: ".$aa['qty'].", price: ".$aa['price']."<br />";
	$s+=$aa['qty']*$aa['price'];
}
echo "total: ".$s;
?>