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

function update_qualification($selected_id, $qualification,
                                $comment, $obtained_date)
{
	                
    $updated_by = $_SESSION['wa_current_user']->user;
    $updated_on = date('Y-m-d H:i:s');
     	
    $sql = "UPDATE ".TB_PREF."employee_qualifications "
                . "SET "
                    . "qualification=".db_escape($qualification).","
                    . "comment=".db_escape($comment).","
                    . "obtained_date=".db_escape($obtained_date).", "
                    . "updated_by=".db_escape($updated_by).","
                    . "updated_on=".db_escape($updated_on)
                . "WHERE "
                    . "id=".db_escape($selected_id);
	
	db_query($sql,"Employee Qualification could not be updated");		
}

function delete_qualification_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_qualifications($employee_code)
{
	$sql = "SELECT *    
		FROM "
                    .TB_PREF."employee_qualifications 
                WHERE 
                    employee_code=".db_escape($employee_code)."  
                ORDER BY obtained_date DESC";	
	
	return db_query($sql,"Employment history could not be retreived");
}

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

?>