dolibarr  9.0.0
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 <http://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','alpha');
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','alpha');
60 $sortorder = GETPOST('sortorder','alpha');
61 $page = 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 
96  $auth = new BlockedLogAuthority($db);
97 
98  $bc = $auth->getLocalBlockChain();
99 
100  header('Content-Type: application/octet-stream');
101  header("Content-Transfer-Encoding: Binary");
102  header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\"");
103 
104  echo $bc;
105 
106  exit;
107 }
108 else if (GETPOST('downloadcsv','alpha'))
109 {
110  $error = 0;
111 
112  $previoushash='';
113  $firstid='';
114 
115  if (! $error)
116  {
117  // Get ID of first line
118  $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
119  $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
120  $sql.= " WHERE entity = ".$conf->entity;
121  if (GETPOST('monthtoexport','int') > 0 || GETPOST('yeartoexport','int') > 0)
122  {
123  $dates = dol_get_first_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):1);
124  $datee = dol_get_last_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):12);
125  $sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
126  }
127  $sql.= " ORDER BY rowid ASC"; // Required so we get the first one
128  $sql.= $db->plimit(1);
129 
130  $res = $db->query($sql);
131  if($res)
132  {
133  // Make the first fetch to get first line
134  $obj = $db->fetch_object($res);
135  if ($obj)
136  {
137  $previoushash = $block_static->getPreviousHash(0, $obj->rowid);
138  $firstid = $obj->rowid;
139  }
140  else
141  { // If not data found for filter, we do not need previoushash neither firstid
142  $previoushash = 'nodata';
143  $firstid = '';
144  }
145  }
146  else
147  {
148  $error++;
149  setEventMessages($db->lasterror, null, 'errors');
150  }
151  }
152 
153  if (! $error)
154  {
155  // Now restart request with all data = no limit(1) in sql request
156  $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
157  $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
158  $sql.= " WHERE entity = ".$conf->entity;
159  if (GETPOST('monthtoexport','int') > 0 || GETPOST('yeartoexport','int') > 0)
160  {
161  $dates = dol_get_first_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):1);
162  $datee = dol_get_last_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):12);
163  $sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
164  }
165  $sql.= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature()
166 
167  $res = $db->query($sql);
168  if($res)
169  {
170  header('Content-Type: application/octet-stream');
171  header("Content-Transfer-Encoding: Binary");
172  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\"");
173 
174  print $langs->transnoentities('Id')
175  .';'.$langs->transnoentities('Date')
176  .';'.$langs->transnoentities('User')
177  .';'.$langs->transnoentities('Action')
178  .';'.$langs->transnoentities('Element')
179  .';'.$langs->transnoentities('Amounts')
180  .';'.$langs->transnoentities('ObjectId')
181  .';'.$langs->transnoentities('Date')
182  .';'.$langs->transnoentities('Ref')
183  .';'.$langs->transnoentities('Fingerprint')
184  .';'.$langs->transnoentities('Status')
185  .';'.$langs->transnoentities('Note')
186  .';'.$langs->transnoentities('FullData')
187  ."\n";
188 
189  $loweridinerror = 0;
190  $i = 0;
191 
192  while ($obj = $db->fetch_object($res))
193  {
194  // We set here all data used into signature calculation (see checkSignature method) and more
195  // IMPORTANT: We must have here, the same rule for transformation of data than into the fetch method (db->jdate for date, ...)
196  $block_static->id = $obj->rowid;
197  $block_static->date_creation = $db->jdate($obj->date_creation);
198  $block_static->date_modification = $db->jdate($obj->tms);
199  $block_static->action = $obj->action;
200  $block_static->fk_object = $obj->fk_object;
201  $block_static->element = $obj->element;
202  $block_static->amounts = (double) $obj->amounts;
203  $block_static->ref_object = $obj->ref_object;
204  $block_static->date_object = $db->jdate($obj->date_object);
205  $block_static->user_fullname = $obj->user_fullname;
206  $block_static->fk_user = $obj->fk_user;
207  $block_static->signature = $obj->signature;
208  $block_static->object_data = $block_static->dolDecodeBlockedData($obj->object_data);
209 
210  $checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it
211 
212  if ($checksignature)
213  {
214  $statusofrecord = 'Valid';
215  if ($loweridinerror > 0) $statusofrecordnote = 'ValidButFoundAPreviousKO';
216  else $statusofrecordnote = '';
217  }
218  else
219  {
220  $statusofrecord = 'KO';
221  $statusofrecordnote = 'LineCorruptedOrNotMatchingPreviousOne';
222  $loweridinerror = $obj->rowid;
223  }
224 
225  if ($i==0)
226  {
227  $statusofrecordnote = $langs->trans("PreviousFingerprint").': '.$previoushash.($statusofrecordnote?' - '.$statusofrecordnote:'');
228  }
229  print $obj->rowid
230  .';'.$obj->date_creation
231  .';"'.$obj->user_fullname.'"'
232  .';'.$obj->action
233  .';'.$obj->element
234  .';'.$obj->amounts
235  .';'.$obj->fk_object
236  .';'.$obj->date_object
237  .';"'.$obj->ref_object.'"'
238  .';'.$obj->signature
239  .';'.$statusofrecord
240  .';'.$statusofrecordnote
241  .';"'.str_replace('"','""',$obj->object_data).'"'
242  ."\n";
243 
244  // Set new previous hash for next fetch
245  $previoushash = $obj->signature;
246 
247  $i++;
248  }
249 
250  exit;
251  }
252  else
253  {
254  setEventMessages($db->lasterror, null, 'errors');
255  }
256  }
257 }
258 
259 
260 /*
261  * View
262  */
263 
264 $form=new Form($db);
265 
266 if (GETPOST('withtab','alpha'))
267 {
268  $title=$langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog');
269 }
270 else
271 {
272  $title=$langs->trans("BrowseBlockedLog");
273 }
274 
275 llxHeader('',$langs->trans("BrowseBlockedLog"));
276 
277 $MAXLINES = 10000;
278 
279 $blocks = $block_static->getLog('all', 0, $MAXLINES, $sortfield, $sortorder, $search_fk_user, $search_start, $search_end, $search_ref, $search_amount, $search_code);
280 if (! is_array($blocks))
281 {
282  if ($blocks == -2)
283  {
284  setEventMessages($langs->trans("TooManyRecordToScanRestrictFilters", $MAXLINES), null, 'errors');
285  }
286  else
287  {
288  dol_print_error($block_static->db, $block_static->error, $block_static->errors);
289  exit;
290  }
291 }
292 
293 $linkback='';
294 if (GETPOST('withtab','alpha'))
295 {
296  $linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
297 }
298 
299 print load_fiche_titre($title, $linkback);
300 
301 if (GETPOST('withtab','alpha'))
302 {
304  dol_fiche_head($head, 'fingerprints', '', -1);
305 }
306 
307 print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("FingerprintsDesc")."<br></span>\n";
308 
309 print '<br>';
310 
311 $param='';
312 if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
313 if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
314 if ($search_fk_user > 0) $param.='&search_fk_user='.urlencode($search_fk_user);
315 if ($search_startyear > 0) $param.='&search_startyear='.urlencode(GETPOST('search_startyear','int'));
316 if ($search_startmonth > 0) $param.='&search_startmonth='.urlencode(GETPOST('search_startmonth','int'));
317 if ($search_startday > 0) $param.='&search_startday='.urlencode(GETPOST('search_startday','int'));
318 if ($search_endyear > 0) $param.='&search_endyear='.urlencode(GETPOST('search_endyear','int'));
319 if ($search_endmonth > 0) $param.='&search_endmonth='.urlencode(GETPOST('search_endmonth','int'));
320 if ($search_endday > 0) $param.='&search_endday='.urlencode(GETPOST('search_endday','int'));
321 if ($search_showonlyerrors > 0) $param.='&search_showonlyerrors='.urlencode($search_showonlyerrors);
322 if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
323 if (GETPOST('withtab','alpha')) $param.='&withtab='.urlencode(GETPOST('withtab','alpha'));
324 
325 // Add $param from extra fields
326 //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
327 
328 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
329 
330 print '<div align="right">';
331 print $langs->trans("RestrictYearToExport").': ';
332 $smonth=GETPOST('monthtoexport','int');
333 // Month
334 $retstring='';
335 $retstring.='<select class="flat valignmiddle maxwidth75imp marginrightonly" id="monthtoexport" name="monthtoexport">';
336 $retstring.='<option value="0" selected>&nbsp;</option>';
337 for ($month = 1 ; $month <= 12 ; $month++)
338 {
339  $retstring.='<option value="'.$month.'"'.($month == $smonth?' selected':'').'>';
340  $retstring.=dol_print_date(mktime(12,0,0,$month,1,2000),"%b");
341  $retstring.="</option>";
342 }
343 $retstring.="</select>";
344 print $retstring;
345 print '<input type="text" name="yeartoexport" class="valignmiddle maxwidth50imp" value="'.GETPOST('yeartoexport','int').'">';
346 print '<input type="hidden" name="withtab" value="'.GETPOST('withtab','alpha').'">';
347 print '<input type="submit" name="downloadcsv" class="button" value="'.$langs->trans('DownloadLogCSV').'">';
348 if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | <a href="?action=downloadblockchain'.(GETPOST('withtab','alpha')?'&withtab='.GETPOST('withtab','alpha'):'').'">'.$langs->trans('DownloadBlockChain').'</a>';
349 print ' </div><br>';
350 
351 print '</form>';
352 
353 print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
354 
355 print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
356 
357 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
358 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
359 print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
360 print '<input type="hidden" name="action" value="list">';
361 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
362 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
363 print '<input type="hidden" name="page" value="'.$page.'">';
364 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
365 print '<input type="hidden" name="withtab" value="'.GETPOST('withtab','alpha').'">';
366 
367 print '<table class="noborder" width="100%">';
368 
369 // Line of filters
370 print '<tr class="liste_titre_filter">';
371 
372 print '<td class="liste_titre">&nbsp;</td>';
373 
374 print '<td class="liste_titre">';
375 //print $langs->trans("from").': ';
376 print $form->selectDate($search_start,'search_start');
377 //print '<br>';
378 //print $langs->trans("to").': ';
379 print $form->selectDate($search_end,'search_end');
380 print '</td>';
381 
382 // User
383 print '<td class="liste_titre">';
384 print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
385 
386 print '</td>';
387 
388 // Actions code
389 $langs->load("blockedlog");
390 print '<td class="liste_titre">';
391 print $form->selectarray('search_code', $block_static->trackedevents, $search_code, 1, 0, 0, '', 1, 0, 0, 'ASC', 'maxwidth200', 1);
392 print '</td>';
393 
394 // Ref
395 print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
396 
397 // Link to ref
398 print '<td class="liste_titre"></td>';
399 
400 // Amount
401 print '<td class="liste_titre right"><input type="text" class="maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
402 
403 // Full data
404 print '<td class="liste_titre"></td>';
405 
406 // Fingerprint
407 print '<td class="liste_titre"></td>';
408 
409 // Status
410 print '<td class="liste_titre">';
411 $array=array("1"=>$langs->trans("OnlyNonValid"));
412 print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1);
413 print '</td>';
414 
415 // Status note
416 print '<td class="liste_titre"></td>';
417 
418 // Action column
419 print '<td class="liste_titre" align="middle">';
420 $searchpicto=$form->showFilterButtons();
421 print $searchpicto;
422 print '</td>';
423 
424 print '</tr>';
425 
426 print '<tr class="liste_titre">';
427 print getTitleFieldOfList($langs->trans('#'), 0, $_SERVER["PHP_SELF"],'rowid','',$param,'',$sortfield,$sortorder,'minwidth50 ')."\n";
428 print getTitleFieldOfList($langs->trans('Date'), 0, $_SERVER["PHP_SELF"],'date_creation','',$param,'',$sortfield,$sortorder,'')."\n";
429 print getTitleFieldOfList($langs->trans('Author'), 0, $_SERVER["PHP_SELF"],'user_fullname','',$param,'',$sortfield,$sortorder,'')."\n";
430 print getTitleFieldOfList($langs->trans('Action'), 0, $_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder,'')."\n";
431 print getTitleFieldOfList($langs->trans('Ref'), 0, $_SERVER["PHP_SELF"],'ref_object','',$param,'',$sortfield,$sortorder,'')."\n";
432 print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder,'')."\n";
433 print getTitleFieldOfList($langs->trans('Amount'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder,'')."\n";
434 print getTitleFieldOfList($langs->trans('DataOfArchivedEvent'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
435 print getTitleFieldOfList($langs->trans('Fingerprint'), 0, $_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder,'')."\n";
436 print getTitleFieldOfList($langs->trans('Status'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
437 print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
438 print getTitleFieldOfList('<span id="blockchainstatus"></span>', 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
439 print '</tr>';
440 
441 if (! empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR))
442 {
443  // This is version that is faster but require more memory and report errors that are outside the filter range
444 
445  // 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
446  // to find the $loweridinerror.
447 }
448 else
449 {
450  // This is version that optimize the memory (but will not report errors that are outside the filter range)
451  $loweridinerror=0;
452  $checkresult=array();
453  if (is_array($blocks))
454  {
455  foreach($blocks as &$block)
456  {
457  $checksignature = $block->checkSignature(); // Note: this make a sql request at each call, we can't avoid this as the sorting order is various
458  $checkresult[$block->id]=$checksignature; // false if error
459  if (! $checksignature)
460  {
461  if (empty($loweridinerror)) $loweridinerror=$block->id;
462  else $loweridinerror = min($loweridinerror, $block->id);
463  }
464  }
465  }
466 }
467 
468 if (is_array($blocks))
469 {
470  foreach($blocks as &$block)
471  {
472  $object_link = $block->getObjectLink();
473 
474  //if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
475  if (empty($search_showonlyerrors) || ! $checkresult[$block->id])
476  {
477  print '<tr class="oddeven">';
478 
479  // ID
480  print '<td>'.$block->id.'</td>';
481 
482  // Date
483  print '<td>'.dol_print_date($block->date_creation,'dayhour').'</td>';
484 
485  // User
486  print '<td>';
487  //print $block->getUser()
488  print $block->user_fullname;
489  print '</td>';
490 
491  // Action
492  print '<td>'.$langs->trans('log'.$block->action).'</td>';
493 
494  // Ref
495  print '<td class="nowrap">'.$block->ref_object.'</td>';
496 
497  // Link to source object
498  print '<td'.(preg_match('/<a/', $object_link) ? ' class="nowrap"' : '').'><!-- object_link -->'.$object_link.'</td>';
499 
500  // Amount
501  print '<td align="right">'.price($block->amounts).'</td>';
502 
503  // Details link
504  print '<td align="center"><a href="#" data-blockid="'.$block->id.'" rel="show-info">'.img_info($langs->trans('ShowDetails')).'</a></td>';
505 
506  // Fingerprint
507  print '<td class="nowrap">';
508  print $form->textwithpicto(dol_trunc($block->signature, '8'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'.$block->id);
509  print '</td>';
510 
511  // Status
512  print '<td class="center">';
513  if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error
514  {
515  if ($checkresult[$block->id]) print img_picto($langs->trans('OkCheckFingerprintValidityButChainIsKo'), 'statut4');
516  else print img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8');
517  }
518  else
519  {
520  print img_picto($langs->trans('OkCheckFingerprintValidity'), 'statut4');
521  }
522 
523  print '</td>';
524 
525  // Note
526  print '<td class="center">';
527  if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error
528  {
529  if ($checkresult[$block->id]) print $form->textwithpicto('', $langs->trans('OkCheckFingerprintValidityButChainIsKo'));
530  }
531 
532  if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) {
533  print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') );
534  }
535  print '</td>';
536 
537  print '<td></td>';
538 
539  print '</tr>';
540  }
541  }
542 }
543 
544 print '</table>';
545 
546 print '</div>';
547 
548 print '</form>';
549 
550 // Javascript to manage the showinfo popup
551 print '<script type="text/javascript">
552 
553 jQuery(document).ready(function () {
554  jQuery("#dialogforpopup").dialog(
555  { closeOnEscape: true, classes: { "ui-dialog": "highlight" },
556  maxHeight: window.innerHeight-60, height: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? 400 : 700).',
557  modal: true,
558  autoOpen: false }).css("z-index: 5000");
559 
560  $("a[rel=show-info]").click(function() {
561 
562  console.log("We click on tooltip, we open popup and get content using an ajax call");
563 
564  var fk_block = $(this).attr("data-blockid");
565 
566  $.ajax({
567  url:"../ajax/block-info.php?id="+fk_block
568  ,dataType:"html"
569  }).done(function(data) {
570  jQuery("#dialogforpopup").html(data);
571  });
572 
573  jQuery("#dialogforpopup").dialog("open");
574  });
575 })
576 </script>'."\n";
577 
578 
579 if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL))
580 {
581 ?>
582  <script type="text/javascript">
583 
584  $.ajax({
585  url : "<?php echo dol_buildpath('/blockedlog/ajax/check_signature.php',1) ?>"
586  ,dataType:"html"
587  }).done(function(data) {
588 
589  if(data == 'hashisok') {
590  $('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity'). ' '. img_picto($langs->trans('SignatureOK'), 'on') ?>');
591  }
592  else{
593  $('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity'). ' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
594  }
595 
596  });
597 
598  </script>
599 <?php
600 }
601 
602 if (GETPOST('withtab','alpha'))
603 {
604  dol_fiche_end();
605 }
606 
607 print '<br><br>';
608 
609 // End of page
610 llxFooter();
611 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:56
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
Definition: index.php:91
setEventMessages($mesg, $mesgs, $style='mesgs')
Set event messages in dol_events session object.
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.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm=false, $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
Class to manage certif authority.
img_info($titlealt='default')
Show info logo.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:453
dol_print_error($db='', $error='', $errors=null)
Affiche message erreur system avec toutes les informations pour faciliter le diagnostic et la remonte...
blockedlogadmin_prepare_head()
Define head array for tabs of blockedlog tools setup pages.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
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 a parameter.
type
Definition: viewcat.php:284
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='')
Get title line of an array.
dol_fiche_end($notab=0)
Show tab footer of a card.
Class to manage Blocked Log.
llxHeader()
Empty header.
Definition: wrapper.php:44
dol_now($mode='gmt')
Return date for now.
dol_print_date($time, $format='', $tzoutput='tzserver', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:467
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.
dol_time_plus_duree($time, $duration_value, $duration_unit)
Add a delay to a date.
Definition: date.lib.php:116
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='')
Show picto whatever it&#39;s its name (generic function)
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.