5 include_once($path_to_root . "/includes/session.inc");
7 page(_("POS settings"));
9 include_once($path_to_root . "/includes/ui.inc");
10 include_once($path_to_root . "/sales/includes/db/sales_points_db.inc");
12 simple_page_mode(true);
13 //----------------------------------------------------------------------------------------------------
15 function can_process()
17 if (strlen($_POST['name']) == 0)
19 display_error(_("The POS name cannot be empty."));
20 set_focus('pos_name');
23 if (!check_value('cash') && !check_value('credit'))
25 display_error(_("You must allow cash or credit sale."));
33 //----------------------------------------------------------------------------------------------------
35 if ($Mode=='ADD_ITEM' && can_process())
37 add_sales_point($_POST['name'], $_POST['location'], $_POST['account'],
38 check_value('cash'), check_value('credit'));
39 display_notification(_('New point of sale has been added'));
43 //----------------------------------------------------------------------------------------------------
45 if ($Mode=='UPDATE_ITEM' && can_process())
48 update_sales_point($selected_id, $_POST['name'], $_POST['location'],
49 $_POST['account'], check_value('cash'), check_value('credit'));
50 display_notification(_('Selected point of sale has been updated'));
54 //----------------------------------------------------------------------------------------------------
56 if ($Mode == 'Delete')
58 delete_sales_point($selected_id);
59 display_notification(_('Selected point of sale has been deleted'));
68 //----------------------------------------------------------------------------------------------------
70 $result = get_all_sales_points();
73 start_table("$table_style");
75 $th = array (_('POS Name'), _('Credit sale'), _('Cash sale'), _('Location'), _('Default account'),
80 while ($myrow = db_fetch($result))
82 alt_table_row_color($k);
83 label_cell($myrow["pos_name"], "nowrap");
84 label_cell($myrow['credit_sale'] ? _('Yes') : _('No'));
85 label_cell($myrow['cash_sale'] ? _('Yes') : _('No'));
86 label_cell($myrow["location_name"], "");
87 label_cell($myrow["bank_account_name"], "");
88 edit_button_cell("Edit".$myrow['id'], _("Edit"));
89 edit_button_cell("Delete".$myrow['id'], _("Delete"));
96 //----------------------------------------------------------------------------------------------------
100 start_table("$table_style2 width=30%");
102 if ($selected_id != -1)
105 if ($Mode == 'Edit') {
106 $myrow = get_sales_point($selected_id);
108 $_POST['name'] = $myrow["pos_name"];
109 $_POST['location'] = $myrow["pos_location"];
110 $_POST['account'] = $myrow["pos_account"];
111 if ($myrow["credit_sale"]) $_POST['credit_sale'] = 1;
112 if ($myrow["cash_sale"]) $_POST['cash_sale'] = 1;
114 hidden('selected_id', $selected_id);
117 text_row_ex(_("Point of Sale Name").':', 'name', 20, 30);
118 check_row(_('Allowed credit sale'), 'credit', check_value('credit_sale'));
119 check_row(_('Allowed cash sale'), 'cash', check_value('cash_sale'));
120 locations_list_row(_("POS location").':', 'location');
121 cash_accounts_list_row(_("Default cash account").':', 'account');
125 submit_add_or_update_center($selected_id == -1, '', true);