You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2012-06-21 19:33:24

danh
Member
From: Chicago, USA
Registered: 2012-03-08
Posts: 546
Website

SOLVED - Custom Report - post a sample?

I have read through the docs and samples as well as reviewed the existing report.php files.

My attempts at creating a custom reports are failing.
Is it possible for someone to post the code for a custom report to show a list of computers and what user is assigned?

I think from this, I'd be able to piece my way through my own functioning reports.

Last edited by danh (2012-06-27 14:55:19)


Thanks,
Dan

Offline

#2 2012-06-23 15:54:05

danh
Member
From: Chicago, USA
Registered: 2012-03-08
Posts: 546
Website

Re: SOLVED - Custom Report - post a sample?

I have spent 2-days on this with no head way.
I just don't understand the code in the reports.

Any help would be much appreciated.


Thanks,
Dan

Offline

#3 2012-06-23 17:39:38

remi
GLPI-DEV
From: Champagne
Registered: 2007-04-28
Posts: 7,127
Website

Re: SOLVED - Custom Report - post a sample?

Have you try using "reports" plugin ?
https://forge.indepnet.net/projects/rep … n_devguide


Dév. Fedora 29 - PHP 5.6/7.0/7.1/7.2/7.3/7.4 - MariaDB 10.3 - GLPI master
Certifié ITILv3 - RPM pour Fedora, RHEL et CentOS sur https://blog.remirepo.net/

Offline

#4 2012-06-23 18:37:30

danh
Member
From: Chicago, USA
Registered: 2012-03-08
Posts: 546
Website

Re: SOLVED - Custom Report - post a sample?

Yes, this is installed.  I am trying to create my own reports based off of the documentation.  I just can't wrap my head around it.

I can do basic SQL statements, but the examples are not what I am familiar with.
Is there a more step-by-step example of what every part means?

I think I am stuck at the Define the report Columns.

From what I gather:
PluginReportsColumn('completename', --> this is the table field
$LANG["entity"] --> I don't understand this part
[0] --> I don't understand this part either

I am trying to get a report that lists the following info:
Computer Name - Serial - User Assigned

I understand that I need to join glpi_computers and glpi_users, but anything I write displays a blank screen.  I can't even get it to just show computer names.


Thanks,
Dan

Offline

#5 2012-06-25 12:08:44

tomolimo
Member
From: Grenoble, France
Registered: 2009-05-12
Posts: 515

Re: SOLVED - Custom Report - post a sample?

Idea to help you: you can simply create a view in MySQL directly, and then use the view in a basic report you've created.
In this way you simplify the report creation. you can also use a tool to create MySQL views...
regards,
Tomolimo


GLPI 9.2.4 - PHP 7.2.13 x64 / ProcessMaker 3.3.0-community-RE-1.7 - PHP 7.1.24 x64 / Windows 2012 x64 / IIS 8.5 / MySQL 5.7.17 x64
Worldwide: >12316 PC, >9400 users (16 languages, >11 timezones), >360k tickets, >3600 entities, >4200 groups
Raynet is ARaymond (http://www.araymond.com) IT service management

Offline

#6 2012-08-28 10:53:08

aabc2
Member
Registered: 2012-08-28
Posts: 13

Re: SOLVED - Custom Report - post a sample?

I wrote my report, but it's not working:
<?php

$USEDBREPLICATE= 1;
$DBCONNECION_REQUIRED= 0;

define('GLPI_ROOT', '../../../..');
include(GLPI_ROOT."/inc/includes.php");

$report = new PluginReportsAutoReport();

   $report->setColumns(array(new PluginReportsColumn('cname', $LANG['common'][1],
                 new PluginReportsColumn('dname', $LANG['common'][2],
                             new PluginReportsColumn('device', $LANG['common'][3],
                             new PluginReportsColumn('device', $LANG['common'][4],                            
                             new PluginReportsColumn('name', $LANG['common'][5],
                             new PluginReportsColumn('totalsize', $LANG['common'][6],
                             new PluginReportsColumn('freesize', $LANG['common'][7])));
   $query = "SELECT
   `glpi_computers`.`name` AS  "Komputer",
   `glpi_computerdisks`.`name` AS "Nazwa",
   `glpi_computerdisks`.`device` AS "Partycja",
   `glpi_computerdisks`.`mountpoint` AS "Punkt montowania",
   `glpi_filesystems`.`name` AS "Plik systemowy",
   `glpi_computerdisks`.`totalsize` AS "Rozmiar",
   `glpi_computerdisks`.`freesize` AS "Wolne miejsce"
    FROM  `glpi_computerdisks`
    LEFT JOIN  `glpi_filesystems` ON (  `glpi_filesystems`.`id` =  `glpi_computerdisks`.`filesystems_id` )
    LEFT JOIN  `glpi_computers` ON (  `glpi_computers`.`id` =  `glpi_computerdisks`.`computers_id` )".
    getEntitiesRestrictRequest(" WHERE ", "glpi_computerdisks") ."
    ORDER BY `glpi_computers`.`name`, `glpi_computerdisks`.`freesize`";

    $report->setGroupBy(array(`glpi_computers`.`name`));
$report->setSqlRequest($query);
$report->execute();
?>

do you know why?

Offline

Board footer

Powered by FluxBB