Tags support related changes.
[fa-stable.git] / inventory / manage / item_categories.php
index b5ded413293931fc278b64717aa9045ebd01208c..26a2889fec39035ef5a247f7a5bb377614d3ee8a 100644 (file)
@@ -9,8 +9,8 @@
     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"));
@@ -43,7 +43,8 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
                                $_POST['tax_type_id'],  $_POST['sales_account'], 
                                $_POST['cogs_account'], $_POST['inventory_account'], 
                                $_POST['adjustment_account'], $_POST['assembly_account'],
-                               $_POST['units'], $_POST['mb_flag'],     $_POST['dim1'], $_POST['dim2']);
+                               $_POST['units'], $_POST['mb_flag'],     $_POST['dim1'], $_POST['dim2'],
+                               check_value('no_sale'));
                        display_notification(_('Selected item category has been updated'));
        } 
        else 
@@ -53,7 +54,7 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
                                $_POST['cogs_account'], $_POST['inventory_account'], 
                                $_POST['adjustment_account'], $_POST['assembly_account'], 
                                $_POST['units'], $_POST['mb_flag'],     $_POST['dim1'], 
-                               $_POST['dim2']);
+                               $_POST['dim2'], check_value('no_sale'));
                        display_notification(_('New item category has been added'));
        }
                $Mode = 'RESET';
@@ -84,7 +85,9 @@ if ($Mode == 'Delete')
 if ($Mode == 'RESET')
 {
        $selected_id = -1;
+       $sav = get_post('show_inactive');
        unset($_POST);
+       $_POST['show_inactive'] = $sav;
 }
 if (list_updated('mb_flag')) {
        $Ajax->activate('details');
@@ -93,14 +96,17 @@ if (list_updated('mb_flag')) {
 
 $sql = "SELECT c.*, t.name as tax_name FROM ".TB_PREF."stock_category c, "
        .TB_PREF."item_tax_types t WHERE c.dflt_tax_type=t.id";
+if (!check_value('show_inactive')) $sql .= " AND !c.inactive";
 
 $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);
+
 table_header($th);
 $k = 0; //row colour counter
 
@@ -114,22 +120,21 @@ 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");
-       edit_button_cell("Edit".$myrow[0], _("Edit"));
-       delete_button_cell("Delete".$myrow[0], _("Delete"));
+       inactive_control_cell($myrow["category_id"], $myrow["inactive"], 'stock_category', 'category_id');
+       edit_button_cell("Edit".$myrow["category_id"], _("Edit"));
+       delete_button_cell("Delete".$myrow["category_id"], _("Delete"));
        end_row();
 }
 
+inactive_control_row($th);
 end_table();
-end_form();
 echo '<br>';
 //----------------------------------------------------------------------------------
 
-start_form();
-
 div_start('details');
 start_table($table_style2);
 
@@ -151,12 +156,14 @@ if ($selected_id != -1)
                $_POST['mb_flag']  = $myrow["dflt_mb_flag"];
                $_POST['dim1']  = $myrow["dflt_dim1"];
                $_POST['dim2']  = $myrow["dflt_dim2"];
+               $_POST['no_sale']  = $myrow["dflt_no_sale"];
        } 
        hidden('selected_id', $selected_id);
        hidden('category_id');
-} else {
+} else if ($Mode != 'CLONE') {
                $_POST['long_description'] = '';
                $_POST['description'] = '';
+               $_POST['no_sale']  = 0;
 
                $company_record = get_company_prefs();
 
@@ -187,19 +194,22 @@ stock_item_types_list_row(_("Item Type:"), 'mb_flag', null, true);
 
 stock_units_list_row(_("Units of Measure:"), 'units', null);
 
-gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']);
+check_row(_("Exclude from sales:"), 'no_sale');
 
-gl_all_accounts_list_row(_("Inventory Account:"), 'inventory_account', $_POST['inventory_account']);
+gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_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']))
@@ -221,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();