From 4c3e37681cd5bf2fe443f545db2c880daada24b3 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Sat, 1 May 2021 20:06:15 +0200 Subject: [PATCH] Update adherent_type.class.php --- .../adherents/class/adherent_type.class.php | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index d051c40810b..4924acf5ab6 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2009-2017 Regis Houssin * Copyright (C) 2016 Charlie Benke * Copyright (C) 2018-2019 Thibault Foucart - * Copyright (C) 2021 Waël Almoman + * Copyright (C) 2021 Waël Almoman * * 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) *