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