X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fmanage%2Fitem_categories.php;h=9af49483d96514387d05430c41746ba07068d4f0;hb=0d191c7bff92b9a9bbc44dab48855477edb99ebf;hp=cff22f4739f0f94b0699e1d19fe39e67f62ec8b1;hpb=a5953f4c442fb44f1e60eb1e15eb7066dca95420;p=fa-stable.git diff --git a/inventory/manage/item_categories.php b/inventory/manage/item_categories.php index cff22f47..9af49483 100644 --- a/inventory/manage/item_categories.php +++ b/inventory/manage/item_categories.php @@ -9,11 +9,11 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -$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"); @@ -44,7 +44,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'], - check_value('no_sale')); + check_value('no_sale'), check_value('no_purchase')); display_notification(_('Selected item category has been updated')); } else @@ -54,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'], check_value('no_sale')); + $_POST['dim2'], check_value('no_sale'), check_value('no_purchase')); display_notification(_('New item category has been added')); } $Mode = 'RESET'; @@ -67,10 +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'"; - $result = db_query($sql, "could not query stock master"); - $myrow = db_fetch_row($result); - if ($myrow[0] > 0) + if (key_in_foreign_table($selected_id, 'stock_master', 'category_id')) { display_error(_("Cannot delete this item category because items have been created using this item category.")); } @@ -94,14 +91,10 @@ 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"); +$result = get_item_categories(check_value('show_inactive')); start_form(); -start_table("$table_style width=80%"); +start_table(TABLESTYLE, "width=80%"); $th = array(_("Name"), _("Tax type"), _("Units"), _("Type"), _("Sales Act"), _("Inventory Account"), _("COGS Account"), _("Adjustment Account"), _("Assembly Account"), "", ""); @@ -136,7 +129,7 @@ echo '
'; //---------------------------------------------------------------------------------- div_start('details'); -start_table($table_style2); +start_table(TABLESTYLE2); if ($selected_id != -1) { @@ -157,13 +150,15 @@ if ($selected_id != -1) $_POST['dim1'] = $myrow["dflt_dim1"]; $_POST['dim2'] = $myrow["dflt_dim2"]; $_POST['no_sale'] = $myrow["dflt_no_sale"]; + $_POST['no_purchase'] = $myrow["dflt_no_purchase"]; } hidden('selected_id', $selected_id); hidden('category_id'); -} else { +} else if ($Mode != 'CLONE') { $_POST['long_description'] = ''; $_POST['description'] = ''; $_POST['no_sale'] = 0; + $_POST['no_purchase'] = 0; $company_record = get_company_prefs(); @@ -194,7 +189,9 @@ 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'); + +check_row(_("Exclude from purchases:"), 'no_purchase'); gl_all_accounts_list_row(_("Sales Account:"), 'sales_account', $_POST['sales_account']); @@ -231,10 +228,9 @@ 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(); end_page(); -?>