2 /**********************************************************************
3 Copyright (C) FrontAccounting, LLC.
4 Released under the terms of the GNU Affero General Public License,
5 AGPL, as published by the Free Software Foundation, either version
6 3 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/agpl-3.0.html>.
11 ***********************************************************************/
13 $path_to_root="../..";
14 include_once($path_to_root . "/includes/session.inc");
16 page(_("POS settings"));
18 include_once($path_to_root . "/includes/ui.inc");
19 include_once($path_to_root . "/sales/includes/db/sales_points_db.inc");
21 simple_page_mode(true);
22 //----------------------------------------------------------------------------------------------------
24 function can_process()
26 if (strlen($_POST['name']) == 0)
28 display_error(_("The POS name cannot be empty."));
29 set_focus('pos_name');
32 if (!check_value('cash') && !check_value('credit'))
34 display_error(_("You must allow cash or credit sale."));
42 //----------------------------------------------------------------------------------------------------
44 if ($Mode=='ADD_ITEM' && can_process())
46 add_sales_point($_POST['name'], $_POST['location'], $_POST['account'],
47 check_value('cash'), check_value('credit'));
48 display_notification(_('New point of sale has been added'));
52 //----------------------------------------------------------------------------------------------------
54 if ($Mode=='UPDATE_ITEM' && can_process())
57 update_sales_point($selected_id, $_POST['name'], $_POST['location'],
58 $_POST['account'], check_value('cash'), check_value('credit'));
59 display_notification(_('Selected point of sale has been updated'));
63 //----------------------------------------------------------------------------------------------------
65 if ($Mode == 'Delete')
67 delete_sales_point($selected_id);
68 display_notification(_('Selected point of sale has been deleted'));
77 //----------------------------------------------------------------------------------------------------
79 $result = get_all_sales_points();
82 start_table("$table_style");
84 $th = array (_('POS Name'), _('Credit sale'), _('Cash sale'), _('Location'), _('Default account'),
89 while ($myrow = db_fetch($result))
91 alt_table_row_color($k);
92 label_cell($myrow["pos_name"], "nowrap");
93 label_cell($myrow['credit_sale'] ? _('Yes') : _('No'));
94 label_cell($myrow['cash_sale'] ? _('Yes') : _('No'));
95 label_cell($myrow["location_name"], "");
96 label_cell($myrow["bank_account_name"], "");
97 edit_button_cell("Edit".$myrow['id'], _("Edit"));
98 delete_button_cell("Delete".$myrow['id'], _("Delete"));
105 //----------------------------------------------------------------------------------------------------
109 start_table($table_style2);
111 if ($selected_id != -1)
114 if ($Mode == 'Edit') {
115 $myrow = get_sales_point($selected_id);
117 $_POST['name'] = $myrow["pos_name"];
118 $_POST['location'] = $myrow["pos_location"];
119 $_POST['account'] = $myrow["pos_account"];
120 if ($myrow["credit_sale"]) $_POST['credit_sale'] = 1;
121 if ($myrow["cash_sale"]) $_POST['cash_sale'] = 1;
123 hidden('selected_id', $selected_id);
126 text_row_ex(_("Point of Sale Name").':', 'name', 20, 30);
127 check_row(_('Allowed credit sale'), 'credit', check_value('credit_sale'));
128 check_row(_('Allowed cash sale'), 'cash', check_value('cash_sale'));
129 locations_list_row(_("POS location").':', 'location');
130 cash_accounts_list_row(_("Default cash account").':', 'account');
134 submit_add_or_update_center($selected_id == -1, '', true);