27 include_once DOL_DOCUMENT_ROOT .
'/core/boxes/modules_boxes.php';
35 public $boxcode =
"box_members_subscriptions_by_year";
36 public $boximg =
"object_user";
37 public $boxlabel =
"BoxTitleMembersSubscriptionsByYear";
38 public $depends = array(
"adherent");
48 public $info_box_head = array();
49 public $info_box_contents = array();
65 $listofmodulesforexternal = explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
66 if (!in_array(
'adherent', $listofmodulesforexternal) && !empty($user->socid)) {
70 $this->hidden = !(
isModEnabled(
'adherent') && $user->rights->adherent->lire);
81 global $user, $langs, $conf;
82 $langs->load(
"boxes");
86 include_once DOL_DOCUMENT_ROOT .
'/adherents/class/adherent.class.php';
87 require_once DOL_DOCUMENT_ROOT .
'/adherents/class/adherent_type.class.php';
91 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleMembersSubscriptionsByYear", $max));
93 if ($user->rights->adherent->lire) {
102 $sql =
"SELECT c.subscription, c.dateadh as dateh";
103 $sql .=
" FROM " . MAIN_DB_PREFIX .
"adherent as d, " . MAIN_DB_PREFIX .
"subscription as c";
104 $sql .=
" WHERE d.entity IN (" .
getEntity(
'adherent') .
")";
105 $sql .=
" AND d.rowid = c.fk_adherent";
108 $result = $this->
db->query($sql);
110 $num = $this->
db->num_rows($result);
113 $objp = $this->
db->fetch_object($result);
115 $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription;
116 $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1;
117 $tot += $objp->subscription;
124 $this->info_box_contents[$line][] = array(
126 'text' => $langs->trans(
"Year"),
128 $this->info_box_contents[$line][] = array(
129 'td' =>
'class="right"',
130 'text' => $langs->trans(
"Subscriptions"),
132 $this->info_box_contents[$line][] = array(
133 'td' =>
'class="right"',
134 'text' => $langs->trans(
"AmountTotal"),
136 $this->info_box_contents[$line][] = array(
137 'td' =>
'class="right"',
138 'text' => $langs->trans(
"AmountAverage"),
145 foreach ($Total as $key => $value) {
153 $this->info_box_contents[$line][] = array(
154 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
157 $this->info_box_contents[$line][] = array(
158 'td' =>
'class="right"',
161 $this->info_box_contents[$line][] = array(
162 'td' =>
'class="right"',
165 $this->info_box_contents[$line][] = array(
166 'td' =>
'class="right"',
172 $this->info_box_contents[$line][] = array(
173 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
174 'text' =>
'<a href="./subscription/list.php?date_select='.$key.
'">'.$key.
'</a>',
177 $this->info_box_contents[$line][] = array(
178 'td' =>
'class="right"',
179 'text' => $Number[$key],
181 $this->info_box_contents[$line][] = array(
182 'td' =>
'class="nowraponall right amount"',
183 'text' =>
price($value),
185 $this->info_box_contents[$line][] = array(
186 'td' =>
'class="nowraponall right amount"',
193 $this->info_box_contents[$line][0] = array(
194 'td' =>
'class="center"',
195 'text' => $langs->trans(
"NoRecordedMembers"),
198 $this->info_box_contents[$line][] = array(
199 'tr' =>
'class="liste_total"',
200 'td' =>
'class="liste_total"',
201 'text' => $langs->trans(
"Total"),
203 $this->info_box_contents[$line][] = array(
204 'td' =>
'class="liste_total right"',
207 $this->info_box_contents[$line][] = array(
208 'td' =>
'class="liste_total nowraponall right amount"',
209 'text' =>
price($tot),
211 $this->info_box_contents[$line][] = array(
212 'td' =>
'class="liste_total nowraponall right amount"',
217 $this->info_box_contents[0][0] = array(
220 'text' => ($this->
db->error() .
' sql=' . $sql),
224 $this->info_box_contents[0][0] = array(
225 'td' =>
'class="nohover opacitymedium left"',
226 'text' => $langs->trans(
"ReadPermissionNotAllowed")
239 public function showBox($head =
null, $contents =
null, $nooutput = 0)
241 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage members of a foundation.
Class to manage members type.
Class to manage the box to show last modofied members.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
loadBox($max=5)
Load data into info_box_contents array to show array later.
__construct($db, $param='')
Constructor.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$conf db
API class for accounts.