--- /tmp/dsg/dolibarr/htdocs/compta/deplacement/stats/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/compta/deplacement/stats/client_index.php @@ -26 +25,0 @@ -// Load Dolibarr environment @@ -37,6 +36,2 @@ -$userid = GETPOST('userid', 'int'); if ($userid < 0) { - $userid = 0; -} -$socid = GETPOST('socid', 'int'); if ($socid < 0) { - $socid = 0; -} +$userid = GETPOST('userid', 'int'); if ($userid < 0) $userid = 0; +$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0; @@ -46 +41,2 @@ -if ($user->socid > 0) { +if ($user->socid > 0) +{ @@ -50,3 +46 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -58,2 +52,4 @@ -if ($userid > 0) { - if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous') && !in_array($userid, $childids)) { +if ($userid > 0) +{ + if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous) && !in_array($userid, $childids)) + { @@ -65,3 +61,4 @@ -$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')))); +$nowyear = strftime("%Y", dol_now()); +$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; +//$startyear=$year-2; +$startyear = $year - 1; @@ -70 +67 @@ -$mode = GETPOST("mode") ? GETPOST("mode") : 'customer'; +$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; @@ -90 +87,2 @@ -if (empty($useridtofilter)) { +if (empty($useridtofilter)) +{ @@ -92,3 +90 @@ - if ($user->hasRight('deplacement', 'readall') || $user->hasRight('deplacement', 'lire_tous')) { - $useridtofilter = 0; - } + if (!empty($user->rights->deplacement->readall) || !empty($user->rights->deplacement->lire_tous)) $useridtofilter = 0; @@ -111 +107,2 @@ -if (!$mesg) { +if (!$mesg) +{ @@ -113,3 +110,3 @@ - $i = $startyear; - $legend = array(); - while ($i <= $endyear) { + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { @@ -142 +139,2 @@ -if (!$mesg) { +if (!$mesg) +{ @@ -144,3 +142,3 @@ - $i = $startyear; - $legend = array(); - while ($i <= $endyear) { + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { @@ -167,16 +165,11 @@ -if (!$user->hasRight('societe', 'client', 'voir') || $user->socid) { - $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; - if ($mode == 'customer') { - $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - } - if ($mode == 'supplier') { - $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; - } -} else { - $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; - if ($mode == 'customer') { - $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; - } - if ($mode == 'supplier') { - $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; - } +if (!$user->rights->societe->client->voir || $user->socid) +{ + $filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png'; +} +else +{ + $filename_avg = $dir.'/ordersaverage-'.$year.'.png'; + if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png'; + if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$year.'.png'; @@ -187,20 +180,21 @@ -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); @@ -214,5 +208,3 @@ - $arrayyears[$val['year']] = $val['year']; -} -if (!count($arrayyears)) { - $arrayyears[$nowyear] = $nowyear; -} + $arrayyears[$val['year']] = $val['year']; +} +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -230 +222 @@ -print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); +dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); @@ -245,2 +237,2 @@ -print img_picto('', 'company', 'class="pictofixedwidth"'); -print $form->select_company($socid, 'socid', '', 1, 1, 0, array(), 0, 'widthcentpercentminusx maxwidth300', ''); +$filter = ''; +print $form->select_company($socid, 'socid', $filter, 1, 1, 0, array(), 0, '', 'style="width: 95%"'); @@ -251,5 +243,2 @@ -if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous')) { - $include = 'hierarchy'; -} -print img_picto('', 'user', 'class="pictofixedwidth"'); -print $form->select_dolusers($userid, 'userid', 1, '', 0, $include, '', 0, 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300'); +if (empty($user->rights->deplacement->readall) && empty($user->rights->deplacement->lire_tous)) $include = 'hierarchy'; +print $form->select_dolusers($userid, 'userid', 1, '', 0, $include, '', 0, 0, 0, '', 0, '', 'maxwidth300'); @@ -259,3 +248 @@ -if (!in_array($year, $arrayyears)) { - $arrayyears[$year] = $year; -} +if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; @@ -263 +250 @@ -print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); +print $form->selectarray('year', $arrayyears, $year, 0); @@ -265 +252 @@ -print ''; +print ''; @@ -272 +259 @@ -print ''; +print ''; @@ -280 +267,2 @@ -foreach ($data as $val) { +foreach ($data as $val) +{ @@ -282 +270,2 @@ - while ($year && $oldyear > $year + 1) { // If we have empty year + while ($year && $oldyear > $year + 1) + { // If we have empty year @@ -284 +273 @@ - print ''; + print ''; @@ -291,3 +280 @@ - - // Total - print ''; + print ''; @@ -305 +292 @@ -print '
'; +print '
'; @@ -310,4 +297,3 @@ -if ($mesg) { - print $mesg; -} else { - print $px1->show(); +if ($mesg) { print $mesg; } +else { + print $px1->show(); @@ -316,2 +302,2 @@ - print "
\n"; - print $px3->show(); + print "
\n"; + print $px3->show(); @@ -322,5 +308,5 @@ -print '
'; -print '
'; - - -print dol_get_fiche_end(); +print ''; +print '
'; + + +dol_fiche_end();