<?php
/**********************************************************************
***********************************************************************/
function write_template($selected, $template_description, $email_content)
{
    if($selected!='')
		$sql = "UPDATE ".TB_PREF."email_template SET
	 	template_description = ".db_escape($template_description).",
	 	email_content = ".db_escape($email_content)."
        	WHERE template_id = ".db_escape($selected);
    
    else
		$sql = "INSERT INTO ".TB_PREF."email_template
			(template_description, email_content) 
                        VALUES( ".db_escape($template_description).", ".db_escape($email_content).")";
    db_query($sql,"An email template could not be updated");
}
////
function delete_email_template($id)
{
	$sql="DELETE FROM ".TB_PREF."email_template WHERE template_id=".db_escape($id);

	db_query($sql,"An email template could not be deleted");
}
////
function get_template_details($id)
{
	$sql="SELECT * FROM ".TB_PREF."email_template WHERE template_id=".db_escape($id);

	$result = db_query($sql,"An email template could not be retrieved");

	return db_fetch($result);
}
function get_all_email_templates($all=false) {
    $sql = "SELECT * FROM ".TB_PREF."email_template";
	//if (!$all) $sql .= " WHERE !inactive";
	//$sql .= " ORDER BY approval_path_name";
    return  db_query($sql, "Could not get stock cateAn email templates");
}
?>