diff --git a/htdocs/blockedlog/admin/fingerprints.php b/htdocs/blockedlog/admin/fingerprints.php
index 95117bf2c28..f585b883c65 100644
--- a/htdocs/blockedlog/admin/fingerprints.php
+++ b/htdocs/blockedlog/admin/fingerprints.php
@@ -34,6 +34,9 @@ $langs->load("blockedlog");
if (! $user->admin) accessforbidden();
$action = GETPOST('action','alpha');
+$showonlyerrors = GETPOST('showonlyerrors','int');
+
+$block_static = new BlockedLog($db);
if($action === 'downloadblockchain') {
@@ -49,14 +52,57 @@ if($action === 'downloadblockchain') {
exit;
}
-
+else if($action === 'downloadcsv') {
+
+ $res = $db->query("SELECT rowid,tms,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user
+ FROM ".MAIN_DB_PREFIX."blockedlog ORDER BY rowid ASC");
+
+ if($res) {
+
+ $signature = $block_static->getSignature();
+
+ header('Content-Type: application/octet-stream');
+ header("Content-Transfer-Encoding: Binary");
+ header("Content-disposition: attachment; filename=\"" .$signature. ".csv\"");
+
+ print $langs->transnoentities('Id')
+ .';'.$langs->transnoentities('Timestamp')
+ .';'.$langs->transnoentities('Action')
+ .';'.$langs->transnoentities('Amounts')
+ .';'.$langs->transnoentities('Element')
+ .';'.$langs->transnoentities('ObjectId')
+ .';'.$langs->transnoentities('Date')
+ .';'.$langs->transnoentities('Ref')
+ .';'.$langs->transnoentities('Fingerprint')
+ .';'.$langs->transnoentities('User')."\n";
+
+ while($obj = $db->fetch_object($res)) {
+
+ print $obj->rowid
+ .';'.$obj->tms
+ .';'.$obj->action
+ .';'.$obj->amounts
+ .';'.$obj->element
+ .';'.$obj->fk_object
+ .';'.$obj->date_object
+ .';'.$obj->ref_object
+ .';'.$obj->signature
+ .';'.$obj->fk_user."\n";
+
+ }
+
+ exit;
+ }
+ else{
+ setEventMessage($db->lasterror, 'errors');
+ }
+
+}
/*
* View
*/
-$block_static = new BlockedLog($db);
-
$blocks = $block_static->getLog('all', 0, GETPOST('all') ? 0 : 50);
$form=new Form($db);
@@ -74,8 +120,13 @@ print $langs->trans("FingerprintsDesc")."
\n";
print '
';
-echo '
';
-
+print '';
+
print '';
print '';
@@ -92,24 +143,30 @@ print ' | ';
print '
';
foreach($blocks as &$block) {
+
+ $checksignature = $block->checkSignature();
+ $object_link = $block->getObjectLink();
- print '';
- print '| '.dol_print_date($block->tms,'dayhour').' | ';
- print ''.$block->ref_object.' | ';
- print ''.$langs->trans('log'.$block->action).' | ';
- print ''.$block->getObject().''.img_info($langs->trans('ShowDetails')).' | ';
- print ''.price($block->amounts).' | ';
- print ''.$block->getUser().' | ';
- print ''.$block->signature.' | ';
- print '';
-
- print $block->checkSignature() ? 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)) {
- print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') );
- }
- print ' | ';
- print '
';
-
+ if(!$showonlyerrors || $block->error>0) {
+
+ print '';
+ print '| '.dol_print_date($block->tms,'dayhour').' | ';
+ print ''.$block->ref_object.' | ';
+ print ''.$langs->trans('log'.$block->action).' | ';
+ print ''.$object_link.''.img_info($langs->trans('ShowDetails')).' | ';
+ print ''.price($block->amounts).' | ';
+ print ''.$block->getUser().' | ';
+ print ''.$block->signature.' | ';
+ print '';
+
+ 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)) {
+ print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') );
+ }
+ print ' | ';
+ print '
';
+
+ }
}
print '
';
@@ -121,7 +178,7 @@ $('a[rel=show-info]').click(function() {
$pop = $('| trans('Field') ?> | trans('Value') ?> |
');
$pop.dialog({
- title:"trans('BlockedlogInfoDialog'); ?>"
+ title:"transnoentities('BlockedlogInfoDialog'); ?>"
,modal:true
,width:'80%'
});
diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php
index 1f93eb3cc26..b0cddd66f75 100644
--- a/htdocs/blockedlog/class/blockedlog.class.php
+++ b/htdocs/blockedlog/class/blockedlog.class.php
@@ -78,6 +78,7 @@ class BlockedLog
public $object_data = null;
+ public $error = 0;
/**
* Constructor
@@ -91,9 +92,9 @@ class BlockedLog
}
/**
- * try to retrieve logged object
+ * try to retrieve logged object link
*/
- public function getObject() {
+ public function getObjectLink() {
global $langs;
if($this->element === 'facture') {
@@ -103,6 +104,9 @@ class BlockedLog
if($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
+ else{
+ $this->error++;
+ }
}
else if($this->element === 'payment') {
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
@@ -111,6 +115,9 @@ class BlockedLog
if($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
+ else{
+ $this->error++;
+ }
}
return $langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object);
@@ -388,8 +395,13 @@ class BlockedLog
$this->getSignatureRecursive();
- return ($signature_to_test=== $this->signature);
+ $res = ($signature_to_test === $this->signature);
+ if(!$res) {
+ $this->error++;
+ }
+
+ return $res;
}
/**
@@ -490,8 +502,7 @@ class BlockedLog
*/
private function getCurrentValue() {
- if($this->action === 'PAYMENT_CUSTOMER_CREATE'
- || $this->action === 'PAYMENT_ADD_TO_BANK') {
+ if($this->element === 'payment') {
$sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiement WHERE rowid=".$this->fk_object;
$res = $this->db->query($sql);
@@ -500,7 +511,15 @@ class BlockedLog
$this->amounts = (double) $obj->amount;
}
}
-
+ elseif($this->element === 'facture') {
+ $sql="SELECT total_ttc FROM ".MAIN_DB_PREFIX."facture WHERE rowid=".$this->fk_object;
+
+ $res = $this->db->query($sql);
+ if($res && $obj = $this->db->fetch_object($res)) {
+ $this->amounts = (double) $obj->total_ttc;
+ }
+ }
+
}
/**
diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
index 5a52777cbb9..461a277dfd4 100644
--- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
+++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
@@ -51,7 +51,7 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
return 0;
}
- if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED') {
+ if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED' || $action === 'BILL_SENTBYMAIL') {
$amounts= (double) $object->total_ttc;
}
else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') {
diff --git a/htdocs/langs/en_US/blockedlog.lang b/htdocs/langs/en_US/blockedlog.lang
index 995801292a3..7e64bfad17f 100644
--- a/htdocs/langs/en_US/blockedlog.lang
+++ b/htdocs/langs/en_US/blockedlog.lang
@@ -3,6 +3,7 @@ BlockedLogDesc=This module store event for invoice and payments as block chain
FingerprintsDesc=All fingerprints stored
EntityKey=Entity Key
ShowAllFingerPrintsMightBeTooLong=Show all fingerprints (might be long)
+ShowAllFingerPrintsErrorsMightBeTooLong=Show all fingerprints with error (might be long)
DownloadBlockChain=Download fingerprints
KoCheckFingerprintValidity=Fingerprint is not valid
OkCheckFingerprintValidity=Fingerprint is valid
@@ -14,3 +15,7 @@ logPAYMENT_CUSTOMER_CREATE=Payment of customer created
logBILL_PAYED=Customer bill payed
logBILL_UNPAYED=Customer bill set unpayed
logBILL_VALIDATE=Customer bill set valid from draft
+logBILL_SENTBYMAIL=Customer bill send by mail
+BlockedlogInfoDialog=Log Details
+Fingerprint=Fingerprint
+DownloadLogCSV=Download fingerprints CSV
\ No newline at end of file