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>
|
2019-06-18 14:07:52 +02:00
|
|
|
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
|
|
|
|
|
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
|
|
|
|
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.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
|
2009-02-02 03:04:26 +01:00
|
|
|
* \brief Page accueil module adherents
|
|
|
|
|
*/
|
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';
|
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
|
|
|
|
|
$langs->loadLangs(array("companies","members"));
|
2004-07-31 15:34:32 +02:00
|
|
|
|
2013-01-10 08:27:12 +01:00
|
|
|
// Security check
|
2019-01-27 11:55:16 +01:00
|
|
|
$result=restrictedArea($user, 'adherent');
|
2013-01-02 18:43:59 +01:00
|
|
|
|
2004-07-31 15:34:32 +02:00
|
|
|
|
2009-03-09 12:28:12 +01:00
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
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
|
|
|
|
2006-04-01 04:07:58 +02:00
|
|
|
$staticmember=new Adherent($db);
|
2007-05-09 13:27:45 +02:00
|
|
|
$statictype=new AdherentType($db);
|
2016-09-24 06:48:40 +02:00
|
|
|
$subscriptionstatic=new Subscription($db);
|
2002-12-28 19:12:22 +01:00
|
|
|
|
2019-09-28 06:02:25 +02:00
|
|
|
print load_fiche_titre($langs->trans("MembersArea"), '', 'members');
|
2005-08-11 20:24:58 +02:00
|
|
|
|
2003-05-05 17:27:02 +02:00
|
|
|
$Adherents=array();
|
2004-07-14 21:46:34 +02:00
|
|
|
$AdherentsAValider=array();
|
2009-02-21 16:14:45 +01:00
|
|
|
$MemberUpToDate=array();
|
2004-07-14 21:46:34 +02:00
|
|
|
$AdherentsResilies=array();
|
2009-02-21 16:14:45 +01:00
|
|
|
|
2006-04-29 13:53:08 +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,";
|
2007-02-27 22:40:09 +01:00
|
|
|
$sql.= " d.statut, count(d.rowid) as somme";
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
|
2012-04-15 11:28:21 +02:00
|
|
|
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."adherent as d";
|
|
|
|
|
$sql.= " ON t.rowid = d.fk_adherent_type";
|
2017-06-10 20:04:24 +02:00
|
|
|
$sql.= " AND d.entity IN (".getEntity('adherent').")";
|
2018-02-24 11:13:14 +01:00
|
|
|
$sql.= " WHERE t.entity IN (".getEntity('member_type').")";
|
2016-09-24 06:48:40 +02:00
|
|
|
$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);
|
2002-12-28 19:12:22 +01:00
|
|
|
$result = $db->query($sql);
|
2006-04-01 04:07:58 +02:00
|
|
|
if ($result)
|
2002-12-28 19:12:22 +01:00
|
|
|
{
|
2006-04-01 04:07:58 +02:00
|
|
|
$num = $db->num_rows($result);
|
|
|
|
|
$i = 0;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$objp = $db->fetch_object($result);
|
|
|
|
|
|
|
|
|
|
$adhtype=new AdherentType($db);
|
|
|
|
|
$adhtype->id=$objp->rowid;
|
2016-09-24 06:48:40 +02:00
|
|
|
$adhtype->subscription=$objp->subscription;
|
2017-09-16 10:54:20 +02:00
|
|
|
$adhtype->label=$objp->label;
|
2006-04-01 04:07:58 +02:00
|
|
|
$AdherentType[$objp->rowid]=$adhtype;
|
|
|
|
|
|
2009-02-21 16:14:45 +01:00
|
|
|
if ($objp->statut == -1) { $MemberToValidate[$objp->rowid]=$objp->somme; }
|
|
|
|
|
if ($objp->statut == 1) { $MembersValidated[$objp->rowid]=$objp->somme; }
|
|
|
|
|
if ($objp->statut == 0) { $MembersResiliated[$objp->rowid]=$objp->somme; }
|
2006-04-01 04:07:58 +02:00
|
|
|
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
$db->free($result);
|
2003-05-05 17:27:02 +02:00
|
|
|
}
|
2002-12-30 16:25:16 +01:00
|
|
|
|
2012-03-23 18:19:50 +01: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";
|
2009-02-21 16:14:45 +01:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."adherent_type as t";
|
2017-06-10 20:04:24 +02:00
|
|
|
$sql.= " WHERE d.entity IN (".getEntity('adherent').")";
|
2019-10-03 00:29:41 +02:00
|
|
|
$sql.= " AND d.statut = 1 AND (d.datefin >= '".$db->idate($now)."' OR t.subscription = 0)";
|
2009-02-21 16:14:45 +01:00
|
|
|
$sql.= " AND t.rowid = d.fk_adherent_type";
|
2006-04-01 04:07:58 +02:00
|
|
|
$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);
|
2003-05-05 17:27:02 +02:00
|
|
|
$result = $db->query($sql);
|
2009-01-21 16:06:34 +01:00
|
|
|
if ($result)
|
2003-05-05 17:27:02 +02:00
|
|
|
{
|
2009-02-02 03:04:26 +01:00
|
|
|
$num = $db->num_rows($result);
|
|
|
|
|
$i = 0;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$objp = $db->fetch_object($result);
|
2009-02-21 16:14:45 +01:00
|
|
|
$MemberUpToDate[$objp->fk_adherent_type]=$objp->somme;
|
2009-02-02 03:04:26 +01:00
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
$db->free();
|
2002-12-28 19:12:22 +01:00
|
|
|
}
|
2009-02-02 03:04:26 +01:00
|
|
|
|
|
|
|
|
|
2013-03-16 14:53:15 +01:00
|
|
|
//print '<tr><td width="30%" class="notopnoleft" valign="top">';
|
|
|
|
|
print '<div class="fichecenter"><div class="fichethirdleft">';
|
2009-02-02 03:04:26 +01:00
|
|
|
|
2015-10-17 02:41:09 +02:00
|
|
|
|
2017-02-21 14:17:44 +01:00
|
|
|
if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
|
2015-10-17 02:41:09 +02:00
|
|
|
{
|
2017-02-21 14:17:44 +01:00
|
|
|
// Search contact/address
|
|
|
|
|
if (! empty($conf->adherent->enabled) && $user->rights->adherent->lire)
|
|
|
|
|
{
|
|
|
|
|
$listofsearchfields['search_member']=array('text'=>'Member');
|
|
|
|
|
}
|
2017-06-10 20:04:24 +02:00
|
|
|
|
2017-02-21 14:17:44 +01:00
|
|
|
if (count($listofsearchfields))
|
|
|
|
|
{
|
|
|
|
|
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
|
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
2019-10-25 18:20:48 +02:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2017-02-21 14:17:44 +01:00
|
|
|
print '<table class="noborder nohover centpercent">';
|
|
|
|
|
$i=0;
|
|
|
|
|
foreach($listofsearchfields as $key => $value)
|
|
|
|
|
{
|
|
|
|
|
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
2018-11-07 14:01:49 +01:00
|
|
|
print '<tr class="oddeven">';
|
2017-02-21 14:17:44 +01:00
|
|
|
print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label>:</td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'" size="18"></td>';
|
|
|
|
|
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
|
|
|
|
print '</tr>';
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
2017-06-10 20:04:24 +02:00
|
|
|
print '</table>';
|
2019-10-25 18:20:48 +02:00
|
|
|
print '</div>';
|
2017-02-21 14:17:44 +01:00
|
|
|
print '</form>';
|
|
|
|
|
print '<br>';
|
|
|
|
|
}
|
2015-10-17 02:41:09 +02:00
|
|
|
}
|
2009-02-02 03:04:26 +01:00
|
|
|
|
|
|
|
|
|
2011-05-22 00:58:09 +02:00
|
|
|
/*
|
|
|
|
|
* Statistics
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if ($conf->use_javascript_ajax)
|
2011-05-21 15:00:22 +02:00
|
|
|
{
|
2017-10-19 19:53:29 +02:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="noborder nohover centpercent">';
|
2017-03-07 22:45:22 +01:00
|
|
|
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
|
2019-03-19 14:12:12 +01:00
|
|
|
print '<tr><td class="center" colspan="2">';
|
2011-05-22 00:58:09 +02:00
|
|
|
|
|
|
|
|
$SommeA=0;
|
|
|
|
|
$SommeB=0;
|
|
|
|
|
$SommeC=0;
|
|
|
|
|
$SommeD=0;
|
2017-11-23 20:00:54 +01:00
|
|
|
$total=0;
|
2011-05-22 00:58:09 +02:00
|
|
|
$dataval=array();
|
|
|
|
|
$datalabels=array();
|
2011-11-20 16:54:41 +01:00
|
|
|
$i=0;
|
2011-05-22 00:58:09 +02:00
|
|
|
foreach ($AdherentType as $key => $adhtype)
|
|
|
|
|
{
|
2019-01-27 11:55:16 +01:00
|
|
|
$datalabels[]=array($i,$adhtype->getNomUrl(0, dol_size(16)));
|
2011-11-20 16:34:30 +01:00
|
|
|
$dataval['draft'][]=array($i,isset($MemberToValidate[$key])?$MemberToValidate[$key]:0);
|
2012-11-13 12:32:05 +01:00
|
|
|
$dataval['notuptodate'][]=array($i,isset($MembersValidated[$key])?$MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0):0);
|
2011-11-20 16:34:30 +01:00
|
|
|
$dataval['uptodate'][]=array($i,isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0);
|
|
|
|
|
$dataval['resiliated'][]=array($i,isset($MembersResiliated[$key])?$MembersResiliated[$key]:0);
|
2011-05-22 00:58:09 +02:00
|
|
|
$SommeA+=isset($MemberToValidate[$key])?$MemberToValidate[$key]:0;
|
2012-11-13 12:32:05 +01:00
|
|
|
$SommeB+=isset($MembersValidated[$key])?$MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0):0;
|
2011-05-22 00:58:09 +02:00
|
|
|
$SommeC+=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
|
|
|
|
|
$SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
|
2011-11-20 16:54:41 +01:00
|
|
|
$i++;
|
2011-05-22 00:58:09 +02:00
|
|
|
}
|
2017-11-23 20:00:54 +01:00
|
|
|
$total = $SommeA + $SommeB + $SommeC + $SommeD;
|
2011-06-07 00:13:43 +02:00
|
|
|
$dataseries=array();
|
2017-11-23 20:00:54 +01:00
|
|
|
$dataseries[]=array($langs->trans("MenuMembersNotUpToDate"), round($SommeB));
|
|
|
|
|
$dataseries[]=array($langs->trans("MenuMembersUpToDate"), round($SommeC));
|
|
|
|
|
$dataseries[]=array($langs->trans("MembersStatusResiliated"), round($SommeD));
|
|
|
|
|
$dataseries[]=array($langs->trans("MembersStatusToValid"), round($SommeA));
|
|
|
|
|
|
|
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
|
|
|
|
$dolgraph = new DolGraph();
|
|
|
|
|
$dolgraph->SetData($dataseries);
|
|
|
|
|
$dolgraph->setShowLegend(1);
|
|
|
|
|
$dolgraph->setShowPercent(1);
|
|
|
|
|
$dolgraph->SetType(array('pie'));
|
|
|
|
|
$dolgraph->setWidth('100%');
|
|
|
|
|
$dolgraph->draw('idgraphstatus');
|
|
|
|
|
print $dolgraph->show($total?0:1);
|
|
|
|
|
|
2011-05-22 00:58:09 +02:00
|
|
|
print '</td></tr>';
|
2019-01-21 22:04:42 +01:00
|
|
|
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
|
2011-05-22 00:58:09 +02:00
|
|
|
print $SommeA+$SommeB+$SommeC+$SommeD;
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
print '</table>';
|
2017-10-19 19:53:29 +02:00
|
|
|
print '</div>';
|
2011-05-21 15:00:22 +02:00
|
|
|
}
|
|
|
|
|
|
2017-03-07 22:45:22 +01:00
|
|
|
print '<br>';
|
|
|
|
|
|
|
|
|
|
// List of subscription by year
|
|
|
|
|
$Total=array();
|
|
|
|
|
$Number=array();
|
|
|
|
|
$tot=0;
|
|
|
|
|
$numb=0;
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT c.subscription, c.dateadh as dateh";
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
|
2017-06-10 20:04:24 +02:00
|
|
|
$sql.= " WHERE d.entity IN (".getEntity('adherent').")";
|
2017-03-07 22:45:22 +01:00
|
|
|
$sql.= " AND d.rowid = c.fk_adherent";
|
2019-10-24 15:16:26 +02:00
|
|
|
|
|
|
|
|
|
2017-03-07 22:45:22 +01:00
|
|
|
$result = $db->query($sql);
|
|
|
|
|
if ($result)
|
|
|
|
|
{
|
|
|
|
|
$num = $db->num_rows($result);
|
|
|
|
|
$i = 0;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$objp = $db->fetch_object($result);
|
2019-01-27 11:55:16 +01:00
|
|
|
$year=dol_print_date($db->jdate($objp->dateh), "%Y");
|
2017-03-07 22:45:22 +01:00
|
|
|
$Total[$year]=(isset($Total[$year])?$Total[$year]:0)+$objp->subscription;
|
|
|
|
|
$Number[$year]=(isset($Number[$year])?$Number[$year]:0)+1;
|
|
|
|
|
$tot+=$objp->subscription;
|
|
|
|
|
$numb+=1;
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-19 19:53:29 +02:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="noborder centpercent">';
|
2017-03-07 22:45:22 +01:00
|
|
|
print '<tr class="liste_titre">';
|
2019-10-24 15:16:26 +02:00
|
|
|
print '<th>'.$langs->trans("Year").'</th>';
|
|
|
|
|
print '<th class="right">'.$langs->trans("Subscriptions").'</th>';
|
2019-01-21 22:04:42 +01:00
|
|
|
print '<th class="right">'.$langs->trans("AmountTotal").'</th>';
|
|
|
|
|
print '<th class="right">'.$langs->trans("AmountAverage").'</th>';
|
2017-03-07 22:45:22 +01:00
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
|
|
krsort($Total);
|
2019-10-24 15:16:26 +02:00
|
|
|
$i = 0;
|
2017-03-07 22:45:22 +01:00
|
|
|
foreach ($Total as $key=>$value)
|
|
|
|
|
{
|
2019-10-24 15:16:26 +02:00
|
|
|
if ($i >= 8)
|
|
|
|
|
{
|
|
|
|
|
print '<tr class="oddeven">';
|
|
|
|
|
print "<td>...</td>";
|
|
|
|
|
print "<td class=\"right\"></td>";
|
|
|
|
|
print "<td class=\"right\"></td>";
|
|
|
|
|
print "<td class=\"right\"></td>";
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
print '<tr class="oddeven">';
|
2017-03-07 22:45:22 +01:00
|
|
|
print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>";
|
2019-01-21 22:04:42 +01:00
|
|
|
print "<td class=\"right\">".$Number[$key]."</td>";
|
|
|
|
|
print "<td class=\"right\">".price($value)."</td>";
|
2019-01-27 11:55:16 +01:00
|
|
|
print "<td class=\"right\">".price(price2num($value/$Number[$key], 'MT'))."</td>";
|
2017-03-07 22:45:22 +01:00
|
|
|
print "</tr>\n";
|
2019-10-24 15:16:26 +02:00
|
|
|
$i++;
|
2017-03-07 22:45:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Total
|
|
|
|
|
print '<tr class="liste_total">';
|
|
|
|
|
print '<td>'.$langs->trans("Total").'</td>';
|
2019-01-21 22:04:42 +01:00
|
|
|
print "<td class=\"right\">".$numb."</td>";
|
|
|
|
|
print '<td class="right">'.price($tot)."</td>";
|
2019-01-27 11:55:16 +01:00
|
|
|
print "<td class=\"right\">".price(price2num($numb>0?($tot/$numb):0, 'MT'))."</td>";
|
2017-03-07 22:45:22 +01:00
|
|
|
print "</tr>\n";
|
2017-10-19 19:53:29 +02:00
|
|
|
print "</table></div>";
|
|
|
|
|
print "<br>\n";
|
2017-03-07 22:45:22 +01:00
|
|
|
|
2013-03-16 14:53:15 +01:00
|
|
|
|
2013-03-30 14:27:13 +01:00
|
|
|
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
2011-05-21 15:00:22 +02:00
|
|
|
|
2006-11-19 18:52:51 +01:00
|
|
|
/*
|
2019-11-01 12:52:03 +01:00
|
|
|
* Latest modified members
|
2006-11-19 18:52:51 +01:00
|
|
|
*/
|
|
|
|
|
$max=5;
|
|
|
|
|
|
2013-02-23 15:26:39 +01:00
|
|
|
$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
|
2010-04-20 21:00:17 +02:00
|
|
|
$sql.= " a.tms as datem, datefin as date_end_subscription,";
|
2017-09-16 10:54:20 +02:00
|
|
|
$sql.= " ta.rowid as typeid, ta.libelle as label, ta.subscription";
|
2006-11-19 18:52:51 +01:00
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."adherent_type as ta";
|
2017-06-10 20:04:24 +02:00
|
|
|
$sql.= " WHERE a.entity IN (".getEntity('adherent').")";
|
2012-04-15 11:28:21 +02:00
|
|
|
$sql.= " AND a.fk_adherent_type = ta.rowid";
|
2019-01-27 11:55:16 +01:00
|
|
|
$sql.= $db->order("a.tms", "DESC");
|
2006-11-19 18:52:51 +01:00
|
|
|
$sql.= $db->plimit($max, 0);
|
|
|
|
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
|
|
|
|
{
|
2017-10-19 19:53:29 +02:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="noborder centpercent">';
|
2009-02-02 03:04:26 +01:00
|
|
|
print '<tr class="liste_titre">';
|
2019-01-27 11:55:16 +01:00
|
|
|
print '<th colspan="4">'.$langs->trans("LastMembersModified", $max).'</th></tr>';
|
2009-02-02 03:04:26 +01:00
|
|
|
|
|
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
if ($num)
|
|
|
|
|
{
|
|
|
|
|
$i = 0;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
2017-04-12 10:28:05 +02:00
|
|
|
print '<tr class="oddeven">';
|
2009-02-02 03:04:26 +01:00
|
|
|
$staticmember->id=$obj->rowid;
|
2012-01-30 10:22:50 +01:00
|
|
|
$staticmember->lastname=$obj->lastname;
|
|
|
|
|
$staticmember->firstname=$obj->firstname;
|
2014-05-03 03:10:58 +02:00
|
|
|
if (! empty($obj->fk_soc))
|
|
|
|
|
{
|
|
|
|
|
$staticmember->fk_soc = $obj->fk_soc;
|
2012-09-24 11:01:27 +02:00
|
|
|
$staticmember->fetch_thirdparty();
|
2012-09-24 12:12:37 +02:00
|
|
|
$staticmember->name=$staticmember->thirdparty->name;
|
2014-05-03 03:10:58 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-09-24 11:01:27 +02:00
|
|
|
$staticmember->name=$obj->company;
|
|
|
|
|
}
|
2011-10-25 23:48:40 +02:00
|
|
|
$staticmember->ref=$staticmember->getFullName($langs);
|
2009-02-02 03:04:26 +01:00
|
|
|
$statictype->id=$obj->typeid;
|
2017-09-16 10:54:20 +02:00
|
|
|
$statictype->label=$obj->label;
|
2019-01-27 11:55:16 +01:00
|
|
|
print '<td>'.$staticmember->getNomUrl(1, 32).'</td>';
|
|
|
|
|
print '<td>'.$statictype->getNomUrl(1, 32).'</td>';
|
|
|
|
|
print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
|
2019-11-01 12:52:03 +01:00
|
|
|
print '<td class="right">'.$staticmember->LibStatut($obj->statut, ($obj->subscription=='yes'?1:0), $db->jdate($obj->date_end_subscription), 3).'</td>';
|
2009-02-02 03:04:26 +01:00
|
|
|
print '</tr>';
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-19 19:53:29 +02:00
|
|
|
print "</table></div>";
|
|
|
|
|
print "<br>";
|
2006-11-19 18:52:51 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-02-20 23:53:15 +01:00
|
|
|
dol_print_error($db);
|
2006-11-19 18:52:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-10-25 23:48:40 +02:00
|
|
|
/*
|
|
|
|
|
* Last modified subscriptions
|
|
|
|
|
*/
|
|
|
|
|
$max=5;
|
|
|
|
|
|
2013-02-23 15:26:39 +01:00
|
|
|
$sql = "SELECT a.rowid, a.statut, a.lastname, a.firstname, a.societe as company, a.fk_soc,";
|
2011-10-25 23:48:40 +02:00
|
|
|
$sql.= " datefin as date_end_subscription,";
|
2016-09-24 06:48:40 +02:00
|
|
|
$sql.= " c.rowid as cid, c.tms as datem, c.datec as datec, c.dateadh as date_start, c.datef as date_end, c.subscription";
|
|
|
|
|
$sql.= " FROM ".MAIN_DB_PREFIX."adherent as a, ".MAIN_DB_PREFIX."subscription as c";
|
2017-06-10 20:04:24 +02:00
|
|
|
$sql.= " WHERE a.entity IN (".getEntity('adherent').")";
|
2012-04-15 11:28:21 +02:00
|
|
|
$sql.= " AND c.fk_adherent = a.rowid";
|
2019-01-27 11:55:16 +01:00
|
|
|
$sql.= $db->order("c.tms", "DESC");
|
2011-10-25 23:48:40 +02:00
|
|
|
$sql.= $db->plimit($max, 0);
|
|
|
|
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
|
|
|
|
{
|
2017-10-19 19:53:29 +02:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="noborder centpercent">';
|
2011-10-25 23:48:40 +02:00
|
|
|
print '<tr class="liste_titre">';
|
2019-01-27 11:55:16 +01:00
|
|
|
print '<th colspan="5">'.$langs->trans("LastSubscriptionsModified", $max).'</th></tr>';
|
2011-10-25 23:48:40 +02:00
|
|
|
|
|
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
if ($num)
|
|
|
|
|
{
|
|
|
|
|
$i = 0;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
2017-04-12 10:28:05 +02:00
|
|
|
print '<tr class="oddeven">';
|
2011-10-25 23:48:40 +02:00
|
|
|
$subscriptionstatic->id=$obj->cid;
|
|
|
|
|
$subscriptionstatic->ref=$obj->cid;
|
|
|
|
|
$staticmember->id=$obj->rowid;
|
2012-01-30 10:22:50 +01:00
|
|
|
$staticmember->lastname=$obj->lastname;
|
|
|
|
|
$staticmember->firstname=$obj->firstname;
|
2012-09-30 21:26:58 +02:00
|
|
|
if (! empty($obj->fk_soc)) {
|
2018-12-03 11:21:49 +01:00
|
|
|
$staticmember->fk_soc = $obj->fk_soc;
|
2012-09-24 12:12:37 +02:00
|
|
|
$staticmember->fetch_thirdparty();
|
2012-09-30 21:26:58 +02:00
|
|
|
$staticmember->name=$staticmember->thirdparty->name;
|
|
|
|
|
} else {
|
|
|
|
|
$staticmember->name=$obj->company;
|
2012-09-24 12:12:37 +02:00
|
|
|
}
|
2011-10-25 23:48:40 +02:00
|
|
|
$staticmember->ref=$staticmember->getFullName($langs);
|
|
|
|
|
print '<td>'.$subscriptionstatic->getNomUrl(1).'</td>';
|
2019-01-27 11:55:16 +01:00
|
|
|
print '<td>'.$staticmember->getNomUrl(1, 32, 'subscription').'</td>';
|
|
|
|
|
print '<td>'.get_date_range($db->jdate($obj->date_start), $db->jdate($obj->date_end)).'</td>';
|
2019-01-21 22:04:42 +01:00
|
|
|
print '<td class="right">'.price($obj->subscription).'</td>';
|
|
|
|
|
//print '<td class="right">'.$staticmember->LibStatut($obj->statut,($obj->subscription=='yes'?1:0),$db->jdate($obj->date_end_subscription),5).'</td>';
|
2019-01-27 11:55:16 +01:00
|
|
|
print '<td class="right">'.dol_print_date($db->jdate($obj->datem?$obj->datem:$obj->datec), 'dayhour').'</td>';
|
2011-10-25 23:48:40 +02:00
|
|
|
print '</tr>';
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-10-19 19:53:29 +02:00
|
|
|
print "</table></div>";
|
|
|
|
|
print "<br>";
|
2011-10-25 23:48:40 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Summary of members by type
|
2017-10-19 19:53:29 +02:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="noborder centpercent">';
|
2011-10-25 23:48:40 +02:00
|
|
|
print '<tr class="liste_titre">';
|
2017-03-07 22:45:22 +01:00
|
|
|
print '<th>'.$langs->trans("MembersTypes").'</th>';
|
2019-01-21 22:04:42 +01:00
|
|
|
print '<th class=right>'.$langs->trans("MembersStatusToValid").'</th>';
|
|
|
|
|
print '<th class=right>'.$langs->trans("MenuMembersNotUpToDate").'</th>';
|
|
|
|
|
print '<th class=right>'.$langs->trans("MenuMembersUpToDate").'</th>';
|
|
|
|
|
print '<th class=right>'.$langs->trans("MembersStatusResiliated").'</th>';
|
2011-10-25 23:48:40 +02:00
|
|
|
print "</tr>\n";
|
|
|
|
|
|
|
|
|
|
foreach ($AdherentType as $key => $adhtype)
|
|
|
|
|
{
|
2017-04-12 10:28:05 +02:00
|
|
|
print '<tr class="oddeven">';
|
2012-09-24 12:12:37 +02:00
|
|
|
print '<td>'.$adhtype->getNomUrl(1, dol_size(32)).'</td>';
|
2019-01-27 11:55:16 +01:00
|
|
|
print '<td class="right">'.(isset($MemberToValidate[$key]) && $MemberToValidate[$key] > 0?$MemberToValidate[$key]:'').' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).'</td>';
|
|
|
|
|
print '<td class="right">'.(isset($MembersValidated[$key]) && ($MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0) > 0) ? $MembersValidated[$key]-(isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0):'').' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3).'</td>';
|
|
|
|
|
print '<td class="right">'.(isset($MemberUpToDate[$key]) && $MemberUpToDate[$key] > 0 ? $MemberUpToDate[$key]:'').' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3).'</td>';
|
|
|
|
|
print '<td class="right">'.(isset($MembersResiliated[$key]) && $MembersResiliated[$key]> 0 ?$MembersResiliated[$key]:'').' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3).'</td>';
|
2011-10-25 23:48:40 +02:00
|
|
|
print "</tr>\n";
|
|
|
|
|
}
|
|
|
|
|
print '<tr class="liste_total">';
|
|
|
|
|
print '<td class="liste_total">'.$langs->trans("Total").'</td>';
|
2019-02-15 02:01:17 +01:00
|
|
|
print '<td class="liste_total right">'.$SommeA.' '.$staticmember->LibStatut(-1, $adhtype->subscription, 0, 3).'</td>';
|
|
|
|
|
print '<td class="liste_total right">'.$SommeB.' '.$staticmember->LibStatut(1, $adhtype->subscription, 0, 3).'</td>';
|
|
|
|
|
print '<td class="liste_total right">'.$SommeC.' '.$staticmember->LibStatut(1, $adhtype->subscription, $now, 3).'</td>';
|
|
|
|
|
print '<td class="liste_total right">'.$SommeD.' '.$staticmember->LibStatut(0, $adhtype->subscription, 0, 3).'</td>';
|
2011-10-25 23:48:40 +02:00
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
print "</table>\n";
|
2017-10-19 19:53:29 +02:00
|
|
|
print "</div>";
|
2005-08-11 20:24:58 +02:00
|
|
|
|
2013-03-30 19:40:52 +01:00
|
|
|
print '</div></div></div>';
|
2005-08-11 20:24:58 +02:00
|
|
|
|
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();
|