-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
byproperties.php
148 lines (114 loc) · 3.58 KB
/
byproperties.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/* Copyright (c) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/adherents/stats/byproperties.php
* \ingroup member
* \brief Page with statistics on members
*/
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
$graphwidth = 700;
$mapratio = 0.5;
$graphheight = round($graphwidth * $mapratio);
$mode=GETPOST('mode')?GETPOST('mode'):'';
// Security check
if ($user->societe_id > 0)
{
$action = '';
$socid = $user->societe_id;
}
$result=restrictedArea($user,'adherent','','','cotisation');
$year = strftime("%Y", time());
$startyear=$year-2;
$endyear=$year;
// Load translation files required by the page
$langs->loadLangs(array("companies","members"));
/*
* View
*/
$memberstatic=new Adherent($db);
llxHeader('',$langs->trans("MembersStatisticsByProperties"),'','',0,0,array('https://www.google.com/jsapi'));
$title=$langs->trans("MembersStatisticsByProperties");
print load_fiche_titre($title, $mesg);
dol_mkdir($dir);
$tab='byproperties';
$data = array();
$sql.="SELECT COUNT(d.rowid) as nb, MAX(d.datevalid) as lastdate, d.morphy as code";
$sql.=" FROM ".MAIN_DB_PREFIX."adherent as d";
$sql.=" WHERE d.entity IN (".getEntity('adherent').")";
$sql.=" AND d.statut = 1";
$sql.=" GROUP BY d.morphy";
$foundphy=$foundmor=0;
// Define $data array
dol_syslog("Count member", LOG_DEBUG);
$resql=$db->query($sql);
if ($resql)
{
$num=$db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj=$db->fetch_object($resql);
if ($obj->code == 'phy') $foundphy++;
if ($obj->code == 'mor') $foundmor++;
$data[]=array('label'=>$obj->code, 'nb'=>$obj->nb, 'lastdate'=>$db->jdate($obj->lastdate));
$i++;
}
$db->free($resql);
}
else
{
dol_print_error($db);
}
$head = member_stats_prepare_head($adh);
dol_fiche_head($head, 'statsbyproperties', $langs->trans("Statistics"), -1, 'user');
// Print title
if (! count($data))
{
print $langs->trans("NoValidatedMemberYet").'<br>';
print '<br>';
}
else
{
print load_fiche_titre($langs->trans("MembersByNature"),'','');
}
// Print array
print '<table class="liste" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Nature").'</td>';
print '<td align="right">'.$langs->trans("NbOfMembers").'</td>';
print '<td align="center">'.$langs->trans("LatestSubscriptionDate").'</td>';
print '</tr>';
if (! $foundphy) $data[]=array('label'=>'phy','nb'=>'0','lastdate'=>'');
if (! $foundmor) $data[]=array('label'=>'mor','nb'=>'0','lastdate'=>'');
$oldyear=0;
foreach ($data as $val)
{
$year = $val['year'];
print '<tr class="oddeven">';
print '<td>'.$memberstatic->getmorphylib($val['label']).'</td>';
print '<td align="right">'.$val['nb'].'</td>';
print '<td align="center">'.dol_print_date($val['lastdate'],'dayhour').'</td>';
print '</tr>';
$oldyear=$year;
}
print '</table>';
dol_fiche_end();
// End of page
llxFooter();
$db->close();