diff --git a/htdocs/blockedlog/admin/blockedlog.php b/htdocs/blockedlog/admin/blockedlog.php
new file mode 100644
index 00000000000..3c143b70b83
--- /dev/null
+++ b/htdocs/blockedlog/admin/blockedlog.php
@@ -0,0 +1,126 @@
+
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/blockedlog/admin/blockedlog.php
+ * \ingroup system
+ * \brief Page setup for blockedlog module
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+
+$langs->load("admin");
+$langs->load("other");
+$langs->load("blockedlog");
+
+if (! $user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+
+/*
+ * Actions
+ */
+if (preg_match('/set_(.*)/',$action,$reg))
+{
+ $code=$reg[1];
+ if (dolibarr_set_const($db, $code, GETPOST($code), 'chaine', 0, '', $conf->entity) > 0)
+ {
+ header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+}
+
+if (preg_match('/del_(.*)/',$action,$reg))
+{
+ $code=$reg[1];
+ if (dolibarr_del_const($db, $code, 0) > 0)
+ {
+ Header("Location: ".$_SERVER["PHP_SELF"]);
+ exit;
+ }
+ else
+ {
+ dol_print_error($db);
+ }
+}
+
+
+/*
+ * View
+ */
+
+$block_static = new BlockedLog($db);
+
+$form=new Form($db);
+
+llxHeader('',$langs->trans("BlockedLogSetup"));
+
+$linkback=''.$langs->trans("BackToModuleList").'';
+print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback);
+
+$head=blockedlogadmin_prepare_head();
+
+dol_fiche_head($head, 'blockedlog', '', -1);
+
+print $langs->trans("BlockedLogDesc")." \n";
+
+print ' ';
+
+print '
';
+
+llxFooter();
+$db->close();
diff --git a/htdocs/blockedlog/admin/fingerprints.php b/htdocs/blockedlog/admin/fingerprints.php
new file mode 100644
index 00000000000..29cd2a3f73b
--- /dev/null
+++ b/htdocs/blockedlog/admin/fingerprints.php
@@ -0,0 +1,142 @@
+
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/blockedlog/admin/blockedlog.php
+ * \ingroup system
+ * \brief Page setup for blockedlog module
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
+require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/authority.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+
+$langs->load("admin");
+$langs->load("other");
+$langs->load("blockedlog");
+
+if (! $user->admin) accessforbidden();
+
+$action = GETPOST('action','alpha');
+
+if($action === 'downloadblockchain') {
+
+ $auth = new BlockedLogAuthority($db);
+
+ $bc = $auth->getLocalBlockChain();
+
+ header('Content-Type: application/octet-stream');
+ header("Content-Transfer-Encoding: Binary");
+ header("Content-disposition: attachment; filename=\"" .$auth->signature. ".certif\"");
+
+ echo $bc;
+
+ exit;
+}
+
+
+/*
+ * View
+ */
+
+$block_static = new BlockedLog($db);
+
+$blocks = $block_static->getLog('all', 0, GETPOST('all') ? 0 : 50);
+
+$form=new Form($db);
+
+llxHeader('',$langs->trans("BlockedLogSetup"));
+
+$linkback=''.$langs->trans("BackToModuleList").'';
+print load_fiche_titre($langs->trans("ModuleSetup").' BlockedLog',$linkback);
+
+$head=blockedlogadmin_prepare_head();
+
+dol_fiche_head($head, 'fingerprints', '', -1);
+
+print $langs->trans("FingerprintsDesc")." \n";
+
+print ' ';
+
+echo '
\n";
$i++;
}
diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php
index 0c66873647a..495eb836bb4 100644
--- a/htdocs/compta/paiement/class/paiement.class.php
+++ b/htdocs/compta/paiement/class/paiement.class.php
@@ -197,7 +197,7 @@ class Paiement extends CommonObject
$this->db->begin();
- $ref = $this->getNextNumRef('');
+ $this->ref = $this->getNextNumRef('');
if ($way == 'dolibarr')
{
@@ -211,7 +211,7 @@ class Paiement extends CommonObject
}
$sql = "INSERT INTO ".MAIN_DB_PREFIX."paiement (entity, ref, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, fk_user_creat)";
- $sql.= " VALUES (".$conf->entity.", '".$ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.")";
+ $sql.= " VALUES (".$conf->entity.", '".$this->ref."', '". $this->db->idate($now)."', '".$this->db->idate($this->datepaye)."', '".$total."', '".$mtotal."', ".$this->paiementid.", '".$this->num_paiement."', '".$this->db->escape($this->note)."', ".$user->id.")";
dol_syslog(get_class($this)."::Create insert paiement", LOG_DEBUG);
$resql = $this->db->query($sql);
@@ -246,21 +246,27 @@ class Paiement extends CommonObject
//var_dump($invoice->total_ttc.' - '.$paiement.' -'.$creditnotes.' - '.$deposits.' - '.$remaintopay);exit;
- // If there is withdrawals request to do and not done yet, we wait before closing.
+ /* Why this ? We can remove i think.
+ // If there is withdrawals request to do and not done yet on the invoice the payment is on, we wait before closing.
$mustwait=0;
+ $sqlrequest ="SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX."prelevement_facture_demande";
+ $sqlrequest.="WHERE fk_facture = ".$invoice->id." AND traite = 0";
+ ...
+
$listofpayments=$invoice->getListOfPayments();
foreach($listofpayments as $paym)
{
- // This payment might be this one or a previous one
+ // This payment on invoice $invoice might be the one we record or another one
if ($paym['type']=='PRE')
{
if (! empty($conf->prelevement->enabled))
{
- // FIXME Check if this invoice has a withdraw request
// if not, $mustwait++; // This will disable automatic close on invoice to allow to process
+
}
}
}
+ */
//Invoice types that are eligible for changing status to paid
$affected_types = array(
@@ -273,7 +279,7 @@ class Paiement extends CommonObject
if (!in_array($invoice->type, $affected_types)) dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more.");
else if ($remaintopay) dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more.");
- else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more.");
+ //else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more.");
else
{
// If invoice is a down payment, we also convert down payment to discount
diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php
index c3e2cb6345a..b149471cd20 100644
--- a/htdocs/core/modules/modBlockedLog.class.php
+++ b/htdocs/core/modules/modBlockedLog.class.php
@@ -60,7 +60,7 @@ class modBlockedLog extends DolibarrModules
// Config pages
//-------------
- $this->config_page_url = array();
+ $this->config_page_url = array('blockedlog.php@blockedlog');
// Dependancies
//-------------
diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
new file mode 100644
index 00000000000..5a52777cbb9
--- /dev/null
+++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
@@ -0,0 +1,94 @@
+
+ *
+ * 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 .
+ */
+
+/**
+ * \file htdocs/core/triggers/interface_50_modAgenda_ActionsBlockedLog.class.php
+ * \ingroup system
+ * \brief Trigger file for blockedlog module
+ */
+
+require_once DOL_DOCUMENT_ROOT.'/core/triggers/dolibarrtriggers.class.php';
+require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
+
+/**
+ * Class of triggered functions for agenda module
+ */
+class InterfaceActionsBlockedLog extends DolibarrTriggers
+{
+ public $family = 'system';
+ public $description = "Triggers of this module add blocklog.";
+ public $version = self::VERSION_DOLIBARR;
+ public $picto = 'system';
+
+ /**
+ * Function called on Dolibarrr payment or invoice event.
+ *
+ * @param string $action Event action code
+ * @param Object $object Object
+ * @param User $user Object user
+ * @param Translate $langs Object langs
+ * @param conf $conf Object conf
+ * @return int <0 if KO, 0 if no triggered ran, >0 if OK
+ */
+ public function runTrigger($action, $object, User $user, Translate $langs, Conf $conf)
+ {
+ // Do not log events not enabled for this action
+ if (empty($conf->blockedlog->enabled)) {
+ return 0;
+ }
+
+ if($action==='BILL_VALIDATE' || $action === 'BILL_PAYED' || $action==='BILL_UNPAYED') {
+ $amounts= (double) $object->total_ttc;
+ }
+ else if($action === 'PAYMENT_CUSTOMER_CREATE' || $action === 'PAYMENT_ADD_TO_BANK') {
+ $amounts = 0;
+ if(!empty($object->amounts)) {
+ foreach($object->amounts as $amount) {
+ $amounts+= price2num($amount);
+ }
+ }
+
+
+ }
+ else if(strpos($action,'PAYMENT')!==false) {
+ $amounts= (double) $object->amount;
+ }
+ else {
+ return 0; // not implemented action log
+ }
+
+ $b=new BlockedLog($this->db);
+ $b->action = $action;
+ $b->amounts= $amounts;
+ $b->setObjectData($object);
+
+ $res = $b->create($user);
+
+ if($res<0) {
+ setEventMessage($b->error,'errors');
+
+ return -1;
+ }
+ else {
+
+ return 1;
+ }
+
+
+ }
+
+}
diff --git a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
index 2789cdbda36..ecc5d3a4e3f 100644
--- a/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
+++ b/htdocs/install/mysql/migration/5.0.0-6.0.0.sql
@@ -397,6 +397,41 @@ ALTER TABLE llx_usergroup_rights DROP INDEX fk_usergroup;
ALTER TABLE llx_usergroup_rights ADD UNIQUE INDEX uk_usergroup_rights (entity, fk_usergroup, fk_id);
ALTER TABLE llx_usergroup_rights ADD CONSTRAINT fk_usergroup_rights_fk_usergroup FOREIGN KEY (fk_usergroup) REFERENCES llx_usergroup (rowid);
+CREATE TABLE llx_blockedlog
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ action varchar(50),
+ amounts real NOT NULL,
+ signature varchar(100) NOT NULL,
+ signature_line varchar(100) NOT NULL,
+ element varchar(50),
+ fk_object integer,
+ ref_object varchar(100),
+ date_object datetime,
+ object_data text,
+ fk_user integer,
+ entity integer DEFAULT 1,
+ certified integer
+) ENGINE=innodb;
+
+ALTER TABLE llx_blockedlog ADD INDEX signature (signature);
+ALTER TABLE llx_blockedlog ADD INDEX fk_object_element (fk_object,element);
+ALTER TABLE llx_blockedlog ADD INDEX entity (entity);
+ALTER TABLE llx_blockedlog ADD INDEX fk_user (fk_user);
+ALTER TABLE llx_blockedlog ADD INDEX entity_action (entity,action);
+ALTER TABLE llx_blockedlog ADD INDEX entity_action_certified (entity,action,certified);
+
+CREATE TABLE llx_blockedlog_authority
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ blockchain longtext NOT NULL,
+ signature varchar(100) NOT NULL,
+ tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
+) ENGINE=innodb;
+
+ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature);
+
ALTER TABLE llx_c_paiement DROP PRIMARY KEY;
ALTER TABLE llx_c_paiement ADD COLUMN entity integer DEFAULT 1 NOT NULL AFTER id;
ALTER TABLE llx_c_paiement DROP INDEX uk_c_paiement;
diff --git a/htdocs/install/mysql/tables/llx_blockedlog.key.sql b/htdocs/install/mysql/tables/llx_blockedlog.key.sql
new file mode 100644
index 00000000000..4312a056894
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_blockedlog.key.sql
@@ -0,0 +1,6 @@
+ALTER TABLE llx_blockedlog ADD INDEX signature (signature);
+ALTER TABLE llx_blockedlog ADD INDEX fk_object_element (fk_object,element);
+ALTER TABLE llx_blockedlog ADD INDEX entity (entity);
+ALTER TABLE llx_blockedlog ADD INDEX fk_user (fk_user);
+ALTER TABLE llx_blockedlog ADD INDEX entity_action (entity,action);
+ALTER TABLE llx_blockedlog ADD INDEX entity_action_certified (entity,action,certified);
diff --git a/htdocs/install/mysql/tables/llx_blockedlog.sql b/htdocs/install/mysql/tables/llx_blockedlog.sql
new file mode 100644
index 00000000000..afc0f0d4375
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_blockedlog.sql
@@ -0,0 +1,19 @@
+
+CREATE TABLE llx_blockedlog
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
+ action varchar(50),
+ amounts real NOT NULL,
+ signature varchar(100) NOT NULL,
+ signature_line varchar(100) NOT NULL,
+ element varchar(50),
+ fk_object integer,
+ ref_object varchar(100),
+ date_object datetime,
+ object_data text,
+ fk_user integer,
+ entity integer DEFAULT 1,
+ certified integer
+) ENGINE=innodb;
+
diff --git a/htdocs/install/mysql/tables/llx_blockedlog_authority.key.sql b/htdocs/install/mysql/tables/llx_blockedlog_authority.key.sql
new file mode 100644
index 00000000000..289b6dbde56
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_blockedlog_authority.key.sql
@@ -0,0 +1 @@
+ALTER TABLE llx_blockedlog_authority ADD INDEX signature (signature);
diff --git a/htdocs/install/mysql/tables/llx_blockedlog_authority.sql b/htdocs/install/mysql/tables/llx_blockedlog_authority.sql
new file mode 100644
index 00000000000..eb491f93af4
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_blockedlog_authority.sql
@@ -0,0 +1,7 @@
+CREATE TABLE llx_blockedlog_authority
+(
+ rowid integer AUTO_INCREMENT PRIMARY KEY,
+ blockchain longtext NOT NULL,
+ signature varchar(100) NOT NULL,
+ tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
+) ENGINE=innodb;