Changed context help organization to enable use of central, multilanguage wiki.
[fa-stable.git] / inventory / manage / item_categories.php
index ec54c1740eab5d519c154567c0e8ab488f2710ba..a12f56ff0da23e06975e8a06d77615c27390831e 100644 (file)
@@ -9,11 +9,11 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-$page_security = 11;
-$path_to_root="../..";
+$page_security = 'SA_ITEMCATEGORY';
+$path_to_root = "../..";
 include($path_to_root . "/includes/session.inc");
 
-page(_("Item Categories"));
+page(_($help_context = "Item Categories"));
 
 include_once($path_to_root . "/includes/ui.inc");
 
@@ -67,7 +67,7 @@ if ($Mode == 'Delete')
 {
 
        // PREVENT DELETES IF DEPENDENT RECORDS IN 'stock_master'
-       $sql= "SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE category_id='$selected_id'";
+       $sql= "SELECT COUNT(*) FROM ".TB_PREF."stock_master WHERE category_id=".db_escape($selected_id);
        $result = db_query($sql, "could not query stock master");
        $myrow = db_fetch_row($result);
        if ($myrow[0] > 0) 
@@ -103,7 +103,7 @@ $result = db_query($sql, "could not get stock categories");
 start_form();
 start_table("$table_style width=80%");
 $th = array(_("Name"), _("Tax type"), _("Units"), _("Type"), _("Sales Act"),
-_("COGS Account"), _("Inventory Account"), _("Adjustment Account"),
+_("Inventory Account"), _("COGS Account"), _("Adjustment Account"),
 _("Assembly Account"), "", "");
 inactive_control_column($th);
 
@@ -120,8 +120,8 @@ while ($myrow = db_fetch($result))
        label_cell($myrow["dflt_units"], "align=center");
        label_cell($stock_types[$myrow["dflt_mb_flag"]]);
        label_cell($myrow["dflt_sales_act"], "align=center");
-       label_cell($myrow["dflt_cogs_act"], "align=center");
        label_cell($myrow["dflt_inventory_act"], "align=center");
+       label_cell($myrow["dflt_cogs_act"], "align=center");
        label_cell($myrow["dflt_adjustment_act"], "align=center");
        label_cell($myrow["dflt_assembly_act"], "align=center");
        inactive_control_cell($myrow["category_id"], $myrow["inactive"], 'stock_category', 'category_id');
@@ -160,7 +160,7 @@ if ($selected_id != -1)
        } 
        hidden('selected_id', $selected_id);
        hidden('category_id');
-} else {
+} else if ($Mode != 'CLONE') {
                $_POST['long_description'] = '';
                $_POST['description'] = '';
                $_POST['no_sale']  = 0;
@@ -194,21 +194,22 @@ stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, true);
 
 stock_units_list_row(_("Units of Measure:"), 'units', null);
 
-check_row(_("Exclude from sales:"), 'no_sale', $_POST['no_sale']);
+check_row(_("Exclude from sales:"), 'no_sale');
 
 gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']);
 
-gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']);
-
-if (!is_service($_POST['mb_flag'])) 
+if (is_service($_POST['mb_flag']))
 {
        gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
-       gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'adjustment_account', $_POST['adjustment_account']);
+       hidden('inventory_account', $_POST['inventory_account']);
+       hidden('adjustment_account', $_POST['adjustment_account']);
 }
-else 
+else
 {
-       hidden('cogs_account', $_POST['cogs_account']);
-       hidden('adjustment_account', $_POST['adjustment_account']);
+       gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']);
+
+       gl_all_accounts_list_row(_("C.O.G.S. Account:"), 'cogs_account', $_POST['cogs_account']);
+       gl_all_accounts_list_row(_("Inventory Adjustments Account:"), 'adjustment_account', $_POST['adjustment_account']);
 }
 
 if (is_manufactured($_POST['mb_flag']))
@@ -230,7 +231,7 @@ if ($dim < 2)
 
 end_table(1);
 div_end();
-submit_add_or_update_center($selected_id == -1, '', 'both');
+submit_add_or_update_center($selected_id == -1, '', 'both', true);
 
 end_form();