<?php
/**********************************************************************
***********************************************************************/
function add_employment_record($employee_code, $designation,
                                $company, $start_date, $end_date)
{
	$created_by = $_SESSION['wa_current_user']->user;
	$created_on = date('Y-m-d H:i:s');
        
        $sql = "INSERT INTO ".TB_PREF."employment_history (
                    employee_code, 
                    designation,
                    company, 
                    start_date, 
                    end_date, 
                    created_by, 
                    created_on) 
		VALUES ("
                .db_escape($employee_code).", "
                .db_escape($designation).", "
                .db_escape($company).", "
                .db_escape($start_date).", "
                .db_escape($end_date).", "
                .db_escape($created_by).", "
                .db_escape($created_on).")";
	
	db_query($sql,"Employment history could not be added");		
}

function update_employment_record($selected_id, $designation,
                                $company, $start_date, $end_date)
{
	                
    $updated_by = $_SESSION['wa_current_user']->user;
    $updated_on = date('Y-m-d H:i:s');
     	
    $sql = "UPDATE ".TB_PREF."employment_history "
                . "SET "
                    . "designation=".db_escape($designation).","
                    . "company=".db_escape($company).","
                    . "start_date=".db_escape($start_date).", "
                    . "end_date=".db_escape($end_date).","
                    . "updated_by=".db_escape($updated_by).","
                    . "updated_on=".db_escape($updated_on)
                . "WHERE "
                    . "id=".db_escape($selected_id);
	
	db_query($sql,"Employment history could not be updated");		
}

function delete_employement_record($price_id)
{
	$sql="DELETE FROM ".TB_PREF." WHERE id= ".db_escape($price_id);
	db_query($sql,"an item price could not be deleted");			
}

function get_employment_history($employee_code)
{
	$sql = "SELECT *    
		FROM "
                    .TB_PREF."employment_history 
                WHERE 
                    employee_code=".db_escape($employee_code)."  
                ORDER BY start_date DESC";	
	
	return db_query($sql,"Employment history could not be retreived");
}

function get_employement_record($selected_id)
{
	$sql = "SELECT *    
		FROM "
                    .TB_PREF."employment_history 
                WHERE 
                    id=".db_escape($selected_id);	
	
	return db_query($sql,"Employment history record could not be retreived");
}

?>