Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition of new graphs #258

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions inc/config.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,10 @@ public function preconfig($funct_name, $classname)
$this->fields['graphtype'] = 'SVG';
break;
}

if (str_contains($funct_name, 'Year')) {
$this->fields["default_delay"] = "1826"; // 5 Years
}
}

return $this->fields;
Expand Down
60 changes: 60 additions & 0 deletions inc/helpdesk.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,66 @@ public function reportAreaNbTicket($config = [], $area = true)
return $datas;
}

public function reportGlineNbTicketYear($config = [])
{
$_SESSION['mreporting_selector']['reportGlineNbTicketYear'] = ['dateinterval'];

return $this->reportGareaNbTicketYear($config);
}

public function reportGareaNbTicketYear($config = [])
{
global $DB;

$_SESSION['mreporting_selector']['reportGareaNbTicketYear'] = ['dateinterval'];

$datas = [];

//Init delay value
$this->sql_date = PluginMreportingCommon::getSQLDate(
"glpi_tickets.date",
$config['delay'],
$config['randname']
);

$query = "SELECT DISTINCT
date_format(date, '%Y-%m') as period,
COUNT(id) as nb
FROM glpi_tickets
WHERE " . $this->sql_date . "
AND glpi_tickets.entities_id IN (" . $this->where_entities . ")
AND glpi_tickets.is_deleted = '0'
GROUP BY period
ORDER BY period";
$res = $DB->query($query);
$lang = $_SESSION['glpilanguage'] ?? 'en_GB';

for ($m = 1; $m <= 12; $m++) {
$datas['labels2'][$m] = IntlDateFormatter::formatObject(new DateTime("2024-$m"), 'MMMM', $lang);
}

while ($data = $DB->fetchAssoc($res)) {
$date = new DateTime($data['period']);
$month = IntlDateFormatter::formatObject($date, 'M', $lang);
$datas['datas'][IntlDateFormatter::formatObject($date, 'Y', $lang)][$month] = $data['nb'];
}

foreach (array_keys($datas['datas']) as $key) {
for ($m = 1; $m <= 12; $m++) {
if (!isset($datas['datas'][$key][$m]))
$datas['datas'][$key][$m] = 0;
}
}

if (count($datas) > 0) {
foreach ($datas['datas'] as &$data) {
ksort($data);
}
}

return $datas;
}

public function reportVstackbarNbTicket($config = [])
{
$_SESSION['mreporting_selector']['reportVstackbarNbTicket'] = ['dateinterval'];
Expand Down
86 changes: 86 additions & 0 deletions inc/helpdeskplus.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class PluginMreportingHelpdeskplus extends PluginMreportingBaseclass
protected $sql_join_cat;
protected $sql_join_g;
protected $sql_join_u;
protected $sql_join_tasku;
protected $sql_join_tt;
protected $sql_join_tu;
protected $sql_join_gt;
Expand All @@ -68,6 +69,8 @@ public function __construct($config = [])
$this->sql_join_tu = 'LEFT JOIN glpi_tickets_users tu
ON tu.tickets_id = glpi_tickets.id
AND tu.type = ' . Ticket_User::ASSIGN;
$this->sql_join_tasku = "LEFT JOIN glpi_users u
ON tt.users_id_tech = u.id";
$this->sql_join_gt = 'LEFT JOIN glpi_groups_tickets gt
ON gt.tickets_id = glpi_tickets.id
AND gt.type = ' . Group_Ticket::ASSIGN;
Expand Down Expand Up @@ -479,6 +482,89 @@ public function reportVstackbarTicketstech($config = [])
return $datas;
}

public function reportVstackbarTicketstechtime($config = [])
{
global $DB;

$_SESSION['mreporting_selector']['reportVstackbarTicketstechtime']
= ['dateinterval', 'multiplegroupassign', 'category'];

$this->sql_date_create = PluginMreportingCommon::getSQLDate(
"`tt`.date",
$config['delay'],
$config['randname']
);

$tab = [];
$datas = [];

if (!isset($_SESSION['mreporting_values']['date2' . $config['randname']])) {
$_SESSION['mreporting_values']['date2' . $config['randname']] = date("Y-m-d");
}

$date1 = (new DateTime($_SESSION['mreporting_values']['date1' . $config['randname']]))
->modify('first day of this month');
$date2 = (new DateTime($_SESSION['mreporting_values']['date2' . $config['randname']]))
->modify('first day of next month');
$period = new DatePeriod($date1, DateInterval::createFromDateString('1 month'), $date2);

$sql_users = "SELECT DISTINCT CONCAT(u.firstname, ' ', u.realname) as name
FROM glpi_tickettasks tt
JOIN glpi_users u on tt.users_id_tech = u.id";
$res = $DB->query($sql_users);
$users = [];
while ($data = $DB->fetchAssoc($res)) {
array_push($users, $data['name']);
}

$sql_create = "SELECT
DISTINCT MONTH(tt.date) as month,
YEAR(tt.date) as year,
CONCAT(YEAR(tt.date), '-', MONTH(tt.date)) AS fulldate,
CONCAT(u.firstname, ' ', u.realname) AS completename,
u.name as name,
u.id as u_id,
IFNULL(SUM(tt.actiontime), 0)/3600 AS nb
FROM glpi_tickets
{$this->sql_join_tu}
{$this->sql_join_tt}
{$this->sql_join_gt}
{$this->sql_join_gtr}
{$this->sql_join_tasku}
WHERE {$this->sql_date_create}
AND glpi_tickets.entities_id IN ({$this->where_entities})
AND glpi_tickets.is_deleted = '0'
AND {$this->sql_group_assign}
AND {$this->sql_group_request}
AND {$this->sql_type}
AND {$this->sql_itilcat}
AND u.id IS NOT NULL
GROUP BY name, fulldate
ORDER BY tt.date, name";
$res = $DB->query($sql_create);
$lang = $_SESSION['glpilanguage'] ?? 'en_GB';
while ($data = $DB->fetchAssoc($res)) {
$column = $data['completename'];
$month_name = IntlDateFormatter::formatObject(new Datetime($data['fulldate']), 'MMMM yyyy', $lang);
if (!isset($tab[$column][$month_name])) {
$tab[$column][$month_name] = 0;
}

$tab[$column][$month_name] += $data['nb'];
}

$datas = [];
foreach ($tab as $name => $data) {
foreach ($period as $date) {
$date_name = IntlDateFormatter::formatObject($date, 'MMMM yyyy', $lang);
$datas['datas'][$date_name][] = $data[$date_name] ?? 0;
}
$datas['labels2'][] = $name;
}

return $datas;
}

public function reportHbarTopcategory($config = [])
{
global $DB;
Expand Down
12 changes: 12 additions & 0 deletions locales/reports_locales/helpdesk_en_GB.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@
'category' => 'Per ticket',
],

'reportGareaNbTicketYear' => [
'title' => 'Number of ticket evolution over the period (per year)',
'desc' => 'Area',
'category' => 'Per ticket',
],

'reportGlineNbTicketYear' => [
'title' => 'Number of ticket evolution over the period (per year)',
'desc' => 'Line',
'category' => 'Per ticket',
],

'reportGlineNbTicket' => [
'title' => 'Number of ticket evolution over the period (per status)',
'desc' => 'Lines',
Expand Down
12 changes: 12 additions & 0 deletions locales/reports_locales/helpdesk_fr_FR.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@
'category' => 'Par tickets',
],

'reportGareaNbTicketYear' => [
'title' => 'Evolution du nombre de ticket sur la période (par Année)',
'desc' => 'Aire',
'category' => 'Par tickets',
],

'reportGlineNbTicketYear' => [
'title' => 'Evolution du nombre de ticket sur la période (par Année)',
'desc' => 'Ligne',
'category' => 'Par tickets',
],

'reportGlineNbTicket' => [
'title' => 'Evolution du nombre de ticket sur la période (par Statut)',
'desc' => 'Lignes',
Expand Down
6 changes: 6 additions & 0 deletions locales/reports_locales/helpdeskplus_en_GB.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
'category' => 'General',
],

'reportVstackbarTicketstechtime' => [
'title' => 'Time taken mensually per technicien',
'desc' => '',
'category' => 'Général',
],

'reportHbarTopcategory' => [
'title' => 'TOP categories',
'desc' => '',
Expand Down
7 changes: 7 additions & 0 deletions locales/reports_locales/helpdeskplus_fr_FR.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@
'category' => 'Général',
],

'reportVstackbarTicketstechtime' => [
'title' => 'Quantitatif mensuel par temps passé par technicien',
'desc' => 'Ce rapport affiche la durée totale passée par chaque employée sur des tâches pour chaque mois sélectionnés.<br>'.
'<b>Vous devez selectionner au préalable un groupe de technicien pour afficher les données.</b>',
'category' => 'Général',
],

'reportHbarTopcategory' => [
'title' => 'TOP catégories',
'desc' => 'Nombre croissant de ticket affiché par catégorie. <br>' .
Expand Down
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* -------------------------------------------------------------------------
*/

define('PLUGIN_MREPORTING_VERSION', '1.8.6');
define('PLUGIN_MREPORTING_VERSION', '1.8.7');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to change the plugin version, this is handled by the github action.


// Minimal GLPI version, inclusive
define('PLUGIN_MREPORTING_MIN_GLPI', '10.0.0');
Expand Down
Loading