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

Added CreditUsed Report and CreditTicket Report #40

Open
wants to merge 1 commit 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
14 changes: 14 additions & 0 deletions report/creditused/creditused.en_GB.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
$LANG['plugin_credit']['creditused'] = "Credit consumed";
$LANG['creditused'][0]="Title";
$LANG['creditused'][1]="Category";
$LANG['creditused'][2]="Date consumed";
$LANG['creditused'][3]="Quantity consumed";
$LANG['creditused'][4]="Name";
$LANG['creditused'][5]="Number ticket";
$LANG['creditused'][6]="Entity";
$LANG['creditused'][7]="Active";
$LANG['creditused_nulo'][0]="None";
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose it's a typo?

Suggested change
$LANG['creditused_nulo'][0]="None";
$LANG['creditused_null'][0]="None";

$LANG['creditused_active'][0]="Yes";
$LANG['creditused_active'][1]="No";
$LANG['creditused_criteria'][0]="Date consumed";
14 changes: 14 additions & 0 deletions report/creditused/creditused.es_ES.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
$LANG['plugin_credit']['creditused'] = "Creditos usados";
$LANG['creditused'][0]="Titulo";
$LANG['creditused'][1]="Categoria";
$LANG['creditused'][2]="Fecha consumido";
$LANG['creditused'][3]="Consumido";
$LANG['creditused'][4]="Nombre";
$LANG['creditused'][5]="Numero incidencia";
$LANG['creditused'][6]="Entidad";
$LANG['creditused'][7]="Activo";
$LANG['creditused_nulo'][0]="Sin categoria";
$LANG['creditused_active'][0]="Si";
$LANG['creditused_active'][1]="No";
$LANG['creditused_criteria'][0]="Fecha consumido";
70 changes: 70 additions & 0 deletions report/creditused/creditused.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

$USEDBREPLICATE= 1;
$DBCONNECTION_REQUIRED= 0;

include ("../../../../inc/includes.php");

$report= new PluginReportsAutoReport($LANG['plugin_credit']['creditused']);
//Filtro fecha
Copy link
Contributor

Choose a reason for hiding this comment

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

English comments, please

new PluginReportsDateIntervalCriteria($report, 'date', $LANG['creditused_criteria'][0]);
//Filtro activo
$choices = [0=>'--', 2 =>$LANG['creditused_active'][1], 1 => $LANG['creditused_active'][0]];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$choices = [0=>'--', 2 =>$LANG['creditused_active'][1], 1 => $LANG['creditused_active'][0]];
$choices = [
0 => '--',
2 => $LANG['creditused_active'][1],
1 => $LANG['creditused_active'][0],
];

$filter_active=new PluginReportsArrayCriteria($report, 'is_active', $LANG['creditused'][7], $choices);
//Filtro entidad
new PluginReportsDropdownCriteria($report, "gpce.id", "glpi_plugin_credit_entities", $LANG['creditused'][4]);

$report->displayCriteriasForm();
$report->setColumns([new PluginReportsColumn('id', $LANG['creditused'][5]),
new PluginReportsColumn('ticket', $LANG['creditused'][0]),
new PluginReportsColumn('active', $LANG['creditused'][7]),
new PluginReportsColumn('categoria', $LANG['creditused'][1]),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
new PluginReportsColumn('categoria', $LANG['creditused'][1]),
new PluginReportsColumn('category', $LANG['creditused'][1]),

new PluginReportsColumnDate('date', $LANG['creditused'][2]),
new PluginReportsColumn('quantity', $LANG['creditused'][3]),
new PluginReportsColumn('credit', $LANG['creditused'][4]),
new PluginReportsColumn('entity', $LANG['creditused'][6])
]
);

if ($report->criteriasValidated()) {
$query = "SELECT gt.id as id,
gt.name as ticket,
case when `gpce`.`is_active` = TRUE then '".$LANG['creditused_active'][0]."' else '".$LANG['creditused_active'][1]."' end as active,
if(gi.name IS NULL,'".$LANG['creditused_nulo'][0]."',gi.name) as categoria,
gpct.date_creation as date,
gpct.consumed as quantity,
gpce.name as credit,
`ge`.`name` as entity
FROM glpi_plugin_credit_tickets as gpct
inner join glpi_tickets as gt on gt.id=gpct.tickets_id
left join glpi_itilcategories as gi on gi.id=gt.itilcategories_id
inner join glpi_plugin_credit_entities as gpce on gpce.id=gpct.plugin_credit_entities_id
inner JOIN `glpi_entities` as ge ON (`gpce`.`entities_id` = `ge`.`id`)
".getEntitiesRestrictRequest(" WHERE", "gpce");
if ($filter_active->getParameterValue()==2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ($filter_active->getParameterValue()==2) {
if ($filter_active->getParameterValue() == 2) {

$report->delCriteria('is_active');
$query.=" AND is_active='0' ";
}
$query.=$report->addSqlCriteriasRestriction();
} else {
$query = "SELECT gt.id as id,
gt.name as ticket,
case when `gpce`.`is_active` = TRUE then '".$LANG['creditused_active'][0]."' else '".$LANG['creditused_active'][1]."' end as active,
if(gi.name IS NULL,'".$LANG['creditused_nulo'][0]."',gi.name) as categoria,
gpct.date_creation as date,
gpct.consumed as quantity,
gpce.name as credit,
`ge`.`name` as entity
FROM glpi_plugin_credit_tickets as gpct
inner join glpi_tickets as gt on gt.id=gpct.tickets_id
left join glpi_itilcategories as gi on gi.id=gt.itilcategories_id
inner join glpi_plugin_credit_entities as gpce on gpce.id=gpct.plugin_credit_entities_id
inner JOIN `glpi_entities` as ge ON (`gpce`.`entities_id` = `ge`.`id`)
".getEntitiesRestrictRequest(" WHERE", "gpce")."
".$report->addSqlCriteriasRestriction();
$query.="order by gpct.id desc";
}
$report->setSqlRequest($query);
$report->execute();


13 changes: 13 additions & 0 deletions report/creditvoucher/creditvoucher.en_GB.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
$LANG['plugin_credit']['creditvoucher'] = "Credit Summary";
$LANG['creditvoucher'][0]="Name";
$LANG['creditvoucher'][1]="Type";
$LANG['creditvoucher'][2]="Start date";
$LANG['creditvoucher'][3]="End date";
$LANG['creditvoucher'][4]="Quantity";
$LANG['creditvoucher'][5]="Quantity consumed";
$LANG['creditvoucher'][6]="Quantity remaining";
$LANG['creditvoucher'][7]="Active";
$LANG['creditvoucher'][8]="Entity";
$LANG['creditvoucher_active'][0]="Yes";
$LANG['creditvoucher_active'][1]="No";
13 changes: 13 additions & 0 deletions report/creditvoucher/creditvoucher.es_ES.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
$LANG['plugin_credit']['creditvoucher'] = "Resumen de créditos";
$LANG['creditvoucher'][0]="Nombre";
$LANG['creditvoucher'][1]="Tipo";
$LANG['creditvoucher'][2]="Fecha inicio";
$LANG['creditvoucher'][3]="Fecha Fin";
$LANG['creditvoucher'][4]="Cantidad";
$LANG['creditvoucher'][5]="Consumidos";
$LANG['creditvoucher'][6]="Cantidad restante";
$LANG['creditvoucher'][7]="Activo";
$LANG['creditvoucher'][8]="Entidad";
$LANG['creditvoucher_active'][0]="Si";
$LANG['creditvoucher_active'][1]="No";
67 changes: 67 additions & 0 deletions report/creditvoucher/creditvoucher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

$USEDBREPLICATE= 1;
$DBCONNECTION_REQUIRED= 0;

include ("../../../../inc/includes.php");

$report= new PluginReportsAutoReport($LANG['plugin_credit']['creditvoucher']);
//Filtro Activo
$choices = [0=>'--', 2 =>$LANG['creditvoucher_active'][1], 1 => $LANG['creditvoucher_active'][0]];
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$choices = [0=>'--', 2 =>$LANG['creditvoucher_active'][1], 1 => $LANG['creditvoucher_active'][0]];
$choices = [
0 => '--',
2 => $LANG['creditvoucher_active'][1],
1 => $LANG['creditvoucher_active'][0],
];

$filter_active=new PluginReportsArrayCriteria($report, 'is_active', $LANG['creditvoucher'][7], $choices);

$report->displayCriteriasForm();
$report->setColumns([new PluginReportsColumn('name', $LANG['creditvoucher'][0]),
new PluginReportsColumn('type', $LANG['creditvoucher'][1]),
new PluginReportsColumn('active', $LANG['creditvoucher'][7]),
new PluginReportsColumnDate('begin_date', $LANG['creditvoucher'][2]),
new PluginReportsColumnDate('end_date', $LANG['creditvoucher'][3]),
new PluginReportsColumn('quantity', $LANG['creditvoucher'][4]),
new PluginReportsColumn('consumed', $LANG['creditvoucher'][5]),
new PluginReportsColumn('rest', $LANG['creditvoucher'][6]),
new PluginReportsColumn('entity', $LANG['creditvoucher'][8])
]
);

if ($report->criteriasValidated()) {
$query = "SELECT `gpce`.`name`,
`gpct`.`name` AS type,
case when `gpce`.`is_active` = TRUE then '".$LANG['creditvoucher_active'][0]."' else '".$LANG['creditvoucher_active'][1]."' end as active,
`gpce`.`begin_date`,
`gpce`.`end_date`,
`gpce`.`quantity`,
SUM(consumed) as consumed,
`gpce`.`quantity`-SUM(consumed) as rest,
`ge`.`name` as entity
FROM `glpi_plugin_credit_entities` as gpce
inner JOIN `glpi_plugin_credit_types` as gpct ON (`gpce`.`plugin_credit_types_id` = `gpct`.`id`)
left join glpi_plugin_credit_tickets as pct on (`pct`.`plugin_credit_entities_id` = `gpce`.`id`)
inner JOIN `glpi_entities` as ge ON (`gpce`.`entities_id` = `ge`.`id`)".
getEntitiesRestrictRequest(" WHERE", "gpce");
if ($filter_active->getParameterValue()==2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ($filter_active->getParameterValue()==2) {
if ($filter_active->getParameterValue() == 2) {

$report->delCriteria('is_active');
$query.=" AND is_active='0' ";
}
$query.=$report->addSqlCriteriasRestriction()."
GROUP BY `gpce`.id
ORDER BY `gpce`.`name`";
} else {
$query = "SELECT `gpce`.`name`,
`gpct`.`name` AS type,
case when `gpce`.`is_active` = TRUE then '".$LANG['creditvoucher_active'][0]."' else '".$LANG['creditvoucher_active'][1]."' end as active,
`gpce`.`begin_date`,
`gpce`.`end_date`,
`gpce`.`quantity`,
SUM(consumed) as consumed,
`gpce`.`quantity`-SUM(consumed) as rest,
`ge`.`name` as entity
FROM `glpi_plugin_credit_entities` as gpce
inner JOIN `glpi_plugin_credit_types` as gpct ON (`gpce`.`plugin_credit_types_id` = `gpct`.`id`)
left join glpi_plugin_credit_tickets as pct on (`pct`.`plugin_credit_entities_id` = `gpce`.`id`)
inner JOIN `glpi_entities` as ge ON (`gpce`.`entities_id` = `ge`.`id`)".
getEntitiesRestrictRequest(" WHERE", "gpce")."
GROUP BY `gpce`.id
ORDER BY `gpce`.`name`";
}
$report->setSqlRequest($query);
$report->execute();