27 require
'../../main.inc.php';
28 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expeditionstats.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
35 $userid =
GETPOST(
'userid',
'int');
36 $socid =
GETPOST(
'socid',
'int');
38 if ($user->socid > 0) {
40 $socid = $user->socid;
45 $startyear = $year - (empty($conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS) ? 2 : max(1, min(10, $conf->global->MAIN_STATS_GRAPHS_SHOW_N_YEARS)));
49 $langs->loadLangs(array(
'sendings',
'other',
'companies'));
53 $socid = $user->socid;
71 $stats =
new ExpeditionStats($db, $socid,
'', ($userid > 0 ? $userid : 0));
74 $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
79 if (empty($user->rights->societe->client->voir) || $user->socid) {
80 $filenamenb = $dir.
'/shipmentsnbinyear-'.$user->id.
'-'.$year.
'.png';
82 $filenamenb = $dir.
'/shipmentsnbinyear-'.$year.
'.png';
86 $mesg = $px1->isGraphKo();
89 $i = $startyear; $legend = array();
90 while ($i <= $endyear) {
94 $px1->SetLegend($legend);
95 $px1->SetMaxValue($px1->GetCeilMaxValue());
96 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
97 $px1->SetWidth($WIDTH);
98 $px1->SetHeight($HEIGHT);
99 $px1->SetYLabel($langs->trans(
"NbOfSendings"));
101 $px1->SetHorizTickIncrement(1);
102 $px1->mode =
'depth';
103 $px1->SetTitle($langs->trans(
"NumberOfShipmentsByMonth"));
105 $px1->draw($filenamenb, $fileurlnb);
189 $data = $stats->getAllByYear();
190 $arrayyears = array();
191 foreach ($data as $val) {
192 if (!empty($val[
'year'])) {
193 $arrayyears[$val[
'year']] = $val[
'year'];
196 if (!count($arrayyears)) {
197 $arrayyears[$nowyear] = $nowyear;
202 $head[$h][0] = DOL_URL_ROOT.
'/expedition/stats/index.php';
203 $head[$h][1] = $langs->trans(
"ByMonthYear");
204 $head[$h][2] =
'byyear';
207 $type =
'shipment_stats';
214 print
'<div class="fichecenter"><div class="fichethirdleft">';
218 print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
219 print
'<input type="hidden" name="token" value="'.newToken().
'">';
221 print
'<table class="noborder centpercent">';
222 print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
224 print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
225 print
img_picto(
'',
'company',
'class="pictofixedwidth"');
226 print
$form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
229 print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
230 print
img_picto(
'',
'user',
'class="pictofixedwidth"');
231 print
$form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
234 print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
235 if (!in_array($year, $arrayyears)) {
236 $arrayyears[$year] = $year;
238 if (!in_array($nowyear, $arrayyears)) {
239 $arrayyears[$nowyear] = $nowyear;
242 print
$form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
244 print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
250 print
'<div class="div-table-responsive-no-min">';
251 print
'<table class="noborder centpercent">';
252 print
'<tr class="liste_titre" height="24">';
253 print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
254 print
'<td class="right">'.$langs->trans(
"NbOfSendings").
'</td>';
260 foreach ($data as $val) {
261 $year = $val[
'year'];
262 while (!empty($year) && $oldyear > $year + 1) {
266 print
'<tr class="oddeven" height="24">';
267 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
269 print
'<td class="right">0</td>';
275 print
'<tr class="oddeven" height="24">';
276 print
'<td class="center">';
278 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a>';
281 print
'Error: validation date of shipment is not defined. This looks strange because shipment is validated. Try to run /install/repair.php?standard=confirmed';
284 print
'<td class="right">'.$val[
'nb'].
'</td>';
295 print
'</div><div class="fichetwothirdright">';
299 print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
309 print
'</td></tr></table>';
312 print
'</div></div>';
313 print
'<div style="clear:both"></div>';
352 print
'<i class="opacitymedium">'.$langs->trans(
"StatsOnShipmentsOnlyValidated").
'</i>';
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Class to manage shipment statistics.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
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.
restrictedArea(User $user, $features, $object=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.