2004-10-19 20:58:50 +02:00
|
|
|
<?php
|
2012-04-15 11:28:21 +02:00
|
|
|
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2021-03-20 18:49:56 +01:00
|
|
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
|
|
|
|
* Copyright (C) 2004-2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
2020-05-11 01:19:33 +02:00
|
|
|
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
2021-03-02 22:31:55 +01:00
|
|
|
* Copyright (C) 2021 Frédéric France <frederic.france@netlgic.fr>
|
2021-03-29 03:28:32 +02:00
|
|
|
* Copyright (C) 2021 Waël Almoman <info@almoman.com>
|
2002-12-28 19:12:22 +01:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-12-28 19:12:22 +01:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-09-23 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2002-12-28 19:12:22 +01:00
|
|
|
*/
|
2004-08-14 14:37:59 +02:00
|
|
|
|
2005-03-05 19:45:40 +01:00
|
|
|
/**
|
2009-02-02 03:04:26 +01:00
|
|
|
* \file htdocs/adherents/index.php
|
2009-10-10 18:00:35 +02:00
|
|
|
* \ingroup member
|
2020-05-11 01:19:33 +02:00
|
|
|
* \brief Home page of membership module
|
2009-02-02 03:04:26 +01:00
|
|
|
*/
|
2004-08-14 14:37:59 +02:00
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
|
2016-09-24 06:48:40 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
|
2021-01-02 20:04:40 +01:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
2006-04-01 04:07:58 +02:00
|
|
|
|
2019-06-18 14:07:52 +02:00
|
|
|
$hookmanager = new HookManager($db);
|
|
|
|
|
|
|
|
|
|
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
|
|
|
|
|
$hookmanager->initHooks(array('membersindex'));
|
|
|
|
|
|
2018-09-07 10:40:36 +02:00
|
|
|
// Load translation files required by the page
|
2019-11-14 12:09:46 +01:00
|
|
|
$langs->loadLangs(array("companies", "members"));
|
2004-07-31 15:34:32 +02:00
|
|
|
|
2013-01-10 08:27:12 +01:00
|
|
|
// Security check
|
2019-11-14 12:09:46 +01:00
|
|
|
$result = restrictedArea($user, 'adherent');
|
2021-03-08 16:47:49 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
2021-01-02 20:04:40 +01:00
|
|
|
|
|
|
|
|
if (GETPOST('addbox')) {
|
|
|
|
|
// Add box (when submit is done from a form when ajax disabled)
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
|
2021-06-11 15:21:24 +02:00
|
|
|
$zone = GETPOST('areacode', 'int');
|
2021-01-02 20:04:40 +01:00
|
|
|
$userid = GETPOST('userid', 'int');
|
|
|
|
|
$boxorder = GETPOST('boxorder', 'aZ09');
|
|
|
|
|
$boxorder .= GETPOST('boxcombo', 'aZ09');
|
|
|
|
|
$result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
|
|
|
|
|
if ($result > 0) {
|
|
|
|
|
setEventMessages($langs->trans("BoxAdded"), null);
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-31 15:34:32 +02:00
|
|
|
|
2021-03-08 16:47:49 +01:00
|
|
|
|
2009-03-09 12:28:12 +01:00
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
2021-03-08 16:47:49 +01:00
|
|
|
$form = new Form($db);
|
|
|
|
|
|
|
|
|
|
// Load $resultboxes (selectboxlist + boxactivated + boxlista + boxlistb)
|
|
|
|
|
$resultboxes = FormOther::getBoxesArea($user, "2");
|
|
|
|
|
|
2019-01-27 11:55:16 +01:00
|
|
|
llxHeader('', $langs->trans("Members"), 'EN:Module_Foundations|FR:Module_Adhérents|ES:Módulo_Miembros');
|
2002-12-28 19:12:22 +01:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$staticmember = new Adherent($db);
|
|
|
|
|
$statictype = new AdherentType($db);
|
|
|
|
|
$subscriptionstatic = new Subscription($db);
|
2002-12-28 19:12:22 +01:00
|
|
|
|
2021-01-02 20:04:40 +01:00
|
|
|
print load_fiche_titre($langs->trans("MembersArea"), $resultboxes['selectboxlist'], 'members');
|
2005-08-11 20:24:58 +02:00
|
|
|
|
2021-03-14 15:51:00 +01:00
|
|
|
$MembersValidated = array();
|
|
|
|
|
$MembersToValidate = array();
|
|
|
|
|
$MembersUpToDate = array();
|
2021-03-14 13:59:50 +01:00
|
|
|
$MembersExcluded = array();
|
2021-03-14 15:51:00 +01:00
|
|
|
$MembersResiliated = array();
|
2009-02-21 16:14:45 +01:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$AdherentType = array();
|
2003-05-05 17:27:02 +02:00
|
|
|
|
2019-11-01 12:52:03 +01:00
|
|
|
// Type of membership
|
2017-09-16 10:54:20 +02:00
|
|
|
$sql = "SELECT t.rowid, t.libelle as label, t.subscription,";
|
2020-04-10 10:59:32 +02:00
|
|
|
$sql .= " d.statut, count(d.rowid) as somme";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
|
|
|
|
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d";
|
|
|
|
|
$sql .= " ON t.rowid = d.fk_adherent_type";
|
|
|
|
|
$sql .= " AND d.entity IN (".getEntity('adherent').")";
|
|
|
|
|
$sql .= " WHERE t.entity IN (".getEntity('member_type').")";
|
|
|
|
|
$sql .= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut";
|
2004-07-14 21:46:34 +02:00
|
|
|
|
2019-11-01 12:52:03 +01:00
|
|
|
dol_syslog("index.php::select nb of members per type", LOG_DEBUG);
|
2022-05-15 22:29:19 +02:00
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$num = $db->num_rows($resql);
|
2006-04-01 04:07:58 +02:00
|
|
|
$i = 0;
|
2020-05-21 09:12:18 +02:00
|
|
|
while ($i < $num) {
|
2022-05-15 22:29:19 +02:00
|
|
|
$objp = $db->fetch_object($resql);
|
2006-04-01 04:07:58 +02:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$adhtype = new AdherentType($db);
|
|
|
|
|
$adhtype->id = $objp->rowid;
|
|
|
|
|
$adhtype->subscription = $objp->subscription;
|
|
|
|
|
$adhtype->label = $objp->label;
|
|
|
|
|
$AdherentType[$objp->rowid] = $adhtype;
|
2006-04-01 04:07:58 +02:00
|
|
|
|
2021-01-02 20:04:40 +01:00
|
|
|
if ($objp->statut == -1) {
|
2021-03-14 15:51:00 +01:00
|
|
|
$MembersToValidate[$objp->rowid] = $objp->somme;
|
2021-01-02 20:04:40 +01:00
|
|
|
}
|
|
|
|
|
if ($objp->statut == 1) {
|
|
|
|
|
$MembersValidated[$objp->rowid] = $objp->somme;
|
|
|
|
|
}
|
2021-03-13 15:18:44 +01:00
|
|
|
if ($objp->statut == -2) {
|
2021-03-14 13:59:50 +01:00
|
|
|
$MembersExcluded[$objp->rowid] = $objp->somme;
|
2021-03-13 15:18:44 +01:00
|
|
|
}
|
2021-01-02 20:04:40 +01:00
|
|
|
if ($objp->statut == 0) {
|
|
|
|
|
$MembersResiliated[$objp->rowid] = $objp->somme;
|
|
|
|
|
}
|
2006-04-01 04:07:58 +02:00
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
2022-05-15 22:29:19 +02:00
|
|
|
$db->free($resql);
|
2003-05-05 17:27:02 +02:00
|
|
|
}
|
2002-12-30 16:25:16 +01:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$now = dol_now();
|
2009-02-02 03:04:26 +01:00
|
|
|
|
2018-11-07 14:01:49 +01:00
|
|
|
// Members up to date list
|
2009-02-21 16:14:45 +01:00
|
|
|
// current rule: uptodate = the end date is in future whatever is type
|
|
|
|
|
// old rule: uptodate = if type does not need payment, that end date is null, if type need payment that end date is in future)
|
2006-04-01 04:07:58 +02:00
|
|
|
$sql = "SELECT count(*) as somme , d.fk_adherent_type";
|
2020-04-10 10:59:32 +02:00
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
|
|
|
|
|
$sql .= " WHERE d.entity IN (".getEntity('adherent').")";
|
|
|
|
|
$sql .= " AND d.statut = 1 AND (d.datefin >= '".$db->idate($now)."' OR t.subscription = 0)";
|
|
|
|
|
$sql .= " AND t.rowid = d.fk_adherent_type";
|
|
|
|
|
$sql .= " GROUP BY d.fk_adherent_type";
|
2003-05-05 17:27:02 +02:00
|
|
|
|
2014-06-12 11:31:53 +02:00
|
|
|
dol_syslog("index.php::select nb of uptodate members by type", LOG_DEBUG);
|
2022-05-15 22:29:19 +02:00
|
|
|
$resql = $db->query($sql);
|
|
|
|
|
if ($resql) {
|
|
|
|
|
$num = $db->num_rows($resql);
|
2009-02-02 03:04:26 +01:00
|
|
|
$i = 0;
|
2020-05-21 09:12:18 +02:00
|
|
|
while ($i < $num) {
|
2022-05-15 22:29:19 +02:00
|
|
|
$objp = $db->fetch_object($resql);
|
2021-03-14 15:51:00 +01:00
|
|
|
$MembersUpToDate[$objp->fk_adherent_type] = $objp->somme;
|
2009-02-02 03:04:26 +01:00
|
|
|
$i++;
|
|
|
|
|
}
|
2022-05-15 22:29:19 +02:00
|
|
|
$db->free($resql);
|
2002-12-28 19:12:22 +01:00
|
|
|
}
|
2009-02-02 03:04:26 +01:00
|
|
|
|
2011-05-22 00:58:09 +02:00
|
|
|
/*
|
|
|
|
|
* Statistics
|
|
|
|
|
*/
|
2021-04-12 15:37:26 +02:00
|
|
|
|
2021-03-02 22:29:02 +01:00
|
|
|
$boxgraph = '';
|
2020-05-21 09:12:18 +02:00
|
|
|
if ($conf->use_javascript_ajax) {
|
2021-03-02 22:29:02 +01:00
|
|
|
$boxgraph .='<div class="div-table-responsive-no-min">';
|
|
|
|
|
$boxgraph .='<table class="noborder nohover centpercent">';
|
|
|
|
|
$boxgraph .='<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
|
|
|
|
$boxgraph .='<tr><td class="center" colspan="2">';
|
2020-10-31 14:32:18 +01:00
|
|
|
|
2021-03-18 23:11:19 +01:00
|
|
|
$SumToValidate = 0;
|
|
|
|
|
$SumValidated = 0;
|
|
|
|
|
$SumUpToDate = 0;
|
|
|
|
|
$SumResiliated = 0;
|
2021-03-20 15:34:30 +01:00
|
|
|
$SumExcluded = 0;
|
2021-03-10 17:02:39 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
$total = 0;
|
|
|
|
|
$dataval = array();
|
|
|
|
|
$i = 0;
|
|
|
|
|
foreach ($AdherentType as $key => $adhtype) {
|
2021-03-14 15:51:00 +01:00
|
|
|
$dataval['draft'][] = array($i, isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0);
|
|
|
|
|
$dataval['uptodate'][] = array($i, isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0);
|
2022-03-29 10:54:35 +02:00
|
|
|
$dataval['notuptodate'][] = array($i, isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0);
|
2021-03-13 15:18:44 +01:00
|
|
|
$dataval['excluded'][] = array($i, isset($MembersExcluded[$key]) ? $MembersExcluded[$key] : 0);
|
2020-10-31 14:32:18 +01:00
|
|
|
$dataval['resiliated'][] = array($i, isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0);
|
2021-03-20 15:34:30 +01:00
|
|
|
|
2021-03-18 23:11:19 +01:00
|
|
|
$SumToValidate += isset($MembersToValidate[$key]) ? $MembersToValidate[$key] : 0;
|
|
|
|
|
$SumValidated += isset($MembersValidated[$key]) ? $MembersValidated[$key] - (isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0) : 0;
|
|
|
|
|
$SumUpToDate += isset($MembersUpToDate[$key]) ? $MembersUpToDate[$key] : 0;
|
2021-03-20 15:34:30 +01:00
|
|
|
$SumExcluded += isset($MembersExcluded[$key]) ? $MembersExcluded [$key] : 0;
|
2021-03-18 23:11:19 +01:00
|
|
|
$SumResiliated += isset($MembersResiliated[$key]) ? $MembersResiliated[$key] : 0;
|
2020-10-31 14:32:18 +01:00
|
|
|
$i++;
|
|
|
|
|
}
|
2021-03-21 14:38:15 +01:00
|
|
|
$total = $SumToValidate + $SumValidated + $SumUpToDate + $SumExcluded + $SumResiliated;
|
2020-10-31 14:32:18 +01:00
|
|
|
$dataseries = array();
|
2022-03-29 10:54:35 +02:00
|
|
|
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusToValid"), round($SumToValidate)); // Draft, not yet validated
|
2021-03-18 23:11:19 +01:00
|
|
|
$dataseries[] = array($langs->transnoentitiesnoconv("UpToDate"), round($SumUpToDate));
|
2022-03-29 10:54:35 +02:00
|
|
|
$dataseries[] = array($langs->transnoentitiesnoconv("OutOfDate"), round($SumValidated));
|
2021-03-20 15:34:30 +01:00
|
|
|
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusExcluded"), round($SumExcluded));
|
2021-03-18 23:11:19 +01:00
|
|
|
$dataseries[] = array($langs->transnoentitiesnoconv("MembersStatusResiliated"), round($SumResiliated));
|
2020-10-31 14:32:18 +01:00
|
|
|
|
2021-03-11 09:43:56 +01:00
|
|
|
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
2020-10-31 14:32:18 +01:00
|
|
|
|
|
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
|
|
|
|
$dolgraph = new DolGraph();
|
|
|
|
|
$dolgraph->SetData($dataseries);
|
2022-03-29 10:56:15 +02:00
|
|
|
$dolgraph->SetDataColor(array('-'.$badgeStatus0, $badgeStatus4, '-'.$badgeStatus1, '-'.$badgeStatus8, $badgeStatus6));
|
2020-10-31 14:32:18 +01:00
|
|
|
$dolgraph->setShowLegend(2);
|
|
|
|
|
$dolgraph->setShowPercent(1);
|
|
|
|
|
$dolgraph->SetType(array('pie'));
|
|
|
|
|
$dolgraph->setHeight('200');
|
|
|
|
|
$dolgraph->draw('idgraphstatus');
|
2021-03-02 22:29:02 +01:00
|
|
|
$boxgraph .=$dolgraph->show($total ? 0 : 1);
|
|
|
|
|
|
|
|
|
|
$boxgraph .= '</td></tr>';
|
|
|
|
|
$boxgraph .= '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
|
2021-03-21 14:38:15 +01:00
|
|
|
$boxgraph .= $SumToValidate + $SumValidated + $SumUpToDate + $SumExcluded + $SumResiliated;
|
2021-03-02 22:29:02 +01:00
|
|
|
$boxgraph .= '</td></tr>';
|
|
|
|
|
$boxgraph .= '</table>';
|
|
|
|
|
$boxgraph .= '</div>';
|
|
|
|
|
$boxgraph .= '<br>';
|
2011-05-21 15:00:22 +02:00
|
|
|
}
|
|
|
|
|
|
2021-01-02 20:04:40 +01:00
|
|
|
// boxes
|
|
|
|
|
print '<div class="clearboth"></div>';
|
|
|
|
|
print '<div class="fichecenter fichecenterbis">';
|
|
|
|
|
|
2021-03-08 16:47:49 +01:00
|
|
|
print '<div class="twocolumns">';
|
|
|
|
|
|
|
|
|
|
print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
|
2021-04-12 15:37:26 +02:00
|
|
|
|
2021-03-08 16:47:49 +01:00
|
|
|
print $boxgraph;
|
|
|
|
|
|
|
|
|
|
print $resultboxes['boxlista'];
|
2021-03-10 16:41:48 +01:00
|
|
|
|
2021-03-08 16:47:49 +01:00
|
|
|
print '</div>'."\n";
|
|
|
|
|
|
|
|
|
|
print '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
|
|
|
|
|
|
|
|
|
|
print $resultboxes['boxlistb'];
|
|
|
|
|
|
|
|
|
|
print '</div>'."\n";
|
|
|
|
|
|
|
|
|
|
print '</div>';
|
2021-01-02 20:04:40 +01:00
|
|
|
print '</div>';
|
|
|
|
|
|
2019-06-18 14:07:52 +02:00
|
|
|
$parameters = array('user' => $user);
|
2019-06-18 15:13:08 +02:00
|
|
|
$reshook = $hookmanager->executeHooks('dashboardMembers', $parameters, $object); // Note that $action and $object may have been modified by hook
|
2019-06-18 14:07:52 +02:00
|
|
|
|
2018-07-28 14:29:28 +02:00
|
|
|
// End of page
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2012-04-15 11:28:21 +02:00
|
|
|
$db->close();
|