28require
'../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formprojet.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
39require_once DOL_DOCUMENT_ROOT.
'/projet/class/projectstats.class.php';
44$mode =
GETPOST(
'mode',
'alpha');
46$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'projectlist';
48$search_project_user =
GETPOSTINT(
'search_project_user');
49$search_opp_status =
GETPOST(
"search_opp_status",
'alpha');
50$search_usage_event_organization =
GETPOST(
'search_usage_event_organization',
'intcomma');
51$search_usage_opportunity =
GETPOST(
'search_usage_opportunity',
'intcomma');
56if ($user->socid > 0) {
58 $socid = $user->socid;
66$langs->loadLangs(array(
'companies',
'projects'));
69if (!$user->hasRight(
'projet',
'lire')) {
81$includeuserlist = array();
83$help_url =
"EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos";
84$title = $langs->trans(
"LeadsOrProjects");
86 $title = $langs->trans(
"Projects");
89 $title = $langs->trans(
"Leads");
92llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-project page-stats');
94$dir =
$conf->project->dir_output.
'/temp';
99$massactionbutton =
'';
101$nbtotalofrecords = $langs->trans(
"Statistics");
105$url = DOL_URL_ROOT.
'/projet/card.php?action=create';
107 $url .=
'&socid='.$socid;
109if ($search_usage_event_organization == 1) {
110 $url .=
'&usage_organize_event=1';
111 if (((
int) $search_usage_opportunity) < 1) {
112 $url .=
'&usage_opportunity=0';
117$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewList'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/projet/list.php?mode=common'.preg_replace(
'/(&|\?)*(mode|groupby)=[^&]+/',
'', $param),
'', ($mode ==
'common' ? 2 : 1), array(
'morecss' =>
'reposition'));
118$newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewKanban'),
'',
'fa fa-th-list imgforviewmode', DOL_URL_ROOT.
'/projet/list.php?mode=kanban'.preg_replace(
'/(&|\?)*(mode|groupby)=[^&]+/',
'', $param),
'', ($mode ==
'kanban' ? 2 : 1), array(
'morecss' =>
'reposition'));
119if ($contextpage ==
'lead') {
120 $newcardbutton .= dolGetButtonTitle($langs->trans(
'ViewKanbanGroupBy'),
'',
'fa fa-grip-vertical imgforviewmode', DOL_URL_ROOT.
'/projet/list.php?mode=kanbangroupby&groupby=p.fk_opp_status'.preg_replace(
'/(&|\?)*(mode|groupby)=[^&]+/',
'', $param),
'', ($mode ==
'kanbangroupby' ? 2 : 1), array(
'morecss' =>
'reposition'));
122$newcardbutton .= dolGetButtonTitle($langs->trans(
'Statistics'),
'',
'fa fa-chart-bar imgforviewmode', DOL_URL_ROOT.
'/projet/stats/index.php?mode=statistics'.preg_replace(
'/(&|\?)*(mode|groupby)=[^&]+/',
'', $param),
'', 2, array(
'morecss' =>
'reposition'));
123$newcardbutton .= dolGetButtonTitleSeparator();
124$newcardbutton .= dolGetButtonTitle($langs->trans(
'NewProject'),
'',
'fa fa-plus-circle', $url,
'', $user->hasRight(
'projet',
'creer'));
128if ($search_project_user == $user->id) {
129 $htmltooltip .= $langs->trans(
"MyProjectsDesc");
131 if ($user->hasRight(
'projet',
'all',
'lire') && !$socid) {
132 $htmltooltip .= $langs->trans(
"ProjectsDesc");
134 $htmltooltip .= $langs->trans(
"ProjectsPublicDesc");
138print_barre_liste($form->textwithpicto($title, $htmltooltip), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords,
'project', 0, $newcardbutton,
'', $limit, 0, 0, 1);
145if (!empty($userid) && $userid != -1) {
146 $stats_project->userid = $userid;
148if (!empty($socid) && $socid != -1) {
149 $stats_project->socid = $socid;
152 $stats_project->year = $year;
156 if ($search_opp_status) {
157 $stats_project->opp_status = $search_opp_status;
164$data = $stats_project->getNbByMonthWithPrevYear($endyear, $startyear);
167$filenamenb =
$conf->project->dir_output.
"/stats/projectnbprevyear-".$year.
".png";
168$fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=projectstats&file=projectnbprevyear-'.$year.
'.png';
171$mesg = $px1->isGraphKo();
173 $px1->SetData($data);
176 while ($i <= $endyear) {
180 $px1->SetLegend($legend);
181 $px1->SetMaxValue($px1->GetCeilMaxValue());
182 $px1->SetWidth($WIDTH);
183 $px1->SetHeight($HEIGHT);
184 $px1->SetYLabel($langs->trans(
"ProjectNbProject"));
186 $px1->SetHorizTickIncrement(1);
187 $px1->mode =
'depth';
188 $px1->SetTitle($langs->trans(
"ProjectNbProjectByMonth"));
190 $px1->draw($filenamenb, $fileurlnb);
197 $data = $stats_project->getAmountByMonthWithPrevYear($endyear, $startyear);
201 $filenamenb =
$conf->project->dir_output.
"/stats/projectamountprevyear-".$year.
".png";
202 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=projectstats&file=projectamountprevyear-'.$year.
'.png';
205 $mesg = $px2->isGraphKo();
209 while ($i <= $endyear) {
214 $px2->SetData($data);
215 $px2->SetLegend($legend);
216 $px2->SetMaxValue($px2->GetCeilMaxValue());
217 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
218 $px2->SetWidth($WIDTH);
219 $px2->SetHeight($HEIGHT);
220 $px2->SetYLabel($langs->trans(
"ProjectOppAmountOfProjectsByMonth"));
222 $px2->SetHorizTickIncrement(1);
223 $px2->SetType(array(
'bars',
'bars'));
224 $px2->mode =
'depth';
225 $px2->SetTitle($langs->trans(
"ProjectOppAmountOfProjectsByMonth"));
227 $px2->draw($filenamenb, $fileurlnb);
234 $data = $stats_project->getWeightedAmountByMonthWithPrevYear($endyear, $startyear, 0, 0);
238 $filenamenb =
$conf->project->dir_output.
"/stats/projecttransrateprevyear-".$year.
".png";
239 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=projectstats&file=projecttransrateprevyear-'.$year.
'.png';
242 $mesg = $px3->isGraphKo();
244 $px3->SetData($data);
247 while ($i <= $endyear) {
251 $px3->SetLegend($legend);
252 $px3->SetMaxValue($px3->GetCeilMaxValue());
253 $px3->SetMinValue(min(0, $px3->GetFloorMinValue()));
254 $px3->SetWidth($WIDTH);
255 $px3->SetHeight($HEIGHT);
256 $px3->SetYLabel($langs->trans(
"ProjectWeightedOppAmountOfProjectsByMonth"));
258 $px3->SetHorizTickIncrement(1);
259 $px3->mode =
'depth';
260 $px3->SetTitle($langs->trans(
"ProjectWeightedOppAmountOfProjectsByMonth"));
262 $px3->draw($filenamenb, $fileurlnb);
268$stats_project->year = 0;
269$data_all_year = $stats_project->getAllByYear();
272 $stats_project->year = $year;
274$arrayyears = array();
275foreach ($data_all_year as $val) {
276 $arrayyears[$val[
'year']] = $val[
'year'];
278if (!count($arrayyears)) {
279 $arrayyears[$nowyear] = $nowyear;
285$head[$h][0] = DOL_URL_ROOT.
'/projet/stats/index.php';
286$head[$h][1] = $langs->trans(
"ByMonthYear");
287$head[$h][2] =
'byyear';
295print
'<div class="fichecenter"><div class="fichethirdleft">';
297print
'<form name="stats" method="POST" action="'.dolBuildUrl($_SERVER[
"PHP_SELF"]).
'">';
298print
'<input type="hidden" name="token" value="'.newToken().
'">';
300print
'<table class="noborder centpercent">';
301print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
303print
'<tr><td>'.$langs->trans(
"ThirdParty").
'</td><td>';
304print
img_picto(
'',
'company',
'class="pictofixedwidth"');
305print $form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
309 print
'<tr><td>'.$langs->trans(
"OpportunityStatusShort").
'</td><td>';
310 print $formproject->selectOpportunityStatus(
'search_opp_status', $search_opp_status, 1, 0, 1, 0,
'maxwidth300', 1, 1);
319print
'<tr><td>'.$langs->trans(
"Year").
' <span class="opacitymedium">('.$langs->trans(
"DateCreation").
')</span></td><td>';
320if (!in_array($year, $arrayyears)) {
321 $arrayyears[$year] = $year;
323if (!in_array($nowyear, $arrayyears)) {
324 $arrayyears[$nowyear] = $nowyear;
327print
img_picto(
'',
'calendar',
'class="pictofixedwidth"');
328print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
330print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
337print
'<div class="div-table-responsive-no-min">';
338print
'<table class="noborder centpercent">';
339print
'<tr class="liste_titre" height="24">';
340print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
341print
'<td class="right">'.$langs->trans(
"NbOfProjects").
'</td>';
343 print
'<td class="right">'.$langs->trans(
"OpportunityAmountShort").
'</td>';
344 print
'<td class="right">'.$langs->trans(
"OpportunityAmountAverageShort").
'</td>';
345 print
'<td class="right">'.$langs->trans(
"OpportunityAmountWeigthedShort").
'</td>';
350foreach ($data_all_year as $val) {
351 $year = $val[
'year'];
352 while ($year && $oldyear > (
int) $year + 1) {
355 print
'<tr class="oddeven" height="24">';
356 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
357 print
'<td class="right">0</td>';
359 print
'<td class="right amount nowraponall">0</td>';
360 print
'<td class="right amount nowraponall">0</td>';
361 print
'<td class="right amount nowraponall">0</td>';
366 print
'<tr class="oddeven" height="24">';
367 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
368 print
'<td class="right">'.$val[
'nb'].
'</td>';
370 print
'<td class="right amount nowraponall">'.($val[
'total'] ?
price(
price2num($val[
'total'],
'MT'), 1) :
'0').
'</td>';
371 print
'<td class="right amount nowraponall">'.($val[
'avg'] ?
price(
price2num($val[
'avg'],
'MT'), 1) :
'0').
'</td>';
372 print
'<td class="right amount nowraponall">'.(isset($val[
'weighted']) ?
price(
price2num($val[
'weighted'],
'MT'), 1) :
'0').
'</td>';
381print
'</div><div class="fichetwothirdright">';
383$stringtoshow =
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
387 $stringtoshow .= $px1->show();
388 $stringtoshow .=
"<br>\n";
389 if (
getDolGlobalString(
'PROJECT_USE_OPPORTUNITIES') && $px2 !==
null && $px3 !==
null) {
392 $stringtoshow .= $px2->show();
393 $stringtoshow .=
"<br>\n";
394 $stringtoshow .= $px3->show();
397$stringtoshow .=
'</td></tr></table>';
403print
'<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.
dol_now($mode='gmt')
Return date for now.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.