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