dolibarr  13.0.2
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 Frédéric France <frederic.france@netlogic.fr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
32 
33 // Load translation files required by the page
34 $langs->loadLangs(array("admin", "other", "blockedlog", "bills"));
35 
36 if ((!$user->admin && !$user->rights->blockedlog->read) || empty($conf->blockedlog->enabled)) accessforbidden();
37 
38 $action = GETPOST('action', 'aZ09');
39 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'blockedloglist'; // To manage different context of search
40 $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page
41 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
42 
43 $search_showonlyerrors = GETPOST('search_showonlyerrors', 'int');
44 if ($search_showonlyerrors < 0) $search_showonlyerrors = 0;
45 
46 $search_fk_user = GETPOST('search_fk_user', 'intcomma');
47 $search_start = -1;
48 if (GETPOST('search_startyear') != '') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear'));
49 $search_end = -1;
50 if (GETPOST('search_endyear') != '') $search_end = dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear'));
51 $search_code = GETPOST('search_code', 'alpha');
52 $search_ref = GETPOST('search_ref', 'alpha');
53 $search_amount = GETPOST('search_amount', 'alpha');
54 
55 if (($search_start == -1 || empty($search_start)) && !GETPOSTISSET('search_startmonth')) $search_start = dol_time_plus_duree(dol_now(), '-1', 'w');
56 
57 // Load variable for pagination
58 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
59 $sortfield = GETPOST('sortfield', 'aZ09comma');
60 $sortorder = GETPOST('sortorder', 'aZ09comma');
61 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
62 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
63 $offset = $limit * $page;
64 $pageprev = $page - 1;
65 $pagenext = $page + 1;
66 
67 if (empty($sortfield)) $sortfield = 'rowid';
68 if (empty($sortorder)) $sortorder = 'DESC';
69 
70 $block_static = new BlockedLog($db);
71 
72 
73 $result = restrictedArea($user, 'blockedlog', 0, '');
74 
75 
76 /*
77  * Actions
78  */
79 
80 // Purge search criteria
81 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
82 {
83  $search_fk_user = '';
84  $search_start = -1;
85  $search_end = -1;
86  $search_code = '';
87  $search_ref = '';
88  $search_amount = '';
89  $search_showonlyerrors = 0;
90  $toselect = '';
91  $search_array_options = array();
92 }
93 
94 if ($action === 'downloadblockchain') {
95  $auth = new BlockedLogAuthority($db);
96 
97  $bc = $auth->getLocalBlockChain();
98 
99  header('Content-Type: application/octet-stream');
100  header("Content-Transfer-Encoding: Binary");
101  header("Content-disposition: attachment; filename=\"".$auth->signature.".certif\"");
102 
103  echo $bc;
104 
105  exit;
106 } elseif (GETPOST('downloadcsv', 'alpha')) {
107  $error = 0;
108 
109  $previoushash = '';
110  $firstid = '';
111 
112  if (!$error)
113  {
114  // Get ID of first line
115  $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
116  $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog";
117  $sql .= " WHERE entity = ".$conf->entity;
118  if (GETPOST('monthtoexport', 'int') > 0 || GETPOST('yeartoexport', 'int') > 0)
119  {
120  $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 1);
121  $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 12);
122  $sql .= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
123  }
124  $sql .= " ORDER BY rowid ASC"; // Required so we get the first one
125  $sql .= $db->plimit(1);
126 
127  $res = $db->query($sql);
128  if ($res)
129  {
130  // Make the first fetch to get first line
131  $obj = $db->fetch_object($res);
132  if ($obj)
133  {
134  $previoushash = $block_static->getPreviousHash(0, $obj->rowid);
135  $firstid = $obj->rowid;
136  } else { // If not data found for filter, we do not need previoushash neither firstid
137  $previoushash = 'nodata';
138  $firstid = '';
139  }
140  } else {
141  $error++;
142  setEventMessages($db->lasterror, null, 'errors');
143  }
144  }
145 
146  if (!$error)
147  {
148  // Now restart request with all data = no limit(1) in sql request
149  $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
150  $sql .= " FROM ".MAIN_DB_PREFIX."blockedlog";
151  $sql .= " WHERE entity = ".$conf->entity;
152  if (GETPOST('monthtoexport', 'int') > 0 || GETPOST('yeartoexport', 'int') > 0)
153  {
154  $dates = dol_get_first_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 1);
155  $datee = dol_get_last_day(GETPOST('yeartoexport', 'int'), GETPOST('monthtoexport', 'int') ?GETPOST('monthtoexport', 'int') : 12);
156  $sql .= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
157  }
158  $sql .= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature()
159 
160  $res = $db->query($sql);
161  if ($res)
162  {
163  header('Content-Type: application/octet-stream');
164  header("Content-Transfer-Encoding: Binary");
165  header("Content-disposition: attachment; filename=\"unalterable-log-archive-".$dolibarr_main_db_name."-".(GETPOST('yeartoexport', 'int') > 0 ? GETPOST('yeartoexport', 'int').(GETPOST('monthtoexport', 'int') > 0 ?sprintf("%02d", GETPOST('monthtoexport', 'int')) : '').'-' : '').$previoushash.".csv\"");
166 
167  print $langs->transnoentities('Id')
168  .';'.$langs->transnoentities('Date')
169  .';'.$langs->transnoentities('User')
170  .';'.$langs->transnoentities('Action')
171  .';'.$langs->transnoentities('Element')
172  .';'.$langs->transnoentities('Amounts')
173  .';'.$langs->transnoentities('ObjectId')
174  .';'.$langs->transnoentities('Date')
175  .';'.$langs->transnoentities('Ref')
176  .';'.$langs->transnoentities('Fingerprint')
177  .';'.$langs->transnoentities('Status')
178  .';'.$langs->transnoentities('Note')
179  .';'.$langs->transnoentities('FullData')
180  ."\n";
181 
182  $loweridinerror = 0;
183  $i = 0;
184 
185  while ($obj = $db->fetch_object($res))
186  {
187  // We set here all data used into signature calculation (see checkSignature method) and more
188  // IMPORTANT: We must have here, the same rule for transformation of data than into the fetch method (db->jdate for date, ...)
189  $block_static->id = $obj->rowid;
190  $block_static->date_creation = $db->jdate($obj->date_creation);
191  $block_static->date_modification = $db->jdate($obj->tms);
192  $block_static->action = $obj->action;
193  $block_static->fk_object = $obj->fk_object;
194  $block_static->element = $obj->element;
195  $block_static->amounts = (double) $obj->amounts;
196  $block_static->ref_object = $obj->ref_object;
197  $block_static->date_object = $db->jdate($obj->date_object);
198  $block_static->user_fullname = $obj->user_fullname;
199  $block_static->fk_user = $obj->fk_user;
200  $block_static->signature = $obj->signature;
201  $block_static->object_data = $block_static->dolDecodeBlockedData($obj->object_data);
202 
203  $checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it
204 
205  if ($checksignature)
206  {
207  $statusofrecord = 'Valid';
208  if ($loweridinerror > 0) $statusofrecordnote = 'ValidButFoundAPreviousKO';
209  else $statusofrecordnote = '';
210  } else {
211  $statusofrecord = 'KO';
212  $statusofrecordnote = 'LineCorruptedOrNotMatchingPreviousOne';
213  $loweridinerror = $obj->rowid;
214  }
215 
216  if ($i == 0)
217  {
218  $statusofrecordnote = $langs->trans("PreviousFingerprint").': '.$previoushash.($statusofrecordnote ? ' - '.$statusofrecordnote : '');
219  }
220  print $obj->rowid;
221  print ';'.$obj->date_creation;
222  print ';"'.str_replace('"', '""', $obj->user_fullname).'"';
223  print ';'.$obj->action;
224  print ';'.$obj->element;
225  print ';'.$obj->amounts;
226  print ';'.$obj->fk_object;
227  print ';'.$obj->date_object;
228  print ';"'.str_replace('"', '""', $obj->ref_object).'"';
229  print ';'.$obj->signature;
230  print ';'.$statusofrecord;
231  print ';'.$statusofrecordnote;
232  print ';"'.str_replace('"', '""', $obj->object_data).'"';
233  print "\n";
234 
235  // Set new previous hash for next fetch
236  $previoushash = $obj->signature;
237 
238  $i++;
239  }
240 
241  exit;
242  } else {
243  setEventMessages($db->lasterror, null, 'errors');
244  }
245  }
246 }
247 
248 
249 /*
250  * View
251  */
252 
253 $form = new Form($db);
254 
255 if (GETPOST('withtab', 'alpha'))
256 {
257  $title = $langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog');
258 } else {
259  $title = $langs->trans("BrowseBlockedLog");
260 }
261 
262 llxHeader('', $langs->trans("BrowseBlockedLog"));
263 
264 $MAXLINES = 10000;
265 
266 $blocks = $block_static->getLog('all', 0, $MAXLINES, $sortfield, $sortorder, $search_fk_user, $search_start, $search_end, $search_ref, $search_amount, $search_code);
267 if (!is_array($blocks))
268 {
269  if ($blocks == -2)
270  {
271  setEventMessages($langs->trans("TooManyRecordToScanRestrictFilters", $MAXLINES), null, 'errors');
272  } else {
273  dol_print_error($block_static->db, $block_static->error, $block_static->errors);
274  exit;
275  }
276 }
277 
278 $linkback = '';
279 if (GETPOST('withtab', 'alpha'))
280 {
281  $linkback = '<a href="'.($backtopage ? $backtopage : DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
282 }
283 
284 print load_fiche_titre($title, $linkback);
285 
286 if (GETPOST('withtab', 'alpha'))
287 {
289  print dol_get_fiche_head($head, 'fingerprints', '', -1);
290 }
291 
292 print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("FingerprintsDesc")."<br></span>\n";
293 
294 print '<br>';
295 
296 $param = '';
297 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
298 if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
299 if ($search_fk_user > 0) $param .= '&search_fk_user='.urlencode($search_fk_user);
300 if ($search_startyear > 0) $param .= '&search_startyear='.urlencode(GETPOST('search_startyear', 'int'));
301 if ($search_startmonth > 0) $param .= '&search_startmonth='.urlencode(GETPOST('search_startmonth', 'int'));
302 if ($search_startday > 0) $param .= '&search_startday='.urlencode(GETPOST('search_startday', 'int'));
303 if ($search_endyear > 0) $param .= '&search_endyear='.urlencode(GETPOST('search_endyear', 'int'));
304 if ($search_endmonth > 0) $param .= '&search_endmonth='.urlencode(GETPOST('search_endmonth', 'int'));
305 if ($search_endday > 0) $param .= '&search_endday='.urlencode(GETPOST('search_endday', 'int'));
306 if ($search_showonlyerrors > 0) $param .= '&search_showonlyerrors='.urlencode($search_showonlyerrors);
307 if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
308 if (GETPOST('withtab', 'alpha')) $param .= '&withtab='.urlencode(GETPOST('withtab', 'alpha'));
309 
310 // Add $param from extra fields
311 //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
312 
313 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
314 print '<input type="hidden" name="token" value="'.newToken().'">';
315 
316 print '<div class="right">';
317 print $langs->trans("RestrictYearToExport").': ';
318 $smonth = GETPOST('monthtoexport', 'int');
319 // Month
320 $retstring = '';
321 $retstring .= '<select class="flat valignmiddle maxwidth75imp marginrightonly" id="monthtoexport" name="monthtoexport">';
322 $retstring .= '<option value="0" selected>&nbsp;</option>';
323 for ($month = 1; $month <= 12; $month++)
324 {
325  $retstring .= '<option value="'.$month.'"'.($month == $smonth ? ' selected' : '').'>';
326  $retstring .= dol_print_date(mktime(12, 0, 0, $month, 1, 2000), "%b");
327  $retstring .= "</option>";
328 }
329 $retstring .= "</select>";
330 print $retstring;
331 print '<input type="text" name="yeartoexport" class="valignmiddle maxwidth50imp" value="'.GETPOST('yeartoexport', 'int').'">';
332 print '<input type="hidden" name="withtab" value="'.GETPOST('withtab', 'alpha').'">';
333 print '<input type="submit" name="downloadcsv" class="button" value="'.$langs->trans('DownloadLogCSV').'">';
334 if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | <a href="?action=downloadblockchain'.(GETPOST('withtab', 'alpha') ? '&withtab='.GETPOST('withtab', 'alpha') : '').'">'.$langs->trans('DownloadBlockChain').'</a>';
335 print ' </div><br>';
336 
337 print '</form>';
338 
339 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
340 
341 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
342 
343 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
344 print '<input type="hidden" name="token" value="'.newToken().'">';
345 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
346 print '<input type="hidden" name="action" value="list">';
347 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
348 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
349 print '<input type="hidden" name="page" value="'.$page.'">';
350 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
351 print '<input type="hidden" name="withtab" value="'.GETPOST('withtab', 'alpha').'">';
352 
353 print '<table class="noborder centpercent">';
354 
355 // Line of filters
356 print '<tr class="liste_titre_filter">';
357 
358 print '<td class="liste_titre">&nbsp;</td>';
359 
360 print '<td class="liste_titre">';
361 //print $langs->trans("from").': ';
362 print $form->selectDate($search_start, 'search_start');
363 //print '<br>';
364 //print $langs->trans("to").': ';
365 print $form->selectDate($search_end, 'search_end');
366 print '</td>';
367 
368 // User
369 print '<td class="liste_titre">';
370 print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
371 
372 print '</td>';
373 
374 // Actions code
375 $langs->load("blockedlog");
376 print '<td class="liste_titre">';
377 print $form->selectarray('search_code', $block_static->trackedevents, $search_code, 1, 0, 0, '', 1, 0, 0, 'ASC', 'maxwidth200', 1);
378 print '</td>';
379 
380 // Ref
381 print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
382 
383 // Link to ref
384 print '<td class="liste_titre"></td>';
385 
386 // Amount
387 print '<td class="liste_titre right"><input type="text" class="maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
388 
389 // Full data
390 print '<td class="liste_titre"></td>';
391 
392 // Fingerprint
393 print '<td class="liste_titre"></td>';
394 
395 // Status
396 print '<td class="liste_titre">';
397 $array = array("1"=>$langs->trans("OnlyNonValid"));
398 print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1);
399 print '</td>';
400 
401 // Status note
402 print '<td class="liste_titre"></td>';
403 
404 // Action column
405 print '<td class="liste_titre" align="middle">';
406 $searchpicto = $form->showFilterButtons();
407 print $searchpicto;
408 print '</td>';
409 
410 print '</tr>';
411 
412 print '<tr class="liste_titre">';
413 print getTitleFieldOfList($langs->trans('#'), 0, $_SERVER["PHP_SELF"], 'rowid', '', $param, '', $sortfield, $sortorder, 'minwidth50 ')."\n";
414 print getTitleFieldOfList($langs->trans('Date'), 0, $_SERVER["PHP_SELF"], 'date_creation', '', $param, '', $sortfield, $sortorder, '')."\n";
415 print getTitleFieldOfList($langs->trans('Author'), 0, $_SERVER["PHP_SELF"], 'user_fullname', '', $param, '', $sortfield, $sortorder, '')."\n";
416 print getTitleFieldOfList($langs->trans('Action'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
417 print getTitleFieldOfList($langs->trans('Ref'), 0, $_SERVER["PHP_SELF"], 'ref_object', '', $param, '', $sortfield, $sortorder, '')."\n";
418 print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
419 print getTitleFieldOfList($langs->trans('Amount'), 0, $_SERVER["PHP_SELF"], '', '', $param, 'class="right"', $sortfield, $sortorder, '')."\n";
420 print getTitleFieldOfList($langs->trans('DataOfArchivedEvent'), 0, $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder, '')."\n";
421 print getTitleFieldOfList($langs->trans('Fingerprint'), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, '')."\n";
422 print getTitleFieldOfList($langs->trans('Status'), 0, $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder, '')."\n";
423 print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder, '')."\n";
424 print getTitleFieldOfList('<span id="blockchainstatus"></span>', 0, $_SERVER["PHP_SELF"], '', '', $param, 'align="center"', $sortfield, $sortorder, '')."\n";
425 print '</tr>';
426 
427 if (!empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR)) {
428  // This is version that is faster but require more memory and report errors that are outside the filter range
429 
430  // TODO Make a full scan of table in reverse order of id of $block, so we can use the parameter $previoushash into checkSignature to save requests
431  // to find the $loweridinerror.
432 } else {
433  // This is version that optimize the memory (but will not report errors that are outside the filter range)
434  $loweridinerror = 0;
435  $checkresult = array();
436  if (is_array($blocks))
437  {
438  foreach ($blocks as &$block)
439  {
440  $checksignature = $block->checkSignature(); // Note: this make a sql request at each call, we can't avoid this as the sorting order is various
441  $checkresult[$block->id] = $checksignature; // false if error
442  if (!$checksignature)
443  {
444  if (empty($loweridinerror)) $loweridinerror = $block->id;
445  else $loweridinerror = min($loweridinerror, $block->id);
446  }
447  }
448  }
449 }
450 
451 if (is_array($blocks))
452 {
453  foreach ($blocks as &$block)
454  {
455  $object_link = $block->getObjectLink();
456 
457  //if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
458  if (empty($search_showonlyerrors) || !$checkresult[$block->id])
459  {
460  print '<tr class="oddeven">';
461 
462  // ID
463  print '<td>'.$block->id.'</td>';
464 
465  // Date
466  print '<td>'.dol_print_date($block->date_creation, 'dayhour').'</td>';
467 
468  // User
469  print '<td>';
470  //print $block->getUser()
471  print $block->user_fullname;
472  print '</td>';
473 
474  // Action
475  print '<td>'.$langs->trans('log'.$block->action).'</td>';
476 
477  // Ref
478  print '<td class="nowrap">'.$block->ref_object.'</td>';
479 
480  // Link to source object
481  print '<td'.(preg_match('/<a/', $object_link) ? ' class="nowrap"' : '').'><!-- object_link -->'.$object_link.'</td>';
482 
483  // Amount
484  print '<td class="right nowraponall">'.price($block->amounts).'</td>';
485 
486  // Details link
487  print '<td align="center"><a href="#" data-blockid="'.$block->id.'" rel="show-info">'.img_info($langs->trans('ShowDetails')).'</a></td>';
488 
489  // Fingerprint
490  print '<td class="nowrap">';
491  print $form->textwithpicto(dol_trunc($block->signature, '8'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'.$block->id);
492  print '</td>';
493 
494  // Status
495  print '<td class="center">';
496  if (!$checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error
497  {
498  if ($checkresult[$block->id]) print img_picto($langs->trans('OkCheckFingerprintValidityButChainIsKo'), 'statut4');
499  else print img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8');
500  } else {
501  print img_picto($langs->trans('OkCheckFingerprintValidity'), 'statut4');
502  }
503 
504  print '</td>';
505 
506  // Note
507  print '<td class="center">';
508  if (!$checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error
509  {
510  if ($checkresult[$block->id]) print $form->textwithpicto('', $langs->trans('OkCheckFingerprintValidityButChainIsKo'));
511  }
512 
513  if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) {
514  print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black'));
515  }
516  print '</td>';
517 
518  print '<td></td>';
519 
520  print '</tr>';
521  }
522  }
523 }
524 
525 print '</table>';
526 
527 print '</div>';
528 
529 print '</form>';
530 
531 // Javascript to manage the showinfo popup
532 print '<script type="text/javascript">
533 
534 jQuery(document).ready(function () {
535  jQuery("#dialogforpopup").dialog(
536  { closeOnEscape: true, classes: { "ui-dialog": "highlight" },
537  maxHeight: window.innerHeight-60, height: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? 400 : 700).',
538  modal: true,
539  autoOpen: false }).css("z-index: 5000");
540 
541  $("a[rel=show-info]").click(function() {
542 
543  console.log("We click on tooltip, we open popup and get content using an ajax call");
544 
545  var fk_block = $(this).attr("data-blockid");
546 
547  $.ajax({
548  url:"../ajax/block-info.php?id="+fk_block
549  ,dataType:"html"
550  }).done(function(data) {
551  jQuery("#dialogforpopup").html(data);
552  });
553 
554  jQuery("#dialogforpopup").dialog("open");
555  });
556 })
557 </script>'."\n";
558 
559 
560 if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL))
561 {
562  ?>
563  <script type="text/javascript">
564 
565  $.ajax({
566  url : "<?php echo dol_buildpath('/blockedlog/ajax/check_signature.php', 1) ?>"
567  ,dataType:"html"
568  }).done(function(data) {
569 
570  if(data == 'hashisok') {
571  $('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity').' '.img_picto($langs->trans('SignatureOK'), 'on') ?>');
572  }
573  else{
574  $('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity').' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
575  }
576 
577  });
578 
579  </script>
580  <?php
581 }
582 
583 if (GETPOST('withtab', 'alpha'))
584 {
585  print dol_get_fiche_end();
586 }
587 
588 print '<br><br>';
589 
590 // End of page
591 llxFooter();
592 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm= 'auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_now($mode= 'auto')
Return date for now.
Class to manage certif authority.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:481
blockedlogadmin_prepare_head()
Define head array for tabs of blockedlog tools setup pages.
llxHeader()
Empty header.
Definition: wrapper.php:45
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
Class to manage Blocked Log.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=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 Calling this function terminate execution ...
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:498
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_info($titlealt= 'default')
Show info logo.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding &#39;...&#39; if string larger than length.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
llxFooter()
Empty footer.
Definition: wrapper.php:59
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
Definition: date.lib.php:114
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105