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


function get_sql_for_petty_cash_adjustment_inquiry($from_date, $to_date, $type_id, $trans_no, $float_id)
{  
	$sql= "SELECT a.id, 
                        a.type, 
                        a.trans_no, 
                        a.reference, 
                        a.float_id, 
                        a.is_return, 
                        a.tran_date, 
                        a.amount, 
                        a.comment,
                        a.approval_status,
                        f.name float_name 
            FROM ".TB_PREF."petty_cash_float_adjustments a  
                    INNER JOIN ".TB_PREF."petty_cash_floats f 
                        ON f.id = a.float_id                      
            WHERE 1=1 "; 
        if ($trans_no > 0){
                $sql .= " AND a.trans_no = ".  db_escape($trans_no); 
        }
        else{
        
            if ($type_id > 0)
            {
                $sql .= " AND a.type = ".db_escape($type_id);
            }

            if ($float_id > 0)
            {
                    $sql .= " AND a.float_id =".db_escape($float_id);
            }

            $sql .= " AND a.tran_date >=".db_escape(date2sql($from_date))."AND a.tran_date <=".db_escape(date2sql($to_date));
        }
        
	$sql .=" ORDER BY tran_date DESC, a.type, a.trans_no DESC";
        
	return $sql;
}



