dolibarr 23.0.3
bar.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
4 * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../main.inc.php'; // Load $user and permissions
37require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
41require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
42
43// Security check
44if (!$user->admin) {
46}
47
48$langs->loadLangs(array("admin", "cashdesk", "printing"));
49
50$res = 0;
51
52
53/*
54 * Actions
55 */
56$error = 0;
57
58if (GETPOST('action', 'alpha') == 'set') {
59 $db->begin();
60
61 dol_syslog("admin/bar");
62
63 $suplement_category = GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha');
64 if ($suplement_category < 0) {
65 $suplement_category = 0;
66 }
67
68 $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", $suplement_category, 'chaine', 0, '', $conf->entity);
69 if ($res <= 0) {
70 $error++;
71 }
72
73 if (!$error) {
74 $db->commit();
75 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
76 } else {
77 $db->rollback();
78 setEventMessages($langs->trans("Error"), null, 'errors');
79 }
80}
81
82if (getDolGlobalInt('TAKEPOS_ORDER_NOTES') == 1) {
83 $extrafields = new ExtraFields($db);
84 $extrafields->addExtraField('order_notes', 'Order notes', 'varchar', 0, '255', 'facturedet', 0, 0, '', '', 0, '', '0', '1');
85}
86
87/*
88 * View
89 */
90
91$form = new Form($db);
92$formproduct = new FormProduct($db);
93
94$arrayofjs = array();
95$arrayofcss = array("/takepos/css/colorbox.css");
96
97llxHeader('', $langs->trans("CashDeskSetup"), '', '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-takepos page-admin_bar');
98
99$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
100
101print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
103print dol_get_fiche_head($head, 'bar', 'TakePOS', -1, 'cash-register');
104
105
106// Mode
107print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
108print '<input type="hidden" name="token" value="'.newToken().'">';
109print '<input type="hidden" name="action" value="set">';
110
111?>
112<script type="text/javascript" src="<?php echo DOL_URL_ROOT ?>/takepos/js/jquery.colorbox-min.js"></script> <!-- TODO It seems we don't need this -->
113<script type="text/javascript">
114function Floors() {
115 console.log("Open box to select floor");
116 $.colorbox({href:"<?php echo DOL_URL_ROOT ?>/takepos/floors.php?mode=edit&place=0", width:"90%", height:"90%", transition:"none", iframe:"true", title:"<?php echo $langs->trans("Floors"); ?>"});
117}
118</script>
119
120<?php
121
122print '<center>';
123print $langs->trans("EnableBarOrRestaurantFeatures");
124print ajax_constantonoff("TAKEPOS_BAR_RESTAURANT", array(), $conf->entity, 0, 0, 1, 0);
125print '</center>';
126
127if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
128 print '<br>';
129 print '<br>';
130 print '<a href="" onclick="Floors(); return false;"><span class="fa fa-glass-cheers"></span> '.$langs->trans("DefineTablePlan").'</a><br>';
131 print '<br><br>';
132
133 print '<div class="div-table-responsive-no-min">';
134 print '<table class="noborder centpercent">';
135 print '<tr class="liste_titre">';
136 print '<td>'.$langs->trans("Parameters").'</td><td class=""></td>';
137 print "</tr>\n";
138
139 print '<tr class="oddeven value"><td>';
140 print $langs->trans("OrderPrinters");
141 print '</td>';
142 print '<td class="">';
143 print ajax_constantonoff("TAKEPOS_ORDER_PRINTERS", array(), $conf->entity, 0, 0, 1, 0);
144 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
145 print' &nbsp; <a href="'.DOL_URL_ROOT.'/takepos/admin/orderprinters.php?leftmenu=setup">'.$langs->trans("Setup").'</a>';
146 }
147 print '</td></tr>';
148
149 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
150 print '<tr class="oddeven value"><td>';
151 print $langs->trans("OrderNotes");
152 print '</td>';
153 print '<td class="">';
154 print ajax_constantonoff("TAKEPOS_ORDER_NOTES", array(), $conf->entity, 0, 0, 1, 0);
155 print '</td></tr>';
156 }
157 /*else {
158 print '<tr class="oddeven value"><td>';
159 print $langs->trans("OrderPrinters");
160 print '</td>';
161 print '<td class="">';
162 print '<span class="opacitymedium">'.$langs->trans("NotAvailableWithBrowserPrinter").'</span>';
163 print '</td></tr>';
164
165 print '<tr class="oddeven value"><td>';
166 print $langs->trans("OrderNotes");
167 print '</td>';
168 print '<td class="">';
169 print '<span class="opacitymedium">'.$langs->trans("NotAvailableWithBrowserPrinter").'</span>';
170 print '</td></tr>';
171 }*/
172
173 print '<tr class="oddeven value"><td>';
174 print $langs->trans("ProductSupplements");
175 print '</td>';
176 print '<td class="">';
177 //print $form->selectyesno("TAKEPOS_SUPPLEMENTS", $conf->global->TAKEPOS_SUPPLEMENTS, 1);
178 print ajax_constantonoff("TAKEPOS_SUPPLEMENTS", array(), $conf->entity, 0, 0, 1, 0);
179 print '</td></tr>';
180
181 if (getDolGlobalInt('TAKEPOS_SUPPLEMENTS')) {
182 print '<tr class="oddeven"><td>';
183 print $langs->trans("SupplementCategory");
184 print '</td>';
185 print '<td class="nowrap">';
186 //print $form->selectCategories(Categorie::TYPE_PRODUCT, 'TAKEPOS_SUPPLEMENTS_CATEGORY', null);
187 print img_picto('', 'category', 'class="pictofixedwidth"');
188 print $form->select_all_categories(Categorie::TYPE_PRODUCT, getDolGlobalString('TAKEPOS_SUPPLEMENTS_CATEGORY'), 'TAKEPOS_SUPPLEMENTS_CATEGORY', 64, 0, 0, 0, 'minwidth 200 maxwidth500 widthcentpercentminusx');
189 print ajax_combobox('TAKEPOS_SUPPLEMENTS_CATEGORY');
190 print "</td></tr>\n";
191 }
192
193 print '<tr class="oddeven value"><td>';
194 print 'QR - '.$langs->trans("CustomerMenu");
195 print '</td>';
196 print '<td class="">';
197 print ajax_constantonoff("TAKEPOS_QR_MENU", array(), $conf->entity, 0, 0, 1, 0);
198 print '</td></tr>';
199
200 print '<tr class="oddeven value"><td>';
201 print 'QR - '.$langs->trans("AutoOrder");
202 print ' - <span class="warning">'.$langs->trans("Development").'</span>';
203 print '</td>';
204 print '<td class="">';
205 print ajax_constantonoff("TAKEPOS_AUTO_ORDER", array(), $conf->entity, 0, 0, 1, 0);
206 print '</td></tr>';
207
208 print '</table>';
209 print '</div>';
210
211 print '<br>';
212
213 print $form->buttonsSaveCancel("Save", '');
214}
215
216if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
217 if (getDolGlobalInt('TAKEPOS_QR_MENU')) {
218 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
219 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
220 print '<br>';
221 print '<div class="div-table-responsive-no-min">';
222 print '<table class="noborder centpercent">';
223 print '<tr class="liste_titre">';
224 print '<td>'.$langs->trans("URL").' - '.$langs->trans("CustomerMenu").'</td><td class="right">'.$langs->trans("QR").'</td>';
225 print "</tr>\n";
226 print '<tr class="oddeven value"><td>';
227 print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/takepos/public/menu.php">'.$urlwithroot.'/takepos/public/menu.php</a>';
228 print '</td>';
229 print '<td class="right">';
230 print '<a target="_blank" rel="noopener noreferrer" href="printqr.php"><img src="'.DOL_URL_ROOT.'/takepos/genimg/qr.php" height="42" width="42"></a>';
231 print '</td></tr>';
232 print '</table>';
233 print '</div>';
234 }
235
236 if (getDolGlobalInt('TAKEPOS_AUTO_ORDER')) {
237 print '<br>';
238 print '<div class="div-table-responsive-no-min">';
239 print '<table class="noborder centpercent">';
240 print '<tr class="liste_titre">';
241 print '<td>'.$langs->trans("Table").'</td><td>'.$langs->trans("URL").' - '.$langs->trans("AutoOrder").'</td><td class="right">'.$langs->trans("QR").'</td>';
242 print "</tr>\n";
243
244 //global $dolibarr_main_url_root;
245 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
246 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
247 $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables WHERE entity IN (".getEntity('takepos').")";
248 $resql = $db->query($sql);
249 $rows = array();
250 while ($row = $db->fetch_array($resql)) {
251 print '<tr class="oddeven value"><td>';
252 print $langs->trans("Table")." ".$row['label'];
253 print '</td>';
254 print '<td>';
255 print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot."/takepos/public/auto_order.php?key=".dol_encode($row['rowid']).'">'.$urlwithroot."/takepos/public/auto_order.php?key=".dol_encode($row['rowid']).'</a>';
256 print '</td>';
257 print '<td class="right">';
258 print '<a target="_blank" rel="noopener noreferrer" href="printqr.php?id='.$row['rowid'].'"><img src="'.DOL_URL_ROOT.'/takepos/genimg/qr.php?key='.dol_encode($row['rowid']).'" height="42" width="42"></a>';
259 print '</td></tr>';
260 }
261
262 print '</table>';
263 print '</div>';
264 }
265}
266
267
268print "</form>\n";
269
270print '<br>';
271
272llxFooter();
273$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage standard extra fields.
Class to manage generation of HTML components Only common components must be here.
Class with static methods for building HTML components related to products Only components common to ...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
treeview li table
No Email.
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:125
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
takepos_admin_prepare_head()
Prepare array with list of tabs.