74 $langs->load(
"boxes");
78 include_once DOL_DOCUMENT_ROOT .
'/adherents/class/adherent.class.php';
79 $staticmember =
new Adherent($this->db);
83 $numberyears =
getDolGlobalInt(
"MAIN_NB_OF_YEAR_IN_MEMBERSHIP_WIDGET_GRAPH", 0);
85 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleMembersByTags").($numberyears ?
' ('.($year - $numberyears).
' - '.$year.
')' :
''));
87 if ($user->hasRight(
'adherent',
'lire')) {
88 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherentstats.class.php';
89 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
90 $stats =
new AdherentStats($this->db, $user->socid, $user->id);
93 $sumMembers = $stats->countMembersByTagAndStatus($numberyears);
96 $this->info_box_contents[$line][] = array(
101 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1);
102 $this->info_box_contents[$line][] = array(
103 'td' =>
'class="right tdoverflowmax100" width="10%" title="'.
dol_escape_htmltag($labelstatus).
'"',
104 'text' => $labelstatus
107 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, 0, 1);
108 $this->info_box_contents[$line][] = array(
109 'td' =>
'class="right tdoverflowmax100" width="10%" title="'.
dol_escape_htmltag($labelstatus).
'"',
110 'text' => $labelstatus,
113 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, $now + 86400, 1);
114 $this->info_box_contents[$line][] = array(
115 'td' =>
'class="right tdoverflowmax100" width="10%" title="'.
dol_escape_htmltag($labelstatus).
'"',
116 'text' => $labelstatus,
119 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, $now - 86400, 1);
120 $this->info_box_contents[$line][] = array(
121 'td' =>
'class="right tdoverflowmax100" width="10%" title="'.
dol_escape_htmltag($labelstatus).
'"',
122 'text' => $labelstatus
125 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1);
126 $this->info_box_contents[$line][] = array(
127 'td' =>
'class="right tdoverflowmax100" width="10%" title="'.
dol_escape_htmltag($labelstatus).
'"',
128 'text' => $labelstatus
131 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1);
132 $this->info_box_contents[$line][] = array(
133 'td' =>
'class="right tdoverflowmax100" width="10%" title="'.
dol_escape_htmltag($labelstatus).
'"',
134 'text' => $labelstatus
137 $this->info_box_contents[$line][] = array(
138 'td' =>
'class="right tdoverflowmax100" width="10%" title="'.
dol_escape_htmltag($langs->trans(
"Total")).
'"',
139 'text' => $langs->trans(
"Total")
142 $AdherentTag = array();
143 foreach ($sumMembers as $key => $data) {
144 if ($key ==
'total') {
148 $adhtag->id = (int) $key;
149 $adhtag->label = $data[
'label'];
150 $AdherentTag[$key] = $adhtag;
152 $this->info_box_contents[$line][] = array(
153 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
154 'text' =>
'<a href="'.DOL_MAIN_URL_ROOT.
'/adherents/list.php?search_categ='.$adhtag->id.
'&sortfield=d.datefin,t.subscription&sortorder=desc,desc&backtopage='.urlencode($_SERVER[
'PHP_SELF']).
'">'.
dol_trunc(($adhtag->ref ? $adhtag->ref : $adhtag->label),
dol_size(32)).
'</a>',
157 $this->info_box_contents[$line][] = array(
158 'td' =>
'class="right"',
159 'text' => (isset($data[
'members_draft']) && $data[
'members_draft'] > 0 ? $data[
'members_draft'] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_DRAFT, 1, 0, 3),
162 $this->info_box_contents[$line][] = array(
163 'td' =>
'class="right"',
164 'text' => (isset($data[
'members_pending']) && $data[
'members_pending'] > 0 ? $data[
'members_pending'] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_VALIDATED, 1, 0, 3),
167 $this->info_box_contents[$line][] = array(
168 'td' =>
'class="right"',
169 'text' => (isset($data[
'members_uptodate']) && $data[
'members_uptodate'] > 0 ? $data[
'members_uptodate'] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_VALIDATED, 0, $now + 86400, 3),
172 $this->info_box_contents[$line][] = array(
173 'td' =>
'class="right"',
174 'text' => (isset($data[
'members_expired']) && $data[
'members_expired'] > 0 ? $data[
'members_expired'] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_VALIDATED, 1, $now - 86400, 3),
177 $this->info_box_contents[$line][] = array(
178 'td' =>
'class="right"',
179 'text' => (isset($data[
'members_excluded']) && $data[
'members_excluded'] > 0 ? $data[
'members_excluded'] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_EXCLUDED, 1, $now, 3),
182 $this->info_box_contents[$line][] = array(
183 'td' =>
'class="right"',
184 'text' => (isset($data[
'members_resiliated']) && $data[
'members_resiliated'] > 0 ? $data[
'members_resiliated'] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_RESILIATED, 1, 0, 3),
187 $this->info_box_contents[$line][] = array(
188 'td' =>
'class="right"',
189 'text' => (isset($data[
'total_adhtag']) && $data[
'total_adhtag'] > 0 ? $data[
'total_adhtag'] :
''),
195 if (count($sumMembers) == 0) {
196 $this->info_box_contents[$line][0] = array(
197 'td' =>
'class="center" colspan="6"',
198 'text' => $langs->trans(
"NoRecordedMembersByType")
201 $this->info_box_contents[$line][] = array(
202 'tr' =>
'class="liste_total"',
203 'td' =>
'class="liste_total"',
204 'text' => $langs->trans(
"Total")
206 $this->info_box_contents[$line][] = array(
207 'td' =>
'class="liste_total right"',
208 'text' => $sumMembers[
'total'][
'members_draft'].
' '.$staticmember->LibStatut(
Adherent::STATUS_DRAFT, 1, 0, 3),
211 $this->info_box_contents[$line][] = array(
212 'td' =>
'class="liste_total right"',
216 $this->info_box_contents[$line][] = array(
217 'td' =>
'class="liste_total right"',
221 $this->info_box_contents[$line][] = array(
222 'td' =>
'class="liste_total right"',
226 $this->info_box_contents[$line][] = array(
227 'td' =>
'class="liste_total right"',
231 $this->info_box_contents[$line][] = array(
232 'td' =>
'class="liste_total right"',
236 $this->info_box_contents[$line][] = array(
237 'td' =>
'class="liste_total right"',
238 'text' => $sumMembers[
'total'][
'all'],
243 $this->info_box_contents[0][0] = array(
246 'text' => ($this->db->lasterror())
250 $this->info_box_contents[0][0] = array(
251 'td' =>
'class="nohover left"',
252 'text' =>
'<span class="opacitymedium">'.$langs->trans(
"ReadPermissionNotAllowed").
'</span>'