Skip to content
11 changes: 8 additions & 3 deletions inc/dropdowncriteria.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,21 @@ public function displayDropdownCriteria() {
*
* @see plugins/reports/inc/PluginReportsAutoCriteria::getSqlCriteriasRestriction()
**/
public function getSqlCriteriasRestriction($link='AND') {
public function getSqlCriteriasRestriction($link='AND',$tableName='') {

$dbu = new DbUtils();

if ($this->getParameterValue() || $this->searchzero) {

if($tableName != '') {
$sqlField = "`" . $tableName . "`.`" . $sqlField ."` "
}

if (!$this->childrens) {
return $link . " " . $this->getSqlField() . "='" . $this->getParameterValue() . "' ";
return $link . " " . $sqlField . "='" . $this->getParameterValue() . "' ";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

where is define $sqlField if $tableName is empty?

}
if ($this->getParameterValue()) {
return $link . " " . $this->getSqlField() .
return $link . " " . $sqlField .
" IN (" . implode(',', $dbu->getSonsOf($this->getTable(),
$this->getParameterValue())) . ") ";
}
Expand Down
57 changes: 57 additions & 0 deletions inc/entitiescriteria.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* @version $Id$
-------------------------------------------------------------------------
LICENSE

This file is part of Reports plugin for GLPI.

Reports is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Reports is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with Reports. If not, see <http://www.gnu.org/licenses/>.

@package reports
@authors Nelly Mahu-Lasson, Remi Collet, Alexandre Delaunay
@copyright Copyright (c) 2009-2021 Reports plugin team
@license AGPL License 3.0 or (at your option) any later version
http://www.gnu.org/licenses/agpl-3.0-standalone.html
@link https://forge.glpi-project.org/projects/reports
@link http://www.glpi-project.org/
@since 2009
--------------------------------------------------------------------------
*/

/**
* Entities selection criteria
*/
class PluginReportsEntitiesCriteria extends PluginReportsDropdownCriteria {


/**
* @param $report
* @param $name (default 'entities_id')
* @param $label (default '')
**/
function __construct($report, $name='entities_id', $label='') {

parent::__construct($report, $name, 'glpi_entities', ($label ? $label : __('Entity')));
}


/**
* @param $entity
**/
public function setDefaultLocation($entity) {
$this->addParameter($this->name, $entity);
}

}