<?php
include_once 'db_functions.php';     
$db = new DB_Functions(); 
$retailerid = $_REQUEST['retailerCode'];      
$users = $db->productList();     
$a = array();     
$b = array(); 
 
 if ($users != false){ 
 	///// get retailer state and type
   $res_loc = $db->getLocationDetail($retailerid);
   $row_loc = mysql_fetch_array($res_loc);
   while($row = mysql_fetch_array($users)) {
	   
	$b["id"] = $row["id"];
  	$b["pname"] = $row["productname"];
  	$b["pcode"] = $row["productcode"];
  	$b["pcolor"] = $row["productcolor"];
	$b["pcat"] = $row["productcategory"];
	$b["pbrand"] = $row["brand"];
	///// get product price on behalf of selected retailer
	$res_price = $db->productPrice($row_loc["state"],$row_loc["id_type"],$b["pcode"]);
	$row_price = mysql_fetch_array($res_price);
	if($row_price["price"]){
		$b["pprice"] = $row_price["price"];
	}else{
		$b["pprice"] = "0.00";
	}
	array_push($a,$b);
   }
	echo json_encode($a);
 }

?>