├── report_page.png ├── locales ├── cs_CZ.mo ├── da_DK.mo ├── de_DE.mo ├── el_GR.mo ├── en_GB.mo ├── es_AR.mo ├── es_ES.mo ├── fi_FI.mo ├── fr_FR.mo ├── hr_HR.mo ├── it_IT.mo ├── nl_NL.mo ├── pt_BR.mo ├── ro_RO.mo ├── ru_RU.mo └── tr_TR.mo ├── tools ├── update_mo.pl ├── extract_template.sh └── HEADER ├── inc ├── columnmodeltype.class.php ├── columntypetype.class.php ├── columnhtml.class.php ├── stat.class.php ├── statuscriteria.class.php ├── suppliercriteria.class.php ├── usertitlecriteria.class.php ├── taskcategorycriteria.class.php ├── softwarecriteria.class.php ├── tickettypecriteria.class.php ├── locationcriteria.class.php ├── ticketcategorycriteria.class.php ├── usertypecriteria.class.php ├── columndate.class.php ├── report.class.php ├── columndatetime.class.php ├── softwarecategoriescriteria.class.php ├── groupcriteria.class.php ├── usercriteria.class.php ├── columntype.class.php ├── columnitemcheckbox.class.php ├── columninteger.class.php ├── requesttypecriteria.class.php ├── arraycriteria.class.php ├── columnfloat.class.php ├── columnmap.class.php ├── columntypelink.class.php ├── textcriteria.class.php ├── columndropdownlinkedtype.class.php ├── columnlink.class.php ├── columntimestamp.class.php ├── softwarewithlicensecriteria.class.php ├── itemtypecriteria.class.php ├── prioritycriteria.class.php ├── ticketstatuscriteria.class.php ├── timeintervalcriteria.class.php ├── column.class.php ├── integercriteria.class.php ├── function.php └── dateintervalcriteria.class.php ├── report ├── location │ └── location.php ├── listgroups │ └── listgroups.php ├── statusertask │ └── statusertask.php ├── licensesexpires │ └── licensesexpires.php ├── transferreditems │ └── transferreditems.php ├── statticketsbypriority │ └── statticketsbypriority.php ├── statticketsbyentity │ └── statticketsbyentity.php ├── statnightticketsbypriority │ └── statnightticketsbypriority.php ├── histoinst │ └── histoinst.php ├── searchinfocom │ └── searchinfocom.php ├── globalhisto │ └── globalhisto.php ├── softversioninstallations │ └── softversioninstallations.php ├── licenses │ └── licenses.php ├── rules │ └── rules.php ├── softnotinstalled │ └── softnotinstalled.php ├── listequipmentbylocation │ └── listequipmentbylocation.php ├── zombies │ └── zombies.php ├── applicationsbylocation │ └── applicationsbylocation.php ├── printers │ └── printers.php └── histohard │ └── histohard.php ├── hook.php ├── setup.php └── front └── report.form.php /report_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/report_page.png -------------------------------------------------------------------------------- /locales/cs_CZ.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/cs_CZ.mo -------------------------------------------------------------------------------- /locales/da_DK.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/da_DK.mo -------------------------------------------------------------------------------- /locales/de_DE.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/de_DE.mo -------------------------------------------------------------------------------- /locales/el_GR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/el_GR.mo -------------------------------------------------------------------------------- /locales/en_GB.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/en_GB.mo -------------------------------------------------------------------------------- /locales/es_AR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/es_AR.mo -------------------------------------------------------------------------------- /locales/es_ES.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/es_ES.mo -------------------------------------------------------------------------------- /locales/fi_FI.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/fi_FI.mo -------------------------------------------------------------------------------- /locales/fr_FR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/fr_FR.mo -------------------------------------------------------------------------------- /locales/hr_HR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/hr_HR.mo -------------------------------------------------------------------------------- /locales/it_IT.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/it_IT.mo -------------------------------------------------------------------------------- /locales/nl_NL.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/nl_NL.mo -------------------------------------------------------------------------------- /locales/pt_BR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/pt_BR.mo -------------------------------------------------------------------------------- /locales/ro_RO.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/ro_RO.mo -------------------------------------------------------------------------------- /locales/ru_RU.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/ru_RU.mo -------------------------------------------------------------------------------- /locales/tr_TR.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/InfotelGLPI/reports/master/locales/tr_TR.mo -------------------------------------------------------------------------------- /tools/update_mo.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | #!/usr/bin/perl -w 3 | 4 | if (@ARGV!=0){ 5 | print "USAGE update_mo.pl\n\n"; 6 | 7 | exit(); 8 | } 9 | 10 | 11 | opendir(DIRHANDLE,'locales')||die "ERROR: can not read current directory\n"; 12 | foreach (readdir(DIRHANDLE)){ 13 | if ($_ ne '..' && $_ ne '.'){ 14 | 15 | if(!(-l "$dir/$_")){ 16 | if (index($_,".po",0)==length($_)-3) { 17 | $lang=$_; 18 | $lang=~s/\.po//; 19 | 20 | `msgfmt locales/$_ -o locales/$lang.mo`; 21 | } 22 | } 23 | 24 | } 25 | } 26 | closedir DIRHANDLE; 27 | 28 | # 29 | # 30 | -------------------------------------------------------------------------------- /tools/extract_template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | soft='GLPI - Reports plugin' 4 | version='0.84' 5 | email=glpi-translation@gna.org 6 | copyright='INDEPNET Development Team' 7 | 8 | #xgettext *.php */*.php -copyright-holder='$copyright' --package-name=$soft --package-version=$version --msgid-bugs-address=$email -o locales/en_GB.po -L PHP --from-code=UTF-8 --force-po -i --keyword=_n:1,2 --keyword=__ --keyword=_e 9 | 10 | # Only strings with domain specified are extracted (use Xt args of keyword param to set number of args needed) 11 | 12 | xgettext *.php */*.php */*/*.php -o locales/glpi.pot -L PHP --add-comments=TRANS --from-code=UTF-8 --force-po \ 13 | --keyword=_n:1,2,4t --keyword=__s:1,2t --keyword=__:1,2t --keyword=_e:1,2t --keyword=_x:1c,2,3t --keyword=_ex:1c,2,3t \ 14 | --keyword=_sx:1c,2,3t --keyword=_nx:1c,2,3,5t 15 | 16 | 17 | ### for using tx : 18 | ##tx set --execute --auto-local -r GLPI_example.glpi-084-current 'locales/.po' --source-lang en --source-file locales/glpi.pot 19 | ## tx push -s 20 | ## tx pull -a 21 | 22 | 23 | -------------------------------------------------------------------------------- /tools/HEADER: -------------------------------------------------------------------------------- 1 | * @version $Id: HEADER 15930 2011-10-25 10:47:55Z jmd $ 2 | ------------------------------------------------------------------------- 3 | reports - Additional reports plugin for GLPI 4 | Copyright (C) 2003-2011 by the reports Development Team. 5 | 6 | https://forge.indepnet.net/projects/reports 7 | ------------------------------------------------------------------------- 8 | 9 | LICENSE 10 | 11 | This file is part of reports. 12 | 13 | reports is free software; you can redistribute it and/or modify 14 | it under the terms of the GNU General Public License as published by 15 | the Free Software Foundation; either version 2 of the License, or 16 | (at your option) any later version. 17 | 18 | reports is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | GNU General Public License for more details. 22 | 23 | You should have received a copy of the GNU General Public License 24 | along with reports. If not, see . 25 | -------------------------------------------------------------------------- 26 | -------------------------------------------------------------------------------- /inc/columnmodeltype.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnModelType extends PluginReportsColumnDropdownLinkedType { 36 | 37 | function __construct($nameid, $title, $nametype, $options=[]) { 38 | parent::__construct($nameid, $title, $nametype, 'Model', $options); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /inc/columntypetype.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnTypeType extends PluginReportsColumnDropdownLinkedType { 36 | 37 | function __construct($nameid, $title, $nametype, $options=[]) { 38 | parent::__construct($nameid, $title, $nametype, 'Type', $options); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /inc/columnhtml.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson 23 | @copyright Copyright (c) 2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnHtml extends PluginReportsColumn 36 | { 37 | 38 | 39 | function displayValue($output_type, $row) 40 | { 41 | 42 | if (isset($row[$this->name]) && $row[$this->name]) { 43 | return htmlspecialchars_decode($row[$this->name]); 44 | } 45 | return ''; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /inc/stat.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | class PluginReportsStat extends CommonGLPI { 33 | 34 | 35 | /** 36 | * Return the localized name of the current Type 37 | * Shoudl be overloaded in each new class 38 | * 39 | * @param $nb integer for singular / plural 40 | * 41 | * @return string 42 | **/ 43 | static function getTypeName($nb=0) { 44 | return __('Statistics'); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /inc/statuscriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Devices status selection criteria 34 | */ 35 | class PluginReportsStatusCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default 'states_id') 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name='states_id', $label='') { 44 | 45 | parent::__construct($report, $name, 'glpi_states', 46 | ($label ? $label : _n('Status', 'Statuses', 1))); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /inc/suppliercriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * User titles selection criteria 34 | */ 35 | class PluginReportsSupplierCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default 'suppliers_id') 41 | * @param $label default '') 42 | **/ 43 | function __construct($report, $name='suppliers_id', $label='') { 44 | 45 | parent::__construct($report, $name, 'glpi_suppliers', 46 | ($label ? $label : _n('Supplier', 'Suppliers', 1))); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /inc/usertitlecriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * User titles selection criteria 34 | */ 35 | class PluginReportsUserTitleCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default usertitles_id) 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name='usertitles_id', $label='') { 44 | 45 | parent :: __construct($report, $name, 'glpi_usertitles', 46 | ($label ? $label : _n('User title', 'Users titles', 1))); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /inc/taskcategorycriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Ticket category selection criteria 34 | */ 35 | class PluginReportsTaskCategoryCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default 'taskcategories_id') 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name='taskcategories_id', $label='') { 44 | 45 | parent::__construct($report, $name, 'glpi_taskcategories', 46 | ($label ? $label : __('Task category'))); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /inc/softwarecriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Software selection criteria 34 | */ 35 | class PluginReportsSoftwareCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default 'softwares_id') 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name = 'softwares_id', $label='') { 44 | 45 | parent::__construct($report, $name, 'glpi_softwares', ($label ? $label : __('Location'))); 46 | } 47 | 48 | 49 | public function setDefaultSoftware($software) { 50 | $this->addParameter($this->name, $software); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /inc/tickettypecriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Ticket category selection criteria 34 | */ 35 | class PluginReportsTicketTypeCriteria extends PluginReportsArrayCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default 'type') 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name='type', $label='') { 44 | 45 | $options = ['all' => Dropdown::EMPTY_VALUE]; 46 | foreach (Ticket::getTypes() as $k => $v) { 47 | $options[$k] = $v; 48 | } 49 | 50 | parent::__construct($report, $name, ($label ? $label : _n('Type', 'Type', 1)), $options); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /inc/locationcriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Location selection criteria 34 | */ 35 | class PluginReportsLocationCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default 'locations_id') 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name='locations_id', $label='') { 44 | 45 | parent::__construct($report, $name, 'glpi_locations', ($label ? $label : __('Location'))); 46 | } 47 | 48 | 49 | /** 50 | * @param $location 51 | **/ 52 | public function setDefaultLocation($location) { 53 | $this->addParameter($this->name, $location); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /inc/ticketcategorycriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Ticket category selection criteria 34 | */ 35 | class PluginReportsTicketCategoryCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default 'itilcategories_id') 41 | * @param $label (default '') 42 | * @param $type (default '') 43 | **/ 44 | function __construct($report, $name='itilcategories_id', $label='', $type='') { 45 | 46 | parent::__construct($report, $name, 'glpi_itilcategories', 47 | ($label ? $label : _n('Ticket category', 'Ticket categories', 1)), 48 | $type); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /inc/usertypecriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * User types selection criteria 34 | */ 35 | class PluginReportsUserTypeCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default usercategories_id) 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name='usercategories_id', $label='') { 44 | 45 | parent::__construct($report, $name, 'glpi_usercategories', 46 | ($label ? $label : sprintf(__('%1$s: %2$s'), 47 | _n('User', 'Users', 1), 48 | _n('Type', 'Types', 1)))); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /inc/columndate.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnDate extends PluginReportsColumn { 36 | 37 | function __construct($name, $title, $options=[]) { 38 | 39 | if (!isset($options['extrafine'])) { 40 | $options['extrafine'] = "class='center'"; 41 | } 42 | if (!isset($options['extrabold'])) { 43 | $options['extrabold'] = "class='b center'"; 44 | } 45 | 46 | parent::__construct($name, $title, $options); 47 | } 48 | 49 | 50 | function displayValue($output_type, $row) { 51 | 52 | if (isset($row[$this->name]) && $row[$this->name]) { 53 | return Html::convDate($row[$this->name]); 54 | } 55 | return ''; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /inc/report.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Dévi Balpe 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | class PluginReportsReport extends CommonDBTM { 33 | 34 | 35 | /** 36 | * Return the localized name of the current Type 37 | * Shoudl be overloaded in each new class 38 | * 39 | * @param $nb integer for singular / plural 40 | * 41 | * @return string 42 | */ 43 | static function getTypeName($nb=0) { 44 | return _n('Report', 'Reports', $nb); 45 | } 46 | 47 | /** 48 | * Get rights for an item _ may be overload by object 49 | * 50 | * @since version 0.85 51 | * 52 | * @param $interface string (defalt 'central') 53 | * 54 | * @return array of rights to display 55 | **/ 56 | function getRights($interface='central') { 57 | return [READ => __('Read')]; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /inc/columndatetime.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnDateTime extends PluginReportsColumn { 36 | 37 | function __construct($name, $title, $options=[]) { 38 | 39 | if (!isset($options['extrafine'])) { 40 | $options['extrafine'] = "class='center'"; 41 | } 42 | if (!isset($options['extrabold'])) { 43 | $options['extrabold'] = "class='b center'"; 44 | } 45 | 46 | parent::__construct($name, $title, $options); 47 | } 48 | 49 | 50 | function displayValue($output_type, $row) { 51 | 52 | if (isset($row[$this->name]) && $row[$this->name]) { 53 | return Html::convDateTime($row[$this->name]); 54 | } 55 | return ''; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /inc/softwarecategoriescriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * SoftwareCategories selection criteria 34 | */ 35 | class PluginReportsSoftwareCategoriesCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default 'softwarecategories_id') 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name = 'softwarecategories_id', $label='') { 44 | 45 | parent::__construct($report, $name, 'glpi_softwarecategories', 46 | ($label ? $label : -n('Software category', 'Software categories', 1))); 47 | } 48 | 49 | 50 | public function setDefaultSoftware($softwarecategories) { 51 | $this->addParameter($this->name, $softwarecategories); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /inc/groupcriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | // ---------------------------------------------------------------------- 33 | // Original Author of file: 34 | // Purpose of file: 35 | // ---------------------------------------------------------------------- 36 | 37 | /** 38 | * Group selection criteria 39 | */ 40 | class PluginReportsGroupCriteria extends PluginReportsDropdownCriteria { 41 | 42 | 43 | /** 44 | * @param $report 45 | * @param $name (default 'groups_id') 46 | * @param $label (default '') 47 | * @param $condition (default '') 48 | **/ 49 | function __construct($report, $name='groups_id', $label='', $condition='') { 50 | 51 | parent::__construct($report, $name, 'glpi_groups', ($label ? $label : __('Group')), 52 | $condition); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /inc/usercriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * User selection criteria 34 | */ 35 | class PluginReportsUserCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default user) 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name='users_id', $label='') { 44 | 45 | parent::__construct($report, $name, 'glpi_users', ($label ? $label : _n('User', 'Users', 1))); 46 | } 47 | 48 | 49 | public function displayDropdownCriteria() { 50 | 51 | User::dropdown(['name' => $this->getName(), 52 | 'value' => $this->getParameterValue(), 53 | 'right' => 'all', 54 | 'comments' => $this->getDisplayComments(), 55 | 'entity' => $this->getEntityRestrict()]); 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /inc/columntype.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnType extends PluginReportsColumn { 36 | 37 | private $obj = NULL; 38 | 39 | 40 | function __construct($name, $title, $options=[]) { 41 | parent::__construct($name, $title, $options); 42 | } 43 | 44 | 45 | function displayValue($output_type, $row) { 46 | 47 | $dbu = new DbUtils(); 48 | 49 | if (!isset($row[$this->name]) 50 | || !$row[$this->name]) { 51 | return ''; 52 | } 53 | 54 | if (!($value = $dbu->getItemForItemtype($row[$this->name]))) { 55 | return $value; 56 | } 57 | 58 | if (is_null($this->obj) 59 | || get_class($this->obj) != $row[$this->name]) { 60 | $this->obj = new $row[$this->name](); 61 | } 62 | 63 | return $this->obj->getTypeName(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /inc/columnitemcheckbox.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnItemCheckbox extends PluginReportsColumn { 36 | 37 | private $obj = NULL; 38 | private $with_comment = 0; 39 | 40 | 41 | function __construct($name, $itemtype, $options=[]) { 42 | 43 | parent::__construct($name, ' ', $options); 44 | 45 | $dbu = new DbUtils(); 46 | $this->obj = $dbu->getItemForItemtype($itemtype); 47 | } 48 | 49 | 50 | function showTitle($output_type, &$num) { 51 | 52 | echo Search::showHeaderItem($output_type, 53 | Html::getCheckAllAsCheckbox('massform'.get_class($this->obj)), $num); 54 | 55 | } 56 | 57 | 58 | function displayValue($output_type, $row) { 59 | 60 | if (!isset($row[$this->name]) || !$row[$this->name]) { 61 | return ''; 62 | } 63 | if ($this->obj 64 | && ($output_type == Search::HTML_OUTPUT) 65 | && $this->obj->can($row[$this->name], UPDATE)) { 66 | return Html::getMassiveActionCheckBox(get_class($this->obj), $row[$this->name]); 67 | } 68 | 69 | return ''; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /inc/columninteger.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnInteger extends PluginReportsColumn { 36 | 37 | private $total; 38 | private $with_zero = 1; 39 | 40 | 41 | function __construct($name, $title, $options=[]) { 42 | 43 | if (!isset($options['extrafine'])) { 44 | $options['extrafine'] = "class='right'"; 45 | } 46 | 47 | if (!isset($options['extrabold'])) { 48 | $options['extrabold'] = "class='b right'"; 49 | } 50 | 51 | if (isset($options['with_zero'])) { 52 | $this->with_zero = $options['with_zero']; 53 | } 54 | 55 | parent::__construct($name, $title, $options); 56 | 57 | $this->total = 0; 58 | } 59 | 60 | 61 | function displayValue($output_type, $row) { 62 | 63 | if (isset($row[$this->name])) { 64 | $this->total += intval($row[$this->name]); 65 | 66 | if ($row[$this->name] || $this->with_zero) { 67 | return Html::formatNumber($row[$this->name], false, 0); 68 | } 69 | } 70 | return ''; 71 | } 72 | 73 | 74 | function displayTotal($output_type) { 75 | return Html::formatNumber($this->total, false, 0); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /inc/requesttypecriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | 33 | /** 34 | * User titles selection criteria 35 | **/ 36 | class PluginReportsRequestTypeCriteria extends PluginReportsDropdownCriteria { 37 | 38 | 39 | /** 40 | * @param $report 41 | * @param $name (default 'requesttypes_id') 42 | * @param $label (default '') 43 | **/ 44 | function __construct($report, $name='requesttypes_id', $label='') { 45 | 46 | parent::__construct($report, $name, NOT_AVAILABLE, 47 | ($label ? $label : _n('Request source', 'Request sources', 1))); 48 | } 49 | 50 | 51 | //Dropdown priorities is not a generic dropdown, so the function needs to be overwritten 52 | public function displayDropdownCriteria() { 53 | 54 | Dropdown::show('RequestType', ['name' => $this->getName(), 55 | 'value' => $this->getParameterValue()]); 56 | } 57 | 58 | 59 | function getSubName() { 60 | 61 | if ($this->getParameterValue() > 0) { 62 | return " ".$this->getCriteriaLabel()." : ".getRequestTypeName($this->getParameterValue()); 63 | } 64 | } 65 | 66 | 67 | public function setDefaultValues() { 68 | $this->addParameter($this->getName(), 1); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /report/location/location.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; // not really a big SQL request 34 | 35 | global $DB; 36 | 37 | $dbu = new DbUtils(); 38 | 39 | //TRANS: The name of the report = Location tree 40 | $report = new PluginReportsAutoReport(__('location_report_title', 'reports')); 41 | 42 | $report->setColumns([new PluginReportsColumn('entity', __('Entity'), 43 | ['sorton' => 'entity,location']), 44 | new PluginReportsColumn('location', __('Location'), ['sorton' => 'location']), 45 | new PluginReportsColumnLink('link', _n('Link', 'Links', 2, 'report'), 46 | 'Location', ['sorton' => '`glpi_locations`.`name`'])]); 47 | 48 | // SQL statement 49 | $query = "SELECT `glpi_entities`.`completename` AS entity, 50 | `glpi_locations`.`completename` AS location, 51 | `glpi_locations`.`id` AS link 52 | FROM `glpi_locations` 53 | LEFT JOIN `glpi_entities` ON (`glpi_locations`.`entities_id` = `glpi_entities`.`id`)" . 54 | $dbu->getEntitiesRestrictRequest(" WHERE ", "glpi_locations") . 55 | $report->getOrderBy('entity'); 56 | 57 | $report->setGroupBy('entity'); 58 | $report->setSqlRequest($query); 59 | $report->execute(); 60 | -------------------------------------------------------------------------------- /inc/arraycriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Ticket status selection criteria 34 | */ 35 | class PluginReportsArrayCriteria extends PluginReportsDropdownCriteria { 36 | private $choice = []; 37 | 38 | function __construct($report, $name, $label='', $options=[]) { 39 | 40 | parent::__construct($report, $name, NOT_AVAILABLE, 41 | ($label ? $label : _n('Criterion', 'Criteria', 2))); 42 | $this->choice = $options; 43 | } 44 | 45 | 46 | function getSubName() { 47 | 48 | $val = $this->getParameterValue(); 49 | if (empty($val) || $val=='all') { 50 | return ''; 51 | } 52 | return " " . sprintf(__('%1$s: %2$s'), $this->getCriteriaLabel(), $this->choice[$val]); 53 | } 54 | 55 | 56 | public function displayDropdownCriteria() { 57 | 58 | Dropdown::showFromArray($this->getName(), $this->choice, 59 | ['value' => $this->getParameterValue()]); 60 | } 61 | 62 | 63 | /** 64 | * Get SQL code associated with the criteria 65 | */ 66 | public function getSqlCriteriasRestriction($link = 'AND') { 67 | 68 | $val = $this->getParameterValue(); 69 | if (empty($val) || ($val == 'all')) { 70 | return ''; 71 | } 72 | return $link . " " . $this->getSqlField() . "='$val' "; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /inc/columnfloat.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnFloat extends PluginReportsColumn { 36 | 37 | private $total; 38 | private $with_zero = 1; 39 | private $decimal = -1; 40 | 41 | 42 | function __construct($name, $title, $options=[]) { 43 | 44 | if (!isset($options['extrafine'])) { 45 | $options['extrafine'] = "class='right'"; 46 | } 47 | 48 | if (!isset($options['extrabold'])) { 49 | $options['extrabold'] = "class='b right'"; 50 | } 51 | 52 | if (isset($options['with_zero'])) { 53 | $this->with_zero = $options['with_zero']; 54 | } 55 | 56 | if (isset($options['decimal'])) { 57 | $this->decimal = $options['decimal']; 58 | } 59 | 60 | parent::__construct($name, $title, $options); 61 | 62 | $this->total = 0.0; 63 | } 64 | 65 | 66 | function displayValue($output_type, $row) { 67 | 68 | if (isset($row[$this->name])) { 69 | $this->total += floatval($row[$this->name]); 70 | 71 | if ($row[$this->name] || $this->with_zero) { 72 | return Html::formatNumber($row[$this->name], false, $this->decimal); 73 | } 74 | } 75 | return ''; 76 | } 77 | 78 | 79 | function displayTotal($output_type) { 80 | return Html::formatNumber($this->total, false, $this->decimal);; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /inc/columnmap.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnMap extends PluginReportsColumn { 36 | 37 | private $map; 38 | 39 | 40 | function __construct($name, $title, $map=[], $options=[]) { 41 | 42 | parent::__construct($name, $title, $options); 43 | 44 | if (count($map)) { 45 | $this->map = $map; 46 | } else { 47 | switch ($name) { 48 | case 'status': 49 | $this->map = Ticket::getAllStatusArray(); 50 | break; 51 | 52 | case 'impact': 53 | $this->map = getImpactLabelsArray(); 54 | break; 55 | 56 | case 'urgency': 57 | $this->map = getUrgencyLabelsArray(); 58 | break; 59 | 60 | case 'priority': 61 | $this->map = getPriorityLabelsArray(); 62 | break; 63 | 64 | case 'type': 65 | $this->map = Ticket::getTypes(); 66 | break; 67 | 68 | default: 69 | $this->map = []; 70 | } 71 | } 72 | } 73 | 74 | 75 | function displayValue($output_type, $row) { 76 | 77 | if (isset($row[$this->name])){ 78 | if (isset($this->map[$row[$this->name]])) { 79 | return $this->map[$row[$this->name]]; 80 | } 81 | return $row[$this->name]; 82 | } 83 | return ''; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /inc/columntypelink.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnTypeLink extends PluginReportsColumn { 36 | 37 | private $obj = NULL; 38 | private $with_comment = 0; 39 | private $nametype = ''; 40 | 41 | 42 | function __construct($nameid, $title, $nametype, $options=[]) { 43 | 44 | parent::__construct($nameid, $title, $options); 45 | 46 | $this->nametype = $nametype; 47 | 48 | if (isset($options['with_comment'])) { 49 | $this->with_comment = $options['with_comment']; 50 | } 51 | } 52 | 53 | 54 | function displayValue($output_type, $row) { 55 | 56 | $dbu = new DbUtils(); 57 | 58 | if (!isset($row[$this->name]) || !$row[$this->name]) { 59 | return ''; 60 | } 61 | if (isset($row[$this->nametype]) 62 | && $row[$this->nametype] 63 | && (is_null($this->obj) || $this->obj->getType()!=$row[$this->nametype])) { 64 | 65 | if (!($this->obj = $dbu->getItemForItemtype($row[$this->nametype]))) { 66 | $this->obj = NULL; 67 | } 68 | } 69 | 70 | if (!$this->obj || !$this->obj->getFromDB($row[$this->name])) { 71 | return 'ID #'.$row[$this->name]; 72 | } 73 | 74 | if ($output_type == Search::HTML_OUTPUT) { 75 | return $this->obj->getLink($this->with_comment); 76 | } 77 | 78 | return $this->obj->getNameID(); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /inc/textcriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * User titles selection criteria 34 | */ 35 | class PluginReportsTextCriteria extends PluginReportsDropdownCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default 'value') 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name='value', $label='') { 44 | 45 | parent::__construct($report, $name, NOT_AVAILABLE, ($label ? $label : __('Name'))); 46 | } 47 | 48 | 49 | function setDefaultValues() { 50 | $this->addParameter($this->getName(), ''); 51 | } 52 | 53 | 54 | function displayCriteria() { 55 | 56 | $this->getReport()->startColumn(); 57 | echo $this->getCriteriaLabel().' :'; 58 | $this->getReport()->endColumn(); 59 | 60 | $this->getReport()->startColumn(); 61 | echo ""; 62 | $this->getReport()->endColumn(); 63 | } 64 | 65 | 66 | /** 67 | * Get criteria's subtitle 68 | **/ 69 | public function getSubName() { 70 | 71 | $param = $this->getParameterValue(); 72 | if ($param) { 73 | return $this->getCriteriaLabel().' : '.$this->getParameterValue(); 74 | } 75 | return ''; 76 | } 77 | 78 | 79 | function getSqlCriteriasRestriction($link = 'AND') { 80 | 81 | $param = $this->getParameterValue(); 82 | if ($param) { 83 | return Search::makeTextCriteria($this->getSqlField(), $param, false, $link); 84 | } 85 | return ''; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /inc/columndropdownlinkedtype.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | #[AllowDynamicProperties] 36 | class PluginReportsColumnDropdownLinkedType extends PluginReportsColumn 37 | { 38 | 39 | private $obj = null; 40 | private $with_comment = 0; 41 | private $nametype = ''; 42 | private $type_suffix = ''; 43 | 44 | 45 | function __construct($nameid, $title, $nametype, $suffix = '', $options = []) 46 | { 47 | 48 | parent::__construct($nameid, $title, $options); 49 | 50 | $this->nametype = $nametype; 51 | $this->suffix = $suffix; 52 | if (isset($options['with_comment'])) { 53 | $this->with_comment = $options['with_comment']; 54 | } 55 | } 56 | 57 | 58 | function displayValue($output_type, $row) 59 | { 60 | 61 | if (!isset($row[$this->name]) || !$row[$this->name]) { 62 | return ''; 63 | } 64 | 65 | if (isset($row[$this->nametype]) 66 | && $row[$this->nametype] 67 | && (is_null($this->obj) || get_class($this->obj)!=$row[$this->nametype])) { 68 | $objname = $row[$this->nametype].$this->suffix; 69 | $this->obj = new $objname(); 70 | } 71 | 72 | if (!$this->obj || !$this->obj->getFromDB($row[$this->name])) { 73 | return $row[$this->name]; 74 | } 75 | 76 | if ($output_type == Search::HTML_OUTPUT) { 77 | return $this->obj->getLink($this->with_comment); 78 | } 79 | 80 | return $this->obj->getNameID(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /inc/columnlink.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnLink extends PluginReportsColumn 36 | { 37 | 38 | private $obj = null; 39 | private $with_comment = 0; 40 | private $with_navigate = 0; 41 | 42 | 43 | function __construct($name, $title, $itemtype, $options = []) 44 | { 45 | 46 | parent::__construct($name, $title, $options); 47 | 48 | $dbu = new DbUtils(); 49 | $this->obj = $dbu->getItemForItemtype($itemtype); 50 | 51 | if (isset($options['with_comment'])) { 52 | $this->with_comment = $options['with_comment']; 53 | } 54 | 55 | if (isset($options['with_navigate'])) { 56 | $this->with_navigate = $options['with_navigate']; 57 | Session::initNavigateListItems($this->obj->getType(), _n('Report', 'Reports', 2)); 58 | } 59 | } 60 | 61 | 62 | function displayValue($output_type, $row) 63 | { 64 | 65 | if (!isset($row[$this->name]) || !$row[$this->name]) { 66 | return ''; 67 | } 68 | 69 | if (!$this->obj || !$this->obj->getFromDB($row[$this->name])) { 70 | return $row[$this->name]; 71 | } 72 | 73 | if ($this->with_navigate) { 74 | Session::addToNavigateListItems($this->obj->getType(), $row[$this->name]); 75 | } 76 | 77 | if ($output_type == Search::HTML_OUTPUT && ($this->obj != null)) { 78 | return $this->obj->getLink([$this->with_comment]); 79 | } 80 | 81 | return $this->obj->getNameID(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /report/listgroups/listgroups.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Benoit Machiavello 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB; 36 | 37 | $dbu = new DbUtils(); 38 | 39 | //TRANS: The name of the report = List of groups and members 40 | $report = new PluginReportsAutoReport(__('listgroups_report_title', 'reports')); 41 | //$group = new GroupCriteria($report); 42 | 43 | $report->setColumns([new PluginReportsColumn('completename', __('Entity')), 44 | new PluginReportsColumnLink('groupid', __('Group'), 'Group'), 45 | new PluginReportsColumnLink('userid', __('Login'), 'User'), 46 | new PluginReportsColumn('firstname', __('First name')), 47 | new PluginReportsColumn('realname', __('Surname')), 48 | new PluginReportsColumnDateTime('last_login', __('Last login'))]); 49 | 50 | $query = "SELECT `glpi_entities`.`completename`, 51 | `glpi_groups`.`id` AS groupid, 52 | `glpi_users`.`id` AS userid, 53 | `glpi_users`.`firstname`, 54 | `glpi_users`.`realname`, 55 | `glpi_users`.`last_login` 56 | FROM `glpi_groups` 57 | LEFT JOIN `glpi_groups_users` ON (`glpi_groups_users`.`groups_id` = `glpi_groups`.`id`) 58 | LEFT JOIN `glpi_users` ON (`glpi_groups_users`.`users_id` = `glpi_users`.`id` 59 | AND `glpi_users`.`is_deleted` = '0' ) 60 | LEFT JOIN `glpi_entities` ON (`glpi_groups`.`entities_id` = `glpi_entities`.`id`)". 61 | $dbu->getEntitiesRestrictRequest(" WHERE ", "glpi_groups") ." 62 | ORDER BY `completename`, `glpi_groups`.`name`, `glpi_users`.`name`"; 63 | 64 | $report->setGroupBy(['completename', 'groupid']); 65 | $report->setSqlRequest($query); 66 | $report->execute(); 67 | -------------------------------------------------------------------------------- /hook.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | 33 | function plugin_reports_install() 34 | { 35 | global $DB; 36 | 37 | $migration = new Migration('1.15.0'); 38 | 39 | // config of doublon report is now in glpi_blacklists 40 | if ($DB->tableExists("glpi_plugin_reports_doublons_backlists")) { 41 | if ($result = $DB->request(['FROM' => 'glpi_plugin_reports_doublons_backlists'])) { 42 | if (count($result) > 0) { 43 | foreach ($result as $data) { 44 | if ($data['type'] == 1) { 45 | $type = 2; 46 | } elseif ($data['type'] == 2) { 47 | $type = 1; 48 | } else { 49 | $type = $data['type']; 50 | } 51 | $query = "INSERT INTO `glpi_blacklists` 52 | (`type`, `name`, `value`, `comment`) 53 | VALUES (".$type.", '".$data['addr']."', '".$data['addr']."', 54 | '".$data['comment']."')"; 55 | $DB->doQuery($query); 56 | } 57 | } 58 | } 59 | $migration->dropTable('glpi_plugin_reports_doublons_backlists'); 60 | } 61 | 62 | // No autoload when plugin is not activated 63 | include_once(Plugin::getPhpDir('reports')."/inc/profile.class.php"); 64 | 65 | PluginReportsProfile::install($migration); 66 | 67 | $migration->executeMigration(); 68 | 69 | return true; 70 | } 71 | 72 | 73 | function plugin_reports_uninstall() 74 | { 75 | 76 | $migration = new Migration('1.15.0'); 77 | 78 | // No autoload when plugin is not activated (if dessactivation before uninstall) 79 | include_once(Plugin::getPhpDir('reports')."/inc/profile.class.php"); 80 | 81 | return PluginReportsProfile::uninstall($migration); 82 | 83 | $migration->executeMigration(); 84 | 85 | return true; 86 | } 87 | -------------------------------------------------------------------------------- /inc/columntimestamp.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumnTimestamp extends PluginReportsColumn { 36 | 37 | private $total; 38 | private $withsec; 39 | 40 | 41 | function __construct($name, $title, $options=[]) { 42 | 43 | if (!isset($options['extrafine'])) { 44 | $options['extrafine'] = "class='right'"; 45 | } 46 | 47 | if (!isset($options['extrabold'])) { 48 | $options['extrabold'] = "class='b right'"; 49 | } 50 | 51 | if (!isset($options['export_timestamp'])) { 52 | $options['export_timestamp'] = false; 53 | } 54 | // Export with timestamp 55 | $this->export_timestamp = (isset($options['export_timestamp']) ? $options['export_timestamp'] : false); 56 | // Always display sec ? 57 | $this->withsec = (isset($options['withsec']) ? $options['withsec'] : false); 58 | 59 | parent::__construct($name, $title, $options); 60 | 61 | $this->total = 0; 62 | } 63 | 64 | 65 | function displayValue($output_type, $row) { 66 | 67 | if ($this->export_timestamp) { 68 | if (isset($row[$this->name])) { 69 | if ($output_type == Search::HTML_OUTPUT) { 70 | 71 | $this->total += intval($row[$this->name]); 72 | return Html::timestampToString($row[$this->name], $this->withsec); 73 | 74 | } 75 | $this->total += intval($row[$this->name]); 76 | return $row[$this->name]; 77 | } 78 | 79 | } elseif (isset($row[$this->name])) { 80 | 81 | $this->total += intval($row[$this->name]); 82 | return Html::timestampToString($row[$this->name], $this->withsec); 83 | } 84 | return ''; 85 | } 86 | 87 | 88 | function displayTotal($output_type) { 89 | if ($this->export_timestamp) { 90 | return $this->total; 91 | } 92 | return Html::timestampToString($this->total, $this->withsec); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /inc/softwarewithlicensecriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Dropdown for softwares with license 34 | */ 35 | class PluginReportsSoftwareWithLicenseCriteria extends PluginReportsDropdownCriteria 36 | { 37 | 38 | 39 | /** 40 | * @param $report 41 | * @param $name (default 'softwares_id') 42 | * @param $label (default '') 43 | **/ 44 | function __construct($report, $name = 'softwares_id', $label = '') 45 | { 46 | 47 | parent::__construct( 48 | $report, 49 | $name, 50 | 'glpi_softwares', 51 | ($label ? $label : _n('Software', 'Software', 1)) 52 | ); 53 | } 54 | 55 | 56 | function displayDropdownCriteria() 57 | { 58 | global $DB; 59 | 60 | $query = "SELECT `glpi_softwares`.`name`, `glpi_softwares`.`id` 61 | FROM `glpi_softwarelicenses` 62 | LEFT JOIN `glpi_softwares` 63 | ON `glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id` 64 | LEFT JOIN `glpi_entities` 65 | ON (`glpi_softwares`.`entities_id` = `glpi_entities`.`id`) 66 | WHERE `glpi_softwarelicenses`.`entities_id` 67 | IN (" . $_SESSION['glpiactiveentities_string'] . ") 68 | GROUP BY `glpi_softwares`.`name`"; 69 | $result = $DB->doQuery($query); 70 | 71 | if ($DB->numrows($result)) { 72 | echo ""; 82 | } else { 83 | echo "".__('No item found').""; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /inc/itemtypecriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | 33 | /** 34 | * Ticket status selection criteria 35 | */ 36 | class PluginReportsItemTypeCriteria extends PluginReportsDropdownCriteria { 37 | 38 | private $types = []; 39 | 40 | 41 | /** 42 | * @param $report 43 | * @param $name (default 'itemtype') 44 | * @param $label (default '') 45 | * @param $types array 46 | * @param $ignored array 47 | **/ 48 | function __construct($report, $name='itemtype', $label='', $types=[], $ignored=[]) { 49 | global $CFG_GLPI; 50 | 51 | parent::__construct($report, $name, NOT_AVAILABLE, ($label ? $label : __('Item type'))); 52 | 53 | $dbu = new DbUtils(); 54 | 55 | if (is_array($types) && count($types)) { 56 | // $types is an hashtable of itemtype => display name 57 | $this->types = $types; 58 | } else if (is_string($types) && isset($CFG_GLPI[$types])) { 59 | // $types is the name of an configured type hashtable (infocom_types, doc_types, ...) 60 | foreach($CFG_GLPI[$types] as $itemtype) { 61 | if (($item = $dbu->getItemForItemtype($itemtype)) && !in_array($itemtype, $ignored)) { 62 | $this->types[$itemtype] = $item->getTypeName(); 63 | } 64 | } 65 | $this->types['all'] = __('All'); 66 | } else { 67 | // No types, use helpdesk_types 68 | $this->types = Ticket::getAllTypesForHelpdesk(); 69 | $this->types['all'] = __('All'); 70 | } 71 | } 72 | 73 | 74 | function getSubName() { 75 | 76 | $dbu = new DbUtils(); 77 | $itemtype = $this->getParameterValue(); 78 | if ($itemtype && ($item = $dbu->getItemForItemtype($itemtype))) { 79 | $name = $item->getTypeName(); 80 | } else { 81 | // All 82 | return ''; 83 | } 84 | return " " . $this->getCriteriaLabel() . " : " . $name; 85 | } 86 | 87 | 88 | public function displayDropdownCriteria() { 89 | ksort($this->types); 90 | 91 | Dropdown::showFromArray($this->getName(), $this->types, 92 | ['value'=> $this->getParameterValue()]); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /report/statusertask/statusertask.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 1; 34 | 35 | global $DB; 36 | 37 | //titre du rapport dans la liste de selection, soit en dur ici, soit mettre à jour la variable dans les fichiers de traduction; 38 | $report = new PluginReportsAutoReport(__('statusertask_report_title', 'reports')); 39 | 40 | //critère de selection; 41 | $date = new PluginReportsDateIntervalCriteria($report, '`glpi_tickettasks`.`date`', __('Tasks created', 'reports')); 42 | 43 | $report->displayCriteriasForm(); 44 | 45 | $display_type = Search::HTML_OUTPUT; 46 | 47 | if ($report->criteriasValidated()) { 48 | // $report->setSubNameAuto(); 49 | // $title = $report->getFullTitle(); 50 | 51 | $cols = [new PluginReportsColumn('realname', __('User')), 52 | new PluginReportsColumn('date', __('Date')), 53 | new PluginReportsColumn('ticketid', __('Ticket task id')), 54 | new PluginReportsColumn('duree', __('Duration')), 55 | new PluginReportsColumn('nbretask', __('Number created tasks', 'reports')), 56 | new PluginReportsColumn('total', __('Total duration'))]; 57 | 58 | $report->setColumns($cols); 59 | 60 | 61 | $query = "SELECT DATE_FORMAT(`glpi_tickettasks`.`date`, '%d/%m/%Y') AS date, 62 | `glpi_users`.`realname`, 63 | `glpi_tickettasks`.`id` AS ticketid, 64 | SEC_TO_TIME( sum( glpi_tickettasks.actiontime ) ) AS duree, 65 | count(`glpi_tickettasks`.`tickets_id` ) AS nbretask, 66 | (SELECT SEC_TO_TIME(sum(glpi_tickettasks.actiontime )) 67 | FROM `glpi_tickettasks` 68 | INNER JOIN `glpi_users` ON (`glpi_tickettasks`.`users_id` = `glpi_users`.`id`) 69 | WHERE `glpi_users`.`id` =".Session::getLoginUserID(false) ." ". 70 | $date->getSqlCriteriasRestriction()." ) as total 71 | FROM `glpi_tickettasks` 72 | INNER JOIN `glpi_users` ON (`glpi_tickettasks`.`users_id` = `glpi_users`.`id`) 73 | WHERE `glpi_users`.`id` = ".Session::getLoginUserID(false) ." ". 74 | $date->getSqlCriteriasRestriction()." 75 | GROUP BY date, realname, ticketid"; 76 | 77 | $report->setSqlRequest($query); 78 | $report->setGroupBy('RTOTAL'); 79 | 80 | $report->execute(); 81 | } else { 82 | Html::footer(); 83 | } 84 | -------------------------------------------------------------------------------- /report/licensesexpires/licensesexpires.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB; 36 | $dbu = new DbUtils(); 37 | 38 | //TRANS: The name of the report = Licenses by expiration date 39 | $report = new PluginReportsAutoReport(__('licensesexpires_report_title', 'reports')); 40 | 41 | $report->setColumns(['expire' => __('Valid to', 'reports'), 42 | 'name' => __('License name'), 43 | 'software' => sprintf(__('%1$s - %2$s'), _n('Software', 'Software', 1), 44 | __('Purchase version')), 45 | 'serial' => __('Serial number'), 46 | 'completename' => __('Entity'), 47 | 'comments' => __('Comments'), 48 | 'ordinateur' => __('Computer')]); 49 | 50 | $query = "SELECT `glpi_softwarelicenses`.`expire`, 51 | `glpi_softwarelicenses`.`name`, 52 | CONCAT(`glpi_softwares`.`name`,' - ',buyversion.`name`) AS software, 53 | `glpi_softwarelicenses`.`serial`, 54 | `glpi_entities`.`completename`, 55 | `glpi_softwarelicenses`.`comment`, 56 | `glpi_computers`.`name` AS ordinateur 57 | FROM `glpi_softwarelicenses` 58 | LEFT JOIN `glpi_softwares` 59 | ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`) 60 | LEFT JOIN `glpi_softwarelicensetypes` 61 | ON (`glpi_softwarelicensetypes`.`id`=`glpi_softwarelicenses`.`softwarelicensetypes_id`) 62 | LEFT JOIN `glpi_softwareversions` AS buyversion 63 | ON (buyversion.`id` = `glpi_softwarelicenses`.`softwareversions_id_buy`) 64 | LEFT JOIN `glpi_entities` 65 | ON (`glpi_softwares`.`entities_id` = `glpi_entities`.`id`) 66 | LEFT JOIN `glpi_items_softwarelicenses` 67 | ON (`glpi_softwarelicenses`.`id` = `glpi_items_softwarelicenses`.`softwarelicenses_id`) 68 | LEFT JOIN `glpi_computers` 69 | ON (`glpi_computers`.`id` = `glpi_items_softwarelicenses`.`items_id` 70 | AND `glpi_items_softwarelicenses`.`itemtype` = 'Computer') 71 | WHERE `glpi_softwares`.`is_deleted` = '0' 72 | AND `glpi_softwares`.`is_template` = '0' " . 73 | $dbu->getEntitiesRestrictRequest(' AND ', 'glpi_softwarelicenses') ." 74 | ORDER BY `glpi_softwarelicenses`.`expire`, `name`"; 75 | 76 | $report->setGroupBy(['expire', 'name']); 77 | $report->setSqlRequest($query); 78 | $report->execute(); 79 | -------------------------------------------------------------------------------- /report/transferreditems/transferreditems.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Stéphane Savona 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | 33 | $USEDBREPLICATE = 1; 34 | $DBCONNECION_REQUIRED = 0; 35 | 36 | include("../../../../inc/includes.php"); 37 | 38 | $dbu = new DbUtils(); 39 | 40 | //TRANS: The name of the report = List of transfered objects 41 | $report= new PluginReportsAutoReport(__('transferreditems_report_title', 'reports')); 42 | 43 | // Search criterias 44 | new PluginReportsDateIntervalCriteria($report, "`glpi_logs`.`date_mod`"); 45 | 46 | $types = []; 47 | foreach (['CartridgeItem', 'Computer', 'Enclosure', 'Monitor', 'NetworkEquipment', 48 | 'PassiveDCEquipment', 'PDU', 'Peripheral', 'Phone', 'Printer', 'Rack', 'Software', 49 | 'SoftwareLicense'] as $type) { 50 | $label = call_user_func([$type, 'getTypeName']); 51 | $types[$type] = $label; 52 | } 53 | 54 | ksort($types); 55 | $typecritera = new PluginReportsItemTypeCriteria($report, "itemtype", __('Type'), $types); 56 | 57 | $report->displayCriteriasForm(); 58 | 59 | // Declare columns 60 | if($report->criteriasValidated()) { 61 | $itemtype = $_POST['itemtype']; 62 | $table = $dbu->getTableForItemType($itemtype); 63 | 64 | $columns = [new PluginReportsColumnLink('items_id', __('Name'), $itemtype, 65 | ['with_comment' => 1]), 66 | new PluginReportsColumn('otherserial', __('Inventory number')), 67 | new PluginReportsColumn('old_value', __('Source entity', 'reports')), 68 | new PluginReportsColumn('new_value', __('Target entity', 'reports')), 69 | new PluginReportsColumnDateTime('date_mod', __('Transfert date', 'reports'))]; 70 | $report->setColumns($columns); 71 | 72 | $otherserial = ''; 73 | if (($itemtype != 'CartridgeItem') 74 | && ($itemtype != 'ConsumableItem')) { 75 | $otherserial = "`$table`.`otherserial`,"; 76 | } 77 | $query = "SELECT `$table`.`id` as `items_id`, 78 | `$table`.`name`, 79 | $otherserial 80 | `glpi_logs`.`date_mod` as `date_mod`, 81 | `glpi_logs`.`itemtype` as `itemtype`, 82 | `glpi_logs`.`old_value`, 83 | `glpi_logs`.`new_value` 84 | FROM `$table`, `glpi_logs` ". 85 | $report->addSqlCriteriasRestriction("WHERE")." 86 | AND `glpi_logs`.`items_id` = `$table`.`id` 87 | AND `glpi_logs`.`itemtype` = '$itemtype' 88 | AND `glpi_logs`.`id_search_option`='80' 89 | ORDER BY `date_mod` ASC"; 90 | 91 | $report->setSqlRequest($query); 92 | $report->execute(); 93 | } else { 94 | Html::footer(); 95 | } 96 | -------------------------------------------------------------------------------- /report/statticketsbypriority/statticketsbypriority.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB; 36 | 37 | $dbu = new DbUtils(); 38 | 39 | //TRANS: The name of the report = Tickets no closed, sorted by priority 40 | $report = new PluginReportsAutoReport(__('statticketsbypriority_report_title', 'reports')); 41 | 42 | //Report's search criterias 43 | new PluginReportsDateIntervalCriteria($report, '`glpi_tickets`.`date`', __('Opening date')); 44 | new PluginReportsTicketStatusCriteria($report); 45 | 46 | //Display criterias form is needed 47 | $report->displayCriteriasForm(); 48 | 49 | //If criterias have been validated 50 | if ($report->criteriasValidated()) { 51 | $report->setSubNameAuto(); 52 | 53 | //Names of the columns to be displayed 54 | $report->setColumns([new PluginReportsColumnMap('priority', __('Priority'), [], 55 | ['sorton' => '`priority`, `date`']), 56 | new PluginReportsColumnDateTime('date', __('Opening date'), 57 | ['sorton' => '`date`']), 58 | new PluginReportsColumn('id2', __('ID')), 59 | new PluginReportsColumnLink('id', __('Title'), 'Ticket'), 60 | new PluginReportsColumn('groupname', __('Assigned to groups'), 61 | ['sorton' => '`glpi_groups_tickets`.`groups_id`, `date`'])]); 62 | 63 | $query = "SELECT `glpi_tickets`.`priority`, DATE(`glpi_tickets`.`date`) AS date, 64 | `glpi_tickets`.`id`, `glpi_tickets`.`id` AS id2, 65 | `glpi_groups`.`name` AS groupname 66 | FROM `glpi_tickets` 67 | LEFT JOIN `glpi_groups_tickets` 68 | ON (`glpi_groups_tickets`.`tickets_id` = `glpi_tickets`.`id` 69 | AND `glpi_groups_tickets`.`type` = '".CommonITILActor::ASSIGN."') 70 | LEFT JOIN `glpi_groups` ON (`glpi_groups_tickets`.`groups_id` = `glpi_groups`.`id`) 71 | WHERE `glpi_tickets`.`status` NOT IN ('".implode("', '", 72 | array_merge(Ticket::getSolvedStatusArray(), 73 | Ticket::getClosedStatusArray()))."') 74 | AND NOT `glpi_tickets`.`is_deleted` ". 75 | $report->addSqlCriteriasRestriction() . 76 | $dbu->getEntitiesRestrictRequest(' AND ', 'glpi_tickets'). 77 | $report->getOrderBy('priority'); 78 | 79 | $report->setSqlRequest($query); 80 | $report->execute(); 81 | 82 | } else { 83 | Html::footer(); 84 | } 85 | -------------------------------------------------------------------------------- /inc/prioritycriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | // ---------------------------------------------------------------------- 33 | // Original Author of file: 34 | // Purpose of file: 35 | // ---------------------------------------------------------------------- 36 | 37 | /** 38 | * Priority selection criteria 39 | **/ 40 | class PluginReportsPriorityCriteria extends PluginReportsAutoCriteria { 41 | 42 | 43 | /** 44 | * @param $report 45 | * @param $name (default 'priority') 46 | * @param $label (default '') 47 | **/ 48 | function __construct($report, $name='priority', $label='') { 49 | 50 | parent::__construct($report, $name, $name, ($label ? $label : __('Priority'))); 51 | } 52 | 53 | 54 | public function setDefaultValues() { 55 | $this->addParameter($this->getName(), 1); 56 | } 57 | 58 | 59 | public function displayCriteria() { 60 | 61 | $this->getReport()->startColumn(); 62 | echo $this->getCriteriaLabel().' :'; 63 | $this->getReport()->endColumn(); 64 | 65 | $this->getReport()->startColumn(); 66 | Ticket::dropdownPriority($this->getName(), $this->getParameterValue(), 1); 67 | $this->getReport()->endColumn(); 68 | } 69 | 70 | 71 | function getSubName() { 72 | 73 | if (!$this->getParameterValue()) { 74 | $priority = __('All'); 75 | 76 | } else { 77 | if ($this->getParameterValue() < 0) { 78 | $priority = sprintf(__('%1$s %2$s'), __('At least', 'reports'), 79 | Ticket::getPriorityName(abs($this->getParameterValue()))); 80 | } else { 81 | $priority = Ticket::getPriorityName($this->getParameterValue()); 82 | } 83 | } 84 | return " " . $this->getCriteriaLabel() . " : " . $priority; 85 | } 86 | 87 | 88 | /** 89 | * @param $priority 90 | **/ 91 | function setDefaultPriorityValue($priority) { 92 | $this->addParameter($this->getName(), $priority); 93 | } 94 | 95 | 96 | /** 97 | * @see plugins/reports/inc/PluginReportsAutoCriteria::getSqlCriteriasRestriction() 98 | */ 99 | public function getSqlCriteriasRestriction($link='AND') { 100 | //If value > 0 : a priority is selected 101 | //If value == 0 : no priority selected 102 | //If value < 0 : means "priority above the priority selected" 103 | 104 | if ($this->getParameterValue() > 0) { 105 | return $link . " " . $this->getSqlField() . "= '" . $this->getParameterValue() . "'"; 106 | } 107 | 108 | if ($this->getParameterValue() < 0) { 109 | return $link . " " . $this->getSqlField() . ">= '" . abs($this->getParameterValue()) ."'"; 110 | } 111 | } 112 | 113 | } 114 | -------------------------------------------------------------------------------- /report/statticketsbyentity/statticketsbyentity.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | // Options for GLPI 0.71 and newer : need slave db to access the report 33 | $USEDBREPLICATE = 1; 34 | $DBCONNECTION_REQUIRED = 1; 35 | 36 | // Initialization of the variables 37 | global $DB; 38 | 39 | $dbu = new DbUtils(); 40 | 41 | //TRANS: The name of the report = Helpdesk requesters and tickets by entity 42 | $report = new PluginReportsAutoReport(__('statticketsbyentity_report_title', 'reports')); 43 | 44 | //Report's search criterias 45 | $prof = new PluginReportsDropdownCriteria($report, 'profiles_id', 'glpi_profiles', 46 | __('Profile')); 47 | 48 | //Display criterias form is needed 49 | $report->displayCriteriasForm(); 50 | 51 | //If criterias have been validated 52 | if ($report->criteriasValidated()) { 53 | $report->setSubNameAuto(); 54 | 55 | //Names of the columns to be displayed 56 | $cols = [new PluginReportsColumn('name', __('Entity'), 57 | ['sorton' => '`glpi_entities`.`completename`']), 58 | new PluginReportsColumnInteger('nbusers', __('Users count', 'reports'), 59 | ['withtotal' => true, 60 | 'sorton' => 'nbusers']), 61 | new PluginReportsColumnInteger('number', __('Tickets count', 'reports'), 62 | ['withtotal' => true, 63 | 'sorton' => 'number']), 64 | new PluginReportsColumnDateTime('mindate', __('Older', 'reports'), 65 | ['sorton' => 'mindate']), 66 | new PluginReportsColumnDateTime('maxdate', __('Newer', 'reports'), 67 | ['sorton' => 'maxdate'])]; 68 | $report->setColumns($cols); 69 | 70 | 71 | $subcpt = "SELECT COUNT(*) 72 | FROM `glpi_profiles_users` 73 | WHERE `glpi_profiles_users`.`entities_id` = `glpi_entities`.`id` ". 74 | $prof->getSqlCriteriasRestriction(); 75 | 76 | $query = "SELECT `glpi_entities`.`completename` AS name, 77 | ($subcpt) as nbusers, 78 | COUNT(`glpi_tickets`.`id`) AS number, 79 | MIN(`glpi_tickets`.`date`) as mindate, 80 | MAX(`glpi_tickets`.`date`) as maxdate 81 | FROM `glpi_entities` 82 | INNER JOIN `glpi_tickets` ON (`glpi_tickets`.`entities_id`=`glpi_entities`.`id`) 83 | WHERE NOT `glpi_tickets`.`is_deleted` ". 84 | $dbu->getEntitiesRestrictRequest('AND', "glpi_entities") . 85 | "GROUP BY `glpi_entities`.`id`". 86 | $report->getOrderBy('name'); 87 | 88 | $report->setSqlRequest($query); 89 | $report->execute(['withtotal' => true]); 90 | 91 | } else { 92 | Html::footer(); 93 | } 94 | -------------------------------------------------------------------------------- /report/statnightticketsbypriority/statnightticketsbypriority.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Benoit Machiavello 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB, $CFG_GLPI; 36 | 37 | $dbu = new DbUtils(); 38 | 39 | //TRANS: The name of the report = Tickets opened at night, sorted by priority 40 | $report = new PluginReportsAutoReport(__('statnightticketsbypriority_report_title', 'reports')); 41 | 42 | //Report's search criterias 43 | new PluginReportsDateIntervalCriteria($report, '`glpi_tickets`.`date`', __('Opening date')); 44 | 45 | $timeInterval = new PluginReportsTimeIntervalCriteria($report, '`glpi_tickets`.`date`'); 46 | 47 | //Criterias default values 48 | $timeInterval->setStartTime($CFG_GLPI['planning_end']); 49 | $timeInterval->setEndtime($CFG_GLPI['planning_begin']); 50 | 51 | //Display criterias form is needed 52 | $report->displayCriteriasForm(); 53 | 54 | //If criterias have been validated 55 | if ($report->criteriasValidated()) { 56 | $report->setSubNameAuto(); 57 | 58 | //Names of the columns to be displayed 59 | $report->setColumns([new PluginReportsColumnMap('priority', __('Priority'), [], 60 | ['sorton' => '`priority`, `date`']), 61 | new PluginReportsColumnDateTime('date', __('Opening date'), 62 | ['sorton' => '`date`']), 63 | new PluginReportsColumn('id2', __('ID')), 64 | new PluginReportsColumnLink('id', __('Title'), 'Ticket'), 65 | new PluginReportsColumn('groupname', __('Group'), 66 | ['sorton' => '`glpi_groups_tickets`.`groups_id`, `date`'])]); 67 | 68 | $query = "SELECT `glpi_tickets`.`priority`, `glpi_tickets`.`date` , `glpi_tickets`.`id`, 69 | `glpi_tickets`.`id` AS id2, `glpi_groups`.`name` as groupname 70 | FROM `glpi_tickets` 71 | LEFT JOIN `glpi_groups_tickets` 72 | ON (`glpi_groups_tickets`.`tickets_id` = `glpi_tickets`.`id` 73 | AND `glpi_groups_tickets`.`type` = '".CommonITILActor::ASSIGN."') 74 | LEFT JOIN `glpi_groups` ON (`glpi_groups_tickets`.`groups_id` = `glpi_groups`.`id`) 75 | WHERE `glpi_tickets`.`status` NOT IN ('".implode("', '", 76 | array_merge(Ticket::getSolvedStatusArray(), 77 | Ticket::getClosedStatusArray()))."') 78 | AND NOT `glpi_tickets`.`is_deleted` ". 79 | $report->addSqlCriteriasRestriction() . 80 | $dbu->getEntitiesRestrictRequest(' AND ', 'glpi_tickets'). 81 | $report->getOrderBy('priority'); 82 | 83 | $report->setSqlRequest($query); 84 | $report->execute(); 85 | } else { 86 | Html::footer(); 87 | } 88 | -------------------------------------------------------------------------------- /report/histoinst/histoinst.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 1; // Really a big SQL request 34 | 35 | global $DB; 36 | 37 | includeLocales("histoinst"); 38 | 39 | Session::checkRight("plugin_reports_histoinst", READ); 40 | $computer = new Computer(); 41 | $computer->checkGlobal(READ); 42 | $software = new Software(); 43 | $software->checkGlobal(READ); 44 | 45 | //TRANS: The name of the report = History of last software's installations 46 | Html::header(__('histoinst_report_title', 'reports'), $_SERVER['PHP_SELF'], "utils", "report"); 47 | 48 | Report::title(); 49 | 50 | echo "
"; 51 | echo "\n"; 52 | echo "". 53 | "\n"; 55 | 56 | echo "" . 57 | "". 58 | "". 59 | "\n"; 60 | 61 | $sql = "SELECT `glpi_logs`.`date_mod` AS dat, `linked_action`, `itemtype`, `itemtype_link`, 62 | `old_value`, `new_value`, `glpi_computers`.`id` AS cid, `name`, `user_name`, 63 | `items_id`, `entities_id` 64 | FROM `glpi_logs` 65 | LEFT JOIN `glpi_computers` ON (`glpi_logs`.`items_id` = `glpi_computers`.`id`) 66 | WHERE `glpi_logs`.`date_mod` > DATE_SUB(Now(), INTERVAL 21 DAY) 67 | AND `itemtype` = 'Computer' 68 | AND `linked_action` = '" .Log::HISTORY_INSTALL_SOFTWARE ."' 69 | AND `entities_id` = '" . $_SESSION["glpiactive_entity"] ."' 70 | ORDER BY `glpi_logs`.`id` DESC 71 | LIMIT 0,200"; 72 | 73 | $result = $DB->doQuery($sql); 74 | 75 | $prev = ""; 76 | $class = "tab_bg_2"; 77 | foreach ($result as $data) { 78 | if (empty($data["name"])) { 79 | $data["name"] = "(".$data["cid"].")"; 80 | } 81 | if ($prev == $data["dat"].$data["name"]) { 82 | echo "
"; 83 | } else { 84 | if (!empty($prev)) { 85 | echo "\n"; 86 | } 87 | $prev = $data["dat"].$data["name"]; 88 | echo "". 89 | "" . 90 | "". 91 | "". 93 | "\n"; 101 | } 102 | echo "
" . __("History of last software's installations", "reports") . 54 | "
". __('Update date') . "". __('User') . "". __("Computer's name") . "". sprintf(__('%1$s (%2$s)'), _n('Software', 'Software', 1), __('version'))."
". Html::convDateTime($data["dat"]) . "". $data["user_name"] . " " . 92 | $data["name"] . ""; 94 | $class = ($class=="tab_bg_2" ? "tab_bg_1" : "tab_bg_2"); 95 | } 96 | echo $data["new_value"]; 97 | } 98 | 99 | if (!empty($prev)) { 100 | echo "

". __('The list is limited to 200 items and 21 days', 'reports')."

\n"; 103 | 104 | Html::footer(); 105 | -------------------------------------------------------------------------------- /setup.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | include_once(Plugin::getPhpDir('reports')."/inc/function.php"); 33 | 34 | define("REPORTS_NO_ENTITY_RESTRICTION", 0); 35 | define("REPORTS_CURRENT_ENTITY", 1); 36 | define("REPORTS_SUB_ENTITIES", 2); 37 | 38 | 39 | function plugin_init_reports() 40 | { 41 | global $PLUGIN_HOOKS, $LANG; 42 | 43 | $PLUGIN_HOOKS['csrf_compliant']['reports'] = true; 44 | 45 | $plugin = new plugin; 46 | 47 | //Define only for bookmarks 48 | Plugin::registerClass('PluginReportsReport'); 49 | 50 | Plugin::registerClass('PluginReportsStat'); 51 | 52 | Plugin::registerClass('PluginReportsProfile', ['addtabon' => ['Profile']]); 53 | 54 | if (Session::haveRight("config", UPDATE)) { 55 | $PLUGIN_HOOKS['config_page']['reports'] = 'front/report.form.php'; 56 | } 57 | 58 | $PLUGIN_HOOKS['menu_entry']['reports'] = false; 59 | 60 | $rightreport = []; 61 | $rightstats = []; 62 | 63 | foreach (searchReport() as $report => $plug) { 64 | $field = 'plugin_reports_'.$report; 65 | if ($plug != 'reports') { 66 | $field = 'plugin_reports_'.$plug."_".$report; 67 | } 68 | if (Session::haveRight($field, READ)) { 69 | $tmp = $LANG["plugin_$plug"][$report]; 70 | //If the report's name contains 'stat' then display it in the statistics page 71 | //(instead of Report page) 72 | if (isStat($report)) { 73 | if (!isset($PLUGIN_HOOKS['stats'][$plug])) { 74 | $PLUGIN_HOOKS['stats'][$plug] = []; 75 | } 76 | $PLUGIN_HOOKS['stats'][$plug]["report/$report/$report.php"] = $tmp; 77 | } else { 78 | if (!isset($PLUGIN_HOOKS['reports'][$plug])) { 79 | $PLUGIN_HOOKS['reports'][$plug] = []; 80 | } 81 | $PLUGIN_HOOKS['reports'][$plug]["report/$report/$report.php"] = $tmp; 82 | } 83 | } 84 | } 85 | } 86 | 87 | 88 | /** 89 | * Indicate if the report must be displayed in reports or statistics menu 90 | * @param $report_name string name of the report 91 | * @return false if it's a stat, false if it's a report 92 | */ 93 | function isStat($report_name) 94 | { 95 | 96 | if (strpos($report_name, 'stat') !== false) { 97 | return true; 98 | } 99 | return false; 100 | } 101 | 102 | 103 | function plugin_version_reports() 104 | { 105 | 106 | return ['name' => _n('Report', 'Reports', 2), 107 | 'version' => '2.0.0', 108 | 'author' => 'Nelly Mahu-Lasson, Remi Collet, Infotel', 109 | 'license' => 'GPLv3+', 110 | 'homepage' => 'https://github.com/InfotelGLPI/reports', 111 | 'minGlpiVersion' => '11.0.0', 112 | 'requirements' => ['glpi' => ['min' => '11.0.0', 113 | 'max' => '12.0.0']]]; 114 | } 115 | -------------------------------------------------------------------------------- /report/searchinfocom/searchinfocom.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB; 36 | 37 | $dbu = new DbUtils(); 38 | 39 | //TRANS: The name of the report = Search in the financial information (plural) 40 | $report = new PluginReportsAutoReport(__('searchinfocom_report_title', 'reports')); 41 | 42 | //Report's search criterias 43 | new PluginReportsDateIntervalCriteria($report, 'order_date', __('Order date')); 44 | new PluginReportsDateIntervalCriteria($report, 'buy_date', __('Date of purchase')); 45 | new PluginReportsDateIntervalCriteria($report, 'delivery_date', __('Delivery date')); 46 | new PluginReportsDateIntervalCriteria($report, 'use_date', __('Startup date')); 47 | new PluginReportsDateIntervalCriteria($report, 'inventory_date', __('Date of last physical inventory')); 48 | new PluginReportsTextCriteria($report, 'immo_number', __('Immobilization number')); 49 | new PluginReportsTextCriteria($report, 'order_number', __('Order number')); 50 | new PluginReportsTextCriteria($report, 'delivery_number', __('Delivery form')); 51 | new PluginReportsDropdownCriteria($report, 'budgets_id', 'glpi_budgets', __('Budget')); 52 | 53 | //Display criterias form is needed 54 | $report->displayCriteriasForm(); 55 | 56 | //If criterias have been validated 57 | if ($report->criteriasValidated()) { 58 | 59 | // Report title 60 | $report->setSubNameAuto(); 61 | 62 | // Report Columns 63 | $cols = [new PluginReportsColumnType('itemtype', __('Type')), 64 | new PluginReportsColumnTypeLink('items_id', __('Item'), 'itemtype', 65 | ['with_comment' => 1]), 66 | new PluginReportsColumnDate('order_date', __('Order date')), 67 | new PluginReportsColumn('order_number', __('Order number')), 68 | new PluginReportsColumnDate('buy_date', __('Date of purchase')), 69 | new PluginReportsColumn('delivery_date', __('Delivery date')), 70 | new PluginReportsColumn('delivery_number', __('Delivery form')), 71 | new PluginReportsColumn('immo_number', __('Immobilization number')), 72 | new PluginReportsColumnDate('use_date', __('Startup date')), 73 | new PluginReportsColumnDate('inventory_date', __('Date of last physical inventory')), 74 | new PluginReportsColumnLink('budgets_id', __('Budget'), 'Budget')]; 75 | 76 | $report->setColumns($cols); 77 | 78 | // Build SQL request 79 | $sql = "SELECT * 80 | FROM `glpi_infocoms` 81 | WHERE `itemtype` NOT IN ('Cartridge', 'CartridgeItem', 'Consumable', 'ConsumableItem', 82 | 'Software', 'Line', 'Certificate', 'Appliance', 'Domain', 83 | 'Item_DeviceSimcard', 'SoftwareLicense')". 84 | $report->addSqlCriteriasRestriction(). 85 | $dbu->getEntitiesRestrictRequest('AND', 'glpi_infocoms'). 86 | "ORDER BY `itemtype`"; 87 | 88 | $report->setGroupBy('itemtype'); 89 | $report->setSqlRequest($sql); 90 | $report->execute(); 91 | 92 | } else { 93 | Html::footer(); 94 | } 95 | -------------------------------------------------------------------------------- /inc/ticketstatuscriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Ticket status selection criteria 34 | **/ 35 | class PluginReportsTicketStatusCriteria extends PluginReportsArrayCriteria { 36 | 37 | private $choice = []; 38 | 39 | 40 | /** 41 | * @param $report 42 | * @param $name (default 'status') 43 | * @param $label (default '') 44 | * @param $option (default 1) 45 | **/ 46 | function __construct($report, $name='status', $label='', $option=1) { 47 | 48 | if (is_array($option)) { 49 | foreach ($option as $opt) { 50 | $tab[$opt] = Ticket::getStatus($opt); 51 | } 52 | 53 | } else if ($option == 1) { 54 | $tab = Ticket::getAllStatusArray(true); 55 | 56 | } else { 57 | $tab = Ticket::getAllStatusArray(false); 58 | } 59 | 60 | // Parent is PluginReportsArrayCriteria 61 | parent::__construct($report, $name, ($label ? $label : _n('Status', 'Statuses', 1)), $tab); 62 | } 63 | 64 | 65 | /** 66 | * Get SQL code associated with the criteria 67 | * 68 | * @see plugins/reports/inc/PluginReportsArrayCriteria::getSqlCriteriasRestriction() 69 | **/ 70 | public function getSqlCriteriasRestriction($link='AND') { 71 | 72 | $status = $this->getParameterValue(); 73 | 74 | switch ($status) { 75 | case "notold" : 76 | $list = Ticket::getAllStatusArray(); 77 | $check = array_merge(Ticket::getSolvedStatusArray(), 78 | Ticket::getClosedStatusArray()); 79 | foreach ($check as $status) { 80 | if (isset($list[$status])) { 81 | unset($list[$status]); 82 | } 83 | } 84 | $list = implode("','", array_keys($list)); 85 | break; 86 | 87 | case "old" : 88 | $list = implode("','", array_merge(Ticket::getSolvedStatusArray(), 89 | Ticket::getClosedStatusArray())); 90 | break; 91 | 92 | case "process" : 93 | $list = implode("','", Ticket::getProcessStatusArray()); 94 | break; 95 | 96 | case 'notclosed' : 97 | $list = Ticket::getAllStatusArray(); 98 | foreach (Ticket::getClosedStatusArray() as $status) { 99 | if (isset($list[$status])) { 100 | unset($list[$status]); 101 | } 102 | } 103 | $list = implode("','", array_keys($list)); 104 | break; 105 | 106 | case Ticket::INCOMING : 107 | case Ticket::ASSIGNED : 108 | case Ticket::PLANNED : 109 | case Ticket::WAITING : 110 | case Ticket::SOLVED : 111 | case Ticket::CLOSED : 112 | $list = $status; 113 | break; 114 | 115 | case "all" : 116 | default : 117 | return ''; 118 | } 119 | return $link . " " . $this->getSqlField() . " IN ('".$list."') "; 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /report/globalhisto/globalhisto.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; // not really a big SQL request 34 | 35 | global $DB; 36 | //TRANS: The name of the report = Global History (for Test / example only) 37 | $report = new PluginReportsAutoReport(__('globalhisto_report_title', 'reports')); 38 | 39 | //Report's search criterias 40 | //Possible current values are : 41 | // - date-interval 42 | // - time-interval 43 | // - group 44 | new PluginReportsDateIntervalCriteria($report, "date_mod"); 45 | 46 | //Display criterias form is needed 47 | $report->displayCriteriasForm(); 48 | 49 | //If criterias have been validated 50 | if ($report->criteriasValidated()) { 51 | $report->setSubNameAuto(); 52 | 53 | //Colunmns mappings if needed 54 | $columns_mappings = 55 | ['0' => '', 56 | Log::HISTORY_ADD_DEVICE => Log::getLinkedActionLabel(Log::HISTORY_ADD_DEVICE), 57 | Log::HISTORY_UPDATE_DEVICE => Log::getLinkedActionLabel(Log::HISTORY_UPDATE_DEVICE), 58 | Log::HISTORY_DELETE_DEVICE => Log::getLinkedActionLabel(Log::HISTORY_DELETE_DEVICE), 59 | Log::HISTORY_INSTALL_SOFTWARE => Log::getLinkedActionLabel(Log::HISTORY_INSTALL_SOFTWARE), 60 | Log::HISTORY_UNINSTALL_SOFTWARE => Log::getLinkedActionLabel(Log::HISTORY_UNINSTALL_SOFTWARE), 61 | Log::HISTORY_DISCONNECT_DEVICE => Log::getLinkedActionLabel(Log::HISTORY_DISCONNECT_DEVICE), 62 | Log::HISTORY_CONNECT_DEVICE => Log::getLinkedActionLabel(Log::HISTORY_CONNECT_DEVICE), 63 | Log::HISTORY_LOCK_DEVICE => Log::getLinkedActionLabel(Log::HISTORY_LOCK_DEVICE), 64 | Log::HISTORY_UNLOCK_DEVICE => Log::getLinkedActionLabel(Log::HISTORY_UNLOCK_DEVICE), 65 | Log::HISTORY_LOG_SIMPLE_MESSAGE => Log::getLinkedActionLabel(Log::HISTORY_LOG_SIMPLE_MESSAGE), 66 | Log::HISTORY_DELETE_ITEM => Log::getLinkedActionLabel(Log::HISTORY_DELETE_ITEM), 67 | Log::HISTORY_RESTORE_ITEM => Log::getLinkedActionLabel(Log::HISTORY_RESTORE_ITEM), 68 | Log::HISTORY_ADD_RELATION => Log::getLinkedActionLabel(Log::HISTORY_ADD_RELATION), 69 | Log::HISTORY_DEL_RELATION => Log::getLinkedActionLabel(Log::HISTORY_DEL_RELATION), 70 | Log::HISTORY_CREATE_ITEM => Log::getLinkedActionLabel(Log::HISTORY_CREATE_ITEM)]; 71 | 72 | //Names of the columns to be displayed 73 | $report->setColumns([new PluginReportsColumn('id', __('ID')), 74 | new PluginReportsColumnDate('date_mod', __('Date')), 75 | new PluginReportsColumn('user_name', __('User')), 76 | new PluginReportsColumnMap('linked_action', _x('noun','Update'), 77 | $columns_mappings)]); 78 | 79 | 80 | $query = "SELECT `id`, `date_mod`, `user_name`, `linked_action` 81 | FROM `glpi_logs` ". 82 | $report->addSqlCriteriasRestriction("WHERE")." 83 | ORDER BY `date_mod`"; 84 | 85 | $report->setSqlRequest($query); 86 | $report->execute(); 87 | } else { 88 | Html::footer(); 89 | } 90 | -------------------------------------------------------------------------------- /inc/timeintervalcriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Criteria which allows to select a time interval 34 | */ 35 | class PluginReportsTimeIntervalCriteria extends PluginReportsAutoCriteria { 36 | 37 | 38 | /** 39 | * @param $report 40 | * @param $name (default time-interval) 41 | * @param $label (default '') 42 | **/ 43 | function __construct($report, $name='time-interval', $label='') { 44 | parent::__construct($report, $name, $name, $label); 45 | } 46 | 47 | 48 | public function setDefaultValues() { 49 | 50 | $this->setStartTime(date("Y-m-d")); 51 | $this->setEndTime(date("Y-m-d")); 52 | } 53 | 54 | 55 | function setStartTime($starttime) { 56 | $this->addParameter('starttime',$starttime); 57 | } 58 | 59 | 60 | function setEndtime($endtime) { 61 | $this->addParameter('endtime',$endtime); 62 | } 63 | 64 | 65 | function displayCriteria() { 66 | 67 | $this->getReport()->startColumn(); 68 | 69 | printf(__('Start at %s'), __('Number pending', 'reports')); 70 | echo "  "; 71 | $this->getReport()->endColumn(); 72 | 73 | $this->getReport()->startColumn(); 74 | Dropdown::showHours("starttime", $this->getParameter('starttime')); 75 | $this->getReport()->endColumn(); 76 | 77 | $this->getReport()->startColumn(); 78 | printf(__('End at %s'), __('Number pending', 'reports')); 79 | echo "  "; 80 | $this->getReport()->endColumn(); 81 | 82 | $this->getReport()->startColumn(); 83 | Dropdown::showHours("endtime", $this->getParameter('endtime')); 84 | $this->getReport()->endColumn(); 85 | } 86 | 87 | 88 | /** 89 | * @see plugins/reports/inc/PluginReportsAutoCriteria::getSqlCriteriasRestriction() 90 | **/ 91 | function getSqlCriteriasRestriction($link='AND') { 92 | 93 | if ($this->getParameter("starttime") < $this->getParameter("endtime")) { 94 | // ex 08:00:00 <= time < 18:00:00 95 | return " $link TIME(".$this->getSqlField().") >= '".$this->getParameter('starttime'). ":00' 96 | AND TIME(" .$this->getSqlField(). ") < '" .$this->getParameter('endtime'). ":00'"; 97 | } 98 | // ex time < 08:00:00 or 18:00:00 <= time 99 | return " $link (TIME(". $this->getSqlField().") >= '".$this->getParameter('starttime').":00' 100 | OR TIME(".$this->getSqlField().") < '".$this->getParameter('endtime').":00')"; 101 | } 102 | 103 | 104 | function getSubName() { 105 | 106 | $title = $this->getCriteriaLabel($this->getName()); 107 | if (empty($title)) { 108 | if ($this->getName() == 'date-interval') { 109 | $title = __('Date interval', 'reports'); 110 | } if ($this->getName() == 'time-interval') { 111 | $title = __('Time interval', 'reports'); 112 | } 113 | } 114 | return sprintf(__('%1$s (%2$s)'), " " . $title, 115 | $this->getParameter('starttime') . "," . $this->getParameter('endtime')); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /front/report.form.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | include_once("../../../inc/includes.php"); 33 | 34 | Session::checkRight('profile', READ); 35 | 36 | Plugin::load('reports', true); 37 | 38 | Html::header( 39 | __('Reports plugin configuration', 'reports'), 40 | $_SERVER['PHP_SELF'], 41 | 'config', 42 | 'plugins' 43 | ); 44 | 45 | global $DB, $LANG; 46 | 47 | require_once "../inc/profile.class.php"; 48 | 49 | $report=''; 50 | if (isset($_POST['report'])) { 51 | $report=$_POST['report']; 52 | } 53 | 54 | $prof = new PluginReportsProfile(); 55 | 56 | if (isset($_POST['delete']) && $report) { 57 | $profile_right = new ProfileRight; 58 | $profile_right->deleteByCriteria(['name' => "plugin_reports_$report"]); 59 | ProfileRight::addProfileRights(["plugin_reports_$report"]); 60 | } elseif (isset($_POST['update']) && $report) { 61 | Session::checkRight('profile', UPDATE); 62 | PluginReportsProfile::updateForReport($_POST); 63 | } 64 | 65 | $tab = $prof->updatePluginRights(); 66 | 67 | echo "
"; 68 | echo ""; 69 | echo ""; 70 | echo "\n"; 71 | 72 | echo ""; 113 | echo "
".__('Reports plugin configuration', 'reports')."
". __('Rights management by report', 'reports'). "
".__('Report', 'Reports', 1). "  "; 73 | 74 | $result = $DB->request( 75 | ['SELECT' => ['id', 'name'], 76 | 'FROM' => 'glpi_profiles', 77 | 'ORDER' => 'name'] 78 | ); 79 | 80 | echo ""; 111 | echo Html::submit(_sx('button', 'Post'), ['class' => 'btn btn-primary']); 112 | //echo "
"; 114 | Html::closeForm(); 115 | 116 | if ($report) { 117 | PluginReportsProfile::showForReport($report); 118 | } 119 | 120 | Html::footer(); 121 | -------------------------------------------------------------------------------- /report/softversioninstallations/softversioninstallations.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB; 36 | 37 | $dbu = new DbUtils(); 38 | 39 | //TRANS: The name of the report = Not installed important software (plural) 40 | $report = new PluginReportsAutoReport(__('softversioninstallations_report_title', 'reports')); 41 | 42 | $statever = new PluginReportsStatusCriteria($report, 'statever', 43 | __('Software version status', 'reports')); 44 | $statever->setSqlField("`glpi_softwareversions`.`states_id`"); 45 | 46 | $statecpt = new PluginReportsStatusCriteria($report, 'statecpt', 47 | __('Computer status', 'reports')); 48 | $statecpt->setSqlField("`glpi_computers`.`states_id`"); 49 | 50 | 51 | $report->displayCriteriasForm(); 52 | 53 | // Form validate and only one software with license 54 | if ($report->criteriasValidated()) { 55 | 56 | $report->setSubNameAuto(); 57 | 58 | $report->setColumns([new PluginReportsColumnLink('software', _n('Software', 'Software', 1), 59 | 'Software', ['sorton' => 'software,version']), 60 | new PluginReportsColumnLink('version', __('Version'), 'SoftwareVersion'), 61 | new PluginReportsColumn('statever', __('Status')), 62 | new PluginReportsColumnLink('computer', __('Computer'),'Computer', 63 | ['sorton' => 'glpi_computers.name']), 64 | new PluginReportsColumn('statecpt', __('Status')), 65 | new PluginReportsColumn('location', __('Location'), 66 | ['sorton' => 'location'])]); 67 | 68 | $query = "SELECT `glpi_softwareversions`.`softwares_id` AS software, 69 | `glpi_softwareversions`.`id` AS version, 70 | `glpi_computers`.`id` AS computer, 71 | `state_ver`.`name` AS statever, 72 | `state_cpt`.`name` AS statecpt, 73 | `glpi_locations`.`completename` as location 74 | FROM `glpi_softwareversions` 75 | INNER JOIN `glpi_items_softwareversions` 76 | ON (`glpi_items_softwareversions`.`softwareversions_id` 77 | = `glpi_softwareversions`.`id`) 78 | INNER JOIN `glpi_computers` 79 | ON (`glpi_items_softwareversions`.`items_id` = `glpi_computers`.`id` 80 | AND `glpi_items_softwareversions`.`itemtype` = 'Computer') 81 | LEFT JOIN `glpi_locations` 82 | ON (`glpi_locations`.`id` = `glpi_computers`.`locations_id`) 83 | LEFT JOIN `glpi_states` state_ver 84 | ON (`state_ver`.`id` = `glpi_softwareversions`.`states_id`) 85 | LEFT JOIN `glpi_states` state_cpt 86 | ON (`state_cpt`.`id` = `glpi_computers`.`states_id`) ". 87 | $dbu->getEntitiesRestrictRequest('WHERE', 'glpi_softwareversions') . 88 | $report->addSqlCriteriasRestriction(). 89 | $report->getOrderby('software', true); 90 | 91 | $report->setSqlRequest($query); 92 | $report->execute(); 93 | } else { 94 | Html::footer(); 95 | } 96 | -------------------------------------------------------------------------------- /inc/column.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * class PluginReportsColumn to manage output 34 | */ 35 | class PluginReportsColumn { 36 | 37 | // name of the column in the SQL result set 38 | public $name; 39 | // Fields for ORDER BY when this column is selected 40 | public $sorton; 41 | // Label of the column in the report 42 | private $title; 43 | // Extras class for rendering in HTML 44 | private $extrafine; 45 | // Extras class for rendering in HTML in Bold 46 | private $extrabold; 47 | // Manage total for this colum (if handled by sub-type) 48 | protected $withtotal; 49 | 50 | 51 | function __construct($name, $title, $options=[]) { 52 | 53 | $this->name = $name; 54 | $this->title = $title; 55 | 56 | // Extras class for each cell 57 | $this->extrafine = (isset($options['extrafine']) ? $options['extrafine'] : ''); 58 | 59 | // Extras class for each total cell 60 | $this->extrabold = (isset($options['extrabold']) ? $options['extrabold'] : "class='b'"); 61 | 62 | // Enable total for this column (if handle bu subtype) 63 | $this->withtotal = (isset($options['withtotal']) ? $options['withtotal'] : false); 64 | 65 | // Enable sort for this column 66 | $this->sorton = (isset($options['sorton']) ? $options['sorton'] : false); 67 | } 68 | 69 | 70 | function showTitle($output_type, &$num) { 71 | 72 | if (($output_type != Search::HTML_OUTPUT) || !$this->sorton) { 73 | echo Search::showHeaderItem($output_type, $this->title, $num); 74 | return; 75 | } 76 | $order = 'ASC'; 77 | $issort = false; 78 | if (isset($_REQUEST['sort']) && $_REQUEST['sort']==$this->name) { 79 | $issort = true; 80 | if (isset($_REQUEST['order']) && $_REQUEST['order']=='ASC') { 81 | $order = 'DESC'; 82 | } 83 | } 84 | $link = $_SERVER['PHP_SELF']; 85 | $first = true; 86 | foreach ($_REQUEST as $name => $value) { 87 | if (!in_array($name, ['sort','order','PHPSESSID'])) { 88 | $link .= ($first ? '?' : '&'); 89 | $link .= $name .'='.urlencode($value); 90 | $first = false; 91 | } 92 | } 93 | $link .= ($first ? '?' : '&').'sort='.urlencode($this->name); 94 | $link .= '&order='.$order; 95 | echo Search::showHeaderItem($output_type, $this->title, $num, 96 | $link, $issort, ($order=='ASC'?'DESC':'ASC')); 97 | } 98 | 99 | 100 | function showValue($output_type, $row, &$num, $row_num, $bold=false) { 101 | 102 | echo Search::showItem($output_type, $this->displayValue($output_type, $row), $num, $row_num, 103 | ($bold ? $this->extrabold : $this->extrafine)); 104 | } 105 | 106 | 107 | function showTotal($output_type, &$num, $row_num) { 108 | 109 | echo Search::showItem($output_type, 110 | ($this->withtotal ? $this->displayTotal($output_type) : ''), 111 | $num, $row_num, $this->extrabold); 112 | } 113 | 114 | 115 | function displayValue($output_type, $row) { 116 | 117 | if (isset($row[$this->name])) { 118 | return $row[$this->name]; 119 | } 120 | return ''; 121 | } 122 | 123 | 124 | function displayTotal($output_type) { 125 | return ''; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /report/licenses/licenses.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB; 36 | 37 | $dbu = new DbUtils(); 38 | 39 | //TRANS: The name of the report = Detailed license report 40 | $report = new PluginReportsAutoReport(__('licenses_report_title', 'reports')); 41 | 42 | $license = new PluginReportsSoftwareWithLicenseCriteria($report); 43 | 44 | $license->setSqlField("`glpi_softwarelicenses`.`softwares_id`"); 45 | 46 | $report->displayCriteriasForm(); 47 | 48 | // Form validate and only one software with license 49 | if ($report->criteriasValidated() 50 | && $license->getParameterValue() >0) { 51 | 52 | $report->setSubNameAuto(); 53 | 54 | $report->setColumns(["license" => _n('License', 'Licenses', 2), 55 | "serial" => __('Serial number'), 56 | "nombre" => _x('Quantity', 'Number'), 57 | "type" => __('Type'), 58 | "buy" => __('Purchase version'), 59 | "used" => __('Used version', 'reports'), 60 | "expire" => __('Expiration'), 61 | "comment" => __('Comments'), 62 | "name" => __('Computer')]); 63 | 64 | $query = "SELECT `glpi_softwarelicenses`.`name` AS license, 65 | `glpi_softwarelicenses`.`serial`, 66 | `glpi_softwarelicenses`.`number` AS nombre, 67 | `glpi_softwarelicensetypes`.`name` AS type, 68 | buyversion.`name` AS buy, 69 | useversion.`name` AS used, 70 | `glpi_softwarelicenses`.`expire`, 71 | `glpi_softwarelicenses`.`comment`, 72 | `glpi_computers`.`name` 73 | FROM `glpi_softwarelicenses` 74 | LEFT JOIN `glpi_softwares` 75 | ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`) 76 | LEFT JOIN `glpi_items_softwarelicenses` 77 | ON (`glpi_softwarelicenses`.`id` 78 | = `glpi_items_softwarelicenses`.`softwarelicenses_id`) 79 | LEFT JOIN `glpi_computers` 80 | ON (`glpi_computers`.`id` = `glpi_items_softwarelicenses`.`items_id` 81 | AND `glpi_items_softwarelicenses`.`itemtype` = 'Computer') 82 | LEFT JOIN `glpi_softwareversions` AS buyversion 83 | ON (buyversion.`id` = `glpi_softwarelicenses`.`softwareversions_id_buy`) 84 | LEFT JOIN `glpi_softwareversions` AS useversion 85 | ON (useversion.`id` = `glpi_softwarelicenses`.`softwareversions_id_use`) 86 | LEFT JOIN `glpi_softwarelicensetypes` 87 | ON (`glpi_softwarelicensetypes`.`id` 88 | =`glpi_softwarelicenses`.`softwarelicensetypes_id`) 89 | LEFT JOIN `glpi_entities` 90 | ON (`glpi_softwares`.`entities_id` = `glpi_entities`.`id`)". 91 | $report->addSqlCriteriasRestriction("WHERE")." 92 | AND `glpi_softwares`.`is_deleted` = '0' 93 | AND `glpi_softwares`.`is_template` = '0' " . 94 | $dbu->getEntitiesRestrictRequest(' AND ', 'glpi_softwares') ." 95 | ORDER BY license"; 96 | 97 | $report->setGroupBy("license"); 98 | $report->setSqlRequest($query); 99 | $report->execute(); 100 | 101 | } else { 102 | Html::footer(); 103 | } 104 | -------------------------------------------------------------------------------- /inc/integercriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * User titles selection criteria 34 | */ 35 | class PluginReportsIntegerCriteria extends PluginReportsDropdownCriteria { 36 | 37 | private $signe = '='; 38 | private $min = 0; 39 | private $max = 100; 40 | private $coef = 1; 41 | 42 | 43 | /** 44 | * @param $report 45 | * @param $name (default 'value') 46 | * @param $label (default '') 47 | * @param $signe (default '') 48 | * @param $min (default 0) 49 | * @param $max (default 100) 50 | * @param $coef (default 1) 51 | * @param $unit (default '') 52 | **/ 53 | function __construct($report, $name='value', $label='', $signe='', $min=0, $max=100, $coef=1, 54 | $unit='') { 55 | 56 | parent::__construct($report, $name, NOT_AVAILABLE, ($label ? $label : __('Value'))); 57 | 58 | $this->setOptions($signe,$min,$max,$coef,$unit); 59 | } 60 | 61 | 62 | function setDefaultValues() { 63 | 64 | $this->addParameter($this->getName(),0); 65 | $this->addParameter($this->getName().'_sign','<='); 66 | } 67 | 68 | 69 | /** 70 | * @param $signe (default '') 71 | * @param $min (default 0) 72 | * @param $max (default 100) 73 | * @param $coef (default 1) 74 | * @param $unit (default '') 75 | **/ 76 | function setOptions($signe='', $min=0, $max=100, $coef=1, $unit='') { 77 | 78 | $this->signe = $signe; 79 | $this->min = $min; 80 | $this->max = $max; 81 | $this->coef = $coef; 82 | $this->unit = $unit; 83 | } 84 | 85 | 86 | function displayCriteria() { 87 | 88 | $this->getReport()->startColumn(); 89 | echo $this->getCriteriaLabel().' :'; 90 | $this->getReport()->endColumn(); 91 | 92 | $this->getReport()->startColumn(); 93 | if (empty($this->signe)) { 94 | Dropdown::showFromArray($this->getName()."_sign", 95 | ['<=' => '<=', 96 | '>=' => '>='], 97 | ['value' => Glpi\Toolbox\Sanitizer::unsanitize($this->getParameter($this->getName()."_sign"))]); 98 | echo " "; 99 | } 100 | $opt = ['value' => $this->getParameterValue(), 101 | 'min' => $this->min, 102 | 'max' => $this->max, 103 | 'step' => 1]; 104 | Dropdown::showNumber($this->getName(), $opt); 105 | echo '  '.$this->unit; 106 | 107 | $this->getReport()->endColumn(); 108 | } 109 | 110 | 111 | /** 112 | * Get criteria's subtitle 113 | **/ 114 | public function getSubName() { 115 | 116 | $value = $this->getParameterValue(); 117 | return $this->getCriteriaLabel().' '.$this->getSign()." $value ".$this->unit; 118 | } 119 | 120 | 121 | function getSign() { 122 | 123 | if (empty($this->signe)) { 124 | return Glpi\Toolbox\Sanitizer::unsanitize($this->getParameter($this->getName()."_sign")); 125 | } 126 | return $this->signe; 127 | } 128 | 129 | 130 | /** 131 | * @see plugins/reports/inc/PluginReportsDropdownCriteria::getSqlCriteriasRestriction() 132 | **/ 133 | function getSqlCriteriasRestriction($link='AND') { 134 | 135 | $param = $this->getParameterValue(); 136 | return $link." ".$this->getSqlField().$this->getSign()."'".($param*$this->coef)."' "; 137 | } 138 | 139 | } 140 | -------------------------------------------------------------------------------- /inc/function.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | 33 | /** 34 | * Search for reports in all activated plugins 35 | * 36 | * @return tab : an array which contains all the reports found (name => plugin) 37 | **/ 38 | function searchReport($all = false) { 39 | global $DB; 40 | 41 | $tab = []; 42 | $filter = ['FROM' => 'glpi_plugins', 43 | 'WHERE' => ['state' => Plugin::ACTIVATED]]; 44 | if ($all) { 45 | $filter = ""; 46 | } 47 | foreach ($DB->request($filter) as $plug) { 48 | foreach (glob(Plugin::getPhpDir($plug['directory'])."/report/*", GLOB_ONLYDIR) as $path) { 49 | $tab[basename($path)] = $plug['directory']; 50 | includeLocales(basename($path), $plug['directory']); 51 | } 52 | } 53 | return $tab; 54 | } 55 | 56 | 57 | /** 58 | * Include locales for a specific report 59 | * 60 | * @param $report_name the name of the report to use 61 | * @param $plugin plugins name (default 'reports') 62 | * 63 | * @return boolean, true if locale found 64 | **/ 65 | function includeLocales($report_name, $plugin='reports') { 66 | global $CFG_GLPI, $LANG; 67 | 68 | $prefix = Plugin::getPhpDir($plugin). "/report/". $report_name ."/" . $report_name; 69 | 70 | if (isset ($_SESSION["glpilanguage"]) 71 | && file_exists($prefix . "." . $_SESSION["glpilanguage"].".php")) { 72 | 73 | include_once ($prefix . "." . $_SESSION["glpilanguage"].".php"); 74 | 75 | } else if (file_exists($prefix . ".en_GB.php")) { 76 | include_once ($prefix . ".en_GB.php"); 77 | 78 | } else { 79 | // At least defined report name 80 | $name = $report_name.'_report_title'; 81 | $LANG['plugin_'.$plugin][$report_name] = __($report_name.'_report_title', $plugin); 82 | // For dev 83 | if (($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE) 84 | && ($LANG['plugin_'.$plugin][$report_name] == $report_name.'_report_title')) { 85 | Toolbox::logInFile('php-errors', 86 | "includeLocales($name, $plugin) => not found\n"); 87 | } 88 | // return false; 89 | } 90 | 91 | return true; 92 | } 93 | 94 | 95 | /** 96 | * Manage display and export of an sql query 97 | * 98 | * @param $name name of the report 99 | * @param $sql the sql query to execute 100 | * @param $cols array which contains the columns and their name to display 101 | * @param $subname second level of name to display (default '') 102 | * @param $group array which contains all the fields to use in GROUP BY sql instruction 103 | **/ 104 | function simpleReport($name, $sql, $cols=[], $subname="", $group=[]) { 105 | global $DB, $CFG_GLPI; 106 | 107 | $report = new AutoReport($name); 108 | 109 | if (count($cols)) { 110 | $report->setColumns($cols); 111 | } 112 | 113 | if (!empty($subname)) { 114 | $report->setSubName($subname); 115 | } 116 | 117 | if (count($group)) { 118 | $report->setGroupBy($group); 119 | } 120 | 121 | $report->setSqlRequest($sql); 122 | $report->execute(); 123 | } 124 | 125 | 126 | function getPriorityLabelsArray() { 127 | 128 | return ["1" => Ticket::getPriorityName(1), 129 | "2" => Ticket::getPriorityName(2), 130 | "3" => Ticket::getPriorityName(3), 131 | "4" => Ticket::getPriorityName(4), 132 | "5" => Ticket::getPriorityName(5), 133 | "6" => Ticket::getPriorityName(6)]; 134 | } 135 | 136 | 137 | function getImpactLabelsArray() { 138 | 139 | return ["1" => Ticket::getImpactName(1), 140 | "2" => Ticket::getImpactName(2), 141 | "3" => Ticket::getImpactName(3), 142 | "4" => Ticket::getImpactName(4), 143 | "5" => Ticket::getImpactName(5)]; 144 | } 145 | 146 | 147 | function getUrgencyLabelsArray() { 148 | 149 | return ["1" => Ticket::getUrgencyName(1), 150 | "2" => Ticket::getUrgencyName(2), 151 | "3" => Ticket::getUrgencyName(3), 152 | "4" => Ticket::getUrgencyName(4), 153 | "5" => Ticket::getUrgencyName(5)]; 154 | } 155 | 156 | -------------------------------------------------------------------------------- /report/rules/rules.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | ------------------------------------------------------------------------- 30 | - */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB; 36 | 37 | Session::checkRight("plugin_reports_rules", READ); 38 | 39 | 40 | function plugin_reports_rulelist ($rulecollection, $title) { 41 | 42 | Session::checkRight($rulecollection::$rightname,READ); 43 | 44 | $rulecollection->getCollectionDatas(true, true); 45 | echo "
"; 46 | echo "\n"; 47 | echo ""; 50 | 51 | echo ""; 52 | echo ""; 53 | echo ""; 54 | echo ""; 55 | echo "\n"; 56 | foreach ($rulecollection->RuleList->list as $rule) { 57 | echo ""; 58 | echo ""; 59 | echo ""; 60 | 61 | if ($rule->fields["match"] == Rule::AND_MATCHING) { 62 | echo ""; 63 | } else { 64 | echo ""; 65 | } 66 | 67 | echo ""; 77 | echo ""; 86 | 87 | if ($rule->fields["is_active"]) { 88 | echo ""; 89 | } else { 90 | echo ""; 91 | } 92 | echo "\n"; 93 | } 94 | echo "
" . 48 | //TRANS: The name of the report = Rule's catalog 49 | __('rules_report_title', 'reports') . " - " . $title . "
".__('Name')."".__('Description').""._n('Criterion', 'Criteria', 2).""._n('Action', 'Actions', 2)."".__('Active')."
" . $rule->fields["name"] . "" . $rule->fields["description"] . "".__('and')."".__('or').""; 68 | foreach ($rule->criterias as $criteria) { 69 | echo $rule->getCriteriaName($criteria->fields["criteria"]) . " " . 70 | RuleCriteria::getConditionByID($criteria->fields["condition"], get_class($rule))." ". 71 | $rule->getCriteriaDisplayPattern($criteria->fields["criteria"], 72 | $criteria->fields["condition"], 73 | $criteria->fields["pattern"]) . 74 | "
"; 75 | } 76 | echo "
"; 78 | foreach ($rule->actions as $action) { 79 | echo $rule->getActionName($action->fields["field"]) . " " . 80 | RuleAction::getActionByID($action->fields["action_type"]) . " " . 81 | stripslashes($rule->getActionValue($action->fields["field"],$action->fields["action_type"], 82 | $action->fields["value"])) . 83 | "
"; 84 | } 85 | echo "
".__('Yes')."".__('No')."
\n"; 95 | } 96 | 97 | Html::header(__("rules_report_title", 'reports'), $_SERVER['PHP_SELF'], "utils", "report"); 98 | 99 | Report::title(); 100 | 101 | $type = (isset($_GET["type"]) ? $_GET["type"] : ""); 102 | 103 | if ($type == "ldap") { 104 | $rulecollection = new RuleRightCollection(); 105 | plugin_reports_rulelist($rulecollection, __('Authorizations assignment rules')); 106 | 107 | } else if ($type == "soft") { 108 | $rulecollection = new RuleSoftwareCategoryCollection(); 109 | plugin_reports_rulelist($rulecollection, __('Rules for assigning a category to software')); 110 | 111 | } else { 112 | echo "
"; 113 | echo "\n"; 114 | echo ""; 116 | 117 | 118 | if (Session::haveRight("rule_ldap", READ)) { 119 | echo ""; 122 | } 123 | 124 | if (Session::haveRight("rule_softwarecategories", READ)) { 125 | echo ""; 128 | } 129 | echo "
". sprintf(__('%1$s - %2$s'), __("rules_report_title", 'reports'), __('Rule type')). 115 | "
". 120 | "".__('Authorizations assignment rules'). 121 | "
". 126 | "". 127 | __('Rules for assigning a category to software')."
\n"; 130 | } 131 | 132 | Html::footer(); 133 | -------------------------------------------------------------------------------- /report/softnotinstalled/softnotinstalled.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB; 36 | 37 | $dbu = new DbUtils(); 38 | 39 | //TRANS: The name of the report = Detailed report of software installation by status 40 | $report = new PluginReportsAutoReport(__('softnotinstalled_report_title', 'reports')); 41 | $soft = new PluginReportsTextCriteria($report, 'software', _n('Software', 'Software', 1)); 42 | $soft->setSqlField("`glpi_softwares`.`name`"); 43 | 44 | $report->displayCriteriasForm(); 45 | 46 | // Form validate and only one software with license 47 | if ($report->criteriasValidated()) { 48 | 49 | $report->setSubNameAuto(); 50 | 51 | $report->setColumns([new PluginReportsColumnLink('computer', __('Computer'),'Computer', 52 | ['sorton' => 'glpi_computers.name']), 53 | new PluginReportsColumn('operatingsystems', __('Operating system'), 54 | ['sorton' => 'operatingsystems']), 55 | new PluginReportsColumn('state', __('Status'), ['sorton' => 'state']), 56 | new PluginReportsColumn('entity', __('Entity'), 57 | ['sorton' => 'entity,location']), 58 | new PluginReportsColumn('location', 59 | sprintf(__('%1$s - %2$s'), __('Location'), 60 | __('Computer')), 61 | ['sorton' => 'location'])]); 62 | 63 | $query = "SELECT `glpi_computers`.`id` AS computer, 64 | `glpi_states`.`name` AS state, 65 | `glpi_operatingsystems`.`name` as operatingsystems, 66 | `glpi_locations`.`completename` as location, 67 | `glpi_entities`.`completename` as entity 68 | FROM `glpi_computers` 69 | LEFT JOIN `glpi_states` 70 | ON (`glpi_states`.`id` = `glpi_computers`.`states_id`) 71 | LEFT JOIN `glpi_items_operatingsystems` 72 | ON (`glpi_items_operatingsystems`.`items_id` = `glpi_computers`.`id` 73 | AND `glpi_items_operatingsystems`.`itemtype` = 'Computer') 74 | LEFT JOIN `glpi_operatingsystems` 75 | ON (`glpi_operatingsystems`.`id` = `glpi_items_operatingsystems`.`operatingsystems_id`) 76 | LEFT JOIN `glpi_locations` 77 | ON (`glpi_locations`.`id` = `glpi_computers`.`locations_id`) 78 | LEFT JOIN `glpi_entities` 79 | ON (`glpi_entities`.`id` = `glpi_computers`.`entities_id`) ". 80 | $dbu->getEntitiesRestrictRequest('WHERE', 'glpi_computers') ." 81 | AND `glpi_computers`.`is_template` = 0 82 | AND `glpi_computers`.`is_deleted` = 0 83 | AND `glpi_computers`.`id` 84 | NOT IN (SELECT `glpi_computers`.`id` 85 | FROM `glpi_softwares` 86 | INNER JOIN `glpi_softwareversions` 87 | ON (`glpi_softwares`.`id` = `glpi_softwareversions`.`softwares_id`) 88 | INNER JOIN `glpi_items_softwareversions` 89 | ON (`glpi_items_softwareversions`.`softwareversions_id` 90 | = `glpi_softwareversions`.`id`) 91 | INNER JOIN `glpi_computers` 92 | ON (`glpi_items_softwareversions`.`items_id` = `glpi_computers`.`id` 93 | AND `glpi_items_softwareversions`.`itemtype` = 'Computer') ". 94 | $dbu->getEntitiesRestrictRequest('WHERE', 'glpi_computers') . 95 | $report->addSqlCriteriasRestriction().")". 96 | $report->getOrderby('computer', true); 97 | 98 | 99 | $report->setSqlRequest($query); 100 | $report->execute(); 101 | } else { 102 | Html::footer(); 103 | } 104 | -------------------------------------------------------------------------------- /report/listequipmentbylocation/listequipmentbylocation.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB, $CFG_GLPI; 36 | 37 | 38 | //TRANS: The name of the report = List of equipments by location 39 | $report = new PluginReportsAutoReport(__('listequipmentbylocation_report_title', 'reports')); 40 | $loc = new PluginReportsLocationCriteria($report); 41 | 42 | 43 | $ignored = ['Cartridge', 'CartridgeItem', 'Consumable', 'ConsumableItem', 'Software', 'Line', 44 | 'Certificate', 'Appliance', 'Domain', 'Item_DeviceSimcard', 'SoftwareLicense']; 45 | 46 | $report->setColumns([new PluginReportsColumnType('itemtype', __('Type'), $ignored), 47 | new PluginReportsColumnTypeLink('items_id', __('Item'), 'itemtype', 48 | ['with_comment' => 1]), 49 | new PluginReportsColumn('statename', __('Status')), 50 | new PluginReportsColumn('serial', __('Serial number')), 51 | new PluginReportsColumn('otherserial', __('Inventory number')), 52 | new PluginReportsColumnModelType('models_id', __('Model'), 'itemtype', 53 | ['with_comment' => 1]), 54 | new PluginReportsColumnTypeType('types_id', __('Type'), 'itemtype', 55 | ['with_comment' => 1])]); 56 | 57 | //Display criterias form is needed 58 | $report->displayCriteriasForm(); 59 | 60 | //If criterias have been validated 61 | if ($report->criteriasValidated() && ($loc->getParameterValue() != 0)) { 62 | $report->setSubNameAuto(); 63 | 64 | $query = getSqlSubRequest("Computer", $loc, new Computer()); 65 | foreach($CFG_GLPI["infocom_types"] as $itemtype) { 66 | $obj = new $itemtype; 67 | if ($obj->isField('locations_id') && ($itemtype != "Computer")) { 68 | $query.= "UNION (".getSqlSubRequest($itemtype,$loc,$obj).")"; 69 | } 70 | } 71 | 72 | $report->setGroupBy("entity","itemtype"); 73 | $report->setSqlRequest($query); 74 | $report->execute(); 75 | 76 | } else { 77 | echo "

". __('Location not selected', 'reports')."

"; 78 | Html::footer(); 79 | } 80 | 81 | 82 | 83 | function getSqlSubRequest($itemtype,$loc,$obj) { 84 | 85 | $dbu = new DbUtils(); 86 | 87 | $table = $dbu->getTableForItemType($itemtype); 88 | $models_id = $dbu->getForeignKeyFieldForTable($dbu->getTableForItemType($itemtype.'Model')); 89 | $types_id = $dbu->getForeignKeyFieldForTable($dbu->getTableForItemType($itemtype.'Type')); 90 | $fields = ['name' => 'name', 91 | 'serial' => 'serial', 92 | 'otherserial' => 'otherserial', 93 | 'states_id' => 'states_id', 94 | $models_id => 'models_id', 95 | $types_id => 'types_id']; 96 | 97 | $query_where = "SELECT '$itemtype' AS itemtype, 98 | `$table`.`id` AS items_id, 99 | `$table`.`locations_id`"; 100 | 101 | $join = ""; 102 | foreach ($fields as $field => $alias) { 103 | if ($obj->isField($field)) { 104 | if ($field == 'states_id') { 105 | $query_where .= ", `glpi_states`.`name` as statename"; 106 | $join .= " LEFT JOIN `glpi_states`ON `glpi_states`.`id` = `$table`.`states_id` "; 107 | } else { 108 | $query_where .= ", `$table`.`$field` AS $alias"; 109 | } 110 | } else { 111 | $query_where .= ", '' AS $alias"; 112 | } 113 | } 114 | 115 | 116 | $query_where .= " FROM `$table` 117 | $join "; 118 | 119 | if ($obj->isEntityAssign()) { 120 | $query_where .= $dbu->getEntitiesRestrictRequest('WHERE', "$table"); 121 | } else { 122 | $query_where .= 'WHERE 1'; 123 | } 124 | 125 | if ($obj->maybeTemplate()) { 126 | $query_where .= " AND `is_template`='0'"; 127 | } 128 | 129 | if ($obj->maybeDeleted()) { 130 | $query_where .= " AND `is_deleted`='0'"; 131 | } 132 | 133 | $query_where .= $loc->getSqlCriteriasRestriction(); 134 | 135 | return $query_where; 136 | } 137 | -------------------------------------------------------------------------------- /inc/dateintervalcriteria.class.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | /** 33 | * Criteria which allows to select a date interval 34 | */ 35 | class PluginReportsDateIntervalCriteria extends PluginReportsAutoCriteria { 36 | 37 | function __construct($report, $name='date-interval', $label='', $start='', $end='') { 38 | 39 | parent::__construct($report, $name, $name, $label); 40 | $this->addCriteriaLabel($this->getName()."_1", 41 | ($start ? $start : ($label ? __('After') : __('Start date')))); 42 | $this->addCriteriaLabel($this->getName()."_2", 43 | ($end ? $end : ($label ? __('Before') : __('End date')))); 44 | } 45 | 46 | 47 | public function setStartDate($startdate) { 48 | $this->addParameter($this->getName()."_1", $startdate); 49 | } 50 | 51 | 52 | function setEndDate($enddate) { 53 | $this->addParameter($this->getName()."_2", $enddate); 54 | } 55 | 56 | 57 | public function getStartDate() { 58 | 59 | $start = $this->getParameter($this->getName()."_1"); 60 | $end = $this->getParameter($this->getName()."_2"); 61 | 62 | return (empty($start) || empty($end) || ($start < $end) ? $start : $end); 63 | } 64 | 65 | 66 | public function getEndDate() { 67 | 68 | $start = $this->getParameter($this->getName()."_1"); 69 | $end = $this->getParameter($this->getName()."_2"); 70 | 71 | return (empty($start) || empty($end) || ($start < $end) ? $end : $start); 72 | } 73 | 74 | 75 | public function setDefaultValues() { 76 | 77 | $this->setStartDate(''); 78 | $this->setEndDate(''); 79 | } 80 | 81 | 82 | public function displayCriteria() { 83 | 84 | $this->getReport()->startColumn(); 85 | $name = $this->getCriteriaLabel($this->getName()); 86 | if ($name) { 87 | echo "$name, "; 88 | } 89 | echo $this->getCriteriaLabel($this->getName()."_1").' :'; 90 | $this->getReport()->endColumn(); 91 | 92 | $this->getReport()->startColumn(); 93 | Html::showDateField($this->getName()."_1", ['value' => $this->getStartDate(), 94 | 'maybeempty' => false]); 95 | $this->getReport()->endColumn(); 96 | 97 | $this->getReport()->startColumn(); 98 | if ($name) { 99 | echo "$name, "; 100 | } 101 | echo $this->getCriteriaLabel($this->getName()."_2").' :'; 102 | $this->getReport()->endColumn(); 103 | 104 | $this->getReport()->startColumn(); 105 | Html::showDateField($this->getName()."_2", ['value' => $this->getEndDate(), 106 | 'maybeempty' => false]); 107 | $this->getReport()->endColumn(); 108 | } 109 | 110 | 111 | public function getSqlCriteriasRestriction($link = 'AND') { 112 | 113 | $start = $this->getStartDate(); 114 | $end = $this->getEndDate(); 115 | 116 | if (empty($start) && empty($end)) { 117 | return ''; 118 | } 119 | 120 | $sql = ''; 121 | if (!empty($start)) { 122 | $sql .= $this->getSqlField() . ">= '" . $this->getStartDate() . " 00:00:00'"; 123 | } 124 | 125 | if (!empty($start) && !empty($end)) { 126 | $sql .= ' AND '; 127 | } 128 | 129 | if (!empty($end)) { 130 | $sql .= $this->getSqlField() . "<='" . $this->getEndDate() . " 23:59:59' "; 131 | } 132 | 133 | return $link . " ($sql)"; 134 | } 135 | 136 | 137 | function getSubName() { 138 | 139 | $start = $this->getStartDate(); 140 | $end = $this->getEndDate(); 141 | $title = $this->getCriteriaLabel($this->getName()); 142 | 143 | if (empty($start) && empty($end)) { 144 | return ''; 145 | } 146 | if (empty($title)) { 147 | if ($this->getName() == 'date-interval') { 148 | $title = __('Date interval', 'reports'); 149 | } if ($this->getName() == 'time-interval') { 150 | $title = __('Time interval', 'reports'); 151 | } 152 | } 153 | 154 | if (empty($start)) { 155 | return $title . ', ' . sprintf(__('%1$s %2$s'), __('Before'), Html::convDate($end)); 156 | } 157 | 158 | if (empty($end)) { 159 | return $title . ', ' . sprintf(__('%1$s %2$s'), __('After'), Html::convDate($start)); 160 | } 161 | 162 | return sprintf(__('%1$s (%2$s)'), $title, Html::convDate($start) . ',' .Html::convDate($end)); 163 | } 164 | 165 | } 166 | -------------------------------------------------------------------------------- /report/zombies/zombies.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 0; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB; 36 | 37 | //TRANS: The name of the report = Users with no right 38 | $report = new PluginReportsAutoReport(__('zombies_report_title', 'reports')); 39 | 40 | $name = new PluginReportsTextCriteria($report, 'name', __('Login')); 41 | 42 | $tab = [0 => __('No'), 43 | 1 => __('Yes')]; 44 | $filter = new PluginReportsArrayCriteria($report, 'tickets', __('With no ticket', 'reports'), $tab); 45 | 46 | //Display criterias form is needed 47 | $report->displayCriteriasForm(); 48 | 49 | //If criterias have been validated 50 | if ($report->criteriasValidated()) { 51 | $report->setSubNameAuto(); 52 | $report->delCriteria('tickets'); 53 | 54 | $cols = [new PluginReportsColumnItemCheckbox('id', 'User'), 55 | new PluginReportsColumnLink('id2', __('User'), 'User', ['with_comment' => true, 56 | 'with_navigate' => true]), 57 | new PluginReportsColumn('name', __('Login'), ['sorton' => 'name']), 58 | new PluginReportsColumn('email', __('Email')), 59 | new PluginReportsColumn('phone', __('Phone')), 60 | new PluginReportsColumn('location', __('Location')), 61 | new PluginReportsColumnDate('last_login', __('Last login'), ['sorton' => 'last_login'])]; 62 | 63 | if (!$filter->getParameterValue()) { 64 | $cols[] = new PluginReportsColumnInteger('nb1', __('Writer'), ['with_zero' => false, 65 | 'sorton' => 'nb1']); 66 | $cols[] = new PluginReportsColumnInteger('nb2', __('Requester'), ['with_zero' => false, 67 | 'sorton' => 'nb2']); 68 | $cols[] = new PluginReportsColumnInteger('nb3', __('Watcher'), ['with_zero' => false, 69 | 'sorton' => 'nb3']); 70 | $cols[] = new PluginReportsColumnInteger('nb4', __('Technician'), ['with_zero' => false, 71 | 'sorton' => 'nb4']); 72 | } 73 | 74 | $report->setColumns($cols); 75 | 76 | $query = "SELECT `glpi_users`.`id`, `glpi_users`.`id` AS id2, `glpi_users`.`name`, `last_login`, 77 | (SELECT COUNT(*) 78 | FROM `glpi_tickets` 79 | WHERE `glpi_users`.`id` = `glpi_tickets`.`users_id_recipient` 80 | ) AS nb1, 81 | (SELECT COUNT(*) 82 | FROM `glpi_tickets_users` 83 | WHERE `glpi_users`.`id` = `glpi_tickets_users`.`users_id` 84 | AND `glpi_tickets_users`.`type`=".CommonITILActor::REQUESTER." 85 | ) AS nb2, 86 | (SELECT COUNT(*) 87 | FROM `glpi_tickets_users` 88 | WHERE `glpi_users`.`id` = `glpi_tickets_users`.`users_id` 89 | AND `glpi_tickets_users`.`type`=".CommonITILActor::OBSERVER." 90 | ) AS nb3, 91 | (SELECT COUNT(*) 92 | FROM `glpi_tickets_users` 93 | WHERE `glpi_users`.`id` = `glpi_tickets_users`.`users_id` 94 | AND `glpi_tickets_users`.`type`=".CommonITILActor::ASSIGN." 95 | ) AS nb4, 96 | `phone`, `glpi_locations`.`completename` as location, 97 | `glpi_useremails`.`email` 98 | FROM `glpi_users` 99 | LEFT JOIN `glpi_locations` 100 | ON `glpi_locations`.`id` = `glpi_users`.`locations_id` 101 | LEFT JOIN `glpi_useremails` 102 | ON `glpi_useremails`.`users_id` = `glpi_users`.`id` 103 | AND `glpi_useremails`.`is_default` 104 | WHERE `glpi_users`.`id` NOT IN ( 105 | SELECT distinct `users_id` 106 | FROM `glpi_profiles_users` 107 | ) 108 | AND `glpi_users`.`is_deleted`=0 ". 109 | $report->addSqlCriteriasRestriction('AND'); 110 | if ($filter->getParameterValue()) { 111 | $query .= " HAVING nb1=0 AND nb2=0 AND nb3=0 AND nb4=0 "; 112 | } 113 | $query .= $report->getOrderBy('name'); 114 | 115 | $report->setSqlRequest($query); 116 | $report->execute(['withmassiveaction' => 'User']); 117 | 118 | } else { 119 | Html::Footer(); 120 | } 121 | -------------------------------------------------------------------------------- /report/applicationsbylocation/applicationsbylocation.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | $dbu = new DbUtils(); 36 | 37 | //TRANS: The name of the report = Applications by locations and versions 38 | $report = new PluginReportsAutoReport(__('applicationsbylocation_report_title', 'reports')); 39 | 40 | $softwarecategories = new PluginReportsSoftwareCategoriesCriteria( 41 | $report, 42 | 'softwarecategories', 43 | __('Software category') 44 | ); 45 | $softwarecategories->setSqlField("`glpi_softwarecategories`.`id`"); 46 | 47 | $software = new PluginReportsSoftwareCriteria($report, 'software', __('Applications', 'reports')); 48 | $software->setSqlField("`glpi_softwares`.`id`"); 49 | 50 | $statecpt = new PluginReportsStatusCriteria($report, 'statecpt', __('Computer status', 'reports')); 51 | $statecpt->setSqlField("`glpi_computers`.`states_id`"); 52 | 53 | $location = new PluginReportsLocationCriteria($report, 'location', _n('Location', 'Locations', 2)); 54 | $location->setSqlField("`glpi_computers`.`locations_id`"); 55 | 56 | 57 | $report->displayCriteriasForm(); 58 | 59 | // Form validate and only one software with license 60 | if ($report->criteriasValidated()) { 61 | $report->setSubNameAuto(); 62 | 63 | $report->setColumns([new PluginReportsColumnLink( 64 | 'soft', 65 | _n('Software', 'Software', 1), 66 | 'Software', 67 | ['sorton' => 'soft,version'] 68 | ), 69 | new PluginReportsColumnLink( 70 | 'locat', 71 | _n('Location', 'Locations', 1), 72 | 'Location', 73 | ['sorton' => 'glpi_locations.name'] 74 | ), 75 | new PluginReportsColumnLink( 76 | 'computer', 77 | _n('Computer', 'Computers', 1), 78 | 'Computer', 79 | ['sorton' => 'glpi_computers.name'] 80 | ), 81 | new PluginReportsColumn('statecpt', _n('Status', 'Statuses', 1)), 82 | new PluginReportsColumnLink( 83 | 'version', 84 | __('Version name'), 85 | 'SoftwareVersion' 86 | ), 87 | new PluginReportsColumnLink( 88 | 'user', 89 | _n('User', 'Users', 1), 90 | 'User', 91 | ['sorton' => 'glpi_users.name'] 92 | )]); 93 | 94 | $query = "SELECT `glpi_softwareversions`.`softwares_id` AS soft, 95 | `glpi_softwareversions`.`name` AS software, 96 | `glpi_locations`.`id` AS locat, 97 | `glpi_computers`.`id` AS computer, 98 | `state_ver`.`name` AS statever, 99 | `state_cpt`.`name` AS statecpt, 100 | `glpi_locations`.`name` as location, 101 | `glpi_softwareversions`.`id` AS version, 102 | `glpi_computers`.`users_id` AS user 103 | FROM `glpi_softwareversions` 104 | INNER JOIN `glpi_items_softwareversions` 105 | ON (`glpi_items_softwareversions`.`softwareversions_id` = `glpi_softwareversions`.`id`) 106 | INNER JOIN `glpi_computers` 107 | ON (`glpi_items_softwareversions`.`items_id` = `glpi_computers`.`id` 108 | AND `glpi_items_softwareversions`.`itemtype` = 'Computer') 109 | INNER JOIN `glpi_softwares` 110 | ON (`glpi_softwares`.`id` = `glpi_softwareversions`.`softwares_id`) 111 | LEFT JOIN `glpi_softwarecategories` 112 | ON (`glpi_softwares`.`softwarecategories_id` = `glpi_softwarecategories`.`id`) 113 | LEFT JOIN `glpi_locations` 114 | ON (`glpi_locations`.`id` = `glpi_computers`.`locations_id`) 115 | LEFT JOIN `glpi_states` state_ver 116 | ON (`state_ver`.`id` = `glpi_softwareversions`.`states_id`) 117 | LEFT JOIN `glpi_states` state_cpt 118 | ON (`state_cpt`.`id` = `glpi_computers`.`states_id`) ". 119 | $dbu->getEntitiesRestrictRequest('WHERE', 'glpi_softwareversions') . 120 | $report->addSqlCriteriasRestriction(). 121 | "ORDER BY soft ASC, locat ASC"; 122 | 123 | $report->setSqlRequest($query); 124 | $report->execute(); 125 | } else { 126 | Html::footer(); 127 | } 128 | -------------------------------------------------------------------------------- /report/printers/printers.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 0; 34 | 35 | global $DB; 36 | 37 | $dbu = new DbUtils(); 38 | 39 | //TRANS: The name of the report = Printers 40 | $report = new PluginReportsAutoReport(__('printers_report_title', 'reports')); 41 | 42 | // Definition of the criteria 43 | $grpcrit = new PluginReportsGroupCriteria($report, 'glpi_printers.groups_id', '', 'is_itemgroup'); 44 | $loccrit = new PluginReportsLocationCriteria($report, 'glpi_printers.locations_id'); 45 | 46 | //Display criterias form is needed 47 | $report->displayCriteriasForm(); 48 | 49 | //If criterias have been validated 50 | if ($report->criteriasValidated()) { 51 | $report->setSubNameAuto(); 52 | 53 | $cols = [new PluginReportsColumnLink('id', __('Name'), 'Printer', 54 | ['with_navigate' => true, 55 | 'sorton' => 'glpi_printers.name']), 56 | new PluginReportsColumn('state', __('Status')), 57 | new PluginReportsColumn('manu', __('Manufacturer')), 58 | new PluginReportsColumn('model', __('Model'), 59 | ['sorton' => 'glpi_manufacturers.name, glpi_printermodels.name']), 60 | new PluginReportsColumn('serial', __('Serial number')), 61 | new PluginReportsColumn('otherserial', __('Inventory number')), 62 | new PluginReportsColumn('immo_number', __('Immobilization number')), 63 | new PluginReportsColumnDate('buy_date', __('Date of purchase'), 64 | ['sorton' => 'glpi_infocoms.buy_date']), 65 | new PluginReportsColumnDate('use_date', __('Startup date'), 66 | ['sorton' => 'glpi_infocoms.use_date']), 67 | new PluginReportsColumnInteger('last_pages_counter', __('Printed pages')), 68 | new PluginReportsColumnLink('user', __('User'), 'User'), 69 | new PluginReportsColumnLink('groupe', __('Group'), 'Group', 70 | ['sorton' => 'glpi_groups.name']), 71 | new PluginReportsColumnInteger('compgrp', __('Computers in the group', 'reports')), 72 | new PluginReportsColumnInteger('usergrp', __('Users in the group', 'reports')), 73 | new PluginReportsColumnLink('location', __('Location'), 'Location', 74 | ['sorton' => 'glpi_locations.completename']), 75 | new PluginReportsColumnInteger('comploc', __('Computers in the location', 'reports')), 76 | new PluginReportsColumnInteger('userloc', __('Users in the location', 'reports'))]; 77 | 78 | $report->setColumns($cols); 79 | 80 | $compgrp = "SELECT COUNT(*) 81 | FROM `glpi_computers` 82 | WHERE `glpi_computers`.`groups_id`>0 83 | AND `glpi_computers`.`groups_id`=`glpi_printers`.`groups_id`"; 84 | 85 | $usergrp = "SELECT COUNT(*) 86 | FROM `glpi_groups_users` 87 | WHERE `glpi_groups_users`.`groups_id`>0 88 | AND `glpi_groups_users`.`groups_id`=`glpi_printers`.`groups_id`"; 89 | 90 | $comploc = "SELECT COUNT(*) 91 | FROM `glpi_computers` 92 | WHERE `glpi_computers`.`locations_id`>0 93 | AND `glpi_computers`.`locations_id`=`glpi_printers`.`locations_id`"; 94 | 95 | $userloc = "SELECT COUNT(*) 96 | FROM `glpi_users` 97 | WHERE `glpi_users`.`locations_id`>0 98 | AND `glpi_users`.`locations_id`=`glpi_printers`.`locations_id`"; 99 | 100 | $sql = "SELECT `glpi_printers`.`id`, `glpi_printers`.`serial`, `glpi_printers`.`otherserial`, 101 | `glpi_printers`.`last_pages_counter`, 102 | `glpi_printermodels`.`name` AS model, 103 | `glpi_manufacturers`.`name` AS manu, 104 | `glpi_printers`.`users_id` AS user, 105 | `glpi_printers`.`groups_id` AS groupe, 106 | (".$compgrp.") AS compgrp, 107 | (".$usergrp.") AS usergrp, 108 | `glpi_locations`.`id` AS location, 109 | (".$comploc.") AS comploc, 110 | (".$userloc.") AS userloc, 111 | `glpi_infocoms`.`immo_number`, `glpi_infocoms`.`buy_date`, 112 | `glpi_infocoms`.`use_date`, 113 | `glpi_states`.`name` AS state 114 | FROM `glpi_printers` 115 | LEFT JOIN `glpi_printermodels` 116 | ON (`glpi_printermodels`.`id`=`glpi_printers`.`printermodels_id`) 117 | LEFT JOIN `glpi_manufacturers` 118 | ON (`glpi_manufacturers`.`id`=`glpi_printers`.`manufacturers_id`) 119 | LEFT JOIN `glpi_states` ON (`glpi_states`.`id`=`glpi_printers`.`states_id`) 120 | LEFT JOIN `glpi_infocoms` ON (`glpi_infocoms`.`itemtype`='Printer' 121 | AND `glpi_infocoms`.`items_id`=`glpi_printers`.`id`) 122 | LEFT JOIN `glpi_locations` ON (`glpi_locations`.`id`=`glpi_printers`.`locations_id`) 123 | LEFT JOIN `glpi_groups` ON (`glpi_groups`.`id`=`glpi_printers`.`groups_id`) ". 124 | $dbu->getEntitiesRestrictRequest('WHERE', 'glpi_printers'). 125 | $report->addSqlCriteriasRestriction(). 126 | $report->getOrderBy('groupe'); 127 | 128 | $report->setSqlRequest($sql); 129 | $report->execute(); 130 | 131 | } else { 132 | Html::footer(); 133 | } 134 | -------------------------------------------------------------------------------- /report/histohard/histohard.php: -------------------------------------------------------------------------------- 1 | . 20 | 21 | @package reports 22 | @authors Nelly Mahu-Lasson, Remi Collet, Benoit Machiavello 23 | @copyright Copyright (c) 2009-2022 Reports plugin team 24 | @license AGPL License 3.0 or (at your option) any later version 25 | http://www.gnu.org/licenses/agpl-3.0-standalone.html 26 | @link https://forge.glpi-project.org/projects/reports 27 | @link http://www.glpi-project.org/ 28 | @since 2009 29 | -------------------------------------------------------------------------- 30 | */ 31 | 32 | $USEDBREPLICATE = 1; 33 | $DBCONNECTION_REQUIRED = 1; // Really a big SQL request 34 | 35 | global $DB; 36 | 37 | includeLocales("histohard"); 38 | 39 | Session::checkRight("plugin_reports_histohard", READ); 40 | $computer = new Computer(); 41 | $dbu = new DbUtils(); 42 | $computer->checkGlobal(READ); 43 | 44 | //TRANS: The name of the report = History of last hardware's installations 45 | Html::header(__("histohard_report_title", 'reports'), $_SERVER['PHP_SELF'], "utils","report"); 46 | 47 | Report::title(); 48 | 49 | echo "
"; 50 | echo "\n"; 51 | echo "". 52 | "\n"; 53 | 54 | echo "" . 55 | "". 56 | "". 57 | "". 58 | "\n"; 59 | 60 | $sql = "SELECT `glpi_logs`.`date_mod` AS dat, `linked_action`, `itemtype`, `itemtype_link`, 61 | `old_value`, `new_value`, `glpi_computers`.`id` AS cid, `name`, `user_name`, 62 | `items_id`,`entities_id` 63 | FROM `glpi_logs` 64 | LEFT JOIN `glpi_computers` ON (`glpi_logs`.`items_id` = `glpi_computers`.`id`) 65 | WHERE `glpi_logs`.`date_mod` > DATE_SUB(Now(), INTERVAL 21 DAY) 66 | AND `itemtype` = 'Computer' 67 | AND `linked_action` IN (".Log::HISTORY_CONNECT_DEVICE.", 68 | ".Log::HISTORY_DISCONNECT_DEVICE.", 69 | ".Log::HISTORY_DELETE_DEVICE.", 70 | ".Log::HISTORY_UPDATE_DEVICE.", 71 | ".Log::HISTORY_ADD_DEVICE.") 72 | AND `entities_id` = '" . $_SESSION["glpiactive_entity"] ."' 73 | ORDER BY `glpi_logs`.`id` DESC 74 | LIMIT 0,100"; 75 | 76 | $result = $DB->doQuery($sql); 77 | 78 | $prev = ""; 79 | $class = "tab_bg_2"; 80 | foreach ($result as $data) { 81 | if (empty($data["name"])) { 82 | $data["name"] = "(".$data["cid"].")"; 83 | } 84 | if ($prev == $data["dat"].$data["name"]) { 85 | echo "\n"; 89 | } 90 | $prev = $data["dat"].$data["name"]; 91 | echo "" . 92 | "". 93 | "\n"; 154 | } 155 | echo "
". __("History of last hardware's installations", 'reports')."
".__('Date of inventory', 'reports'). "". __('User') . "". __('Network device') . "". __('Field') . "". __('Modification', 'reports') . "
"; 86 | } else { 87 | if (!empty($prev)) { 88 | echo "
". Html::convDateTime($data["dat"]) . "". $data["user_name"] . " " . 94 | $data["name"] . ""; 95 | $prevclass = $class; 96 | $class = ($class=="tab_bg_2" ? "tab_bg_1" : "tab_bg_2"); 97 | } 98 | $field = ""; 99 | if ($data["linked_action"]) { 100 | $action_label = Log::getLinkedActionLabel($data["linked_action"]); 101 | // Yes it is an internal device 102 | switch ($data["linked_action"]) { 103 | case Log::HISTORY_ADD_DEVICE : 104 | case Log::HISTORY_CONNECT_DEVICE : 105 | $field = NOT_AVAILABLE; 106 | if ($item = $dbu->getItemForItemtype($data["itemtype_link"])) { 107 | if ($item instanceof Item_Devices) { 108 | $field = $item->getDeviceTypeName(1); 109 | } else { 110 | $field = $item->getTypeName(1); 111 | } 112 | } 113 | $change = sprintf(__('%1$s: %2$s'), $action_label, $data[ "new_value"]); 114 | break; 115 | 116 | case Log::HISTORY_UPDATE_DEVICE : 117 | $field = NOT_AVAILABLE; 118 | $change = ''; 119 | $linktype_field = explode('#', $data["itemtype_link"]); 120 | $linktype = $linktype_field[0]; 121 | $fieldval = $linktype_field[1]; 122 | $devicetype = $linktype::getDeviceType(); 123 | $field = $devicetype; 124 | $specif_fields = $linktype::getSpecificities(); 125 | if (isset($specif_fields[$fieldval]['short name'])) { 126 | $field = $devicetype; 127 | $field .= " (".$specif_fields[$fieldval]['short name'].")"; 128 | } 129 | //TRANS: %1$s is the old_value, %2$s is the new_value 130 | $change = sprintf(__('%1$s: %2$s'), 131 | sprintf(__('%1$s (%2$s)'), $action_label, $field), 132 | sprintf(__('%1$s by %2$s'), $data["old_value"], $data[ "new_value"])); 133 | break; 134 | 135 | case Log::HISTORY_DELETE_DEVICE : 136 | case Log::HISTORY_DISCONNECT_DEVICE : 137 | $field = NOT_AVAILABLE; 138 | if ($item = $dbu->getItemForItemtype($data["itemtype_link"])) { 139 | if ($item instanceof Item_Devices) { 140 | $field = $item->getDeviceTypeName(1); 141 | } else { 142 | $field = $item->getTypeName(1); 143 | } 144 | } 145 | $change = sprintf(__('%1$s: %2$s'), $action_label, $data["old_value"]); 146 | break; 147 | }//fin du switch 148 | } 149 | echo $field . "" . $change; 150 | } 151 | 152 | if (!empty($prev)) { 153 | echo "

".__('The list is limited to 100 items and 21 days', 'reports')."

\n"; 156 | 157 | Html::footer(); 158 | --------------------------------------------------------------------------------