--- /tmp/dsg/dolibarr/htdocs/comm/propal/stats/github_index.php +++ /tmp/dsg/dolibarr/htdocs/comm/propal/stats/client_index.php @@ -37,11 +37,11 @@ $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); -$mode = GETPOSTISSET("mode") ? GETPOST("mode", 'aZ09') : 'customer'; +$mode = GETPOST("mode") ?GETPOST("mode") : 'customer'; if ($mode == 'customer' && !$user->rights->propale->lire) accessforbidden(); if ($mode == 'supplier' && !$user->rights->supplier_proposal->lire) accessforbidden(); -$object_status = GETPOST('object_status', 'intcomma'); +$object_status = GETPOST('object_status'); $typent_id = GETPOST('typent_id', 'int'); $categ_id = GETPOST('categ_id', 'categ_id'); @@ -50,12 +50,12 @@ // Security check if ($user->socid > 0) { - $action = ''; - $socid = $user->socid; + $action = ''; + $socid = $user->socid; } $nowyear = strftime("%Y", dol_now()); -$year = GETPOST('year') > 0 ? GETPOST('year', 'int') : $nowyear; +$year = GETPOST('year') > 0 ?GETPOST('year') : $nowyear; //$startyear=$year-2; $startyear = $year - 1; $endyear = $year; @@ -77,19 +77,19 @@ if ($mode == 'customer') { - $picto = 'propal'; - $title = $langs->trans("ProposalsStatistics"); - $dir = $conf->propale->dir_temp; - $cat_type = Categorie::TYPE_CUSTOMER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); + $picto = 'propal'; + $title = $langs->trans("ProposalsStatistics"); + $dir = $conf->propale->dir_temp; + $cat_type = Categorie::TYPE_CUSTOMER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Customer")); } if ($mode == 'supplier') { $picto = 'supplier_proposal'; - $title = $langs->trans("ProposalsStatisticsSuppliers"); - $dir = $conf->supplier_proposal->dir_temp; - $cat_type = Categorie::TYPE_SUPPLIER; - $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); + $title = $langs->trans("ProposalsStatisticsSuppliers").' ('.$langs->trans("SentToSuppliers").")"; + $dir = $conf->supplier_proposal->dir_temp; + $cat_type = Categorie::TYPE_SUPPLIER; + $cat_label = $langs->trans("Category").' '.lcfirst($langs->trans("Supplier")); } llxHeader('', $title); @@ -101,7 +101,7 @@ $stats = new PropaleStats($db, $socid, ($userid > 0 ? $userid : 0), $mode, ($typent_id > 0 ? $typent_id : 0), ($categ_id > 0 ? $categ_id : 0)); -if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND p.fk_statut IN ('.$db->sanitize($db->escape($object_status)).')'; +if ($object_status != '' && $object_status >= 0) $stats->where .= ' AND p.fk_statut IN ('.$db->escape($object_status).')'; // Build graphic number of object $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear); @@ -110,36 +110,38 @@ if (!$user->rights->societe->client->voir || $user->socid) { - $filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png'; - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png'; -} else { - $filenamenb = $dir.'/proposalsnbinyear-'.$year.'.png'; - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png'; + $filenamenb = $dir.'/proposalsnbinyear-'.$user->id.'-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$user->id.'-'.$year.'.png'; +} +else +{ + $filenamenb = $dir.'/proposalsnbinyear-'.$year.'.png'; + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsnbinyear-'.$year.'.png'; } $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); 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("NbOfProposals")); - $px1->SetShading(3); - $px1->SetHorizTickIncrement(1); - $px1->mode = 'depth'; - $px1->SetTitle($langs->trans("NumberOfProposalsByMonth")); - - $px1->draw($filenamenb, $fileurlnb); + $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("NbOfProposals")); + $px1->SetShading(3); + $px1->SetHorizTickIncrement(1); + $px1->mode = 'depth'; + $px1->SetTitle($langs->trans("NumberOfProposalsByMonth")); + + $px1->draw($filenamenb, $fileurlnb); } // Build graphic amount of object @@ -148,36 +150,38 @@ if (!$user->rights->societe->client->voir || $user->socid) { - $filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png'; - $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png'; -} else { - $filenameamount = $dir.'/proposalsamountinyear-'.$year.'.png'; - $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png'; + $filenameamount = $dir.'/proposalsamountinyear-'.$user->id.'-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$user->id.'-'.$year.'.png'; +} +else +{ + $filenameamount = $dir.'/proposalsamountinyear-'.$year.'.png'; + $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=propalstats&file=proposalsamountinyear-'.$year.'.png'; } $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); 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("AmountOfProposals")); - $px2->SetShading(3); - $px2->SetHorizTickIncrement(1); - $px2->mode = 'depth'; - $px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT")); - - $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("AmountOfProposals")); + $px2->SetShading(3); + $px2->SetHorizTickIncrement(1); + $px2->mode = 'depth'; + $px2->SetTitle($langs->trans("AmountOfProposalsByMonthHT")); + + $px2->draw($filenameamount, $fileurlamount); } $data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear); @@ -185,38 +189,40 @@ $fileurl_avg = ''; 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'; + $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'; } $px3 = new DolGraph(); $mesg = $px3->isGraphKo(); 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); + $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); } @@ -240,7 +246,7 @@ complete_head_from_modules($conf, $langs, null, $head, $h, 'propal_stats'); -print dol_get_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); +dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1); print '
'; @@ -260,23 +266,23 @@ $filter = 's.client IN (1,2,3)'; print $form->select_company($socid, 'socid', $filter, 1, 0, 0, array(), 0, '', 'style="width: 95%"'); print ''; - // ThirdParty Type - print ''.$langs->trans("ThirdPartyType").''; - $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. - print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent); - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); - print ''; - // Category - print ''.$cat_label.''; - print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); - print ''; + // ThirdParty Type + print ''.$langs->trans("ThirdPartyType").''; + $sortparam_typent = (empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? 'ASC' : $conf->global->SOCIETE_SORT_ON_TYPEENT); // NONE means we keep sort of original array, so we sort on position. ASC, means next function will sort on label. + print $form->selectarray("typent_id", $formcompany->typent_array(0), $typent_id, 0, 0, 0, '', 0, 0, 0, $sortparam_typent); + if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); + print ''; + // Category + print ''.$cat_label.''; + print $formother->select_categories($cat_type, $categ_id, 'categ_id', true); + print ''; // User print ''.$langs->trans("CreatedBy").''; print $form->select_dolusers($userid, 'userid', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300'); print ''; // Status print ''.$langs->trans("Status").''; - $formpropal->selectProposalStatus(($object_status != '' ? $object_status : -1), 0, 0, 1, $mode, 'object_status'); + $formpropal->selectProposalStatus(($object_status != '' ? $object_status : -1), 0, 0, 1, $mode, 'object_status'); print ''; // Year print ''.$langs->trans("Year").''; @@ -306,31 +312,31 @@ $oldyear = 0; foreach ($data as $val) { - $year = $val['year']; - while (!empty($year) && $oldyear > $year + 1) - { // If we have empty year - $oldyear--; - - print ''; - print ' 0 ? '&userid='.$userid : '').'">'.$oldyear.''; - print '0'; - print ''; - print '0'; - print ''; - print '0'; - print ''; - print ''; - } - print ''; - print ' 0 ? '&userid='.$userid : '').'">'.$year.''; - print ''.$val['nb'].''; + $year = $val['year']; + while (!empty($year) && $oldyear > $year + 1) + { // If we have empty year + $oldyear--; + + print ''; + print ' 0 ? '&userid='.$userid : '').'">'.$oldyear.''; + print '0'; + print ''; + print '0'; + print ''; + print '0'; + print ''; + print ''; + } + print ''; + print ' 0 ? '&userid='.$userid : '').'">'.$year.''; + print ''.$val['nb'].''; print ''.round($val['nb_diff']).''; - print ''.price(price2num($val['total'], 'MT'), 1).''; + print ''.price(price2num($val['total'], 'MT'), 1).''; print ''.round($val['total_diff']).''; - print ''.price(price2num($val['avg'], 'MT'), 1).''; + print ''.price(price2num($val['avg'], 'MT'), 1).''; print ''.round($val['avg_diff']).''; - print ''; - $oldyear = $year; + print ''; + $oldyear = $year; } print ''; @@ -341,12 +347,13 @@ // Show graphs print '
'; -if ($mesg) { print $mesg; } else { - print $px1->show(); - print "
\n"; - print $px2->show(); - print "
\n"; - print $px3->show(); +if ($mesg) { print $mesg; } +else { + print $px1->show(); + print "
\n"; + print $px2->show(); + print "
\n"; + print $px3->show(); } print '
'; @@ -355,7 +362,7 @@ print '
'; -print dol_get_fiche_end(); +dol_fiche_end(); // End of page llxFooter();