<?php //
/**********************************************************************
***********************************************************************/
function add_est_projects_billing_schedule($est_project_id, $date, $amount, $percentage, $comment, $invoice_no)
{
                $id_user = $_SESSION['wa_current_user']->user;
                $datetime = date('Y-m-d H:i:s');
                
        $sql = "INSERT INTO ".TB_PREF."est_projects_billing_schedule 
                       (est_project_id, date, amount,percentage,comment,created_by,created_on,invoice_no) 
                            
                VALUES (".db_escape($est_project_id).", "
                        .db_escape(date2sql($date))
                        .", ".db_escape($amount).", ".db_escape($percentage).", "
                        .db_escape($comment).", ".db_escape($id_user).", ".db_escape($datetime).", ".db_escape($invoice_no).")";

        db_query($sql,"Billing schedule could not be added");		
}

function update_est_projects_billing_schedule($schedule_id, $date, $amount, $percentage, $comment, $invoice_no)
{
    $id_user = $_SESSION['wa_current_user']->user;
    $datetime = date('Y-m-d H:i:s');
    
    $sql = "UPDATE ".TB_PREF."est_projects_billing_schedule SET 
                date=".db_escape(date2sql($date)).", 
                amount=".db_escape($amount).",       
                comment=".db_escape($comment).",
                updated_by=".db_escape($id_user).",
                percentage=".db_escape($percentage).",
                invoice_no=".db_escape($invoice_no).",
                updated_on=".db_escape($datetime)."
            WHERE schedule_id=".db_escape($schedule_id);

    db_query($sql,"Billing schedule could not be updated");		
}

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

function get_est_schedules($est_project_id)
{
	$sql = "SELECT * FROM ".TB_PREF."est_projects_billing_schedule WHERE est_project_id=".db_escape($est_project_id);
	return db_query($sql,"Project billing schedule could not be retreived");
}

function get_est_schedule_details($schedule_id)
{
	$sql = "SELECT * FROM ".TB_PREF."est_projects_billing_schedule WHERE schedule_id=".db_escape($schedule_id);
	
	$result = db_query($sql,"price could not be retreived");
	
	return db_fetch($result);
}

?>
















