27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/reception/class/reception.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/reception/class/receptionstats.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
35 $userid =
GETPOST(
'userid',
'int');
36 $socid =
GETPOST(
'socid',
'int');
41 $socid = $user->socid;
44 $nowyear = strftime(
"%Y",
dol_now());
47 $startyear = $year - 1;
50 $langs->load(
"reception");
51 $langs->load(
"other");
52 $langs->load(
"companies");
60 $form =
new Form($db);
69 $stats =
new ReceptionStats($db, $socid,
'', ($userid > 0 ? $userid : 0));
72 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
77 if (!$user->rights->societe->client->voir || $user->socid)
79 $filenamenb = $dir.
'/receptionsnbinyear-'.$user->id.
'-'.$year.
'.png';
81 $filenamenb = $dir.
'/receptionsnbinyear-'.$year.
'.png';
85 $mesg = $px1->isGraphKo();
89 $i = $startyear; $legend = array();
90 while ($i <= $endyear)
95 $px1->SetLegend($legend);
96 $px1->SetMaxValue($px1->GetCeilMaxValue());
97 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
98 $px1->SetWidth($WIDTH);
99 $px1->SetHeight($HEIGHT);
100 $px1->SetYLabel($langs->trans(
"NbOfReceptions"));
102 $px1->SetHorizTickIncrement(1);
103 $px1->mode =
'depth';
104 $px1->SetTitle($langs->trans(
"NumberOfReceptionsByMonth"));
106 $px1->draw($filenamenb, $fileurlnb);
190 $data = $stats->getAllByYear();
191 $arrayyears = array();
192 foreach ($data as $val) {
193 if (!empty($val[
'year'])) {
194 $arrayyears[$val[
'year']] = $val[
'year'];
197 if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
201 $head[$h][0] = DOL_URL_ROOT.
'/reception/stats/index.php';
202 $head[$h][1] = $langs->trans(
"ByMonthYear");
203 $head[$h][2] =
'byyear';
206 $type =
'reception_stats';
213 print '<div class="fichecenter"><div class="fichethirdleft">';
219 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
220 print
'<input type="hidden" name="token" value="'.newToken().
'">';
222 print
'<table class="noborder centpercent">';
223 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
225 print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
226 print $form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'',
'style="width: 95%"');
229 print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
230 print $form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
233 print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
234 if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
235 if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
237 print $form->selectarray(
'year', $arrayyears, $year, 0);
239 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
245 print
'<table class="noborder centpercent">';
246 print
'<tr class="liste_titre" height="24">';
247 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
248 print
'<td class="right">'.$langs->trans(
"NbOfReceptions").
'</td>';
254 foreach ($data as $val)
256 $year = $val[
'year'];
257 while (!empty($year) && $oldyear > $year + 1)
262 print
'<tr class="oddeven" height="24">';
263 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
265 print
'<td class="right">0</td>';
271 print
'<tr class="oddeven" height="24">';
272 print
'<td class="center">';
273 if ($year) print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a>';
274 else print $langs->trans(
"ValidationDateNotDefinedEvenIfReceptionValidated");
276 print
'<td class="right">'.$val[
'nb'].
'</td>';
286 print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">';
290 print
'<table class="border centpercent"><tr valign="top"><td class="center">';
291 if ($mesg) { print $mesg; }
else {
298 print
'</td></tr></table>';
301 print
'</div></div></div>';
302 print
'<div style="clear:both"></div>';
341 print
'<i class="opacitymedium">'.$langs->trans(
"StatsOnReceptionsOnlyValidated").
'</i>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_now($mode= 'auto')
Return date for now.
Class to manage reception statistics.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
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
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode= 'add')
Complete or removed entries into a head array (used to build tabs).
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)