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


function get_bank_trans_for_bulk_bank_transfers($bank_account, $from, $to, $tran_type, $debit)
{
	$from = date2sql($from);
	$to = date2sql($to);
        
	$sql = "SELECT t.*,
                        CONCAT(b.bank_account_name, ' - ', bn.value_name) bank_account_name 
                FROM ".TB_PREF."bank_trans t 
                    JOIN ".TB_PREF."bank_accounts b ON 
                        t.bank_act = b.id 
                    JOIN ".TB_PREF."list_values bn  ON 
                        b.bank_id = bn.id  
		WHERE t.bank_act = ".db_escape($bank_account) . " 
                    AND trans_date >= '$from'
                    AND trans_date <= '$to' 
                    AND type = ".db_escape($tran_type); 
            if($debit == 1){
                $sql .= " AND amount > 0 ";
            }
            else{
                $sql .= " AND amount < 0 ";
            }
		
        $sql .= " ORDER BY trans_date, t.id";

	return db_query($sql,"get_bank_trans_for_bulk_bank_transfers");
}




?>
