27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/don/class/donstats.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;
51 $langs->loadLangs(array(
"companies",
"other",
"sendings"));
58 $form =
new Form($db);
67 $stats =
new DonationStats($db, $socid,
'', ($userid > 0 ? $userid : 0));
70 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
75 if (!$user->rights->societe->client->voir || $user->socid)
77 $filenamenb = $dir.
'/shipmentsnbinyear-'.$user->id.
'-'.$year.
'.png';
79 $filenamenb = $dir.
'/shipmentsnbinyear-'.$year.
'.png';
83 $mesg = $px1->isGraphKo();
87 $i = $startyear; $legend = array();
88 while ($i <= $endyear)
93 $px1->SetLegend($legend);
94 $px1->SetMaxValue($px1->GetCeilMaxValue());
95 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
96 $px1->SetWidth($WIDTH);
97 $px1->SetHeight($HEIGHT);
98 $px1->SetYLabel($langs->trans(
"NbOfSendings"));
100 $px1->SetHorizTickIncrement(1);
101 $px1->mode =
'depth';
102 $px1->SetTitle($langs->trans(
"NumberOfShipmentsByMonth"));
104 $px1->draw($filenamenb, $fileurlnb);
188 $data = $stats->getAllByYear();
189 $arrayyears = array();
190 foreach ($data as $val) {
191 if (!empty($val[
'year'])) {
192 $arrayyears[$val[
'year']] = $val[
'year'];
195 if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
199 $head[$h][0] = DOL_URL_ROOT.
'/don/stats/index.php';
200 $head[$h][1] = $langs->trans(
"ByMonthYear");
201 $head[$h][2] =
'byyear';
204 $type =
'donation_stats';
211 print '<div class="fichecenter"><div class="fichethirdleft">';
217 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
218 print
'<input type="hidden" name="token" value="'.newToken().
'">';
220 print
'<table class="border centpercent">';
221 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
223 print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
224 print $form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'',
'style="width: 95%"');
227 print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
228 print $form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
231 print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
232 if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
233 if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
235 print $form->selectarray(
'year', $arrayyears, $year, 0);
237 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
243 print
'<div class="div-table-responsive-no-min">';
244 print
'<table class="border centpercent">';
245 print
'<tr height="24">';
246 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
247 print
'<td class="center">'.$langs->trans(
"NbOfSendings").
'</td>';
253 foreach ($data as $val)
255 $year = $val[
'year'];
256 while (!empty($year) && $oldyear > $year + 1)
259 print
'<tr height="24">';
260 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
262 print
'<td class="right">0</td>';
268 print
'<tr height="24">';
269 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a></td>';
270 print
'<td class="right">'.$val[
'nb'].
'</td>';
281 print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">';
285 print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
286 if ($mesg) { print $mesg; }
else {
293 print
'</td></tr></table>';
296 print
'</div></div></div>';
297 print
'<div style="clear:both"></div>';
336 print
'<i>'.$langs->trans(
"StatsOnShipmentsOnlyValidated").
'</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.
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.
Class to manage donations statistics.
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)