--- /tmp/dsg/dolibarr/htdocs/ticket/stats/github_19.0.3_index.php
+++ /tmp/dsg/dolibarr/htdocs/ticket/stats/client_index.php
@@ -24 +23,0 @@
-// Load Dolibarr environment

@@ -34,5 +33,3 @@
-if (!$user->hasRight('ticket', 'read')) {

-	accessforbidden();

-}

-

-$object_status = GETPOST('object_status', 'intcomma');

+if (!$user->rights->ticket->read) accessforbidden();

+

+$object_status = GETPOST('object_status');

@@ -43,8 +40,10 @@
-if ($user->socid > 0) {

-	$action = '';

-	$socid = $user->socid;

-}

-

-$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt');

-$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear;

-$startyear = $year - (!getDolGlobalString('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));

+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;

@@ -74,3 +73 @@
-if ($object_status != '' && $object_status >= -1) {

-	$stats->where .= ' AND fk_statut IN ('.$db->sanitize($db->escape($object_status)).')';

-}

+if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND fk_statut IN ('.$db->escape($object_status).')';

@@ -86,6 +83,9 @@
-if (!$user->hasRight('societe', 'client', 'voir') || $user->socid) {

-	$filenamenb = $dir.'/ticketsnbinyear-'.$user->id.'-'.$year.'.png';

-	$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.'-'.$year.'.png';

-} else {

-	$filenamenb = $dir.'/ticketsnbinyear-'.$year.'.png';

-	$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$year.'.png';

+if (!$user->rights->societe->client->voir || $user->socid)

+{

+    $filenamenb = $dir.'/ticketsnbinyear-'.$user->id.'-'.$year.'.png';

+    $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.'-'.$year.'.png';

+}

+else

+{

+    $filenamenb = $dir.'/ticketsnbinyear-'.$year.'.png';

+    $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$year.'.png';

@@ -96,20 +96,21 @@
-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("NbOfTicket"));

-	$px1->SetShading(3);

-	$px1->SetHorizTickIncrement(1);

-	$px1->mode = 'depth';

-	$px1->SetTitle($langs->trans("NumberOfTicketsByMonth"));

-

-	$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("NbOfTicket"));

+    $px1->SetShading(3);

+    $px1->SetHorizTickIncrement(1);

+    $px1->mode = 'depth';

+    $px1->SetTitle($langs->trans("NumberOfTicketsByMonth"));

+

+    $px1->draw($filenamenb, $fileurlnb);

@@ -123,7 +124,9 @@
-

-/*if (empty($user->rights->societe->client->voir) || $user->socid) {

-	$filenameamount = $dir.'/ticketsamountinyear-'.$user->id.'-'.$year.'.png';

-	$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.'-'.$year.'.png';

-} else {

-	$filenameamount = $dir.'/ticketsamountinyear-'.$year.'.png';

-	$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$year.'.png';

+if (!$user->rights->societe->client->voir || $user->socid)

+{

+    $filenameamount = $dir.'/ticketsamountinyear-'.$user->id.'-'.$year.'.png';

+    $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.'-'.$year.'.png';

+}

+else

+{

+    $filenameamount = $dir.'/ticketsamountinyear-'.$year.'.png';

+    $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$year.'.png';

@@ -134,19 +137,21 @@
-if (!$mesg) {

-	$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("AmountOfTickets"));

-	$px2->SetShading(3);

-	$px2->SetHorizTickIncrement(1);

-	$px2->mode = 'depth';

-	$px2->SetTitle($langs->trans("AmountOfTicketsByMonthHT"));

-

-	$px2->draw($filenameamount, $fileurlamount);

+if (!$mesg)

+{

+    $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("AmountOfTickets"));

+    $px2->SetShading(3);

+    $px2->SetHorizTickIncrement(1);

+    $px2->mode = 'depth';

+    $px2->SetTitle($langs->trans("AmountOfTicketsByMonthHT"));

+

+    $px2->draw($filenameamount, $fileurlamount);

@@ -158,6 +163,9 @@
-if (empty($user->rights->societe->client->voir) || $user->socid) {

-	$filename_avg = $dir.'/ticketsaverage-'.$user->id.'-'.$year.'.png';

-	$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.'-'.$year.'.png';

-} else {

-	$filename_avg = $dir.'/ticketsaverage-'.$year.'.png';

-	$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$year.'.png';

+if (!$user->rights->societe->client->voir || $user->socid)

+{

+    $filename_avg = $dir.'/ticketsaverage-'.$user->id.'-'.$year.'.png';

+    $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.'-'.$year.'.png';

+}

+else

+{

+    $filename_avg = $dir.'/ticketsaverage-'.$year.'.png';

+    $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$year.'.png';

@@ -168,20 +176,22 @@
-if (!$mesg) {

-	$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);

-}*/

+if (!$mesg)

+{

+    $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);

+}

@@ -199,3 +209 @@
-if (!count($arrayyears)) {

-	$arrayyears[$nowyear] = $nowyear;

-}

+if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;

@@ -214 +222 @@
-print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);

+dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);

@@ -228,2 +236 @@
-print img_picto('', 'company', 'class="pictofixedwidth"');

-print $form->select_company($socid, 'socid', '', 1, 0, 0, array(), 0, 'widthcentpercentminusx maxwidth300', '');

+print $form->select_company($socid, 'socid', '', 1, 0, 0, array(), 0, '', 'style="width: 95%"');

@@ -233,2 +240 @@
-print img_picto('', 'user', 'class="pictofixedwidth"');

-print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');

+print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');

@@ -238 +244 @@
-print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'intcomma'), -4, 0, 0, '', 1);

+print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4, 0, 0, '', 1);

@@ -242,6 +248,2 @@
-if (!in_array($year, $arrayyears)) {

-	$arrayyears[$year] = $year;

-}

-if (!in_array($nowyear, $arrayyears)) {

-	$arrayyears[$nowyear] = $nowyear;

-}

+if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;

+if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;

@@ -249 +251 @@
-print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75');

+print $form->selectarray('year', $arrayyears, $year, 0);

@@ -251 +253 @@
-print '<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans("Refresh").'"></td></tr>';

+print '<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';

@@ -270 +272,2 @@
-foreach ($data as $val) {

+foreach ($data as $val)

+{

@@ -272 +275,2 @@
-	while (!empty($year) && $oldyear > $year + 1) { // If we have empty year

+	while (!empty($year) && $oldyear > $year + 1)

+	{ // If we have empty year

@@ -290 +294 @@
-	print '<td class="right" style="'.((isset($val['nb_diff']) && $val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round(isset($val['nb_diff']) ? $val['nb_diff'] : 0).'</td>';

+	print '<td class="right" style="'.(($val['nb_diff'] >= 0) ? 'color: green;' : 'color: red;').'">'.round($val['nb_diff']).'</td>';

@@ -303 +307 @@
-print '</div><div class="fichetwothirdright">';

+print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';

@@ -308,8 +312,7 @@
-if ($mesg) {

-	print $mesg;

-} else {

-	print $px1->show();

-	print "<br>\n";

-	//print $px2->show();

-	//print "<br>\n";

-	//print $px3->show();

+if ($mesg) { print $mesg; }

+else {

+    print $px1->show();

+    print "<br>\n";

+    //print $px2->show();

+    //print "<br>\n";

+    //print $px3->show();

@@ -320,4 +323,4 @@
-print '</div></div>';

-print '<div class="clearboth"></div>';

-

-print dol_get_fiche_end();

+print '</div></div></div>';

+print '<div style="clear:both"></div>';

+

+dol_fiche_end();