Activated strict SQL mode, minor SQL injection fix, fixed _vl() debug helper.
[fa-stable.git] / inventory / manage / locations.php
index 0bae7585fc6469b1bc1813f5fee64fa9c95338a5..6728e1e53fb9f72100da2cc69cbdab0efad6f7d1 100644 (file)
@@ -13,12 +13,19 @@ $page_security = 'SA_INVENTORYLOCATION';
 $path_to_root = "../..";
 include($path_to_root . "/includes/session.inc");
 
-page(_($help_context = "Inventory Locations"));
 
 include_once($path_to_root . "/includes/ui.inc");
 
 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
 
+if (isset($_GET['FixedAsset'])) {
+       $help_context = "Fixed Assets Locations";
+       $_POST['fixed_asset'] = 1;
+} else
+       $help_context = "Inventory Locations";
+
+page(_($help_context));
+
 simple_page_mode(true);
 
 if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') 
@@ -33,7 +40,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
        //first off validate inputs sensible
        $_POST['loc_code'] = strtoupper($_POST['loc_code']);
 
-       if (strlen(db_escape($_POST['loc_code'])) > 7) //check length after conversion
+       if ((strlen(db_escape($_POST['loc_code'])) > 7) || empty($_POST['loc_code'])) //check length after conversion
        {
                $input_error = 1;
                display_error( _("The location code must be five characters or less long (including converted special chars)."));
@@ -52,7 +59,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
        {
     
                update_item_location($selected_id, $_POST['location_name'], $_POST['delivery_address'],
-                       $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], $_POST['contact']);  
+                               $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], $_POST['contact'], check_value('fixed_asset'));
                        display_notification(_('Selected location has been updated'));
        } 
        else 
@@ -61,7 +68,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
        /*selected_id is null cos no item selected on first time round so must be adding a      record must be submitting new entries in the new Location form */
        
                add_item_location($_POST['loc_code'], $_POST['location_name'], $_POST['delivery_address'], 
-                       $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], $_POST['contact']);
+                               $_POST['phone'], $_POST['phone2'], $_POST['fax'], $_POST['email'], $_POST['contact'], check_value('fixed_asset'));
                        display_notification(_('New location has been added'));
        }
                
@@ -135,11 +142,13 @@ if ($Mode == 'RESET')
 {
        $selected_id = -1;
        $sav = get_post('show_inactive');
+       $sav2 = get_post('fixed_asset');
        unset($_POST);
        $_POST['show_inactive'] = $sav;
+       $_POST['fixed_asset'] = $sav2;
 }
 
-$result = get_item_locations(check_value('show_inactive'));
+$result = get_item_locations(check_value('show_inactive'), get_post('fixed_asset', 0));
 
 start_form();
 start_table(TABLESTYLE);
@@ -169,6 +178,7 @@ end_table();
 echo '<br>';
 
 start_table(TABLESTYLE2);
+hidden("fixed_asset");
 
 $_POST['email'] = "";
 if ($selected_id != -1) 
@@ -199,12 +209,12 @@ else
 text_row_ex(_("Location Name:"), 'location_name', 50, 50);
 text_row_ex(_("Contact for deliveries:"), 'contact', 30, 30);
 
-textarea_row(_("Address:"), 'delivery_address', null, 35, 5);  
+textarea_row(_("Address:"), 'delivery_address', null, 34, 5);  
 
 text_row_ex(_("Telephone No:"), 'phone', 32, 30);
 text_row_ex(_("Secondary Phone Number:"), 'phone2', 32, 30);
 text_row_ex(_("Facsimile No:"), 'fax', 32, 30);
-email_row_ex(_("E-mail:"), 'email', 30);
+email_row_ex(_("E-mail:"), 'email', 50);
 
 end_table(1);
 submit_add_or_update_center($selected_id == -1, '', 'both');
@@ -213,4 +223,3 @@ end_form();
 
 end_page();
 
-?>