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

function get_project_float_adjustments($float_id)
{
        $sql= "SELECT * 
               FROM ".TB_PREF."project_float_adjustments 
               WHERE id=".db_escape($float_id);             
        
return db_query($sql,"Could not get project float adjustments");	
       //  db_fetch($result);    
}

function add_project_float_adjustment($reference, $project_id, $company_code, 
                                        $employee_code, $tran_date, $is_return, 
                                        $amount, $comment)
{
    $created_by = $_SESSION['wa_current_user']->user;
    $created_on = date('Y-m-d H:i:s');        
        
	$sql = "INSERT INTO ".TB_PREF."project_float_adjustments 
                    (reference, project_id, company_code, 
                    employee_code, tran_date, is_return, 
                    amount, comment,
                    created_by, created_on) 
                      
            VALUES (".db_escape($reference)."," 
                     .db_escape($project_id).","
                     .db_escape($company_code).","  
                     .db_escape($employee_code).","  
                     .db_escape(date2sql($tran_date))."," 
                     .db_escape($is_return)."," 
                     .db_escape($amount)."," 
                     .db_escape($comment)."," 
                     .db_escape($created_by).","
                     .db_escape($created_on).")";
                     
        
    db_query($sql,"Could not add project float adjustment");        
    return db_insert_id();

}


function view_project_float_adjustment($id)
{
        $sql= "SELECT fa.*,
                    pf.name float_name,
                    u.real_name user_name
               FROM ".TB_PREF."project_float_adjustments fa
                    INNER JOIN ".TB_PREF."project_floats pf ON
                            pf.id = fa.float_id
                    INNER JOIN ".TB_PREF."users u ON
                            u.id = fa.created_by
               WHERE fa.id=".db_escape($id);             
        
        $result = db_query($sql,"Could not view project float adjustments");	
        return db_fetch($result);    
}
?>