More fix and enhancements in LDAP module
This commit is contained in:
parent
10858091a0
commit
f1cb94b9a1
@ -87,10 +87,10 @@ class Adherent extends CommonObject
|
|||||||
var $fk_soc;
|
var $fk_soc;
|
||||||
|
|
||||||
// Fields loaded by fetch_subscriptions()
|
// Fields loaded by fetch_subscriptions()
|
||||||
var $fistsubscription_date;
|
var $first_subscription_date;
|
||||||
var $fistsubscription_amount;
|
var $first_subscription_amount;
|
||||||
var $lastsubscription_date;
|
var $last_subscription_date;
|
||||||
var $lastsubscription_amount;
|
var $last_subscription_amount;
|
||||||
var $subscriptions=array();
|
var $subscriptions=array();
|
||||||
|
|
||||||
// var $public;
|
// var $public;
|
||||||
@ -413,9 +413,7 @@ class Adherent extends CommonObject
|
|||||||
$sql.= ", fk_user_mod=".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest
|
$sql.= ", fk_user_mod=".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest
|
||||||
$sql.= " WHERE rowid = ".$this->id;
|
$sql.= " WHERE rowid = ".$this->id;
|
||||||
|
|
||||||
dol_syslog("Adherent::update UPDATE MEMBER");
|
dol_syslog("Adherent::update update member sql=".$sql);
|
||||||
|
|
||||||
dol_syslog("Adherent::update sql=".$sql);
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -448,7 +446,7 @@ class Adherent extends CommonObject
|
|||||||
}
|
}
|
||||||
$sql.=")";
|
$sql.=")";
|
||||||
|
|
||||||
dol_syslog("Adherent::update sql=".$sql);
|
dol_syslog("Adherent::update update option sql=".$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -466,7 +464,7 @@ class Adherent extends CommonObject
|
|||||||
// Update password
|
// Update password
|
||||||
if ($this->pass)
|
if ($this->pass)
|
||||||
{
|
{
|
||||||
dol_syslog("Adherent::update UPDATE PASSWORD");
|
dol_syslog("Adherent::update update password");
|
||||||
if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted)
|
if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted)
|
||||||
{
|
{
|
||||||
// Si mot de passe saisi et different de celui en base
|
// Si mot de passe saisi et different de celui en base
|
||||||
@ -476,7 +474,7 @@ class Adherent extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove link to user
|
// Remove link to user
|
||||||
dol_syslog("Adherent::update UPDATE LINK TO USER");
|
dol_syslog("Adherent::update update link to user");
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id;
|
$sql = "UPDATE ".MAIN_DB_PREFIX."user SET fk_member = NULL WHERE fk_member = ".$this->id;
|
||||||
dol_syslog("Adherent::update sql=".$sql, LOG_DEBUG);
|
dol_syslog("Adherent::update sql=".$sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
@ -496,7 +494,7 @@ class Adherent extends CommonObject
|
|||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT."/user.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/user.class.php");
|
||||||
|
|
||||||
dol_syslog("Adherent::update UPDATE LINKED USER");
|
dol_syslog("Adherent::update update linked user");
|
||||||
|
|
||||||
// This member is linked with a user, so we also update users informations
|
// This member is linked with a user, so we also update users informations
|
||||||
// if this is an update.
|
// if this is an update.
|
||||||
@ -573,9 +571,10 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Fonction qui met a jour le chp denormalise date fin adhesion
|
* \brief Update denormalized last subscription date.
|
||||||
\param user Utilisateur qui realise la mise a jour
|
* This function is called when we delete a subscription for example.
|
||||||
\return int <0 si KO, >0 si OK
|
* \param user Utilisateur qui realise la mise a jour
|
||||||
|
* \return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function update_end_date($user)
|
function update_end_date($user)
|
||||||
{
|
{
|
||||||
@ -586,7 +585,7 @@ class Adherent extends CommonObject
|
|||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
// Search for last subscription id and end date
|
// Search for last subscription id and end date
|
||||||
$sql = "SELECT rowid, datef";
|
$sql = "SELECT rowid, datec as dateop, dateadh as datedeb, datef as datefin";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."cotisation";
|
$sql.= " FROM ".MAIN_DB_PREFIX."cotisation";
|
||||||
$sql.= " WHERE fk_adherent='".$this->id."'";
|
$sql.= " WHERE fk_adherent='".$this->id."'";
|
||||||
$sql.= " ORDER by dateadh DESC"; // Sort by start subscription date
|
$sql.= " ORDER by dateadh DESC"; // Sort by start subscription date
|
||||||
@ -596,7 +595,9 @@ class Adherent extends CommonObject
|
|||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$obj=$this->db->fetch_object($resql);
|
$obj=$this->db->fetch_object($resql);
|
||||||
$datefin=$this->db->jdate($obj->datef);
|
$dateop=$this->db->jdate($obj->dateop);
|
||||||
|
$datedeb=$this->db->jdate($obj->datedeb);
|
||||||
|
$datefin=$this->db->jdate($obj->datefin);
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
|
||||||
$sql.= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null");
|
$sql.= " datefin=".($datefin != '' ? "'".$this->db->idate($datefin)."'" : "null");
|
||||||
@ -606,6 +607,10 @@ class Adherent extends CommonObject
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
$this->last_subscription_date=$dateop;
|
||||||
|
$this->last_subscription_date_start=$datedeb;
|
||||||
|
$this->last_subscription_date_end=$datefin;
|
||||||
|
$this->datefin=$datefin;
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -1012,10 +1017,10 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Fonction qui recupere pour un adherent les parametres
|
* \brief Fonction qui recupere pour un adherent les parametres
|
||||||
* firstsubscription_date
|
* first_subscription_date
|
||||||
* fistrsubscription_amount
|
* first_subscription_amount
|
||||||
* lastsubscription_date
|
* last_subscription_date
|
||||||
* lastsubscription_amount
|
* last_subscription_amount
|
||||||
* \return int <0 si KO, >0 si OK
|
* \return int <0 si KO, >0 si OK
|
||||||
*/
|
*/
|
||||||
function fetch_subscriptions()
|
function fetch_subscriptions()
|
||||||
@ -1042,11 +1047,11 @@ class Adherent extends CommonObject
|
|||||||
{
|
{
|
||||||
if ($i==0)
|
if ($i==0)
|
||||||
{
|
{
|
||||||
$this->firstsubscription_date=$obj->dateadh;
|
$this->first_subscription_date=$obj->dateadh;
|
||||||
$this->firstsubscription_amount=$obj->cotisation;
|
$this->first_subscription_amount=$obj->cotisation;
|
||||||
}
|
}
|
||||||
$this->lastsubscription_date=$obj->dateadh;
|
$this->last_subscription_date=$obj->dateadh;
|
||||||
$this->lastsubscription_amount=$obj->cotisation;
|
$this->last_subscription_amount=$obj->cotisation;
|
||||||
|
|
||||||
$subscription=new Cotisation($this->db);
|
$subscription=new Cotisation($this->db);
|
||||||
$subscription->id=$obj->rowid;
|
$subscription->id=$obj->rowid;
|
||||||
@ -1138,7 +1143,7 @@ class Adherent extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf,$langs,$user;
|
global $conf,$langs,$user;
|
||||||
|
|
||||||
// Nettoyage parametres
|
// Clean parameters
|
||||||
if (! $montant) $montant=0;
|
if (! $montant) $montant=0;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -1157,8 +1162,8 @@ class Adherent extends CommonObject
|
|||||||
// Create subscription
|
// Create subscription
|
||||||
$cotisation=new Cotisation($this->db);
|
$cotisation=new Cotisation($this->db);
|
||||||
$cotisation->fk_adherent=$this->id;
|
$cotisation->fk_adherent=$this->id;
|
||||||
$cotisation->dateh=$date;
|
$cotisation->dateh=$date; // Date of new subscription
|
||||||
$cotisation->datef=$datefin;
|
$cotisation->datef=$datefin; // End data of new subscription
|
||||||
$cotisation->amount=$montant;
|
$cotisation->amount=$montant;
|
||||||
$cotisation->note=$label;
|
$cotisation->note=$label;
|
||||||
|
|
||||||
@ -1166,7 +1171,8 @@ class Adherent extends CommonObject
|
|||||||
|
|
||||||
if ($rowid > 0)
|
if ($rowid > 0)
|
||||||
{
|
{
|
||||||
// Update denormalized subscription end date
|
// Update denormalized subscription end date (read database subscription to find values)
|
||||||
|
// This will also update this->datefin
|
||||||
$result=$this->update_end_date($user);
|
$result=$this->update_end_date($user);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
@ -1217,11 +1223,11 @@ class Adherent extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ajout de proprietes pour le triggers
|
// Change properties of object (used by triggers)
|
||||||
$this->last_subscription_date=$dateop;
|
$this->last_subscription_date=$dateop;
|
||||||
|
$this->last_subscription_amount=$montant;
|
||||||
$this->last_subscription_date_start=$date;
|
$this->last_subscription_date_start=$date;
|
||||||
$this->last_subscription_date_end=$datefin;
|
$this->last_subscription_date_end=$datefin;
|
||||||
$this->last_subscription_amount=$montant;
|
|
||||||
$this->use_webcal=($conf->global->PHPWEBCALENDAR_MEMBERSTATUS=='always'?1:0);
|
$this->use_webcal=($conf->global->PHPWEBCALENDAR_MEMBERSTATUS=='always'?1:0);
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
@ -1931,10 +1937,10 @@ class Adherent extends CommonObject
|
|||||||
$this->type='Type adherent'; // Libelle type adherent
|
$this->type='Type adherent'; // Libelle type adherent
|
||||||
$this->need_subscription=0;
|
$this->need_subscription=0;
|
||||||
|
|
||||||
$this->firstsubscription_date=time();
|
$this->first_subscription_date=time();
|
||||||
$this->firstsubscription_amount=10;
|
$this->first_subscription_amount=10;
|
||||||
$this->lastsubscription_date=time();
|
$this->last_subscription_date=time();
|
||||||
$this->lastsubscription_amount=10;
|
$this->last_subscription_amount=10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1992,10 +1998,10 @@ class Adherent extends CommonObject
|
|||||||
if ($this->datefin && $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap');
|
if ($this->datefin && $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION) $info[$conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION] = dol_print_date($this->datefin,'dayhourldap');
|
||||||
|
|
||||||
// Subscriptions
|
// Subscriptions
|
||||||
if ($this->firstsubscription_date && $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] = dol_print_date($this->firstsubscription_date,'dayhourldap');
|
if ($this->first_subscription_date && $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE] = dol_print_date($this->first_subscription_date,'dayhourldap');
|
||||||
if (isset($this->firstsubscription_amount) && $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->firstsubscription_amount;
|
if (isset($this->first_subscription_amount) && $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT) $info[$conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT] = $this->first_subscription_amount;
|
||||||
if ($this->lastsubscription_date && $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] = dol_print_date($this->lastsubscription_date,'dayhourldap');
|
if ($this->last_subscription_date && $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE] = dol_print_date($this->last_subscription_date,'dayhourldap');
|
||||||
if (isset($this->lastsubscription_amount) && $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->lastsubscription_amount;
|
if (isset($this->last_subscription_amount) && $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT) $info[$conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT] = $this->last_subscription_amount;
|
||||||
|
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1298,7 +1298,8 @@ if ($rowid && $action != 'edit')
|
|||||||
{
|
{
|
||||||
if ($user->rights->user->user->creer)
|
if ($user->rights->user->user->creer)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="fiche.php?rowid='.$adh->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
|
if ($adh->statut != -1) print '<a class="butAction" href="fiche.php?rowid='.$adh->id.'&action=create_user">'.$langs->trans("CreateDolibarrLogin").'</a>';
|
||||||
|
else print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("CreateDolibarrLogin").'</a>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user