dolibarr  16.0.5
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  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 require '../../main.inc.php'; // Load $user and permissions
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
31 require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
32 
33 // Security check
34 if (!$user->admin) {
36 }
37 
38 $langs->loadLangs(array("admin", "cashdesk", "printing"));
39 
40 $res = 0;
41 
42 
43 /*
44  * Actions
45  */
46 
47 if (GETPOST('action', 'alpha') == 'set') {
48  $db->begin();
49 
50  dol_syslog("admin/bar");
51 
52  $suplement_category = GETPOST('TAKEPOS_SUPPLEMENTS_CATEGORY', 'alpha');
53  if ($suplement_category < 0) {
54  $suplement_category = 0;
55  }
56 
57  $res = dolibarr_set_const($db, "TAKEPOS_SUPPLEMENTS_CATEGORY", $suplement_category, 'chaine', 0, '', $conf->entity);
58  if ($res <= 0) {
59  $error++;
60  }
61 
62  if (!$error) {
63  $db->commit();
64  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
65  } else {
66  $db->rollback();
67  setEventMessages($langs->trans("Error"), null, 'errors');
68  }
69 }
70 
71 if (getDolGlobalInt('TAKEPOS_ORDER_NOTES') == 1) {
72  $extrafields = new ExtraFields($db);
73  $extrafields->addExtraField('order_notes', 'Order notes', 'varchar', 0, 255, 'facturedet', 0, 0, '', '', 0, '', 0, 1);
74 }
75 
76 /*
77  * View
78  */
79 
80 $form = new Form($db);
81 $formproduct = new FormProduct($db);
82 
83 $arrayofjs = array();
84 $arrayofcss = array("/takepos/css/colorbox.css");
85 
86 llxHeader('', $langs->trans("CashDeskSetup"), '', '', 0, 0, $arrayofjs, $arrayofcss);
87 
88 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
89 print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
91 print dol_get_fiche_head($head, 'bar', 'TakePOS', -1, 'cash-register');
92 
93 
94 // Mode
95 print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
96 print '<input type="hidden" name="token" value="'.newToken().'">';
97 print '<input type="hidden" name="action" value="set">';
98 
99 ?>
100 <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 -->
101 <script type="text/javascript">
102 function Floors() {
103  console.log("Open box to select floor");
104  $.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"); ?>"});
105 }
106 </script>
107 
108 <?php
109 
110 print '<center>';
111 print $langs->trans("EnableBarOrRestaurantFeatures");
112 print ajax_constantonoff("TAKEPOS_BAR_RESTAURANT", array(), $conf->entity, 0, 0, 1, 0);
113 print '</center>';
114 
115 print '<br>';
116 
117 if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
118  print '<br>';
119  print '<a href="" onclick="Floors(); return false;"><span class="fa fa-glass-cheers"></span> '.$langs->trans("DefineTablePlan").'</a><br>';
120  print '<br><br>';
121 
122  print '<div class="div-table-responsive-no-min">';
123  print '<table class="noborder centpercent">';
124  print '<tr class="liste_titre">';
125  print '<td>'.$langs->trans("Parameters").'</td><td class="center">'.$langs->trans("Value").'</td>';
126  print "</tr>\n";
127 
128  if ($conf->global->TAKEPOS_PRINT_METHOD != "browser") { // Why this ?
129  print '<tr class="oddeven value"><td>';
130  print $langs->trans("OrderPrinters").' (<a href="'.DOL_URL_ROOT.'/takepos/admin/orderprinters.php?leftmenu=setup">'.$langs->trans("Setup").'</a>)';
131  print '</td>';
132  print '<td class="center">';
133  print ajax_constantonoff("TAKEPOS_ORDER_PRINTERS", array(), $conf->entity, 0, 0, 1, 0);
134  //print $form->selectyesno("TAKEPOS_ORDER_PRINTERS", $conf->global->TAKEPOS_ORDER_PRINTERS, 1);
135  print '</td></tr>';
136 
137  print '<tr class="oddeven value"><td>';
138  print $langs->trans("OrderNotes");
139  print '</td>';
140  print '<td class="center">';
141  print ajax_constantonoff("TAKEPOS_ORDER_NOTES", array(), $conf->entity, 0, 0, 1, 0);
142  //print $form->selectyesno("TAKEPOS_ORDER_NOTES", $conf->global->TAKEPOS_ORDER_NOTES, 1);
143  print '</td></tr>';
144  } else {
145  print '<tr class="oddeven value"><td>';
146  print $langs->trans("OrderPrinters");
147  print '</td>';
148  print '<td class="center">';
149  print '<span class="opacitymedium">'.$langs->trans("NotAvailableWithBrowserPrinter").'</span>';
150  print '</td></tr>';
151 
152  print '<tr class="oddeven value"><td>';
153  print $langs->trans("OrderNotes");
154  print '</td>';
155  print '<td class="center">';
156  print '<span class="opacitymedium">'.$langs->trans("NotAvailableWithBrowserPrinter").'</span>';
157  print '</td></tr>';
158  }
159 
160  print '<tr class="oddeven value"><td>';
161  print $langs->trans("BasicPhoneLayout");
162  print '</td>';
163  print '<td class="center">';
164  //print $form->selectyesno("TAKEPOS_PHONE_BASIC_LAYOUT", $conf->global->TAKEPOS_PHONE_BASIC_LAYOUT, 1);
165  print ajax_constantonoff("TAKEPOS_PHONE_BASIC_LAYOUT", array(), $conf->entity, 0, 0, 1, 0);
166  print '</td></tr>';
167 
168  print '<tr class="oddeven value"><td>';
169  print $langs->trans("ProductSupplements");
170  print '</td>';
171  print '<td class="center">';
172  //print $form->selectyesno("TAKEPOS_SUPPLEMENTS", $conf->global->TAKEPOS_SUPPLEMENTS, 1);
173  print ajax_constantonoff("TAKEPOS_SUPPLEMENTS", array(), $conf->entity, 0, 0, 1, 0);
174  print '</td></tr>';
175 
176  if (getDolGlobalInt('TAKEPOS_SUPPLEMENTS')) {
177  print '<tr class="oddeven"><td>';
178  print $langs->trans("SupplementCategory");
179  print '</td>';
180  print '<td class="center">';
181  print $form->select_all_categories(Categorie::TYPE_PRODUCT, getDolGlobalString('TAKEPOS_SUPPLEMENTS_CATEGORY'), 'TAKEPOS_SUPPLEMENTS_CATEGORY', 64, 0, 0);
182  print ajax_combobox('TAKEPOS_SUPPLEMENTS_CATEGORY');
183  print "</td></tr>\n";
184  }
185 
186  print '<tr class="oddeven value"><td>';
187  print 'QR - '.$langs->trans("CustomerMenu");
188  print '</td>';
189  print '<td class="center">';
190  print ajax_constantonoff("TAKEPOS_QR_MENU", array(), $conf->entity, 0, 0, 1, 0);
191  print '</td></tr>';
192 
193  print '<tr class="oddeven value"><td>';
194  print 'QR - '.$langs->trans("AutoOrder");
195  print '</td>';
196  print '<td class="center">';
197  print ajax_constantonoff("TAKEPOS_AUTO_ORDER", array(), $conf->entity, 0, 0, 1, 0);
198  print '</td></tr>';
199 
200  print '</table>';
201  print '</div>';
202 
203  print '<br>';
204 
205  print $form->buttonsSaveCancel("Save", '');
206 }
207 
208 if (getDolGlobalInt('TAKEPOS_BAR_RESTAURANT')) {
209  if (getDolGlobalInt('TAKEPOS_QR_MENU')) {
210  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
211  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
212  print '<br>';
213  print '<table class="noborder centpercent">';
214  print '<tr class="liste_titre">';
215  print '<td>'.$langs->trans("URL").' - '.$langs->trans("CustomerMenu").'</td><td class="right">'.$langs->trans("QR").'</td>';
216  print "</tr>\n";
217  print '<tr class="oddeven value"><td>';
218  print '<a target="_blank" rel="noopener noreferrer" href="'.$urlwithroot.'/takepos/public/menu.php">'.$urlwithroot.'/takepos/public/menu.php</a>';
219  print '</td>';
220  print '<td class="right">';
221  print '<a target="_blank" rel="noopener noreferrer" href="printqr.php"><img src="'.DOL_URL_ROOT.'/takepos/genimg/qr.php" height="42" width="42"></a>';
222  print '</td></tr>';
223  print '</table>';
224  }
225 
226  if (getDolGlobalInt('TAKEPOS_AUTO_ORDER')) {
227  print '<br>';
228  print '<table class="noborder centpercent">';
229  print '<tr class="liste_titre">';
230  print '<td>'.$langs->trans("Table").'</td><td>'.$langs->trans("URL").' - '.$langs->trans("AutoOrder").'</td><td class="right">'.$langs->trans("QR").'</td>';
231  print "</tr>\n";
232 
233  //global $dolibarr_main_url_root;
234  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
235  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
236  $sql = "SELECT rowid, entity, label, leftpos, toppos, floor FROM ".MAIN_DB_PREFIX."takepos_floor_tables";
237  $resql = $db->query($sql);
238  $rows = array();
239  while ($row = $db->fetch_array($resql)) {
240  print '<tr class="oddeven value"><td>';
241  print $langs->trans("Table")." ".$row['label'];
242  print '</td>';
243  print '<td>';
244  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>';
245  print '</td>';
246  print '<td class="right">';
247  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>';
248  print '</td></tr>';
249  }
250 
251  print '</table>';
252  }
253 }
254 
255 
256 print "</form>\n";
257 
258 print '<br>';
259 
260 llxFooter();
261 $db->close();
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
rowid
print *****$script_file(".$version.") pid c cd cd cd description as p label as s rowid
Definition: email_expire_services_to_representatives.php:79
takepos_admin_prepare_head
takepos_admin_prepare_head()
Prepare array with list of tabs.
Definition: takepos.lib.php:30
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
FormProduct
Class with static methods for building HTML components related to products Only components common to ...
Definition: html.formproduct.class.php:30
dolibarr_set_const
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).
Definition: admin.lib.php:627
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
Definition: security.lib.php:933
getDolGlobalInt
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
Definition: functions.lib.php:93
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59