diff --git a/htdocs/blockedlog/admin/blockedlog_list.php b/htdocs/blockedlog/admin/blockedlog_list.php
index 3f824ac1238..54b8a05a19d 100644
--- a/htdocs/blockedlog/admin/blockedlog_list.php
+++ b/htdocs/blockedlog/admin/blockedlog_list.php
@@ -305,8 +305,11 @@ foreach($blocks as &$block) {
if (empty($showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
{
print '
';
+ // ID
print '| '.$block->id.' | ';
+ // Date
print ''.dol_print_date($block->tms,'dayhour').' | ';
+ // User
print '';
//print $block->getUser()
print $block->user_fullname;
@@ -315,6 +318,7 @@ foreach($blocks as &$block) {
print ' | '.$langs->trans('log'.$block->action).' | ';
// Ref
print ''.$block->ref_object.' | ';
+ // Link to source object
print ''.$object_link.' | ';
print ''.price($block->amounts).' | ';
print ''.img_info($langs->trans('ShowDetails')).' | ';
diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php
index be731dc4a70..ad2e6bb110a 100644
--- a/htdocs/blockedlog/class/blockedlog.class.php
+++ b/htdocs/blockedlog/class/blockedlog.class.php
@@ -154,7 +154,7 @@ class BlockedLog
}
/**
- * try to retrieve logged object link
+ * Try to retrieve source object (it it still exists)
*/
public function getObjectLink()
{
@@ -164,7 +164,7 @@ class BlockedLog
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$object = new Facture($this->db);
- if($object->fetch($this->fk_object)>0) {
+ if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
@@ -175,7 +175,7 @@ class BlockedLog
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$object = new FactureFournisseur($this->db);
- if($object->fetch($this->fk_object)>0) {
+ if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
@@ -186,7 +186,7 @@ class BlockedLog
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
$object = new Paiement($this->db);
- if($object->fetch($this->fk_object)>0) {
+ if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
@@ -197,7 +197,7 @@ class BlockedLog
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
$object = new PaiementFourn($this->db);
- if($object->fetch($this->fk_object)>0) {
+ if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
@@ -208,7 +208,18 @@ class BlockedLog
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
$object = new PaymentDonation($this->db);
- if($object->fetch($this->fk_object)>0) {
+ if ($object->fetch($this->fk_object)>0) {
+ return $object->getNomUrl(1);
+ }
+ else{
+ $this->error++;
+ }
+ }
+ else if($this->element === 'don' || $this->element === 'donation') {
+ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
+
+ $object = new Don($this->db);
+ if ($object->fetch($this->fk_object)>0) {
return $object->getNomUrl(1);
}
else{
@@ -796,14 +807,12 @@ class BlockedLog
if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'";
if ($search_ref != '') $sql.=natural_search("ref_object", $search_ref);
if ($search_amount != '') $sql.=natural_search("amounts", $search_amount, 1);
- if ($search_code != '') $sql.=natural_search("action", $search_code, 3);
+ if ($search_code != '' && $search_code != '-1') $sql.=natural_search("action", $search_code, 3);
$sql.=$this->db->order($sortfield, $sortorder);
-
- if($limit > 0 )$sql.=' LIMIT '.$limit;
+ $sql.=$this->db->plimit($limit);
$res = $this->db->query($sql);
-
if($res) {
$results=array();
diff --git a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
index 52b804283cc..03fb170650d 100644
--- a/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
+++ b/htdocs/core/triggers/interface_50_modBlockedlog_ActionsBlockedLog.class.php
@@ -74,7 +74,9 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
)
{
$qualified++;
- $amounts= (double) $object->total_ttc;
+
+ if ($action==='DON_VALIDATE') $amounts = (double) $object->amount;
+ else $amounts = (double) $object->total_ttc;
}
/*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
|| $action === 'BILL_SUPPLIER_PAYED' || $action === 'BILL_SUPPLIER_UNPAYED')
@@ -106,8 +108,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
return 0; // not implemented action log
}
-
$result = $b->setObjectData($object, $action, $amounts); // Set field date_object, ref_object, fk_object, element, object_data
+
if ($result < 0)
{
$this->error = $b->error;
diff --git a/htdocs/don/card.php b/htdocs/don/card.php
index bd1752be99e..01164c47508 100644
--- a/htdocs/don/card.php
+++ b/htdocs/don/card.php
@@ -199,8 +199,11 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights-
}
if ($action == 'valid_promesse')
{
+ $object->fetch($id);
if ($object->valid_promesse($id, $user->id) >= 0)
{
+ setEventMessages($langs->trans("DonationValidated", $object->ref), null);
+
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
}
@@ -210,7 +213,8 @@ if ($action == 'valid_promesse')
}
if ($action == 'set_cancel')
{
- if ($object->set_cancel($id) >= 0)
+ $object->fetch($id);
+ if ($object->set_cancel($id) >= 0)
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
exit;
@@ -221,6 +225,7 @@ if ($action == 'set_cancel')
}
if ($action == 'set_paid')
{
+ $object->fetch($id);
if ($object->set_paid($id, $modepayment) >= 0)
{
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php
index 7224df1aa22..c0c00f7971d 100644
--- a/htdocs/don/class/don.class.php
+++ b/htdocs/don/class/don.class.php
@@ -689,27 +689,45 @@ class Don extends CommonObject
* @param int $userid User who validate the donation/promise
* @return int <0 if KO, >0 if OK
*/
- function valid_promesse($id, $userid)
+ function valid_promesse($id, $userid, $notrigger=0)
{
+ global $langs, $user;
+
+ $error=0;
+
+ $this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = ".$userid." WHERE rowid = ".$id." AND fk_statut = 0";
$resql=$this->db->query($sql);
if ($resql)
{
- if ( $this->db->affected_rows($resql) )
+ if ($this->db->affected_rows($resql))
{
- return 1;
- }
- else
- {
- return 0;
+ if (!$notrigger)
+ {
+ // Call trigger
+ $result=$this->call_trigger('DON_VALIDATE',$user);
+ if ($result < 0) { $error++; }
+ // End call triggers
+ }
}
}
else
{
- dol_print_error($this->db);
- return -1;
+ $error++;
+ $this->error = $this->db->lasterror();
+ }
+
+ if (!$error)
+ {
+ $this->db->commit();
+ return 1;
+ }
+ else
+ {
+ $this->db->rollback();
+ return -1;
}
}
@@ -720,14 +738,14 @@ class Don extends CommonObject
* @param int $modepayment mode of payment
* @return int <0 if KO, >0 if OK
*/
- function set_paid($id, $modepayment='')
+ function set_paid($id, $modepayment=0)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2";
if ($modepayment)
{
- $sql .= ", fk_payment=$modepayment";
+ $sql .= ", fk_payment=".$modepayment;
}
- $sql .= " WHERE rowid = $id AND fk_statut = 1";
+ $sql .= " WHERE rowid = ".$id." AND fk_statut = 1";
$resql=$this->db->query($sql);
if ($resql)
diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang
index 606b6b5d789..748057cc9cc 100644
--- a/htdocs/langs/en_US/donations.lang
+++ b/htdocs/langs/en_US/donations.lang
@@ -31,3 +31,4 @@ DONATION_ART200=Show article 200 from CGI if you are concerned
DONATION_ART238=Show article 238 from CGI if you are concerned
DONATION_ART885=Show article 885 from CGI if you are concerned
DonationPayment=Donation payment
+DonationValidated=Donation %s validated