3 function add_item_location($loc_code, $location_name, $delivery_address, $phone, $fax, $email, $contact)
5 $sql = "INSERT INTO ".TB_PREF."locations (loc_code, location_name, delivery_address, phone, fax, email, contact)
6 VALUES (".db_escape($loc_code).", ".db_escape($location_name).", ".db_escape($delivery_address).", ".db_escape($phone).", ".db_escape($fax).", ".db_escape($email).", ".db_escape($contact).")";
8 db_query($sql,"a location could not be added");
10 /* Also need to add loc_stock records for all existing items */
11 $sql = "INSERT INTO ".TB_PREF."loc_stock (loc_code, stock_id, reorder_level)
12 SELECT '$loc_code', ".TB_PREF."stock_master.stock_id, 0 FROM ".TB_PREF."stock_master";
14 db_query($sql,"a location could not be added");
17 //------------------------------------------------------------------------------------
19 function update_item_location($loc_code, $location_name, $delivery_address, $phone, $fax, $email, $contact)
22 $sql = "UPDATE ".TB_PREF."locations SET location_name=".db_escape($location_name).",
23 delivery_address=".db_escape($delivery_address).",
24 phone=".db_escape($phone).", fax=".db_escape($fax).",
25 email=".db_escape($email).", contact=".db_escape($contact)."
26 WHERE loc_code = '$loc_code'";
28 db_query($sql,"a location could not be updated");
31 //------------------------------------------------------------------------------------
33 function delete_item_location($item_location)
35 $sql="DELETE FROM ".TB_PREF."locations WHERE loc_code='$item_location'";
36 db_query($sql,"a location could not be deleted");
38 $sql = "DELETE FROM ".TB_PREF."loc_stock WHERE loc_code ='$item_location'";
39 db_query($sql,"a location could not be deleted");
42 //------------------------------------------------------------------------------------
44 function get_item_location($item_location)
46 $sql="SELECT * FROM ".TB_PREF."locations WHERE loc_code='$item_location'";
48 $result = db_query($sql,"a location could not be retrieved");
50 return db_fetch($result);
53 //------------------------------------------------------------------------------------
55 function set_reorder_level($stock_id, $loc_code, $reorder_level)
57 $sql = "UPDATE ".TB_PREF."loc_stock SET reorder_level = $reorder_level
58 WHERE stock_id = '$stock_id' AND loc_code = '$loc_code'";
60 db_query($sql,"an item reorder could not be set");
63 //------------------------------------------------------------------------------------
65 function get_loc_details($stock_id)
67 $sql = "SELECT ".TB_PREF."loc_stock.*, ".TB_PREF."locations.location_name
68 FROM ".TB_PREF."loc_stock, ".TB_PREF."locations
69 WHERE ".TB_PREF."loc_stock.loc_code=".TB_PREF."locations.loc_code
70 AND ".TB_PREF."loc_stock.stock_id = '" . $stock_id . "' ORDER BY ".TB_PREF."loc_stock.loc_code";
71 return db_query($sql,"an item reorder could not be retreived");
74 //------------------------------------------------------------------------------------