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

function update_initiate_est_project($selected_id, $code, $description, 
                                    $bid_date, $start_date, $end_date, 
                                    $department_id, $data_access_group_id, $created_by)
{			
        $id_user = $_SESSION['wa_current_user']->user;
        $datetime = date('Y-m-d H:i:s');

        
        $sql = "UPDATE ".TB_PREF."est_projects_master 
                SET 
                    updated_on=".db_escape($datetime).",
                    updated_by=".db_escape($id_user).",
                    created_by=".db_escape($created_by).",
                    code=".db_escape($code).",
                    description=".db_escape($description).",
                    bid_date=".db_escape(date2sql($bid_date)).",
                    start_date=".db_escape(date2sql($start_date)).",
                    end_date=".db_escape(date2sql($end_date)).", 
                    department_id=".db_escape($department_id).",    
                    dag_id=".db_escape($data_access_group_id)." ";   

        $sql .= " WHERE est_project_id=".db_escape($selected_id);

        db_query($sql, "The estimated project could not be updated");

}

function add_initiate_est_project($code, $description, $department_id, 
                                    $bid_date, $project_start_date, $project_end_date, 
                                    $approval_project_id, $data_access_group_id, $created_by)
{
        $datetime = date('Y-m-d H:i:s');
        
        $sql = "INSERT INTO ".TB_PREF."est_projects_master(code, description, department_id, 
                                                            bid_date, start_date, end_date, 
                                                            project_id, dag_id, created_on, created_by)
                         

                VALUES(".db_escape($code).", ".db_escape($description).", ".db_escape($department_id).", "
                        .db_escape(date2sql($bid_date)).", ".db_escape(date2sql($project_start_date)).", ".db_escape(date2sql($project_end_date)).", "
                        .db_escape($approval_project_id).",".db_escape($data_access_group_id).", ".db_escape($datetime).", ".db_escape($created_by).")"; 
                                               

        db_query($sql, "The Initiate Estimation project could not be added");

}

function get_initiate_est_project_details($est_project_id)
{  
    $sql = "SELECT em.*,
                    lv.value_name data_access_group_name,
                    lvd.value_name department_name 
                    
            FROM ".TB_PREF."est_projects_master em
                JOIN ".TB_PREF."list_values lv 
                    ON em.dag_id = lv.id 
                JOIN ".TB_PREF."list_values lvd 
                    ON em.department_id = lvd.id 
                    
            WHERE em.est_project_id = ".db_escape($est_project_id)."";

    $result = db_query($sql,"Initiate Estimation Project could not be retreived");

    return db_fetch($result);
}

?>






























































































































































