Update adherent_type.class.php
This commit is contained in:
parent
5f23c68f85
commit
4c3e37681c
@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2009-2017 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2018-2019 Thibault Foucart <support@ptibogxiv.net>
|
||||
* Copyright (C) 2021 Waël Almoman <info@almoman.com>
|
||||
* Copyright (C) 2021 Waël Almoman <info@almoman.com>
|
||||
*
|
||||
* 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
|
||||
@ -88,6 +88,11 @@ class AdherentType extends CommonObject
|
||||
* @var int Subsription required (0 or 1)
|
||||
*/
|
||||
public $subscription;
|
||||
|
||||
/**
|
||||
* @var float amount for subscription if required
|
||||
*/
|
||||
public $amount;
|
||||
|
||||
/** @var string Public note */
|
||||
public $note;
|
||||
@ -361,6 +366,7 @@ class AdherentType extends CommonObject
|
||||
$sql .= "libelle = '".$this->db->escape($this->label)."',";
|
||||
$sql .= "morphy = '".$this->db->escape($this->morphy)."',";
|
||||
$sql .= "subscription = '".$this->db->escape($this->subscription)."',";
|
||||
$sql .= "amount = '".$this->db->escape($this->amount)."',";
|
||||
$sql .= "duration = '".$this->db->escape($this->duration_value.$this->duration_unit)."',";
|
||||
$sql .= "note = '".$this->db->escape($this->note)."',";
|
||||
$sql .= "vote = ".(integer) $this->db->escape($this->vote).",";
|
||||
@ -455,7 +461,7 @@ class AdherentType extends CommonObject
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote";
|
||||
$sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.amount, d.mail_valid, d.note, d.vote";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
|
||||
$sql .= " WHERE d.rowid = ".(int) $rowid;
|
||||
|
||||
@ -475,6 +481,7 @@ class AdherentType extends CommonObject
|
||||
$this->duration_value = substr($obj->duration, 0, dol_strlen($obj->duration) - 1);
|
||||
$this->duration_unit = substr($obj->duration, -1);
|
||||
$this->subscription = $obj->subscription;
|
||||
$this->amount = $obj->amount;
|
||||
$this->mail_valid = $obj->mail_valid;
|
||||
$this->note = $obj->note;
|
||||
$this->vote = $obj->vote;
|
||||
@ -535,6 +542,44 @@ class AdherentType extends CommonObject
|
||||
return $adherenttypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return list of amount by type id
|
||||
*
|
||||
* @param int $status Filter on status of type
|
||||
* @return array List of types of members
|
||||
*/
|
||||
public function amount_by_type($status = null) {
|
||||
|
||||
global $conf, $langs;
|
||||
|
||||
$amountbytype = array();
|
||||
|
||||
$sql = "SELECT rowid, amount";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type";
|
||||
$sql .= " WHERE entity IN (".getEntity('member_type').")";
|
||||
if ($status !== null) {
|
||||
$sql .= " AND statut = ".((int) $status);
|
||||
}
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql) {
|
||||
$nump = $this->db->num_rows($resql);
|
||||
|
||||
if ($nump) {
|
||||
$i = 0;
|
||||
while ($i < $nump) {
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$amountbytype[$obj->rowid] = $obj->amount;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
print $this->db->error();
|
||||
}
|
||||
return $amountbytype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of Member objects for member type this->id (or all if this->id not defined)
|
||||
*
|
||||
|
||||
Loading…
Reference in New Issue
Block a user