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