26 require
'../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expeditionstats.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
34 $userid=
GETPOST(
'userid',
'int');
37 if ($user->societe_id > 0)
40 $socid = $user->societe_id;
43 $nowyear=strftime(
"%Y",
dol_now());
50 $langs->loadLangs(array(
'sendings',
'other',
'companies'));
66 $stats =
new ExpeditionStats($db, $socid, $mode, ($userid>0?$userid:0));
69 $data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
74 if (!$user->rights->societe->client->voir || $user->societe_id)
76 $filenamenb = $dir.
'/shipmentsnbinyear-'.$user->id.
'-'.$year.
'.png';
77 if ($mode ==
'customer') $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=shipmentstats&file=shipmentsnbinyear-'.$user->id.
'-'.$year.
'.png';
78 if ($mode ==
'supplier') $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsnbinyear-'.$user->id.
'-'.$year.
'.png';
82 $filenamenb = $dir.
'/shipmentsnbinyear-'.$year.
'.png';
83 if ($mode ==
'customer') $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=shipmentstats&file=shipmentsnbinyear-'.$year.
'.png';
84 if ($mode ==
'supplier') $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsnbinyear-'.$year.
'.png';
88 $mesg = $px1->isGraphKo();
92 $px1->SetPrecisionY(0);
93 $i=$startyear;$legend=array();
94 while ($i <= $endyear)
99 $px1->SetLegend($legend);
100 $px1->SetMaxValue($px1->GetCeilMaxValue());
101 $px1->SetMinValue(min(0,$px1->GetFloorMinValue()));
102 $px1->SetWidth($WIDTH);
103 $px1->SetHeight($HEIGHT);
104 $px1->SetYLabel($langs->trans(
"NbOfSendings"));
106 $px1->SetHorizTickIncrement(1);
107 $px1->SetPrecisionY(0);
109 $px1->SetTitle($langs->trans(
"NumberOfShipmentsByMonth"));
111 $px1->draw($filenamenb,$fileurlnb);
205 $data = $stats->getAllByYear();
207 foreach($data as $val) {
208 if (! empty($val[
'year'])) {
209 $arrayyears[$val[
'year']]=$val[
'year'];
212 if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
216 $head[$h][0] = DOL_URL_ROOT .
'/expedition/stats/index.php?mode='.$mode;
217 $head[$h][1] = $langs->trans(
"ByMonthYear");
218 $head[$h][2] =
'byyear';
221 $type=
'shipment_stats';
228 print '<div class="fichecenter"><div class="fichethirdleft">';
234 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
235 print
'<input type="hidden" name="mode" value="'.$mode.
'">';
237 print
'<table class="noborder" width="100%">';
238 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
240 print
'<tr><td align="left">'.$langs->trans(
"ThirdParty").
'</td><td align="left">';
241 if ($mode ==
'customer') $filter=
's.client in (1,2,3)';
242 if ($mode ==
'supplier') $filter=
's.fournisseur = 1';
243 print $form->select_company($socid,
'socid',$filter,1,0,0,array(),0,
'',
'style="width: 95%"');
246 print
'<tr><td align="left">'.$langs->trans(
"CreatedBy").
'</td><td align="left">';
247 print $form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'maxwidth300');
250 print
'<tr><td align="left">'.$langs->trans(
"Year").
'</td><td align="left">';
251 if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
252 if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
254 print $form->selectarray(
'year',$arrayyears,$year,0);
256 print
'<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
263 print
'<div class="div-table-responsive-no-min">';
264 print
'<table class="noborder" width="100%">';
265 print
'<tr class="liste_titre" height="24">';
266 print
'<td align="center">'.$langs->trans(
"Year").
'</td>';
267 print
'<td align="right">'.$langs->trans(
"NbOfSendings").
'</td>';
273 foreach ($data as $val)
275 $year = $val[
'year'];
276 while (! empty($year) && $oldyear > $year+1)
281 print
'<tr class="oddeven" height="24">';
282 print
'<td align="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'&mode='.$mode.
'">'.$oldyear.
'</a></td>';
284 print
'<td align="right">0</td>';
290 print
'<tr class="oddeven" height="24">';
291 print
'<td align="center">';
292 if ($year) print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'&mode='.$mode.
'">'.$year.
'</a>';
293 else print $langs->trans(
"ValidationDateNotDefinedEvenIfShipmentValidated");
295 print
'<td align="right">'.$val[
'nb'].
'</td>';
306 print
'</div><div class="fichetwothirdright"><div class="ficheaddleft">';
310 print
'<table class="border" width="100%"><tr class="pair nohover"><td align="center">';
311 if ($mesg) { print $mesg; }
319 print
'</td></tr></table>';
322 print
'</div></div></div>';
323 print
'<div style="clear:both"></div>';
362 print
'<i>'.$langs->trans(
"StatsOnShipmentsOnlyValidated").
'</i>';
load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='none', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print
Draft customers invoices.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add')
Complete or removed entries into a head array (used to build tabs).
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
dol_fiche_end($notab=0)
Show tab footer of a card.
dol_now($mode='gmt')
Return date for now.
dol_mkdir($dir, $dataroot='', $newmask=null)
Creation of a directory (this can create recursive subdir)
Class to manage shipment statistics.
dol_fiche_head($links=array(), $active='0', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='')
Show tab header of a card.