X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fmanage%2Fitem_units.php;h=a17ac69ff5045b085d7d114b2c25d35051917b1f;hb=8ea6c4dd0d9b31b3456d012b0c94339b801bee0c;hp=76af07d90aa20c64f1c3a057a0d95d7dc38fea27;hpb=0ad7b92c6cf2e4e65ca0fa94ba31f30f7b292ba8;p=fa-stable.git diff --git a/inventory/manage/item_units.php b/inventory/manage/item_units.php index 76af07d9..a17ac69f 100644 --- a/inventory/manage/item_units.php +++ b/inventory/manage/item_units.php @@ -1,7 +1,16 @@ . +***********************************************************************/ +$page_security = 'SA_UOM'; +$path_to_root = "../.."; include($path_to_root . "/includes/session.inc"); page(_("Units of Measure")); @@ -10,122 +19,131 @@ include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/inventory/includes/db/items_units_db.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -else if (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} - +simple_page_mode(false); //---------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { //initialise no input errors assumed initially before we test $input_error = 0; - if (strlen($_POST['abbr']) == 0) + if (strlen($_POST['abbr']) == 0) { $input_error = 1; display_error(_("The unit of measure code cannot be empty.")); + set_focus('abbr'); } - if (strlen($_POST['description']) == 0) + if (strlen(db_escape($_POST['abbr']))>(20+2)) { $input_error = 1; - display_error(_("The unit of measure description cannot be empty.")); + display_error(_("The unit of measure code is too long.")); + set_focus('abbr'); } - if (!is_numeric($_POST['decimals'])) + if (strlen($_POST['description']) == 0) { $input_error = 1; - display_error(_("The number of decimal places must be integer.")); + display_error(_("The unit of measure description cannot be empty.")); + set_focus('description'); } - if ($input_error !=1) { - write_item_unit(isset($selected_id) ? $selected_id : '', $_POST['abbr'], $_POST['description'], $_POST['decimals'] ); - meta_forward($_SERVER['PHP_SELF']); + write_item_unit(htmlentities($selected_id), $_POST['abbr'], $_POST['description'], $_POST['decimals'] ); + if($selected_id != '') + display_notification(_('Selected unit has been updated')); + else + display_notification(_('New unit has been added')); + $Mode = 'RESET'; } } -//---------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { // PREVENT DELETES IF DEPENDENT RECORDS IN 'stock_master' - + if (item_unit_used($selected_id)) { - display_error(_("Cannot delete this unit of measure because items have been created using this units.")); + display_error(_("Cannot delete this unit of measure because items have been created using this unit.")); - } - else + } + else { delete_item_unit($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected unit has been deleted')); } + $Mode = 'RESET'; +} + +if ($Mode == 'RESET') +{ + $selected_id = ''; + $sav = get_post('show_inactive'); + unset($_POST); + $_POST['show_inactive'] = $sav; } //---------------------------------------------------------------------------------- -$result = get_all_item_units(); -start_table("$table_style width=50%"); +$result = get_all_item_units(check_value('show_inactive')); + +start_form(); +start_table("$table_style width=40%"); $th = array(_('Unit'), _('Description'), _('Decimals'), "", ""); +inactive_control_column($th); table_header($th); $k = 0; //row colour counter -while ($myrow = db_fetch($result)) +while ($myrow = db_fetch($result)) { - + alt_table_row_color($k); label_cell($myrow["abbr"]); label_cell($myrow["name"]); - label_cell($myrow["decimals"]); + label_cell(($myrow["decimals"]==-1?_("User Quantity Decimals"):$myrow["decimals"])); - edit_link_cell(SID."selected_id=$myrow[0]"); - delete_link_cell(SID."selected_id=$myrow[0]&delete=yes"); + inactive_control_cell($myrow["abbr"], $myrow["inactive"], 'item_units', 'abbr'); + edit_button_cell("Edit".$myrow["abbr"], _("Edit")); + delete_button_cell("Delete".$myrow["abbr"], _("Delete")); end_row(); } -end_table(); +inactive_control_row($th); +end_table(1); //---------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Unit of Measure")); - -start_form(); - -start_table("class='tablestyle_noborder'"); +start_table($table_style2); -if (isset($selected_id)) +if ($selected_id != '') { - //editing an existing item category - - $myrow = get_item_unit($selected_id); + if ($Mode == 'Edit') { + //editing an existing item category - $_POST['abbr'] = $myrow["abbr"]; - $_POST['description'] = $myrow["name"]; - $_POST['decimals'] = $myrow["decimals"]; + $myrow = get_item_unit($selected_id); + $_POST['abbr'] = $myrow["abbr"]; + $_POST['description'] = $myrow["name"]; + $_POST['decimals'] = $myrow["decimals"]; + } hidden('selected_id', $selected_id); } - -if (isset($selected_id) && item_unit_used($selected_id)) { +if ($selected_id != '' && item_unit_used($selected_id)) { label_row(_("Unit Abbreviation:"), $_POST['abbr']); hidden('abbr', $_POST['abbr']); } else text_row(_("Unit Abbreviation:"), 'abbr', null, 20, 20); -text_row(_("Descriptive Name:"), 'description', null, 40, 40); -text_row(_("Decimal Places:"), 'decimals', null, 3, 3); +text_row(_("Descriptive Name:"), 'description', null, 40, 40); + +number_list_row(_("Decimal Places:"), 'decimals', null, 0, 6, _("User Quantity Decimals")); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == '', '', 'both'); end_form();