<?php
/**********************************************************************
***********************************************************************/
function write_employee_rates($selected, $rate_category, $rate)
{
    $user = $_SESSION['wa_current_user']->user;
    $date = date('Y-m-d H:i:s');
    
    if($selected != '')
    {
        $sql = "UPDATE ".TB_PREF."employee_rates 
                SET
                    description = ".db_escape($rate_category).",
                    rate = ".db_escape($rate).",
                    updated_by = ".db_escape($user).",
                    updated_on = ".db_escape($date)."
                WHERE 
                    id = ".db_escape($selected);
        
        db_query($sql, "Employee Rate could not be updated");
    }
    else
    {
        $sql = "INSERT INTO ".TB_PREF."employee_rates
                        (description,rate,created_by, created_on) 
                VALUES
                        (".db_escape($rate_category).",".db_escape($rate).","
                            .db_escape($user).",".db_escape($date).")";
        
        db_query($sql, "Employee Rate could not be added");
    }
    
}
////
function delete_employee_rates($id)
{
	$sql="DELETE FROM ".TB_PREF."employee_rates 
                    WHERE 
                        id=".db_escape($id);

	db_query($sql,"Selected employee rate could not be deleted");
}
////
function get_employee_rates($id)
{
	$sql="SELECT * FROM ".TB_PREF."employee_rates 
                WHERE 
                    id=".db_escape($id);

	$result = db_query($sql,"Selected employee rate could not be retrieved");
	return db_fetch($result);
}

function get_all_employee_rates() {
    $sql = "SELECT * FROM ".TB_PREF."employee_rates ";
        
    return  db_query($sql, "Could not get employee rates");
}
?>