dolibarr 19.0.3
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
28require '../../main.inc.php'; // Load $user and permissions
29require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
33require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
34require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
35
36$terminal = GETPOST('terminal', 'int');
37// If socid provided by ajax company selector
38if (!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
45if (!$user->admin) {
47}
48
49$langs->loadLangs(array("admin", "cashdesk", "printing", "receiptprinter"));
50
51global $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();
59if ($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
72if (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') && getDolGlobalString('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
135llxHeader('', $langs->trans("CashDeskSetup"));
136
137$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
138print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
140print dol_get_fiche_head($head, 'terminal'.$terminal, 'TakePOS', -1, 'cash-register');
141print '<br>';
142
143
144// Mode
145print '<form action="'.$_SERVER["PHP_SELF"].'?terminal='.(empty($terminal) ? 1 : $terminal).'" method="post">';
146print '<input type="hidden" name="token" value="'.newToken().'">';
147print '<input type="hidden" name="action" value="set">';
148
149print '<div class="div-table-responsive">';
150print '<table class="noborder centpercent">';
151print '<tr class="liste_titre">';
152print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
153print "</tr>\n";
154
155print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("TerminalNameDesc").'</td>';
156print '<td>';
157print '<input type="text" name="terminalname'.$terminal.'" value="'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$terminal, $langs->trans("TerminalName", $terminal)).'" >';
158print '</td></tr>';
159
160print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
161print '<td>';
162print img_picto('', 'company', 'class="pictofixedwidth"');
163$filter = '((s.client:IN:1,2,3) AND (s.status:=:1))';
164print $form->select_company(getDolGlobalInt('CASHDESK_ID_THIRDPARTY'.$terminaltouse), 'socid', $filter, 1, 0, 0, array(), 0, 'maxwidth500 widthcentpercentminusx');
165print '</td></tr>';
166
167$atleastonefound = 0;
168if (isModEnabled("banque")) {
169 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
170 print '<td>';
171 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
172 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 0, "courant=2", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
173 print ' <a href="'.DOL_URL_ROOT.'/compta/bank/card.php?action=create&type=2&backtopage='.urlencode($_SERVER["PHP_SELF"].'?terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewBankAccount").'"></span></a>';
174 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse)) {
175 $atleastonefound++;
176 }
177 print '</td></tr>';
178 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
179 print '<td>';
180 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
181 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 0, "courant=1", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
182 print ' <a href="'.DOL_URL_ROOT.'/compta/bank/card.php?action=create&type=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewBankAccount").'"></span></a>';
183 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse)) {
184 $atleastonefound++;
185 }
186 print '</td></tr>';
187 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
188 print '<td>';
189 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
190 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 0, "courant=1", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
191 print ' <a href="'.DOL_URL_ROOT.'/compta/bank/card.php?action=create&type=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewBankAccount").'"></span></a>';
192 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse)) {
193 $atleastonefound++;
194 }
195 print '</td></tr>';
196
197 if (isModEnabled('stripe') && getDolGlobalString('STRIPE_CARD_PRESENT')) {
198 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForStripeTerminal").'</td>'; // Force Stripe Terminal
199 print '<td>';
200 $service = 'StripeTest';
201 $servicestatus = 0;
202 if (getDolGlobalString('STRIPE_LIVE') && !GETPOST('forcesandbox', 'alpha')) {
203 $service = 'StripeLive';
204 $servicestatus = 1;
205 }
206 global $stripearrayofkeysbyenv;
207 $site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
208 \Stripe\Stripe::setApiKey($site_account);
209 if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE') || GETPOST('forcesandbox', 'alpha'))) {
210 $service = 'StripeTest';
211 $servicestatus = '0';
212 dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), '', 'warning');
213 } else {
214 $service = 'StripeLive';
215 $servicestatus = '1';
216 }
217 $stripe = new Stripe($db);
218 $stripeacc = $stripe->getStripeAccount($service);
219 if ($stripeacc) {
220 $readers = \Stripe\Terminal\Reader::all('', array("location" => $conf->global->STRIPE_LOCATION, "stripe_account" => $stripeacc));
221 } else {
222 $readers = \Stripe\Terminal\Reader::all('', array("location" => $conf->global->STRIPE_LOCATION));
223 }
224
225 $reader = array();
226 $reader[""] = $langs->trans("NoReader");
227 foreach ($readers as $tmpreader) {
228 $reader[$tmpreader->id] = $tmpreader->label.' ('.$tmpreader->status.')';
229 }
230 print $form->selectarray('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, $reader, getDolGlobalString('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse));
231 print '</td></tr>';
232 }
233
234 if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
235 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSumup").'</td>';
236 print '<td>';
237 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
238 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 0, "courant=1", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
239 print ' <a href="'.DOL_URL_ROOT.'/compta/bank/card.php?action=create&type=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewBankAccount").'"></span></a>';
240 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse)) {
241 $atleastonefound++;
242 }
243 print '</td></tr>';
244 }
245
246 foreach ($paiements as $modep) {
247 if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
248 continue; // Already managed before
249 }
250 $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
251 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).'</td>';
252 print '<td>';
253 if (getDolGlobalString($name)) {
254 $atleastonefound++;
255 }
256 $cour = preg_match('/^LIQ.*/', $modep->code) ? 2 : 1;
257 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
258 print $form->select_comptes(getDolGlobalInt($name), $name, 0, "courant=".$cour, 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
259 print ' <a href="'.DOL_URL_ROOT.'/compta/bank/card.php?action=create&type=1&backtopage='.urlencode($_SERVER["PHP_SELF"].'?terminal='.$terminal).'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("NewBankAccount").'"></span></a>';
260 print '</td></tr>';
261 }
262}
263
264if (isModEnabled('stock')) {
265 print '<tr class="oddeven"><td>';
266 print $form->textwithpicto($langs->trans("CashDeskDoNotDecreaseStock"), $langs->trans("CashDeskDoNotDecreaseStockHelp"));
267 print '</td>'; // Force warehouse (this is not a default value)
268 print '<td>';
269 print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal), 1);
270 print '</td></tr>';
271
272 $disabled = getDolGlobalString('CASHDESK_NO_DECREASE_STOCK'.$terminal);
273
274
275 print '<tr class="oddeven"><td>';
276 if (!$disabled) {
277 print '<span class="fieldrequired">';
278 }
279 print $langs->trans("CashDeskIdWareHouse");
280 if (!$disabled) {
281 print '</span>';
282 }
283 if (!getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$terminal)) {
284 print img_warning($langs->trans("DisableStockChange").' - '.$langs->trans("NoWarehouseDefinedForTerminal"));
285 }
286 print '</td>'; // Force warehouse (this is not a default value)
287 print '<td class="minwidth300">';
288 if (!$disabled) {
289 print img_picto('', 'stock', 'class="pictofixedwidth"');
290 print $formproduct->selectWarehouses(getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$terminal), 'CASHDESK_ID_WAREHOUSE'.$terminal, '', 1, $disabled, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx');
291 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>';
292 } else {
293 print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
294 }
295 print '</td></tr>';
296
297 // Deprecated: CASHDESK_FORCE_DECREASE_STOCK is now always false. No more required/used.
298 if (isModEnabled('productbatch') && getDolGlobalString('CASHDESK_FORCE_DECREASE_STOCK') && !getDolGlobalString('CASHDESK_NO_DECREASE_STOCK'.$terminal)) {
299 print '<tr class="oddeven"><td>'.$langs->trans('CashDeskForceDecreaseStockLabel').'</td>';
300 print '<td>';
301 print '<span class="opacitymedium">'.$langs->trans('CashDeskForceDecreaseStockDesc').'</span>';
302 print '</td></tr>';
303 }
304}
305
306if (isModEnabled('receiptprinter')) {
307 // Select printer to use with terminal
308 require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
309 $printer = new dolReceiptPrinter($db);
310
311 $printer->listprinters();
312 $printers = array();
313 foreach ($printer->listprinters as $key => $value) {
314 $printers[$value['rowid']] = $value['name'];
315 }
316 print '<tr class="oddeven"><td>'.$langs->trans("MainPrinterToUse");
317 print ' <span class="opacitymedium">('.$langs->trans("MainPrinterToUseMore").')</span>';
318 print '</td>';
319 print '<td>';
320 print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$terminal), 1);
321 print '</td></tr>';
322 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT') && getDolGlobalInt('TAKEPOS_ORDER_PRINTERS')) {
323 print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 1</td>';
324 print '<td>';
325 print $form->selectarray('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal), 1);
326 print '</td></tr>';
327 print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 2</td>';
328 print '<td>';
329 print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal), 1);
330 print '</td></tr>';
331 print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("Printer").' 3</td>';
332 print '<td>';
333 print $form->selectarray('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal), 1);
334 print '</td></tr>';
335 }
336}
337
338if (isModEnabled('receiptprinter') || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
339 // Select printer to use with terminal
340 require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
341 $printer = new dolReceiptPrinter($db);
342 $printer->listPrintersTemplates();
343 $templates = array();
344 foreach ($printer->listprinterstemplates as $key => $value) {
345 $templates[$value['rowid']] = $value['name'];
346 }
347 print '<tr class="oddeven"><td>'.$langs->trans("MainTemplateToUse");
348 print ' <span class="opacitymedium">('.$langs->trans("MainTemplateToUseMore").')</span>';
349 print ' (<a href="'.DOL_URL_ROOT.'/admin/receiptprinter.php?mode=template">'.$langs->trans("SetupReceiptTemplate").'</a>)</td>';
350 print '<td>';
351 print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal), 1);
352 print '</td></tr>';
353 if (getDolGlobalInt('TAKEPOS_ORDER_PRINTERS')) {
354 print '<tr class="oddeven"><td>'.$langs->trans("OrderTemplateToUse").'</td>';
355 print '<td>';
356 print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal, $templates, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal), 1);
357 print '</td></tr>';
358 }
359}
360
361print '<tr class="oddeven"><td>'.$langs->trans('CashDeskReaderKeyCodeForEnter').'</td>';
362print '<td>';
363print '<input type="text" class="width50" name="CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse.'" value="'.getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse).'" />';
364print '</td></tr>';
365
366// Numbering module
367if (getDolGlobalString('TAKEPOS_ADDON') == "terminal") {
368 print '<tr class="oddeven"><td>';
369 print $langs->trans("BillsNumberingModule");
370 print '<td colspan="2">';
371 $array = array(0 => $langs->trans("Default"));
372 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
373 foreach ($dirmodels as $reldir) {
374 $dir = dol_buildpath($reldir."core/modules/facture/");
375 if (is_dir($dir)) {
376 $handle = opendir($dir);
377 if (is_resource($handle)) {
378 while (($file = readdir($handle)) !== false) {
379 if (!is_dir($dir.$file) || (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS')) {
380 $filebis = $file;
381 $classname = preg_replace('/\.php$/', '', $file);
382 // For compatibility
383 if (!is_file($dir.$filebis)) {
384 $filebis = $file."/".$file.".modules.php";
385 $classname = "mod_facture_".$file;
386 }
387 // Check if there is a filter on country
388 preg_match('/\-(.*)_(.*)$/', $classname, $reg);
389 if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
390 continue;
391 }
392
393 $classname = preg_replace('/\-.*$/', '', $classname);
394 if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
395 // Charging the numbering class
396 require_once $dir.$filebis;
397
398 $module = new $classname($db);
399
400 // Show modules according to features level
401 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
402 continue;
403 }
404 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
405 continue;
406 }
407
408 if ($module->isEnabled()) {
409 $array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))] = preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
410 }
411 }
412 }
413 }
414 closedir($handle);
415 }
416 }
417 }
418 print $form->selectarray('TAKEPOS_ADDON'.$terminaltouse, $array, getDolGlobalString('TAKEPOS_ADDON'.$terminaltouse, '0'), 0);
419 print "</td></tr>\n";
420 print '</table>';
421 print '</div>';
422}
423
424print '</table>';
425print '</div>';
426
427// add free text on each terminal of cash desk
428$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
429$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans('Translation');
430$htmltext = '<i>'.$langs->trans('AvailableVariables').':<br>';
431foreach ($substitutionarray as $key => $val) {
432 $htmltext .= $key.'<br>';
433}
434$htmltext .= '</i>';
435
436print '<br>';
437print load_fiche_titre($langs->trans('FreeLegalTextOnInvoices'), '', '');
438
439print '<div class="div-table-responsive-no-min">';
440print '<table class="noborder centpercent">';
441print '<tr class="liste_titre">';
442print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans('Value').'</td>';
443print '</tr>';
444
445// free text on header
446print '<tr class="oddeven">';
447print '<td>';
448print $form->textwithpicto($langs->trans('Header'), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
449print '</td>';
450print '<td>';
451$variablename = 'TAKEPOS_HEADER'.$terminaltouse;
452if (!getDolGlobalInt('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
453 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
454} else {
455 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
456 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
457 print $doleditor->Create();
458}
459print '</td></tr>';
460
461// free text on footer
462print '<tr class="oddeven">';
463print '<td>';
464print $form->textwithpicto($langs->trans('Footer'), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
465print '</td>';
466print '<td>';
467$variablename = 'TAKEPOS_FOOTER'.$terminaltouse;
468if (!getDolGlobalInt('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
469 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
470} else {
471 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
472 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
473 print $doleditor->Create();
474}
475print '</td></tr>';
476
477print '</table>';
478print '</div>';
479
480if ($atleastonefound == 0 && isModEnabled("banque")) {
481 print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error');
482}
483
484print '<br>';
485
486print $form->buttonsSaveCancel("Save", '');
487
488print "</form>\n";
489
490print '<br>';
491
492llxFooter();
493$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()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a 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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formated messages to output (Used to show messages on html output).
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition pdf.lib.php:762
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.