You are not logged in.
Pages: 1
Topic closed
Hello, I'm trying to create a new report with plugin Reports version 1.7.2 and GLPI version 0.84.4. GLPI and standard reports work ok.
I've created a new directory with report name the same of dir.
I've also added user rights to be able to view it.
My report is based on listequipmentbylocation reports which lists items by location.
I need to convert it(or write from scratch) report that will list all items by user.
I have managed to display user criteria instead of location, but no data is recieved based on that.
I would be very grateful for any assistance on this, thanks in advance:
<?php
/*
* @version $Id: listequipmentbylocation.php 246 2013-05-02 13:03:33Z yllen $
-------------------------------------------------------------------------
reports - Additional reports plugin for GLPI
Copyright (C) 2003-2013 by the reports Development Team.
-------------------------------------------------------------------------
LICENSE
This file is part of reports.
reports is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with reports. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
$USEDBREPLICATE = 1;
$DBCONNECTION_REQUIRED = 0;
include ("../../../../inc/includes.php");
//TRANS: The name of the report = List of equipments by location
$report = new PluginReportsAutoReport(__('testuser', 'reports'));
$usr = new PluginReportsUserCriteria($report);
$report->setColumns(array(new PluginReportsColumnType('itemtype', __('Type')),
new PluginReportsColumnTypeLink('items_id', __('Item'),
'itemtype', array('with_comment' => 1)),
new PluginReportsColumn('serial', __('Serial number')),
new PluginReportsColumn('otherserial', __('Inventory number')),
new PluginReportsColumnModelType('models_id', __('Model'),
'itemtype', array('with_comment' => 1)),
new PluginReportsColumnTypeType('types_id', __('Type'),
'itemtype', array('with_comment' => 1))));
//Display criterias form is needed
$report->displayCriteriasForm();
//If criterias have been validated
if ($report->criteriasValidated()) {
$report->setSubNameAuto();
$query = getSqlSubRequest("Computer",$usr,new Computer());
foreach($CFG_GLPI["infocom_types"] as $itemtype) {
$obj = new $itemtype;
if ($obj->isField('users_id')) {
$query.= "UNION (".getSqlSubRequest($itemtype,$usr,$obj).")";
}
}
$report->setGroupBy("entity","itemtype");
$report->setSqlRequest($query);
$report->execute();
}
else {
Html::footer();
}
function getSqlSubRequest($itemtype,$usr,$obj) {
$table = getTableForItemType($itemtype);
$models_id = getForeignKeyFieldForTable(getTableForItemType($itemtype.'Model'));
$types_id = getForeignKeyFieldForTable(getTableForItemType($itemtype.'Type'));
$fields = array('name' => 'name',
'serial' => 'serial',
'otherserial' => 'otherserial',
$models_id => 'models_id',
$types_id => 'types_id');
$query_where = "SELECT '$itemtype' AS itemtype,
`$table`.`id` AS items_id,
`$table`.`users_id`";
foreach ($fields as $field => $alias) {
if ($obj->isField($field)) {
$query_where .= ", `$table`.`$field` AS $alias";
} else {
$query_where .= ", '' AS $alias";
}
}
$query_where .= " FROM `$table` ";
if ($obj->isEntityAssign()) {
$query_where .= getEntitiesRestrictRequest('WHERE', "$table");
} else {
$query_where .= 'WHERE 1';
}
if ($obj->maybeTemplate()) {
$query_where .= " AND `is_template`='0'";
}
if ($obj->maybeDeleted()) {
$query_where .= " AND `is_deleted`='0'";
}
$query_where .= $usr->getSqlCriteriasRestriction();
return $query_where;
}
?>
Last edited by milosz.engel (2014-02-17 12:12:27)
miloszengel.com
GLPI 0.85.4, Data Injection 2.4.0+fusioninventory 2.3.16 on debian 8.0 (jeesie)
Offline
Ok, i have managed to fix it. There is a bug in reports plugin in usercriteria.class.php.
There is a line:
function __construct($report, $name='user', $label='') {
looking at locationcriteria.class.php
i figured that it is wrong because it doesn't point to users_id,so i changed that line to:
function __construct($report, $name='users_id', $label='') {
After change, my report work and shows items for selected user.
Now i will try to make a custimized print version...
miloszengel.com
GLPI 0.85.4, Data Injection 2.4.0+fusioninventory 2.3.16 on debian 8.0 (jeesie)
Offline
Ticket added on the roadmap of the plugin: https://forge.indepnet.net/issues/4799
CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6 - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)
Offline
can you create new report contain full computer details with attached devices, periphirals, softwares etc.
Offline
ritesh: create your own post if the subject is different
CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6 - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)
Offline
subject is the same, trying to find out full computer inventory report i.e. full computer details with attached devices, peripherals, software's etc. On report option not fully generated details. I tried but not succeeded. If you have any suggestion please let me know soon.
Thanks
Offline
you can have this report with the search engine of the core.
Add criteria on extend item (red cross) with name contains ^ (or id if no name)
CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6 - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)
Offline
CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6 - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)
Offline
Version 1.11.2 published this day.
CentOS 6.5 - CentOS 7.x
PHP 5.6 - PHP 7.x - MySQL 5.6 - MariaDB 10.2 + APC + oOPcache
GLPI from 0.72 to dev version
Certifiée ITIL (ITV2F, ITILF, ITILOSA)
Offline
Pages: 1
Topic closed