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