25require
'../../main.inc.php';
26require_once DOL_DOCUMENT_ROOT.
'/ticket/class/actions_ticket.class.php';
27require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticketstats.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/ticket/class/ticket.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
34if (!$user->rights->ticket->read) {
38$object_status =
GETPOST(
'object_status',
'intcomma');
40$userid =
GETPOST(
'userid',
'int');
41$socid =
GETPOST(
'socid',
'int');
43if ($user->socid > 0) {
45 $socid = $user->socid;
54$langs->loadLangs(array(
'orders',
'companies',
'other',
'tickets'));
64$title = $langs->trans(
"Statistics");
65$dir = $conf->ticket->dir_temp;
73$stats =
new TicketStats($db, $socid, ($userid > 0 ? $userid : 0));
74if ($object_status !=
'' && $object_status >= -1) {
75 $stats->where .=
' AND fk_statut IN ('.$db->sanitize($db->escape($object_status)).
')';
80$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
86if (empty($user->rights->societe->client->voir) || $user->socid) {
87 $filenamenb = $dir.
'/ticketsnbinyear-'.$user->id.
'-'.$year.
'.png';
88 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.
'-'.$year.
'.png';
90 $filenamenb = $dir.
'/ticketsnbinyear-'.$year.
'.png';
91 $fileurlnb = DOL_URL_ROOT.
'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$year.
'.png';
95$mesg = $px1->isGraphKo();
98 $i = $startyear; $legend = array();
99 while ($i <= $endyear) {
103 $px1->SetLegend($legend);
104 $px1->SetMaxValue($px1->GetCeilMaxValue());
105 $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
106 $px1->SetWidth($WIDTH);
107 $px1->SetHeight($HEIGHT);
108 $px1->SetYLabel($langs->trans(
"NbOfTicket"));
110 $px1->SetHorizTickIncrement(1);
111 $px1->mode =
'depth';
112 $px1->SetTitle($langs->trans(
"NumberOfTicketsByMonth"));
114 $px1->draw($filenamenb, $fileurlnb);
118$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
191$data = $stats->getAllByYear();
192$arrayyears = array();
193foreach ($data as $val) {
194 if (!empty($val[
'year'])) {
195 $arrayyears[$val[
'year']] = $val[
'year'];
198if (!count($arrayyears)) {
199 $arrayyears[$nowyear] = $nowyear;
204$head[$h][0] = DOL_URL_ROOT.
'/ticket/stats/index.php';
205$head[$h][1] = $langs->trans(
"ByMonthYear");
206$head[$h][2] =
'byyear';
209$type =
'ticket_stats';
216print
'<div class="fichecenter"><div class="fichethirdleft">';
220print
'<form name="stats" method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
221print
'<input type="hidden" name="token" value="'.newToken().
'">';
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">';
227print
img_picto(
'',
'company',
'class="pictofixedwidth"');
228print $form->select_company($socid,
'socid',
'', 1, 0, 0, array(), 0,
'widthcentpercentminusx maxwidth300',
'');
231print
'<tr><td class="left">'.$langs->trans(
"CreatedBy").
'</td><td class="left">';
232print
img_picto(
'',
'user',
'class="pictofixedwidth"');
233print $form->select_dolusers($userid,
'userid', 1,
'', 0,
'',
'', 0, 0, 0,
'', 0,
'',
'widthcentpercentminusx maxwidth300');
235print
'<tr><td class="left">'.$langs->trans(
"Status").
'</td><td class="left">';
236$liststatus = $object->fields[
'fk_statut'][
'arrayofkeyval'];
237print $form->selectarray(
'object_status', $liststatus,
GETPOST(
'object_status',
'intcomma'), -4, 0, 0,
'', 1);
240print
'<tr><td class="left">'.$langs->trans(
"Year").
'</td><td class="left">';
241if (!in_array($year, $arrayyears)) {
242 $arrayyears[$year] = $year;
244if (!in_array($nowyear, $arrayyears)) {
245 $arrayyears[$nowyear] = $nowyear;
248print $form->selectarray(
'year', $arrayyears, $year, 0, 0, 0,
'', 0, 0, 0,
'',
'width75');
250print
'<tr><td class="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans(
"Refresh").
'"></td></tr>';
256print
'<div class="div-table-responsive-no-min">';
257print
'<table class="noborder centpercent">';
258print
'<tr class="liste_titre" height="24">';
259print
'<td class="center">'.$langs->trans(
"Year").
'</td>';
260print
'<td class="right">'.$langs->trans(
"NbOfTickets").
'</td>';
261print
'<td class="right">%</td>';
269foreach ($data as $val) {
270 $year = $val[
'year'];
271 while (!empty($year) && $oldyear > $year + 1) {
274 print
'<tr class="oddeven" height="24">';
275 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$oldyear.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$oldyear.
'</a></td>';
276 print
'<td class="right">0</td>';
277 print
'<td class="right"></td>';
286 print
'<tr class="oddeven" height="24">';
287 print
'<td class="center"><a href="'.$_SERVER[
"PHP_SELF"].
'?year='.$year.($socid > 0 ?
'&socid='.$socid :
'').($userid > 0 ?
'&userid='.$userid :
'').
'">'.$year.
'</a></td>';
288 print
'<td class="right">'.$val[
'nb'].
'</td>';
289 print
'<td class="right" style="'.((isset($val[
'nb_diff']) && $val[
'nb_diff'] >= 0) ?
'color: green;' :
'color: red;').
'">'.round(isset($val[
'nb_diff']) ? $val[
'nb_diff'] : 0).
'</td>';
302print
'</div><div class="fichetwothirdright">';
306print
'<table class="border centpercent"><tr class="pair nohover"><td class="center">';
316print
'</td></tr></table>';
320print
'<div class="clearboth"></div>';
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
static getDefaultGraphSizeForStats($direction, $defaultsize='')
getDefaultGraphSizeForStats
Classe permettant la gestion des stats des deplacements et notes de frais.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
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 dolibarr global constant string value.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Class to generate the form for creating a new ticket.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.