27require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expedition.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/expedition/class/expeditionstats.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
35$userid =
GETPOST(
'userid',
'int');
36$socid =
GETPOST(
'socid',
'int');
38if ($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;
68$dir = (!empty($conf->expedition->multidir_temp[$conf->entity]) ? $conf->expedition->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]);
71$stats =
new ExpeditionStats($db, $socid,
'', ($userid > 0 ? $userid : 0));
74$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
79if (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();
90 $i = $startyear; $legend = array();
91 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(
"NbOfSendings"));
102 $px1->SetHorizTickIncrement(1);
103 $px1->mode =
'depth';
104 $px1->SetTitle($langs->trans(
"NumberOfShipmentsByMonth"));
106 $px1->draw($filenamenb, $fileurlnb);
190$data = $stats->getAllByYear();
191$arrayyears = array();
192foreach ($data as $val) {
193 if (!empty($val[
'year'])) {
194 $arrayyears[$val[
'year']] = $val[
'year'];
197if (!count($arrayyears)) {
198 $arrayyears[$nowyear] = $nowyear;
203$head[$h][0] = DOL_URL_ROOT.
'/expedition/stats/index.php';
204$head[$h][1] = $langs->trans(
"ByMonthYear");
205$head[$h][2] =
'byyear';
208$type =
'shipment_stats';
215print
'<div class="fichecenter"><div class="fichethirdleft">';
219print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
220print
'<input type="hidden" name="token" value="'.newToken().
'">';
222print
'<table class="noborder centpercent">';
223print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
225print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
226print
img_picto(
'',
'company',
'class="pictofixedwidth"');
227print $form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
230print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
231print
img_picto(
'',
'user',
'class="pictofixedwidth"');
232print $form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
235print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
236if (!in_array($year, $arrayyears)) {
237 $arrayyears[$year] = $year;
239if (!in_array($nowyear, $arrayyears)) {
240 $arrayyears[$nowyear] = $nowyear;
243print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
245print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
251print
'<div class="div-table-responsive-no-min">';
252print
'<table class="noborder centpercent">';
253print
'<tr class="liste_titre" height="24">';
254print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
255print
'<td class="right">'.$langs->trans(
"NbOfSendings").
'</td>';
261foreach ($data as $val) {
262 $year = $val[
'year'];
263 while (!empty($year) && $oldyear > $year + 1) {
267 print
'<tr class="oddeven" height="24">';
268 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'">'.$oldyear.
'</a></td>';
270 print
'<td class="right">0</td>';
276 print
'<tr class="oddeven" height="24">';
277 print
'<td class="center">';
279 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'">'.$year.
'</a>';
282 print
'Error: validation date of shipment is not defined. This looks strange because shipment is validated. Try to run /install/repair.php?standard=confirmed';
285 print
'<td class="right">'.$val[
'nb'].
'</td>';
296print
'</div><div class="fichetwothirdright">';
300print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
310print
'</td></tr></table>';
314print
'<div class="clearboth"></div>';
353print
'<i class="opacitymedium">'.$langs->trans(
"StatsOnShipmentsOnlyValidated").
'</i>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Class to manage shipment 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='', $dragdropfile=0)
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)
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.