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


function get_sql_for_project_advance_batches_inquiry($float_id, $from_date, $to_date)
{    
    $sql = "SELECT pab.*,
                    pcf.name float_name

            FROM ".TB_PREF."project_advance_batches pab
                LEFT JOIN ".TB_PREF."petty_cash_floats pcf ON
                    pab.float_id = pcf.id
                    
            WHERE pab.tran_date >=".db_escape(date2sql($from_date))." AND pab.tran_date <=".db_escape(date2sql($to_date));
            
     if($float_id > 0){
        $sql .= "AND pab.float_id=".db_escape($float_id);
    }
    
    return $sql;
}

function view_project_advance_batch_header($trans_no)
{
    $sql = "SELECT ab.*,
                    fl.name float_name 
            FROM ".TB_PREF."project_advance_batches ab   
                    INNER JOIN ".TB_PREF."petty_cash_floats fl ON 
                        ab.float_id = fl.id 
            WHERE ab.id=".db_escape($trans_no);
    
    $result = db_query($sql,"Could not view_project_advance_batch_header");	
    
    return db_fetch($result);
    
}        
        
function view_project_advance_batches_details($trans_no)
{
    $sql = "SELECT ad.*,
                    pm.description project_desctiption 
            FROM ".TB_PREF."project_advance_batch_details ad 
                    INNER JOIN ".TB_PREF."projects_master pm ON 
                        ad.project_id = pm.project_id 
            WHERE ad.pab_id =".db_escape($trans_no);
    
    return db_query($sql,"Could not view_project_advance_batches_details");
}
?>