<?php
/*
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
*/
include("db_connect.php");
include("db_functions.php");
$db=new DB_Functions();
$dc = new DB_Connect();         
$link1 = $dc->connect();
$ei = $_REQUEST['collect_by']; 
$retailer_code=$_REQUEST['retailer_code'];
$from_date=$_REQUEST['from_date'];
$to_date=$_REQUEST['to_date'];
$users=$db->collection_list_test($ei,$retailer_code,$from_date,$to_date);
$a=array();
$b=array();
   if($users!=false){
       $total_collect=0;
   while($row = mysqli_fetch_array($users)) {
	$b["retailer_id"] = $row["retailer_code"]; 
	$name=mysqli_fetch_assoc(mysqli_query($link1,"select locationname from location_master where location_code='".$row['retailer_code']."'"));
	$b["retailer_name"]=$name['locationname'];
	$b["collect_id"] = $row["collect_id"];
	$b["mode"] = $row["collection_mode"];
	$b["collection_sub_mode"] = $row["collection_sub_mode"];
	$b["trans_no"] = $row["trans_no"];
	$b["trans_date"] = $row["trans_date"];
		$b["cheque_no"] = $row["cheque_no"];
	$b["cheque_date"] = $row["cheque_date"];
  	$b["collect_amt"] = $row["collect_amt"];
  	$b["collect_date"] = $row["collect_date"];
  	$b["collect_by"] = $row["collect_by"];
	  $b["remark"] = $row["remark"];
$total_collect=$total_collect+$row["collect_amt"];

	array_push($a,$b);
   }

}
   echo json_encode($a);
?>