27require
'../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinter.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/fichinter/class/fichinterstats.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
44if (!$user->hasRight(
'ficheinter',
'lire')) {
51if ($user->socid > 0) {
53 $socid = $user->socid;
61$object_status =
GETPOST(
'object_status',
'intcomma');
64$langs->loadLangs(array(
'interventions',
'companies',
'other',
'suppliers'));
74$title = $langs->trans(
"InterventionStatistics");
75$dir =
$conf->ficheinter->dir_temp;
77llxHeader(
'', $title,
'',
'', 0, 0,
'',
'',
'',
'mod-fichinter page-stats_index');
83$stats =
new FichinterStats($db, $socid, $mode, ($userid > 0 ? $userid : 0));
84if ($object_status !=
'' && $object_status > -1) {
85 $stats->where .=
' AND c.fk_statut IN ('.$db->sanitize($db->escape($object_status)).
')';
89$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
93if (!$user->hasRight(
'societe',
'client',
'voir')) {
94 $filenamenb = $dir.
'/interventionsnbinyear-'.$user->id.
'-'.$year.
'.png';
95 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$user->id.
'-'.$year.
'.png';
97 $filenamenb = $dir.
'/interventionsnbinyear-'.$year.
'.png';
98 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsnbinyear-'.$year.
'.png';
102$mesg = $px1->isGraphKo();
104 $px1->SetData($data);
107 while ($i <= $endyear) {
111 $px1->SetLegend($legend);
112 $px1->SetMaxValue($px1->GetCeilMaxValue());
113 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
114 $px1->SetWidth($WIDTH);
115 $px1->SetHeight($HEIGHT);
116 $px1->SetYLabel($langs->trans(
"NbOfIntervention"));
118 $px1->SetHorizTickIncrement(1);
119 $px1->mode =
'depth';
120 $px1->SetTitle($langs->trans(
"NumberOfInterventionsByMonth"));
122 $px1->draw($filenamenb, $fileurlnb);
126$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
129if (!$user->hasRight(
'societe',
'client',
'voir')) {
130 $filenameamount = $dir.
'/interventionsamountinyear-'.$user->id.
'-'.$year.
'.png';
131 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$user->id.
'-'.$year.
'.png';
133 $filenameamount = $dir.
'/interventionsamountinyear-'.$year.
'.png';
134 $fileurlamount = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsamountinyear-'.$year.
'.png';
138$mesg = $px2->isGraphKo();
140 $px2->SetData($data);
143 while ($i <= $endyear) {
147 $px2->SetLegend($legend);
148 $px2->SetMaxValue($px2->GetCeilMaxValue());
149 $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
150 $px2->SetWidth($WIDTH);
151 $px2->SetHeight($HEIGHT);
152 $px2->SetYLabel($langs->trans(
"AmountOfinterventions"));
154 $px2->SetHorizTickIncrement(1);
155 $px2->mode =
'depth';
156 $px2->SetTitle($langs->trans(
"AmountOfinterventionsByMonthHT"));
158 $px2->draw($filenameamount, $fileurlamount);
162$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
164if (!$user->hasRight(
'societe',
'client',
'voir')) {
165 $filename_avg = $dir.
'/interventionsaverage-'.$user->id.
'-'.$year.
'.png';
166 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$user->id.
'-'.$year.
'.png';
168 $filename_avg = $dir.
'/interventionsaverage-'.$year.
'.png';
169 $fileurl_avg = DOL_URL_ROOT.
'/viewimage.php?modulepart=interventionstats&file=interventionsaverage-'.$year.
'.png';
173$mesg = $px3->isGraphKo();
175 $px3->SetData($data);
178 while ($i <= $endyear) {
182 $px3->SetLegend($legend);
183 $px3->SetYLabel($langs->trans(
"AmountAverage"));
184 $px3->SetMaxValue($px3->GetCeilMaxValue());
185 $px3->SetMinValue($px3->GetFloorMinValue());
186 $px3->SetWidth($WIDTH);
187 $px3->SetHeight($HEIGHT);
189 $px3->SetHorizTickIncrement(1);
190 $px3->mode =
'depth';
191 $px3->SetTitle($langs->trans(
"AmountAverage"));
193 $px3->draw($filename_avg, $fileurl_avg);
199$data = $stats->getAllByYear();
200$arrayyears = array();
201foreach ($data as $val) {
202 if (!empty($val[
'year'])) {
203 $arrayyears[$val[
'year']] = $val[
'year'];
206if (!count($arrayyears)) {
207 $arrayyears[$nowyear] = $nowyear;
212$head[$h][0] = DOL_URL_ROOT.
'/fichinter/stats/index.php';
213$head[$h][1] = $langs->trans(
"ByMonthYear");
214$head[$h][2] =
'byyear';
217$type =
'fichinter_stats';
224print
'<div class="fichecenter"><div class="fichethirdleft">';
228print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
229print
'<input type="hidden" name="token" value="'.newToken().
'">';
230print
'<input type="hidden" name="mode" value="'.$mode.
'">';
232print
'<table class="noborder centpercent">';
233print
'<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans(
"Filter").
'</td></tr>';
235print
'<tr><td class="left">'.$langs->trans(
"ThirdParty").
'</td><td class="left">';
236$filter =
'(s.client:IN:1,2,3)';
237print
img_picto(
'',
'company',
'class="pictofixedwidth"');
238print $form->select_company($socid,
'socid', $filter, 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
241print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
242print
img_picto(
'',
'user',
'class="pictofixedwidth"');
243print $form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
245print
'<tr><td class="left">'.$langs->trans(
"Status").
'</td><td class="left">';
246$tmp = $objectstatic->LibStatut(0);
247$liststatus = $objectstatic->labelStatus;
249 unset($liststatus[$objectstatic::STATUS_BILLED]);
251print $form->selectarray(
'object_status', $liststatus, $object_status, 1, 0, 0,
'', 1);
254print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
255if (!in_array($year, $arrayyears)) {
256 $arrayyears[$year] = $year;
258if (!in_array($nowyear, $arrayyears)) {
259 $arrayyears[$nowyear] = $nowyear;
262print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
264print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
269print
'<div class="div-table-responsive-no-min">';
270print
'<table class="noborder centpercent">';
271print
'<tr class="liste_titre" height="24">';
272print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
273print
'<td class="right">'.$langs->trans(
"NbOfinterventions").
'</td>';
274print
'<td class="right">%</td>';
275print
'<td class="right">'.$langs->trans(
"AmountTotal").
'</td>';
276print
'<td class="right">%</td>';
277print
'<td class="right">'.$langs->trans(
"AmountAverage").
'</td>';
278print
'<td class="right">%</td>';
282foreach ($data as $val) {
283 $year = $val[
'year'];
284 while (!empty($year) && $oldyear > (
int) $year + 1) {
288 print
'<tr class="oddeven" height="24">';
289 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.
'&mode='.$mode.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
291 print
'<td class="right">0</td>';
292 print
'<td class="right"></td>';
293 print
'<td class="right">0</td>';
294 print
'<td class="right"></td>';
295 print
'<td class="right">0</td>';
296 print
'<td class="right"></td>';
301 print
'<tr class="oddeven" height="24">';
302 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.
'&mode='.$mode.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
303 print
'<td class="right">'.$val[
'nb'].
'</td>';
304 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>';
305 print
'<td class="right">'.price(
price2num($val[
'total'],
'MT'), 1).
'</td>';
306 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>';
307 print
'<td class="right">'.price(
price2num($val[
'avg'],
'MT'), 1).
'</td>';
308 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>';
317print
'</div><div class="fichetwothirdright">';
321print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
331print
'</td></tr></table>';
335print
'<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)
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.