<?php


function get_fi_miscellaneous_project_costs($cutoff_date, $batch_size)
{
    $sql = "SELECT DISTINCT mpc.id trans_no, 
                    mpc.date tran_date,
                    mpc.project_id 
                    
            FROM ".TB_PREF."miscellaneous_project_costs mpc    
                JOIN ".TB_PREF."miscellaneous_project_cost_details mpd    
                    ON mpd.mpc_id = mpc.id  
                    
            WHERE mpd.debit_account <> '' 
                    AND mpd.credit_account <> ''                                           
                    AND mpc.approval_status =".db_escape(AS_APPROVED)." 
                    AND mpc.date <= ".db_escape($cutoff_date)."  
                    AND mpc.fi_batch_no = 0 
                    
            ORDER BY mpc.id LIMIT ".$batch_size;

    return db_query($sql);
}

function get_fi_miscellaneous_project_cost_details($mpc_id)
{
    $sql = "SELECT mpd.id,
                    mpd.mpc_id trans_no,                  
                    mpd.quantity, 
                    mpd.rate, 
                    mpd.task_id,
                    mpc.project_id,
                    mpd.debit_account,
                    mpd.credit_account 
                    
            FROM ".TB_PREF."miscellaneous_project_cost_details mpd 
                LEFT JOIN ".TB_PREF."miscellaneous_project_costs mpc ON
                    mpd.mpc_id = mpc.id
                                                
            WHERE mpd.debit_account <> '' 
                    AND mpd.credit_account <> '' 
                    AND mpd.mpc_id = ".db_escape($mpc_id);                    

    return db_query($sql);
}  


?>