Standardize and debug code of module BlockedLog
This commit is contained in:
parent
26e80045a6
commit
1c8daf9700
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -31,12 +31,13 @@ $langs->load("other");
|
|||||||
$langs->load("blockedlog");
|
$langs->load("blockedlog");
|
||||||
|
|
||||||
if (! $user->admin) accessforbidden();
|
if (! $user->admin) accessforbidden();
|
||||||
|
|
||||||
$action = GETPOST('action','alpha');
|
$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].'>';
|
||||||
|
|||||||
@ -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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -32,39 +32,39 @@ $langs->load("other");
|
|||||||
$langs->load("blockedlog");
|
$langs->load("blockedlog");
|
||||||
|
|
||||||
if (! $user->admin) accessforbidden();
|
if (! $user->admin) accessforbidden();
|
||||||
|
|
||||||
$action = GETPOST('action','alpha');
|
$action = GETPOST('action','alpha');
|
||||||
$showonlyerrors = GETPOST('showonlyerrors','int');
|
$showonlyerrors = GETPOST('showonlyerrors','int');
|
||||||
|
|
||||||
$block_static = new BlockedLog($db);
|
$block_static = new BlockedLog($db);
|
||||||
|
|
||||||
if($action === 'downloadblockchain') {
|
if($action === 'downloadblockchain') {
|
||||||
|
|
||||||
$auth = new BlockedLogAuthority($db);
|
$auth = new BlockedLogAuthority($db);
|
||||||
|
|
||||||
$bc = $auth->getLocalBlockChain();
|
$bc = $auth->getLocalBlockChain();
|
||||||
|
|
||||||
header('Content-Type: application/octet-stream');
|
header('Content-Type: application/octet-stream');
|
||||||
header("Content-Transfer-Encoding: Binary");
|
header("Content-Transfer-Encoding: Binary");
|
||||||
header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\"");
|
header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\"");
|
||||||
|
|
||||||
echo $bc;
|
echo $bc;
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else if($action === 'downloadcsv') {
|
else if($action === 'downloadcsv') {
|
||||||
|
|
||||||
$res = $db->query("SELECT rowid,tms,action,amounts,element,fk_object,date_object,ref_object,signature,fk_user
|
$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");
|
FROM ".MAIN_DB_PREFIX."blockedlog ORDER BY rowid ASC");
|
||||||
|
|
||||||
if($res) {
|
if($res) {
|
||||||
|
|
||||||
$signature = $block_static->getSignature();
|
$signature = $block_static->getSignature();
|
||||||
|
|
||||||
header('Content-Type: application/octet-stream');
|
header('Content-Type: application/octet-stream');
|
||||||
header("Content-Transfer-Encoding: Binary");
|
header("Content-Transfer-Encoding: Binary");
|
||||||
header("Content-disposition: attachment; filename=\"" .$signature. ".csv\"");
|
header("Content-disposition: attachment; filename=\"" .$signature. ".csv\"");
|
||||||
|
|
||||||
print $langs->transnoentities('Id')
|
print $langs->transnoentities('Id')
|
||||||
.';'.$langs->transnoentities('Timestamp')
|
.';'.$langs->transnoentities('Timestamp')
|
||||||
.';'.$langs->transnoentities('Action')
|
.';'.$langs->transnoentities('Action')
|
||||||
@ -75,9 +75,9 @@ else if($action === 'downloadcsv') {
|
|||||||
.';'.$langs->transnoentities('Ref')
|
.';'.$langs->transnoentities('Ref')
|
||||||
.';'.$langs->transnoentities('Fingerprint')
|
.';'.$langs->transnoentities('Fingerprint')
|
||||||
.';'.$langs->transnoentities('User')."\n";
|
.';'.$langs->transnoentities('User')."\n";
|
||||||
|
|
||||||
while($obj = $db->fetch_object($res)) {
|
while($obj = $db->fetch_object($res)) {
|
||||||
|
|
||||||
print $obj->rowid
|
print $obj->rowid
|
||||||
.';'.$obj->tms
|
.';'.$obj->tms
|
||||||
.';'.$obj->action
|
.';'.$obj->action
|
||||||
@ -88,15 +88,15 @@ else if($action === 'downloadcsv') {
|
|||||||
.';'.$obj->ref_object
|
.';'.$obj->ref_object
|
||||||
.';'.$obj->signature
|
.';'.$obj->signature
|
||||||
.';'.$obj->fk_user."\n";
|
.';'.$obj->fk_user."\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
setEventMessage($db->lasterror, 'errors');
|
setEventMessage($db->lasterror, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -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,52 +131,63 @@ 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>';
|
||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
foreach($blocks as &$block) {
|
foreach($blocks as &$block) {
|
||||||
|
|
||||||
$checksignature = $block->checkSignature();
|
$checksignature = $block->checkSignature();
|
||||||
$object_link = $block->getObjectLink();
|
$object_link = $block->getObjectLink();
|
||||||
|
|
||||||
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>'.$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 '<td>';
|
||||||
|
print $form->textwithpicto(dol_trunc($block->signature, '12'), $block->signature);
|
||||||
print $block->error == 0 ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'on') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'off');
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
print $block->error == 0 ? img_picto($langs->trans('OkCheckFingerprintValidity'), 'tick') : img_picto($langs->trans('KoCheckFingerprintValidity'), 'statut8');
|
||||||
|
|
||||||
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>';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$('a[rel=show-info]').click(function() {
|
$('a[rel=show-info]').click(function() {
|
||||||
|
|
||||||
$pop = $('<div id="pop-info"><table width="100%" class="border"><thead><th width="25%"><?php echo $langs->trans('Field') ?></th><th><?php echo $langs->trans('Value') ?></th></thead><tbody></tbody></table></div>');
|
$pop = $('<div id="pop-info"><table width="100%" class="border"><thead><th width="25%"><?php echo $langs->trans('Field') ?></th><th><?php echo $langs->trans('Value') ?></th></thead><tbody></tbody></table></div>');
|
||||||
|
|
||||||
$pop.dialog({
|
$pop.dialog({
|
||||||
title:"<?php echo $langs->transnoentities('BlockedlogInfoDialog'); ?>"
|
title:"<?php echo $langs->transnoentities('BlockedlogInfoDialog'); ?>"
|
||||||
,modal:true
|
,modal:true
|
||||||
@ -184,16 +195,16 @@ $('a[rel=show-info]').click(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var fk_block = $(this).attr("blockid");
|
var fk_block = $(this).attr("blockid");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url:"../ajax/block-info.php?id="+fk_block
|
url:"../ajax/block-info.php?id="+fk_block
|
||||||
,dataType:'json'
|
,dataType:'json'
|
||||||
}).done(function(data) {
|
}).done(function(data) {
|
||||||
|
|
||||||
drawData(data,'');
|
drawData(data,'');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function drawData(data, prefix) {
|
function drawData(data, prefix) {
|
||||||
@ -203,41 +214,41 @@ function drawData(data, prefix) {
|
|||||||
value = data[x];
|
value = data[x];
|
||||||
|
|
||||||
$('#pop-info table tbody').append('<tr><td>'+prefix+x+'</td><td>'+value+'</td></tr>');
|
$('#pop-info table tbody').append('<tr><td>'+prefix+x+'</td><td>'+value+'</td></tr>');
|
||||||
|
|
||||||
if( (typeof value === "object") && (value !== null) ) {
|
if( (typeof value === "object") && (value !== null) ) {
|
||||||
drawData(value, prefix+x+' >> ');
|
drawData(value, prefix+x+' >> ');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
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)) {
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url : "<?php echo dol_buildpath('/blockedlog/ajax/check_signature.php',1) ?>"
|
url : "<?php echo dol_buildpath('/blockedlog/ajax/check_signature.php',1) ?>"
|
||||||
,dataType:"html"
|
,dataType:"html"
|
||||||
}).done(function(data) {
|
}).done(function(data) {
|
||||||
|
|
||||||
if(data == 'hashisok') {
|
if(data == 'hashisok') {
|
||||||
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity'). ' '. img_picto($langs->trans('SignatureOK'), 'on') ?>');
|
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityReconizeFingerprintConformity'). ' '. img_picto($langs->trans('SignatureOK'), 'on') ?>');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity'). ' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
|
$('#blockchainstatus').html('<?php echo $langs->trans('AuthorityDidntReconizeFingerprintConformity'). ' '.img_picto($langs->trans('SignatureKO'), 'off') ?>');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,45 +1,77 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
require '../../master.inc.php';
|
* Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
|
||||||
|
*
|
||||||
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
|
* This program is free software; you can redistribute it and/or modify
|
||||||
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
$user=new User($db);
|
/**
|
||||||
$user->fetch(1); //TODO conf user authority
|
* \file htdocs/blockedlog/ajax/authority.php
|
||||||
|
* \ingroup blockedlog
|
||||||
$auth = new BlockedLogAuthority($db);
|
* \brief authority
|
||||||
|
*/
|
||||||
$signature = GETPOST('s');
|
|
||||||
$newblock = GETPOST('b');
|
|
||||||
$hash = GETPOST('h');
|
// This script is called with a POST method.
|
||||||
|
// Directory to scan (full path) is inside POST['dir'].
|
||||||
if($auth->fetch(0, $signature)<=0) {
|
|
||||||
$auth->signature = $signature;
|
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
|
||||||
$auth->create($user);
|
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||||
}
|
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||||
|
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||||
|
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||||
if(!empty($hash)) {
|
|
||||||
|
$res=require '../../master.inc.php';
|
||||||
echo $auth->checkBlockchain($hash) ? 'hashisok' : 'hashisjunk';
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
|
||||||
}
|
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
|
||||||
elseif(!empty($newblock)){
|
|
||||||
if($auth->checkBlock($newblock)) {
|
$user=new User($db);
|
||||||
$auth->addBlock($newblock);
|
$user->fetch(1); //TODO conf user authority
|
||||||
$auth->update($user);
|
|
||||||
|
$auth = new BlockedLogAuthority($db);
|
||||||
echo 'blockadded';
|
|
||||||
}
|
$signature = GETPOST('s');
|
||||||
else{
|
$newblock = GETPOST('b');
|
||||||
|
$hash = GETPOST('h');
|
||||||
echo 'blockalreadyadded';
|
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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
|
||||||
$id = GETPOST('id','int');
|
* \brief Block-add
|
||||||
$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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -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
|
||||||
$id = GETPOST('id');
|
* \brief block-info
|
||||||
|
*/
|
||||||
$block = new BlockedLog($db);
|
|
||||||
if($block->fetch($id)>0) {
|
|
||||||
echo json_encode($block->object_data);
|
// This script is called with a POST method.
|
||||||
}
|
// Directory to scan (full path) is inside POST['dir'].
|
||||||
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);
|
||||||
|
}
|
||||||
|
|||||||
@ -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';
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
|
|
||||||
|
|
||||||
$auth=new BlockedLogAuthority($db);
|
|
||||||
$auth->syncSignatureWithAuthority();
|
|
||||||
|
|
||||||
$block_static = new BlockedLog($db);
|
|
||||||
|
|
||||||
$blocks = $block_static->getLog('just_certified', 0, 0, 1) ;
|
|
||||||
|
|
||||||
$auth->signature = $block_static->getSignature();
|
// This script is called with a POST method.
|
||||||
|
// Directory to scan (full path) is inside POST['dir'].
|
||||||
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);
|
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
|
||||||
//echo $url;
|
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||||
echo $res;
|
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||||
|
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||||
|
//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||||
|
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
|
||||||
|
if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) exit('BLOCKEDLOG_AUTHORITY_URL not set');
|
||||||
|
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
|
||||||
|
|
||||||
|
$auth=new BlockedLogAuthority($db);
|
||||||
|
$auth->syncSignatureWithAuthority();
|
||||||
|
|
||||||
|
$block_static = new BlockedLog($db);
|
||||||
|
|
||||||
|
$blocks = $block_static->getLog('just_certified', 0, 0, 1) ;
|
||||||
|
|
||||||
|
$auth->signature = $block_static->getSignature();
|
||||||
|
|
||||||
|
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;
|
||||||
@ -21,65 +21,65 @@
|
|||||||
|
|
||||||
class BlockedLog
|
class BlockedLog
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Id of the log
|
* Id of the log
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $id;
|
public $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unique fingerprint of the log
|
* Unique fingerprint of the log
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $signature = '';
|
public $signature = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unique fingerprint of the line log content
|
* Unique fingerprint of the line log content
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $signature_line = '';
|
public $signature_line = '';
|
||||||
|
|
||||||
public $amounts = null;
|
public $amounts = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* trigger action
|
* trigger action
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $action = '';
|
public $action = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object element
|
* Object element
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
public $element = '';
|
public $element = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object id
|
* Object id
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $fk_object = 0;
|
public $fk_object = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log certified by remote authority or not
|
* Log certified by remote authority or not
|
||||||
* @var boolean
|
* @var boolean
|
||||||
*/
|
*/
|
||||||
public $certified = false;
|
public $certified = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author
|
* Author
|
||||||
* @var int
|
* @var int
|
||||||
*/
|
*/
|
||||||
public $fk_user = 0;
|
public $fk_user = 0;
|
||||||
|
|
||||||
public $date_object = 0;
|
public $date_object = 0;
|
||||||
|
|
||||||
public $ref_object = '';
|
public $ref_object = '';
|
||||||
|
|
||||||
public $object_data = null;
|
public $object_data = null;
|
||||||
|
|
||||||
public $error = 0;
|
public $error = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
@ -88,7 +88,7 @@ class BlockedLog
|
|||||||
public function __construct(DoliDB $db)
|
public function __construct(DoliDB $db)
|
||||||
{
|
{
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -96,10 +96,10 @@ class BlockedLog
|
|||||||
*/
|
*/
|
||||||
public function getObjectLink() {
|
public function getObjectLink() {
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
if($this->element === 'facture') {
|
if($this->element === 'facture') {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
|
|
||||||
$object = new Facture($this->db);
|
$object = new Facture($this->db);
|
||||||
if($object->fetch($this->fk_object)>0) {
|
if($object->fetch($this->fk_object)>0) {
|
||||||
return $object->getNomUrl(1);
|
return $object->getNomUrl(1);
|
||||||
@ -110,7 +110,7 @@ class BlockedLog
|
|||||||
}
|
}
|
||||||
else if($this->element === 'payment') {
|
else if($this->element === 'payment') {
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||||
|
|
||||||
$object = new Paiement($this->db);
|
$object = new Paiement($this->db);
|
||||||
if($object->fetch($this->fk_object)>0) {
|
if($object->fetch($this->fk_object)>0) {
|
||||||
return $object->getNomUrl(1);
|
return $object->getNomUrl(1);
|
||||||
@ -119,61 +119,61 @@ class BlockedLog
|
|||||||
$this->error++;
|
$this->error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object);
|
return $langs->trans('ImpossibleToReloadObject', $this->element, $this->fk_object);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* try to retrieve user author
|
* try to retrieve user author
|
||||||
*/
|
*/
|
||||||
public function getUser() {
|
public function getUser() {
|
||||||
global $langs, $cachedUser;
|
global $langs, $cachedUser;
|
||||||
|
|
||||||
if(empty($cachedUser))$cachedUser=array();
|
if(empty($cachedUser))$cachedUser=array();
|
||||||
|
|
||||||
if(empty($cachedUser[$this->fk_user])) {
|
if(empty($cachedUser[$this->fk_user])) {
|
||||||
$u=new User($this->db);
|
$u=new User($this->db);
|
||||||
if($u->fetch($this->fk_user)>0) {
|
if($u->fetch($this->fk_user)>0) {
|
||||||
$cachedUser[$this->fk_user] = $u;
|
$cachedUser[$this->fk_user] = $u;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($cachedUser[$this->fk_user])) {
|
if(!empty($cachedUser[$this->fk_user])) {
|
||||||
return $cachedUser[$this->fk_user]->getNomUrl(1);
|
return $cachedUser[$this->fk_user]->getNomUrl(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $langs->trans('ImpossibleToRetrieveUser', $this->fk_user);
|
return $langs->trans('ImpossibleToRetrieveUser', $this->fk_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* populate log by object
|
* populate log by object
|
||||||
*
|
*
|
||||||
* @param payment|facture $object object to store
|
* @param payment|facture $object object to store
|
||||||
*/
|
*/
|
||||||
public function setObjectData(&$object) {
|
public function setObjectData(&$object) {
|
||||||
|
|
||||||
if($object->element=='payment') {
|
if($object->element=='payment') {
|
||||||
$this->date_object = $object->datepaye;
|
$this->date_object = $object->datepaye;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$this->date_object = $object->date;
|
$this->date_object = $object->date;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->ref_object = $object->ref;
|
$this->ref_object = $object->ref;
|
||||||
$this->element = $object->element;
|
$this->element = $object->element;
|
||||||
$this->fk_object = $object->id;
|
$this->fk_object = $object->id;
|
||||||
|
|
||||||
$this->object_data=new stdClass();
|
$this->object_data=new stdClass();
|
||||||
|
|
||||||
if($this->element === 'facture') {
|
if($this->element === 'facture') {
|
||||||
if(empty($object->thirdparty))$object->fetch_thirdparty();
|
if(empty($object->thirdparty))$object->fetch_thirdparty();
|
||||||
$this->object_data->thirdparty = new stdClass();
|
$this->object_data->thirdparty = new stdClass();
|
||||||
|
|
||||||
foreach($object->thirdparty as $key=>$value) {
|
foreach($object->thirdparty as $key=>$value) {
|
||||||
if(!is_object($value)) $this->object_data->thirdparty->{$key} = $value;
|
if(!is_object($value)) $this->object_data->thirdparty->{$key} = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->object_data->total_ht = (double) $object->total_ht;
|
$this->object_data->total_ht = (double) $object->total_ht;
|
||||||
$this->object_data->total_tva = (double) $object->total_tva;
|
$this->object_data->total_tva = (double) $object->total_tva;
|
||||||
$this->object_data->total_ttc = (double) $object->total_ttc;
|
$this->object_data->total_ttc = (double) $object->total_ttc;
|
||||||
@ -181,17 +181,17 @@ class BlockedLog
|
|||||||
$this->object_data->total_localtax2= (double) $object->total_localtax2;
|
$this->object_data->total_localtax2= (double) $object->total_localtax2;
|
||||||
$this->object_data->note_public = (double) $object->note_public;
|
$this->object_data->note_public = (double) $object->note_public;
|
||||||
$this->object_data->note_private= (double) $object->note_private;
|
$this->object_data->note_private= (double) $object->note_private;
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif($this->element==='payment'){
|
elseif($this->element==='payment'){
|
||||||
|
|
||||||
$this->object_data->amounts = $object->amounts;
|
$this->object_data->amounts = $object->amounts;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get object from database
|
* Get object from database
|
||||||
*
|
*
|
||||||
@ -199,50 +199,50 @@ class BlockedLog
|
|||||||
* @return int >0 if OK, <0 if KO, 0 if not found
|
* @return int >0 if OK, <0 if KO, 0 if not found
|
||||||
*/
|
*/
|
||||||
public function fetch($id) {
|
public function fetch($id) {
|
||||||
|
|
||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch id=".$id, LOG_DEBUG);
|
||||||
|
|
||||||
if (empty($id))
|
if (empty($id))
|
||||||
{
|
{
|
||||||
$this->error='BadParameter';
|
$this->error='BadParameter';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$langs->load("blockedlog");
|
$langs->load("blockedlog");
|
||||||
|
|
||||||
$sql = "SELECT b.rowid, b.signature, b.amounts, b.action, b.element, b.fk_object, b.certified, b.tms, b.fk_user, b.date_object, b.ref_object, b.object_data";
|
$sql = "SELECT b.rowid, b.signature, b.amounts, b.action, b.element, b.fk_object, b.certified, b.tms, b.fk_user, b.date_object, b.ref_object, b.object_data";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog as b";
|
$sql.= " FROM ".MAIN_DB_PREFIX."blockedlog as b";
|
||||||
if ($id) $sql.= " WHERE b.rowid = ". $id;
|
if ($id) $sql.= " WHERE b.rowid = ". $id;
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
if ($this->db->num_rows($resql))
|
if ($this->db->num_rows($resql))
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
$this->ref = $obj->rowid;
|
$this->ref = $obj->rowid;
|
||||||
|
|
||||||
$this->signature = $obj->signature;
|
$this->signature = $obj->signature;
|
||||||
$this->amounts = (double) $obj->amounts;
|
$this->amounts = (double) $obj->amounts;
|
||||||
$this->action = $obj->action;
|
$this->action = $obj->action;
|
||||||
$this->element = $obj->element;
|
$this->element = $obj->element;
|
||||||
|
|
||||||
$this->fk_object = trim($obj->fk_object);
|
$this->fk_object = trim($obj->fk_object);
|
||||||
$this->date_object = $this->db->jdate($obj->date_object);
|
$this->date_object = $this->db->jdate($obj->date_object);
|
||||||
$this->ref_object = $obj->ref_object;
|
$this->ref_object = $obj->ref_object;
|
||||||
|
|
||||||
$this->certified = ($obj->certified == 1);
|
$this->certified = ($obj->certified == 1);
|
||||||
|
|
||||||
$this->fk_user = $obj->fk_user;
|
$this->fk_user = $obj->fk_user;
|
||||||
|
|
||||||
$this->tms = $this->db->jdate($obj->tms);
|
$this->tms = $this->db->jdate($obj->tms);
|
||||||
|
|
||||||
$this->object_data = unserialize($obj->object_data);
|
$this->object_data = unserialize($obj->object_data);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -256,24 +256,24 @@ class BlockedLog
|
|||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set block certified by authority
|
* Set block certified by authority
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function setCertified() {
|
public function setCertified() {
|
||||||
|
|
||||||
$res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id);
|
$res = $this->db->query("UPDATE ".MAIN_DB_PREFIX."blockedlog SET certified=1 WHERE rowid=".$this->id);
|
||||||
if($res===false) return false;
|
if($res===false) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create blocked log in database.
|
* Create blocked log in database.
|
||||||
*
|
*
|
||||||
@ -281,31 +281,31 @@ class BlockedLog
|
|||||||
* @return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
public function create($user) {
|
public function create($user) {
|
||||||
|
|
||||||
global $conf,$langs,$hookmanager;
|
global $conf,$langs,$hookmanager;
|
||||||
|
|
||||||
$langs->load('blockedlog');
|
$langs->load('blockedlog');
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
dol_syslog(get_class($this).'::create', LOG_DEBUG);
|
dol_syslog(get_class($this).'::create', LOG_DEBUG);
|
||||||
|
|
||||||
$this->getSignatureRecursive();
|
$this->getSignatureRecursive();
|
||||||
|
|
||||||
|
|
||||||
if (is_null($this->amounts))
|
if (is_null($this->amounts))
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("BlockLogNeedAmountsValue");
|
$this->error=$langs->trans("BlockLogNeedAmountsValue");
|
||||||
dol_syslog($this->error, LOG_WARNING);
|
dol_syslog($this->error, LOG_WARNING);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($this->element)) {
|
if(empty($this->element)) {
|
||||||
$this->error=$langs->trans("BlockLogNeedElement");
|
$this->error=$langs->trans("BlockLogNeedElement");
|
||||||
dol_syslog($this->error, LOG_WARNING);
|
dol_syslog($this->error, LOG_WARNING);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(empty($this->action)) {
|
if(empty($this->action)) {
|
||||||
$this->error=$langs->trans("BlockLogNeedAction");
|
$this->error=$langs->trans("BlockLogNeedAction");
|
||||||
dol_syslog($this->error, LOG_WARNING);
|
dol_syslog($this->error, LOG_WARNING);
|
||||||
@ -313,9 +313,9 @@ class BlockedLog
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->fk_user = $user->id;
|
$this->fk_user = $user->id;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog (";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."blockedlog (";
|
||||||
$sql.= "action,";
|
$sql.= "action,";
|
||||||
$sql.= " amounts,";
|
$sql.= " amounts,";
|
||||||
@ -343,18 +343,18 @@ class BlockedLog
|
|||||||
$sql.= "".$user->id.",";
|
$sql.= "".$user->id.",";
|
||||||
$sql.= $conf->entity;
|
$sql.= $conf->entity;
|
||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
$res = $this->db->query($sql);
|
$res = $this->db->query($sql);
|
||||||
if ($res)
|
if ($res)
|
||||||
{
|
{
|
||||||
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog");
|
$id = $this->db->last_insert_id(MAIN_DB_PREFIX."blockedlog");
|
||||||
|
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|
||||||
return $this->id;
|
return $this->id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -369,9 +369,9 @@ class BlockedLog
|
|||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return crypted value.
|
* return crypted value.
|
||||||
*
|
*
|
||||||
@ -379,56 +379,56 @@ class BlockedLog
|
|||||||
* @return string crypted string
|
* @return string crypted string
|
||||||
*/
|
*/
|
||||||
private function crypt($value) {
|
private function crypt($value) {
|
||||||
|
|
||||||
return hash('sha256',$value);
|
return hash('sha256',$value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if current signature still correct compare to the chain
|
* check if current signature still correct compare to the chain
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function checkSignature() {
|
public function checkSignature() {
|
||||||
|
|
||||||
$signature_to_test = $this->signature;
|
$signature_to_test = $this->signature;
|
||||||
|
|
||||||
$this->getSignatureRecursive();
|
$this->getSignatureRecursive();
|
||||||
|
|
||||||
$res = ($signature_to_test === $this->signature);
|
$res = ($signature_to_test === $this->signature);
|
||||||
|
|
||||||
if(!$res) {
|
if(!$res) {
|
||||||
$this->error++;
|
$this->error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set current signatures
|
* set current signatures
|
||||||
*/
|
*/
|
||||||
private function getSignatureRecursive(){
|
private function getSignatureRecursive(){
|
||||||
|
|
||||||
$this->signature_line = $this->crypt( $this->action . $this->getSignature() . $this->amounts . print_r($this->object_data, true) );
|
$this->signature_line = $this->crypt( $this->action . $this->getSignature() . $this->amounts . print_r($this->object_data, true) );
|
||||||
/*if($this->signature=='d6320580a02c1ab67fcc0a6d49d453c7d96dda0148901736f7f55725bfe1b900' || $this->signature=='ea65d435ff12ca929936a406aa9d707d99fb334c127878d256b602a5541bbbc9') {
|
/*if($this->signature=='d6320580a02c1ab67fcc0a6d49d453c7d96dda0148901736f7f55725bfe1b900' || $this->signature=='ea65d435ff12ca929936a406aa9d707d99fb334c127878d256b602a5541bbbc9') {
|
||||||
var_dump($this->signature_line,$this->action ,$this->getSignature() , $this->amounts , $this->object_data);
|
var_dump($this->signature_line,$this->action ,$this->getSignature() , $this->amounts , $this->object_data);
|
||||||
}*/
|
}*/
|
||||||
$this->signature = $this->signature_line;
|
$this->signature = $this->signature_line;
|
||||||
|
|
||||||
$logs = $this->getLog('all', 0, 0, 1) ;
|
$logs = $this->getLog('all', 0, 0, 1) ;
|
||||||
if($logs!==false) {
|
if($logs!==false) {
|
||||||
foreach($logs as &$b) {
|
foreach($logs as &$b) {
|
||||||
|
|
||||||
if($this->id>0 && $b->id == $this->id) break; // on arrête sur un enregistrement précis pour recalculer une signature
|
if($this->id>0 && $b->id == $this->id) break; // on arrête sur un enregistrement précis pour recalculer une signature
|
||||||
|
|
||||||
$b->getCurrentValue(); // on récupère la valeur actuelle en base de l'élément enregistré
|
$b->getCurrentValue(); // on récupère la valeur actuelle en base de l'élément enregistré
|
||||||
|
|
||||||
$this->signature = $this->crypt($this->signature. $this->action . $b->signature . $b->amounts);
|
$this->signature = $this->crypt($this->signature. $this->action . $b->signature . $b->amounts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return log object for a element.
|
* return log object for a element.
|
||||||
*
|
*
|
||||||
@ -439,110 +439,110 @@ class BlockedLog
|
|||||||
* @return array array of object log
|
* @return array array of object log
|
||||||
*/
|
*/
|
||||||
public function getLog($element, $fk_object, $limit = 0, $order = -1) {
|
public function getLog($element, $fk_object, $limit = 0, $order = -1) {
|
||||||
global $conf,$cachedlogs ;
|
global $conf,$cachedlogs ;
|
||||||
|
|
||||||
/* $cachedlogs allow fastest search */
|
/* $cachedlogs allow fastest search */
|
||||||
if(empty($cachedlogs)) $cachedlogs=array();
|
if(empty($cachedlogs)) $cachedlogs=array();
|
||||||
|
|
||||||
|
|
||||||
if($element=='all') {
|
if($element=='all') {
|
||||||
|
|
||||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||||
WHERE entity=".$conf->entity;
|
WHERE entity=".$conf->entity;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if($element=='not_certified') {
|
else if($element=='not_certified') {
|
||||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||||
WHERE entity=".$conf->entity." AND certified = 0";
|
WHERE entity=".$conf->entity." AND certified = 0";
|
||||||
|
|
||||||
}
|
}
|
||||||
else if($element=='just_certified') {
|
else if($element=='just_certified') {
|
||||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||||
WHERE entity=".$conf->entity." AND certified = 1";
|
WHERE entity=".$conf->entity." AND certified = 1";
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
$sql="SELECT rowid FROM ".MAIN_DB_PREFIX."blockedlog
|
||||||
WHERE element='".$element."' AND fk_object=".(int) $fk_object;
|
WHERE element='".$element."' AND fk_object=".(int) $fk_object;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql.=($order<0 ? ' ORDER BY rowid DESC ' : ' ORDER BY rowid ASC ');
|
$sql.=($order<0 ? ' ORDER BY rowid DESC ' : ' ORDER BY rowid ASC ');
|
||||||
|
|
||||||
if($limit > 0 )$sql.=' LIMIT '.$limit;
|
if($limit > 0 )$sql.=' LIMIT '.$limit;
|
||||||
|
|
||||||
$res = $this->db->query($sql);
|
$res = $this->db->query($sql);
|
||||||
|
|
||||||
if($res) {
|
if($res) {
|
||||||
|
|
||||||
$results=array();
|
$results=array();
|
||||||
|
|
||||||
while($obj = $this->db->fetch_object($res)) {
|
while($obj = $this->db->fetch_object($res)) {
|
||||||
|
|
||||||
if(!isset($cachedlogs[$obj->rowid])) {
|
if(!isset($cachedlogs[$obj->rowid])) {
|
||||||
$b=new BlockedLog($this->db);
|
$b=new BlockedLog($this->db);
|
||||||
$b->fetch($obj->rowid);
|
$b->fetch($obj->rowid);
|
||||||
|
|
||||||
$cachedlogs[$obj->rowid] = $b;
|
$cachedlogs[$obj->rowid] = $b;
|
||||||
}
|
}
|
||||||
|
|
||||||
$results[] = $cachedlogs[$obj->rowid];
|
$results[] = $cachedlogs[$obj->rowid];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set amounts of log from current element value in order to compare signature.
|
* set amounts of log from current element value in order to compare signature.
|
||||||
*/
|
*/
|
||||||
private function getCurrentValue() {
|
private function getCurrentValue() {
|
||||||
|
|
||||||
if($this->element === 'payment') {
|
if($this->element === 'payment') {
|
||||||
$sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiement WHERE rowid=".$this->fk_object;
|
$sql="SELECT amount FROM ".MAIN_DB_PREFIX."paiement WHERE rowid=".$this->fk_object;
|
||||||
|
|
||||||
$res = $this->db->query($sql);
|
$res = $this->db->query($sql);
|
||||||
|
|
||||||
if($res && $obj = $this->db->fetch_object($res)) {
|
if($res && $obj = $this->db->fetch_object($res)) {
|
||||||
$this->amounts = (double) $obj->amount;
|
$this->amounts = (double) $obj->amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif($this->element === 'facture') {
|
elseif($this->element === 'facture') {
|
||||||
$sql="SELECT total_ttc FROM ".MAIN_DB_PREFIX."facture WHERE rowid=".$this->fk_object;
|
$sql="SELECT total_ttc FROM ".MAIN_DB_PREFIX."facture WHERE rowid=".$this->fk_object;
|
||||||
|
|
||||||
$res = $this->db->query($sql);
|
$res = $this->db->query($sql);
|
||||||
if($res && $obj = $this->db->fetch_object($res)) {
|
if($res && $obj = $this->db->fetch_object($res)) {
|
||||||
$this->amounts = (double) $obj->total_ttc;
|
$this->amounts = (double) $obj->total_ttc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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';
|
||||||
|
|
||||||
$fingerprint = $this->crypt(print_r($mysoc,true).time().rand(0,1000));
|
$fingerprint = $this->crypt(print_r($mysoc,true).time().rand(0,1000));
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -32,17 +32,17 @@ function blockedlogadmin_prepare_head()
|
|||||||
|
|
||||||
$h = 0;
|
$h = 0;
|
||||||
$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++;
|
||||||
|
|
||||||
$head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/fingerprints.php";
|
$head[$h][0] = DOL_URL_ROOT."/blockedlog/admin/fingerprints.php";
|
||||||
$head[$h][1] = $langs->trans("Fingerprints");
|
$head[$h][1] = $langs->trans("Fingerprints");
|
||||||
$head[$h][2] = 'fingerprints';
|
$head[$h][2] = 'fingerprints';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
$object=new stdClass();
|
$object=new stdClass();
|
||||||
|
|
||||||
// Show more tabs from modules
|
// Show more tabs from modules
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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';
|
||||||
|
|
||||||
|
|||||||
@ -50,9 +50,9 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
|
|||||||
if (empty($conf->blockedlog->enabled)) {
|
if (empty($conf->blockedlog->enabled)) {
|
||||||
return 0;
|
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' || $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') {
|
||||||
@ -62,8 +62,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
|
|||||||
$amounts+= price2num($amount);
|
$amounts+= price2num($amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(strpos($action,'PAYMENT')!==false) {
|
else if(strpos($action,'PAYMENT')!==false) {
|
||||||
$amounts= (double) $object->amount;
|
$amounts= (double) $object->amount;
|
||||||
@ -71,25 +71,25 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
|
|||||||
else {
|
else {
|
||||||
return 0; // not implemented action log
|
return 0; // not implemented action log
|
||||||
}
|
}
|
||||||
|
|
||||||
$b=new BlockedLog($this->db);
|
$b=new BlockedLog($this->db);
|
||||||
$b->action = $action;
|
$b->action = $action;
|
||||||
$b->amounts= $amounts;
|
$b->amounts= $amounts;
|
||||||
$b->setObjectData($object);
|
$b->setObjectData($object);
|
||||||
|
|
||||||
$res = $b->create($user);
|
$res = $b->create($user);
|
||||||
|
|
||||||
if($res<0) {
|
if($res<0) {
|
||||||
setEventMessage($b->error,'errors');
|
setEventMessage($b->error,'errors');
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
@ -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";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user