dolibarr 23.0.3
receipt.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) 2019 Andreu Bisquerra Gaya <jove@bisquerra.com>
5 * Copyright (C) 2021 Nicolas ZABOURI <info@inovea-conseil.com>
6 * Copyright (C) 2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../../main.inc.php'; // Load $user and permissions
39require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
41require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
42require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
43
44// Security check
45if (!$user->admin) {
47}
48
49$langs->loadLangs(array("admin", "cashdesk", "commercial"));
50
51
52/*
53 * Actions
54 */
55$error = 0;
56
57if (GETPOST('action', 'alpha') == 'set') {
58 $db->begin();
59
60 $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'restricthtml'), 'chaine', 0, '', $conf->entity);
61 $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'restricthtml'), 'chaine', 0, '', $conf->entity);
62 $res = dolibarr_set_const($db, "TAKEPOS_RECEIPT_NAME", GETPOST('TAKEPOS_RECEIPT_NAME', 'alpha'), 'chaine', 0, '', $conf->entity);
63 $res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity);
64 $res = dolibarr_set_const($db, 'TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT', GETPOST('TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
65
66 dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
67
68 if (!($res > 0)) {
69 $error++;
70 }
71
72 if (!$error) {
73 $db->commit();
74 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
75 } else {
76 $db->rollback();
77 setEventMessages($langs->trans("Error"), null, 'errors');
78 }
79} elseif (GETPOST('action', 'alpha') == 'setmethod') {
80 dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity);
81 // TakePOS connector require ReceiptPrinter module
82 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && !isModEnabled('receiptprinter')) {
83 activateModule("modReceiptPrinter");
84 }
85}
86
87
88/*
89 * View
90 */
91
92$form = new Form($db);
93
94llxHeader('', $langs->trans("CashDeskSetup"), '', '', 0, 0, '', '', '', 'mod-takepos page-admin_receipt');
95
96$linkback = '<a href="'.dolBuildUrl(DOL_URL_ROOT.'/admin/modules.php', ['restore_lastsearch_values' => 1]).'">'.img_picto($langs->trans("BackToModuleList"), 'back', 'class="pictofixedwidth"').'<span class="hideonsmartphone">'.$langs->trans("BackToModuleList").'</span></a>';
97
98print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
99
101print dol_get_fiche_head($head, 'receipt', 'TakePOS', -1, 'cash-register');
102
103print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
104print '<input type="hidden" name="token" value="'.newToken().'">';
105print '<input type="hidden" name="action" value="set">';
106
107print load_fiche_titre($langs->trans("Receipt"), '', '');
108
109print '<div class="div-table-responsive-no-min">';
110print '<table class="noborder centpercent">';
111print '<tr class="liste_titre">';
112print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
113print "</tr>\n";
114
115// VAT Grouped on ticket
116print '<tr class="oddeven"><td>';
117print $langs->trans('TicketVatGrouped');
118print '<td colspan="2">';
119print ajax_constantonoff("TAKEPOS_TICKET_VAT_GROUPPED", array(), $conf->entity, 0, 0, 1, 0);
120print "</td></tr>\n";
121
122if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "browser" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
123 $substitutionarray = pdf_getSubstitutionArray($langs, array('ticket', 'member', 'candidate'), null, 2, array('company', 'user', 'object', 'system'));
124 $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
125
126 $htmltext = '<i class="small">'.$langs->trans("AvailableVariables").':<br>';
127 foreach ($substitutionarray as $key => $val) {
128 $htmltext .= $key.'<br>';
129 }
130 $htmltext .= '</i>';
131
132 print '<tr class="oddeven"><td>';
133 print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
134 print '</td><td>';
135 $variablename = 'TAKEPOS_HEADER';
136 if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
137 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
138 } else {
139 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
140 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
141 print $doleditor->Create();
142 }
143 print "</td></tr>\n";
144
145 print '<tr class="oddeven"><td>';
146 print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
147 print '</td><td>';
148 $variablename = 'TAKEPOS_FOOTER';
149 if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
150 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
151 } else {
152 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
153 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
154 print $doleditor->Create();
155 }
156 print "</td></tr>\n";
157
158 print '<tr class="oddeven"><td><label for="receipt_name">'.$langs->trans("ReceiptName").'</label></td><td>';
159 print '<input name="TAKEPOS_RECEIPT_NAME" id="TAKEPOS_RECEIPT_NAME" class="minwidth200" value="'.getDolGlobalString('TAKEPOS_RECEIPT_NAME').'">';
160 print '</td></tr>';
161
162 // Customer information
163 print '<tr class="oddeven"><td>';
164 print $langs->trans('PrintCustomerOnReceipts');
165 print '<td colspan="2">';
166 print ajax_constantonoff("TAKEPOS_SHOW_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0);
167 print "</td></tr>\n";
168
169 // Print payment method
170 // When LNE is own, we show an information to the user to help himunderstand that the feature is forced.
171 print '<tr class="oddeven"><td>';
172 print $langs->trans('PrintPaymentMethodOnReceipts');
173 print '<td colspan="2">';
174 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
175 if (isALNERunningVersion()) {
176 $conf->global->TAKEPOS_PRINT_PAYMENT_METHOD = 1;
177 print ajax_constantonoff("TAKEPOS_PRINT_PAYMENT_METHOD", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', '', 'inline-block', 0, '', 1);
178 print '<span class="opacitymedium">'.$langs->trans("Always").'</span>';
179 } else {
180 print ajax_constantonoff("TAKEPOS_PRINT_PAYMENT_METHOD", array(), $conf->entity, 0, 0, 1, 0);
181 }
182 print "</td></tr>\n";
183}
184
185// Show price without vat
186print '<tr class="oddeven"><td>';
187print $langs->trans('ShowPriceHTOnReceipt');
188print '<td colspan="2">';
190 $conf->global->TAKEPOS_PRINT_PAYMENT_METHOD = 1;
191 print ajax_constantonoff("TAKEPOS_SHOW_HT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', '', 'inline-block', 0, '', 1);
192 print '<span class="opacitymedium">'.$langs->trans("Always").'</span>';
193} else {
194 print ajax_constantonoff("TAKEPOS_SHOW_HT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0);
195}
196print "</td></tr>\n";
197
198if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
199 print '<tr class="oddeven"><td>';
200 print $langs->trans('WeighingScale');
201 print '<td colspan="2">';
202 print ajax_constantonoff("TAKEPOS_WEIGHING_SCALE", array(), $conf->entity, 0, 0, 1, 0);
203 print "</td></tr>\n";
204}
205
206if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
207 print '<tr class="oddeven"><td>';
208 print $langs->trans('CustomerDisplay');
209 print '<td colspan="2">';
210 print ajax_constantonoff("TAKEPOS_CUSTOMER_DISPLAY", array(), $conf->entity, 0, 0, 1, 0);
211 print "</td></tr>\n";
212}
213
214// Print without details
215print '<tr class="oddeven"><td>';
216print $langs->trans('PrintWithoutDetailsButton');
217print '<td colspan="2">';
218print ajax_constantonoff('TAKEPOS_PRINT_WITHOUT_DETAILS', array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', '', 'inline-block', 0, '');
219print "</td></tr>\n";
220if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
221 print '<tr class="oddeven"><td>';
222 print $langs->trans('PrintWithoutDetailsLabelDefault');
223 print '<td colspan="2">';
224 print '<input type="text" name="TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT" value="' . getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT') . '" />';
225 print "</td></tr>\n";
226}
227
228// Gift receipt
229print '<tr class="oddeven"><td>';
230print $langs->trans('GiftReceiptButton');
231print '<td>';
233 print ajax_constantonoff("TAKEPOS_GIFT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', '', 'inline-block', 0, '', 1);
234 print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("NotAvailableForCountryWhenModuleIsOn", $mysoc->country_code, $langs->transnoentitiesnoconv('Module3200Name'))).'</span>';
235} else {
236 print ajax_constantonoff("TAKEPOS_GIFT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0);
237}
238print "</td></tr>\n";
239
240// Auto print tickets
241print '<tr class="oddeven"><td>';
242print $langs->trans("AutoPrintTickets");
243print '<td colspan="2">';
244print ajax_constantonoff("TAKEPOS_AUTO_PRINT_TICKETS", array(), $conf->entity, 0, 0, 1, 0);
245print "</td></tr>\n";
246
247
248print '</table>';
249print '</div>';
250
251print $form->buttonsSaveCancel("Save", '');
252
253print "</form>\n";
254
255
256print '<br>';
257
258
259print load_fiche_titre($langs->trans("Preview"), '', '');
260print '<div style="width: 50%; float:center;background-color:#606060">';
261print '<center>';
262
263// Call takepos/receipt.php
264print '<iframe id="iframe" allowtransparency="true" style="background: #FFFFFF;" src="'.DOL_URL_ROOT.'/takepos/receipt.php?forcenoautoopen=1&specimen=1" width="80%" height="600"></iframe>';
265
266print '</center>';
267print '</div>';
268
269print '<br>';
270
271llxFooter();
272$db->close();
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
isALNERunningVersion($blockedlogtestalreadydone=0)
Return if the application is executed with the LNE requirements on.
Class to manage a WYSIWYG editor.
Class to manage generation of HTML components Only common components must be here.
global $mysoc
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition pdf.lib.php:824
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
takepos_admin_prepare_head()
Prepare array with list of tabs.