<?php


$usuario=$_POST['user'];
$password=$_POST['pass'];
$url=$_POST['url'];
$include=includec($url);
includec($url);

$query=mysql_query("SELECT vtiger_products.*,vtiger_productcf.* 
	FROM vtiger_products 
	INNER JOIN vtiger_productcf ON vtiger_productcf.productid=vtiger_products.productid 
	INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid=vtiger_products.productid 
	WHERE deleted='0' LIMIT 10");
$num=mysql_num_rows($query);
$z=0;
if($num>=1){
while ($z<$num) {
    $productid=mysql_result($query,$z,'vtiger_products.productid');
    $product_no=mysql_result($query,$z,'product_no');
    $productname=mysql_result($query,$z,'productname');
    $productcode=mysql_result($query,$z,'productcode');
    $productcategory=mysql_result($query,$z,'productcategory');
    $qtyinstock=mysql_result($query,$z,'qtyinstock');
    $docs[$z]=array('productid'=>$productid,'product_no'=>$product_no,'productname'=>$productname,'productcode'=>$productcode,'productcategory'=>$productcategory,'qtyinstock'=>$qtyinstock);
    $z++;
}    
//print_r($docs);
echo json_encode($docs);
}
else{
	echo "Error: No products available for you";
}

function includec($url){
    $domain=explode(".",$url);
    $domain=$domain[0];
    $domain=explode("//",$domain);
    $domain=$domain[1];
    $include="../".$domain."/popup/conexion.php";
    return $include;

}


function DateApp($cdate){
    $date = new DateTime($cdate);
    $cdate=$date->format('Y-m-d');
    return $cdate;

}



?>
