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_amount='.urlencode($search_amount);
279}
280if (!empty($search_module_source)) {
281 $param .= '&search_module_source='.urlencode(implode(',', $search_module_source));
282}
283if ($search_pos_source) {
284 $param .= '&search_pos_source='.urlencode($search_pos_source);
285}
286if ($search_type_code) {
287 $param .= '&search_type_code='.urlencode($search_type_code);
288}
289if ($search_startyear > 0) {
290 $param .= '&search_startyear='.((int) $search_startyear);
291}
292if ($search_startmonth > 0) {
293 $param .= '&search_startmonth='.((int) $search_startmonth);
294}
295if ($search_startday > 0) {
296 $param .= '&search_startday='.((int) $search_startday);
297}
298if ($search_endyear > 0) {
299 $param .= '&search_endyear='.((int) $search_endyear);
300}
301if ($search_endmonth > 0) {
302 $param .= '&search_endmonth='.((int) $search_endmonth);
303}
304if ($search_endday > 0) {
305 $param .= '&search_endday='.((int) $search_endday);
306}
307if ($search_amount) {
308 $param .= '&search_amount='.urlencode($search_amount);
309}
310if ($search_signature) {
311 $param .= '&search_signature='.urlencode($search_signature);
312}
313if ($search_showonlyerrors > 0) {
314 $param .= '&search_showonlyerrors='.((int) $search_showonlyerrors);
315}
316if ($withtab) {
317 $param .= '&withtab='.((int) $withtab);
318}
319
320// Clear memory cache of the obfuscation key
321if (GETPOST('clearcache')) {
322 unset($_SESSION['obfuscationkey_'.((int) $conf->entity)]);
323 unset($conf->cache['obfuscationkey_'.((int) $conf->entity)]);
324}
325
326// Get the remoteobfuscation key
327// 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.
328$remoteobfuscationkey = '';
329if (isALNERunningVersion(1) && $mysoc->country_code == 'FR') {
330 try {
331 $remoteobfuscationkey = $block_static->getObfuscationKey();
332 // Note: To emulate a pb in getting the obfuscation key, there is some code to uncomment into the method
333 } catch (Exception $e) {
334 $error++;
335
336 print '<div class="error mess1">';
337 print $e->getMessage();
338 print '<br>';
339 print '<a class="" href="'.$_SERVER["PHP_SELF"].'?clearcache=1">'.$langs->trans("Retry").'</a>';
340 print '</div>';
341 }
342}
343
344// Get the encoded HMAC key.
345$hmac_encoded_secret_key = $block_static->getEncodedHMACSecretKey(); // Can be old 'dolcrypt:...' if migration not yet complete but should be 'dolobfuscationv1...'
346if (empty($hmac_encoded_secret_key)) {
347 // This is no more the case since Dolibarr v23 and Blockedlog v2+
348 print '<div class="error mess2">';
349 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.';
350 print '</div>';
351}
352
353// Here we have the obfuscated value of BLOCKEDLOG_HMAC_KEY in $hmac_encoded_secret_key. We need to unobfuscate it.
354$hmac_secret_key = '';
355if (!$error) {
356 try {
357 $hmac_secret_key = $block_static->getClearHMACSecretKey($hmac_encoded_secret_key); // Note: On network trouble, an Exception is thrown to the caller
358 } catch (Exception $e) {
359 print '<div class="error mess3">';
360 print $e->getMessage();
361 print '<br>';
362 print '<a class="" href="'.$_SERVER["PHP_SELF"].'?clearcache=1">'.$langs->trans("Retry").'</a>';
363 print '</div>';
364 }
365}
366
367print '<form method="POST" id="searchFormList" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'" spellcheck="false">';
368
369if ($optioncss != '') {
370 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
371}
372print '<input type="hidden" name="token" value="'.newToken().'">';
373print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
374print '<input type="hidden" name="action" value="list">';
375print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
376print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
377print '<input type="hidden" name="page" value="'.$page.'">';
378print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
379print '<input type="hidden" name="withtab" value="'.$withtab.'">';
380
381print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
382print '<table class="noborder centpercent liste">';
383
384// Line of filters
385print '<tr class="liste_titre_filter">';
386
387// Action column
388if ($conf->main_checkbox_left_column) {
389 print '<td class="liste_titre center">';
390 $searchpicto = $form->showFilterButtons();
391 print $searchpicto;
392 print '</td>';
393}
394
395print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.dol_escape_htmltag($search_id).'"></td>';
396
397print '<td class="liste_titre">';
398//print $langs->trans("from").': ';
399print $form->selectDate($search_start, 'search_start');
400//print '<br>';
401//print $langs->trans("to").': ';
402print $form->selectDate($search_end, 'search_end');
403print '</td>';
404
405// User
406print '<td class="liste_titre">';
407print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth100');
408print '</td>';
409
410// Module source
411print '<td class="liste_titre">';
412//print $form->multiselectarray('search_module_source', $block_static->trackedmodules, $search_module_source, 0, 0, 'minwidth75 maxwidth200', 1);
413print '<input type="text" class="maxwidth100" name="search_module_source" list="search_module_sources" value="'.dol_escape_htmltag($search_module_source[0]).'">';
414if (isModEnabled('takepos')) {
415 print '<datalist id="search_module_sources">
416 <option value="takepos">
417 <option value="backoffice">
418 </datalist>';
419}
420print '</td>';
421
422// POS source
423print '<td class="liste_titre">';
424print '<input type="text" class="maxwidth50" name="search_pos_source" value="'.dol_escape_htmltag($search_pos_source).'">';
425print '</td>';
426
427// Actions code
428
429$actioncodetoshowincombo = array();
430// Merge the action PAYMENT_CUSTOMER_CREATE and PAYMENT_CUSTOMER_DELETE into PAYMENT_CUSTOMER
431foreach ($block_static->trackedevents as $key => $value) {
432 if ($key === 'PAYMENT_CUSTOMER_DELETE') {
433 $actioncodetoshowincombo['PAYMENT_CUSTOMER'] = array('id' => 'PAYMENT_CUSTOMER', 'label' => 'logPAYMENT_CUSTOMER', 'labelhtml' => img_picto('', 'bill', 'class="pictofixedwidth").').$langs->trans('logPAYMENT_CUSTOMER'));
434 unset($actioncodetoshowincombo['PAYMENT_CUSTOMER_CREATE']);
435 unset($actioncodetoshowincombo['PAYMENT_CUSTOMER_DELETE']);
436 } else {
437 $actioncodetoshowincombo[$key] = $value;
438 }
439}
440$actioncodetoshowincombo['PAYMENT_CUSTOMER'] = array('id' => 'PAYMENT_CUSTOMER', 'label' => 'logPAYMENT_CUSTOMER', 'labelhtml' => img_picto('', 'bill', 'class="pictofixedwidth").').$langs->trans('logPAYMENT_CUSTOMER'));
441
442print '<td class="liste_titre">';
443print $form->multiselectarray('search_code', $actioncodetoshowincombo, $search_code, 0, 0, 'maxwidth200', 1);
444print '</td>';
445
446// Ref
447print '<td class="liste_titre"><input type="text" class="maxwidth100" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
448
449// Payment mode
450//print '<td class="liste_titre"><input type="text" class="maxwidth100" name="search_type_code" value="'.dol_escape_htmltag($search_type_code).'"></td>';
451
452// Amount
453print '<td class="liste_titre right"><input type="text" class="maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
454
455// Full data
456print '<td class="liste_titre"></td>';
457
458// Fingerprint
459print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_signature" value="'.dol_escape_htmltag($search_signature).'"></td>';
460
461// Status
462print '<td class="liste_titre center minwidth75imp parentonrightofpage">';
463$array = array("1" => $langs->trans("OnlyNonValid").' (KO)');
464print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1, 0, 0, '', 1, 0, 0, 'ASC', 'search_status width100 onrightofpage', 1);
465print '</td>';
466
467// Link to debug information object
468if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
469 print '<td class="liste_titre"></td>';
470 print '<td class="liste_titre"></td>';
471}
472
473// Action column
474if (!$conf->main_checkbox_left_column) {
475 print '<td class="liste_titre center">';
476 $searchpicto = $form->showFilterButtons();
477 print $searchpicto;
478 print '</td>';
479}
480
481print '</tr>';
482
483
484print '<tr class="liste_titre">';
485// Action column
486if ($conf->main_checkbox_left_column) {
487 print getTitleFieldOfList('<span id="blockchainstatus"></span>', 0, $_SERVER["PHP_SELF"], '', '', $param, 'class="center"', $sortfield, $sortorder, '')."\n";
488}
489print getTitleFieldOfList($langs->trans('#'), 0, $_SERVER["PHP_SELF"], 'rowid', '', $param, '', $sortfield, $sortorder, 'minwidth50 ')."\n";
490print getTitleFieldOfList($langs->trans('Date'), 0, $_SERVER["PHP_SELF"], 'date_creation', '', $param, '', $sortfield, $sortorder, '')."\n";
491print getTitleFieldOfList($langs->trans('Author'), 0, $_SERVER["PHP_SELF"], 'user_fullname', '', $param, '', $sortfield, $sortorder, '')."\n";
492print getTitleFieldOfList($langs->trans('POS'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
493print getTitleFieldOfList($langs->trans('Terminal'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
494print getTitleFieldOfList($langs->trans('Action'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
495print getTitleFieldOfList($langs->trans('Ref'), 0, $_SERVER["PHP_SELF"], 'ref_object', '', $param, '', $sortfield, $sortorder, '')."\n";
496//print getTitleFieldOfList($langs->trans('PaymentMode'), 0, $_SERVER["PHP_SELF"], 'type_code', '', $param, '', $sortfield, $sortorder, '')."\n";
497print getTitleFieldOfList($langs->trans('Amount'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right ', 0, $langs->trans("TotalTTCIfInvoiceSeeCompleteDataForDetail").'<br>'.$langs->trans("AmountInCurrency", getDolCurrency()))."\n";
498print getTitleFieldOfList($langs->trans('DataOfArchivedEvent'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ', 0, $langs->trans('DataOfArchivedEventHelp'), 1)."\n";
499print getTitleFieldOfList($langs->trans('Fingerprint'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
500print getTitleFieldOfList($form->textwithpicto($langs->trans('Status'), $langs->trans('DataOfArchivedEventHelp2')), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center ')."\n";
501if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
502 print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
503 print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
504}
505// Action column
506if (!$conf->main_checkbox_left_column) {
507 print getTitleFieldOfList('<span id="blockchainstatus"></span>', 0, $_SERVER["PHP_SELF"], '', '', $param, 'class="center"', $sortfield, $sortorder, '')."\n";
508}
509print '</tr>';
510
511$checkresult = array();
512$checkdetail = array();
513$checkerror = array();
514$loweridinerror = 0; // The lower rowid we found an anomaly (for debug or analysis purposes only)
515
516// 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)
517if (is_array($blocks)) {
518 foreach ($blocks as &$block) {
519 // Enable this log to get information used to recalculate the signature
520 //var_dump($block->id.' '.$block->signature, $block->object_data);
521
522 $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
523
524 $checksignature = $tmpcheckresult['checkresult'];
525
526 $checkresult[$block->id] = $checksignature; // false if error
527 $checkdetail[$block->id] = $tmpcheckresult;
528
529 if (!empty($tmpcheckresult['error'])) {
530 $checkerror[$block->id] = $tmpcheckresult['error'];
531 }
532 if (!empty($block->note)) {
533 $checkresult[$block->id] = false;
534 //$checkerror[$block->id] = $block->note;
535 }
536
537 if (!$checksignature) {
538 if (empty($loweridinerror)) {
539 $loweridinerror = $block->id;
540 } else {
541 $loweridinerror = min($loweridinerror, $block->id);
542 }
543 }
544 }
545}
546
547$refinvoicefound = array();
548$totalhtamount = array();
549$totalvatamount = array();
550$totalamount = array();
551
552if (is_array($blocks)) {
553 $nbshown = 0;
554 $object_link = '';
555 $object_link_title = '';
556
557 $colspan = 12;
558 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) {
559 $colspan++;
560 $colspan++;
561 }
562
563 // Get the last record of the chain (may be used later).
564 $lastrecord = $block_static->getLastRecord();
565
566 $lockfile = $block_static->getEndOfChainFlagFile();
567 $lockline = '';
568
569 // Check that there was no deletion on the end of chain.
570 // Note: We can find a similar code into the blockedlog_archive
571 if (defined('BLOCKEDLOG_END_FLAG_IN_A_FILE')) {
572 if (!file_exists($lockfile)) {
573 $error++;
574
575 print '<tr><td class="center" colspan="'.$colspan.'">';
576 if ($mysoc->country_code == 'FR') {
577 print '<span class="error">'.$langs->trans("ErrorEndOfChainFlagWasRemoved").'</span>';
578 } else {
579 print '<span class="warning">'.$langs->trans("WarningNoProtectionOnEndOfChain").'</span>';
580 }
581 print '</td></tr>';
582 } else {
583 $lockline = trim(file_get_contents($lockfile));
584 }
585 } else {
586 $sql = "SELECT value from ".MAIN_DB_PREFIX."const";
587 $sql .= " WHERE name = '".$db->escape(basename($lockfile))."' AND entity = ".((int) $conf->entity);
588 $resql = $db->query($sql);
589 if ($resql) {
590 $obj = $db->fetch_object($resql);
591 if ($obj) {
592 $lockline = $obj->value;
593 } else {
594 $error++;
595
596 print '<tr><td class="center" colspan="'.$colspan.'">';
597 if ($mysoc->country_code == 'FR') {
598 print '<span class="error">'.$langs->trans("ErrorEndOfChainFlagWasRemoved").'</span>';
599 } else {
600 print '<span class="warning">'.$langs->trans("WarningNoProtectionOnEndOfChain").'</span>';
601 }
602 print '</td></tr>';
603 }
604 }
605 }
606
607 if (! $error) {
608 $headstring = '';
609 if (preg_match('/^dolcrypt/', $lockline)) {
610 $headstring = dolDecrypt($lockline, '', 'BLOCKEDLOGHEAD');
611 } elseif (preg_match('/^dolobfuscation/', $lockline)) {
612 try {
613 $remoteobfuscationkey = $block_static->getObfuscationKey();
614 if (empty($remoteobfuscationkey)) {
615 throw new Exception('Remote obfuscation key is empty');
616 }
617 } catch (Exception $e) {
618 $error++;
619
620 print '<tr><td class="center" colspan="'.$colspan.'">';
621 $url_for_ping = getDolGlobalString('MAIN_URL_FOR_PING', "https://ping.dolibarr.org/");
622 print '<span class="warning">'.$langs->trans("FailedToGetRemoteObfuscationKeyReTryLater", $url_for_ping).'</span>';
623 print ' ';
624 print '<span class="warning">'.$langs->trans("CantValidateEndOfChain").'</span>';
625 print '</td></tr>';
626 }
627 $headstring = dolDecrypt($lockline, $remoteobfuscationkey, 'BLOCKEDLOGHEAD');
628 }
629
630 $reg = array();
631 if (preg_match('/^BLOCKEDLOGHEAD (\d+) ([^\s]+) ([a-zA-Z0-9\-]+)/', $headstring, $reg)) { // Failed to decypt the head
632 // Compare with last line
633 $lastrecordid = $lastrecord['id'];
634 $lastrecorddate = $lastrecord['date'];
635 $lastrecordsignature = $lastrecord['signature'];
636
637 if ($reg[1] > $lastrecordid || $reg[3] != $lastrecordsignature) {
638 $error++;
639
640 // Check that last line is the one declared into the head flag. If not, it means some record were deleted at end of chain.
641 print '<tr><td class="center" colspan="'.$colspan.'">';
642 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>';
643 print '</td></tr>';
644 }
645 } else {
646 $error++;
647
648 print '<tr><td class="center" colspan="'.$colspan.'">';
649 print '<span class="error">'.$langs->trans("FailedToDecodeTheHeadFlagEndOfChainIsNotReliable").'</span>';
650 print '</td></tr>';
651 }
652 }
653
654 // Now loop on each line to show them
655 foreach ($blocks as &$block) {
656 //if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
657 if (empty($search_showonlyerrors) || !$checkresult[$block->id]) {
658 $nbshown++;
659
660 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) {
661 if ($nbshown < $MAXFORSHOWNLINKS) { // For performance and memory purpose, we get/show the debug info link of objects only for the 100 first output
662 $object_link = $block->getObjectLink();
663 $object_link_title = '';
664 } else {
665 $object_link = $block->element.'/'.$block->fk_object;
666 $object_link_title = $langs->trans('LinkHasBeenDisabledForPerformancePurpose');
667 }
668 }
669
670 print '<tr class="oddeven">';
671
672 // Action column
673 if ($conf->main_checkbox_left_column) {
674 print '<td>';
675 print '</td>';
676 }
677
678 // ID
679 print '<td>'.dolPrintHTML((string) $block->id).'</td>';
680
681 // Date
682 print '<td class="nowraponall">'.dol_print_date($block->date_creation, 'dayhour', 'tzuserrel').'</td>';
683
684 // User
685 print '<td class="tdoverflowmax200" title="'.dolPrintHTMLForAttribute($block->user_fullname).'">';
686 //print $block->getUser()
687 print dolPrintHTML($block->user_fullname);
688 print '</td>';
689
690 // Module Source
691 $labelofmodulesource = $block->module_source;
692 print '<td class="tdoverflowmax250" title="'.dolPrintHTMLForAttribute($labelofmodulesource).'">'.dolPrintHTML($labelofmodulesource).'</td>';
693
694 // Terminal POS
695 print '<td>'.dolPrintHTML($block->pos_source).'</td>';
696
697 // Action
698 $labelofaction = $langs->transnoentitiesnoconv('log'.$block->action);
699 print '<td class="" title="'.dolPrintHTMLForAttribute($labelofaction).'">';
700 print '<div class="twolinesmax-normallineheight minwidth200onall small">';
701 print dolPrintHTML($labelofaction);
702 print '</div>';
703 print '</td>';
704
705 // Define $totalhtamount, $totalvatamount, $totalamount for $block action code and module
706 $total_ht = $total_vat = $total_ttc = 0;
707 sumAmountsForUnalterableEvent($block, $refinvoicefound, $totalhtamount, $totalvatamount, $totalamount, $total_ht, $total_vat, $total_ttc);
708
709 // Ref
710 print '<td class="nowraponall"><div class="smallheight" title="'.dolPrintHTMLForAttribute(price($total_ttc)).'">';
711 if (!empty($block->ref_object)) {
712 print dolPrintHTML($block->ref_object);
713 if ($block->linktype && $block->linktoref) {
714 if ($block->linktype == 'payment') {
715 print '<br><span class="opacitymedium small">'.$langs->trans("PaymentOf").' '.$block->linktoref.'</span>';
716 }
717 if ($block->linktype == 'replacedby') {
718 print '<br><span class="opacitymedium small">'.$langs->trans("ReplacedBy").' '.$block->linktoref.'</span>';
719 }
720 if ($block->linktype == 'credit_note_of') {
721 print '<br><span class="opacitymedium small">'.$langs->trans("CreditNoteOf").' '.$block->linktoref.'</span>';
722 }
723 }
724 } else {
725 // Ref not stored
726 }
727 print '</div></td>';
728
729 // Payment mode
730 //print '<td>'.dolPrintHTML($block->type_code).'</td>';
731
732 // Amount
733 print '<td class="right nowraponall"><span class="amount">';
734 if (!in_array($block->action, array('BLOCKEDLOG_EXPORT', 'CASHCONTROL_CLOSE', 'MODULE_SET', 'MODULE_RESET'))) {
735 $showamount = in_array($block->action, array('BILL_VALIDATE', 'PAYMENT_CUSTOMER_CREATE', 'PAYMENT_CUSTOMER_DELETE'));
736 if ($showamount) {
737 print price($total_ttc);
738 }
739 }
740 print '</span></td>';
741
742 // Details link
743 print '<td class="center"><a href="#" data-blockid="'.$block->id.'" rel="show-info">'.img_picto($langs->trans('ShowDetails'), 'note', 'class="size15x"').'</span></td>';
744
745 // Fingerprint
746 print '<td class="nowraponall">';
747 // 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.
748 $texttoshow = $langs->trans("Fingerprint").' - '.$langs->trans("SavedOnLine").' =<br>'.$block->signature;
749 $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'];
750 $texttoshow .= '<br><span class="opacitymedium">'.$langs->trans("PreviousHash").'='.$checkdetail[$block->id]['previoushash'].'</span>';
751 $texttoshow .= '<br><span class="opacitymedium">'.$langs->trans("SecretKey").'=Not available from interface</span>';
752 //$texttoshow .= '<br>keyforsignature='.$checkdetail[$block->id]['keyforsignature'];
753 print $form->textwithpicto(dol_trunc($block->signature, 8), $texttoshow, 1, 'help', '', 0, 2, 'fingerprint'.$block->id);
754 print '</td>';
755
756 // Status
757 print '<td class="center">';
758 if (!$checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) { // If error
759 if ($checkresult[$block->id]) {
760 //print '<span class="badge badge-status4 badge-status" title="'.dolPrintHTMLForAttribute($langs->trans('OkCheckFingerprintValidityButChainIsKo')).'">'.$langs->trans("StatusValid").'</span>';
761 print '<span class="badge badge-status4 badge-status" title="'.dolPrintHTMLForAttribute($langs->trans('OkCheckFingerprintValidity')).'">'.$langs->trans("StatusValid").'</span>';
762 } elseif ($block->action == 'MODULE_RESET') {
763 // Old action code on old version.
764 print '<span class="badge badge-status8 badge-status" title="'.dolPrintHTMLForAttribute('Module has been disabled').'">OK</span>';
765 } else {
766 print '<span class="badge badge-status8 badge-status" title="';
767 if (!empty($checkerror[$block->id])) {
768 print dolPrintHTMLForAttribute($checkerror[$block->id])."\n";
769 }
770 $alt = $langs->trans('KoCheckFingerprintValidity');
771 if ($block->note) {
772 $notetoshow = $block->note;
773 $notetoshow = str_replace('EndOfChainDeletionDetected', $langs->trans("EndOfChainDeletionDetected"), $notetoshow);
774 $alt .= "\n".' '.$langs->trans("AddtionalInformation").': '.$notetoshow;
775 }
776
777 print dolPrintHTMLForAttribute($alt).'">KO</span>';
778 }
779 } else {
780 print '<span class="badge badge-status4 badge-status" title="'.$langs->trans('OkCheckFingerprintValidity').'">'.$langs->trans("StatusValid").'</span>';
781 }
782
783 // Add debug information
784 if (!$checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) { // If error
785 if ($checkresult[$block->id]) {
786 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) {
787 print $form->textwithpicto('', $langs->trans('OkCheckFingerprintValidityButChainIsKo'));
788 }
789 }
790 }
791 print '</td>';
792
793 // Link to debug information object
794 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
795 print '<td class="nowraponall">';
796 print '<!-- version -->'; // $object_link can be a '<a href' link or a text
797 print '<span class="small">'.$block->object_version. '<br>'.$block->object_format.'</span>';
798 print '</td>';
799
800 print '<td class="tdoverflowmax150"'.(preg_match('/<a/', $object_link) ? '' : 'title="'.dol_escape_htmltag(dol_string_nohtmltag($object_link.($object_link_title ? ' - '.$object_link_title : ''))).'"').'>';
801 print '<!-- object_link -->'; // $object_link can be a '<a href' link or a text with more information
802 print $object_link;
803 print '</td>';
804 }
805
806 // Action column
807 if (!$conf->main_checkbox_left_column) {
808 print '<td class="liste_titre">';
809 print '</td>';
810 }
811
812 print '</tr>';
813 }
814 }
815
816 // Define which source we want to show
817 $showtotalfor = array();
818 foreach ($totalamount as $key => $totalamountofcodepersource) {
819 if ($key == 'BILL_VALIDATE' || $key == 'PAYMENT_CUSTOMER') {
820 foreach ($totalamountofcodepersource as $source => $tmpval) {
821 $showtotalfor[$source] = 1;
822 // If we found one entry for the source, we make sure we have both BILL_VALIDATE and PAYMENT_CUSTOMER for this source
823 if (empty($totalamount['BILL_VALIDATE'][$source])) {
824 $totalamount['BILL_VALIDATE'][$source] = 0;
825 }
826 if (empty($totalamount['PAYMENT_CUSTOMER'][$source])) {
827 $totalamount['PAYMENT_CUSTOMER'][$source] = 0;
828 }
829 if (empty($totalhtamount['BILL_VALIDATE'][$source])) {
830 $totalhtamount['BILL_VALIDATE'][$source] = 0;
831 }
832 if (empty($totalhtamount['PAYMENT_CUSTOMER'][$source])) {
833 $totalhtamount['PAYMENT_CUSTOMER'][$source] = 0;
834 }
835 if (empty($totalvatamount['BILL_VALIDATE'][$source])) {
836 $totalvatamount['BILL_VALIDATE'][$source] = 0;
837 }
838 if (empty($totalvatamount['PAYMENT_CUSTOMER'][$source])) {
839 $totalvatamount['PAYMENT_CUSTOMER'][$source] = 0;
840 }
841 }
842 }
843 }
844
845 // Show total lines
846 if ($nbshown == 0) {
847 print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
848 } else {
849 ksort($totalamount);
850 krsort($showtotalfor);
851
852 // Show the total for period if filters are ok
853 $afilterexists = ($search_id || ($search_fk_user > 0) || $search_ref || $search_amount || $search_signature);
854
855 $countsource = 0;
856 foreach ($showtotalfor as $source => $tmpval) {
857 $countsource++;
858
859 // Line of title for total for period for $source
860 print '<tr class="liste_titre totalblockedlog">';
861 print '<td colspan="'.$colspan.'"';
862 if ($countsource == 1) {
863 print ' style="border-top: 1px solid #000;"';
864 }
865 print '>';
866 print $langs->trans("TotalForThePeriod");
867 print ' - '.($source ? ($source == 'takepos' ? $langs->trans("PointOfSale").' ' : '').ucfirst($source) : $langs->trans("BackOffice"));
868 print ' <span class="opacitylow">(';
869 if ($afilterexists) {
870 print img_picto($langs->trans("ForPeriodAndFilters"), 'warning', 'class="pictofixedwidth"');
871 }
872 print $langs->trans("ForPeriodAndFilters").')</span>';
873 print '</td>';
874 print '</tr>';
875
876 foreach ($totalamount as $actioncode => $totalamountofcodepersource) {
877 if ($actioncode == 'BILL_VALIDATE' && (!empty($search_code) && !in_array('BILL_VALIDATE', $search_code))) {
878 continue;
879 }
880 if ($actioncode == 'PAYMENT_CUSTOMER' && (!empty($search_code) && !in_array('PAYMENT_CUSTOMER', $search_code))) {
881 continue;
882 }
883
884 // Total
885 print '<tr class="liste_total totalblockedlog">';
886
887 // Action column
888 if ($conf->main_checkbox_left_column) {
889 print '<td>';
890 print '</td>';
891 }
892
893 // ID
894 print '<td colspan="4">';
895 $s = $actioncode;
896 if ($actioncode == 'BILL_VALIDATE') {
897 $s = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("Turnover");
898 } elseif ($actioncode == 'PAYMENT_CUSTOMER') {
899 $s = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("TurnoverCollected");
900 }
901 print $form->textwithpicto($s, $langs->trans("TotalForAction").' '.$langs->trans('log'.$actioncode));
902 print '</td>';
903
904 // Action
905 print '<td></td>';
906
907 // Amount (HT)
908 print '<td class="right nowraponall" colspan="3">';
909 if ($actioncode == 'BILL_VALIDATE') {
910 print '<span class="amount">'.price($totalhtamount[$actioncode][$source]).'</span>';
911 print ' '.$langs->trans("HT");
912
913 print ' - ';
914
915 print '<span class="amount">'.price($totalvatamount[$actioncode][$source]).'</span>';
916 print ' '.$langs->trans("VAT");
917
918 print ' - ';
919 }
920
921 print '<span class="amount">'.price($totalamount[$actioncode][$source]).'</span>';
922 if ($actioncode == 'BILL_VALIDATE') {
923 print ' '.$langs->trans("TTC");
924 }
925 print '</td>';
926
927 // Details link
928 print '<td class="center"></td>';
929
930 // Fingerprint
931 print '<td class="nowraponall">';
932 print '</td>';
933
934 // Status
935 print '<td class="center">';
936 print '</td>';
937
938 // Link to debug information object
939 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
940 print '<td></td>';
941
942 print '<td class="tdoverflowmax150"'.(preg_match('/<a/', $object_link) ? '' : 'title="'.dol_escape_htmltag(dol_string_nohtmltag($object_link.($object_link_title ? ' - '.$object_link_title : ''))).'"').'>';
943 print '</td>';
944 }
945
946 // Action column
947 if (!$conf->main_checkbox_left_column) {
948 print '<td class="liste_titre">';
949 print '</td>';
950 }
951
952 print '</tr>';
953 }
954 }
955
956 // Show total for lifetime
957 $countsource = 0;
958 foreach ($showtotalfor as $source => $tmpval) {
959 $countsource++;
960
961 if (empty($search_end) || $search_end == -1) {
962 $search_end = dol_now();
963 }
964
965 // Get lifetime amount of all invoices validated and payments created/deleted.
966 // We do not use $totalamountalllines because it is only for the period, but we want lifetime amount since the first record to now.
967
968 $totalamountlifetime = array('BILL_VALIDATE' => array(), 'PAYMENT_CUSTOMER_CREATE' => array(), 'PAYMENT_CUSTOMER_DELETE' => array());
969 $totalhtamountlifetime = array('BILL_VALIDATE' => array(), 'PAYMENT_CUSTOMER_CREATE' => array(), 'PAYMENT_CUSTOMER_DELETE' => array());
970
971 $foundoldformat = 0;
972 $firstrecorddate = 0;
973 global $foundoldformat, $firstrecorddate;
974 include DOL_DOCUMENT_ROOT.'/blockedlog/admin/lifetimeamount.inc.php';
975 '@phan-var-force array<string,array<string,float>> $totalamountlifetime';
976 '@phan-var-force array<string,array<string,float>> $totalhtamountlifetime';
977
978 print '<tr class="liste_titre totalblockedlog" style="border-top: 1px solid #222">';
979 print '<td colspan="'.$colspan.'"';
980 if ($countsource == 1) {
981 print ' style="border-top: 1px solid #000;"';
982 }
983 print '>';
984
985 print $langs->trans("TotalForLifetime");
986 print ' - '.($source ? ($source == 'takepos' ? $langs->trans("PointOfSale").' ' : '').ucfirst($source) : $langs->trans("BackOffice"));
987
988 print ' <span class="opacitymedium">('.dol_print_date($firstrecorddate, 'dayhour', 'tzuserrel');
989 if (GETPOST('search_endyear') && $search_end && $search_end != -1) {
990 print ' - '.dol_print_date($search_end, 'dayhoursec', 'tzuserrel');
991 } else {
992 print ' - '.$langs->trans("Now");
993 }
994 print ')</span>';
995 print '</td>';
996 print '</tr>';
997
998 // Lifetime amount of invoices validated
999 if (empty($search_code) || in_array('BILL_VALIDATE', $search_code)) {
1000 // Total
1001 print '<tr class="liste_total totalblockedlog">';
1002
1003 // Action column
1004 if ($conf->main_checkbox_left_column) {
1005 print '<td></td>';
1006 }
1007
1008 // ID
1009 print '<td colspan="4">';
1010
1011 $s = img_picto('', 'bill', 'class="pictofixedwidth"').$langs->trans("Turnover");
1012 print $form->textwithpicto($s, $langs->trans("TotalForAction").' '.$langs->trans('logBILL_VALIDATE'));
1013
1014 print ' &nbsp; ';
1015
1016 // If there is at least one record with old format
1017 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog WHERE object_format < 'V2' and action = 'BILL_VALIDATE' LIMIT 1";
1018 $resql = $db->query($sql);
1019 $obj = $db->fetch_object($resql);
1020 if ($obj) {
1021 $foundav1 = 1;
1022 if ($includebeforev2) {
1023 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>';
1024 } else {
1025 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>';
1026 }
1027 }
1028 print '</td>';
1029
1030 // Action
1031 print '<td></td>';
1032
1033 // Amount (HT)
1034 print '<td class="right nowraponall" colspan="3">';
1035 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");
1036 print '</td>';
1037
1038 // Details link
1039 print '<td class="center"></td>';
1040
1041 // Fingerprint
1042 print '<td class="nowraponall"></td>';
1043
1044 // Status
1045 print '<td class="center"></td>';
1046
1047 // Link to debug information object
1048 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
1049 print '<td>';
1050 print '</td>';
1051
1052 print '<td class="tdoverflowmax150"'.(preg_match('/<a/', $object_link) ? '' : 'title="'.dol_escape_htmltag(dol_string_nohtmltag($object_link.($object_link_title ? ' - '.$object_link_title : ''))).'"').'>';
1053 print '</td>';
1054 }
1055
1056 // Action column
1057 if (!$conf->main_checkbox_left_column) {
1058 print '<td class="liste_titre"></td>';
1059 }
1060
1061 print '</tr>';
1062 }
1063
1064 // Lifetime amount for payments
1065 if (empty($search_code)
1066 || in_array('PAYMENT_CUSTOMER', $search_code) // Filter for both PAYMENT_CUSTOMER_CREATE and PAYMENT_CUSTOMER_DELETE
1067 || in_array('PAYMENT_CUSTOMER_CREATE', $search_code)
1068 || in_array('PAYMENT_CUSTOMER_DELETE', $search_code)) {
1069 // Total
1070 print '<tr class="liste_total totalblockedlog">';
1071
1072 // Action column
1073 if ($conf->main_checkbox_left_column) {
1074 print '<td></td>';
1075 }
1076
1077 // ID
1078 print '<td colspan="4">';
1079
1080 $s = img_picto('', 'payment', 'class="pictofixedwidth"').$langs->trans("TurnoverCollected");
1081 print $form->textwithpicto($s, $langs->trans("TotalForAction").' '.$langs->trans('logPAYMENT_CUSTOMER'));
1082
1083 print '</td>';
1084
1085 // Action
1086 print '<td></td>';
1087
1088 // Amount (HT)
1089 print '<td class="right nowraponall" colspan="3">';
1090 print '<span class="amount">'.price((float) $totalamountlifetime['PAYMENT_CUSTOMER_CREATE'][$source] + (float) $totalamountlifetime['PAYMENT_CUSTOMER_DELETE'][$source]).'</span>';
1091 print '</td>';
1092
1093 // Details link
1094 print '<td class="center"></td>';
1095
1096 // Fingerprint
1097 print '<td class="nowraponall"></td>';
1098
1099 // Status
1100 print '<td class="center"></td>';
1101
1102 // Link to debug information object
1103 if (getDolGlobalString("BLOCKEDLOG_DEBUG")) { // If in experimental or develop mode, we add some debug information. It may help developers to find origin of bugs.
1104 print '<td>';
1105 print '</td>';
1106
1107 print '<td class="tdoverflowmax150"'.(preg_match('/<a/', $object_link) ? '' : 'title="'.dol_escape_htmltag(dol_string_nohtmltag($object_link.($object_link_title ? ' - '.$object_link_title : ''))).'"').'>';
1108 print '</td>';
1109 }
1110
1111 // Action column
1112 if (!$conf->main_checkbox_left_column) {
1113 print '<td class="liste_titre"></td>';
1114 }
1115
1116 print '</tr>';
1117 }
1118 }
1119 }
1120}
1121
1122print '</table>';
1123
1124print '</div>';
1125
1126print '</form>';
1127
1128// Javascript to manage the showinfo popup
1129print '<script type="text/javascript">
1130
1131jQuery(document).ready(function () {
1132 jQuery("#dialogforpopup").dialog({
1133 closeOnEscape: true,
1134 classes: { "ui-dialog": "highlight" },
1135 maxHeight: window.innerHeight-60,
1136 height: window.innerHeight-60,
1137 width: '.($conf->browser->layout == 'phone' ? 400 : 700).',
1138 modal: true,
1139 autoOpen: false
1140 }).css("z-index: 5000");
1141
1142 $("a[rel=show-info]").click(function() {
1143 console.log("We click on tooltip a[rel=show-info], we open popup and get content using an ajax call");
1144
1145 var fk_block = $(this).attr("data-blockid");
1146
1147 $.ajax({
1148 method: "GET",
1149 data: { token: \''.currentToken().'\' },
1150 url: "'.DOL_URL_ROOT.'/blockedlog/ajax/block-info.php?id="+fk_block,
1151 dataType: "html"
1152 }).done(function(data) {
1153 jQuery("#dialogforpopup").html(data);
1154 });
1155
1156 var mydialog = jQuery("#dialogforpopup");
1157 mydialog.dialog({autoOpen: false, modal: true, height: (window.innerHeight - 150), width: \'80%\', title: \''.dol_escape_js($langs->transnoentitiesnoconv("UnlaterableDataOfEvent")).'\',});
1158 mydialog.dialog("open");
1159 return false;
1160 });
1161})
1162</script>'."\n";
1163
1164
1165/*
1166if (getDolGlobalString('BLOCKEDLOG_USE_REMOTE_AUTHORITY') && getDolGlobalString('BLOCKEDLOG_AUTHORITY_URL')) {
1167 ?>
1168 <script type="text/javascript">
1169
1170 $.ajax({
1171 method: "GET",
1172 data: { token: '<?php echo currentToken() ?>' },
1173 url: '<?php echo DOL_URL_ROOT.'/blockedlog/ajax/check_signature.php' ?>',
1174 dataType: 'html'
1175 }).done(function(data) {
1176 if(data == 'hashisok') {
1177 $('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity').' '.img_picto($langs->trans('SignatureOK'), 'on') ?>');
1178 }
1179 else{
1180 $('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity').' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
1181 }
1182
1183 });
1184
1185 </script>
1186 <?php
1187}
1188*/
1189
1190print dol_get_fiche_end();
1191
1192print '<br><br>';
1193
1194// End of page
1195llxFooter();
1196$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.
currentToken()
Return the value of token currently saved into session with name 'token'.
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.