Merged changes from main trunk up to 2.2.3
[fa-stable.git] / inventory / manage / item_codes.php
index bbd7d7d80ecbd8f87a97e2152796afaba84451b9..d26f6f413522ea7178d016badb5fed0bb9643547 100644 (file)
@@ -1,19 +1,19 @@
 <?php
 /**********************************************************************
     Copyright (C) FrontAccounting, LLC.
-       Released under the terms of the GNU Affero General Public License,
-       AGPL, as published by the Free Software Foundation, either version 
-       of the License, or (at your option) any later version.
+       Released under the terms of the GNU General Public License, GPL, 
+       as published by the Free Software Foundation, either version 3 
+       of the License, or (at your option) any later version.
     This program is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
-    See the License here <http://www.gnu.org/licenses/agpl-3.0.html>.
+    See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-$page_security = 11;
-$path_to_root="../..";
+$page_security = 'SA_FORITEMCODE';
+$path_to_root = "../..";
 include_once($path_to_root . "/includes/session.inc");
 
-page(_("Foreign Item Codes"));
+page(_($help_context = "Foreign Item Codes"));
 
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
@@ -35,10 +35,10 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
        display_error( _("There is no item selected."));
                set_focus('stock_id');
        }
-       elseif (!check_num('quantity', 0))
+       elseif (!input_num('quantity'))
        {
        $input_error = 1;
-       display_error( _("The price entered was not numeric."));
+       display_error( _("The price entered was not positive number."));
                set_focus('quantity');
        }
        elseif ($_POST['description'] == '')
@@ -97,13 +97,13 @@ if (list_updated('stock_id'))
 
 //--------------------------------------------------------------------------------------------------
 
-start_form(false, true);
+start_form();
 
 if (!isset($_POST['stock_id']))
        $_POST['stock_id'] = get_global_stock_item();
 
 echo "<center>" . _("Item:"). "&nbsp;";
-stock_purchasable_items_list('stock_id', $_POST['stock_id'], false, true);
+echo stock_purchasable_items_list('stock_id', $_POST['stock_id'], false, true);
 
 echo "<hr></center>";
 
@@ -152,22 +152,23 @@ div_end();
 
 //-----------------------------------------------------------------------------------------------
 
-if ($Mode =='Edit')
-{
-       $myrow = get_item_code($selected_id);
-       $_POST['item_code'] = $myrow["item_code"];
-    $_POST['quantity'] = $myrow["quantity"];
-    $_POST['description'] = $myrow["description"];
-    $_POST['category_id'] = $myrow["category_id"];
-}
- else {
-    $_POST['quantity'] = 1;
-    $_POST['description'] = $dflt_desc;
-    $_POST['category_id'] = $dflt_cat;
+if ($selected_id != '') {
+       if ($Mode =='Edit')
+       {
+               $myrow = get_item_code($selected_id);
+               $_POST['item_code'] = $myrow["item_code"];
+               $_POST['quantity'] = $myrow["quantity"];
+               $_POST['description'] = $myrow["description"];
+               $_POST['category_id'] = $myrow["category_id"];
+       }
+       hidden('selected_id', $selected_id);
+} else {
+       $_POST['quantity'] = 1;
+       $_POST['description'] = $dflt_desc;
+       $_POST['category_id'] = $dflt_cat;
 }
 
 echo "<br>";
-hidden('selected_id', $selected_id);
 start_table($table_style2);
 
 hidden('code_id', $selected_id);
@@ -179,7 +180,7 @@ stock_categories_list_row(_("Category:"), 'category_id', null);
 
 end_table(1);
 
-submit_add_or_update_center($selected_id == -1, '', true);
+submit_add_or_update_center($selected_id == -1, '', 'both');
 
 end_form();
 end_page();