Merge pull request #6989 from atm-alexis/NEW_blocklog_develop_refactor

NEW Blokedlog stuff
This commit is contained in:
Laurent Destailleur
2017-06-12 17:44:27 +02:00
committed by GitHub
7 changed files with 104 additions and 22 deletions

View File

@@ -101,20 +101,20 @@ print $block_static->getSignature();
print '</td></tr>';
// Example with a yes / no select
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("BlockedLogAuthorityUrl").img_info($langs->trans('BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote')).'</td>';
print '<td align="right" width="300">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_BLOCKEDLOG_AUTHORITY_URL">';
print '<input type="text" name="BLOCKEDLOG_AUTHORITY_URL" value="'.$conf->global->BLOCKEDLOG_AUTHORITY_URL.'" size="40" />';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) {
// Example with a yes / no select
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("BlockedLogAuthorityUrl").img_info($langs->trans('BlockedLogAuthorityNeededToStoreYouFingerprintsInNonAlterableRemote')).'</td>';
print '<td align="right" width="300">';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set_BLOCKEDLOG_AUTHORITY_URL">';
print '<input type="text" name="BLOCKEDLOG_AUTHORITY_URL" value="'.$conf->global->BLOCKEDLOG_AUTHORITY_URL.'" size="40" />';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</form>';
print '</td></tr>';
}
print '</table>';

View File

@@ -74,7 +74,7 @@ print $langs->trans("FingerprintsDesc")."<br>\n";
print '<br>';
echo '<div align="right"><a href="?all=1">'.$langs->trans('ShowAllFingerPrintsMightBeTooLong').'</a> <a href="?action=downloadblockchain">'.$langs->trans('DownloadBlockChain').'</a></div>';
echo '<div align="right"><a href="?all=1">'.$langs->trans('ShowAllFingerPrintsMightBeTooLong').'</a> | <a href="?action=downloadblockchain">'.$langs->trans('DownloadBlockChain').'</a></div>';
print '<table class="noborder" width="100%">';
@@ -97,15 +97,16 @@ foreach($blocks as &$block) {
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>'.$block->getObject().'</td>';
print '<td>'.$block->getObject().'<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->signature.'</td>';
print '<td>';
print $block->checkSignature() ? img_picto('OkCheckPaymentValidity', 'on') : img_picto($langs->trans('KoCheckPaymentValidity'), 'off');
print ' '.($block->certified ? img_picto($langs->trans('AddedByAuthority'), 'info') : img_picto($langs->trans('NotAddedByAuthorityYet'), 'info_black') );
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 '</td>';
print '</tr>';
@@ -113,6 +114,54 @@ foreach($blocks as &$block) {
print '</table>';
?>
<script type="text/javascript">
$('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.dialog({
title:"<?php echo $langs->trans('BlockedlogInfoDialog'); ?>"
,modal:true
,width:'80%'
});
var fk_block = $(this).attr("blockid");
$.ajax({
url:"../ajax/block-info.php?id="+fk_block
,dataType:'json'
}).done(function(data) {
drawData(data,'');
});
});
function drawData(data, prefix) {
for(x in data) {
value = data[x];
$('#pop-info table tbody').append('<tr><td>'+prefix+x+'</td><td>'+value+'</td></tr>');
if( (typeof value === "object") && (value !== null) ) {
drawData(value, prefix+x+' &gt;&gt; ');
}
}
}
</script>
<?php
if(!empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY) && !empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) {
?>
<script type="text/javascript">
@@ -134,6 +183,8 @@ print '</table>';
<?php
}
dol_fiche_end();
print '<br><br>';

View File

@@ -0,0 +1,15 @@
<?php
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

@@ -294,7 +294,7 @@ class BlockedLogAuthority
//TODO create cron task on activation
if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL)) {
if(empty($conf->global->BLOCKEDLOG_AUTHORITY_URL) || empty($conf->global->BLOCKEDLOG_USE_REMOTE_AUTHORITY)) {
$this->error = $langs->trans('NoAuthorityURLDefined');
return -2;
}

View File

@@ -411,7 +411,7 @@ CREATE TABLE llx_blockedlog
date_object datetime,
object_data text,
fk_user integer,
entity integer DEFAULT 1,
entity integer DEFAULT 1 NOT NULL,
certified integer
) ENGINE=innodb;

View File

@@ -13,7 +13,7 @@ CREATE TABLE llx_blockedlog
date_object datetime,
object_data text,
fk_user integer,
entity integer DEFAULT 1,
entity integer DEFAULT 1 NOT NULL,
certified integer
) ENGINE=innodb;

View File

@@ -0,0 +1,16 @@
Field=Field
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)
DownloadBlockChain=Download fingerprints
KoCheckFingerprintValidity=Fingerprint is not valid
OkCheckFingerprintValidity=Fingerprint is valid
AddedByAuthority=Stored into remote authority
NotAddedByAuthorityYet=Not yet stored into remote authority
ShowDetails=Show stored details
logPAYMENT_ADD_TO_BANK=Payment added to bank
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