dolibarr 23.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 * 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 $res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY".$terminaltouse, (GETPOSTINT('socid') > 0 ? GETPOSTINT('socid') : ''), 'chaine', 0, '', $conf->entity);
89
90 if (GETPOSTISSET('projectid')) {
91 $res = dolibarr_set_const($db, "CASHDESK_ID_PROJECT".$terminaltouse, (GETPOSTINT('projectid') > 0 ? GETPOSTINT('projectid') : ''), 'chaine', 0, '', $conf->entity);
92 }
93 if (GETPOSTISSET('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse)) {
94 $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);
95 }
96 if (GETPOSTISSET('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse)) {
97 $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);
98 }
99 if (GETPOSTISSET('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse)) {
100 $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);
101 }
102 if (GETPOSTISSET('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse)) {
103 $res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL".$terminaltouse, GETPOST('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
104 }
105 if (GETPOSTISSET('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse)) {
106 $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);
107 }
108 foreach ($paiements as $modep) {
109 if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
110 continue;
111 }
112 $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
113 if (GETPOSTISSET($name)) {
114 $res = dolibarr_set_const($db, $name, (GETPOST($name, 'alpha') > 0 ? GETPOST($name, 'alpha') : ''), 'chaine', 0, '', $conf->entity);
115 }
116 }
117 if (GETPOSTISSET('CASHDESK_ID_WAREHOUSE'.$terminaltouse)) {
118 $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);
119 }
120 if (GETPOSTISSET('CASHDESK_NO_DECREASE_STOCK'.$terminaltouse)) {
121 $res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK".$terminaltouse, GETPOST('CASHDESK_NO_DECREASE_STOCK'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
122 }
123 if (GETPOSTISSET('TAKEPOS_PRINTER_TO_USE'.$terminaltouse)) {
124 $res = dolibarr_set_const($db, "TAKEPOS_PRINTER_TO_USE".$terminaltouse, GETPOST('TAKEPOS_PRINTER_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
125 }
126 if (GETPOSTISSET('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminaltouse)) {
127 $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER1_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
128 }
129 if (GETPOSTISSET('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminaltouse)) {
130 $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER2_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
131 }
132 if (GETPOSTISSET('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminaltouse)) {
133 $res = dolibarr_set_const($db, "TAKEPOS_ORDER_PRINTER3_TO_USE".$terminaltouse, GETPOST('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
134 }
135 if (GETPOSTISSET('TAKEPOS_TEMPLATE_TO_USE_FOR_INVOICES'.$terminaltouse)) {
136 $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);
137 }
138 if (GETPOSTISSET('TAKEPOS_TEMPLATE_TO_USE_FOR_ORDERS'.$terminaltouse)) {
139 $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);
140 }
141
142 if (GETPOSTISSET('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse)) {
143 $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);
144 }
145
146 if (GETPOSTISSET('TAKEPOS_ADDON'.$terminaltouse)) {
147 $res = dolibarr_set_const($db, "TAKEPOS_ADDON".$terminaltouse, GETPOST('TAKEPOS_ADDON'.$terminaltouse, 'alpha'), 'chaine', 0, '', $conf->entity);
148 }
149
150 // Add free text on each terminal of cash desk
151 if (GETPOSTISSET('TAKEPOS_HEADER'.$terminaltouse)) {
152 $res = dolibarr_set_const($db, 'TAKEPOS_HEADER'.$terminaltouse, GETPOST('TAKEPOS_HEADER'.$terminaltouse, 'restricthtml'), 'chaine', 0, '', $conf->entity);
153 }
154 if (GETPOSTISSET('TAKEPOS_FOOTER'.$terminaltouse)) {
155 $res = dolibarr_set_const($db, 'TAKEPOS_FOOTER'.$terminaltouse, GETPOST('TAKEPOS_FOOTER'.$terminaltouse, 'restricthtml'), 'chaine', 0, '', $conf->entity);
156 }
157
158 dol_syslog("admin/terminal.php: level ".GETPOST('level', 'alpha'));
159
160 if (!($res > 0)) {
161 $error++;
162 }
163
164 if (!$error) {
165 $db->commit();
166 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
167 } else {
168 $db->rollback();
169 setEventMessages($langs->trans("Error"), null, 'errors');
170 }
171}
172
173
174/*
175 * View
176 */
177
178$form = new Form($db);
179$formproduct = new FormProduct($db);
180
181llxHeader('', $langs->trans("CashDeskSetup"), '', '', 0, 0, '', '', '', 'mod-takepos page-admin_terminal');
182
183$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>';
184
185print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
187print dol_get_fiche_head($head, 'terminal'.$terminal, 'TakePOS', -1, 'cash-register');
188print '<br>';
189
190
191// Mode
192print '<form action="'.$_SERVER["PHP_SELF"].'?terminal='.(empty($terminal) ? 1 : $terminal).'" method="post">';
193print '<input type="hidden" name="token" value="'.newToken().'">';
194print '<input type="hidden" name="action" value="set">';
195
196print '<div class="div-table-responsive">';
197print '<table class="noborder centpercent">';
198print '<tr class="liste_titre">';
199print '<td>'.$langs->trans("Parameters").'</td><td></td>';
200print "</tr>\n";
201
202print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("TerminalNameDesc").'</td>';
203print '<td>';
204print '<input type="text" name="terminalname'.$terminal.'" value="'.getDolGlobalString("TAKEPOS_TERMINAL_NAME_".$terminal, $langs->trans("TerminalName", $terminal)).'" >';
205print '</td></tr>';
206
207print '<tr class="oddeven"><td>'.$langs->trans("ForbidSalesToTheDefaultCustomer").'</td>';
208print '<td>';
209print ajax_constantonoff("TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0);
210print '</td></tr>';
211
212if (!getDolGlobalString('TAKEPOS_FORBID_SALES_TO_DEFAULT_CUSTOMER')) {
213 print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
214 print '<td>';
215 print img_picto('', 'company', 'class="pictofixedwidth"');
216 $filter = '((s.client:IN:1,2,3) AND (s.status:=:1))';
217 print $form->select_company(getDolGlobalInt('CASHDESK_ID_THIRDPARTY'.$terminaltouse), 'socid', $filter, 1, 0, 0, array(), 0, 'maxwidth500 widthcentpercentminusx');
218 print '</td></tr>';
219}
220
221$atleastonefound = 0;
222if (isModEnabled("bank")) {
223 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
224 print '<td>';
225 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
226 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse, 0, "courant=2", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
227 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>';
228 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CASH'.$terminaltouse)) {
229 $atleastonefound++;
230 }
231 print '</td></tr>';
232 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
233 print '<td>';
234 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
235 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse, 0, "courant=1", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
236 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>';
237 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CHEQUE'.$terminaltouse)) {
238 $atleastonefound++;
239 }
240 print '</td></tr>';
241 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
242 print '<td>';
243 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
244 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse, 0, "courant=1", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
245 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>';
246 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_CB'.$terminaltouse)) {
247 $atleastonefound++;
248 }
249 print '</td></tr>';
250
251 if (isModEnabled('stripe') && getDolGlobalString('STRIPE_CARD_PRESENT')) {
252 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForStripeTerminal").'</td>'; // Force Stripe Terminal
253 print '<td>';
254 $service = 'StripeTest';
255 $servicestatus = 0;
256 if (getDolGlobalString('STRIPE_LIVE')/* && !GETPOST('forcesandbox', 'alpha') */) {
257 $service = 'StripeLive';
258 $servicestatus = 1;
259 }
260 global $stripearrayofkeysbyenv;
261 $site_account = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
262 \Stripe\Stripe::setApiKey($site_account);
263 if (isModEnabled('stripe') && (!getDolGlobalString('STRIPE_LIVE')/* || GETPOST('forcesandbox', 'alpha') */)) {
264 $service = 'StripeTest';
265 $servicestatus = '0';
266 dol_htmloutput_mesg($langs->trans('YouAreCurrentlyInSandboxMode', 'Stripe'), [], 'warning');
267 } else {
268 $service = 'StripeLive';
269 $servicestatus = '1';
270 }
271 $stripe = new Stripe($db);
272 $stripeacc = $stripe->getStripeAccount($service);
273 if ($stripeacc) {
274 $readers = \Stripe\Terminal\Reader::all(null, array("location" => getDolGlobalString('STRIPE_LOCATION'), "stripe_account" => $stripeacc));
275 } else {
276 $readers = \Stripe\Terminal\Reader::all(null, array("location" => getDolGlobalString('STRIPE_LOCATION')));
277 }
278
279 $reader = array();
280 $reader[""] = $langs->trans("NoReader");
281 foreach ($readers as $tmpreader) {
282 $reader[$tmpreader->id] = $tmpreader->label.' ('.$tmpreader->status.')';
283 }
284 print $form->selectarray('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse, $reader, getDolGlobalString('CASHDESK_ID_BANKACCOUNT_STRIPETERMINAL'.$terminaltouse));
285 print '</td></tr>';
286 }
287
288 if (getDolGlobalInt('TAKEPOS_ENABLE_SUMUP')) {
289 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSumup").'</td>';
290 print '<td>';
291 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
292 print $form->select_comptes(getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse), 'CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse, 0, "courant=1", 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
293 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>';
294 if (getDolGlobalInt('CASHDESK_ID_BANKACCOUNT_SUMUP'.$terminaltouse)) {
295 $atleastonefound++;
296 }
297 print '</td></tr>';
298 }
299
300 // Payment mode other than 'LIQ', 'CB', 'CHQ' are not supported by the cash control feature so we must disallow them
301 foreach ($paiements as $modep) {
302 if (in_array($modep->code, array('LIQ', 'CB', 'CHQ'))) {
303 continue; // Already managed before
304 }
305 $name = "CASHDESK_ID_BANKACCOUNT_".$modep->code.$terminaltouse;
306 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountFor").' '.$langs->trans($modep->label).'</td>';
307 print '<td>';
308 if (getDolGlobalString($name)) {
309 $atleastonefound++;
310 }
311 $cour = preg_match('/^LIQ.*/', $modep->code) ? 2 : 1;
312 if (isALNERunningVersion() && $mysoc->country_code == 'FR') {
313 print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("NotAvailableForCountryWhenModuleIsOn", $mysoc->country_code, $langs->transnoentitiesnoconv('Module3200Name'))).'</span>';
314 } else {
315 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
316 print $form->select_comptes(getDolGlobalInt($name), $name, 0, "courant=".$cour, 1, '', 0, 'maxwidth500 widthcentpercentminusxx', 1);
317 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>';
318 }
319 print '</td></tr>';
320 }
321}
322
323if (isModEnabled('stock')) {
324 print '<tr class="oddeven"><td>';
325 print $form->textwithpicto($langs->trans("CashDeskDoNotDecreaseStock"), $langs->trans("CashDeskDoNotDecreaseStockHelp"));
326 print '</td>'; // Force warehouse (this is not a default value)
327 print '<td>';
328 //print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK'.$terminal, getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal), 1);
329 print ajax_constantonoff('CASHDESK_NO_DECREASE_STOCK'.$terminal, array(), $conf->entity, 0, 0, 1, 0);
330 print '</td></tr>';
331
332
333 $disabled = getDolGlobalInt('CASHDESK_NO_DECREASE_STOCK'.$terminal);
334
335
336 print '<tr class="oddeven"><td>';
337 if (!$disabled) {
338 print '<span class="fieldrequired">';
339 }
340 print $langs->trans("CashDeskIdWareHouse");
341 if (!$disabled) {
342 print '</span>';
343 }
344 if (!$disabled && !getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$terminal)) {
345 print img_warning($langs->trans("DisableStockChange").' - '.$langs->trans("NoWarehouseDefinedForTerminal"));
346 }
347 print '</td>'; // Force warehouse (this is not a default value)
348 print '<td class="minwidth300">';
349 if (!$disabled) {
350 print img_picto('', 'stock', 'class="pictofixedwidth"');
351 print $formproduct->selectWarehouses(getDolGlobalString('CASHDESK_ID_WAREHOUSE'.$terminal), 'CASHDESK_ID_WAREHOUSE'.$terminal, '', 1, $disabled, 0, '', 0, 0, array(), 'maxwidth500 widthcentpercentminusxx');
352 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>';
353 } else {
354 print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
355 }
356 print '</td></tr>';
357
358 // Deprecated: CASHDESK_FORCE_DECREASE_STOCK is now always false. No more required/used.
359 if (isModEnabled('productbatch') && getDolGlobalString('CASHDESK_FORCE_DECREASE_STOCK') && !getDolGlobalString('CASHDESK_NO_DECREASE_STOCK'.$terminal)) {
360 print '<tr class="oddeven"><td>'.$langs->trans('CashDeskForceDecreaseStockLabel').'</td>';
361 print '<td>';
362 print '<span class="opacitymedium">'.$langs->trans('CashDeskForceDecreaseStockDesc').'</span>';
363 print '</td></tr>';
364 }
365}
366
367if (isModEnabled('project')) {
368 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
369 $formproject = new FormProjets($db);
370 print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDefaultProject").'</td><td>';
371 print img_picto('', 'project', 'class="pictofixedwidth"');
372 // 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 = '')
373 $projectid = getDolGlobalInt('CASHDESK_ID_PROJECT'.$terminaltouse);
374 print $formproject->select_projects(-1, (string) $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 1, 'maxwidth500 widthcentpercentminusxx');
375 print '</td></tr>';
376}
377
378print '<tr class="oddeven"><td>'.$langs->trans('CashDeskReaderKeyCodeForEnter').'</td>';
379print '<td>';
380print '<input type="text" class="width50" name="CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse.'" value="'.getDolGlobalString('CASHDESK_READER_KEYCODE_FOR_ENTER'.$terminaltouse).'" />';
381print '</td></tr>';
382
383// Numbering module (TODO When this is used ?)
384if (getDolGlobalString('TAKEPOS_ADDON') == "terminal") {
385 print '<tr class="oddeven"><td>';
386 print $langs->trans("BillsNumberingModule");
387 print '<td colspan="2">';
388 $array = array(0 => $langs->trans("Default"));
389 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
390 foreach ($dirmodels as $reldir) {
391 $dir = dol_buildpath($reldir."core/modules/facture/");
392 if (is_dir($dir)) {
393 $handle = opendir($dir);
394 if (is_resource($handle)) {
395 while (($file = readdir($handle)) !== false) {
396 if (!is_dir($dir.$file) || (substr($file, 0, 1) != '.' && substr($file, 0, 3) != 'CVS')) {
397 $filebis = $file;
398 $classname = preg_replace('/\.php$/', '', $file);
399 // For compatibility
400 if (!is_file($dir.$filebis)) {
401 $filebis = $file."/".$file.".modules.php";
402 $classname = "mod_facture_".$file;
403 }
404 // Check if there is a filter on country
405 $reg = array();
406 preg_match('/\-(.*)_(.*)$/', $classname, $reg);
407 if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) {
408 continue;
409 }
410
411 $classname = preg_replace('/\-.*$/', '', $classname);
412 if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
413 // Charging the numbering class
414 require_once $dir.$filebis;
415
416 $module = new $classname($db);
417 '@phan-var-force ModeleNumRefFactures $module';
418
419 // Show modules according to features level
420 if ($module->version == 'development' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 2) {
421 continue;
422 }
423 if ($module->version == 'experimental' && getDolGlobalInt('MAIN_FEATURES_LEVEL') < 1) {
424 continue;
425 }
426
427 if ($module->isEnabled()) {
428 $array[preg_replace('/\-.*$/', '', preg_replace('/\.php$/', '', $file))] = preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
429 }
430 }
431 }
432 }
433 closedir($handle);
434 }
435 }
436 }
437 print $form->selectarray('TAKEPOS_ADDON'.$terminaltouse, $array, getDolGlobalString('TAKEPOS_ADDON'.$terminaltouse, '0'), 0);
438 print "</td></tr>\n";
439}
440
441
442// Options when using a special printer in TakePOS
443$customprinterallowed = true;
444$orderprinterallowed = (getDolGlobalString('TAKEPOS_BAR_RESTAURANT') && getDolGlobalInt('TAKEPOS_ORDER_PRINTERS'));
445$customprinttemplateallowed = true;
446include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
447if (isALNERunningVersion()) { // No need to show the custom template when isALNERunningVersion is true because it has no effect (disabled by receipt.php).
448 $customprinttemplateallowed = false; // Custom printer may be allowed if mandatory information in template are guaranteed. For the moment, we prefer not allow this.
449}
450
451if (isModEnabled('receiptprinter')) {
452 // Select printer to use with terminal
453 require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
454 $printer = new dolReceiptPrinter($db);
455
456 $printer->listprinters();
457 $printers = array();
458 foreach ($printer->listprinters as $key => $value) {
459 $printers[$value['rowid']] = $value['name'];
460 }
461 print '<tr class="oddeven"><td>'.$langs->trans("MainPrinterToUse");
462 print ' <span class="opacitymedium">('.$langs->trans("MainPrinterToUseMore").')</span>';
463 print '</td>';
464 print '<td>';
465 if (!$customprinterallowed) { // @phpstan-ignore-line
466 print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("NotAvailableForCountryWhenModuleIsOn", $mysoc->country_code, $langs->transnoentitiesnoconv('Module3200Name'))).'</span>';
467 } else {
468 print $form->selectarray('TAKEPOS_PRINTER_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_PRINTER_TO_USE'.$terminal), 1);
469 }
470 print '</td></tr>';
471
472 if (getDolGlobalString('TAKEPOS_BAR_RESTAURANT') && getDolGlobalInt('TAKEPOS_ORDER_PRINTERS') && $orderprinterallowed) {
473 print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("KitchenPrinter").' 1</td>';
474 print '<td>';
475 print $form->selectarray('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER1_TO_USE'.$terminal), 1);
476 print '</td></tr>';
477 print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("KitchenPrinter").' 2</td>';
478 print '<td>';
479 print $form->selectarray('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER2_TO_USE'.$terminal), 1);
480 print '</td></tr>';
481 print '<tr class="oddeven"><td>'.$langs->trans("OrderPrinterToUse").' - '.$langs->trans("KitchenPrinter").' 3</td>';
482 print '<td>';
483 print $form->selectarray('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal, $printers, getDolGlobalInt('TAKEPOS_ORDER_PRINTER3_TO_USE'.$terminal), 1);
484 print '</td></tr>';
485 }
486}
487
488if (isModEnabled('receiptprinter') || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "receiptprinter" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
489 // Select printer to use with terminal
490 require_once DOL_DOCUMENT_ROOT.'/core/class/dolreceiptprinter.class.php';
491 $printer = new dolReceiptPrinter($db);
492 $printer->listPrintersTemplates();
493 $templates = array();
494 foreach ($printer->listprinterstemplates as $key => $value) {
495 $templates[$value['rowid']] = $value['name'];
496 }
497 print '<tr class="oddeven"><td>'.$langs->trans("MainTemplateToUse");
498 print ' <span class="opacitymedium">('.$langs->trans("MainTemplateToUseMore").')</span>';
499 if ($customprinttemplateallowed) {
500 print ' (<a href="'.DOL_URL_ROOT.'/admin/receiptprinter.php?mode=template">'.$langs->trans("SetupReceiptTemplate").'</a>)</td>';
501 }
502 print '<td>';
503 if (!$customprinttemplateallowed) {
504 print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("NotAvailableForCountryWhenModuleIsOn", $mysoc->country_code, $langs->transnoentitiesnoconv('Module3200Name'))).'</span>';
505 } else {
506 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');
507 }
508 print '</td></tr>';
509
510 if (getDolGlobalInt('TAKEPOS_ORDER_PRINTERS') && $orderprinterallowed) {
511 print '<tr class="oddeven"><td>'.$langs->trans("OrderTemplateToUse").'</td>';
512 print '<td>';
513 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');
514 print '</td></tr>';
515 }
516}
517
518
519print '</table>';
520
521print $form->buttonsSaveCancel("Save", '');
522
523print '</div>';
524
525
526// add free text on each terminal of cash desk
527$substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
528$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans('Translation');
529$htmltext = '<i>'.$langs->trans('AvailableVariables').':<br>';
530foreach ($substitutionarray as $key => $val) {
531 $htmltext .= $key.'<br>';
532}
533$htmltext .= '</i>';
534
535print '<br>';
536print load_fiche_titre($langs->trans('FreeLegalTextOnInvoices'), '', '');
537
538print '<div class="div-table-responsive-no-min">';
539print '<table class="noborder centpercent">';
540print '<tr class="liste_titre">';
541print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans('Value').'</td>';
542print '</tr>';
543
544// free text on header
545print '<tr class="oddeven">';
546print '<td>';
547print $form->textwithpicto($langs->trans('Header'), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
548print '</td>';
549print '<td>';
550$variablename = 'TAKEPOS_HEADER'.$terminaltouse;
551if (!getDolGlobalInt('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
552 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
553} else {
554 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
555 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
556 print $doleditor->Create();
557}
558print '</td></tr>';
559
560// free text on footer
561print '<tr class="oddeven">';
562print '<td>';
563print $form->textwithpicto($langs->trans('Footer'), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
564print '</td>';
565print '<td>';
566$variablename = 'TAKEPOS_FOOTER'.$terminaltouse;
567if (!getDolGlobalInt('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
568 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
569} else {
570 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
571 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
572 print $doleditor->Create();
573}
574print '</td></tr>';
575
576print '</table>';
577print '</div>';
578
579if ($atleastonefound == 0 && isModEnabled("bank")) {
580 print info_admin($langs->trans("AtLeastOneDefaultBankAccountMandatory"), 0, 0, 'error');
581}
582
583print $form->buttonsSaveCancel("Save", '');
584
585print "</form>\n";
586
587print '<br>';
588
589llxFooter();
590$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.