26require
'../../main.inc.php';
27require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinterstats.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
35if (!$user->hasRight(
'ficheinter',
'lire')) {
42if ($user->socid > 0) {
44 $socid = $user->socid;
52$object_status =
GETPOST(
'object_status',
'intcomma');
55$langs->loadLangs(array(
'interventions',
'companies',
'other',
'suppliers'));
65$title = $langs->trans(
"InterventionStatistics");
66$dir = $conf->ficheinter->dir_temp;
68llxHeader(
'', $title,
'',
'', 0, 0,
'',
'',
'',
'mod-fichinter page-stats_index');
74$stats =
new FichinterStats($db, $socid, $mode, ($userid > 0 ? $userid : 0));
75if ($object_status !=
'' && $object_status > -1) {
76 $stats->where .=
' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).
')';
80$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
84if (!$user->hasRight(
'societe',
'client',
'voir')) {
85 $filenamenb = $dir.
'/interventionsnbinyear-'.$user->id.
'-'.$year.
'.png';
86 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.
'-'.$year.
'.png';
88 $filenamenb = $dir.
'/interventionsnbinyear-'.$year.
'.png';
89 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$year.
'.png';
93$mesg = $px1->isGraphKo();
98 while ($i <= $endyear) {
102 $px1->SetLegend($legend);
103 $px1->SetMaxValue($px1->GetCeilMaxValue());
104 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
105 $px1->SetWidth($WIDTH);
106 $px1->SetHeight($HEIGHT);
107 $px1->SetYLabel($langs->trans(
"NbOfIntervention"));
109 $px1->SetHorizTickIncrement(1);
110 $px1->mode =
'depth';
111 $px1->SetTitle($langs->trans(
"NumberOfInterventionsByMonth"));
113 $px1->draw($filenamenb, $fileurlnb);
117$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
120if (!$user->hasRight(
'societe',
'client',
'voir')) {
121 $filenameamount = $dir.
'/interventionsamountinyear-'.$user->id.
'-'.$year.
'.png';
122 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.
'-'.$year.
'.png';
124 $filenameamount = $dir.
'/interventionsamountinyear-'.$year.
'.png';
125 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$year.
'.png';
129$mesg = $px2->isGraphKo();
131 $px2->SetData($data);
134 while ($i <= $endyear) {
138 $px2->SetLegend($legend);
139 $px2->SetMaxValue($px2->GetCeilMaxValue());
140 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
141 $px2->SetWidth($WIDTH);
142 $px2->SetHeight($HEIGHT);
143 $px2->SetYLabel($langs->trans(
"AmountOfinterventions"));
145 $px2->SetHorizTickIncrement(1);
146 $px2->mode =
'depth';
147 $px2->SetTitle($langs->trans(
"AmountOfinterventionsByMonthHT"));
149 $px2->draw($filenameamount, $fileurlamount);
153$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
155if (!$user->hasRight(
'societe',
'client',
'voir')) {
156 $filename_avg = $dir.
'/interventionsaverage-'.$user->id.
'-'.$year.
'.png';
157 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.
'-'.$year.
'.png';
159 $filename_avg = $dir.
'/interventionsaverage-'.$year.
'.png';
160 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$year.
'.png';
164$mesg = $px3->isGraphKo();
166 $px3->SetData($data);
169 while ($i <= $endyear) {
173 $px3->SetLegend($legend);
174 $px3->SetYLabel($langs->trans(
"AmountAverage"));
175 $px3->SetMaxValue($px3->GetCeilMaxValue());
176 $px3->SetMinValue($px3->GetFloorMinValue());
177 $px3->SetWidth($WIDTH);
178 $px3->SetHeight($HEIGHT);
180 $px3->SetHorizTickIncrement(1);
181 $px3->mode =
'depth';
182 $px3->SetTitle($langs->trans(
"AmountAverage"));
184 $px3->draw($filename_avg, $fileurl_avg);
190$data = $stats->getAllByYear();
191$arrayyears = array();
192foreach ($data as $val) {
193 if (!empty($val[
'year'])) {
194 $arrayyears[$val[
'year']] = $val[
'year'];
197if (!count($arrayyears)) {
198 $arrayyears[$nowyear] = $nowyear;
203$head[$h][0] = DOL_URL_ROOT.
'/fichinter/stats/index.php';
204$head[$h][1] = $langs->trans(
"ByMonthYear");
205$head[$h][2] =
'byyear';
208$type =
'fichinter_stats';
215print
'<div class="fichecenter"><div class="fichethirdleft">';
219print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
220print
'<input type="hidden" name="token" value="'.newToken().
'">';
221print
'<input type="hidden" name="mode" value="'.$mode.
'">';
223print
'<table class="noborder centpercent">';
224print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
226print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
227$filter =
'(s.client:IN:1,2,3)';
228print
img_picto(
'',
'company',
'class="pictofixedwidth"');
229print $form->select_company($socid,
'socid', $filter, 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
232print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
233print
img_picto(
'',
'user',
'class="pictofixedwidth"');
234print $form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
236print
'<tr><td class="left">'.$langs->trans(
"Status").
'</td><td class="left">';
237$tmp = $objectstatic->LibStatut(0);
238$liststatus = $objectstatic->labelStatus;
240 unset($liststatus[$objectstatic::STATUS_BILLED]);
242print $form->selectarray(
'object_status', $liststatus, $object_status, 1, 0, 0,
'', 1);
245print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
246if (!in_array($year, $arrayyears)) {
247 $arrayyears[$year] = $year;
249if (!in_array($nowyear, $arrayyears)) {
250 $arrayyears[$nowyear] = $nowyear;
253print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
255print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
260print
'<div class="div-table-responsive-no-min">';
261print
'<table class="noborder centpercent">';
262print
'<tr class="liste_titre" height="24">';
263print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
264print
'<td class="right">'.$langs->trans(
"NbOfinterventions").
'</td>';
265print
'<td class="right">%</td>';
266print
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
267print
'<td class="right">%</td>';
268print
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
269print
'<td class="right">%</td>';
273foreach ($data as $val) {
274 $year = $val[
'year'];
275 while (!empty($year) && $oldyear > (
int) $year + 1) {
279 print
'<tr class="oddeven" height="24">';
280 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'&mode='.$mode.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
282 print
'<td class="right">0</td>';
283 print
'<td class="right"></td>';
284 print
'<td class="right">0</td>';
285 print
'<td class="right"></td>';
286 print
'<td class="right">0</td>';
287 print
'<td class="right"></td>';
292 print
'<tr class="oddeven" height="24">';
293 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'&mode='.$mode.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
294 print
'<td class="right">'.$val[
'nb'].
'</td>';
295 print
'<td class="right opacitylow" style="'.((!isset($val[
'nb_diff']) || $val[
'nb_diff'] >= 0) ?
'color: green;' :
'color: red;').
'">'.(isset($val[
'nb_diff']) ? round($val[
'nb_diff']) :
"0").
'%</td>';
296 print
'<td class="right">'.price(
price2num($val[
'total'],
'MT'), 1).
'</td>';
297 print
'<td class="right opacitylow" style="'.((!isset($val[
'total_diff']) || $val[
'total_diff'] >= 0) ?
'color: green;' :
'color: red;').
'">'.(isset($val[
'total_diff']) ? round($val[
'total_diff']) :
"0").
'%</td>';
298 print
'<td class="right">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</td>';
299 print
'<td class="right opacitylow" style="'.((!isset($val[
'avg_diff']) || $val[
'avg_diff'] >= 0) ?
'color: green;' :
'color: red;').
'">'.(isset($val[
'avg_diff']) ? round($val[
'avg_diff']) :
"0").
'%</td>';
308print
'</div><div class="fichetwothirdright">';
312print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
322print
'</td></tr></table>';
326print
'<div class="clearboth"></div>';
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 intervention statistics.
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)
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)
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.
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)
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.