--- /tmp/dsg/dolibarr/htdocs/projet/stats/github_19.0.3_index.php +++ /tmp/dsg/dolibarr/htdocs/projet/stats/client_index.php @@ -3 +3 @@ - * Copyright (C) 2015-2021 Laurent Destailleur + * Copyright (C) 2015 Laurent Destailleur @@ -25 +24,0 @@ -// Load Dolibarr environment @@ -28 +26,0 @@ -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php'; @@ -31,0 +30,5 @@ +// Security check +if (!$user->rights->projet->lire) + accessforbidden(); + + @@ -34,2 +36,0 @@ - -$search_opp_status = GETPOST("search_opp_status", 'alpha'); @@ -40 +41,2 @@ -if ($user->socid > 0) { +if ($user->socid > 0) +{ @@ -44,3 +46,4 @@ -$nowyear = dol_print_date(dol_now('gmt'), "%Y", 'gmt'); -$year = GETPOST('year', 'int') > 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; @@ -51,5 +53,0 @@ - -// Security check -if (!$user->hasRight('projet', 'lire')) { - accessforbidden(); -} @@ -63 +60,0 @@ -$formproject = new FormProjets($db); @@ -71 +68 @@ -$dir = $conf->project->dir_output.'/temp'; +$dir = $conf->projet->dir_output.'/temp'; @@ -79,15 +76,64 @@ -if (!empty($userid) && $userid != -1) { - $stats_project->userid = $userid; -} -if (!empty($socid) && $socid != -1) { - $stats_project->socid = $socid; -} -if (!empty($year)) { - $stats_project->year = $year; -} - -if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { - if ($search_opp_status) { - $stats_project->opp_status = $search_opp_status; - } -} +if (!empty($userid) && $userid != -1) $stats_project->userid = $userid; +if (!empty($socid) && $socid != -1) $stats_project->socid = $socid; +if (!empty($year)) $stats_project->year = $year; + +/* +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) +{ + // Current stats of project amount per status + $data1 = $stats_project->getAllProjectByStatus(); + + if (!is_array($data1) && $data1 < 0) { + setEventMessages($stats_project->error, null, 'errors'); + } + if (empty($data1)) + { + $showpointvalue = 0; + $nocolor = 1; + $data1 = array(array(0=>$langs->trans("None"), 1=>1)); + } + + $filenamenb = $conf->project->dir_output."/stats/projectbystatus.png"; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=projectstats&file=projectbystatus.png'; + $px = new DolGraph(); + $mesg = $px->isGraphKo(); + if (empty($mesg)) { + $i = 0; $tot = count($data1); $legend = array(); + while ($i <= $tot) + { + $legend[] = $data1[$i][0]; + $i++; + } + + $px->SetData($data1); + unset($data1); + + if ($nocolor) + $px->SetDataColor(array( + array( + 220, + 220, + 220 + ) + )); + + $px->SetLegend($legend); + $px->setShowLegend(0); + $px->setShowPointValue($showpointvalue); + $px->setShowPercent(1); + $px->SetMaxValue($px->GetCeilMaxValue()); + $px->SetWidth($WIDTH); + $px->SetHeight($HEIGHT); + $px->SetShading(3); + $px->SetHorizTickIncrement(1); + $px->SetCssPrefix("cssboxes"); + $px->SetType(array('pie')); + $px->SetTitle($langs->trans('OpportunitiesStatusForProjects')); + $result = $px->draw($filenamenb, $fileurlnb); + if ($result < 0) { + setEventMessages($px->error, null, 'errors'); + } + } else { + setEventMessages(null, $mesg, 'errors'); + } +}*/ @@ -106 +152,2 @@ -if (!$mesg) { +if (!$mesg) +{ @@ -108,3 +155,3 @@ - $i = $startyear; - $legend = array(); - while ($i <= $endyear) { + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { @@ -128 +175,2 @@ -if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) +{ @@ -139,4 +187,5 @@ - if (!$mesg) { - $i = $startyear; - $legend = array(); - while ($i <= $endyear) { + if (!$mesg) + { + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { @@ -164 +213,2 @@ -if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) +{ @@ -175 +225,2 @@ - if (!$mesg) { + if (!$mesg) + { @@ -177,3 +228,3 @@ - $i = $startyear; - $legend = array(); - while ($i <= $endyear) { + $i = $startyear; $legend = array(); + while ($i <= $endyear) + { @@ -203,3 +254 @@ -if (!empty($year)) { - $stats_project->year = $year; -} +if (!empty($year)) $stats_project->year = $year; @@ -210,3 +259 @@ -if (!count($arrayyears)) { - $arrayyears[$nowyear] = $nowyear; -} +if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -222,3 +269,3 @@ -complete_head_from_modules($conf, $langs, null, $head, $h, 'project_stats'); - -print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1, ''); +complete_head_from_modules($conf, $langs, null, $head, $h, $type); + +dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1, ''); @@ -236,2 +283 @@ -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%"'); @@ -239,7 +284,0 @@ -// Opportunity status -if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { - print ''.$langs->trans("OpportunityStatusShort").''; - print $formproject->selectOpportunityStatus('search_opp_status', $search_opp_status, 1, 0, 1, 0, 'maxwidth300', 1, 1); - print ''; -} - @@ -251,7 +290,3 @@ -print ''.$langs->trans("Year").' ('.$langs->trans("DateCreation").')'; -if (!in_array($year, $arrayyears)) { - $arrayyears[$year] = $year; -} -if (!in_array($nowyear, $arrayyears)) { - $arrayyears[$nowyear] = $nowyear; -} +print ''.$langs->trans("Year").''; +if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year; +if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear; @@ -259 +294 @@ -print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75'); +print $form->selectarray('year', $arrayyears, $year, 0); @@ -261 +296 @@ -print ''; +print ''; @@ -263 +297,0 @@ - @@ -265 +298,0 @@ - @@ -273 +306,2 @@ -if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { +if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) +{ @@ -281 +315,2 @@ -foreach ($data_all_year as $val) { +foreach ($data_all_year as $val) +{ @@ -283 +318,2 @@ - while ($year && $oldyear > $year + 1) { // If we have empty year + while ($year && $oldyear > $year + 1) + { // If we have empty year @@ -287,0 +324,6 @@ + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print '0'; + print '0'; + print '0'; + } @@ -289,5 +330,0 @@ - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { - print '0'; - print '0'; - print '0'; - } @@ -300,4 +337,5 @@ - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { - print ''.($val['total'] ? price(price2num($val['total'], 'MT'), 1) : '0').''; - print ''.($val['avg'] ? price(price2num($val['avg'], 'MT'), 1) : '0').''; - print ''.(isset($val['weighted']) ? price(price2num($val['weighted'], 'MT'), 1) : '0').''; + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { + print ''.($val['total'] ?price(price2num($val['total'], 'MT'), 1) : '0').''; + print ''.($val['avg'] ?price(price2num($val['avg'], 'MT'), 1) : '0').''; + print ''.($val['weighted'] ?price(price2num($val['weighted'], 'MT'), 1) : '0').''; @@ -312,6 +350,5 @@ -print '
'; - -$stringtoshow = '
'; -if ($mesg) { - print $mesg; -} else { +print '
'; + +$stringtoshow .= '
'; +if ($mesg) { print $mesg; } +else { @@ -320 +357,2 @@ - if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES')) { + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) + { @@ -332,5 +370,3 @@ -print ''; - -print '
'; - -print dol_get_fiche_end(); + +print ''; +print '
';