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

function add_asset_location($loc_code, $location_name, $delivery_address, $phone, $phone2, $fax, $email, $contact, $inactive){
    $sql = "INSERT INTO ".TB_PREF."asset_locations (loc_code, location_name, delivery_address, 
                                                    phone, phone2, 
                                                    fax, email, contact, inactive)
                                                    
            VALUES (".db_escape($loc_code).", ".db_escape($location_name).", ".db_escape($delivery_address).", "
                     .db_escape($phone).", ".db_escape($phone2).", "
                     .db_escape($fax).", ".db_escape($email).", ".db_escape($contact).", ".db_escape($inactive).")";

    db_query($sql,"could not add_asset_location");
}

//------------------------------------------------------------------------------------

function update_asset_location($loc_code, $location_name, $delivery_address, $phone, $phone2, $fax, $email, $contact, $inactive){
    $sql = "UPDATE ".TB_PREF."asset_locations 
                SET location_name=".db_escape($location_name).",
                    delivery_address=".db_escape($delivery_address).",
                    phone=".db_escape($phone).", phone2=".db_escape($phone2).", fax=".db_escape($fax).",
                    email=".db_escape($email).", contact=".db_escape($contact).", inactive=".db_escape($inactive)."
            WHERE loc_code = ".db_escape($loc_code);

	db_query($sql,"a location could not be updated");
}


//------------------------------------------------------------------------------------

function get_asset_location($item_location){
    $sql = "SELECT * FROM ".TB_PREF."asset_locations WHERE loc_code = ".db_escape($item_location);

    $result = db_query($sql,"could not get_asset_location");

    return db_fetch($result);
}

//------------------------------------------------------------------------------------

function get_asset_locations($show_inactive){
    $sql = "SELECT * 
            FROM ".TB_PREF."asset_locations";
    
    if(!$show_inactive) 
        $sql .= " WHERE !inactive";
    
    return db_query($sql, "could not get_asset_locations");;
}



?>