26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherentstats.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/member.lib.php';
34 $userid =
GETPOST(
'userid',
'int');
if ($userid < 0) $userid = 0;
35 $socid =
GETPOST(
'socid',
'int');
if ($socid < 0) $socid = 0;
38 if ($user->socid > 0) {
40 $socid = $user->socid;
44 $year = strftime(
"%Y", time());
45 $startyear = $year - 2;
49 $langs->loadLangs(array(
"companies",
"members"));
56 $form =
new Form($db);
58 $title = $langs->trans(
"SubscriptionsStatistics");
63 $dir = $conf->adherent->dir_temp;
70 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
75 $filenamenb = $dir.
'/subscriptionsnbinyear-'.$year.
'.png';
76 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=memberstats&file=subscriptionsnbinyear-'.$year.
'.png';
80 $mesg = $px1->isGraphKo();
84 while ($i <= $endyear) {
88 $px1->SetLegend($legend);
89 $px1->SetMaxValue($px1->GetCeilMaxValue());
90 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
91 $px1->SetWidth($WIDTH);
92 $px1->SetHeight($HEIGHT);
93 $px1->SetYLabel($langs->trans(
"NbOfSubscriptions"));
95 $px1->SetHorizTickIncrement(1);
97 $px1->SetTitle($langs->trans(
"NbOfSubscriptions"));
99 $px1->draw($filenamenb, $fileurlnb);
103 $data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
107 $filenameamount = $dir.
'/subscriptionsamountinyear-'.$year.
'.png';
108 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=memberstats&file=subscriptionsamountinyear-'.$year.
'.png';
111 $mesg = $px2->isGraphKo();
113 $px2->SetData($data);
115 while ($i <= $endyear) {
119 $px2->SetLegend($legend);
120 $px2->SetMaxValue($px2->GetCeilMaxValue());
121 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
122 $px2->SetWidth($WIDTH);
123 $px2->SetHeight($HEIGHT);
124 $px2->SetYLabel($langs->trans(
"AmountOfSubscriptions"));
126 $px2->SetHorizTickIncrement(1);
127 $px2->mode =
'depth';
128 $px2->SetTitle($langs->trans(
"AmountOfSubscriptions"));
130 $px2->draw($filenameamount, $fileurlamount);
139 print '<div class="fichecenter"><div class="fichethirdleft">';
160 $data = $stats->getAllByYear();
163 print
'<div class="div-table-responsive-no-min">';
164 print
'<table class="noborder">';
165 print
'<tr class="liste_titre" height="24">';
166 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
167 print
'<td class="right">'.$langs->trans(
"NbOfSubscriptions").
'</td>';
168 print
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
169 print
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
173 foreach ($data as $val) {
174 $year = $val[
'year'];
175 while ($oldyear > $year + 1) {
177 print
'<tr class="oddeven" height="24">';
178 print
'<td class="center">';
183 print
'<td class="right">0</td>';
184 print
'<td class="right">0</td>';
185 print
'<td class="right">0</td>';
188 print
'<tr class="oddeven" height="24">';
189 print
'<td class="center">';
194 print
'<td class="right">'.$val[
'nb'].
'</td>';
195 print
'<td class="right">'.price(
price2num($val[
'total'],
'MT'), 1).
'</td>';
196 print
'<td class="right">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</td>';
205 print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">';
209 print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
210 if ($mesg) { print $mesg; }
else {
215 print
'</td></tr></table>';
218 print
'</div></div></div>';
219 print
'<div style="clear:both"></div>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage statistics of members.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
member_stats_prepare_head($object)
Return array head with list of tabs to view object stats informations.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
static getDefaultGraphSizeForStats($direction, $defaultsize= '')
getDefaultGraphSizeForStats
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)