dolibarr  17.0.4
terminal.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) 2021 Thibault FOUCART <support@ptibogxiv.net>
5  * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 // Load Dolibarr environment
28 require '../../main.inc.php'; // Load $user and permissions
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
33 require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
34 require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
35 
36 $terminal = GETPOST('terminal', 'int');
37 // If socid provided by ajax company selector
38 if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal.'_id'])) {
39  $_GET['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
40  $_POST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
41  $_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
42 }
43 
44 // Security check
45 if (!$user->admin) {
47 }
48 
49 $langs->loadLangs(array("admin", "cashdesk", "printing", "receiptprinter"));
50 
51 global $db;
52 
53 $sql = "SELECT code, libelle as label FROM ".MAIN_DB_PREFIX."c_paiement";
54 $sql .= " WHERE entity IN (".getEntity('c_paiement').")";
55 $sql .= " AND active = 1";
56 $sql .= " ORDER BY libelle";
57 $resql = $db->query($sql);
58 $paiements = array();
59 if ($resql) {
60  while ($obj = $db->fetch_object($resql)) {
61  array_push($paiements, $obj);
62  }
63 }
64 
65 $terminaltouse = $terminal;
66 
67 
68 /*
69  * Actions
70  */
71 
72 if (GETPOST('action', 'alpha') == 'set') {
73  $db->begin();
74 
75  $res = dolibarr_set_const($db, "TAKEPOS_TERMINAL_NAME_".$terminaltouse, (!empty(GETPOST('terminalname'.$terminaltouse, 'restricthtml')) ? GETPOST('terminalname'.$terminaltouse, 'restricthtml') : $langs->trans("TerminalName", $terminaltouse)), 'chaine', 0, '', $conf->entity);
76 
77  $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminaltouse, (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
78 
79  $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
80  $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
81  $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
82  if (isModEnabled('stripe') && !empty($conf->global->STRIPE_CARD_PRESENT)) {
83  $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$terminaltouse, GETPOST('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
84  }
85  if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
86  $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_SUMUP".$terminaltouse, (GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
87  }
88  foreach ($paiements as $modep) {
89  if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
90  continue;
91  }
92  $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
93  $res = dolibarr_set_const($db, $name, (GETPOST($name, 'alpha') > 0 ? GETPOST($name, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
94  }
95  $res = dolibarr_set_const($db, "CASHDESK_ID_WAREHOUSE".$terminaltouse, (GETPOST('CASHDESK_ID_WAREHOUSE'.$terminaltouse, 'alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE'.$terminaltouse, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
96  $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminaltouse, GETPOST('CASHDESK_NO_DECREASE_STOCK'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
97  $res = dolibarr_set_const($db, "TAKEPOS_PRINTER_TO_USE".$terminaltouse, GETPOST('TAKEPOS_PRINTER_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
98  $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER1_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
99  $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER2_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
100  $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER3_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
101  $res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
102  $res = dolibarr_set_const($db, "TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS".$terminaltouse, GETPOST('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
103 
104  $res = dolibarr_set_const($db, 'CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, (GETPOST('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, 'int') > 0 ? GETPOST('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, 'int') : ''), 'chaine', 0, '', $conf->entity);
105 
106  $res = dolibarr_set_const($db, "TAKEPOS_ADDON".$terminaltouse, GETPOST('TAKEPOS_ADDON'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
107 
108  // add free text on each terminal of cash desk
109  $res = dolibarr_set_const($db, 'TAKEPOS_HEADER'.$terminaltouse, GETPOST('TAKEPOS_HEADER'.$terminaltouse, 'restricthtml'), 'chaine', 0, '', $conf->entity);
110  $res = dolibarr_set_const($db, 'TAKEPOS_FOOTER'.$terminaltouse, GETPOST('TAKEPOS_FOOTER'.$terminaltouse, 'restricthtml'), 'chaine', 0, '', $conf->entity);
111 
112  dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
113 
114  if (!($res > 0)) {
115  $error++;
116  }
117 
118  if (!$error) {
119  $db->commit();
120  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
121  } else {
122  $db->rollback();
123  setEventMessages($langs->trans("Error"), null, 'errors');
124  }
125 }
126 
127 
128 /*
129  * View
130  */
131 
132 $form = new Form($db);
133 $formproduct = new FormProduct($db);
134 
135 llxHeader('', $langs->trans("CashDeskSetup"));
136 
137 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
138 print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
140 print dol_get_fiche_head($head, 'terminal'.$terminal, 'TakePOS', -1, 'cash-register');
141 print '<br>';
142 
143 
144 // Mode
145 print '<form action="'.$_SERVER["PHP_SELF"].'?terminal='.(empty($terminal) ? 1 : $terminal).'" method="post">';
146 print '<input type="hidden" name="token" value="'.newToken().'">';
147 print '<input type="hidden" name="action" value="set">';
148 
149 print '<div class="div-table-responsive">';
150 print '<table class="noborder centpercent">';
151 print '<tr class="liste_titre">';
152 print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
153 print "</tr>\n";
154 
155 print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("TerminalNameDesc").'</td>';
156 print '<td>';
157 print '<input type="text" name="terminalname'.$terminal.'" value="'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$terminal, $langs->trans("TerminalName", $terminal)).'" >';
158 print '</td></tr>';
159 
160 print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
161 print '<td>';
162 print $form->select_company(getDolGlobalInt('CASHDESK_ID_THIRDPARTY'.$terminaltouse), 'socid', '(s.client IN (1, 3) AND s.status = 1)', 1, 0, 0, array(), 0);
163 print '</td></tr>';
164 
165 $atleastonefound = 0;
166 if (isModEnabled("banque")) {
167  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
168  print '<td>';
169  print img_picto('', 'bank_account', 'class="pictofixedwidth"');
170  $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 0, "courant=2", 1);
171  if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse)) {
172  $atleastonefound++;
173  }
174  print '</td></tr>';
175  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
176  print '<td>';
177  print img_picto('', 'bank_account', 'class="pictofixedwidth"');
178  $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 0, "courant=1", 1);
179  if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse)) {
180  $atleastonefound++;
181  }
182  print '</td></tr>';
183  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
184  print '<td>';
185  print img_picto('', 'bank_account', 'class="pictofixedwidth"');
186  $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 0, "courant=1", 1);
187  if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse)) {
188  $atleastonefound++;
189  }
190  print '</td></tr>';
191 
192  if (isModEnabled('stripe') && !empty($conf->global->STRIPE_CARD_PRESENT)) {
193  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForStripeTerminal").'</td>'; // Force Stripe Terminal
194  print '<td>';
195  $service = 'StripeTest';
196  $servicestatus = 0;
197  if (!empty($conf->global->STRIPE_LIVE) && !GETPOST('forcesandbox', 'alpha')) {
198  $service = 'StripeLive';
199  $servicestatus = 1;
200  }
201  global $stripearrayofkeysbyenv;
202  $site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
203  \Stripe\Stripe::setApiKey($site_account);
204  if (isModEnabled('stripe') && (empty($conf->global->STRIPE_LIVE) || GETPOST('forcesandbox', 'alpha'))) {
205  $service = 'StripeTest';
206  $servicestatus = '0';
207  dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
208  } else {
209  $service = 'StripeLive';
210  $servicestatus = '1';
211  }
212  $stripe = new Stripe($db);
213  $stripeacc = $stripe->getStripeAccount($service);
214  if ($stripeacc) {
215  $readers = \Stripe\Terminal\Reader::all('', array("location" => $conf->global->STRIPE_LOCATION, "stripe_account" => $stripeacc));
216  } else {
217  $readers = \Stripe\Terminal\Reader::all('', array("location" => $conf->global->STRIPE_LOCATION));
218  }
219 
220  $reader = array();
221  $reader[""] = $langs->trans("NoReader");
222  foreach ($readers as $tmpreader) {
223  $reader[$tmpreader->id] = $tmpreader->label.' ('.$tmpreader->status.')';
224  }
225  print $form->selectarray('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, $reader, $conf->global->{'CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse});
226  print '</td></tr>';
227  }
228 
229  if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
230  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSumup").'</td>';
231  print '<td>';
232  print img_picto('', 'bank_account', 'class="pictofixedwidth"');
233  $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 0, "courant=1", 1);
234  if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse)) {
235  $atleastonefound++;
236  }
237  print '</td></tr>';
238  }
239 
240  foreach ($paiements as $modep) {
241  if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
242  continue; // Already managed before
243  }
244  $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
245  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).'</td>';
246  print '<td>';
247  if (!empty($conf->global->$name)) {
248  $atleastonefound++;
249  }
250  $cour = preg_match('/^LIQ.*/', $modep->code) ? 2 : 1;
251  print img_picto('', 'bank_account', 'class="pictofixedwidth"');
252  $form->select_comptes(getDolGlobalInt($name), $name, 0, "courant=".$cour, 1);
253  print '</td></tr>';
254  }
255 }
256 
257 if (isModEnabled('stock')) {
258  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value)
259  print '<td>';
260  if (!isModEnabled('productbatch') || getDolGlobalInt('CASHDESK_FORCE_DECREASE_STOCK')) {
261  print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal), 1);
262  } else {
263  if (getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal)) {
264  $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminal, 1, 'chaine', 0, '', $conf->entity);
265  }
266  print $langs->trans("Yes").'<br>';
267  print '<span class="opacitymedium">'.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').'</span>';
268  }
269  print '</td></tr>';
270 
271  $disabled = $conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal};
272 
273 
274  print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
275  print '<td class="minwidth300">';
276  if (!$disabled) {
277  print img_picto('', 'bank_account', 'class="pictofixedwidth"');
278  print $formproduct->selectWarehouses($conf->global->{'CASHDESK_ID_WAREHOUSE'.$terminal}, 'CASHDESK_ID_WAREHOUSE'.$terminal, '', 1, $disabled, 0, '', 0, 0, array(), 'maxwidth250');
279  print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"].'?&terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle"></span></a>';
280  } else {
281  print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
282  }
283  print '</td></tr>';
284 
285  if (isModEnabled('productbatch') && !empty($conf->global->CASHDESK_FORCE_DECREASE_STOCK) && !$conf->global->{'CASHDESK_NO_DECREASE_STOCK'.$terminal}) {
286  print '<tr class="oddeven"><td>'.$langs->trans('CashDeskForceDecreaseStockLabel').'</td>';
287  print '<td>';
288  print '<span class="opacitymedium">'.$langs->trans('CashDeskForceDecreaseStockDesc').'</span>';
289  print '</td></tr>';
290  }
291 }
292 
293 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
294  // Select printer to use with terminal
295  require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
296  $printer = new dolReceiptPrinter($db);
297  if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter") {
298  $printer->listprinters();
299  $printers = array();
300  foreach ($printer->listprinters as $key => $value) {
301  $printers[$value['rowid']] = $value['name'];
302  }
303  print '<tr class="oddeven"><td>'.$langs->trans("MainPrinterToUse").'</td>';
304  print '<td>';
305  print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$terminal), 1);
306  print '</td></tr>';
307  if (getDolGlobalInt('TAKEPOS_ORDER_PRINTERS')) {
308  print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 1</td>';
309  print '<td>';
310  print $form->selectarray('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal), 1);
311  print '</td></tr>';
312  print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 2</td>';
313  print '<td>';
314  print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal), 1);
315  print '</td></tr>';
316  print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 3</td>';
317  print '<td>';
318  print $form->selectarray('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal), 1);
319  print '</td></tr>';
320  }
321  }
322  $printer->listPrintersTemplates();
323  $templates = array();
324  foreach ($printer->listprinterstemplates as $key => $value) {
325  $templates[$value['rowid']] = $value['name'];
326  }
327  print '<tr class="oddeven"><td>'.$langs->trans("MainTemplateToUse").' (<a href="'.DOL_URL_ROOT.'/admin/receiptprinter.php?mode=template">'.$langs->trans("SetupReceiptTemplate").'</a>)</td>';
328  print '<td>';
329  print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal), 1);
330  print '</td></tr>';
331  if (getDolGlobalInt('TAKEPOS_ORDER_PRINTERS')) {
332  print '<tr class="oddeven"><td>'.$langs->trans("OrderTemplateToUse").'</td>';
333  print '<td>';
334  print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal, $templates, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal), 1);
335  print '</td></tr>';
336  }
337 }
338 
339 print '<tr class="oddeven"><td>'.$langs->trans('CashDeskReaderKeyCodeForEnter').'</td>';
340 print '<td>';
341 print '<input type="text" class="width50" name="CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse.'" value="'.getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse).'" />';
342 print '</td></tr>';
343 
344 // Numbering module
345 if (getDolGlobalString('TAKEPOS_ADDON') == "terminal") {
346  print '<tr class="oddeven"><td>';
347  print $langs->trans("BillsNumberingModule");
348  print '<td colspan="2">';
349  $array = array(0=>$langs->trans("Default"));
350  $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
351  foreach ($dirmodels as $reldir) {
352  $dir = dol_buildpath($reldir."core/modules/facture/");
353  if (is_dir($dir)) {
354  $handle = opendir($dir);
355  if (is_resource($handle)) {
356  while (($file = readdir($handle)) !== false) {
357  if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) {
358  $filebis = $file;
359  $classname = preg_replace('/\.php$/', '', $file);
360  // For compatibility
361  if (!is_file($dir.$filebis)) {
362  $filebis = $file."/".$file.".modules.php";
363  $classname = "mod_facture_".$file;
364  }
365  // Check if there is a filter on country
366  preg_match('/\-(.*)_(.*)$/', $classname, $reg);
367  if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
368  continue;
369  }
370 
371  $classname = preg_replace('/\-.*$/', '', $classname);
372  if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
373  // Charging the numbering class
374  require_once $dir.$filebis;
375 
376  $module = new $classname($db);
377 
378  // Show modules according to features level
379  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
380  continue;
381  }
382  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
383  continue;
384  }
385 
386  if ($module->isEnabled()) {
387  $array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))] = preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
388  }
389  }
390  }
391  }
392  closedir($handle);
393  }
394  }
395  }
396  print $form->selectarray('TAKEPOS_ADDON'.$terminaltouse, $array, (empty($conf->global->{'TAKEPOS_ADDON'.$terminaltouse}) ? '0' : $conf->global->{'TAKEPOS_ADDON'.$terminaltouse}), 0);
397  print "</td></tr>\n";
398  print '</table>';
399  print '</div>';
400 }
401 
402 print '</table>';
403 print '</div>';
404 
405 // add free text on each terminal of cash desk
406 $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
407 $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans('Translation');
408 $htmltext = '<i>'.$langs->trans('AvailableVariables').':<br>';
409 foreach ($substitutionarray as $key => $val) {
410  $htmltext .= $key.'<br>';
411 }
412 $htmltext .= '</i>';
413 
414 print '<br>';
415 print load_fiche_titre($langs->trans('FreeLegalTextOnInvoices'), '', '');
416 
417 print '<div class="div-table-responsive-no-min">';
418 print '<table class="noborder centpercent">';
419 print '<tr class="liste_titre">';
420 print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans('Value').'</td>';
421 print '</tr>';
422 
423 // free text on header
424 print '<tr class="oddeven">';
425 print '<td>';
426 print $form->textwithpicto($langs->trans('Header'), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
427 print '</td>';
428 print '<td>';
429 $variablename = 'TAKEPOS_HEADER'.$terminaltouse;
430 if (!getDolGlobalInt('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
431  print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->{$variablename}.'</textarea>';
432 } else {
433  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
434  $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
435  print $doleditor->Create();
436 }
437 print '</td></tr>';
438 
439 // free text on footer
440 print '<tr class="oddeven">';
441 print '<td>';
442 print $form->textwithpicto($langs->trans('Footer'), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
443 print '</td>';
444 print '<td>';
445 $variablename = 'TAKEPOS_FOOTER'.$terminaltouse;
446 if (!getDolGlobalInt('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
447  print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->{$variablename}.'</textarea>';
448 } else {
449  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
450  $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
451  print $doleditor->Create();
452 }
453 print '</td></tr>';
454 
455 print '</table>';
456 print '</div>';
457 
458 if ($atleastonefound == 0 && isModEnabled("banque")) {
459  print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error');
460 }
461 
462 print '<br>';
463 
464 print $form->buttonsSaveCancel("Save", '');
465 
466 print "</form>\n";
467 
468 print '<br>';
469 
470 llxFooter();
471 $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).
Definition: admin.lib.php:632
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage a WYSIWYG editor.
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 ...
Stripe class.
Class to manage Receipt Printers.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition: pdf.lib.php:749
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.
Definition: takepos.lib.php:30