<?php
/**********************************************************************
***********************************************************************/

function add_import_payment_term($description){
    $user_id = $_SESSION['wa_current_user']->user;
    $date_time = date('Y-m-d H:i:s'); 
    
    $sql = "INSERT INTO ".TB_PREF."import_payment_terms (
                description, created_by, created_on) 
            VALUES (".db_escape($description).", ".db_escape($user_id).", ".db_escape($date_time).")";

    db_query($sql, "add_import_payment_term");
}

function update_import_payment_term($selected_id, $description){
    
    $user_id = $_SESSION['wa_current_user']->user;
    $date_time = date('Y-m-d H:i:s'); 
    
    $sql = "UPDATE ".TB_PREF."import_payment_terms 
            SET description = ".db_escape($description).",  
                updated_by = ".db_escape($user_id).", 
                updated_on = ".db_escape($date_time)."  
            WHERE id = " .db_escape($selected_id);
    
    db_query($sql,"update_import_payment_term");
}

function delete_import_payment_term($selected_id)
{
	$sql="DELETE FROM ".TB_PREF."import_payment_terms WHERE id=".db_escape($selected_id);
	db_query($sql,"delete_import_payment_term");
}



function get_import_payment_term($selected_id){
    
    $sql = "SELECT * 
            FROM ".TB_PREF."import_payment_terms 
            WHERE id = ".db_escape($selected_id);

    $result = db_query($sql,"get_import_payment_term");
    return db_fetch($result);
}


function get_import_payment_terms($show_inactive){
    
    $sql = "SELECT * FROM ".TB_PREF."import_payment_terms";
    
    if(!$show_inactive){
        $sql .= " WHERE !inactive";
    }
        
    return db_query($sql,"get_import_payment_terms");
}



?>