--- /tmp/dsg/dolibarr/htdocs/expensereport/stats/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/expensereport/stats/client_index.php @@ -27 +26,0 @@ -// Load Dolibarr environment @@ -38,2 +37,2 @@ -$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; -$object_status = GETPOST('object_status', 'intcomma'); +$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; +$object_status = GETPOST('object_status'); @@ -42,3 +41 @@ -$socid = GETPOST('socid', 'int'); if ($socid < 0) { - $socid = 0; -} +$socid = GETPOST('socid', 'int'); if ($socid < 0) $socid = 0; @@ -48 +45,2 @@ -if ($user->socid > 0) { +if ($user->socid > 0) +{ @@ -52,3 +50 @@ -if ($user->socid) { - $socid = $user->socid; -} +if ($user->socid) $socid = $user->socid; @@ -57,3 +53,4 @@ -$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, 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; @@ -81,3 +78 @@ -if ($object_status != '' && $object_status >= -1) { - $stats->where .= ' AND e.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; -} +if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND e.fk_statut IN ('.$db->escape($object_status).')'; @@ -96 +91,2 @@ -if (!$mesg) { +if (!$mesg) +{ @@ -98,3 +94,3 @@ - $i = $startyear; - $legend = array(); - while ($i <= $endyear) { + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { @@ -127 +123,2 @@ -if (!$mesg) { +if (!$mesg) +{ @@ -129,3 +126,3 @@ - $i = $startyear; - $legend = array(); - while ($i <= $endyear) { + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { @@ -152,16 +149,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'; @@ -172,20 +164,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); @@ -199,5 +192,3 @@ - $arrayyears[$val['year']] = $val['year']; -} -if (!count($arrayyears)) { - $arrayyears[$nowyear] = $nowyear; -} + $arrayyears[$val['year']] = $val['year']; +} +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -215 +206 @@ -print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); +dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); @@ -231 +222 @@ -print $form->select_company($socid,'socid','',1,1,0,array(),0,'widthcentpercentminusx maxwidth300',''); +print $form->select_company($socid,'socid','',1,1,0,array(),0,'','style="width: 95%"'); @@ -237,5 +228,2 @@ -if (!$user->hasRight('expensereport', 'readall') && !$user->hasRight('expensereport', '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->expensereport->readall) && empty($user->rights->expensereport->lire_tous)) $include = 'hierarchy'; +print $form->select_dolusers($userid, 'userid', 1, '', 0, $include, '', 0, 0, 0, '', 0, '', 'maxwidth300'); @@ -245,2 +233,2 @@ -$liststatus = $tmpexpensereport->labelStatus; -print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'intcomma'), -4, 0, 0, '', 1); +$liststatus = $tmpexpensereport->statuts; +print $form->selectarray('object_status', $liststatus, GETPOST('object_status', 'int'), -4, 0, 0, '', 1); @@ -252,3 +240 @@ -if (!in_array($year, $arrayyears)) { - $arrayyears[$year] = $year; -} +if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; @@ -256 +242 @@ -print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); +print $form->selectarray('year', $arrayyears, $year, 0); @@ -258 +244 @@ -print ''; +print ''; @@ -273 +259,2 @@ -foreach ($data as $val) { +foreach ($data as $val) +{ @@ -275 +262,2 @@ - while ($year && $oldyear > $year + 1) { // If we have empty year + while ($year && $oldyear > $year + 1) + { // If we have empty year @@ -281,2 +269,2 @@ - print '0'; - print '0'; + print '0'; + print '0'; @@ -290,2 +278,2 @@ - print ''.price(price2num($val['total'], 'MT'), 1).''; - print ''.price(price2num($val['avg'], 'MT'), 1).''; + print ''.price(price2num($val['total'], 'MT'), 1).''; + print ''.price(price2num($val['avg'], 'MT'), 1).''; @@ -299 +287 @@ -print '
'; +print '
'; @@ -304,4 +292,3 @@ -if ($mesg) { - print $mesg; -} else { - print $px1->show(); +if ($mesg) { print $mesg; } +else { + print $px1->show(); @@ -310,2 +297,2 @@ - print "
\n"; - print $px3->show(); + print "
\n"; + print $px3->show(); @@ -316,5 +303,5 @@ -print '
'; -print '
'; - - -print dol_get_fiche_end(); +print ''; +print '
'; + + +dol_fiche_end();