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");
{
// 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."));
}
}
//----------------------------------------------------------------------------------
-$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"), "", "");
//----------------------------------------------------------------------------------
div_start('details');
-start_table($table_style2);
+start_table(TABLESTYLE2);
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;
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']);
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();