blockedlog_list.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  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. /**
  20. * \file htdocs/blockedlog/admin/blockedlog_list.php
  21. * \ingroup blockedlog
  22. * \brief Page setup for blockedlog module
  23. */
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
  28. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  29. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  30. // Load translation files required by the page
  31. $langs->loadLangs(array("admin", "other", "blockedlog", "bills"));
  32. if ((! $user->admin && ! $user->rights->blockedlog->read) || empty($conf->blockedlog->enabled)) accessforbidden();
  33. $action = GETPOST('action','alpha');
  34. $contextpage= GETPOST('contextpage','aZ')?GETPOST('contextpage','aZ'):'blockedloglist'; // To manage different context of search
  35. $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated page
  36. $optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')
  37. $search_showonlyerrors = GETPOST('search_showonlyerrors','int');
  38. if ($search_showonlyerrors < 0) $search_showonlyerrors=0;
  39. $search_fk_user=GETPOST('search_fk_user','intcomma');
  40. $search_start = -1;
  41. if (GETPOST('search_startyear')!='') $search_start = dol_mktime(0, 0, 0, GETPOST('search_startmonth'), GETPOST('search_startday'), GETPOST('search_startyear'));
  42. $search_end = -1;
  43. if (GETPOST('search_endyear')!='') $search_end= dol_mktime(23, 59, 59, GETPOST('search_endmonth'), GETPOST('search_endday'), GETPOST('search_endyear'));
  44. $search_code = GETPOST('search_code', 'alpha');
  45. $search_ref = GETPOST('search_ref', 'alpha');
  46. $search_amount = GETPOST('search_amount', 'alpha');
  47. if (($search_start == -1 || empty($search_start)) && ! GETPOSTISSET('search_startmonth')) $search_start = dol_time_plus_duree(dol_now(), '-1', 'w');
  48. // Load variable for pagination
  49. $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
  50. $sortfield = GETPOST('sortfield','alpha');
  51. $sortorder = GETPOST('sortorder','alpha');
  52. $page = GETPOST('page','int');
  53. if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
  54. $offset = $limit * $page;
  55. $pageprev = $page - 1;
  56. $pagenext = $page + 1;
  57. if (empty($sortfield)) $sortfield='rowid';
  58. if (empty($sortorder)) $sortorder='DESC';
  59. $block_static = new BlockedLog($db);
  60. $result = restrictedArea($user, 'blockedlog', 0, '');
  61. /*
  62. * Actions
  63. */
  64. // Purge search criteria
  65. 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
  66. {
  67. $search_fk_user = '';
  68. $search_start = -1;
  69. $search_end = -1;
  70. $search_code = '';
  71. $search_ref = '';
  72. $search_amount = '';
  73. $search_showonlyerrors = 0;
  74. $toselect='';
  75. $search_array_options=array();
  76. }
  77. if ($action === 'downloadblockchain') {
  78. $auth = new BlockedLogAuthority($db);
  79. $bc = $auth->getLocalBlockChain();
  80. header('Content-Type: application/octet-stream');
  81. header("Content-Transfer-Encoding: Binary");
  82. header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\"");
  83. echo $bc;
  84. exit;
  85. }
  86. elseif (GETPOST('downloadcsv','alpha'))
  87. {
  88. $error = 0;
  89. $previoushash='';
  90. $firstid='';
  91. if (! $error)
  92. {
  93. // Get ID of first line
  94. $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
  95. $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
  96. $sql.= " WHERE entity = ".$conf->entity;
  97. if (GETPOST('monthtoexport','int') > 0 || GETPOST('yeartoexport','int') > 0)
  98. {
  99. $dates = dol_get_first_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):1);
  100. $datee = dol_get_last_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):12);
  101. $sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
  102. }
  103. $sql.= " ORDER BY rowid ASC"; // Required so we get the first one
  104. $sql.= $db->plimit(1);
  105. $res = $db->query($sql);
  106. if($res)
  107. {
  108. // Make the first fetch to get first line
  109. $obj = $db->fetch_object($res);
  110. if ($obj)
  111. {
  112. $previoushash = $block_static->getPreviousHash(0, $obj->rowid);
  113. $firstid = $obj->rowid;
  114. }
  115. else
  116. { // If not data found for filter, we do not need previoushash neither firstid
  117. $previoushash = 'nodata';
  118. $firstid = '';
  119. }
  120. }
  121. else
  122. {
  123. $error++;
  124. setEventMessages($db->lasterror, null, 'errors');
  125. }
  126. }
  127. if (! $error)
  128. {
  129. // Now restart request with all data = no limit(1) in sql request
  130. $sql = "SELECT rowid,date_creation,tms,user_fullname,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user,object_data";
  131. $sql.= " FROM ".MAIN_DB_PREFIX."blockedlog";
  132. $sql.= " WHERE entity = ".$conf->entity;
  133. if (GETPOST('monthtoexport','int') > 0 || GETPOST('yeartoexport','int') > 0)
  134. {
  135. $dates = dol_get_first_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):1);
  136. $datee = dol_get_last_day(GETPOST('yeartoexport','int'), GETPOST('monthtoexport','int')?GETPOST('monthtoexport','int'):12);
  137. $sql.= " AND date_creation BETWEEN '".$db->idate($dates)."' AND '".$db->idate($datee)."'";
  138. }
  139. $sql.= " ORDER BY rowid ASC"; // Required so later we can use the parameter $previoushash of checkSignature()
  140. $res = $db->query($sql);
  141. if($res)
  142. {
  143. header('Content-Type: application/octet-stream');
  144. header("Content-Transfer-Encoding: Binary");
  145. 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\"");
  146. print $langs->transnoentities('Id')
  147. .';'.$langs->transnoentities('Date')
  148. .';'.$langs->transnoentities('User')
  149. .';'.$langs->transnoentities('Action')
  150. .';'.$langs->transnoentities('Element')
  151. .';'.$langs->transnoentities('Amounts')
  152. .';'.$langs->transnoentities('ObjectId')
  153. .';'.$langs->transnoentities('Date')
  154. .';'.$langs->transnoentities('Ref')
  155. .';'.$langs->transnoentities('Fingerprint')
  156. .';'.$langs->transnoentities('Status')
  157. .';'.$langs->transnoentities('Note')
  158. .';'.$langs->transnoentities('FullData')
  159. ."\n";
  160. $loweridinerror = 0;
  161. $i = 0;
  162. while ($obj = $db->fetch_object($res))
  163. {
  164. // We set here all data used into signature calculation (see checkSignature method) and more
  165. // IMPORTANT: We must have here, the same rule for transformation of data than into the fetch method (db->jdate for date, ...)
  166. $block_static->id = $obj->rowid;
  167. $block_static->date_creation = $db->jdate($obj->date_creation);
  168. $block_static->date_modification = $db->jdate($obj->tms);
  169. $block_static->action = $obj->action;
  170. $block_static->fk_object = $obj->fk_object;
  171. $block_static->element = $obj->element;
  172. $block_static->amounts = (double) $obj->amounts;
  173. $block_static->ref_object = $obj->ref_object;
  174. $block_static->date_object = $db->jdate($obj->date_object);
  175. $block_static->user_fullname = $obj->user_fullname;
  176. $block_static->fk_user = $obj->fk_user;
  177. $block_static->signature = $obj->signature;
  178. $block_static->object_data = $block_static->dolDecodeBlockedData($obj->object_data);
  179. $checksignature = $block_static->checkSignature($previoushash); // If $previoushash is not defined, checkSignature will search it
  180. if ($checksignature)
  181. {
  182. $statusofrecord = 'Valid';
  183. if ($loweridinerror > 0) $statusofrecordnote = 'ValidButFoundAPreviousKO';
  184. else $statusofrecordnote = '';
  185. }
  186. else
  187. {
  188. $statusofrecord = 'KO';
  189. $statusofrecordnote = 'LineCorruptedOrNotMatchingPreviousOne';
  190. $loweridinerror = $obj->rowid;
  191. }
  192. if ($i==0)
  193. {
  194. $statusofrecordnote = $langs->trans("PreviousFingerprint").': '.$previoushash.($statusofrecordnote?' - '.$statusofrecordnote:'');
  195. }
  196. print $obj->rowid
  197. .';'.$obj->date_creation
  198. .';"'.$obj->user_fullname.'"'
  199. .';'.$obj->action
  200. .';'.$obj->element
  201. .';'.$obj->amounts
  202. .';'.$obj->fk_object
  203. .';'.$obj->date_object
  204. .';"'.$obj->ref_object.'"'
  205. .';'.$obj->signature
  206. .';'.$statusofrecord
  207. .';'.$statusofrecordnote
  208. .';"'.str_replace('"','""',$obj->object_data).'"'
  209. ."\n";
  210. // Set new previous hash for next fetch
  211. $previoushash = $obj->signature;
  212. $i++;
  213. }
  214. exit;
  215. }
  216. else
  217. {
  218. setEventMessages($db->lasterror, null, 'errors');
  219. }
  220. }
  221. }
  222. /*
  223. * View
  224. */
  225. $form=new Form($db);
  226. if (GETPOST('withtab','alpha'))
  227. {
  228. $title=$langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog');
  229. }
  230. else
  231. {
  232. $title=$langs->trans("BrowseBlockedLog");
  233. }
  234. llxHeader('',$langs->trans("BrowseBlockedLog"));
  235. $MAXLINES = 10000;
  236. $blocks = $block_static->getLog('all', 0, $MAXLINES, $sortfield, $sortorder, $search_fk_user, $search_start, $search_end, $search_ref, $search_amount, $search_code);
  237. if (! is_array($blocks))
  238. {
  239. if ($blocks == -2)
  240. {
  241. setEventMessages($langs->trans("TooManyRecordToScanRestrictFilters", $MAXLINES), null, 'errors');
  242. }
  243. else
  244. {
  245. dol_print_error($block_static->db, $block_static->error, $block_static->errors);
  246. exit;
  247. }
  248. }
  249. $linkback='';
  250. if (GETPOST('withtab','alpha'))
  251. {
  252. $linkback='<a href="'.($backtopage?$backtopage:DOL_URL_ROOT.'/admin/modules.php').'">'.$langs->trans("BackToModuleList").'</a>';
  253. }
  254. print load_fiche_titre($title, $linkback);
  255. if (GETPOST('withtab','alpha'))
  256. {
  257. $head=blockedlogadmin_prepare_head();
  258. dol_fiche_head($head, 'fingerprints', '', -1);
  259. }
  260. print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("FingerprintsDesc")."<br></span>\n";
  261. print '<br>';
  262. $param='';
  263. if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
  264. if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
  265. if ($search_fk_user > 0) $param.='&search_fk_user='.urlencode($search_fk_user);
  266. if ($search_startyear > 0) $param.='&search_startyear='.urlencode(GETPOST('search_startyear','int'));
  267. if ($search_startmonth > 0) $param.='&search_startmonth='.urlencode(GETPOST('search_startmonth','int'));
  268. if ($search_startday > 0) $param.='&search_startday='.urlencode(GETPOST('search_startday','int'));
  269. if ($search_endyear > 0) $param.='&search_endyear='.urlencode(GETPOST('search_endyear','int'));
  270. if ($search_endmonth > 0) $param.='&search_endmonth='.urlencode(GETPOST('search_endmonth','int'));
  271. if ($search_endday > 0) $param.='&search_endday='.urlencode(GETPOST('search_endday','int'));
  272. if ($search_showonlyerrors > 0) $param.='&search_showonlyerrors='.urlencode($search_showonlyerrors);
  273. if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
  274. if (GETPOST('withtab','alpha')) $param.='&withtab='.urlencode(GETPOST('withtab','alpha'));
  275. // Add $param from extra fields
  276. //include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
  277. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  278. print '<div align="right">';
  279. print $langs->trans("RestrictYearToExport").': ';
  280. $smonth=GETPOST('monthtoexport','int');
  281. // Month
  282. $retstring='';
  283. $retstring.='<select class="flat valignmiddle maxwidth75imp marginrightonly" id="monthtoexport" name="monthtoexport">';
  284. $retstring.='<option value="0" selected>&nbsp;</option>';
  285. for ($month = 1 ; $month <= 12 ; $month++)
  286. {
  287. $retstring.='<option value="'.$month.'"'.($month == $smonth?' selected':'').'>';
  288. $retstring.=dol_print_date(mktime(12,0,0,$month,1,2000),"%b");
  289. $retstring.="</option>";
  290. }
  291. $retstring.="</select>";
  292. print $retstring;
  293. print '<input type="text" name="yeartoexport" class="valignmiddle maxwidth50imp" value="'.GETPOST('yeartoexport','int').'">';
  294. print '<input type="hidden" name="withtab" value="'.GETPOST('withtab','alpha').'">';
  295. print '<input type="submit" name="downloadcsv" class="button" value="'.$langs->trans('DownloadLogCSV').'">';
  296. if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) print ' | <a href="?action=downloadblockchain'.(GETPOST('withtab','alpha')?'&withtab='.GETPOST('withtab','alpha'):'').'">'.$langs->trans('DownloadBlockChain').'</a>';
  297. print ' </div><br>';
  298. print '</form>';
  299. print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
  300. print '<div class="div-table-responsive">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
  301. if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
  302. print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  303. print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
  304. print '<input type="hidden" name="action" value="list">';
  305. print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
  306. print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
  307. print '<input type="hidden" name="page" value="'.$page.'">';
  308. print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
  309. print '<input type="hidden" name="withtab" value="'.GETPOST('withtab','alpha').'">';
  310. print '<table class="noborder" width="100%">';
  311. // Line of filters
  312. print '<tr class="liste_titre_filter">';
  313. print '<td class="liste_titre">&nbsp;</td>';
  314. print '<td class="liste_titre">';
  315. //print $langs->trans("from").': ';
  316. print $form->selectDate($search_start,'search_start');
  317. //print '<br>';
  318. //print $langs->trans("to").': ';
  319. print $form->selectDate($search_end,'search_end');
  320. print '</td>';
  321. // User
  322. print '<td class="liste_titre">';
  323. print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth200');
  324. print '</td>';
  325. // Actions code
  326. $langs->load("blockedlog");
  327. print '<td class="liste_titre">';
  328. print $form->selectarray('search_code', $block_static->trackedevents, $search_code, 1, 0, 0, '', 1, 0, 0, 'ASC', 'maxwidth200', 1);
  329. print '</td>';
  330. // Ref
  331. print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_ref" value="'.dol_escape_htmltag($search_ref).'"></td>';
  332. // Link to ref
  333. print '<td class="liste_titre"></td>';
  334. // Amount
  335. print '<td class="liste_titre right"><input type="text" class="maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
  336. // Full data
  337. print '<td class="liste_titre"></td>';
  338. // Fingerprint
  339. print '<td class="liste_titre"></td>';
  340. // Status
  341. print '<td class="liste_titre">';
  342. $array=array("1"=>$langs->trans("OnlyNonValid"));
  343. print $form->selectarray('search_showonlyerrors', $array, $search_showonlyerrors, 1);
  344. print '</td>';
  345. // Status note
  346. print '<td class="liste_titre"></td>';
  347. // Action column
  348. print '<td class="liste_titre" align="middle">';
  349. $searchpicto=$form->showFilterButtons();
  350. print $searchpicto;
  351. print '</td>';
  352. print '</tr>';
  353. print '<tr class="liste_titre">';
  354. print getTitleFieldOfList($langs->trans('#'), 0, $_SERVER["PHP_SELF"],'rowid','',$param,'',$sortfield,$sortorder,'minwidth50 ')."\n";
  355. print getTitleFieldOfList($langs->trans('Date'), 0, $_SERVER["PHP_SELF"],'date_creation','',$param,'',$sortfield,$sortorder,'')."\n";
  356. print getTitleFieldOfList($langs->trans('Author'), 0, $_SERVER["PHP_SELF"],'user_fullname','',$param,'',$sortfield,$sortorder,'')."\n";
  357. print getTitleFieldOfList($langs->trans('Action'), 0, $_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder,'')."\n";
  358. print getTitleFieldOfList($langs->trans('Ref'), 0, $_SERVER["PHP_SELF"],'ref_object','',$param,'',$sortfield,$sortorder,'')."\n";
  359. print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder,'')."\n";
  360. print getTitleFieldOfList($langs->trans('Amount'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="right"',$sortfield,$sortorder,'')."\n";
  361. print getTitleFieldOfList($langs->trans('DataOfArchivedEvent'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
  362. print getTitleFieldOfList($langs->trans('Fingerprint'), 0, $_SERVER["PHP_SELF"],'','',$param,'',$sortfield,$sortorder,'')."\n";
  363. print getTitleFieldOfList($langs->trans('Status'), 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
  364. print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
  365. print getTitleFieldOfList('<span id="blockchainstatus"></span>', 0, $_SERVER["PHP_SELF"],'','',$param,'align="center"',$sortfield,$sortorder,'')."\n";
  366. print '</tr>';
  367. if (! empty($conf->global->BLOCKEDLOG_SCAN_ALL_FOR_LOWERIDINERROR))
  368. {
  369. // This is version that is faster but require more memory and report errors that are outside the filter range
  370. // 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
  371. // to find the $loweridinerror.
  372. }
  373. else
  374. {
  375. // This is version that optimize the memory (but will not report errors that are outside the filter range)
  376. $loweridinerror=0;
  377. $checkresult=array();
  378. if (is_array($blocks))
  379. {
  380. foreach($blocks as &$block)
  381. {
  382. $checksignature = $block->checkSignature(); // Note: this make a sql request at each call, we can't avoid this as the sorting order is various
  383. $checkresult[$block->id]=$checksignature; // false if error
  384. if (! $checksignature)
  385. {
  386. if (empty($loweridinerror)) $loweridinerror=$block->id;
  387. else $loweridinerror = min($loweridinerror, $block->id);
  388. }
  389. }
  390. }
  391. }
  392. if (is_array($blocks))
  393. {
  394. foreach($blocks as &$block)
  395. {
  396. $object_link = $block->getObjectLink();
  397. //if (empty($search_showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
  398. if (empty($search_showonlyerrors) || ! $checkresult[$block->id])
  399. {
  400. print '<tr class="oddeven">';
  401. // ID
  402. print '<td>'.$block->id.'</td>';
  403. // Date
  404. print '<td>'.dol_print_date($block->date_creation,'dayhour').'</td>';
  405. // User
  406. print '<td>';
  407. //print $block->getUser()
  408. print $block->user_fullname;
  409. print '</td>';
  410. // Action
  411. print '<td>'.$langs->trans('log'.$block->action).'</td>';
  412. // Ref
  413. print '<td class="nowrap">'.$block->ref_object.'</td>';
  414. // Link to source object
  415. print '<td'.(preg_match('/<a/', $object_link) ? ' class="nowrap"' : '').'><!-- object_link -->'.$object_link.'</td>';
  416. // Amount
  417. print '<td class="right">'.price($block->amounts).'</td>';
  418. // Details link
  419. print '<td align="center"><a href="#" data-blockid="'.$block->id.'" rel="show-info">'.img_info($langs->trans('ShowDetails')).'</a></td>';
  420. // Fingerprint
  421. print '<td class="nowrap">';
  422. print $form->textwithpicto(dol_trunc($block->signature, '8'), $block->signature, 1, 'help', '', 0, 2, 'fingerprint'.$block->id);
  423. print '</td>';
  424. // Status
  425. print '<td class="center">';
  426. if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error
  427. {
  428. if ($checkresult[$block->id]) print img_picto($langs->trans('OkCheckFingerprintValidityButChainIsKo'), 'statut4');
  429. else print img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8');
  430. }
  431. else
  432. {
  433. print img_picto($langs->trans('OkCheckFingerprintValidity'), 'statut4');
  434. }
  435. print '</td>';
  436. // Note
  437. print '<td class="center">';
  438. if (! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror)) // If error
  439. {
  440. if ($checkresult[$block->id]) print $form->textwithpicto('', $langs->trans('OkCheckFingerprintValidityButChainIsKo'));
  441. }
  442. if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) {
  443. print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') );
  444. }
  445. print '</td>';
  446. print '<td></td>';
  447. print '</tr>';
  448. }
  449. }
  450. }
  451. print '</table>';
  452. print '</div>';
  453. print '</form>';
  454. // Javascript to manage the showinfo popup
  455. print '<script type="text/javascript">
  456. jQuery(document).ready(function () {
  457. jQuery("#dialogforpopup").dialog(
  458. { closeOnEscape: true, classes: { "ui-dialog": "highlight" },
  459. maxHeight: window.innerHeight-60, height: window.innerHeight-60, width: '.($conf->browser->layout == 'phone' ? 400 : 700).',
  460. modal: true,
  461. autoOpen: false }).css("z-index: 5000");
  462. $("a[rel=show-info]").click(function() {
  463. console.log("We click on tooltip, we open popup and get content using an ajax call");
  464. var fk_block = $(this).attr("data-blockid");
  465. $.ajax({
  466. url:"../ajax/block-info.php?id="+fk_block
  467. ,dataType:"html"
  468. }).done(function(data) {
  469. jQuery("#dialogforpopup").html(data);
  470. });
  471. jQuery("#dialogforpopup").dialog("open");
  472. });
  473. })
  474. </script>'."\n";
  475. if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL))
  476. {
  477. ?>
  478. <script type="text/javascript">
  479. $.ajax({
  480. url : "<?php echo dol_buildpath('/blockedlog/ajax/check_signature.php',1) ?>"
  481. ,dataType:"html"
  482. }).done(function(data) {
  483. if(data == 'hashisok') {
  484. $('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity'). ' '. img_picto($langs->trans('SignatureOK'), 'on') ?>');
  485. }
  486. else{
  487. $('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity'). ' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
  488. }
  489. });
  490. </script>
  491. <?php
  492. }
  493. if (GETPOST('withtab','alpha'))
  494. {
  495. dol_fiche_end();
  496. }
  497. print '<br><br>';
  498. // End of page
  499. llxFooter();
  500. $db->close();