dolibarr 24.0.0-beta
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-2026 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
38require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
42require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
43
44// Security check
45if (!$user->admin) {
47}
48
49$langs->loadLangs(array("admin", "cashdesk", "printing"));
50
51$res = 0;
52
53
54/*
55 * Actions
56 */
57$error = 0;
58
59if (GETPOST('action', 'alpha') == 'set') {
60 $db->begin();
61
62 dol_syslog("admin/bar");
63
64 $suplement_category = GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha');
65 if ($suplement_category < 0) {
66 $suplement_category = 0;
67 }
68
69 $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", $suplement_category, 'chaine', 0, '', $conf->entity);
70 if ($res <= 0) {
71 $error++;
72 }
73
74 if (!$error) {
75 $db->commit();
76 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
77 } else {
78 $db->rollback();
79 setEventMessages($langs->trans("Error"), null, 'errors');
80 }
81}
82
83if (getDolGlobalInt('TAKEPOS_ORDER_NOTES') == 1) {
84 $extrafields = new ExtraFields($db);
85 $extrafields->addExtraField('order_notes', 'Order notes', 'varchar', 0, '255', 'facturedet', 0, 0, '', '', 0, '', '0', '1');
86}
87
88/*
89 * View
90 */
91
92$form = new Form($db);
93$formproduct = new FormProduct($db);
94
95$arrayofjs = array();
96$arrayofcss = array("/takepos/css/colorbox.css");
97
98llxHeader('', $langs->trans("CashDeskSetup"), '', '', 0, 0, $arrayofjs, $arrayofcss, '', 'mod-takepos page-admin_bar');
99
100$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>';
101
102print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
104print dol_get_fiche_head($head, 'bar', 'TakePOS', -1, 'cash-register');
105
106
107// Mode
108print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
109print '<input type="hidden" name="token" value="'.newToken().'">';
110print '<input type="hidden" name="action" value="set">';
111
112?>
113<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 -->
114<script type="text/javascript">
115function Floors() {
116 console.log("Open box to select floor");
117 $.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"); ?>"});
118}
119</script>
120
121<?php
122
123print '<center>';
124print $langs->trans("EnableBarOrRestaurantFeatures");
125print ajax_constantonoff("TAKEPOS_BAR_RESTAURANT", array(), $conf->entity, 0, 0, 1, 0);
126print '</center>';
127
128if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
129 print '<br>';
130 print '<br>';
131 print '<a href="" onclick="Floors(); return false;"><span class="fa fa-glass-cheers"></span> '.$langs->trans("DefineTablePlan").'</a><br>';
132 print '<br><br>';
133
134 print '<div class="div-table-responsive-no-min">';
135 print '<table class="noborder centpercent">';
136 print '<tr class="liste_titre">';
137 print '<td>'.$langs->trans("Parameters").'</td><td class=""></td>';
138 print "</tr>\n";
139
140 print '<tr class="oddeven value"><td>';
141 print $langs->trans("OrderPrinters");
142 print '</td>';
143 print '<td class="">';
144 print ajax_constantonoff("TAKEPOS_ORDER_PRINTERS", array(), $conf->entity, 0, 0, 1, 0);
145 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
146 print' &nbsp; <a href="'.DOL_URL_ROOT.'/takepos/admin/orderprinters.php?leftmenu=setup">'.$langs->trans("Setup").'</a>';
147 }
148 print '</td></tr>';
149
150 if (getDolGlobalString('TAKEPOS_ORDER_PRINTERS')) {
151 print '<tr class="oddeven value"><td>';
152 print $langs->trans("OrderNotes");
153 print '</td>';
154 print '<td class="">';
155 print ajax_constantonoff("TAKEPOS_ORDER_NOTES", array(), $conf->entity, 0, 0, 1, 0);
156 print '</td></tr>';
157 }
158 /*else {
159 print '<tr class="oddeven value"><td>';
160 print $langs->trans("OrderPrinters");
161 print '</td>';
162 print '<td class="">';
163 print '<span class="opacitymedium">'.$langs->trans("NotAvailableWithBrowserPrinter").'</span>';
164 print '</td></tr>';
165
166 print '<tr class="oddeven value"><td>';
167 print $langs->trans("OrderNotes");
168 print '</td>';
169 print '<td class="">';
170 print '<span class="opacitymedium">'.$langs->trans("NotAvailableWithBrowserPrinter").'</span>';
171 print '</td></tr>';
172 }*/
173
174 print '<tr class="oddeven value"><td>';
175 print $langs->trans("ProductSupplements");
176 print '</td>';
177 print '<td class="">';
178 //print $form->selectyesno("TAKEPOS_SUPPLEMENTS", $conf->global->TAKEPOS_SUPPLEMENTS, 1);
179 print ajax_constantonoff("TAKEPOS_SUPPLEMENTS", array(), $conf->entity, 0, 0, 1, 0);
180 print '</td></tr>';
181
182 if (getDolGlobalInt('TAKEPOS_SUPPLEMENTS')) {
183 print '<tr class="oddeven"><td>';
184 print $langs->trans("SupplementCategory");
185 print '</td>';
186 print '<td class="nowrap">';
187 //print $form->selectCategories(Categorie::TYPE_PRODUCT, 'TAKEPOS_SUPPLEMENTS_CATEGORY', null);
188 print img_picto('', 'category', 'class="pictofixedwidth"');
189 print $form->select_all_categories(Categorie::TYPE_PRODUCT, getDolGlobalString('TAKEPOS_SUPPLEMENTS_CATEGORY'), 'TAKEPOS_SUPPLEMENTS_CATEGORY', 64, 0, 0, 0, 'minwidth 200 maxwidth500 widthcentpercentminusx');
190 print ajax_combobox('TAKEPOS_SUPPLEMENTS_CATEGORY');
191 print "</td></tr>\n";
192 }
193
194 print '<tr class="oddeven value"><td>';
195 print 'QR - '.$langs->trans("CustomerMenu");
196 print '</td>';
197 print '<td class="">';
198 print ajax_constantonoff("TAKEPOS_QR_MENU", array(), $conf->entity, 0, 0, 1, 0);
199 print '</td></tr>';
200
201 print '<tr class="oddeven value"><td>';
202 print 'QR - '.$langs->trans("AutoOrder");
203 print ' - <span class="warning">'.$langs->trans("Development").'</span>';
204 print '</td>';
205 print '<td class="">';
206 print ajax_constantonoff("TAKEPOS_AUTO_ORDER", array(), $conf->entity, 0, 0, 1, 0);
207 print '</td></tr>';
208
209 print '</table>';
210 print '</div>';
211
212 print '<br>';
213
214 print $form->buttonsSaveCancel("Save", '');
215}
216
217if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
218 if (getDolGlobalInt('TAKEPOS_QR_MENU')) {
219 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
220 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
221 print '<br>';
222 print '<div class="div-table-responsive-no-min">';
223 print '<table class="noborder centpercent">';
224 print '<tr class="liste_titre">';
225 print '<td>'.$langs->trans("URL").' - '.$langs->trans("CustomerMenu").'</td><td class="right">'.$langs->trans("QR").'</td>';
226 print "</tr>\n";
227 print '<tr class="oddeven value"><td>';
228 print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/takepos/public/menu.php">'.$urlwithroot.'/takepos/public/menu.php</a>';
229 print '</td>';
230 print '<td class="right">';
231 print '<a target="_blank" rel="noopener noreferrer" href="printqr.php"><img src="'.DOL_URL_ROOT.'/takepos/genimg/qr.php" height="42" width="42"></a>';
232 print '</td></tr>';
233 print '</table>';
234 print '</div>';
235 }
236
237 if (getDolGlobalInt('TAKEPOS_AUTO_ORDER')) {
238 print '<br>';
239 print '<div class="div-table-responsive-no-min">';
240 print '<table class="noborder centpercent">';
241 print '<tr class="liste_titre">';
242 print '<td>'.$langs->trans("Table").'</td><td>'.$langs->trans("URL").' - '.$langs->trans("AutoOrder").'</td><td class="right">'.$langs->trans("QR").'</td>';
243 print "</tr>\n";
244
245 //global $dolibarr_main_url_root;
246 $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
247 $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
248 $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables WHERE entity IN (".getEntity('takepos').")";
249 $resql = $db->query($sql);
250 $rows = array();
251 while ($row = $db->fetch_array($resql)) {
252 print '<tr class="oddeven value"><td>';
253 print $langs->trans("Table")." ".$row['label'];
254 print '</td>';
255 print '<td>';
256 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>';
257 print '</td>';
258 print '<td class="right">';
259 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>';
260 print '</td></tr>';
261 }
262
263 print '</table>';
264 print '</div>';
265 }
266}
267
268
269print "</form>\n";
270
271print '<br>';
272
273llxFooter();
274$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 ...
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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:130
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.