Fix module blockedlog for donation
This commit is contained in:
parent
dbf7603118
commit
332ee53c22
@ -305,8 +305,11 @@ foreach($blocks as &$block) {
|
||||
if (empty($showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
|
||||
{
|
||||
print '<tr class="oddeven">';
|
||||
// ID
|
||||
print '<td>'.$block->id.'</td>';
|
||||
// Date
|
||||
print '<td>'.dol_print_date($block->tms,'dayhour').'</td>';
|
||||
// User
|
||||
print '<td>';
|
||||
//print $block->getUser()
|
||||
print $block->user_fullname;
|
||||
@ -315,6 +318,7 @@ foreach($blocks as &$block) {
|
||||
print '<td>'.$langs->trans('log'.$block->action).'</td>';
|
||||
// Ref
|
||||
print '<td>'.$block->ref_object.'</td>';
|
||||
// Link to source object
|
||||
print '<td>'.$object_link.'</td>';
|
||||
print '<td align="right">'.price($block->amounts).'</td>';
|
||||
print '<td align="center"><a href="#" data-blockid="'.$block->id.'" rel="show-info">'.img_info($langs->trans('ShowDetails')).'</a></td>';
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user