You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2015-06-01 14:02:52

patrickz
Member
Registered: 2015-06-01
Posts: 1

Ticket Statistic by Entity

Hello,

for the statistics module for tickets statistic ( stat.tracking.php ) I wanted to create a Group By "Entity". This sorting mechanism is not available in my version I am using 0.84.8, but useful to see the tickets for a specific entity.

I applied some enhancement in the stat.tracking.php and stat.class.php to query for ticket statistics by entity. Here is what I have changed.
Would it be useful to integrate this filter option in the future ( also 0.85 ) ?

Kind regards,
Patrick


Patch Correction in the join on line stat.class.php 731 [Update 23-07-2015]:

diff -ruN glpi_orig/front/stat.tracking.php glpi/front/stat.tracking.php
--- glpi_orig/front/stat.tracking.php    2015-05-28 17:12:21.000000000 +0200
+++ glpi/front/stat.tracking.php    2015-05-28 17:06:46.000000000 +0200
@@ -77,6 +77,7 @@
$requester = array('user'               => array('title' => __('Requester')),
                    'users_id_recipient' => array('title' => __('Writer')),
                    'group'              => array('title' => __('Group')),
+                   'entity'              => array('title' => __('Entity')),
                    'group_tree'         => array('title' => __('Group tree')),
                    'usertitles_id'      => array('title' => _x('person','Title')),
                    'usercategories_id'  => array('title' => __('Category')));
@@ -90,6 +91,7 @@

if ($_GET['itemtype'] == 'Ticket') {
    $caract['type']            = array('title' => __('Type'));
+   $caract['entity']            = array('title' => __('Entity'));
    $caract['requesttypes_id'] = array('title' => __('Request source'));
    $caract['locations_id']    = array('title' => __('Location'));
    $caract['locations_tree']  = array('title' => __('Location tree'));
@@ -106,6 +108,8 @@
                                                    => array('title' => __('Group')),
                                               'groups_tree_assign'
                                                    => array('title' => __('Group tree')),
+                                              'entity'
+                                                   => array('title' => __('Entity')),
                                               'suppliers_id_assign'
                                                    => array('title' => __('Supplier'))));

diff -ruN glpi_orig/inc/stat.class.php glpi/inc/stat.class.php
--- glpi_orig/inc/stat.class.php    2015-05-28 17:12:44.000000000 +0200
+++ glpi/inc/stat.class.php    2015-05-28 17:06:49.000000000 +0200
@@ -731,6 +731,7 @@
       $LEFTJOIN          = "";
       $LEFTJOINUSER      = "LEFT JOIN `$userlinktable`
                               ON (`$userlinktable`.`$fkfield` = `$table`.`id`)";
+      $LEFTJOINENTITY     = "LEFT JOIN `glpi_entities` ON (`$table`.`entities_id` = `glpi_entities`.`id`)";
       $LEFTJOINGROUP     = "LEFT JOIN `$grouplinktable`
                               ON (`$grouplinktable`.`$fkfield` = `$table`.`id`)";
       $LEFTJOINSUPPLIER  = "LEFT JOIN `$supplierlinktable`
@@ -755,6 +757,13 @@
                                AND `$userlinktable`.`type` ='".CommonITILActor::REQUESTER."')";
             break;

+         case "entity" :
+            $LEFTJOIN = $LEFTJOINENTITY;
+            $WHERE   .= " AND (`glpi_tickets`.`entities_id` = '$value'
+                               )";
+            break;
+
+
          case "usertitles_id" :
             $LEFTJOIN  = $LEFTJOINUSER;
             $LEFTJOIN .= " LEFT JOIN `glpi_users`

Last edited by patrickz (2015-07-24 08:09:45)

Offline

#2 2015-06-02 15:29:19

yllen
GLPI-DEV
From: Sillery (51)
Registered: 2008-01-14
Posts: 15,278

Re: Ticket Statistic by Entity

Ticket opened for discussion: https://forge.indepnet.net/issues/5351


CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6  - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)

Offline

Board footer

Powered by FluxBB