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))
|
if (empty($showonlyerrors) || ! $checkresult[$block->id] || ($loweridinerror && $block->id >= $loweridinerror))
|
||||||
{
|
{
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
|
// ID
|
||||||
print '<td>'.$block->id.'</td>';
|
print '<td>'.$block->id.'</td>';
|
||||||
|
// Date
|
||||||
print '<td>'.dol_print_date($block->tms,'dayhour').'</td>';
|
print '<td>'.dol_print_date($block->tms,'dayhour').'</td>';
|
||||||
|
// User
|
||||||
print '<td>';
|
print '<td>';
|
||||||
//print $block->getUser()
|
//print $block->getUser()
|
||||||
print $block->user_fullname;
|
print $block->user_fullname;
|
||||||
@ -315,6 +318,7 @@ foreach($blocks as &$block) {
|
|||||||
print '<td>'.$langs->trans('log'.$block->action).'</td>';
|
print '<td>'.$langs->trans('log'.$block->action).'</td>';
|
||||||
// Ref
|
// Ref
|
||||||
print '<td>'.$block->ref_object.'</td>';
|
print '<td>'.$block->ref_object.'</td>';
|
||||||
|
// Link to source object
|
||||||
print '<td>'.$object_link.'</td>';
|
print '<td>'.$object_link.'</td>';
|
||||||
print '<td align="right">'.price($block->amounts).'</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>';
|
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()
|
public function getObjectLink()
|
||||||
{
|
{
|
||||||
@ -164,7 +164,7 @@ class BlockedLog
|
|||||||
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);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -175,7 +175,7 @@ class BlockedLog
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||||
|
|
||||||
$object = new FactureFournisseur($this->db);
|
$object = new FactureFournisseur($this->db);
|
||||||
if($object->fetch($this->fk_object)>0) {
|
if ($object->fetch($this->fk_object)>0) {
|
||||||
return $object->getNomUrl(1);
|
return $object->getNomUrl(1);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -186,7 +186,7 @@ class BlockedLog
|
|||||||
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);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -197,7 +197,7 @@ class BlockedLog
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||||
|
|
||||||
$object = new PaiementFourn($this->db);
|
$object = new PaiementFourn($this->db);
|
||||||
if($object->fetch($this->fk_object)>0) {
|
if ($object->fetch($this->fk_object)>0) {
|
||||||
return $object->getNomUrl(1);
|
return $object->getNomUrl(1);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -208,7 +208,18 @@ class BlockedLog
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
|
||||||
|
|
||||||
$object = new PaymentDonation($this->db);
|
$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);
|
return $object->getNomUrl(1);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -796,14 +807,12 @@ class BlockedLog
|
|||||||
if ($search_end > 0) $sql.=" AND date_creation <= '".$this->db->idate($search_end)."'";
|
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_ref != '') $sql.=natural_search("ref_object", $search_ref);
|
||||||
if ($search_amount != '') $sql.=natural_search("amounts", $search_amount, 1);
|
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);
|
$sql.=$this->db->order($sortfield, $sortorder);
|
||||||
|
$sql.=$this->db->plimit($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();
|
||||||
|
|||||||
@ -74,7 +74,9 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
$qualified++;
|
$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'
|
/*if ($action === 'BILL_PAYED' || $action==='BILL_UNPAYED'
|
||||||
|| $action === 'BILL_SUPPLIER_PAYED' || $action === 'BILL_SUPPLIER_UNPAYED')
|
|| $action === 'BILL_SUPPLIER_PAYED' || $action === 'BILL_SUPPLIER_UNPAYED')
|
||||||
@ -106,8 +108,8 @@ class InterfaceActionsBlockedLog extends DolibarrTriggers
|
|||||||
return 0; // not implemented action log
|
return 0; // not implemented action log
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$result = $b->setObjectData($object, $action, $amounts); // Set field date_object, ref_object, fk_object, element, object_data
|
$result = $b->setObjectData($object, $action, $amounts); // Set field date_object, ref_object, fk_object, element, object_data
|
||||||
|
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error = $b->error;
|
$this->error = $b->error;
|
||||||
|
|||||||
@ -199,8 +199,11 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights-
|
|||||||
}
|
}
|
||||||
if ($action == 'valid_promesse')
|
if ($action == 'valid_promesse')
|
||||||
{
|
{
|
||||||
|
$object->fetch($id);
|
||||||
if ($object->valid_promesse($id, $user->id) >= 0)
|
if ($object->valid_promesse($id, $user->id) >= 0)
|
||||||
{
|
{
|
||||||
|
setEventMessages($langs->trans("DonationValidated", $object->ref), null);
|
||||||
|
|
||||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
@ -210,7 +213,8 @@ if ($action == 'valid_promesse')
|
|||||||
}
|
}
|
||||||
if ($action == 'set_cancel')
|
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);
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||||
exit;
|
exit;
|
||||||
@ -221,6 +225,7 @@ if ($action == 'set_cancel')
|
|||||||
}
|
}
|
||||||
if ($action == 'set_paid')
|
if ($action == 'set_paid')
|
||||||
{
|
{
|
||||||
|
$object->fetch($id);
|
||||||
if ($object->set_paid($id, $modepayment) >= 0)
|
if ($object->set_paid($id, $modepayment) >= 0)
|
||||||
{
|
{
|
||||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||||
|
|||||||
@ -689,27 +689,45 @@ class Don extends CommonObject
|
|||||||
* @param int $userid User who validate the donation/promise
|
* @param int $userid User who validate the donation/promise
|
||||||
* @return int <0 if KO, >0 if OK
|
* @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";
|
$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);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
if ( $this->db->affected_rows($resql) )
|
if ($this->db->affected_rows($resql))
|
||||||
{
|
{
|
||||||
return 1;
|
if (!$notrigger)
|
||||||
}
|
{
|
||||||
else
|
// Call trigger
|
||||||
{
|
$result=$this->call_trigger('DON_VALIDATE',$user);
|
||||||
return 0;
|
if ($result < 0) { $error++; }
|
||||||
|
// End call triggers
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_print_error($this->db);
|
$error++;
|
||||||
return -1;
|
$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
|
* @param int $modepayment mode of payment
|
||||||
* @return int <0 if KO, >0 if OK
|
* @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";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2";
|
||||||
if ($modepayment)
|
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);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
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_ART238=Show article 238 from CGI if you are concerned
|
||||||
DONATION_ART885=Show article 885 from CGI if you are concerned
|
DONATION_ART885=Show article 885 from CGI if you are concerned
|
||||||
DonationPayment=Donation payment
|
DonationPayment=Donation payment
|
||||||
|
DonationValidated=Donation %s validated
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user