28 include_once DOL_DOCUMENT_ROOT .
'/core/boxes/modules_boxes.php';
36 public $boxcode =
"box_members_by_type";
37 public $boximg =
"object_user";
38 public $boxlabel =
"BoxTitleMembersByType";
39 public $depends = array(
"adherent");
49 public $info_box_head = array();
50 public $info_box_contents = array();
66 $listofmodulesforexternal = explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL);
67 if (!in_array(
'adherent', $listofmodulesforexternal) && !empty($user->socid)) {
71 $this->hidden = !(
isModEnabled(
'adherent') && $user->rights->adherent->lire);
82 global $user, $langs, $conf;
83 $langs->loadLangs(array(
"boxes",
"members"));
87 include_once DOL_DOCUMENT_ROOT .
'/adherents/class/adherent.class.php';
88 require_once DOL_DOCUMENT_ROOT .
'/adherents/class/adherent_type.class.php';
91 $this->info_box_head = array(
'text' => $langs->trans(
"BoxTitleMembersByType", $max));
93 if ($user->rights->adherent->lire) {
94 $MembersToValidate = array();
95 $MembersPending = array();
96 $MembersValidated = array();
97 $MembersUpToDate = array();
98 $MembersExcluded = array();
99 $MembersResiliated = array();
108 $AdherentType = array();
111 $sql =
"SELECT t.rowid, t.libelle as label, t.subscription,";
112 $sql .=
" d.statut, count(d.rowid) as somme";
113 $sql .=
" FROM " . MAIN_DB_PREFIX .
"adherent_type as t";
114 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"adherent as d";
115 $sql .=
" ON t.rowid = d.fk_adherent_type";
116 $sql .=
" AND d.entity IN (" .
getEntity(
'adherent') .
")";
117 $sql .=
" WHERE t.entity IN (" .
getEntity(
'member_type') .
")";
118 $sql .=
" GROUP BY t.rowid, t.libelle, t.subscription, d.statut";
120 dol_syslog(
"box_members_by_type::select nb of members per type", LOG_DEBUG);
121 $result = $this->
db->query($sql);
123 $num = $this->
db->num_rows($result);
126 $objp = $this->
db->fetch_object($result);
129 $adhtype->id = $objp->rowid;
130 $adhtype->subscription = $objp->subscription;
131 $adhtype->label = $objp->label;
132 $AdherentType[$objp->rowid] = $adhtype;
135 $MembersToValidate[$objp->rowid] = $objp->somme;
138 $MembersValidated[$objp->rowid] = $objp->somme;
141 $MembersExcluded[$objp->rowid] = $objp->somme;
144 $MembersResiliated[$objp->rowid] = $objp->somme;
149 $this->
db->free($result);
155 $sql =
"SELECT count(*) as somme , d.fk_adherent_type";
156 $sql .=
" FROM " . MAIN_DB_PREFIX .
"adherent as d, " . MAIN_DB_PREFIX .
"adherent_type as t";
157 $sql .=
" WHERE d.entity IN (" .
getEntity(
'adherent') .
")";
158 $sql .=
" AND d.statut = 1 AND (d.datefin >= '" . $this->
db->idate($now) .
"' OR t.subscription = 0)";
159 $sql .=
" AND t.rowid = d.fk_adherent_type";
160 $sql .=
" GROUP BY d.fk_adherent_type";
162 dol_syslog(
"index.php::select nb of uptodate members by type", LOG_DEBUG);
163 $result = $this->
db->query($sql);
165 $num2 = $this->
db->num_rows($result);
168 $objp = $this->
db->fetch_object($result);
169 $MembersUpToDate[$objp->fk_adherent_type] = $objp->somme;
172 $this->
db->free($result);
175 $sql =
"SELECT count(*) as somme , d.fk_adherent_type";
176 $sql .=
" FROM " . MAIN_DB_PREFIX .
"adherent as d, " . MAIN_DB_PREFIX .
"adherent_type as t";
177 $sql .=
" WHERE d.entity IN (" .
getEntity(
'adherent') .
")";
178 $sql .=
" AND d.statut = 1 AND (d.datefin IS NULL AND t.subscription = 1)";
179 $sql .=
" AND t.rowid = d.fk_adherent_type";
180 $sql .=
" GROUP BY d.fk_adherent_type";
182 dol_syslog(
"index.php::select nb of uptodate members by type", LOG_DEBUG);
183 $result = $this->
db->query($sql);
185 $num2 = $this->
db->num_rows($result);
188 $objp = $this->
db->fetch_object($result);
189 $MembersPending[$objp->fk_adherent_type] = $objp->somme;
192 $this->
db->free($result);
196 $this->info_box_contents[$line][] = array(
201 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_DRAFT, 0, 0, 1);
202 $this->info_box_contents[$line][] = array(
203 'td' =>
'class="right tdoverflowmax100" width="15%" title="'.
dol_escape_htmltag($labelstatus).
'"',
204 'text' => $labelstatus
207 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1, 0, 1);
208 $this->info_box_contents[$line][] = array(
209 'td' =>
'class="right tdoverflowmax100" width="15%" title="'.
dol_escape_htmltag($labelstatus).
'"',
210 'text' => $labelstatus
213 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1,
dol_now() + 86400, 1);
214 $this->info_box_contents[$line][] = array(
215 'td' =>
'class="right tdoverflowmax100" width="15%" title="'.
dol_escape_htmltag($labelstatus).
'"',
216 'text' => $labelstatus,
219 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_VALIDATED, 1,
dol_now() - 86400, 1);
220 $this->info_box_contents[$line][] = array(
221 'td' =>
'class="right tdoverflowmax100" width="15%" title="'.
dol_escape_htmltag($labelstatus).
'"',
222 'text' => $labelstatus
225 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_EXCLUDED, 0, 0, 1);
226 $this->info_box_contents[$line][] = array(
227 'td' =>
'class="right tdoverflowmax100" width="15%" title="'.
dol_escape_htmltag($labelstatus).
'"',
228 'text' => $labelstatus
231 $labelstatus = $staticmember->LibStatut($staticmember::STATUS_RESILIATED, 0, 0, 1);
232 $this->info_box_contents[$line][] = array(
233 'td' =>
'class="right tdoverflowmax100" width="15%" title="'.
dol_escape_htmltag($labelstatus).
'"',
234 'text' => $labelstatus
238 foreach ($AdherentType as $key => $adhtype) {
239 $SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0;
240 $SumPending += isset($MembersPending[$key]) ? $MembersPending[$key] : 0;
241 $SumExpired += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) - (isset($MembersPending[$key]) ? $MembersPending[$key] : 0): 0;
242 $SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0;
243 $SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0;
244 $SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0;
246 $this->info_box_contents[$line][] = array(
247 'td' =>
'class="tdoverflowmax150 maxwidth150onsmartphone"',
248 'text' => $adhtype->getNomUrl(1,
dol_size(32)),
251 $this->info_box_contents[$line][] = array(
252 'td' =>
'class="right"',
253 'text' => (isset($MembersToValidate[$key]) && $MembersToValidate[$key] > 0 ? $MembersToValidate[$key] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_DRAFT, 1, 0, 3),
256 $this->info_box_contents[$line][] = array(
257 'td' =>
'class="right"',
258 'text' => (isset($MembersPending[$key]) && $MembersPending[$key] > 0 ? $MembersPending[$key] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_VALIDATED, 1, 0, 3),
261 $this->info_box_contents[$line][] = array(
262 'td' =>
'class="right"',
263 'text' => (isset($MembersUpToDate[$key]) && $MembersUpToDate[$key] > 0 ? $MembersUpToDate[$key] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_VALIDATED, 1, $now, 3),
266 $this->info_box_contents[$line][] = array(
267 'td' =>
'class="right"',
268 'text' => (isset($MembersValidated[$key]) && ($MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) > 0) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_VALIDATED, 1, 1, 3),
271 $this->info_box_contents[$line][] = array(
272 'td' =>
'class="right"',
273 'text' => (isset($MembersExcluded[$key]) && $MembersExcluded[$key] > 0 ? $MembersExcluded[$key] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_EXCLUDED, 1, $now, 3),
276 $this->info_box_contents[$line][] = array(
277 'td' =>
'class="right"',
278 'text' => (isset($MembersResiliated[$key]) && $MembersResiliated[$key] > 0 ? $MembersResiliated[$key] :
'') .
' ' . $staticmember->LibStatut(
Adherent::STATUS_RESILIATED, 1, 0, 3),
286 $this->info_box_contents[$line][0] = array(
287 'td' =>
'colspan="7" class="center"',
288 'text' => $langs->trans(
"NoRecordedMembersByType")
291 $this->info_box_contents[$line][] = array(
292 'tr' =>
'class="liste_total"',
293 'td' =>
'class="liste_total"',
294 'text' => $langs->trans(
"Total")
296 $this->info_box_contents[$line][] = array(
297 'td' =>
'class="liste_total right"',
301 $this->info_box_contents[$line][] = array(
302 'td' =>
'class="liste_total right"',
306 $this->info_box_contents[$line][] = array(
307 'td' =>
'class="liste_total right"',
311 $this->info_box_contents[$line][] = array(
312 'td' =>
'class="liste_total right"',
316 $this->info_box_contents[$line][] = array(
317 'td' =>
'class="liste_total right"',
321 $this->info_box_contents[$line][] = array(
322 'td' =>
'class="liste_total right"',
328 $this->info_box_contents[0][0] = array(
331 'text' => ($this->
db->error() .
' sql=' . $sql)
335 $this->info_box_contents[0][0] = array(
336 'td' =>
'class="nohover opacitymedium left"',
337 'text' => $langs->trans(
"ReadPermissionNotAllowed")
350 public function showBox($head =
null, $contents =
null, $nooutput = 0)
352 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
Class to manage members of a foundation.
const STATUS_EXCLUDED
Excluded.
const STATUS_DRAFT
Draft status.
const STATUS_RESILIATED
Resiliated.
const STATUS_VALIDATED
Validated status.
Class to manage members type.
Class to manage the box to show last modofied members.
loadBox($max=5)
Load data into info_box_contents array to show array later.
__construct($db, $param='')
Constructor.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_now($mode='auto')
Return date for now.
dol_size($size, $type='')
Optimize a size for some browsers (phone, smarphone, ...)
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$conf db
API class for accounts.