Go to the documentation of this file.
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');
35 $socid =
GETPOST(
'socid',
'int');
37 if ($user->socid > 0) {
39 $socid = $user->socid;
44 $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
48 $langs->loadLangs(array(
'sendings',
'other',
'companies'));
52 $socid = $user->socid;
70 $stats =
new ExpeditionStats($db, $socid,
'', ($userid > 0 ? $userid : 0));
73 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
78 if (empty($user->rights->societe->client->voir) || $user->socid) {
79 $filenamenb = $dir.
'/shipmentsnbinyear-'.$user->id.
'-'.$year.
'.png';
81 $filenamenb = $dir.
'/shipmentsnbinyear-'.$year.
'.png';
85 $mesg = $px1->isGraphKo();
88 $i = $startyear; $legend = array();
89 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)) {
196 $arrayyears[$nowyear] = $nowyear;
201 $head[$h][0] = DOL_URL_ROOT.
'/expedition/stats/index.php';
202 $head[$h][1] = $langs->trans(
"ByMonthYear");
203 $head[$h][2] =
'byyear';
206 $type =
'shipment_stats';
213 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="noborder 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
img_picto(
'',
'company',
'class="pictofixedwidth"');
225 print
$form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
228 print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
229 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
230 print
$form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
233 print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
234 if (!in_array($year, $arrayyears)) {
235 $arrayyears[$year] = $year;
237 if (!in_array($nowyear, $arrayyears)) {
238 $arrayyears[$nowyear] = $nowyear;
241 print
$form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
243 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
249 print
'<div class="div-table-responsive-no-min">';
250 print
'<table class="noborder centpercent">';
251 print
'<tr class="liste_titre" height="24">';
252 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
253 print
'<td class="right">'.$langs->trans(
"NbOfSendings").
'</td>';
259 foreach ($data as $val) {
260 $year = $val[
'year'];
261 while (!empty($year) && $oldyear > $year + 1) {
265 print
'<tr class="oddeven" height="24">';
266 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
268 print
'<td class="right">0</td>';
274 print
'<tr class="oddeven" height="24">';
275 print
'<td class="center">';
277 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a>';
280 print
'Error: validation date of shipment is not defined. This looks strange because shipment is validated. Try to run /install/repair.php?standard=confirmed';
283 print
'<td class="right">'.$val[
'nb'].
'</td>';
294 print
'</div><div class="fichetwothirdright">';
298 print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
308 print
'</td></tr></table>';
311 print
'</div></div>';
312 print
'<div style="clear:both"></div>';
351 print
'<i class="opacitymedium">'.$langs->trans(
"StatsOnShipmentsOnlyValidated").
'</i>';
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
restrictedArea($user, $features, $objectid=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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 shipment statistics.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_now($mode='auto')
Return date for now.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)