dolibarr 20.0.2
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4 * Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
7 * Copyright (C) 2021-2023 Frédéric France <frederic.france@netlgic.fr>
8 * Copyright (C) 2021-2023 Waël Almoman <info@almoman.com>
9 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
34require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
35require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
37
38
39// Load translation files required by the page
40$langs->loadLangs(array("companies", "members"));
41
42
43$hookmanager = new HookManager($db);
44
45// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
46$hookmanager->initHooks(array('membersindex'));
47
48
49// Security check
50$result = restrictedArea($user, 'adherent');
51
52
53/*
54 * Actions
55 */
56
57$userid = GETPOSTINT('userid');
58if (GETPOST('addbox')) {
59 // Add box (when submit is done from a form when ajax disabled)
60 require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
61 $zone = GETPOSTINT('areacode');
62 $boxorder = GETPOST('boxorder', 'aZ09');
63 $boxorder .= GETPOST('boxcombo', 'aZ09');
64 $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
65 if ($result > 0) {
66 setEventMessages($langs->trans("BoxAdded"), null);
67 }
68}
69
70
71/*
72 * View
73 */
74
75$form = new Form($db);
76
77// Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
78$resultboxes = FormOther::getBoxesArea($user, "2");
79
80llxHeader('', $langs->trans("Members"), 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder');
81
82$staticmember = new Adherent($db);
83$statictype = new AdherentType($db);
84$subscriptionstatic = new Subscription($db);
85
86print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist'], 'members');
87
88/*
89 * Statistics
90 */
91
92$boxgraph = '';
93if ($conf->use_javascript_ajax) {
94 $year = idate('Y');
95 $numberyears = getDolGlobalInt("MAIN_NB_OF_YEAR_IN_MEMBERSHIP_WIDGET_GRAPH");
96
97 $boxgraph .= '<div class="div-table-responsive-no-min">';
98 $boxgraph .= '<table class="noborder nohover centpercent">';
99 $boxgraph .= '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").($numberyears ? ' ('.($year - $numberyears).' - '.$year.')' : '').'</th></tr>';
100 $boxgraph .= '<tr><td class="center" colspan="2">';
101
102 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php';
103 $stats = new AdherentStats($db, 0, $userid);
104
105 // Show array
106 $sumMembers = $stats->countMembersByTypeAndStatus($numberyears);
107 if (is_array($sumMembers) && !empty($sumMembers)) {
108 $total = $sumMembers['total']['members_draft'] + $sumMembers['total']['members_pending'] + $sumMembers['total']['members_uptodate'] + $sumMembers['total']['members_expired'] + $sumMembers['total']['members_excluded'] + $sumMembers['total']['members_resiliated'];
109 } else {
110 $total = 0;
111 }
112 foreach (array('members_draft', 'members_pending', 'members_uptodate', 'members_expired', 'members_excluded', 'members_resiliated') as $val) {
113 if (empty($sumMembers['total'][$val])) {
114 $sumMembers['total'][$val] = 0;
115 }
116 }
117
118 $dataseries = array();
119 $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), $sumMembers['total']['members_draft']); // Draft, not yet validated
120 $dataseries[] = array($langs->transnoentitiesnoconv("WaitingSubscription"), $sumMembers['total']['members_pending']);
121 $dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), $sumMembers['total']['members_uptodate']);
122 $dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), $sumMembers['total']['members_expired']);
123 $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusExcluded"), $sumMembers['total']['members_excluded']);
124 $dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), $sumMembers['total']['members_resiliated']);
125
126 include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
127
128 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
129 $dolgraph = new DolGraph();
130 $dolgraph->SetData($dataseries);
131 $dolgraph->SetDataColor(array('-'.$badgeStatus0, $badgeStatus1, $badgeStatus4, $badgeStatus8, '-'.$badgeStatus8, $badgeStatus6));
132 $dolgraph->setShowLegend(2);
133 $dolgraph->setShowPercent(1);
134 $dolgraph->SetType(array('pie'));
135 $dolgraph->setHeight('200');
136 $dolgraph->draw('idgraphstatus');
137 $boxgraph .= $dolgraph->show($total ? 0 : 1);
138
139 $boxgraph .= '</td></tr>';
140 $boxgraph .= '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
141 $boxgraph .= $total;
142 $boxgraph .= '</td></tr>';
143 $boxgraph .= '</table>';
144 $boxgraph .= '</div>';
145 $boxgraph .= '<br>';
146}
147
148// boxes
149print '<div class="clearboth"></div>';
150print '<div class="fichecenter fichecenterbis">';
151
152print '<div class="twocolumns">';
153
154print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
155
156print $boxgraph;
157
158print $resultboxes['boxlista'];
159
160print '</div>'."\n";
161
162print '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
163
164print $resultboxes['boxlistb'];
165
166print '</div>'."\n";
167
168print '</div>';
169print '</div>';
170
171$parameters = array('user' => $user);
172$reshook = $hookmanager->executeHooks('dashboardMembers', $parameters, $object); // Note that $action and $object may have been modified by hook
173
174// End of page
175llxFooter();
176$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class to manage members of a foundation.
Class to manage statistics of members.
Class to manage members type.
Class to build graphs.
Class to manage generation of HTML components Only common components must be here.
static getBoxesArea($user, $areacode)
Get array with HTML tabs with boxes of a particular area including personalized choices of user.
Class to manage hooks.
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
Class to manage subscriptions of foundation members.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.