<?php
/**********************************************************************
***********************************************************************/


function get_sql_for_pos_customer_account_payments_inquiry($customer_id, $from_date, $to_date)
{
	$date_after = date2sql($from_date);
        $date_to = date2sql($to_date);

  	$sql = "SELECT 
                        pcap.trans_no, 
                        pcap.reference, 
                        pcap.tran_date, 
                        pcap.invoice_no, 
                        dm.name,
                        cb.br_name, 
                        pcap.amount 
                        
		FROM ".TB_PREF."pos_customer_account_payments as pcap, "
			.TB_PREF."debtors_master as dm, "
			.TB_PREF."cust_branch as cb 
		WHERE pcap.debtor_no = dm.debtor_no
			AND pcap.tran_date >= '$date_after'
			AND pcap.tran_date <= '$date_to'
			AND pcap.branch_code = cb.branch_code";

   	if ($customer_id != ALL_TEXT)
   		$sql .= " AND pcap.debtor_no = ".db_escape($customer_id);

   	return $sql;
}



?>