Merge pull request #17411 from daraelmin/daraelmin-patch-adh-const

Fix wrong set of constant
This commit is contained in:
Laurent Destailleur 2021-04-28 15:32:41 +02:00 committed by GitHub
commit 2feca855e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -206,7 +206,7 @@ class Adherent extends CommonObject
public $public;
// -2:exclu, -1:brouillon, 0:resilie, >=1:valide,paye
// -2:excluded, -1:draft, 0:resiliated, >=1:valided,payed
// def in common object
//public $status;
@ -326,7 +326,7 @@ class Adherent extends CommonObject
'fk_user_valid' => array('type' => 'integer:User:user/class/user.class.php', 'label' => 'UserValidation', 'enabled' => 1, 'visible' => -1, 'position' => 190),
'canvas' => array('type' => 'varchar(32)', 'label' => 'Canvas', 'enabled' => 1, 'visible' => -1, 'position' => 195),
'statut' => array('type' => 'smallint(6)', 'label' => 'Statut', 'enabled' => 1, 'visible' => -1, 'notnull' => 1, 'position' => 500,
'arrayofkeyval' => array(0 => 'Draft', 1 => 'Validated', -1 => 'MemberStatusResiliatedShort', -2 => 'MemberStatusExcludedShort')),
'arrayofkeyval' => array(-1 => 'Draft', 1 => 'Validated', 0 => 'MemberStatusResiliatedShort', -2 => 'MemberStatusExcludedShort')),
'model_pdf' => array('type' => 'varchar(255)', 'label' => 'Model pdf', 'enabled' => 1, 'visible' => 0, 'position' => 800),
'import_key' => array('type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'visible' => -2, 'position' => 805)
);
@ -334,7 +334,7 @@ class Adherent extends CommonObject
/**
* Draft status
*/
const STATUS_DRAFT = 0;
const STATUS_DRAFT = -1;
/**
* Validated status
*/
@ -342,7 +342,7 @@ class Adherent extends CommonObject
/**
* Resiliated
*/
const STATUS_RESILIATED = -1;
const STATUS_RESILIATED = 0;
/**
* Excluded
*/
@ -357,7 +357,7 @@ class Adherent extends CommonObject
public function __construct($db)
{
$this->db = $db;
$this->statut = -1;
$this->statut = self::STATUS_DRAFT; // shouldn't this be $status ?
// l'adherent n'est pas public par defaut
$this->public = 0;
// les champs optionnels sont vides
@ -1854,7 +1854,7 @@ class Adherent extends CommonObject
$now = dol_now();
// Check parameters
if ($this->statut == 1) {
if ($this->statut == self::STATUS_VALIDATED) {
dol_syslog(get_class($this)."::validate statut of member does not allow this", LOG_WARNING);
return 0;
}
@ -1862,7 +1862,7 @@ class Adherent extends CommonObject
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql .= " statut = 1";
$sql .= " statut = ".self::STATUS_VALIDATED;
$sql .= ", datevalid = '".$this->db->idate($now)."'";
$sql .= ", fk_user_valid=".$user->id;
$sql .= " WHERE rowid = ".$this->id;
@ -1870,7 +1870,7 @@ class Adherent extends CommonObject
dol_syslog(get_class($this)."::validate", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$this->statut = 1;
$this->statut = self::STATUS_VALIDATED;
// Call trigger
$result = $this->call_trigger('MEMBER_VALIDATE', $user);
@ -1906,7 +1906,7 @@ class Adherent extends CommonObject
$error = 0;
// Check parameters
if ($this->statut == 0) {
if ($this->statut == self::STATUS_RESILIATED) {
dol_syslog(get_class($this)."::resiliate statut of member does not allow this", LOG_WARNING);
return 0;
}
@ -1914,13 +1914,13 @@ class Adherent extends CommonObject
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql .= " statut = 0";
$sql .= " statut = ".self::STATUS_RESILIATED;
$sql .= ", fk_user_valid=".$user->id;
$sql .= " WHERE rowid = ".$this->id;
$result = $this->db->query($sql);
if ($result) {
$this->statut = 0;
$this->statut = self::STATUS_RESILIATED;
// Call trigger
$result = $this->call_trigger('MEMBER_RESILIATE', $user);
@ -1956,7 +1956,7 @@ class Adherent extends CommonObject
$error = 0;
// Check parameters
if ($this->statut == 0) {
if ($this->statut == self::STATUS_EXCLUDED) {
dol_syslog(get_class($this)."::resiliate statut of member does not allow this", LOG_WARNING);
return 0;
}
@ -1964,13 +1964,13 @@ class Adherent extends CommonObject
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql .= " statut = -2";
$sql .= " statut = ".self::STATUS_EXCLUDED;
$sql .= ", fk_user_valid=".$user->id;
$sql .= " WHERE rowid = ".$this->id;
$result = $this->db->query($sql);
if ($result) {
$this->statut = 0;
$this->statut = self::STATUS_EXCLUDED;
// Call trigger
$result = $this->call_trigger('MEMBER_EXCLUDE', $user);
@ -2275,11 +2275,11 @@ class Adherent extends CommonObject
$labelStatus = '';
$labelStatusShort = '';
if ($status == -1) {
if ($status == self::STATUS_DRAFT) {
$statusType = 'status0';
$labelStatus = $langs->trans("MemberStatusDraft");
$labelStatusShort = $langs->trans("MemberStatusDraftShort");
} elseif ($status >= 1) {
} elseif ($status >= self::STATUS_VALIDATED) {
if ($need_subscription == 0) {
$statusType = 'status4';
$labelStatus = $langs->trans("MemberStatusNoSubscription");
@ -2297,11 +2297,11 @@ class Adherent extends CommonObject
$labelStatus = $langs->trans("MemberStatusPaid");
$labelStatusShort = $langs->trans("MemberStatusPaidShort");
}
} elseif ($status == 0) {
} elseif ($status == self::STATUS_RESILIATED) {
$statusType = 'status6';
$labelStatus = $langs->trans("MemberStatusResiliated");
$labelStatusShort = $langs->trans("MemberStatusResiliatedShort");
} elseif ($status == -2) {
} elseif ($status == self::STATUS_EXCLUDED) {
$statusType = 'status10';
$labelStatus = $langs->trans("MemberStatusExcluded");
$labelStatusShort = $langs->trans("MemberStatusExcludedShort");
@ -2367,11 +2367,11 @@ class Adherent extends CommonObject
$sql .= ", ".MAIN_DB_PREFIX."adherent_type as t";
$sql .= " WHERE a.fk_adherent_type = t.rowid";
if ($mode == 'expired') {
$sql .= " AND a.statut = 1";
$sql .= " AND a.statut = ".self::STATUS_VALIDATED;
$sql .= " AND a.entity IN (".getEntity('adherent').")";
$sql .= " AND ((a.datefin IS NULL or a.datefin < '".$this->db->idate($now)."') AND t.subscription = '1')";
} elseif ($mode == 'shift') {
$sql .= " AND a.statut = -1";
$sql .= " AND a.statut = ".self::STATUS_DRAFT;
$sql .= " AND a.entity IN (".getEntity('adherent').")";
}
@ -2388,10 +2388,10 @@ class Adherent extends CommonObject
$warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
$label = $langs->trans("MembersWithSubscriptionToReceive");
$labelShort = $langs->trans("MembersWithSubscriptionToReceiveShort");
$url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&amp;statut=1&amp;filter=outofdate';
$url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&amp;statut='.self::STATUS_VALIDATED.'&amp;filter=outofdate';
} elseif ($mode == 'shift') {
$warning_delay = $conf->adherent->subscription->warning_delay / 60 / 60 / 24;
$url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&amp;statut=-1';
$url = DOL_URL_ROOT.'/adherents/list.php?mainmenu=members&amp;statut='.self::STATUS_DRAFT;
$label = $langs->trans("MembersListToValid");
$labelShort = $langs->trans("ToValidate");
}
@ -2504,7 +2504,7 @@ class Adherent extends CommonObject
$this->birth = $now;
$this->photo = '';
$this->public = 1;
$this->statut = 0;
$this->statut = self::STATUS_DRAFT;
$this->datefin = $now;
$this->datevalid = $now;
@ -2823,7 +2823,7 @@ class Adherent extends CommonObject
global $conf;
//Only valid members
if ($this->statut <= 0) {
if ($this->statut != self::STATUS_VALIDATED) {
return false;
}
if (!$this->datefin) {