Fix: When deleting a subscription, end date was not updated.
This commit is contained in:
parent
77f4e5f65f
commit
30d585495e
@ -96,6 +96,7 @@ class Adherent extends CommonObject
|
|||||||
var $fistsubscription_amount;
|
var $fistsubscription_amount;
|
||||||
var $lastsubscription_date;
|
var $lastsubscription_date;
|
||||||
var $lastsubscription_amount;
|
var $lastsubscription_amount;
|
||||||
|
var $subscriptions=array();
|
||||||
|
|
||||||
// var $public;
|
// var $public;
|
||||||
var $array_options;
|
var $array_options;
|
||||||
@ -937,9 +938,10 @@ class Adherent extends CommonObject
|
|||||||
global $langs;
|
global $langs;
|
||||||
|
|
||||||
$sql = "SELECT c.rowid, c.fk_adherent, c.cotisation, c.note, c.fk_bank,";
|
$sql = "SELECT c.rowid, c.fk_adherent, c.cotisation, c.note, c.fk_bank,";
|
||||||
$sql.= " ".$this->db->pdate("c.tms")." as datem,";
|
$sql.= " c.tms as datem,";
|
||||||
$sql.= " ".$this->db->pdate("c.datec")." as datec,";
|
$sql.= " c.datec as datec,";
|
||||||
$sql.= " ".$this->db->pdate("c.dateadh")." as dateadh";
|
$sql.= " c.dateadh as dateadh,";
|
||||||
|
$sql.= " c.datef as datef";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."cotisation as c";
|
$sql.= " FROM ".MAIN_DB_PREFIX."cotisation as c";
|
||||||
$sql.= " WHERE c.fk_adherent = ".$this->id;
|
$sql.= " WHERE c.fk_adherent = ".$this->id;
|
||||||
$sql.= " ORDER BY c.dateadh";
|
$sql.= " ORDER BY c.dateadh";
|
||||||
@ -948,6 +950,8 @@ class Adherent extends CommonObject
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
$this->subscriptions=array();
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
while ($obj = $this->db->fetch_object($resql))
|
while ($obj = $this->db->fetch_object($resql))
|
||||||
{
|
{
|
||||||
@ -959,7 +963,18 @@ class Adherent extends CommonObject
|
|||||||
$this->lastsubscription_date=$obj->dateadh;
|
$this->lastsubscription_date=$obj->dateadh;
|
||||||
$this->lastsubscription_amount=$obj->cotisation;
|
$this->lastsubscription_amount=$obj->cotisation;
|
||||||
|
|
||||||
// TODO Add also array of subscription records
|
$subscription=new Cotisation($this->db);
|
||||||
|
$subscription->id=$obj->rowid;
|
||||||
|
$subscription->fk_adherent=$obj->fk_adherent;
|
||||||
|
$subscription->amount=$obj->cotisation;
|
||||||
|
$subscription->note=$obj->note;
|
||||||
|
$subscription->fk_bank=$obj->fk_bank;
|
||||||
|
$subscription->datem=$this->db->jdate($obj->datem);
|
||||||
|
$subscription->datec=$this->db->jdate($obj->datec);
|
||||||
|
$subscription->dateadh=$this->db->jdate($obj->dateadh);
|
||||||
|
$subscription->datef=$this->db->jdate($obj->datef);
|
||||||
|
|
||||||
|
$this->subscriptions[]=$subscription;
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -181,13 +181,13 @@ class Cotisation extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Fonction qui permet de supprimer la cotisation
|
* \brief Delete a subscription
|
||||||
\param rowid Id cotisation
|
* \param rowid Id cotisation
|
||||||
\return int <0 si KO, 0 si OK mais non trouve, >0 si OK
|
* \return int <0 si KO, 0 si OK mais non trouve, >0 si OK
|
||||||
*/
|
*/
|
||||||
function delete()
|
function delete($user)
|
||||||
{
|
{
|
||||||
// Verification
|
// It subscription is linked to a bank transaction, we get it
|
||||||
if ($this->fk_bank)
|
if ($this->fk_bank)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/compta/bank/account.class.php");
|
||||||
@ -205,9 +205,14 @@ class Cotisation extends CommonObject
|
|||||||
$num=$this->db->affected_rows($resql);
|
$num=$this->db->affected_rows($resql);
|
||||||
if ($num)
|
if ($num)
|
||||||
{
|
{
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
|
||||||
|
$member=new Adherent($this->db);
|
||||||
|
$result=$member->fetch($this->fk_adherent);
|
||||||
|
$result=$member->update_end_date($user);
|
||||||
|
|
||||||
if ($this->fk_bank)
|
if ($this->fk_bank)
|
||||||
{
|
{
|
||||||
$result=$accountline->delete(); // Renvoi faux si ligne rapprocher
|
$result=$accountline->delete($user); // Return false if refused because line is conciliated
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2007-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -126,7 +126,7 @@ if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'update
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($user->rights->adherent->cotisation->creer && $_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes')
|
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && $user->rights->adherent->cotisation->creer)
|
||||||
{
|
{
|
||||||
$result=$subscription->fetch($rowid);
|
$result=$subscription->fetch($rowid);
|
||||||
$result=$subscription->delete();
|
$result=$subscription->delete();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user