--- /tmp/dsg/dolibarr/htdocs/reception/stats/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/reception/stats/client_index.php @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -38,4 +37,11 @@ - -$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); -$year = GETPOST('year') > 0 ? GETPOST('year') : $nowyear; -$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS')))); +// Security check +if ($user->socid > 0) +{ + $action = ''; + $socid = $user->socid; +} + +$nowyear = strftime("%Y", dol_now()); +$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; +//$startyear=$year-2; +$startyear = $year - 1; @@ -44,7 +50,4 @@ -$langs->loadLangs(array("receptions", "other", "companies")); - -// Security check -if ($user->socid) { - $socid = $user->socid; -} -$result = restrictedArea($user, 'reception', 0, ''); +$langs->load("reception"); +$langs->load("other"); +$langs->load("companies"); + @@ -63 +66 @@ -$dir = (!empty($conf->reception->multidir_temp[$conf->entity]) ? $conf->reception->multidir_temp[$conf->entity] : $conf->service->multidir_temp[$conf->entity]); + @@ -74,4 +77,7 @@ -if (!$user->hasRight('societe', 'client', 'voir') || $user->socid) { - $filenamenb = $dir.'/receptionsnbinyear-'.$user->id.'-'.$year.'.png'; -} else { - $filenamenb = $dir.'/receptionsnbinyear-'.$year.'.png'; +if (!$user->rights->societe->client->voir || $user->socid) +{ + $filenamenb = $dir.'/receptionsnbinyear-'.$user->id.'-'.$year.'.png'; +} +else +{ + $filenamenb = $dir.'/receptionsnbinyear-'.$year.'.png'; @@ -82,21 +88,21 @@ -$fileurlnb = ''; -if (!$mesg) { - $px1->SetData($data); - $i = $startyear; - $legend = array(); - while ($i <= $endyear) { - $legend[] = $i; - $i++; - } - $px1->SetLegend($legend); - $px1->SetMaxValue($px1->GetCeilMaxValue()); - $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); - $px1->SetWidth($WIDTH); - $px1->SetHeight($HEIGHT); - $px1->SetYLabel($langs->trans("NbOfReceptions")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NumberOfReceptionsByMonth")); - - $px1->draw($filenamenb, $fileurlnb); +if (!$mesg) +{ + $px1->SetData($data); + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { + $legend[] = $i; + $i++; + } + $px1->SetLegend($legend); + $px1->SetMaxValue($px1->GetCeilMaxValue()); + $px1->SetMinValue(min(0, $px1->GetFloorMinValue())); + $px1->SetWidth($WIDTH); + $px1->SetHeight($HEIGHT); + $px1->SetYLabel($langs->trans("NbOfReceptions")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->mode = 'depth'; + $px1->SetTitle($langs->trans("NumberOfReceptionsByMonth")); + + $px1->draw($filenamenb, $fileurlnb); @@ -111,3 +117,3 @@ -if (empty($user->rights->societe->client->voir) || $user->socid) -{ - $filenameamount = $dir.'/receptionsamountinyear-'.$user->id.'-'.$year.'.png'; +if (!$user->rights->societe->client->voir || $user->socid) +{ + $filenameamount = $dir.'/receptionsamountinyear-'.$user->id.'-'.$year.'.png'; @@ -117 +123 @@ - $filenameamount = $dir.'/receptionsamountinyear-'.$year.'.png'; + $filenameamount = $dir.'/receptionsamountinyear-'.$year.'.png'; @@ -124,19 +130,19 @@ - $px2->SetData($data); - $i=$startyear;$legend=array(); - while ($i <= $endyear) - { - $legend[]=$i; - $i++; - } - $px2->SetLegend($legend); - $px2->SetMaxValue($px2->GetCeilMaxValue()); - $px2->SetMinValue(min(0,$px2->GetFloorMinValue())); - $px2->SetWidth($WIDTH); - $px2->SetHeight($HEIGHT); - $px2->SetYLabel($langs->trans("AmountOfReceptions")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode='depth'; - $px2->SetTitle($langs->trans("AmountOfReceptionsByMonthHT")); - - $px2->draw($filenameamount,$fileurlamount); + $px2->SetData($data); + $i=$startyear;$legend=array(); + while ($i <= $endyear) + { + $legend[]=$i; + $i++; + } + $px2->SetLegend($legend); + $px2->SetMaxValue($px2->GetCeilMaxValue()); + $px2->SetMinValue(min(0,$px2->GetFloorMinValue())); + $px2->SetWidth($WIDTH); + $px2->SetHeight($HEIGHT); + $px2->SetYLabel($langs->trans("AmountOfReceptions")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode='depth'; + $px2->SetTitle($langs->trans("AmountOfReceptionsByMonthHT")); + + $px2->draw($filenameamount,$fileurlamount); @@ -149,3 +155,3 @@ -if (empty($user->rights->societe->client->voir) || $user->socid) -{ - $filename_avg = $dir.'/receptionsaverage-'.$user->id.'-'.$year.'.png'; +if (!$user->rights->societe->client->voir || $user->socid) +{ + $filename_avg = $dir.'/receptionsaverage-'.$user->id.'-'.$year.'.png'; @@ -155 +161 @@ - $filename_avg = $dir.'/receptionsaverage-'.$year.'.png'; + $filename_avg = $dir.'/receptionsaverage-'.$year.'.png'; @@ -162,19 +168,19 @@ - $px3->SetData($data); - $i=$startyear;$legend=array(); - while ($i <= $endyear) - { - $legend[]=$i; - $i++; - } - $px3->SetLegend($legend); - $px3->SetYLabel($langs->trans("AmountAverage")); - $px3->SetMaxValue($px3->GetCeilMaxValue()); - $px3->SetMinValue($px3->GetFloorMinValue()); - $px3->SetWidth($WIDTH); - $px3->SetHeight($HEIGHT); - $px3->SetShading(3); - $px3->SetHorizTickIncrement(1); - $px3->mode='depth'; - $px3->SetTitle($langs->trans("AmountAverage")); - - $px3->draw($filename_avg,$fileurl_avg); + $px3->SetData($data); + $i=$startyear;$legend=array(); + while ($i <= $endyear) + { + $legend[]=$i; + $i++; + } + $px3->SetLegend($legend); + $px3->SetYLabel($langs->trans("AmountAverage")); + $px3->SetMaxValue($px3->GetCeilMaxValue()); + $px3->SetMinValue($px3->GetFloorMinValue()); + $px3->SetWidth($WIDTH); + $px3->SetHeight($HEIGHT); + $px3->SetShading(3); + $px3->SetHorizTickIncrement(1); + $px3->mode='depth'; + $px3->SetTitle($langs->trans("AmountAverage")); + + $px3->draw($filename_avg,$fileurl_avg); @@ -193,3 +199 @@ -if (!count($arrayyears)) { - $arrayyears[$nowyear] = $nowyear; -} +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -208 +212 @@ -print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); +dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); @@ -214,31 +218,28 @@ -// Show filter box -print '
'; -print '