<?php


function get_project_work_done_employees($project_id,  $from_date, $to_date)
{
    $sql = "SELECT DISTINCT employee_code 
            FROM ".TB_PREF."employee_project_work  
            WHERE project_id = ". db_escape($project_id)." 
                AND start_date <= ". db_escape($to_date)." 
                AND end_date >= ". db_escape($from_date);    
    
    return db_query($sql, "get_project_employees");
    
}

function get_project_employee_work_done_boq_items($project_id, $employee_code, $from_date, $to_date)
{
    $sql = "SELECT ep.*,
                pbi.code boq_item_code,
                pbi.description boq_item_name   
            FROM ".TB_PREF."employee_project_work ep 
                JOIN ".TB_PREF."project_boq_items pbi   
                    ON ep.boq_item_id = pbi.id 
            WHERE ep.project_id = ". db_escape($project_id)." 
                AND ep.employee_code = ". db_escape($employee_code)." 
                AND ep.start_date <= ". db_escape($to_date)." 
                AND ep.end_date >= ". db_escape($from_date);      
    
    return db_query($sql, "get_project_employees");
    
}

function get_project_employee_work_done_boq_item_day_value($boq_item_rec_id, $date)
{
    $sql = "SELECT ep.* 
            FROM ".TB_PREF."employee_project_work ep 
            WHERE ep.id = ". db_escape($boq_item_rec_id)."  
                AND start_date <= ". db_escape($date)." 
                AND end_date >= ". db_escape($date);      
    
    $result = db_query($sql, "get_project_employees");
    return db_fetch($result);
    
}