diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php
index 17e118412b9..db4bd33b2d4 100644
--- a/htdocs/ticket/class/ticket.class.php
+++ b/htdocs/ticket/class/ticket.class.php
@@ -183,23 +183,23 @@ class Ticket extends CommonObject
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'visible'=>1, 'enabled'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object", 'css'=>''),
'track_id' => array('type'=>'varchar(255)', 'label'=>'TrackID', 'visible'=>0, 'enabled'=>1, 'position'=>11, 'notnull'=>-1, 'searchall'=>1, 'help'=>"Help text"),
'fk_user_create' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Author', 'visible'=>1, 'enabled'=>1, 'position'=>15, 'notnull'=>1, 'css'=>'nowraponall'),
- 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>1, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"),
+ 'origin_email' => array('type'=>'mail', 'label'=>'OriginEmail', 'visible'=>-2, 'enabled'=>1, 'position'=>16, 'notnull'=>1, 'index'=>1, 'searchall'=>1, 'comment'=>"Reference of object"),
'subject' => array('type'=>'varchar(255)', 'label'=>'Subject', 'visible'=>1, 'enabled'=>1, 'position'=>18, 'notnull'=>-1, 'searchall'=>1, 'help'=>""),
'type_code' => array('type'=>'varchar(32)', 'label'=>'Type', 'visible'=>1, 'enabled'=>1, 'position'=>20, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'),
- 'category_code' => array('type'=>'varchar(32)', 'label'=>'Category', 'visible'=>1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'),
+ 'category_code' => array('type'=>'varchar(32)', 'label'=>'Category', 'visible'=>-1, 'enabled'=>1, 'position'=>21, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'),
'severity_code' => array('type'=>'varchar(32)', 'label'=>'Severity', 'visible'=>1, 'enabled'=>1, 'position'=>22, 'notnull'=>-1, 'searchall'=>1, 'help'=>"", 'css'=>'maxwidth100'),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'visible'=>1, 'enabled'=>1, 'position'=>50, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToThirparty"),
- 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-2, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1),
- 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"),
- 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1),
- 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>60, 'notnull'=>-1,),
+ 'notify_tiers_at_create' => array('type'=>'integer', 'label'=>'NotifyThirdparty', 'visible'=>-1, 'enabled'=>0, 'position'=>51, 'notnull'=>1, 'index'=>1),
+ 'fk_project' => array('type'=>'integer:Project:projet/class/project.class.php', 'label'=>'Project', 'visible'=>-1, 'enabled'=>1, 'position'=>52, 'notnull'=>-1, 'index'=>1, 'searchall'=>1, 'help'=>"LinkToProject"),
'progress' => array('type'=>'varchar(100)', 'label'=>'Progression', 'visible'=>1, 'enabled'=>1, 'position'=>41, 'notnull'=>-1, 'searchall'=>1, 'css'=>'right', 'help'=>""),
'timing' => array('type'=>'varchar(20)', 'label'=>'Timing', 'visible'=>-1, 'enabled'=>1, 'position'=>42, 'notnull'=>-1, 'searchall'=>1, 'help'=>""),
- 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
- 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
- 'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>-2, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
- 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-2, 'enabled'=>1, 'position'=>501, 'notnull'=>1),
- 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-2, 'enabled'=>1, 'position'=>550, 'notnull'=>1),
+ 'datec' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
+ 'date_read' => array('type'=>'datetime', 'label'=>'TicketReadOn', 'visible'=>1, 'enabled'=>1, 'position'=>500, 'notnull'=>1),
+ 'fk_user_assign' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'AssignedTo', 'visible'=>1, 'enabled'=>1, 'position'=>505, 'notnull'=>1),
+ 'date_close' => array('type'=>'datetime', 'label'=>'TicketCloseOn', 'visible'=>1, 'enabled'=>1, 'position'=>510, 'notnull'=>1),
+ 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>520, 'notnull'=>1),
+ 'message' => array('type'=>'text', 'label'=>'Message', 'visible'=>-2, 'enabled'=>1, 'position'=>540, 'notnull'=>-1,),
+ 'resolution' => array('type'=>'integer', 'label'=>'Resolution', 'visible'=>-1, 'enabled'=>1, 'position'=>550, 'notnull'=>1),
'fk_statut' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'position'=>600, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0 => 'Unread', 1 => 'Read', 3 => 'Answered', 4 => 'Assigned', 5 => 'InProgress', 6 => 'Waiting', 8 => 'Closed', 9 => 'Deleted'))
);
diff --git a/htdocs/ticket/class/ticketstats.class.php b/htdocs/ticket/class/ticketstats.class.php
index 28a49a3bd8f..44360c788a5 100644
--- a/htdocs/ticket/class/ticketstats.class.php
+++ b/htdocs/ticket/class/ticketstats.class.php
@@ -59,7 +59,7 @@ class TicketStats extends Stats
$object = new Ticket($this->db);
$this->from = MAIN_DB_PREFIX . $object->table_element;
- $this->field = 'km';
+ $this->field = 'timing';
$this->where = " fk_statut > 0";
$this->where .= " AND entity = " . $conf->entity;
diff --git a/htdocs/ticket/index.php b/htdocs/ticket/index.php
index 7787a09e1f7..7466a0308e1 100644
--- a/htdocs/ticket/index.php
+++ b/htdocs/ticket/index.php
@@ -257,10 +257,13 @@ $data = $stats->getNbByMonth($endyear, $startyear);
print '
';
+
/*
* Last tickets
*/
-$max = 15;
+
+$max = 10;
+
$sql = "SELECT t.rowid, t.ref, t.track_id, t.datec, t.subject, t.type_code, t.category_code, t.severity_code, t.fk_statut, t.progress,";
$sql .= " type.label as type_label, category.label as category_label, severity.label as severity_label";
$sql .= " FROM " . MAIN_DB_PREFIX . "ticket as t";
@@ -300,11 +303,11 @@ if ($result) {
print '
';
print '
';
print '| ' . $transRecordedType . ' | ';
- print '' . $langs->trans('Date') . ' | ';
- print '' . $langs->trans('Subject') . ' | ';
- print '' . $langs->trans('Type') . ' | ';
- print '' . $langs->trans('Category') . ' | ';
- print '' . $langs->trans('Severity') . ' | ';
+ print ' | ';
+ print ' | ';
+ print ' | ';
+ print ' | ';
+ print ''.$langs->trans("FullList").' | ';
print ' | ';
print '
';
if ($num > 0) {
@@ -373,11 +376,6 @@ if ($result) {
print '';
print '';
-print '';
-print '
';
-print '
';
-print '
';
-
// End of page
llxFooter('');
$db->close();
diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php
index 99b394963f7..2c16e4508f1 100644
--- a/htdocs/ticket/list.php
+++ b/htdocs/ticket/list.php
@@ -617,6 +617,7 @@ while ($i < min($num, $limit))
$cssforfield='';
if (in_array($val['type'], array('date','datetime','timestamp'))) $cssforfield.=($cssforfield?' ':'').'center';
if (in_array($val['type'], array('timestamp'))) $cssforfield.=($cssforfield?' ':'').'nowrap';
+ if ($key == 'ref') $cssforfield.=($cssforfield?' ':'').'nowraponall';
if ($key == 'status') $cssforfield.=($cssforfield?' ':'').'center';
if (! empty($arrayfields['t.'.$key]['checked']))
{
diff --git a/htdocs/ticket/stats/index.php b/htdocs/ticket/stats/index.php
new file mode 100644
index 00000000000..2366ac30610
--- /dev/null
+++ b/htdocs/ticket/stats/index.php
@@ -0,0 +1,340 @@
+
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/ticket/stats/index.php
+ * \ingroup ticket
+ * \brief Page with tickets statistics
+ */
+
+require '../../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/ticket/class/actions_ticket.class.php';
+require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticketstats.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
+
+$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
+$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
+
+if (! $user->rights->ticket->read) accessforbidden();
+
+$object_status=GETPOST('object_status');
+
+$userid=GETPOST('userid', 'int');
+$socid=GETPOST('socid', 'int');
+// Security check
+if ($user->societe_id > 0)
+{
+ $action = '';
+ $socid = $user->societe_id;
+}
+
+$nowyear=strftime("%Y", dol_now());
+$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
+//$startyear=$year-2;
+$startyear=$year-1;
+$endyear=$year;
+
+// Load translation files required by the page
+$langs->loadLangs(array('orders', 'companies', 'other', 'tickets'));
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+//$formticket=new FormTicket($db);
+
+$title=$langs->trans("Statistics");
+$dir=$conf->ticket->dir_temp;
+
+llxHeader('', $title);
+
+print load_fiche_titre($title, '', 'title_ticket.png');
+
+dol_mkdir($dir);
+
+$stats = new TicketStats($db, $socid, ($userid>0?$userid:0));
+if ($object_status != '' && $object_status >= -1) $stats->where .= ' AND c.fk_statut IN ('.$db->escape($object_status).')';
+
+
+// Build graphic number of object
+$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
+
+//var_dump($data);
+// $data = array(array('Lib',val1,val2,val3),...)
+
+
+if (!$user->rights->societe->client->voir || $user->societe_id)
+{
+ $filenamenb = $dir.'/ticketsnbinyear-'.$user->id.'-'.$year.'.png';
+ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$user->id.'-'.$year.'.png';
+}
+else
+{
+ $filenamenb = $dir.'/ticketsnbinyear-'.$year.'.png';
+ $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsnbinyear-'.$year.'.png';
+}
+
+$px1 = new DolGraph();
+$mesg = $px1->isGraphKo();
+if (! $mesg)
+{
+ $px1->SetData($data);
+ $px1->SetPrecisionY(0);
+ $i=$startyear;$legend=array();
+ while ($i <= $endyear)
+ {
+ $legend[]=$i;
+ $i++;
+ }
+ $px1->SetLegend($legend);
+ $px1->SetMaxValue($px1->GetCeilMaxValue());
+ $px1->SetMinValue(min(0, $px1->GetFloorMinValue()));
+ $px1->SetWidth($WIDTH);
+ $px1->SetHeight($HEIGHT);
+ $px1->SetYLabel($langs->trans("NbOfTicket"));
+ $px1->SetShading(3);
+ $px1->SetHorizTickIncrement(1);
+ $px1->SetPrecisionY(0);
+ $px1->mode='depth';
+ $px1->SetTitle($langs->trans("NumberOfTicketsByMonth"));
+
+ $px1->draw($filenamenb, $fileurlnb);
+}
+
+// Build graphic amount of object
+$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
+//var_dump($data);
+// $data = array(array('Lib',val1,val2,val3),...)
+
+if (!$user->rights->societe->client->voir || $user->societe_id)
+{
+ $filenameamount = $dir.'/ticketsamountinyear-'.$user->id.'-'.$year.'.png';
+ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$user->id.'-'.$year.'.png';
+}
+else
+{
+ $filenameamount = $dir.'/ticketsamountinyear-'.$year.'.png';
+ $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsamountinyear-'.$year.'.png';
+}
+
+$px2 = new DolGraph();
+$mesg = $px2->isGraphKo();
+if (! $mesg)
+{
+ $px2->SetData($data);
+ $i=$startyear;$legend=array();
+ while ($i <= $endyear)
+ {
+ $legend[]=$i;
+ $i++;
+ }
+ $px2->SetLegend($legend);
+ $px2->SetMaxValue($px2->GetCeilMaxValue());
+ $px2->SetMinValue(min(0, $px2->GetFloorMinValue()));
+ $px2->SetWidth($WIDTH);
+ $px2->SetHeight($HEIGHT);
+ $px2->SetYLabel($langs->trans("AmountOfTickets"));
+ $px2->SetShading(3);
+ $px2->SetHorizTickIncrement(1);
+ $px2->SetPrecisionY(0);
+ $px2->mode='depth';
+ $px2->SetTitle($langs->trans("AmountOfTicketsByMonthHT"));
+
+ $px2->draw($filenameamount, $fileurlamount);
+}
+
+
+$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
+
+if (!$user->rights->societe->client->voir || $user->societe_id)
+{
+ $filename_avg = $dir.'/ticketsaverage-'.$user->id.'-'.$year.'.png';
+ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$user->id.'-'.$year.'.png';
+}
+else
+{
+ $filename_avg = $dir.'/ticketsaverage-'.$year.'.png';
+ $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=ticketstats&file=ticketsaverage-'.$year.'.png';
+}
+
+$px3 = new DolGraph();
+$mesg = $px3->isGraphKo();
+if (! $mesg)
+{
+ $px3->SetData($data);
+ $i=$startyear;$legend=array();
+ while ($i <= $endyear)
+ {
+ $legend[]=$i;
+ $i++;
+ }
+ $px3->SetLegend($legend);
+ $px3->SetYLabel($langs->trans("AmountAverage"));
+ $px3->SetMaxValue($px3->GetCeilMaxValue());
+ $px3->SetMinValue($px3->GetFloorMinValue());
+ $px3->SetWidth($WIDTH);
+ $px3->SetHeight($HEIGHT);
+ $px3->SetShading(3);
+ $px3->SetHorizTickIncrement(1);
+ $px3->SetPrecisionY(0);
+ $px3->mode='depth';
+ $px3->SetTitle($langs->trans("AmountAverage"));
+
+ $px3->draw($filename_avg, $fileurl_avg);
+}
+
+
+
+// Show array
+$data = $stats->getAllByYear();
+$arrayyears=array();
+foreach($data as $val) {
+ if (! empty($val['year'])) {
+ $arrayyears[$val['year']]=$val['year'];
+ }
+}
+if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
+
+$h=0;
+$head = array();
+$head[$h][0] = DOL_URL_ROOT . '/ticket/stats/index.php?mode='.$mode;
+$head[$h][1] = $langs->trans("ByMonthYear");
+$head[$h][2] = 'byyear';
+$h++;
+
+$type='ticket_stats';
+
+complete_head_from_modules($conf, $langs, null, $head, $h, $type);
+
+dol_fiche_head($head, 'byyear', $langs->trans("Statistics"), -1);
+
+
+print '';
+
+
+// Show filter box
+print '
';
+print '
';
+
+
+print '
';
+print '
';
+print '';
+print '| '.$langs->trans("Year").' | ';
+print ''.$langs->trans("NbOfTickets").' | ';
+print '% | ';
+//print ''.$langs->trans("AmountTotal").' | ';
+//print '% | ';
+//print ''.$langs->trans("AmountAverage").' | ';
+//print '% | ';
+print '
';
+
+$oldyear=0;
+foreach ($data as $val)
+{
+ $year = $val['year'];
+ while (! empty($year) && $oldyear > $year+1)
+ { // If we have empty year
+ $oldyear--;
+
+ print '';
+ print '| 0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$oldyear.' | ';
+ print '0 | ';
+ print ' | ';
+ //print '0 | ';
+ //print ' | ';
+ //print '0 | ';
+ //print ' | ';
+ print '
';
+ }
+
+
+ print '';
+ print '| 0?'&socid='.$socid:'').($userid>0?'&userid='.$userid:'').'">'.$year.' | ';
+ print ''.$val['nb'].' | ';
+ print ''.round($val['nb_diff']).' | ';
+ //print ''.price(price2num($val['total'], 'MT'), 1).' | ';
+ //print ''.round($val['total_diff']).' | ';
+ //print ''.price(price2num($val['avg'], 'MT'), 1).' | ';
+ //print ''.round($val['avg_diff']).' | ';
+ print '
';
+ $oldyear=$year;
+}
+
+print '
';
+print '
';
+
+
+print '
';
+
+
+// Show graphs
+print '
';
+if ($mesg) { print $mesg; }
+else {
+ print $px1->show();
+ print " \n";
+ //print $px2->show();
+ //print " \n";
+ //print $px3->show();
+}
+print ' |
';
+
+
+print '
';
+print '';
+
+dol_fiche_end();
+
+// End of page
+llxFooter();
+$db->close();