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