dolibarr 24.0.0-beta
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.'/core/lib/pdf.lib.php';
41require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
42require_once DOL_DOCUMENT_ROOT."/blockedlog/lib/blockedlog.lib.php";
43require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
44
45// Security check
46if (!$user->admin) {
48}
49
50$langs->loadLangs(array("admin", "cashdesk", "commercial"));
51
52
53/*
54 * Actions
55 */
56$error = 0;
57
58if (GETPOST('action', 'alpha') == 'set') {
59 $db->begin();
60
61 $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'restricthtml'), 'chaine', 0, '', $conf->entity);
62 $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'restricthtml'), 'chaine', 0, '', $conf->entity);
63 $res = dolibarr_set_const($db, "TAKEPOS_RECEIPT_NAME", GETPOST('TAKEPOS_RECEIPT_NAME', 'alpha'), 'chaine', 0, '', $conf->entity);
64 $res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity);
65 $res = dolibarr_set_const($db, 'TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT', GETPOST('TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
66
67 dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
68
69 if (!($res > 0)) {
70 $error++;
71 }
72
73 if (!$error) {
74 $db->commit();
75 setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
76 } else {
77 $db->rollback();
78 setEventMessages($langs->trans("Error"), null, 'errors');
79 }
80} elseif (GETPOST('action', 'alpha') == 'setmethod') {
81 dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity);
82 // TakePOS connector require ReceiptPrinter module
83 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && !isModEnabled('receiptprinter')) {
84 activateModule("modReceiptPrinter", 1, 0);
85 }
86}
87
88
89/*
90 * View
91 */
92
93$form = new Form($db);
94
95llxHeader('', $langs->trans("CashDeskSetup"), '', '', 0, 0, '', '', '', 'mod-takepos page-admin_receipt');
96
97$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>';
98
99print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
100
102print dol_get_fiche_head($head, 'receipt', 'TakePOS', -1, 'cash-register');
103
104print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
105print '<input type="hidden" name="token" value="'.newToken().'">';
106print '<input type="hidden" name="action" value="set">';
107
108print load_fiche_titre($langs->trans("Receipt"), '', '');
109
110print '<div class="div-table-responsive-no-min">';
111print '<table class="noborder centpercent">';
112print '<tr class="liste_titre">';
113print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
114print "</tr>\n";
115
116// VAT Grouped on ticket
117print '<tr class="oddeven"><td>';
118print $langs->trans('TicketVatGrouped');
119print '<td colspan="2">';
121 // Always forced to true
122 $conf->global->TAKEPOS_TICKET_VAT_GROUPPED = 1;
123 print img_picto($langs->trans("Enabled"), 'switch_on', 'class="opacitymedium valignmiddle"');
124 print ' <span class="opacitymedium valignmiddle">'.$langs->trans("Always").'</span>';
125} else {
126 print ajax_constantonoff("TAKEPOS_TICKET_VAT_GROUPPED", array(), $conf->entity, 0, 0, 1, 0);
127}
128print "</td></tr>\n";
129
130if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "browser" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
131 $substitutionarray = pdf_getSubstitutionArray($langs, array('ticket', 'member', 'candidate', 'shipping'), null, 2, array('mycompany', 'company', 'user', 'object', 'system'));
132 $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
133
134 $htmltext = '<i class="small">'.$langs->trans("AvailableVariables").':<br>';
135 foreach ($substitutionarray as $key => $val) {
136 $htmltext .= $key.'<br>';
137 }
138 $htmltext .= '</i>';
139
140 print '<tr class="oddeven"><td>';
141 print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
142 print '</td><td>';
143 $variablename = 'TAKEPOS_HEADER';
144 if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
145 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
146 } else {
147 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
148 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
149 print $doleditor->Create();
150 }
151 print "</td></tr>\n";
152
153 print '<tr class="oddeven"><td>';
154 print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
155 print '</td><td>';
156 $variablename = 'TAKEPOS_FOOTER';
157 if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
158 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
159 } else {
160 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
161 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
162 print $doleditor->Create();
163 }
164 print "</td></tr>\n";
165
166 print '<tr class="oddeven"><td><label for="receipt_name">'.$langs->trans("ReceiptName").'</label></td><td>';
167 print '<input name="TAKEPOS_RECEIPT_NAME" id="TAKEPOS_RECEIPT_NAME" class="minwidth200" value="'.getDolGlobalString('TAKEPOS_RECEIPT_NAME').'">';
168 print '</td></tr>';
169
170 // Customer information
171 print '<tr class="oddeven"><td>';
172 print $langs->trans('PrintCustomerOnReceipts');
173 print '<td colspan="2">';
174 print ajax_constantonoff("TAKEPOS_SHOW_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0);
175 print "</td></tr>\n";
176
177 // Print payment method
178 // When LNE is own, we show an information to the user to help him understand that the feature is forced.
179 print '<tr class="oddeven"><td>';
180 print $langs->trans('PrintPaymentMethodOnReceipts');
181 print '<td colspan="2">';
182 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
183 if (isALNERunningVersion()) {
184 $conf->global->TAKEPOS_PRINT_PAYMENT_METHOD = 1;
185 print ajax_constantonoff("TAKEPOS_PRINT_PAYMENT_METHOD", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', '', 'inline-block', 0, '', 1);
186 print '<span class="opacitymedium">'.$langs->trans("Always").'</span>';
187 } else {
188 print ajax_constantonoff("TAKEPOS_PRINT_PAYMENT_METHOD", array(), $conf->entity, 0, 0, 1, 0);
189 }
190 print "</td></tr>\n";
191}
192
193// Show price without vat
194print '<tr class="oddeven"><td>';
195print $langs->trans('ShowPriceHTOnReceipt');
196print '<td colspan="2">';
198 $conf->global->TAKEPOS_SHOW_HT_RECEIPT = 1;
199 print ajax_constantonoff("TAKEPOS_SHOW_HT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', '', 'inline-block', 0, '', 1);
200 print '<span class="opacitymedium">'.$langs->trans("Always").'</span>';
201} else {
202 print ajax_constantonoff("TAKEPOS_SHOW_HT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0);
203}
204print "</td></tr>\n";
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('WeighingScale');
209 print '<td colspan="2">';
210 print ajax_constantonoff("TAKEPOS_WEIGHING_SCALE", array(), $conf->entity, 0, 0, 1, 0);
211 print "</td></tr>\n";
212}
213
214if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
215 print '<tr class="oddeven"><td>';
216 print $langs->trans('CustomerDisplay');
217 print '<td colspan="2">';
218 print ajax_constantonoff("TAKEPOS_CUSTOMER_DISPLAY", array(), $conf->entity, 0, 0, 1, 0);
219 print "</td></tr>\n";
220}
221
222// Print without details
223if (getDolGlobalString('TAKEPOS_ENABLE_PRINT_WITHOUT_DETAILS')) { // Note that even if option is set manually, if version is certified, option will be disabled later and above all in the page that generate the documents/receipts.
224 print '<tr class="oddeven"><td>';
225 print $langs->trans('PrintWithoutDetailsButton');
226 print '<td colspan="2">';
227 if (isALNERunningVersion()) {
228 // Always forced to true
229 $conf->global->TAKEPOS_PRINT_WITHOUT_DETAILS = 1;
230 print img_picto($langs->trans("Disabled"), 'switch_off', 'class="opacitymedium valignmiddle"');
231 print ' <span class="opacitymedium valignmiddle">'.$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("NotAvailableForCountryWhenModuleIsOn", $mysoc->country_code, $langs->transnoentitiesnoconv('Module3200Name'))).'</span>';
232 } else {
233 print ajax_constantonoff('TAKEPOS_PRINT_WITHOUT_DETAILS', array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', '', 'inline-block', 0, '');
234 }
235 print "</td></tr>\n";
236
237 if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
238 print '<tr class="oddeven"><td>';
239 print $langs->trans('PrintWithoutDetailsLabelDefault');
240 print '<td colspan="2">';
241 print '<input type="text" name="TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT" value="' . getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT') . '" />';
242 print "</td></tr>\n";
243 }
244}
245
246// Gift receipt
247print '<tr class="oddeven"><td>';
248print $langs->trans('GiftReceiptButton');
249print '<td>';
251 print ajax_constantonoff("TAKEPOS_GIFT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0, 0, 0, '', '', 'inline-block', 0, '', 1);
252 print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("NotAvailable"), $langs->trans("NotAvailableForCountryWhenModuleIsOn", $mysoc->country_code, $langs->transnoentitiesnoconv('Module3200Name'))).'</span>';
253} else {
254 print ajax_constantonoff("TAKEPOS_GIFT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0);
255}
256print "</td></tr>\n";
257
258// Auto print tickets
259print '<tr class="oddeven"><td>';
260print $langs->trans("AutoPrintTickets");
261print '<td colspan="2">';
262print ajax_constantonoff("TAKEPOS_AUTO_PRINT_TICKETS", array(), $conf->entity, 0, 0, 1, 0);
263print "</td></tr>\n";
264
265
266print '</table>';
267print '</div>';
268
269print $form->buttonsSaveCancel("Save", '');
270
271print "</form>\n";
272
273
274print '<br>';
275
276
277print load_fiche_titre($langs->trans("Preview"), '', '');
278print '<div style="width: 50%; float:center;background-color:#606060">';
279print '<center>';
280
281// Call takepos/receipt.php
282print '<iframe id="iframe" allowtransparency="true" style="background: #FFFFFF;" src="'.DOL_URL_ROOT.'/takepos/receipt.php?forcenoautoopen=1&specimen=1" width="80%" height="600"></iframe>';
283
284print '</center>';
285print '</div>';
286
287print '<br>';
288
289llxFooter();
290$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, $blockedlogmodulealreadydone=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
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
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:1135
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.