2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU General Public License, GPL,
5 as published by the Free Software Foundation, either version 3
6 of the License, or (at your option) any later version.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
11 ***********************************************************************/
12 $page_security = 'SA_INVENTORYMOVETYPE';
13 $path_to_root = "../..";
14 include($path_to_root . "/includes/session.inc");
16 page(_($help_context = "Inventory Movement Types"));
18 include_once($path_to_root . "/inventory/includes/inventory_db.inc");
20 include_once($path_to_root . "/includes/ui.inc");
22 simple_page_mode(true);
23 //-----------------------------------------------------------------------------------
25 if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
28 //initialise no input errors assumed initially before we test
31 if (strlen($_POST['name']) == 0)
34 display_error(_("The inventory movement type name cannot be empty."));
38 if ($input_error != 1)
40 if ($selected_id != -1)
42 update_movement_type($selected_id, $_POST['name']);
43 display_notification(_('Selected movement type has been updated'));
47 add_movement_type($_POST['name']);
48 display_notification(_('New movement type has been added'));
55 //-----------------------------------------------------------------------------------
57 function can_delete($selected_id)
59 if (movement_types_in_stock_moves($selected_id))
61 display_error(_("Cannot delete this inventory movement type because item transactions have been created referring to it."));
69 //-----------------------------------------------------------------------------------
71 if ($Mode == 'Delete')
73 if (can_delete($selected_id))
75 delete_movement_type($selected_id);
76 display_notification(_('Selected movement type has been deleted'));
84 $sav = get_post('show_inactive');
86 $_POST['show_inactive'] = $sav;
88 //-----------------------------------------------------------------------------------
90 $result = get_all_movement_type(check_value('show_inactive'));
93 start_table(TABLESTYLE, "width='30%'");
95 $th = array(_("Description"), "", "");
96 inactive_control_column($th);
99 while ($myrow = db_fetch($result))
102 alt_table_row_color($k);
104 label_cell($myrow["name"]);
105 inactive_control_cell($myrow["id"], $myrow["inactive"], 'movement_types', 'id');
106 edit_button_cell("Edit".$myrow['id'], _("Edit"));
107 delete_button_cell("Delete".$myrow['id'], _("Delete"));
110 inactive_control_row($th);
113 //-----------------------------------------------------------------------------------
115 start_table(TABLESTYLE2);
117 if ($selected_id != -1)
119 if ($Mode == 'Edit') {
120 //editing an existing status code
122 $myrow = get_movement_type($selected_id);
124 $_POST['name'] = $myrow["name"];
126 hidden('selected_id', $selected_id);
129 text_row(_("Description:"), 'name', null, 50, 50);
133 submit_add_or_update_center($selected_id == -1, '', 'both');
137 //------------------------------------------------------------------------------------