diff --git a/report/creditused/creditused.en_GB.php b/report/creditused/creditused.en_GB.php new file mode 100644 index 0000000..79c11e8 --- /dev/null +++ b/report/creditused/creditused.en_GB.php @@ -0,0 +1,14 @@ +'--', 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]), + 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) { + $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(); + + diff --git a/report/creditvoucher/creditvoucher.en_GB.php b/report/creditvoucher/creditvoucher.en_GB.php new file mode 100644 index 0000000..7de6daf --- /dev/null +++ b/report/creditvoucher/creditvoucher.en_GB.php @@ -0,0 +1,13 @@ +'--', 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) { + $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(); \ No newline at end of file