dolibarr 25.0.0-alpha
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2026 Jose Martinez <jose.martinez@pichinov.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../../main.inc.php'; // Load $user and permissions
40require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
45require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
46require_once DOL_DOCUMENT_ROOT.'/stripe/class/stripe.class.php';
47
48$terminal = GETPOSTINT('terminal');
49// If socid provided by ajax company selector
50if (GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha')) {
51 $_GET['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
52 $_POST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
53 $_REQUEST['CASHDESK_ID_THIRDPARTY'.$terminal] = GETPOST('CASHDESK_ID_THIRDPARTY'.$terminal.'_id', 'alpha');
54}
55
56// Security check
57if (!$user->admin) {
59}
60
61$langs->loadLangs(array("admin", "cashdesk", "printing", "receiptprinter"));
62
63$sql = "SELECT code, libelle as label FROM ".MAIN_DB_PREFIX."c_paiement";
64$sql .= " WHERE entity IN (".getEntity('c_paiement').")";
65$sql .= " AND active = 1";
66$sql .= " ORDER BY libelle";
67$resql = $db->query($sql);
68$paiements = array();
69if ($resql) {
70 while ($obj = $db->fetch_object($resql)) {
71 array_push($paiements, $obj);
72 }
73}
74
75$terminaltouse = $terminal;
76
77
78/*
79 * Actions
80 */
81
82$error = 0;
83
84if (GETPOST('action', 'alpha') == 'set') {
85 $db->begin();
86
87 $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);
88
89 $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminaltouse, (GETPOSTINT('socid') > 0 ? GETPOSTINT('socid') : ''), 'chaine', 0, '', $conf->entity);
90
91 if (GETPOSTISSET('projectid')) {
92 $res = dolibarr_set_const($db, "CASHDESK_ID_PROJECT".$terminaltouse, (GETPOSTINT('projectid') > 0 ? GETPOSTINT('projectid') : ''), 'chaine', 0, '', $conf->entity);
93 }
94 if (GETPOSTISSET('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse)) {
95 $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);
96 }
97 if (GETPOSTISSET('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse)) {
98 $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);
99 }
100 if (GETPOSTISSET('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse)) {
101 $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);
102 }
103 if (GETPOSTISSET('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse)) {
104 $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$terminaltouse, GETPOST('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
105 }
106 if (GETPOSTISSET('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse)) {
107 $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);
108 }
109 foreach ($paiements as $modep) {
110 if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
111 continue;
112 }
113 $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
114 if (GETPOSTISSET($name)) {
115 $res = dolibarr_set_const($db, $name, (GETPOST($name, 'alpha') > 0 ? GETPOST($name, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
116 }
117 }
118 if (GETPOSTISSET('CASHDESK_ID_WAREHOUSE'.$terminaltouse)) {
119 $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);
120 }
121 if (GETPOSTISSET('CASHDESK_NO_DECREASE_STOCK'.$terminaltouse)) {
122 $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminaltouse, GETPOST('CASHDESK_NO_DECREASE_STOCK'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
123 }
124 if (GETPOSTISSET('TAKEPOS_PRINTER_TO_USE'.$terminaltouse)) {
125 $res = dolibarr_set_const($db, "TAKEPOS_PRINTER_TO_USE".$terminaltouse, GETPOST('TAKEPOS_PRINTER_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
126 }
127 if (GETPOSTISSET('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminaltouse)) {
128 $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER1_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
129 }
130 if (GETPOSTISSET('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminaltouse)) {
131 $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER2_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
132 }
133 if (GETPOSTISSET('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminaltouse)) {
134 $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER3_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
135 }
136 if (GETPOSTISSET('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminaltouse)) {
137 $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);
138 }
139 if (GETPOSTISSET('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminaltouse)) {
140 $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);
141 }
142
143 if (GETPOSTISSET('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse)) {
144 $res = dolibarr_set_const($db, 'CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse, (GETPOSTINT('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse) > 0 ? GETPOSTINT('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse) : ''), 'chaine', 0, '', $conf->entity);
145 }
146
147 if (GETPOSTISSET('TAKEPOS_ADDON'.$terminaltouse)) {
148 $res = dolibarr_set_const($db, "TAKEPOS_ADDON".$terminaltouse, GETPOST('TAKEPOS_ADDON'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
149 }
150
151 // Add free text on each terminal of cash desk
152 if (GETPOSTISSET('TAKEPOS_HEADER'.$terminaltouse)) {
153 $res = dolibarr_set_const($db, 'TAKEPOS_HEADER'.$terminaltouse, GETPOST('TAKEPOS_HEADER'.$terminaltouse, 'restricthtml'), 'chaine', 0, '', $conf->entity);
154 }
155 if (GETPOSTISSET('TAKEPOS_FOOTER'.$terminaltouse)) {
156 $res = dolibarr_set_const($db, 'TAKEPOS_FOOTER'.$terminaltouse, GETPOST('TAKEPOS_FOOTER'.$terminaltouse, 'restricthtml'), 'chaine', 0, '', $conf->entity);
157 }
158
159 dol_syslog("admin/terminal.php: level ".GETPOST('level', 'alpha'));
160
161 if (!($res > 0)) {
162 $error++;
163 }
164
165 if (!$error) {
166 $db->commit();
167 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
168 } else {
169 $db->rollback();
170 setEventMessages($langs->trans("Error"), null, 'errors');
171 }
172}
173
174
175/*
176 * View
177 */
178
179$form = new Form($db);
180$formproduct = new FormProduct($db);
181
182llxHeader('', $langs->trans("CashDeskSetup"), '', '', 0, 0, '', '', '', 'mod-takepos page-admin_terminal');
183
184$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>';
185
186print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
188print dol_get_fiche_head($head, 'terminal'.$terminal, 'TakePOS', -1, 'cash-register');
189print '<br>';
190
191
192// Mode
193print '<form action="'.$_SERVER["PHP_SELF"].'?terminal='.(empty($terminal) ? 1 : $terminal).'" method="post">';
194print '<input type="hidden" name="token" value="'.newToken().'">';
195print '<input type="hidden" name="action" value="set">';
196
197print '<div class="div-table-responsive">';
198print '<table class="noborder centpercent">';
199print '<tr class="liste_titre">';
200print '<td>'.$langs->trans("Parameters").'</td><td></td>';
201print "</tr>\n";
202
203print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("TerminalNameDesc").'</td>';
204print '<td>';
205print '<input type="text" name="terminalname'.$terminal.'" value="'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$terminal, $langs->trans("TerminalName", $terminal)).'" >';
206print '</td></tr>';
207
208// A disabled terminal is hidden from the terminal selection screen. Its invoices and its
209// reference counter are kept, so it can be enabled again later without losing anything.
210print '<tr class="oddeven"><td>';
211print $form->textwithpicto($langs->trans("TakeposTerminalDisabled"), $langs->trans("TakeposTerminalDisabledHelp"));
212print '</td>';
213print '<td>';
214print ajax_constantonoff("TAKEPOS_TERMINAL_DISABLED_".$terminal, array(), $conf->entity, 0, 0, 1, 0);
215print '</td></tr>';
216
217print '<tr class="oddeven"><td>'.$langs->trans("ForbidSalesToTheDefaultCustomer").'</td>';
218print '<td>';
219print ajax_constantonoff("TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0);
220print '</td></tr>';
221
222if (!getDolGlobalString('TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER')) {
223 print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
224 print '<td>';
225 print img_picto('', 'company', 'class="pictofixedwidth"');
226 $filter = '((s.client:IN:1,2,3) AND (s.status:=:1))';
227 print $form->select_company(getDolGlobalInt('CASHDESK_ID_THIRDPARTY'.$terminaltouse), 'socid', $filter, 1, 0, 0, array(), 0, 'maxwidth500 widthcentpercentminusx');
228 print '</td></tr>';
229}
230
231$atleastonefound = 0;
232if (isModEnabled("bank")) {
233 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
234 print '<td>';
235 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
236 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 0, "(courant:=:2)", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
237 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>';
238 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse)) {
239 $atleastonefound++;
240 }
241 print '</td></tr>';
242 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
243 print '<td>';
244 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
245 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 0, "(courant:=:1)", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
246 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>';
247 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse)) {
248 $atleastonefound++;
249 }
250 print '</td></tr>';
251 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
252 print '<td>';
253 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
254 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 0, "(courant:=:1)", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
255 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>';
256 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse)) {
257 $atleastonefound++;
258 }
259 print '</td></tr>';
260
261 if (isModEnabled('stripe') && getDolGlobalString('STRIPE_CARD_PRESENT')) {
262 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForStripeTerminal").'</td>'; // Force Stripe Terminal
263 print '<td>';
264 $service = 'StripeTest';
265 $servicestatus = 0;
266 if (getDolGlobalString('STRIPE_LIVE')/* && !GETPOST('forcesandbox', 'alpha') */) {
267 $service = 'StripeLive';
268 $servicestatus = 1;
269 }
270 global $stripearrayofkeysbyenv;
271 $site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
272 \Stripe\Stripe::setApiKey($site_account);
273 if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE')/* || GETPOST('forcesandbox', 'alpha') */)) {
274 $service = 'StripeTest';
275 $servicestatus = '0';
276 dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), [], 'warning');
277 } else {
278 $service = 'StripeLive';
279 $servicestatus = '1';
280 }
281 $stripe = new Stripe($db);
282 $stripeacc = $stripe->getStripeAccount($service);
283 if ($stripeacc) {
284 $readers = \Stripe\Terminal\Reader::all(null, array("location" => getDolGlobalString('STRIPE_LOCATION'), "stripe_account" => $stripeacc));
285 } else {
286 $readers = \Stripe\Terminal\Reader::all(null, array("location" => getDolGlobalString('STRIPE_LOCATION')));
287 }
288
289 $reader = array();
290 $reader[""] = $langs->trans("NoReader");
291 foreach ($readers as $tmpreader) {
292 $reader[$tmpreader->id] = $tmpreader->label.' ('.$tmpreader->status.')';
293 }
294 print $form->selectarray('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, $reader, getDolGlobalString('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse));
295 print '</td></tr>';
296 }
297
298 if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
299 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSumup").'</td>';
300 print '<td>';
301 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
302 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 0, "(courant:=:1)", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
303 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>';
304 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse)) {
305 $atleastonefound++;
306 }
307 print '</td></tr>';
308 }
309
310 // Payment mode other than 'LIQ', 'CB', 'CHQ' are not supported by the cash control feature so we must disallow them
311 foreach ($paiements as $modep) {
312 if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
313 continue; // Already managed before
314 }
315 $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
316 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).'</td>';
317 print '<td>';
318 if (getDolGlobalString($name)) {
319 $atleastonefound++;
320 }
321 $cour = preg_match('/^LIQ.*/', $modep->code) ? 2 : 1;
322 if (isALNERunningVersion() && $mysoc->country_code == 'FR') {
323 print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("NotAvailableForCountryWhenModuleIsOn", $mysoc->country_code, $langs->transnoentitiesnoconv('Module3200Name'))).'</span>';
324 } else {
325 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
326 print $form->select_comptes(getDolGlobalInt($name), $name, 0, "(courant:=:".((int) $cour).")", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
327 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>';
328 }
329 print '</td></tr>';
330 }
331}
332
333if (isModEnabled('stock')) {
334 print '<tr class="oddeven"><td>';
335 print $form->textwithpicto($langs->trans("CashDeskDoNotDecreaseStock"), $langs->trans("CashDeskDoNotDecreaseStockHelp"));
336 print '</td>'; // Force warehouse (this is not a default value)
337 print '<td>';
338 //print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal), 1);
339 print ajax_constantonoff('CASHDESK_NO_DECREASE_STOCK'.$terminal, array(), $conf->entity, 0, 0, 1, 0);
340 print '</td></tr>';
341
342
343 $disabled = getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal);
344
345
346 print '<tr class="oddeven"><td>';
347 if (!$disabled) {
348 print '<span class="fieldrequired">';
349 }
350 print $langs->trans("CashDeskIdWareHouse");
351 if (!$disabled) {
352 print '</span>';
353 }
354 if (!$disabled && !getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$terminal)) {
355 print img_warning($langs->trans("DisableStockChange").' - '.$langs->trans("NoWarehouseDefinedForTerminal"));
356 }
357 print '</td>'; // Force warehouse (this is not a default value)
358 print '<td class="minwidth300">';
359 if (!$disabled) {
360 print img_picto('', 'stock', 'class="pictofixedwidth"');
361 print $formproduct->selectWarehouses(getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$terminal), 'CASHDESK_ID_WAREHOUSE'.$terminal, '', 1, $disabled, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx');
362 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>';
363 } else {
364 print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
365 }
366 print '</td></tr>';
367
368 // Deprecated: CASHDESK_FORCE_DECREASE_STOCK is now always false. No more required/used.
369 if (isModEnabled('productbatch') && getDolGlobalString('CASHDESK_FORCE_DECREASE_STOCK') && !getDolGlobalString('CASHDESK_NO_DECREASE_STOCK'.$terminal)) {
370 print '<tr class="oddeven"><td>'.$langs->trans('CashDeskForceDecreaseStockLabel').'</td>';
371 print '<td>';
372 print '<span class="opacitymedium">'.$langs->trans('CashDeskForceDecreaseStockDesc').'</span>';
373 print '</td></tr>';
374 }
375}
376
377if (isModEnabled('project')) {
378 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
379 $formproject = new FormProjets($db);
380 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDefaultProject").'</td><td>';
381 print img_picto('', 'project', 'class="pictofixedwidth"');
382 // select_projects($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 16, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $morecss = '', $htmlid = '', $morefilter = '')
383 $projectid = getDolGlobalInt('CASHDESK_ID_PROJECT'.$terminaltouse);
384 print $formproject->select_projects(-1, (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 1, 'maxwidth500 widthcentpercentminusxx');
385 print '</td></tr>';
386}
387
388print '<tr class="oddeven"><td>'.$langs->trans('CashDeskReaderKeyCodeForEnter').'</td>';
389print '<td>';
390print '<input type="text" class="width50" name="CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse.'" value="'.getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse).'" />';
391print '</td></tr>';
392
393// Numbering module (TODO When this is used ?)
394if (getDolGlobalString('TAKEPOS_ADDON') == "terminal") {
395 print '<tr class="oddeven"><td>';
396 print $langs->trans("BillsNumberingModule");
397 print '<td colspan="2">';
398 $array = array(0 => $langs->trans("Default"));
399 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
400 foreach ($dirmodels as $reldir) {
401 $dir = dol_buildpath($reldir."core/modules/facture/");
402 if (is_dir($dir)) {
403 $handle = opendir($dir);
404 if (is_resource($handle)) {
405 while (($file = readdir($handle)) !== false) {
406 if (!is_dir($dir.$file) || (dol_substr($file, 0, 1) != '.' && dol_substr($file, 0, 3) != 'CVS')) {
407 $filebis = $file;
408 $classname = preg_replace('/\.php$/', '', $file);
409 // For compatibility
410 if (!is_file($dir.$filebis)) {
411 $filebis = $file."/".$file.".modules.php";
412 $classname = "mod_facture_".$file;
413 }
414 // Check if there is a filter on country
415 $reg = array();
416 preg_match('/\-(.*)_(.*)$/', $classname, $reg);
417 if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
418 continue;
419 }
420
421 $classname = preg_replace('/\-.*$/', '', $classname);
422 if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && dol_substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
423 // Charging the numbering class
424 require_once $dir.$filebis;
425
426 $module = new $classname($db);
427 '@phan-var-force ModeleNumRefFactures $module';
428
429 // Show modules according to features level
430 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
431 continue;
432 }
433 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
434 continue;
435 }
436
437 if ($module->isEnabled()) {
438 $array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))] = preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
439 }
440 }
441 }
442 }
443 closedir($handle);
444 }
445 }
446 }
447 print $form->selectarray('TAKEPOS_ADDON'.$terminaltouse, $array, getDolGlobalString('TAKEPOS_ADDON'.$terminaltouse, '0'), 0);
448 print "</td></tr>\n";
449}
450
451
452// Options when using a special printer in TakePOS
453$customprinterallowed = true;
454$orderprinterallowed = (getDolGlobalString('TAKEPOS_BAR_RESTAURANT') && getDolGlobalInt('TAKEPOS_ORDER_PRINTERS'));
455$customprinttemplateallowed = true;
456include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
457if (isALNERunningVersion()) { // No need to show the custom template when isALNERunningVersion is true because it has no effect (disabled by receipt.php).
458 $customprinterallowed = false;
459 $customprinttemplateallowed = false; // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
460}
461
462if (isModEnabled('receiptprinter')) {
463 // Select printer to use with terminal
464 require_once DOL_DOCUMENT_ROOT.'/takepos/class/dolreceiptprinter.class.php';
465 $printer = new dolReceiptPrinter($db);
466
467 $printer->listprinters();
468 $printers = array();
469 foreach ($printer->listprinters as $key => $value) {
470 $printers[$value['rowid']] = $value['name'];
471 }
472 print '<tr class="oddeven"><td>'.$langs->trans("MainPrinterToUse");
473 print ' <span class="opacitymedium">('.$langs->trans("MainPrinterToUseMore").')</span>';
474 print '</td>';
475 print '<td>';
476 if (!$customprinterallowed) { // @phpstan-ignore-line
477 print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("NotAvailableForCountryWhenModuleIsOn", $mysoc->country_code, $langs->transnoentitiesnoconv('Module3200Name'))).'</span>';
478 } else {
479 print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$terminal), 1);
480 }
481 print '</td></tr>';
482
483 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT') && getDolGlobalInt('TAKEPOS_ORDER_PRINTERS') && $orderprinterallowed) {
484 print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("KitchenPrinter").' 1</td>';
485 print '<td>';
486 print $form->selectarray('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal), 1);
487 print '</td></tr>';
488 print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("KitchenPrinter").' 2</td>';
489 print '<td>';
490 print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal), 1);
491 print '</td></tr>';
492 print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("KitchenPrinter").' 3</td>';
493 print '<td>';
494 print $form->selectarray('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal), 1);
495 print '</td></tr>';
496 }
497}
498
499if (isModEnabled('receiptprinter') || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
500 // Select printer to use with terminal
501 require_once DOL_DOCUMENT_ROOT.'/takepos/class/dolreceiptprinter.class.php';
502 $printer = new dolReceiptPrinter($db);
503 $printer->listPrintersTemplates();
504 $templates = array();
505 foreach ($printer->listprinterstemplates as $key => $value) {
506 $templates[$value['rowid']] = $value['name'];
507 }
508 print '<tr class="oddeven"><td>'.$langs->trans("MainTemplateToUse");
509 print ' <span class="opacitymedium">('.$langs->trans("MainTemplateToUseMore").')</span>';
510 if ($customprinttemplateallowed) {
511 print ' (<a href="'.DOL_URL_ROOT.'/admin/receiptprinter.php?mode=template">'.$langs->trans("SetupReceiptTemplate").'</a>)</td>';
512 }
513 print '<td>';
514 if (!$customprinttemplateallowed) {
515 print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("NotAvailableForCountryWhenModuleIsOn", $mysoc->country_code, $langs->transnoentitiesnoconv('Module3200Name'))).'</span>';
516 } else {
517 print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal, $templates, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminal), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150');
518 }
519 print '</td></tr>';
520
521 if (getDolGlobalInt('TAKEPOS_ORDER_PRINTERS') && $orderprinterallowed) {
522 print '<tr class="oddeven"><td>'.$langs->trans("OrderTemplateToUse").'</td>';
523 print '<td>';
524 print $form->selectarray('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal, $templates, getDolGlobalInt('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminal), 1, 0, 0, '', 0, 0, 0, '', 'minwidth150');
525 print '</td></tr>';
526 }
527}
528
529
530print '</table>';
531
532print $form->buttonsSaveCancel("Save", '');
533
534print '</div>';
535
536
537// add free text on each terminal of cash desk
538$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
539$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans('Translation');
540$htmltext = '<i>'.$langs->trans('AvailableVariables').':<br>';
541foreach ($substitutionarray as $key => $val) {
542 $htmltext .= $key.'<br>';
543}
544$htmltext .= '</i>';
545
546print '<br>';
547print load_fiche_titre($langs->trans('FreeLegalTextOnInvoices'), '', '');
548
549print '<div class="div-table-responsive-no-min">';
550print '<table class="noborder centpercent">';
551print '<tr class="liste_titre">';
552print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans('Value').'</td>';
553print '</tr>';
554
555// free text on header
556print '<tr class="oddeven">';
557print '<td>';
558print $form->textwithpicto($langs->trans('Header'), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
559print '</td>';
560print '<td>';
561$variablename = 'TAKEPOS_HEADER'.$terminaltouse;
562if (!getDolGlobalInt('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
563 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
564} else {
565 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
566 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
567 print $doleditor->Create();
568}
569print '</td></tr>';
570
571// free text on footer
572print '<tr class="oddeven">';
573print '<td>';
574print $form->textwithpicto($langs->trans('Footer'), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
575print '</td>';
576print '<td>';
577$variablename = 'TAKEPOS_FOOTER'.$terminaltouse;
578if (!getDolGlobalInt('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
579 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
580} else {
581 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
582 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
583 print $doleditor->Create();
584}
585print '</td></tr>';
586
587print '</table>';
588print '</div>';
589
590if ($atleastonefound == 0 && isModEnabled("bank")) {
591 print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error');
592}
593
594print $form->buttonsSaveCancel("Save", '');
595
596print "</form>\n";
597
598print '<br>';
599
600llxFooter();
601$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).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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
isALNERunningVersion($blockedlogusagealreadychecked=0, $blockedlogmoduleonalreadychecked=0)
Return if the application is executed with the LNE requirements on.
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 ...
Class to manage building of HTML components.
Stripe class @TODO No reason to extend CommonObject.
Class to manage Receipt Printers.
if(! $sortfield) if(! $sortorder) $module
Definition list.php:193
global $mysoc
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_substr($string, $start, $length=null, $stringencoding='', $trunconbytes=0)
Make a substring.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
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.
Definition html.lib.php:540
dol_htmloutput_mesg($mesgstring='', $mesgarray=array(), $style='ok', $keepembedded=0)
Print formatted messages to output (Used to show messages on html output).
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
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:1180
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.