dolibarr  17.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  *
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
29 require '../../main.inc.php'; // Load $user and permissions
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
33 require_once DOL_DOCUMENT_ROOT."/core/lib/takepos.lib.php";
34 
35 // Security check
36 if (!$user->admin) {
38 }
39 
40 $langs->loadLangs(array("admin", "cashdesk", "commercial"));
41 
42 
43 /*
44  * Actions
45  */
46 
47 if (GETPOST('action', 'alpha') == 'set') {
48  $db->begin();
49 
50  $res = dolibarr_set_const($db, "TAKEPOS_HEADER", GETPOST('TAKEPOS_HEADER', 'restricthtml'), 'chaine', 0, '', $conf->entity);
51  $res = dolibarr_set_const($db, "TAKEPOS_FOOTER", GETPOST('TAKEPOS_FOOTER', 'restricthtml'), 'chaine', 0, '', $conf->entity);
52  $res = dolibarr_set_const($db, "TAKEPOS_RECEIPT_NAME", GETPOST('TAKEPOS_RECEIPT_NAME', 'alpha'), 'chaine', 0, '', $conf->entity);
53  $res = dolibarr_set_const($db, "TAKEPOS_PRINT_SERVER", GETPOST('TAKEPOS_PRINT_SERVER', 'alpha'), 'chaine', 0, '', $conf->entity);
54  $res = dolibarr_set_const($db, 'TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT', GETPOST('TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT', 'alphanohtml'), 'chaine', 0, '', $conf->entity);
55 
56  dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
57 
58  if (!($res > 0)) {
59  $error++;
60  }
61 
62  if (!$error) {
63  $db->commit();
64  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
65  } else {
66  $db->rollback();
67  setEventMessages($langs->trans("Error"), null, 'errors');
68  }
69 } elseif (GETPOST('action', 'alpha') == 'setmethod') {
70  dolibarr_set_const($db, "TAKEPOS_PRINT_METHOD", GETPOST('value', 'alpha'), 'chaine', 0, '', $conf->entity);
71  // TakePOS connector require ReceiptPrinter module
72  if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && !isModEnabled('receiptprinter')) {
73  activateModule("modReceiptPrinter");
74  }
75 }
76 
77 
78 /*
79  * View
80  */
81 
82 $form = new Form($db);
83 $formproduct = new FormProduct($db);
84 
85 llxHeader('', $langs->trans("CashDeskSetup"));
86 
87 $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
88 print load_fiche_titre($langs->trans("CashDeskSetup").' (TakePOS)', $linkback, 'title_setup');
90 print dol_get_fiche_head($head, 'receipt', 'TakePOS', -1, 'cash-register');
91 
92 print '<form action="'.$_SERVER["PHP_SELF"].'?terminal='.(empty($terminal) ? 1 : $terminal).'" method="post">';
93 print '<input type="hidden" name="token" value="'.newToken().'">';
94 print '<input type="hidden" name="action" value="set">';
95 
96 print load_fiche_titre($langs->trans("Receipt"), '', '');
97 
98 print '<div class="div-table-responsive-no-min">';
99 print '<table class="noborder centpercent">';
100 print '<tr class="liste_titre">';
101 print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
102 print "</tr>\n";
103 
104 // VAT Grouped on ticket
105 print '<tr class="oddeven"><td>';
106 print $langs->trans('TicketVatGrouped');
107 print '<td colspan="2">';
108 print ajax_constantonoff("TAKEPOS_TICKET_VAT_GROUPPED", array(), $conf->entity, 0, 0, 1, 0);
109 print "</td></tr>\n";
110 
111 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "browser" || getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector") {
112  $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2);
113  $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
114  $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
115  foreach ($substitutionarray as $key => $val) {
116  $htmltext .= $key.'<br>';
117  }
118  $htmltext .= '</i>';
119 
120  print '<tr class="oddeven"><td>';
121  print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Header"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
122  print '</td><td>';
123  $variablename = 'TAKEPOS_HEADER';
124  if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
125  print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
126  } else {
127  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
128  $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
129  print $doleditor->Create();
130  }
131  print "</td></tr>\n";
132 
133  print '<tr class="oddeven"><td>';
134  print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices")." - ".$langs->trans("Footer"), $htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
135  print '</td><td>';
136  $variablename = 'TAKEPOS_FOOTER';
137  if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) {
138  print '<textarea name="'.$variablename.'" class="flat" cols="120">'.getDolGlobalString($variablename).'</textarea>';
139  } else {
140  include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
141  $doleditor = new DolEditor($variablename, getDolGlobalString($variablename), '', 80, 'dolibarr_notes');
142  print $doleditor->Create();
143  }
144  print "</td></tr>\n";
145 
146  print '<tr class="oddeven"><td><label for="receipt_name">'.$langs->trans("ReceiptName").'</label></td><td>';
147  print '<input name="TAKEPOS_RECEIPT_NAME" id="TAKEPOS_RECEIPT_NAME" class="minwidth200" value="'.getDolGlobalString('TAKEPOS_RECEIPT_NAME').'">';
148  print '</td></tr>';
149 
150  // Customer information
151  print '<tr class="oddeven"><td>';
152  print $langs->trans('PrintCustomerOnReceipts');
153  print '<td colspan="2">';
154  print ajax_constantonoff("TAKEPOS_SHOW_CUSTOMER", array(), $conf->entity, 0, 0, 1, 0);
155  print "</td></tr>\n";
156 
157  // Print payment method
158  print '<tr class="oddeven"><td>';
159  print $langs->trans('PrintPaymentMethodOnReceipts');
160  print '<td colspan="2">';
161  print ajax_constantonoff("TAKEPOS_PRINT_PAYMENT_METHOD", array(), $conf->entity, 0, 0, 1, 0);
162  print "</td></tr>\n";
163 }
164 
165 // Auto print tickets
166 print '<tr class="oddeven"><td>';
167 print $langs->trans("AutoPrintTickets");
168 print '<td colspan="2">';
169 print ajax_constantonoff("TAKEPOS_AUTO_PRINT_TICKETS", array(), $conf->entity, 0, 0, 1, 0);
170 print "</td></tr>\n";
171 
172 
173 // Show price without vat
174 print '<tr class="oddeven"><td>';
175 print $langs->trans('ShowPriceHTOnReceipt');
176 print '<td colspan="2">';
177 print ajax_constantonoff("TAKEPOS_SHOW_HT_RECEIPT", array(), $conf->entity, 0, 0, 1, 0);
178 print "</td></tr>\n";
179 
180 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
181  print '<tr class="oddeven"><td>';
182  print $langs->trans('WeighingScale');
183  print '<td colspan="2">';
184  print ajax_constantonoff("TAKEPOS_WEIGHING_SCALE", array(), $conf->entity, 0, 0, 1, 0);
185  print "</td></tr>\n";
186 }
187 
188 if (getDolGlobalString('TAKEPOS_PRINT_METHOD') == "takeposconnector" && filter_var(getDolGlobalString('TAKEPOS_PRINT_SERVER'), FILTER_VALIDATE_URL) == true) {
189  print '<tr class="oddeven"><td>';
190  print $langs->trans('CustomerDisplay');
191  print '<td colspan="2">';
192  print ajax_constantonoff("TAKEPOS_CUSTOMER_DISPLAY", array(), $conf->entity, 0, 0, 1, 0);
193  print "</td></tr>\n";
194 }
195 
196 // Print without details
197 print '<tr class="oddeven"><td>';
198 print $langs->trans('PrintWithoutDetailsButton');
199 print '<td colspan="2">';
200 print ajax_constantonoff('TAKEPOS_PRINT_WITHOUT_DETAILS', array(), $conf->entity, 0, 0, 1, 0);
201 print "</td></tr>\n";
202 if (getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS')) {
203  print '<tr class="oddeven"><td>';
204  print $langs->trans('PrintWithoutDetailsLabelDefault');
205  print '<td colspan="2">';
206  print '<input type="text" name="TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT" value="' . getDolGlobalString('TAKEPOS_PRINT_WITHOUT_DETAILS_LABEL_DEFAULT') . '" />';
207  print "</td></tr>\n";
208 }
209 
210 print '</table>';
211 print '</div>';
212 
213 print '<br>';
214 
215 print $form->buttonsSaveCancel("Save", '');
216 
217 print "</form>\n";
218 
219 print load_fiche_titre($langs->trans("Preview"), '', '');
220 print '<div style="width: 50%; float:center;background-color:#606060">';
221 print '<center>';
222 print '<iframe id="iframe" allowtransparency="true" style="background: #FFFFFF;" src="../receipt.php" width="80%" height="600"></iframe>';
223 print '</center>';
224 print '</div>';
225 
226 print '<br>';
227 
228 llxFooter();
229 $db->close();
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:70
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5360
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:520
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
activateModule
activateModule($value, $withdeps=1)
Enable a module.
Definition: admin.lib.php:1091
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:56
takepos_admin_prepare_head
takepos_admin_prepare_head()
Prepare array with list of tabs.
Definition: takepos.lib.php:30
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1628
ajax_constantonoff
ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0, $strict=0, $forcereload=0, $marginleftonlyshort=2, $forcenoajax=0, $setzeroinsteadofdel=0, $suffix='', $mode='')
On/off button for constant.
Definition: ajax.lib.php:600
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1858
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:82
FormProduct
Class with static methods for building HTML components related to products Only components common to ...
Definition: html.formproduct.class.php:30
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:137
dolibarr_set_const
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).
Definition: admin.lib.php:632
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:53
pdf_getSubstitutionArray
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition: pdf.lib.php:749
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8465
accessforbidden
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
Definition: security.lib.php:1125
DolEditor
Class to manage a WYSIWYG editor.
Definition: doleditor.class.php:30