dolibarr 24.0.0-beta
blockedlog_list.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
3 * Copyright (C) 2017-2018 Laurent Destailleur <eldy@destailleur.fr>
4 * Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
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';
40require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/core/lib/json.lib.php';
45require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
46
47// Load translation files required by the page
48$langs->loadLangs(array('admin', 'banks', 'bills', 'blockedlog', 'cashdesk', 'other'));
49
50// Get Parameters
51$action = GETPOST('action', 'aZ09');
52$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : getDolDefaultContextPage(__FILE__); // To manage different context of search
53$backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
54$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
55
56$search_showonlyerrors = GETPOSTINT('search_showonlyerrors');
57if ($search_showonlyerrors < 0) {
58 $search_showonlyerrors = 0;
59}
60
61$search_startyear = GETPOSTINT('search_startyear');
62$search_startmonth = GETPOSTINT('search_startmonth');
63$search_startday = GETPOSTINT('search_startday');
64$search_endyear = GETPOSTINT('search_endyear');
65$search_endmonth = GETPOSTINT('search_endmonth');
66$search_endday = GETPOSTINT('search_endday');
67$search_id = GETPOST('search_id', 'alpha'); // Can be a USF search string
68$search_fk_user = GETPOST('search_fk_user', 'intcomma');
69$search_start = -1;
70if (GETPOST('search_startyear') != '') {
71 $search_start = dol_mktime(0, 0, 0, $search_startmonth, $search_startday, $search_startyear);
72}
73$search_end = -1;
74if (GETPOST('search_endyear') != '') {
75 $search_end = dol_mktime(23, 59, 59, $search_endmonth, $search_endday, $search_endyear);
76}
77$search_code = GETPOST('search_code', 'array:alpha');
78$search_module_source = GETPOSTISSET('search_module_source') ? GETPOST('search_module_source', 'array:alpha') : (isModEnabled('takepos') ? array('takepos') : array());
79$search_pos_source = GETPOST('search_pos_source');
80$search_ref = GETPOST('search_ref', 'alpha');
81$search_type_code = GETPOST('search_type_code', 'aZ09');
82$search_amount = GETPOST('search_amount', 'alpha');
83$search_signature = GETPOST('search_signature', 'alpha');
84$withtab = GETPOSTISSET('withtab') ? GETPOSTINT('withtab') : 1;
85
86if (($search_start == -1 || empty($search_start)) && !GETPOSTISSET('search_startmonth') && !GETPOSTISSET('begin')) {
87 $search_start = dol_time_plus_duree(dol_now(), -1, 'w');
88 $tmparray = dol_getdate($search_start);
89 $search_startday = $tmparray['mday'];
90 $search_startmonth = $tmparray['mon'];
91 $search_startyear = $tmparray['year'];
92}
93
94$includebeforev2 = GETPOSTINT('includebeforev2');
95
96// Load variable for pagination
97$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
98$sortfield = GETPOST('sortfield', 'aZ09comma');
99$sortorder = GETPOST('sortorder', 'aZ09comma');
100$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
101if (empty($page) || $page == -1) {
102 $page = 0;
103} // If $page is not defined, or '' or -1
104$offset = $limit * $page;
105$pageprev = $page - 1;
106$pagenext = $page + 1;
107
108if (empty($sortfield)) {
109 $sortfield = 'rowid';
110}
111if (empty($sortorder)) {
112 $sortorder = 'DESC';
113}
114
115$block_static = new BlockedLog($db);
116$block_static->loadTrackedEvents();
117
118// Access Control
119if ((!$user->admin && !$user->hasRight('blockedlog', 'read')) || !isModEnabled('blockedlog')) {
121}
122
123$result = restrictedArea($user, 'blockedlog', 0, '');
124
125// Execution Time
126$max_execution_time_for_importexport = getDolGlobalInt('EXPORT_MAX_EXECUTION_TIME', 300); // 5mn if not defined
127$max_time = @ini_get("max_execution_time");
128if ($max_time && $max_time < $max_execution_time_for_importexport) {
129 dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically.");
130 @ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300
131}
132
133$MAXLINES = getDolGlobalInt('BLOCKEDLOG_MAX_LINES', 10000);
134$MAXFORSHOWNLINKS = getDolGlobalInt('BLOCKEDLOG_MAX_FOR_SHOWN_LINKS', 100);
135
136$error = 0;
137
138
139/*
140 * Actions
141 */
142
143// Purge search criteria
144if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
145 $search_id = '';
146 $search_fk_user = '';
147 $search_start = dol_time_plus_duree(dol_now(), -1, 'w');
148 $search_end = -1;
149 $search_code = array();
150 $search_module_source = isModEnabled('takepos') ? array('takepos') : array();
151 $search_pos_source = '';
152 $search_ref = '';
153 $search_type_code = ''; // Type of payment
154 $search_amount = '';
155 $search_signature = '';
156 $search_showonlyerrors = 0;
157 $search_startyear = '';
158 $search_startmonth = '';
159 $search_startday = '';
160 $search_endyear = '';
161 $search_endmonth = '';
162 $search_endday = '';
163 $toselect = array();
164 $search_array_options = array();
165}
166
167if (userIsTaxAuditor()) {
168 // When this hidden option is on, open another tab as the tab by default
169 header("Location: ".DOL_URL_ROOT."/blockedlog/admin/blockedlog_archives.php");
170 exit;
171}
172
173
174/*
175 * View
176 */
177
178$form = new Form($db);
179
180if ($withtab) {
181 $title = $langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog');
182} else {
183 $title = $langs->trans("BrowseBlockedLog");
184}
185$help_url = "EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable";
186
187llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'bodyforlist mod-blockedlog page-admin_blockedlog_list');
188
189// Get list of blocked logs.
190// Warning: This make a fetch on each line.
191$blocks = $block_static->getLog('all', (string) $search_id, $MAXLINES, $sortfield, $sortorder, (int) $search_fk_user, $search_start, $search_end, $search_ref, $search_amount, $search_code, $search_signature, $search_module_source, $search_pos_source);
192
193if (!is_array($blocks)) {
194 if ($blocks == -2) {
195 setEventMessages($langs->trans("TooManyRecordToScanRestrictFilters", $MAXLINES), null, 'errors');
196 } else {
197 dol_print_error($block_static->db, $block_static->error, $block_static->errors);
198 exit;
199 }
200}
201
202$linkback = '';
203if ($withtab) {
204 $linkback = '<a href="'.dolBuildUrl($backtopage ? $backtopage : 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>';
205}
206
207$morehtmlcenter = '';
208$texttop = '';
209
210$registrationnumber = getHashUniqueIdOfRegistration();
211if (!userIsTaxAuditor()) { // @phpstan-ignore-line as it is already checked before
212 $texttop = '<small class="opacitymedium">'.$langs->trans("RegistrationNumber").':</small> <small>'.dol_trunc($registrationnumber, 10).'</small>';
214 $texttop = '';
215 }
216}
217
218print load_fiche_titre($title.'<br>'.$texttop, $linkback, 'blockedlog', 0, '', '', $morehtmlcenter);
219
220$head = blockedlogadmin_prepare_head($withtab);
221
222print dol_get_fiche_head($head, 'fingerprints', '', -1);
223
224//print $texttop;
225//print '<br><br>';
226
227print '<div class="justify">';
228print '<span class="opacitymedium hideonsmartphone">';
229print $langs->trans("FingerprintsDesc")."<br>";
230print $langs->trans("FilesIntegrityDesc").': ';
231print '</span>';
232print '<a href="'.DOL_URL_ROOT.'/blockedlog/admin/filecheck.php">'.img_picto('', 'url', 'class="pictofixedwidth"').$langs->trans("FileCheck").'</a>';
233print '<br>';
234print "</div>\n";
235
236$nbrecorddone = $block_static->countRecord();
237$mindisksize = 50; // Gb
238$maxtranspermonth = 10000;
239$nbrecordallowed = $mindisksize * 1024 * 1024 / 40 - $nbrecorddone;
240$nbmonthallowed = $nbrecordallowed / $maxtranspermonth;
241
242$htmltext = '';
243$htmltext .= $langs->trans("UnalterableLogTool2", $langs->transnoentitiesnoconv("Archives"))."<br>";
244$htmltext .= '<span class="small">'.$langs->trans("UnalterableLogTool2MaxUsage", $nbrecorddone, $mindisksize, $nbrecordallowed)."</span><br>";
245
246$htmltext .= '<span class="small">'.$langs->trans("UnalterableLogTool3")."</span><br>";
247if ($mysoc->country_code == 'FR') {
248 $htmltext .= '<br><span class="small">'.$langs->trans("UnalterableLogTool1FR", $langs->transnoentitiesnoconv("Archives")).'</span><br>';
249} else {
250 $htmltext .= '<span class="small">'.$langs->trans("UnalterableLogTool2b", $langs->transnoentitiesnoconv("Archives"))."</span><br>";
251}
252
253print info_admin($htmltext, 0, 0, 'warning');
254
255
256print '<br>';
257
258$param = '';
259if ($contextpage != getDolDefaultContextPage(__FILE__)) {
260 $param .= '&contextpage='.urlencode($contextpage);
261}
262if ($limit > 0 && $limit != $conf->liste_limit) {
263 $param .= '&limit='.((int) $limit);
264}
265if ($optioncss != '') {
266 $param .= '&optioncss='.urlencode($optioncss);
267}
268if ($search_id != '') {
269 $param .= '&search_id='.urlencode($search_id);
270}
271if ($search_ref != '') {
272 $param .= '&search_ref='.urlencode($search_ref);
273}
274if ($search_fk_user > 0) {
275 $param .= '&search_fk_user='.urlencode($search_fk_user);
276}
277if ($search_amount) {
278 $param .= '&search_module_source='.urlencode($search_module_source);
279}
280if ($search_pos_source) {
281 $param .= '&search_pos_source='.urlencode($search_pos_source);
282}
283if ($search_type_code) {
284 $param .= '&search_type_code='.urlencode($search_type_code);
285}
286if ($search_startyear > 0) {
287 $param .= '&search_startyear='.((int) $search_startyear);
288}
289if ($search_startmonth > 0) {
290 $param .= '&search_startmonth='.((int) $search_startmonth);
291}
292if ($search_startday > 0) {
293 $param .= '&search_startday='.((int) $search_startday);
294}
295if ($search_endyear > 0) {
296 $param .= '&search_endyear='.((int) $search_endyear);
297}
298if ($search_endmonth > 0) {
299 $param .= '&search_endmonth='.((int) $search_endmonth);
300}
301if ($search_endday > 0) {
302 $param .= '&search_endday='.((int) $search_endday);
303}
304if ($search_amount) {
305 $param .= '&search_amount='.urlencode($search_amount);
306}
307if ($search_signature) {
308 $param .= '&search_signature='.urlencode($search_signature);
309}
310if ($search_showonlyerrors > 0) {
311 $param .= '&search_showonlyerrors='.((int) $search_showonlyerrors);
312}
313if ($withtab) {
314 $param .= '&withtab='.((int) $withtab);
315}
316
317// Clear memory cache of the obfuscation key
318if (GETPOST('clearcache')) {
319 unset($_SESSION['obfuscationkey_'.((int) $conf->entity)]);
320 unset($conf->cache['obfuscationkey_'.((int) $conf->entity)]);
321}
322
323// Get the remoteobfuscation key
324// Show an error to ask to retry later if we can't get it because it means we can't decode the HMAC KEY later so we can't validate record.
325$remoteobfuscationkey = '';
326if (isALNERunningVersion(1) && $mysoc->country_code == 'FR') {
327 try {
328 $remoteobfuscationkey = $block_static->getObfuscationKey();
329 // Note: To emulate a pb in getting the obfuscation key, there is some code to uncomment into the method
330 } catch (Exception $e) {
331 $error++;
332
333 print '<div class="error mess1">';
334 print $e->getMessage();
335 print '<br>';
336 print '<a class="" href="'.$_SERVER["PHP_SELF"].'?clearcache=1">'.$langs->trans("Retry").'</a>';
337 print '</div>';
338 }
339}
340
341// Get the encoded HMAC key.
342$hmac_encoded_secret_key = $block_static->getEncodedHMACSecretKey(); // Can be old 'dolcrypt:...' if migration not yet complete but should be 'dolobfuscationv1...'
343if (empty($hmac_encoded_secret_key)) {
344 // This is no more the case since Dolibarr v23 and Blockedlog v2+
345 print '<div class="error mess2">';
346 print 'Error: BLOCKEDLOG_HMAC_KEY was not found. It should have been initialized to a value "BLOCKEDLOG_HMAC_...." during initialization of module BlockedLog or during migration from a very old version.';
347 print '</div>';
348}
349
350// Here we have the obfuscated value of BLOCKEDLOG_HMAC_KEY in $hmac_encoded_secret_key. We need to unobfuscate it.
351$hmac_secret_key = '';
352if (!$error) {
353 try {
354 $hmac_secret_key = $block_static->getClearHMACSecretKey($hmac_encoded_secret_key); // Note: On network trouble, an Exception is thrown to the caller
355 } catch (Exception $e) {
356 print '<div class="error mess3">';
357 print $e->getMessage();
358 print '<br>';
359 print '<a class="" href="'.$_SERVER["PHP_SELF"].'?clearcache=1">'.$langs->trans("Retry").'</a>';
360 print '</div>';
361 }
362}
363
364print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'" spellcheck="false">';
365
366if ($optioncss != '') {
367 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
368}
369print '<input type="hidden" name="token" value="'.newToken().'">';
370print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
371print '<input type="hidden" name="action" value="list">';
372print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
373print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
374print '<input type="hidden" name="page" value="'.$page.'">';
375print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
376print '<input type="hidden" name="withtab" value="'.$withtab.'">';
377
378print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
379print '<table class="noborder centpercent liste">';
380
381// Line of filters
382print '<tr class="liste_titre_filter">';
383
384// Action column
385if ($conf->main_checkbox_left_column) {
386 print '<td class="liste_titre center">';
387 $searchpicto = $form->showFilterButtons();
388 print $searchpicto;
389 print '</td>';
390}
391
392print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.dol_escape_htmltag($search_id).'"></td>';
393
394print '<td class="liste_titre">';
395//print $langs->trans("from").': ';
396print $form->selectDate($search_start, 'search_start');
397//print '<br>';
398//print $langs->trans("to").': ';
399print $form->selectDate($search_end, 'search_end');
400print '</td>';
401
402// User
403print '<td class="liste_titre">';
404print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth100');
405print '</td>';
406
407// Module source
408print '<td class="liste_titre">';
409//print $form->multiselectarray('search_module_source', $block_static->trackedmodules, $search_module_source, 0, 0, 'minwidth75 maxwidth200', 1);
410print '<input type="text" class="maxwidth100" name="search_module_source" list="search_module_sources" value="'.dol_escape_htmltag($search_module_source[0]).'">';
411if (isModEnabled('takepos')) {
412 print '<datalist id="search_module_sources">
413 <option value="takepos">
414 <option value="backoffice">
415 </datalist>';
416}
417print '</td>';
418
419// POS source
420print '<td class="liste_titre">';
421print '<input type="text" class="maxwidth50" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).'">';
422print '</td>';
423
424// Actions code
425
426$actioncodetoshowincombo = array();
427// Merge the action PAYMENT_CUSTOMER_CREATE and PAYMENT_CUSTOMER_DELETE into PAYMENT_CUSTOMER
428foreach ($block_static->trackedevents as $key => $value) {
429 if ($key === 'PAYMENT_CUSTOMER_DELETE') {
430 $actioncodetoshowincombo['PAYMENT_CUSTOMER'] = array('id' => 'PAYMENT_CUSTOMER', 'label' => 'logPAYMENT_CUSTOMER', 'labelhtml' => img_picto('', 'bill', 'class="pictofixedwidth").').$langs->trans('logPAYMENT_CUSTOMER'));
431 unset($actioncodetoshowincombo['PAYMENT_CUSTOMER_CREATE']);
432 unset($actioncodetoshowincombo['PAYMENT_CUSTOMER_DELETE']);
433 } else {
434 $actioncodetoshowincombo[$key] = $value;
435 }
436}
437$actioncodetoshowincombo['PAYMENT_CUSTOMER'] = array('id' => 'PAYMENT_CUSTOMER', 'label' => 'logPAYMENT_CUSTOMER', 'labelhtml' => img_picto('', 'bill', 'class="pictofixedwidth").').$langs->trans('logPAYMENT_CUSTOMER'));
438
439print '<td class="liste_titre">';
440print $form->multiselectarray('search_code', $actioncodetoshowincombo, $search_code, 0, 0, 'maxwidth200', 1);
441print '</td>';
442
443// Ref
444print '<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
445
446// Payment mode
447//print '<td class="liste_titre"><input type="text" class="maxwidth100" name="search_type_code" value="'.dol_escape_htmltag($search_type_code).'"></td>';
448
449// Amount
450print '<td class="liste_titre right"><input type="text" class="maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
451
452// Full data
453print '<td class="liste_titre"></td>';
454
455// Fingerprint
456print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_signature" value="'.dol_escape_htmltag($search_signature).'"></td>';
457
458// Status
459print '<td class="liste_titre center minwidth75imp parentonrightofpage">';
460$array = array("1" => $langs->trans("OnlyNonValid").' (KO)');
461print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1, 0, 0, '', 1, 0, 0, 'ASC', 'search_status width100 onrightofpage', 1);
462print '</td>';
463
464// Link to debug information object
465if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
466 print '<td class="liste_titre"></td>';
467 print '<td class="liste_titre"></td>';
468}
469
470// Action column
471if (!$conf->main_checkbox_left_column) {
472 print '<td class="liste_titre center">';
473 $searchpicto = $form->showFilterButtons();
474 print $searchpicto;
475 print '</td>';
476}
477
478print '</tr>';
479
480
481print '<tr class="liste_titre">';
482// Action column
483if ($conf->main_checkbox_left_column) {
484 print getTitleFieldOfList('<span id="blockchainstatus"></span>', 0, $_SERVER["PHP_SELF"], '', '', $param, 'class="center"', $sortfield, $sortorder, '')."\n";
485}
486print getTitleFieldOfList($langs->trans('#'), 0, $_SERVER["PHP_SELF"], 'rowid', '', $param, '', $sortfield, $sortorder, 'minwidth50 ')."\n";
487print getTitleFieldOfList($langs->trans('Date'), 0, $_SERVER["PHP_SELF"], 'date_creation', '', $param, '', $sortfield, $sortorder, '')."\n";
488print getTitleFieldOfList($langs->trans('Author'), 0, $_SERVER["PHP_SELF"], 'user_fullname', '', $param, '', $sortfield, $sortorder, '')."\n";
489print getTitleFieldOfList($langs->trans('POS'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
490print getTitleFieldOfList($langs->trans('Terminal'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
491print getTitleFieldOfList($langs->trans('Action'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
492print getTitleFieldOfList($langs->trans('Ref'), 0, $_SERVER["PHP_SELF"], 'ref_object', '', $param, '', $sortfield, $sortorder, '')."\n";
493//print getTitleFieldOfList($langs->trans('PaymentMode'), 0, $_SERVER["PHP_SELF"], 'type_code', '', $param, '', $sortfield, $sortorder, '')."\n";
494print getTitleFieldOfList($langs->trans('Amount'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ', 0, $langs->trans("TotalTTCIfInvoiceSeeCompleteDataForDetail").'<br>'.$langs->trans("AmountInCurrency", getDolCurrency()))."\n";
495print getTitleFieldOfList($langs->trans('DataOfArchivedEvent'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ', 0, $langs->trans('DataOfArchivedEventHelp'), 1)."\n";
496print getTitleFieldOfList($langs->trans('Fingerprint'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
497print getTitleFieldOfList($form->textwithpicto($langs->trans('Status'), $langs->trans('DataOfArchivedEventHelp2')), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
498if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
499 print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
500 print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
501}
502// Action column
503if (!$conf->main_checkbox_left_column) {
504 print getTitleFieldOfList('<span id="blockchainstatus"></span>', 0, $_SERVER["PHP_SELF"], '', '', $param, 'class="center"', $sortfield, $sortorder, '')."\n";
505}
506print '</tr>';
507
508$checkresult = array();
509$checkdetail = array();
510$checkerror = array();
511$loweridinerror = 0; // The lower rowid we found an anomaly (for debug or analysis purposes only)
512
513// This is the algorithm that optimize the memory (note: it will not report errors that are outside the filter range, but we don't need them)
514if (is_array($blocks)) {
515 foreach ($blocks as &$block) {
516 // Enable this log to get information used to recalculate the signature
517 //var_dump($block->id.' '.$block->signature, $block->object_data);
518
519 $tmpcheckresult = $block->checkSignature('', 1); // Note: this make a sql request at each call, we can't avoid this as the sorting order and filter is various
520
521 $checksignature = $tmpcheckresult['checkresult'];
522
523 $checkresult[$block->id] = $checksignature; // false if error
524 $checkdetail[$block->id] = $tmpcheckresult;
525
526 if (!empty($tmpcheckresult['error'])) {
527 $checkerror[$block->id] = $tmpcheckresult['error'];
528 }
529 if (!empty($block->note)) {
530 $checkresult[$block->id] = false;
531 //$checkerror[$block->id] = $block->note;
532 }
533
534 if (!$checksignature) {
535 if (empty($loweridinerror)) {
536 $loweridinerror = $block->id;
537 } else {
538 $loweridinerror = min($loweridinerror, $block->id);
539 }
540 }
541 }
542}
543
544$refinvoicefound = array();
545$totalhtamount = array();
546$totalvatamount = array();
547$totalamount = array();
548
549if (is_array($blocks)) {
550 $nbshown = 0;
551 $object_link = '';
552 $object_link_title = '';
553
554 $colspan = 12;
555 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) {
556 $colspan++;
557 $colspan++;
558 }
559
560 // Get the last record of the chain (may be used later).
561 $lastrecord = $block_static->getLastRecord();
562
563 $lockfile = $block_static->getEndOfChainFlagFile();
564 $lockline = '';
565
566 // Check that there was no deletion on the end of chain.
567 // Note: We can find a similar code into the blockedlog_archive
568 if (defined('BLOCKEDLOG_END_FLAG_IN_A_FILE')) {
569 if (!file_exists($lockfile)) {
570 $error++;
571
572 print '<tr><td class="center" colspan="'.$colspan.'">';
573 if ($mysoc->country_code == 'FR') {
574 print '<span class="error">'.$langs->trans("ErrorEndOfChainFlagWasRemoved").'</span>';
575 } else {
576 print '<span class="warning">'.$langs->trans("WarningNoProtectionOnEndOfChain").'</span>';
577 }
578 print '</td></tr>';
579 } else {
580 $lockline = trim(file_get_contents($lockfile));
581 }
582 } else {
583 $sql = "SELECT value from ".MAIN_DB_PREFIX."const";
584 $sql .= " WHERE name = '".$db->escape(basename($lockfile))."' AND entity = ".((int) $conf->entity);
585 $resql = $db->query($sql);
586 if ($resql) {
587 $obj = $db->fetch_object($resql);
588 if ($obj) {
589 $lockline = $obj->value;
590 } else {
591 $error++;
592
593 print '<tr><td class="center" colspan="'.$colspan.'">';
594 if ($mysoc->country_code == 'FR') {
595 print '<span class="error">'.$langs->trans("ErrorEndOfChainFlagWasRemoved").'</span>';
596 } else {
597 print '<span class="warning">'.$langs->trans("WarningNoProtectionOnEndOfChain").'</span>';
598 }
599 print '</td></tr>';
600 }
601 }
602 }
603
604 if (! $error) {
605 $headstring = '';
606 if (preg_match('/^dolcrypt/', $lockline)) {
607 $headstring = dolDecrypt($lockline, '', 'BLOCKEDLOGHEAD');
608 } elseif (preg_match('/^dolobfuscation/', $lockline)) {
609 try {
610 $remoteobfuscationkey = $block_static->getObfuscationKey();
611 if (empty($remoteobfuscationkey)) {
612 throw new Exception('Remote obfuscation key is empty');
613 }
614 } catch (Exception $e) {
615 $error++;
616
617 print '<tr><td class="center" colspan="'.$colspan.'">';
618 $url_for_ping = getDolGlobalString('MAIN_URL_FOR_PING', "https://ping.dolibarr.org/");
619 print '<span class="warning">'.$langs->trans("FailedToGetRemoteObfuscationKeyReTryLater", $url_for_ping).'</span>';
620 print ' ';
621 print '<span class="warning">'.$langs->trans("CantValidateEndOfChain").'</span>';
622 print '</td></tr>';
623 }
624 $headstring = dolDecrypt($lockline, $remoteobfuscationkey, 'BLOCKEDLOGHEAD');
625 }
626
627 $reg = array();
628 if (preg_match('/^BLOCKEDLOGHEAD (\d+) ([^\s]+) ([a-zA-Z0-9\-]+)/', $headstring, $reg)) { // Failed to decypt the head
629 // Compare with last line
630 $lastrecordid = $lastrecord['id'];
631 $lastrecorddate = $lastrecord['date'];
632 $lastrecordsignature = $lastrecord['signature'];
633
634 if ($reg[1] > $lastrecordid || $reg[3] != $lastrecordsignature) {
635 $error++;
636
637 // Check that last line is the one declared into the head flag. If not, it means some record were deleted at end of chain.
638 print '<tr><td class="center" colspan="'.$colspan.'">';
639 print '<span class="error">'.$langs->trans("ErrorEndOfChainRecordWasRemoved", str_replace(array('T', 'Z'), ' ', dol_print_date($lastrecorddate, 'dayhourrfc', 'gmt')), str_replace(array('T', 'Z'), ' ', $reg[2])).'</span>';
640 print '</td></tr>';
641 }
642 } else {
643 $error++;
644
645 print '<tr><td class="center" colspan="'.$colspan.'">';
646 print '<span class="error">'.$langs->trans("FailedToDecodeTheHeadFlagEndOfChainIsNotReliable").'</span>';
647 print '</td></tr>';
648 }
649 }
650
651 // Now loop on each line to show them
652 foreach ($blocks as &$block) {
653 //if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
654 if (empty($search_showonlyerrors) || !$checkresult[$block->id]) {
655 $nbshown++;
656
657 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) {
658 if ($nbshown < $MAXFORSHOWNLINKS) { // For performance and memory purpose, we get/show the debug info link of objects only for the 100 first output
659 $object_link = $block->getObjectLink();
660 $object_link_title = '';
661 } else {
662 $object_link = $block->element.'/'.$block->fk_object;
663 $object_link_title = $langs->trans('LinkHasBeenDisabledForPerformancePurpose');
664 }
665 }
666
667 print '<tr class="oddeven">';
668
669 // Action column
670 if ($conf->main_checkbox_left_column) {
671 print '<td>';
672 print '</td>';
673 }
674
675 // ID
676 print '<td>'.dolPrintHTML((string) $block->id).'</td>';
677
678 // Date
679 print '<td class="nowraponall">'.dol_print_date($block->date_creation, 'dayhour', 'tzuserrel').'</td>';
680
681 // User
682 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($block->user_fullname).'">';
683 //print $block->getUser()
684 print dolPrintHTML($block->user_fullname);
685 print '</td>';
686
687 // Module Source
688 $labelofmodulesource = $block->module_source;
689 print '<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($labelofmodulesource).'">'.dolPrintHTML($labelofmodulesource).'</td>';
690
691 // Terminal POS
692 print '<td>'.dolPrintHTML($block->pos_source).'</td>';
693
694 // Action
695 $labelofaction = $langs->transnoentitiesnoconv('log'.$block->action);
696 print '<td class="" title="'.dolPrintHTMLForAttribute($labelofaction).'">';
697 print '<div class="twolinesmax-normallineheight minwidth200onall small">';
698 print dolPrintHTML($labelofaction);
699 print '</div>';
700 print '</td>';
701
702 // Define $totalhtamount, $totalvatamount, $totalamount for $block action code and module
703 $total_ht = $total_vat = $total_ttc = 0;
704 sumAmountsForUnalterableEvent($block, $refinvoicefound, $totalhtamount, $totalvatamount, $totalamount, $total_ht, $total_vat, $total_ttc);
705
706 // Ref
707 print '<td class="nowraponall"><div class="smallheight" title="'.dolPrintHTMLForAttribute(price($total_ttc)).'">';
708 if (!empty($block->ref_object)) {
709 print dolPrintHTML($block->ref_object);
710 if ($block->linktype && $block->linktoref) {
711 if ($block->linktype == 'payment') {
712 print '<br><span class="opacitymedium small">'.$langs->trans("PaymentOf").' '.$block->linktoref.'</span>';
713 }
714 if ($block->linktype == 'replacedby') {
715 print '<br><span class="opacitymedium small">'.$langs->trans("ReplacedBy").' '.$block->linktoref.'</span>';
716 }
717 if ($block->linktype == 'credit_note_of') {
718 print '<br><span class="opacitymedium small">'.$langs->trans("CreditNoteOf").' '.$block->linktoref.'</span>';
719 }
720 }
721 } else {
722 // Ref not stored
723 }
724 print '</div></td>';
725
726 // Payment mode
727 //print '<td>'.dolPrintHTML($block->type_code).'</td>';
728
729 // Amount
730 print '<td class="right nowraponall"><span class="amount">';
731 if (!in_array($block->action, array('BLOCKEDLOG_EXPORT', 'CASHCONTROL_CLOSE', 'MODULE_SET', 'MODULE_RESET'))) {
732 $showamount = in_array($block->action, array('BILL_VALIDATE', 'PAYMENT_CUSTOMER_CREATE', 'PAYMENT_CUSTOMER_DELETE'));
733 if ($showamount) {
734 print price($total_ttc);
735 }
736 }
737 print '</span></td>';
738
739 // Details link
740 print '<td class="center"><a href="#" data-blockid="'.$block->id.'" rel="show-info">'.img_picto($langs->trans('ShowDetails'), 'note', 'class="size15x"').'</span></td>';
741
742 // Fingerprint
743 print '<td class="nowraponall">';
744 // Note: the previous line id is not necessarily id-1, so in texttoshow we say "on previous line" without giving id to avoid a search/fetch to get previous id.
745 $texttoshow = $langs->trans("Fingerprint").' - '.$langs->trans("SavedOnLine").' =<br>'.$block->signature;
746 $texttoshow .= '<br><br>'.$langs->trans("Fingerprint").' - Recalculated hash_hmac(\'sha256\', '.strtolower($langs->trans("PreviousHash").' on previous line').' + data, secret key) =<br>'.$checkdetail[$block->id]['calculatedsignature'];
747 $texttoshow .= '<br><span class="opacitymedium">'.$langs->trans("PreviousHash").'='.$checkdetail[$block->id]['previoushash'].'</span>';
748 $texttoshow .= '<br><span class="opacitymedium">'.$langs->trans("SecretKey").'=Not available from interface</span>';
749 //$texttoshow .= '<br>keyforsignature='.$checkdetail[$block->id]['keyforsignature'];
750 print $form->textwithpicto(dol_trunc($block->signature, 8), $texttoshow, 1, 'help', '', 0, 2, 'fingerprint'.$block->id);
751 print '</td>';
752
753 // Status
754 print '<td class="center">';
755 if (!$checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) { // If error
756 if ($checkresult[$block->id]) {
757 //print '<span class="badge badge-status4 badge-status" title="'.dolPrintHTMLForAttribute($langs->trans('OkCheckFingerprintValidityButChainIsKo')).'">'.$langs->trans("StatusValid").'</span>';
758 print '<span class="badge badge-status4 badge-status" title="'.dolPrintHTMLForAttribute($langs->trans('OkCheckFingerprintValidity')).'">'.$langs->trans("StatusValid").'</span>';
759 } elseif ($block->action == 'MODULE_RESET') {
760 // Old action code on old version.
761 print '<span class="badge badge-status8 badge-status" title="'.dolPrintHTMLForAttribute('Module has been disabled').'">OK</span>';
762 } else {
763 print '<span class="badge badge-status8 badge-status" title="';
764 if (!empty($checkerror[$block->id])) {
765 print dolPrintHTMLForAttribute($checkerror[$block->id])."\n";
766 }
767 $alt = $langs->trans('KoCheckFingerprintValidity');
768 if ($block->note) {
769 $notetoshow = $block->note;
770 $notetoshow = str_replace('EndOfChainDeletionDetected', $langs->trans("EndOfChainDeletionDetected"), $notetoshow);
771 $alt .= "\n".' '.$langs->trans("AddtionalInformation").': '.$notetoshow;
772 }
773
774 print dolPrintHTMLForAttribute($alt).'">KO</span>';
775 }
776 } else {
777 print '<span class="badge badge-status4 badge-status" title="'.$langs->trans('OkCheckFingerprintValidity').'">'.$langs->trans("StatusValid").'</span>';
778 }
779
780 // Add debug information
781 if (!$checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) { // If error
782 if ($checkresult[$block->id]) {
783 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) {
784 print $form->textwithpicto('', $langs->trans('OkCheckFingerprintValidityButChainIsKo'));
785 }
786 }
787 }
788 print '</td>';
789
790 // Link to debug information object
791 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
792 print '<td class="nowraponall">';
793 print '<!-- version -->'; // $object_link can be a '<a href' link or a text
794 print '<span class="small">'.$block->object_version. '<br>'.$block->object_format.'</span>';
795 print '</td>';
796
797 print '<td class="tdoverflowmax150"'.(preg_match('/<a/', $object_link) ? '' : 'title="'.dol_escape_htmltag(dol_string_nohtmltag($object_link.($object_link_title ? ' - '.$object_link_title : ''))).'"').'>';
798 print '<!-- object_link -->'; // $object_link can be a '<a href' link or a text with more information
799 print $object_link;
800 print '</td>';
801 }
802
803 // Action column
804 if (!$conf->main_checkbox_left_column) {
805 print '<td class="liste_titre">';
806 print '</td>';
807 }
808
809 print '</tr>';
810 }
811 }
812
813 // Define which source we want to show
814 $showtotalfor = array();
815 foreach ($totalamount as $key => $totalamountofcodepersource) {
816 if ($key == 'BILL_VALIDATE' || $key == 'PAYMENT_CUSTOMER') {
817 foreach ($totalamountofcodepersource as $source => $tmpval) {
818 $showtotalfor[$source] = 1;
819 // If we found one entry for the source, we make sure we have both BILL_VALIDATE and PAYMENT_CUSTOMER for this source
820 if (empty($totalamount['BILL_VALIDATE'][$source])) {
821 $totalamount['BILL_VALIDATE'][$source] = 0;
822 }
823 if (empty($totalamount['PAYMENT_CUSTOMER'][$source])) {
824 $totalamount['PAYMENT_CUSTOMER'][$source] = 0;
825 }
826 if (empty($totalhtamount['BILL_VALIDATE'][$source])) {
827 $totalhtamount['BILL_VALIDATE'][$source] = 0;
828 }
829 if (empty($totalhtamount['PAYMENT_CUSTOMER'][$source])) {
830 $totalhtamount['PAYMENT_CUSTOMER'][$source] = 0;
831 }
832 if (empty($totalvatamount['BILL_VALIDATE'][$source])) {
833 $totalvatamount['BILL_VALIDATE'][$source] = 0;
834 }
835 if (empty($totalvatamount['PAYMENT_CUSTOMER'][$source])) {
836 $totalvatamount['PAYMENT_CUSTOMER'][$source] = 0;
837 }
838 }
839 }
840 }
841
842 // Show total lines
843 if ($nbshown == 0) {
844 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
845 } else {
846 ksort($totalamount);
847 krsort($showtotalfor);
848
849 // Show the total for period if filters are ok
850 $afilterexists = ($search_id || ($search_fk_user > 0) || $search_ref || $search_amount || $search_signature);
851
852 $countsource = 0;
853 foreach ($showtotalfor as $source => $tmpval) {
854 $countsource++;
855
856 // Line of title for total for period for $source
857 print '<tr class="liste_titre totalblockedlog">';
858 print '<td colspan="'.$colspan.'"';
859 if ($countsource == 1) {
860 print ' style="border-top: 1px solid #000;"';
861 }
862 print '>';
863 print $langs->trans("TotalForThePeriod");
864 print ' - '.($source ? $langs->trans("PointOfSale").' '.ucfirst($source) : $langs->trans("BackOffice"));
865 print ' <span class="opacitylow">(';
866 if ($afilterexists) {
867 print img_picto($langs->trans("ForPeriodAndFilters"), 'warning', 'class="pictofixedwidth"');
868 }
869 print $langs->trans("ForPeriodAndFilters").')</span>';
870 print '</td>';
871 print '</tr>';
872
873 foreach ($totalamount as $actioncode => $totalamountofcodepersource) {
874 if ($actioncode == 'BILL_VALIDATE' && (!empty($search_code) && !in_array('BILL_VALIDATE', $search_code))) {
875 continue;
876 }
877 if ($actioncode == 'PAYMENT_CUSTOMER' && (!empty($search_code) && !in_array('PAYMENT_CUSTOMER', $search_code))) {
878 continue;
879 }
880
881 // Total
882 print '<tr class="liste_total totalblockedlog">';
883
884 // Action column
885 if ($conf->main_checkbox_left_column) {
886 print '<td>';
887 print '</td>';
888 }
889
890 // ID
891 print '<td colspan="4">';
892 $s = $actioncode;
893 if ($actioncode == 'BILL_VALIDATE') {
894 $s = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("Turnover");
895 } elseif ($actioncode == 'PAYMENT_CUSTOMER') {
896 $s = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("TurnoverCollected");
897 }
898 print $form->textwithpicto($s, $langs->trans("TotalForAction").' '.$langs->trans('log'.$actioncode));
899 print '</td>';
900
901 // Action
902 print '<td></td>';
903
904 // Amount (HT)
905 print '<td class="right nowraponall" colspan="3">';
906 if ($actioncode == 'BILL_VALIDATE') {
907 print '<span class="amount">'.price($totalhtamount[$actioncode][$source]).'</span>';
908 print ' '.$langs->trans("HT");
909
910 print ' - ';
911
912 print '<span class="amount">'.price($totalvatamount[$actioncode][$source]).'</span>';
913 print ' '.$langs->trans("VAT");
914
915 print ' - ';
916 }
917
918 print '<span class="amount">'.price($totalamount[$actioncode][$source]).'</span>';
919 if ($actioncode == 'BILL_VALIDATE') {
920 print ' '.$langs->trans("TTC");
921 }
922 print '</td>';
923
924 // Details link
925 print '<td class="center"></td>';
926
927 // Fingerprint
928 print '<td class="nowraponall">';
929 print '</td>';
930
931 // Status
932 print '<td class="center">';
933 print '</td>';
934
935 // Link to debug information object
936 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
937 print '<td></td>';
938
939 print '<td class="tdoverflowmax150"'.(preg_match('/<a/', $object_link) ? '' : 'title="'.dol_escape_htmltag(dol_string_nohtmltag($object_link.($object_link_title ? ' - '.$object_link_title : ''))).'"').'>';
940 print '</td>';
941 }
942
943 // Action column
944 if (!$conf->main_checkbox_left_column) {
945 print '<td class="liste_titre">';
946 print '</td>';
947 }
948
949 print '</tr>';
950 }
951 }
952
953 // Show total for lifetime
954 $countsource = 0;
955 foreach ($showtotalfor as $source => $tmpval) {
956 $countsource++;
957
958 if (empty($search_end) || $search_end == -1) {
959 $search_end = dol_now();
960 }
961
962 // Get lifetime amount of all invoices validated and payments created/deleted.
963 // We do not use $totalamountalllines because it is only for the period, but we want lifetime amount since the first record to now.
964
965 $totalamountlifetime = array('BILL_VALIDATE' => array(), 'PAYMENT_CUSTOMER_CREATE' => array(), 'PAYMENT_CUSTOMER_DELETE' => array());
966 $totalhtamountlifetime = array('BILL_VALIDATE' => array(), 'PAYMENT_CUSTOMER_CREATE' => array(), 'PAYMENT_CUSTOMER_DELETE' => array());
967
968 $foundoldformat = 0;
969 $firstrecorddate = 0;
970 global $foundoldformat, $firstrecorddate;
971 include DOL_DOCUMENT_ROOT.'/blockedlog/admin/lifetimeamount.inc.php';
972 '@phan-var-force array<string,array<string,float>> $totalamountlifetime';
973 '@phan-var-force array<string,array<string,float>> $totalhtamountlifetime';
974
975 print '<tr class="liste_titre totalblockedlog" style="border-top: 1px solid #222">';
976 print '<td colspan="'.$colspan.'"';
977 if ($countsource == 1) {
978 print ' style="border-top: 1px solid #000;"';
979 }
980 print '>';
981
982 print $langs->trans("TotalForLifetime");
983 print ' - '.($source ? $langs->trans("PointOfSale").' '.ucfirst($source) : $langs->trans("BackOffice"));
984
985 print ' <span class="opacitymedium">('.dol_print_date($firstrecorddate, 'dayhour', 'tzuserrel');
986 if (GETPOST('search_endyear') && $search_end && $search_end != -1) {
987 print ' - '.dol_print_date($search_end, 'dayhoursec', 'tzuserrel');
988 } else {
989 print ' - '.$langs->trans("Now");
990 }
991 print ')</span>';
992 print '</td>';
993 print '</tr>';
994
995 // Lifetime amount of invoices validated
996 if (empty($search_code) || in_array('BILL_VALIDATE', $search_code)) {
997 // Total
998 print '<tr class="liste_total totalblockedlog">';
999
1000 // Action column
1001 if ($conf->main_checkbox_left_column) {
1002 print '<td></td>';
1003 }
1004
1005 // ID
1006 print '<td colspan="4">';
1007
1008 $s = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("Turnover");
1009 print $form->textwithpicto($s, $langs->trans("TotalForAction").' '.$langs->trans('logBILL_VALIDATE'));
1010
1011 print ' &nbsp; ';
1012
1013 // If there is at least one record with old format
1014 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE object_format < 'V2' and action = 'BILL_VALIDATE' LIMIT 1";
1015 $resql = $db->query($sql);
1016 $obj = $db->fetch_object($resql);
1017 if ($obj) {
1018 $foundav1 = 1;
1019 if ($includebeforev2) {
1020 print ' <span class="small"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?includebeforev2=0&'.($page ? 'page='.$page.'&' : '').$param.'">'.$form->textwithpicto($langs->trans("OnlyFromV2"), $langs->trans("OnlyFromV2Help")).'</a></span>';
1021 } else {
1022 print ' <span class="small"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?includebeforev2=1&'.($page ? 'page='.$page.'&' : '').$param.'">'.$form->textwithpicto($langs->trans("IncludesAll"), $langs->trans("IncludesAllHelp")).'</a></span>';
1023 }
1024 }
1025 print '</td>';
1026
1027 // Action
1028 print '<td></td>';
1029
1030 // Amount (HT)
1031 print '<td class="right nowraponall" colspan="3">';
1032 print ($foundoldformat ? '' : '<span class="amount">'.price($totalhtamountlifetime['BILL_VALIDATE'][$source]).'</span> '.$langs->trans("HT")).($foundoldformat ? '' : ' - <span class="amount">'.price((float) $totalamountlifetime['BILL_VALIDATE'][$source] - (float) $totalhtamountlifetime['BILL_VALIDATE'][$source]).'</span> '.$langs->transnoentitiesnoconv("VAT")).($foundoldformat ? '' : " - ").'<span class="amount">'.price($totalamountlifetime['BILL_VALIDATE'][$source]).'</span> '.$langs->trans("TTC");
1033 print '</td>';
1034
1035 // Details link
1036 print '<td class="center"></td>';
1037
1038 // Fingerprint
1039 print '<td class="nowraponall"></td>';
1040
1041 // Status
1042 print '<td class="center"></td>';
1043
1044 // Link to debug information object
1045 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
1046 print '<td>';
1047 print '</td>';
1048
1049 print '<td class="tdoverflowmax150"'.(preg_match('/<a/', $object_link) ? '' : 'title="'.dol_escape_htmltag(dol_string_nohtmltag($object_link.($object_link_title ? ' - '.$object_link_title : ''))).'"').'>';
1050 print '</td>';
1051 }
1052
1053 // Action column
1054 if (!$conf->main_checkbox_left_column) {
1055 print '<td class="liste_titre"></td>';
1056 }
1057
1058 print '</tr>';
1059 }
1060
1061 // Lifetime amount for payments
1062 if (empty($search_code)
1063 || in_array('PAYMENT_CUSTOMER', $search_code) // Filter for both PAYMENT_CUSTOMER_CREATE and PAYMENT_CUSTOMER_DELETE
1064 || in_array('PAYMENT_CUSTOMER_CREATE', $search_code)
1065 || in_array('PAYMENT_CUSTOMER_DELETE', $search_code)) {
1066 // Total
1067 print '<tr class="liste_total totalblockedlog">';
1068
1069 // Action column
1070 if ($conf->main_checkbox_left_column) {
1071 print '<td></td>';
1072 }
1073
1074 // ID
1075 print '<td colspan="4">';
1076
1077 $s = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("TurnoverCollected");
1078 print $form->textwithpicto($s, $langs->trans("TotalForAction").' '.$langs->trans('logPAYMENT_CUSTOMER'));
1079
1080 print '</td>';
1081
1082 // Action
1083 print '<td></td>';
1084
1085 // Amount (HT)
1086 print '<td class="right nowraponall" colspan="3">';
1087 print '<span class="amount">'.price((float) $totalamountlifetime['PAYMENT_CUSTOMER_CREATE'][$source] + (float) $totalamountlifetime['PAYMENT_CUSTOMER_DELETE'][$source]).'</span>';
1088 print '</td>';
1089
1090 // Details link
1091 print '<td class="center"></td>';
1092
1093 // Fingerprint
1094 print '<td class="nowraponall"></td>';
1095
1096 // Status
1097 print '<td class="center"></td>';
1098
1099 // Link to debug information object
1100 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
1101 print '<td>';
1102 print '</td>';
1103
1104 print '<td class="tdoverflowmax150"'.(preg_match('/<a/', $object_link) ? '' : 'title="'.dol_escape_htmltag(dol_string_nohtmltag($object_link.($object_link_title ? ' - '.$object_link_title : ''))).'"').'>';
1105 print '</td>';
1106 }
1107
1108 // Action column
1109 if (!$conf->main_checkbox_left_column) {
1110 print '<td class="liste_titre"></td>';
1111 }
1112
1113 print '</tr>';
1114 }
1115 }
1116 }
1117}
1118
1119print '</table>';
1120
1121print '</div>';
1122
1123print '</form>';
1124
1125// Javascript to manage the showinfo popup
1126print '<script type="text/javascript">
1127
1128jQuery(document).ready(function () {
1129 jQuery("#dialogforpopup").dialog({
1130 closeOnEscape: true,
1131 classes: { "ui-dialog": "highlight" },
1132 maxHeight: window.innerHeight-60,
1133 height: window.innerHeight-60,
1134 width: '.($conf->browser->layout == 'phone' ? 400 : 700).',
1135 modal: true,
1136 autoOpen: false
1137 }).css("z-index: 5000");
1138
1139 $("a[rel=show-info]").click(function() {
1140 console.log("We click on tooltip a[rel=show-info], we open popup and get content using an ajax call");
1141
1142 var fk_block = $(this).attr("data-blockid");
1143
1144 $.ajax({
1145 method: "GET",
1146 data: { token: \''.currentToken().'\' },
1147 url: "'.DOL_URL_ROOT.'/blockedlog/ajax/block-info.php?id="+fk_block,
1148 dataType: "html"
1149 }).done(function(data) {
1150 jQuery("#dialogforpopup").html(data);
1151 });
1152
1153 var mydialog = jQuery("#dialogforpopup");
1154 mydialog.dialog({autoOpen: false, modal: true, height: (window.innerHeight - 150), width: \'80%\', title: \''.dol_escape_js($langs->transnoentitiesnoconv("UnlaterableDataOfEvent")).'\',});
1155 mydialog.dialog("open");
1156 return false;
1157 });
1158})
1159</script>'."\n";
1160
1161
1162/*
1163if (getDolGlobalString('BLOCKEDLOG_USE_REMOTE_AUTHORITY') && getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL')) {
1164 ?>
1165 <script type="text/javascript">
1166
1167 $.ajax({
1168 method: "GET",
1169 data: { token: '<?php echo currentToken() ?>' },
1170 url: '<?php echo DOL_URL_ROOT.'/blockedlog/ajax/check_signature.php' ?>',
1171 dataType: 'html'
1172 }).done(function(data) {
1173 if(data == 'hashisok') {
1174 $('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity').' '.img_picto($langs->trans('SignatureOK'), 'on') ?>');
1175 }
1176 else{
1177 $('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity').' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
1178 }
1179
1180 });
1181
1182 </script>
1183 <?php
1184}
1185*/
1186
1187print dol_get_fiche_end();
1188
1189print '<br><br>';
1190
1191// End of page
1192llxFooter();
1193$db->close();
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
sumAmountsForUnalterableEvent($block, &$refinvoicefound, &$totalhtamount, &$totalvatamount, &$totalamount, &$total_ht, &$total_vat, &$total_ttc)
sumAmountsForUnalterableEvent
userIsTaxAuditor()
Call remote API service to push the last counter and signature.
blockedlogadmin_prepare_head($withtabsetup)
Define head array for tabs of blockedlog tools setup pages.
isRegistrationDataSavedAndPushed()
Return if the KYC mandatory parameters are set AND pushed/registered centralized server.
getHashUniqueIdOfRegistration($algo='sha256')
Return a hash unique identifier of the registration (used to identify the registration of instance wi...
isALNERunningVersion($blockedlogtestalreadydone=0, $blockedlogmodulealreadydone=0)
Return if the application is executed with the LNE requirements on.
Class to manage Blocked Log.
Class to manage generation of HTML components Only common components must be here.
global $mysoc
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition date.lib.php:126
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.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
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)
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='')
Show information in HTML for admin users or standard users.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into JavaScript code.
dolPrintHTMLForAttribute($s, $escapeonlyhtmltags=0, $allowothertags=array())
Return a string ready to be output into an HTML attribute (alt, title, data-html, ....
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
getDolDefaultContextPage($s)
Return the default context page string.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
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.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
dolDecrypt($chain, $key='', $patterntotest='')
Decode a string with a symmetric encryption.