Standardize and debug code of module BlockedLog

This commit is contained in:
Laurent Destailleur 2017-06-16 11:51:33 +02:00
parent 26e80045a6
commit 1c8daf9700
14 changed files with 486 additions and 341 deletions

View File

@ -17,7 +17,7 @@
/** /**
* \file htdocs/blockedlog/admin/blockedlog.php * \file htdocs/blockedlog/admin/blockedlog.php
* \ingroup system * \ingroup blockedlog
* \brief Page setup for blockedlog module * \brief Page setup for blockedlog module
*/ */
@ -37,6 +37,7 @@ $action = GETPOST('action','alpha');
/* /*
* Actions * Actions
*/ */
if (preg_match('/set_(.*)/',$action,$reg)) if (preg_match('/set_(.*)/',$action,$reg))
{ {
$code=$reg[1]; $code=$reg[1];
@ -77,7 +78,7 @@ $form=new Form($db);
llxHeader('',$langs->trans("BlockedLogSetup")); llxHeader('',$langs->trans("BlockedLogSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback); print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback);
$head=blockedlogadmin_prepare_head(); $head=blockedlogadmin_prepare_head();
@ -95,13 +96,11 @@ print "</tr>\n";
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="titlefield">'; print '<td class="titlefield">';
print $langs->trans("EntityKey").'</td><td align="center">'; print $langs->trans("CompanyInitialKey").'</td><td>';
print $block_static->getSignature(); print $block_static->getSignature();
print '</td></tr>'; print '</td></tr>';
if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) { if (!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) {
// Example with a yes / no select // Example with a yes / no select
$var=!$var; $var=!$var;
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';

View File

@ -16,8 +16,8 @@
*/ */
/** /**
* \file htdocs/blockedlog/admin/blockedlog.php * \file htdocs/blockedlog/admin/fingerprints.php
* \ingroup system * \ingroup blockedlog
* \brief Page setup for blockedlog module * \brief Page setup for blockedlog module
*/ */
@ -110,7 +110,7 @@ $form=new Form($db);
llxHeader('',$langs->trans("BlockedLogSetup")); llxHeader('',$langs->trans("BlockedLogSetup"));
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>'; $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback); print load_fiche_titre($langs->trans("ModuleSetup").' '.$langs->trans('BlockedLog'),$linkback);
$head=blockedlogadmin_prepare_head(); $head=blockedlogadmin_prepare_head();
@ -131,12 +131,14 @@ print ' </div>';
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Date').'</td>'; print '<td class="minwidth50">'.$langs->trans('#').'</td>';
print '<td>'.$langs->trans('Ref').'</td>'; print '<td class="center">'.$langs->trans('Date').'</td>';
print '<td>'.$langs->trans('Author').'</td>';
print '<td>'.$langs->trans('Action').'</td>'; print '<td>'.$langs->trans('Action').'</td>';
print '<td>'.$langs->trans('Ref').'</td>';
print '<td>'.$langs->trans('Element').'</td>'; print '<td>'.$langs->trans('Element').'</td>';
print '<td>'.$langs->trans('Amount').'</td>'; print '<td>'.$langs->trans('Amount').'</td>';
print '<td>'.$langs->trans('Author').'</td>'; print '<td class="center">'.$langs->trans('DataOfArchivedEvent').'</td>';
print '<td>'.$langs->trans('Fingerprint').'</td>'; print '<td>'.$langs->trans('Fingerprint').'</td>';
print '<td><span id="blockchainstatus"></span></td>'; print '<td><span id="blockchainstatus"></span></td>';
@ -150,20 +152,27 @@ foreach($blocks as &$block) {
if(!$showonlyerrors || $block->error>0) { if(!$showonlyerrors || $block->error>0) {
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td>'.$block->id.'</td>';
print '<td>'.dol_print_date($block->tms,'dayhour').'</td>'; print '<td>'.dol_print_date($block->tms,'dayhour').'</td>';
print '<td>'.$block->ref_object.'</td>';
print '<td>'.$langs->trans('log'.$block->action).'</td>';
print '<td>'.$object_link.'<a href="#" blockid="'.$block->id.'" rel="show-info">'.img_info($langs->trans('ShowDetails')).'</a></td>';
print '<td align="right">'.price($block->amounts).'</td>';
print '<td>'.$block->getUser().'</td>'; print '<td>'.$block->getUser().'</td>';
print '<td>'.$block->signature.'</td>'; print '<td>'.$langs->trans('log'.$block->action).'</td>';
print '<td>'; print '<td>'.$block->ref_object.'</td>';
print '<td>'.$object_link.'</td>';
print '<td align="right">'.price($block->amounts).'</td>';
print '<td align="center"><a href="#" blockid="'.$block->id.'" rel="show-info">'.img_info($langs->trans('ShowDetails')).'</a></td>';
print '<td>';
print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature);
print '</td>';
print '<td>';
print $block->error == 0 ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'tick') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8');
print $block->error == 0 ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'on') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'off');
if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) { if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) {
print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') ); print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') );
} }
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
} }
@ -171,6 +180,8 @@ foreach($blocks as &$block) {
print '</table>'; print '</table>';
?> ?>
<script type="text/javascript"> <script type="text/javascript">
$('a[rel=show-info]').click(function() { $('a[rel=show-info]').click(function() {

View File

@ -1,45 +1,77 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require '../../master.inc.php'; /**
* \file htdocs/blockedlog/ajax/authority.php
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; * \ingroup blockedlog
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; * \brief authority
*/
$user=new User($db);
$user->fetch(1); //TODO conf user authority
$auth = new BlockedLogAuthority($db);
$signature = GETPOST('s');
$newblock = GETPOST('b');
$hash = GETPOST('h');
if($auth->fetch(0, $signature)<=0) {
$auth->signature = $signature;
$auth->create($user);
}
if(!empty($hash)) { // This script is called with a POST method.
// Directory to scan (full path) is inside POST['dir'].
echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk'; if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
} $res=require '../../master.inc.php';
elseif(!empty($newblock)){
if($auth->checkBlock($newblock)) {
$auth->addBlock($newblock);
$auth->update($user);
echo 'blockadded'; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
} require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
else{
echo 'blockalreadyadded'; $user=new User($db);
$user->fetch(1); //TODO conf user authority
} $auth = new BlockedLogAuthority($db);
$signature = GETPOST('s');
$newblock = GETPOST('b');
$hash = GETPOST('h');
if($auth->fetch(0, $signature)<=0) {
$auth->signature = $signature;
$auth->create($user);
}
if(!empty($hash)) {
echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk';
}
elseif(!empty($newblock)){
if($auth->checkBlock($newblock)) {
$auth->addBlock($newblock);
$auth->update($user);
echo 'blockadded';
} }
else{ else{
echo 'idontunderstandwhatihavetodo';
echo 'blockalreadyadded';
} }
}
else{
echo 'idontunderstandwhatihavetodo';
}

View File

@ -1,19 +1,49 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require '../../main.inc.php'; /**
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; * \file htdocs/blockedlog/ajax/block-add.php
* \ingroup blockedlog
* \brief Block-add
*/
$id = GETPOST('id','int');
$element = GETPOST('element','alpha');
$action = GETPOST('action','alpha');
if($element === 'facture') { // This script is called with a POST method.
dol_include_once('/compta/facture/class/facture.class.php'); // Directory to scan (full path) is inside POST['dir'].
$facture = new Facture($db); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
if($facture->fetch($id)>0) { //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
$facture->call_trigger($action, $user); if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
} if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
$res=require '../../main.inc.php';
$id = GETPOST('id','int');
$element = GETPOST('element','alpha');
$action = GETPOST('action','alpha');
if ($element === 'facture') {
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$facture = new Facture($db);
if($facture->fetch($id)>0) {
$facture->call_trigger($action, $user);
} }
}

View File

@ -1,15 +1,47 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require '../../main.inc.php'; /**
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; * \file htdocs/blockedlog/ajax/block-info.php
* \ingroup blockedlog
* \brief block-info
*/
$id = GETPOST('id');
$block = new BlockedLog($db); // This script is called with a POST method.
if($block->fetch($id)>0) { // Directory to scan (full path) is inside POST['dir'].
echo json_encode($block->object_data);
}
else {
echo json_encode(false);
}
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
$id = GETPOST('id');
$block = new BlockedLog($db);
if($block->fetch($id)>0) {
echo json_encode($block->object_data);
}
else {
echo json_encode(false);
}

View File

@ -1,30 +1,63 @@
<?php <?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require '../../main.inc.php'; /**
* \file htdocs/blockedlog/ajax/block-info.php
* \ingroup blockedlog
* \brief block-info
*/
if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) exit('BLOCKEDLOG_AUTHORITY_URL not set');
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php'; // This script is called with a POST method.
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php'; // Directory to scan (full path) is inside POST['dir'].
$auth=new BlockedLogAuthority($db); if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
$auth->syncSignatureWithAuthority(); //if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
$block_static = new BlockedLog($db);
$blocks = $block_static->getLog('just_certified', 0, 0, 1) ; require '../../main.inc.php';
$auth->signature = $block_static->getSignature(); if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) exit('BLOCKEDLOG_AUTHORITY_URL not set');
foreach($blocks as &$b) { require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
$auth->blockchain.=$b->signature; require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
} $auth=new BlockedLogAuthority($db);
$auth->syncSignatureWithAuthority();
$hash = $auth->getBlockchainHash(); $block_static = new BlockedLog($db);
$url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$auth->signature.'&h='.$hash; $blocks = $block_static->getLog('just_certified', 0, 0, 1) ;
$res = file_get_contents($url); $auth->signature = $block_static->getSignature();
//echo $url;
echo $res; foreach($blocks as &$b) {
$auth->blockchain.=$b->signature;
}
$hash = $auth->getBlockchainHash();
$url = $conf->global->BLOCKEDLOG_AUTHORITY_URL.'/blockedlog/ajax/authority.php?s='.$auth->signature.'&h='.$hash;
$res = file_get_contents($url);
//echo $url;
echo $res;

View File

@ -523,14 +523,14 @@ class BlockedLog
} }
/** /**
* return and set the entity signature included into line signature * Return and set the entity signature included into line signature
* *
* @return string current entity signature * @return string current entity signature
*/ */
public function getSignature() { public function getSignature() {
global $db,$conf,$mysoc; global $db,$conf,$mysoc;
if(empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint if (empty($conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT)) { // creation of a unique fingerprint
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
@ -538,7 +538,7 @@ class BlockedLog
dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine',0,'Numeric Unique Fingerprint', $conf->entity); dolibarr_set_const($db, 'BLOCKEDLOG_ENTITY_FINGERPRINT', $fingerprint, 'chaine',0,'Numeric Unique Fingerprint', $conf->entity);
$conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT= $fingerprint; $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT=$fingerprint;
} }
return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT; return $conf->global->BLOCKEDLOG_ENTITY_FINGERPRINT;

View File

@ -34,7 +34,7 @@ function blockedlogadmin_prepare_head()
$head = array(); $head = array();
$head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/blockedlog.php"; $head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/blockedlog.php";
$head[$h][1] = $langs->trans("BlockedLog"); $head[$h][1] = $langs->trans("Setup");
$head[$h][2] = 'blockedlog'; $head[$h][2] = 'blockedlog';
$h++; $h++;

View File

@ -4247,37 +4247,6 @@ else if ($id > 0 || ! empty($ref))
$delallowed = $user->rights->facture->supprimer; $delallowed = $user->rights->facture->supprimer;
print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang); print $formfile->showdocuments('facture', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
if(!empty($conf->blockedlog->enabled) && $object->statut>0) {
?>
<script type="text/javascript">
$(document).ready(function() {
$('a.documentpreview').click(function() {
$.post("<?php echo DOL_URL_ROOT."/blockedlog/ajax/block-add.php" ?>"
, {
id:<?php echo $object->id; ?>
, element:"<?php echo $object->element ?>"
, action:"PREVIEW_BILL"
}
);
});
$('a.documentdownload').click(function() {
$.post("<?php echo DOL_URL_ROOT."/blockedlog/ajax/block-add.php" ?>"
, {
id:<?php echo $object->id; ?>
, element:"<?php echo $object->element ?>"
, action:"DOWNLOAD_BILL"
}
);
});
});
</script>
<?php
}
$somethingshown = $formfile->numoffiles; $somethingshown = $formfile->numoffiles;
// Show links to link elements // Show links to link elements

View File

@ -43,15 +43,15 @@ class modBlockedLog extends DolibarrModules
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other' // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
// It is used to group modules in module setup page // It is used to group modules in module setup page
$this->family = "technic"; $this->family = "base";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this)); $this->name = preg_replace('/^mod/i','',get_class($this));
$this->description = "Enable a log on some business events into a reserved log. This module may be mandatory for some countries."; $this->description = "Enable a log on some business events into a non reversible log. This module may be mandatory for some countries.";
$this->version = 'development'; // 'development', 'experimental' or 'dolibarr' or version $this->version = 'development'; // 'development', 'experimental' or 'dolibarr' or version
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 1; $this->special = 2;
// Name of image file used for this module. // Name of image file used for this module.
$this->picto='technic'; $this->picto='technic';

View File

@ -52,7 +52,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
} }
if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
|| $action === 'BILL_SENTBYMAIL' || $action === 'DOWNLOAD_BILL' || $action === 'PREVIEW_BILL') { || $action === 'BILL_SENTBYMAIL' || $action === 'DOC_DOWNLOAD' || $action === 'DOC_PREVIEW') {
$amounts= (double) $object->total_ttc; $amounts= (double) $object->total_ttc;
} }
else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') { else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') {

View File

@ -467,7 +467,7 @@ Module30Desc=Invoice and credit note management for customers. Invoice managemen
Module40Name=Suppliers Module40Name=Suppliers
Module40Desc=Supplier management and buying (orders and invoices) Module40Desc=Supplier management and buying (orders and invoices)
Module42Name=Logs Module42Name=Logs
Module42Desc=Logging facilities (file, syslog, ...) Module42Desc=Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes. For legal purpose, see instead module 'Non Reversible Logs'.
Module49Name=Editors Module49Name=Editors
Module49Desc=Editor management Module49Desc=Editor management
Module50Name=Products Module50Name=Products
@ -565,6 +565,8 @@ Module2900Name=GeoIPMaxmind
Module2900Desc=GeoIP Maxmind conversions capabilities Module2900Desc=GeoIP Maxmind conversions capabilities
Module3100Name=Skype Module3100Name=Skype
Module3100Desc=Add a Skype button into users / third parties / contacts / members cards Module3100Desc=Add a Skype button into users / third parties / contacts / members cards
Module3200Name=Non Reversible Logs
Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table that can be then exported. This module may be mandatory for some countries.
Module4000Name=HRM Module4000Name=HRM
Module4000Desc=Human resources management (mangement of department, employee contracts and feelings) Module4000Desc=Human resources management (mangement of department, employee contracts and feelings)
Module5000Name=Multi-company Module5000Name=Multi-company

View File

@ -1,12 +1,14 @@
BlockedLog=Non Reversible Logs
Field=Field Field=Field
BlockedLogDesc=This module store event for invoice and payments as block chain BlockedLogDesc=This module store event for invoice and payments into a block chain
FingerprintsDesc=All fingerprints stored Fingerprints=Archived events and fingerprints
EntityKey=Entity Key FingerprintsDesc=Archived business events and fingerprints
ShowAllFingerPrintsMightBeTooLong=Show all fingerprints (might be long) CompanyInitialKey=Company initial key
ShowAllFingerPrintsErrorsMightBeTooLong=Show all fingerprints with error (might be long) ShowAllFingerPrintsMightBeTooLong=Show all archived logs (might be long)
ShowAllFingerPrintsErrorsMightBeTooLong=Show all archive logs with error (might be long)
DownloadBlockChain=Download fingerprints DownloadBlockChain=Download fingerprints
KoCheckFingerprintValidity=Fingerprint is not valid KoCheckFingerprintValidity=Archived log is not valid. It means someone (a hacker ?) has modified some datas of this archived log after it was recorded, or has erased the previous archived record (check that line with previous # exists).
OkCheckFingerprintValidity=Fingerprint is valid OkCheckFingerprintValidity=Archived log is valid. It means all data on this line were not modified and record follow the previous one.
AddedByAuthority=Stored into remote authority AddedByAuthority=Stored into remote authority
NotAddedByAuthorityYet=Not yet stored into remote authority NotAddedByAuthorityYet=Not yet stored into remote authority
ShowDetails=Show stored details ShowDetails=Show stored details
@ -18,6 +20,7 @@ logBILL_VALIDATE=Customer bill set valid from draft
logBILL_SENTBYMAIL=Customer bill send by mail logBILL_SENTBYMAIL=Customer bill send by mail
BlockedlogInfoDialog=Log Details BlockedlogInfoDialog=Log Details
Fingerprint=Fingerprint Fingerprint=Fingerprint
DownloadLogCSV=Download fingerprints CSV DownloadLogCSV=Download archive logs (CSV)
logPREVIEW_BILL=Preview of a validated customer bill in order to print or download logDOC_PREVIEW=Preview of a validated document in order to print or download
logDOWNLOAD_BILL=Download of a validated customer bill in order to print or send logDOC_DOWNLOAD=Download of a validated document in order to print or send
DataOfArchivedEvent=Full datas of archived event

View File

@ -1891,7 +1891,7 @@ if (! function_exists("llxFooter"))
*/ */
function llxFooter($comment='',$zone='private') function llxFooter($comment='',$zone='private')
{ {
global $conf, $langs, $user; global $conf, $langs, $user, $object;
global $delayedhtmlcontent; global $delayedhtmlcontent;
// Global html output events ($mesgs, $errors, $warnings) // Global html output events ($mesgs, $errors, $warnings)
@ -2026,6 +2026,40 @@ if (! function_exists("llxFooter"))
</script>'; </script>';
} }
// Wrapper to add log when clicking on download or preview
if (! empty($conf->blockedlog->enabled) && is_object($object) && $object->id > 0 && $object->statut > 0)
{
if (in_array($object->element, array('facture'))) // Restrict for the moment to element 'facture'
{
print "\n<!-- JS CODE TO ENABLE log when making a download or a preview of a document -->\n";
?>
<script type="text/javascript">
jQuery(document).ready(function () {
$('a.documentpreview').click(function() {
$.post('<?php echo DOL_URL_ROOT."/blockedlog/ajax/block-add.php" ?>'
, {
id:<?php echo $object->id; ?>
, element:'<?php echo $object->element ?>'
, action:'DOC_PREVIEW'
}
);
});
$('a.documentdownload').click(function() {
$.post('<?php echo DOL_URL_ROOT."/blockedlog/ajax/block-add.php" ?>'
, {
id:<?php echo $object->id; ?>
, element:'<?php echo $object->element ?>'
, action:'DOC_DOWNLOAD'
}
);
});
});
</script>
<?php
}
}
// A div for the address popup // A div for the address popup
print "\n<!-- A div to allow dialog popup -->\n"; print "\n<!-- A div to allow dialog popup -->\n";
print '<div id="dialogforpopup" style="display: none;"></div>'."\n"; print '<div id="dialogforpopup" style="display: none;"></div>'."\n";