dolibarr 21.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
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."/core/lib/takepos.lib.php";
35
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$formproduct = new FormProduct($db);
94
95llxHeader('', $langs->trans("CashDeskSetup"), '', '', 0, 0, '', '', '', 'mod-takepos page-admin_receipt');
96
97$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
98print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
100print dol_get_fiche_head($head, 'receipt', 'TakePOS', -1, 'cash-register');
101
102print '<form action="'.$_SERVER["PHP_SELF"].'?terminal='.(empty($terminal) ? 1 : $terminal).'" method="post">';
103print '<input type="hidden" name="token" value="'.newToken().'">';
104print '<input type="hidden" name="action" value="set">';
105
106print load_fiche_titre($langs->trans("Receipt"), '', '');
107
108print '<div class="div-table-responsive-no-min">';
109print '<table class="noborder centpercent">';
110print '<tr class="liste_titre">';
111print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
112print "</tr>\n";
113
114// VAT Grouped on ticket
115print '<tr class="oddeven"><td>';
116print $langs->trans('TicketVatGrouped');
117print '<td colspan="2">';
118print ajax_constantonoff("TAKEPOS_TICKET_VAT_GROUPPED", array(), $conf->entity, 0, 0, 1, 0);
119print "</td></tr>\n";
120
121if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "browser" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
122 $substitutionarray = pdf_getSubstitutionArray($langs, array('ticket', 'member', 'candidate'), null, 2, array('company', 'user', 'object', 'system'));
123 $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
124
125 $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
126 foreach ($substitutionarray as $key => $val) {
127 $htmltext .= $key.'<br>';
128 }
129 $htmltext .= '</i>';
130
131 print '<tr class="oddeven"><td>';
132 print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
133 print '</td><td>';
134 $variablename = 'TAKEPOS_HEADER';
135 if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
136 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
137 } else {
138 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
139 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
140 print $doleditor->Create();
141 }
142 print "</td></tr>\n";
143
144 print '<tr class="oddeven"><td>';
145 print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
146 print '</td><td>';
147 $variablename = 'TAKEPOS_FOOTER';
148 if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
149 print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
150 } else {
151 include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
152 $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
153 print $doleditor->Create();
154 }
155 print "</td></tr>\n";
156
157 print '<tr class="oddeven"><td><label for="receipt_name">'.$langs->trans("ReceiptName").'</label></td><td>';
158 print '<input name="TAKEPOS_RECEIPT_NAME" id="TAKEPOS_RECEIPT_NAME" class="minwidth200" value="'.getDolGlobalString('TAKEPOS_RECEIPT_NAME').'">';
159 print '</td></tr>';
160
161 // Customer information
162 print '<tr class="oddeven"><td>';
163 print $langs->trans('PrintCustomerOnReceipts');
164 print '<td colspan="2">';
165 print ajax_constantonoff("TAKEPOS_SHOW_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0);
166 print "</td></tr>\n";
167
168 // Print payment method
169 print '<tr class="oddeven"><td>';
170 print $langs->trans('PrintPaymentMethodOnReceipts');
171 print '<td colspan="2">';
172 print ajax_constantonoff("TAKEPOS_PRINT_PAYMENT_METHOD", array(), $conf->entity, 0, 0, 1, 0);
173 print "</td></tr>\n";
174}
175
176// Show price without vat
177print '<tr class="oddeven"><td>';
178print $langs->trans('ShowPriceHTOnReceipt');
179print '<td colspan="2">';
180print ajax_constantonoff("TAKEPOS_SHOW_HT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0);
181print "</td></tr>\n";
182
183if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
184 print '<tr class="oddeven"><td>';
185 print $langs->trans('WeighingScale');
186 print '<td colspan="2">';
187 print ajax_constantonoff("TAKEPOS_WEIGHING_SCALE", array(), $conf->entity, 0, 0, 1, 0);
188 print "</td></tr>\n";
189}
190
191if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
192 print '<tr class="oddeven"><td>';
193 print $langs->trans('CustomerDisplay');
194 print '<td colspan="2">';
195 print ajax_constantonoff("TAKEPOS_CUSTOMER_DISPLAY", array(), $conf->entity, 0, 0, 1, 0);
196 print "</td></tr>\n";
197}
198
199// Print without details
200print '<tr class="oddeven"><td>';
201print $langs->trans('PrintWithoutDetailsButton');
202print '<td colspan="2">';
203print ajax_constantonoff('TAKEPOS_PRINT_WITHOUT_DETAILS', array(), $conf->entity, 0, 0, 1, 0);
204print "</td></tr>\n";
205if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
206 print '<tr class="oddeven"><td>';
207 print $langs->trans('PrintWithoutDetailsLabelDefault');
208 print '<td colspan="2">';
209 print '<input type="text" name="TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT" value="' . getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT') . '" />';
210 print "</td></tr>\n";
211}
212
213// Auto print tickets
214print '<tr class="oddeven"><td>';
215print $langs->trans("AutoPrintTickets");
216print '<td colspan="2">';
217print ajax_constantonoff("TAKEPOS_AUTO_PRINT_TICKETS", array(), $conf->entity, 0, 0, 1, 0);
218print "</td></tr>\n";
219
220
221print '</table>';
222print '</div>';
223
224print $form->buttonsSaveCancel("Save", '');
225
226print "</form>\n";
227
228
229print '<br>';
230
231
232print load_fiche_titre($langs->trans("Preview"), '', '');
233print '<div style="width: 50%; float:center;background-color:#606060">';
234print '<center>';
235print '<iframe id="iframe" allowtransparency="true" style="background: #FFFFFF;" src="../receipt.php" width="80%" height="600"></iframe>';
236print '</center>';
237print '</div>';
238
239print '<br>';
240
241llxFooter();
242$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).
activateModule($value, $withdeps=1, $noconfverification=0)
Enable a module.
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:71
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 ...
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.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.