dolibarr 24.0.0-beta
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-2026 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2021-2023 Waël Almoman <info@almoman.com>
9 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
10 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <https://www.gnu.org/licenses/>.
24 */
25
32// Load Dolibarr environment
33require '../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
42require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
43require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
44require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
45
46// Load translation files required by the page
47$langs->loadLangs(array("companies", "members"));
48
49// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
50$hookmanager->initHooks(array('membersindex'));
51
52// Security check
53$result = restrictedArea($user, 'adherent');
54
55
56/*
57 * Actions
58 */
59
60$userid = GETPOSTINT('userid');
61if (GETPOST('addbox')) {
62 // Add box (when submit is done from a form when ajax disabled)
63 require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
64 $zone = GETPOSTINT('areacode');
65 $boxorder = GETPOST('boxorder', 'aZ09');
66 $boxorder .= GETPOST('boxcombo', 'aZ09');
67 $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
68 if ($result > 0) {
69 setEventMessages($langs->trans("BoxAdded"), null);
70 }
71}
72
73
74/*
75 * View
76 */
77
78$form = new Form($db);
79
80// Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
81$resultboxes = FormOther::getBoxesArea($user, "2");
82
83$title = $langs->trans("Members");
84$help_url = 'EN:Module_Foundations|FR:Module_Adh&eacute;rents|ES:M&oacute;dulo_Miembros|DE:Modul_Mitglieder';
85
86llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-member page-index');
87
88$staticmember = new Adherent($db);
89$statictype = new AdherentType($db);
90$subscriptionstatic = new Subscription($db);
91
92print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist'], 'members');
93
94/*
95 * Statistics
96 */
97
98$boxgraph = '';
99if ($conf->use_javascript_ajax) {
100 $year = idate('Y');
101 $numberyears = getDolGlobalInt("MAIN_NB_OF_YEAR_IN_MEMBERSHIP_WIDGET_GRAPH");
102
103 $boxgraph .= '<div class="div-table-responsive-no-min">';
104 $boxgraph .= '<table class="noborder nohover centpercent">';
105 $boxgraph .= '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("Status").' '.($numberyears ? ' ('.($year - $numberyears).' - '.$year.')' : '').'</th></tr>';
106 $boxgraph .= '<tr><td class="center" colspan="2">';
107
108 require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherentstats.class.php';
109 $stats = new AdherentStats($db, 0, $userid);
110
111 // Show array
112 $sumMembers = $stats->countMembersByTypeAndStatus($numberyears);
113 if (is_array($sumMembers) && !empty($sumMembers)) {
114 $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'];
115 } else {
116 $total = 0;
117 }
118 foreach (array('members_draft', 'members_pending', 'members_uptodate', 'members_expired', 'members_excluded', 'members_resiliated') as $val) {
119 if (empty($sumMembers['total'][$val])) {
120 $sumMembers['total'][$val] = 0;
121 }
122 }
123
124 $dataseries = [
125 [$langs->transnoentitiesnoconv("MembersStatusToValid"), $sumMembers['total']['members_draft']], // Draft, not yet validated
126 [$langs->transnoentitiesnoconv("WaitingSubscription"), $sumMembers['total']['members_pending']],
127 [$langs->transnoentitiesnoconv("UpToDate"), $sumMembers['total']['members_uptodate']],
128 [$langs->transnoentitiesnoconv("OutOfDate"), $sumMembers['total']['members_expired']],
129 [$langs->transnoentitiesnoconv("MembersStatusExcluded"), $sumMembers['total']['members_excluded']],
130 [$langs->transnoentitiesnoconv("MembersStatusResiliated"), $sumMembers['total']['members_resiliated']],
131 ];
132
140 include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
141
142 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
143 $dolgraph = new DolGraph();
144 $dolgraph->SetData($dataseries);
145 $dolgraph->SetDataColor(array('-'.$badgeStatus0, $badgeStatus1, $badgeStatus4, $badgeStatus8, '-'.$badgeStatus8, $badgeStatus6));
146 $dolgraph->setShowLegend(2);
147 $dolgraph->setShowPercent(1);
148 $dolgraph->SetType(array('pie'));
149 $dolgraph->setHeight('200');
150 $dolgraph->draw('idgraphstatus');
151 $boxgraph .= $dolgraph->show($total ? 0 : 1);
152
153 $boxgraph .= '</td></tr>';
154 $boxgraph .= '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
155 $boxgraph .= $total;
156 $boxgraph .= '</td></tr>';
157 $boxgraph .= '</table>';
158 $boxgraph .= '</div>';
159 $boxgraph .= '<br>';
160}
161
162// boxes
163print '<div class="clearboth"></div>';
164print '<div class="fichecenter fichecenterbis">';
165
166print '<div class="twocolumns">';
167
168print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
169
170print $boxgraph;
171
172print $resultboxes['boxlista'];
173
174print '</div>'."\n";
175
176print '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
177
178print $resultboxes['boxlistb'];
179
180print '</div>'."\n";
181
182print '</div>';
183print '</div>';
184
185$parameters = array('user' => $user);
186$reshook = $hookmanager->executeHooks('dashboardMembers', $parameters, $object); // Note that $action and $object may have been modified by hook
187
188// End of page
189llxFooter();
190$db->close();
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
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 widgets/boxes of a particular area including personalized choices of us...
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
Class to manage subscriptions of foundation members.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.