28require
'../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/projet/class/projectstats.class.php';
45$search_opp_status =
GETPOST(
"search_opp_status",
'alpha');
50if ($user->socid > 0) {
52 $socid = $user->socid;
60$langs->loadLangs(array(
'companies',
'projects'));
63if (!$user->hasRight(
'projet',
'lire')) {
75$includeuserlist = array();
77llxHeader(
'', $langs->trans(
'Projects'),
'',
'', 0, 0,
'',
'',
'',
'mod-project page-stats');
79$title = $langs->trans(
"ProjectsStatistics");
80$dir =
$conf->project->dir_output.
'/temp';
88if (!empty($userid) && $userid != -1) {
89 $stats_project->userid = $userid;
91if (!empty($socid) && $socid != -1) {
92 $stats_project->socid = $socid;
95 $stats_project->year = $year;
99 if ($search_opp_status) {
100 $stats_project->opp_status = $search_opp_status;
107$data = $stats_project->getNbByMonthWithPrevYear($endyear, $startyear);
110$filenamenb =
$conf->project->dir_output.
"/stats/projectnbprevyear-".$year.
".png";
111$fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=projectstats&file=projectnbprevyear-'.$year.
'.png';
114$mesg = $px1->isGraphKo();
116 $px1->SetData($data);
119 while ($i <= $endyear) {
123 $px1->SetLegend($legend);
124 $px1->SetMaxValue($px1->GetCeilMaxValue());
125 $px1->SetWidth($WIDTH);
126 $px1->SetHeight($HEIGHT);
127 $px1->SetYLabel($langs->trans(
"ProjectNbProject"));
129 $px1->SetHorizTickIncrement(1);
130 $px1->mode =
'depth';
131 $px1->SetTitle($langs->trans(
"ProjectNbProjectByMonth"));
133 $px1->draw($filenamenb, $fileurlnb);
140 $data = $stats_project->getAmountByMonthWithPrevYear($endyear, $startyear);
144 $filenamenb =
$conf->project->dir_output.
"/stats/projectamountprevyear-".$year.
".png";
145 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=projectstats&file=projectamountprevyear-'.$year.
'.png';
148 $mesg = $px2->isGraphKo();
152 while ($i <= $endyear) {
157 $px2->SetData($data);
158 $px2->SetLegend($legend);
159 $px2->SetMaxValue($px2->GetCeilMaxValue());
160 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
161 $px2->SetWidth($WIDTH);
162 $px2->SetHeight($HEIGHT);
163 $px2->SetYLabel($langs->trans(
"ProjectOppAmountOfProjectsByMonth"));
165 $px2->SetHorizTickIncrement(1);
166 $px2->SetType(array(
'bars',
'bars'));
167 $px2->mode =
'depth';
168 $px2->SetTitle($langs->trans(
"ProjectOppAmountOfProjectsByMonth"));
170 $px2->draw($filenamenb, $fileurlnb);
177 $data = $stats_project->getWeightedAmountByMonthWithPrevYear($endyear, $startyear, 0, 0);
181 $filenamenb =
$conf->project->dir_output.
"/stats/projecttransrateprevyear-".$year.
".png";
182 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=projectstats&file=projecttransrateprevyear-'.$year.
'.png';
185 $mesg = $px3->isGraphKo();
187 $px3->SetData($data);
190 while ($i <= $endyear) {
194 $px3->SetLegend($legend);
195 $px3->SetMaxValue($px3->GetCeilMaxValue());
196 $px3->SetMinValue(min(0, $px3->GetFloorMinValue()));
197 $px3->SetWidth($WIDTH);
198 $px3->SetHeight($HEIGHT);
199 $px3->SetYLabel($langs->trans(
"ProjectWeightedOppAmountOfProjectsByMonth"));
201 $px3->SetHorizTickIncrement(1);
202 $px3->mode =
'depth';
203 $px3->SetTitle($langs->trans(
"ProjectWeightedOppAmountOfProjectsByMonth"));
205 $px3->draw($filenamenb, $fileurlnb);
211$stats_project->year = 0;
212$data_all_year = $stats_project->getAllByYear();
215 $stats_project->year = $year;
217$arrayyears = array();
218foreach ($data_all_year as $val) {
219 $arrayyears[$val[
'year']] = $val[
'year'];
221if (!count($arrayyears)) {
222 $arrayyears[$nowyear] = $nowyear;
228$head[$h][0] = DOL_URL_ROOT.
'/projet/stats/index.php';
229$head[$h][1] = $langs->trans(
"ByMonthYear");
230$head[$h][2] =
'byyear';
238print
'<div class="fichecenter"><div class="fichethirdleft">';
240print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
241print
'<input type="hidden" name="token" value="'.newToken().
'">';
243print
'<table class="noborder centpercent">';
244print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
246print
'<tr><td>'.$langs->trans(
"ThirdParty").
'</td><td>';
247print
img_picto(
'',
'company',
'class="pictofixedwidth"');
248print $form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
252 print
'<tr><td>'.$langs->trans(
"OpportunityStatusShort").
'</td><td>';
253 print $formproject->selectOpportunityStatus(
'search_opp_status', $search_opp_status, 1, 0, 1, 0,
'maxwidth300', 1, 1);
262print
'<tr><td>'.$langs->trans(
"Year").
' <span class="opacitymedium">('.$langs->trans(
"DateCreation").
')</span></td><td>';
263if (!in_array($year, $arrayyears)) {
264 $arrayyears[$year] = $year;
266if (!in_array($nowyear, $arrayyears)) {
267 $arrayyears[$nowyear] = $nowyear;
270print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
272print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
279print
'<div class="div-table-responsive-no-min">';
280print
'<table class="noborder centpercent">';
281print
'<tr class="liste_titre" height="24">';
282print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
283print
'<td class="right">'.$langs->trans(
"NbOfProjects").
'</td>';
285 print
'<td class="right">'.$langs->trans(
"OpportunityAmountShort").
'</td>';
286 print
'<td class="right">'.$langs->trans(
"OpportunityAmountAverageShort").
'</td>';
287 print
'<td class="right">'.$langs->trans(
"OpportunityAmountWeigthedShort").
'</td>';
292foreach ($data_all_year as $val) {
293 $year = $val[
'year'];
294 while ($year && $oldyear > (
int) $year + 1) {
297 print
'<tr class="oddeven" height="24">';
298 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
299 print
'<td class="right">0</td>';
301 print
'<td class="right amount nowraponall">0</td>';
302 print
'<td class="right amount nowraponall">0</td>';
303 print
'<td class="right amount nowraponall">0</td>';
308 print
'<tr class="oddeven" height="24">';
309 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
310 print
'<td class="right">'.$val[
'nb'].
'</td>';
312 print
'<td class="right amount nowraponall">'.($val[
'total'] ?
price(
price2num($val[
'total'],
'MT'), 1) :
'0').
'</td>';
313 print
'<td class="right amount nowraponall">'.($val[
'avg'] ?
price(
price2num($val[
'avg'],
'MT'), 1) :
'0').
'</td>';
314 print
'<td class="right amount nowraponall">'.(isset($val[
'weighted']) ?
price(
price2num($val[
'weighted'],
'MT'), 1) :
'0').
'</td>';
323print
'</div><div class="fichetwothirdright">';
325$stringtoshow =
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
329 $stringtoshow .= $px1->show();
330 $stringtoshow .=
"<br>\n";
331 if (
getDolGlobalString(
'PROJECT_USE_OPPORTUNITIES') && $px2 !==
null && $px3 !==
null) {
334 $stringtoshow .= $px2->show();
335 $stringtoshow .=
"<br>\n";
336 $stringtoshow .= $px3->show();
339$stringtoshow .=
'</td></tr></table>';
345print
'<div class="clearboth"></div>';
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Class to manage statistics on projects.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.