26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherentstats.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/member.lib.php';
35 $userid =
GETPOST(
'userid',
'int');
if ($userid < 0) {
38 $socid =
GETPOST(
'socid',
'int');
if ($socid < 0) {
43 if ($user->socid > 0) {
45 $socid = $user->socid;
49 $year = strftime(
"%Y", time());
50 $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
54 $langs->loadLangs(array(
"companies",
"members"));
64 $title = $langs->trans(
"SubscriptionsStatistics");
69 $dir = $conf->adherent->dir_temp;
76 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
81 $filenamenb = $dir.
'/subscriptionsnbinyear-'.$year.
'.png';
82 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=memberstats&file=subscriptionsnbinyear-'.$year.
'.png';
86 $mesg = $px1->isGraphKo();
90 while ($i <= $endyear) {
94 $px1->SetLegend($legend);
95 $px1->SetMaxValue($px1->GetCeilMaxValue());
96 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
97 $px1->SetWidth($WIDTH);
98 $px1->SetHeight($HEIGHT);
99 $px1->SetYLabel($langs->trans(
"NbOfSubscriptions"));
101 $px1->SetHorizTickIncrement(1);
102 $px1->mode =
'depth';
103 $px1->SetTitle($langs->trans(
"NbOfSubscriptions"));
105 $px1->draw($filenamenb, $fileurlnb);
109 $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
113 $filenameamount = $dir.
'/subscriptionsamountinyear-'.$year.
'.png';
114 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=memberstats&file=subscriptionsamountinyear-'.$year.
'.png';
117 $mesg = $px2->isGraphKo();
119 $px2->SetData($data);
121 while ($i <= $endyear) {
125 $px2->SetLegend($legend);
126 $px2->SetMaxValue($px2->GetCeilMaxValue());
127 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
128 $px2->SetWidth($WIDTH);
129 $px2->SetHeight($HEIGHT);
130 $px2->SetYLabel($langs->trans(
"AmountOfSubscriptions"));
132 $px2->SetHorizTickIncrement(1);
133 $px2->mode =
'depth';
134 $px2->SetTitle($langs->trans(
"AmountOfSubscriptions"));
136 $px2->draw($filenameamount, $fileurlamount);
145 print
'<div class="fichecenter"><div class="fichethirdleft">';
168 $data = $stats->getAllByYear();
171 print
'<div class="div-table-responsive-no-min">';
172 print
'<table class="noborder">';
173 print
'<tr class="liste_titre" height="24">';
174 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
175 print
'<td class="right">'.$langs->trans(
"NbOfSubscriptions").
'</td>';
176 print
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
177 print
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
181 foreach ($data as $val) {
182 $year = $val[
'year'];
183 while ($oldyear > $year + 1) {
185 print
'<tr class="oddeven" height="24">';
186 print
'<td class="center">';
191 print
'<td class="right">0</td>';
192 print
'<td class="right amount nowraponall">0</td>';
193 print
'<td class="right amount nowraponall">0</td>';
196 print
'<tr class="oddeven" height="24">';
197 print
'<td class="center">';
198 print
'<a href="'.DOL_URL_ROOT.
'/adherents/subscription/list.php?date_select='.((int) $year).
'">'.$year.
'</a>';
200 print
'<td class="right">'.$val[
'nb'].
'</td>';
201 print
'<td class="right amount nowraponall"><span class="amount">'.price(
price2num($val[
'total'],
'MT'), 1).
'</span></td>';
202 print
'<td class="right amount nowraponall"><span class="amount">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</span></td>';
211 print
'</div><div class="fichetwothirdright">';
215 print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
223 print
'</td></tr></table>';
226 print
'</div></div>';
227 print
'<div style="clear:both"></div>';