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 2011-04-21 16:21:41

arndtt
Member
Registered: 2010-03-17
Posts: 6

[Solved] New report not visible and problems with output

I' m trying to create a new report via the reports plugin. I can see the newly report in the grant section. Although I'm setting the correct rights it's not visible in the reports section...

My second problem is I'm not able to set a proper group by I tried it with $report->setGroupBy(array('software','version')); but it doesn't work so far. I would like to generate a list with software based on the status of a computer. My code and environment so far:

<?php

$LANG['plugin_reports']['fichtnerswbystatus'][1] = "Fichtner Software Report nach Status";
$LANG['plugin_reports']['fichtnerswbystatus'][2] = "Computer Status";

?>


<?php
$USEDBREPLICATE=1;
$DBCONNECTION_REQUIRED=0;

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

$report = new PluginReportsAutoReport();

$statecpt = new PluginReportsStatusCriteria($report, 'statecpt', $LANG['plugin_reports']['fichtnerswbystatus'][2]);
$statecpt->setSqlField("`glpi_computers`.`states_id`");


$report->displayCriteriasForm();

// Form validate and only one software with license
if ($report->criteriasValidated()) {

   $report->setSubNameAuto();

   $report->setColumns(array(
      new PluginReportsColumnLink('software', $LANG['help'][31], 'Software',
            array('sorton' => 'software,version')),
      new PluginReportsColumnLink('version',  $LANG['rulesengine'][78],'SoftwareVersion'),
      new PluginReportsColumnLink('computer', $LANG['help'][25],'Computer',
            array('sorton' => 'glpi_computers.name')),
   ));

   $query = "SELECT `glpi_softwareversions`.`softwares_id` AS software,
                    `glpi_softwareversions`.`id` AS version,
                    count(`glpi_computers`.`id`) AS computer
             FROM `glpi_softwareversions`
             INNER JOIN `glpi_computers_softwareversions`
                  ON (`glpi_computers_softwareversions`.`softwareversions_id` = `glpi_softwareversions`.`id`)
             INNER JOIN `glpi_computers`
                  ON (`glpi_computers_softwareversions`.`computers_id` = `glpi_computers`.`id`)
             LEFT JOIN `glpi_states` state_cpt
                  ON (`state_cpt`.`id` = `glpi_computers`.`states_id`) ".
             getEntitiesRestrictRequest('WHERE', 'glpi_softwareversions') .
             $report->addSqlCriteriasRestriction().
             $report->getOrderby('software', true);

$report->setSqlRequest($query);
$report->execute();
}
?>




GLPI  0.78.2 (/glpi => /var/www/glpi)


Server


Operating Systems : Linux fcsv030 2.6.35-22-server #33-Ubuntu SMP Sun Sep 19 20:48:58 UTC 2010 x86_64
PHP 5.3.3-1ubuntu9.3 (Core, PDO, Phar, Reflection, SPL, SimpleXML, apache2handler, bcmath, bz2, calendar, ctype, date, dba, dom,
    ereg, exif, fileinfo, filter, ftp, gd, gettext, hash, iconv, json, libxml, mbstring, mhash, mysql, mysqli, openssl, pcre,
    pdo_mysql, posix, session, shmop, soap, sockets, standard, sysvmsg, sysvsem, sysvshm, tokenizer, wddx, xml, xmlreader,
    xmlwriter, zip, zlib)
Setup: memory_limit="128M" max_execution_time="-1" safe_mode="" session.save_handler="files" post_max_size="1537M"
    upload_max_filesize="1536M"
Software: Apache/2.2.16 (Ubuntu) (Apache/2.2.16 (Ubuntu) Server at fcsv030.fce.com Port 80)
    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0) Gecko/20100101 Firefox/4.0
MySQL: 5.1.49-1ubuntu8.1 (glpi@localhost/glpi)


Mysql replicate Active : No


Plugins list


    datainjection    Name:File injection                 Version :2.0.1      Status :Enabled
    massocsimport    Name:OCS import                     Version :1.4.1      Status :Enabled
    reports          Name:Reports                        Version :1.4.0      Status :Enabled


OCS Inventory NG


Host for the OCSNG database : 'localhost', Connection to OCSNG database successful, Use the OCSNG software dictionary : 0

Last edited by arndtt (2011-04-27 11:19:14)

Offline

#2 2011-04-26 10:49:08

yllen
GLPI-DEV
From: Sillery (51)
Registered: 2008-01-14
Posts: 15,278

Re: [Solved] New report not visible and problems with output

You must desactivate an activate the plugin to see new report


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

#3 2011-04-26 11:49:24

arndtt
Member
Registered: 2010-03-17
Posts: 6

Re: [Solved] New report not visible and problems with output

Thx for your response ! I already tried uninstall/reinstall of the reports plugin via glpi webinterface, deactivation via glpi webinterface, apache restart, browser cache deletion... I still can't see my new report in the reports section. Right now im testing the report by typing the complete URL of the Report in the browser field.

Offline

#4 2011-04-26 22:43:51

Bobtary
Member
Registered: 2009-06-12
Posts: 29

Re: [Solved] New report not visible and problems with output

Hi,
=> Try to modify the name of your report : ex : "fichtnerswbystatus" => "fichtner"
(and as usual, after granting new rights on the report, logout then login), it could be better...

=> for the request, i test this one :
"SELECT `glpi_softwareversions`.`softwares_id` AS software,
                    `glpi_softwareversions`.`id` AS version,
                    count(`glpi_computers`.`id`) AS computer
             FROM `glpi_softwareversions`
             INNER JOIN `glpi_computers_softwareversions`
                  ON (`glpi_computers_softwareversions`.`softwareversions_id` = `glpi_softwareversions`.`id`)
             INNER JOIN `glpi_computers`
                  ON (`glpi_computers_softwareversions`.`computers_id` = `glpi_computers`.`id`)
             LEFT JOIN `glpi_states` state_cpt
                  ON (`state_cpt`.`id` = `glpi_computers`.`states_id`) ".
             getEntitiesRestrictRequest('WHERE', 'glpi_softwareversions') .
             $report->addSqlCriteriasRestriction()."

             GROUP BY version
             ORDER BY software";   

To obtain, according to the status of a computer, the number of installations of each software version...
It can be useful for me, thanks for the idea.

Offline

#5 2011-04-27 10:02:47

arndtt
Member
Registered: 2010-03-17
Posts: 6

Re: [Solved] New report not visible and problems with output

I tried to rename the report according to your suggestions. But it doesn't work.  Is there any way to debug the report.php that should display the reports list ? I'm not a php developer an this is my first report... Something is wrong with my code, all the other standard reports are displayed without a problem. I already tried to get a conclusion if I switch the GLPI webinterface into debug mode

I ended up with this code (not very classy code, but it's o.k. for my first report I think) which works fine for me if I start directly by typing the complete URL in the browser - so the only problem that is open is that I can't display my report in the list

fichtnerswbystatus.php:
<?php
$USEDBREPLICATE=1;
$DBCONNECTION_REQUIRED=0;

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

$report = new PluginReportsAutoReport();

$statecpt = new PluginReportsStatusCriteria($report, 'statecpt', $LANG['plugin_reports']['fichtnerswbystatus'][2]);
$statecpt->setSqlField("`glpi_computers`.`states_id`");


$report->displayCriteriasForm();

// Form validate
if ($report->criteriasValidated()) {

   $report->setSubNameAuto();

   $report->setColumns(array(
new PluginReportsColumn('Software', 'Software', array('sorton'=>'Software')),
    new PluginReportsColumn('Version', 'Version', array('sorton'=>'version')),
    new PluginReportsColumnInteger('Anzahl', 'Anzahl', array('withtotal'=>false)),
                    )
           );

   $query = "SELECT glpi_softwares.name as Software,
            glpi_softwareversions.name as Version,
            count(glpi_softwares.name) as Anzahl
            FROM glpi_computers_softwareversions, glpi_softwares,glpi_softwareversions, glpi_computers
            WHERE glpi_computers_softwareversions.computers_id=glpi_computers.ID ".
    $report->addSqlCriteriasRestriction().   
    getEntitiesRestrictRequest(' AND ' , 'glpi_computers') ."           
            AND glpi_computers_softwareversions.computers_id=glpi_computers.ID
            AND glpi_computers.is_deleted = 0
            AND glpi_computers_softwareversions.softwareversions_id = glpi_softwareversions.ID
            AND glpi_softwareversions.softwares_id = glpi_softwares.ID
            AND glpi_softwares.name != ''
                        GROUP BY glpi_softwares.name, glpi_softwareversions.name
            ORDER BY glpi_softwares.name";

$report->setSqlRequest($query);
$report->execute();
}
?>

fichtnerswbystatus.de_DE.php:
<?php

$LANG['plugin_reports']['fichtnerswbystatus'][1] = "Fichtner Software Report";
$LANG['plugin_reports']['fichtnerswbystatus'][2] = "Computer Status";

?>

Offline

#6 2011-04-27 11:18:44

arndtt
Member
Registered: 2010-03-17
Posts: 6

Re: [Solved] New report not visible and problems with output

O.k. - somehow Bobtary pointed me to the solution, although it didn't work on the first try. This is what I have done:

- I copied the standard report globalhisto and renamed it to fisw
- I verified if the new report fisw was visible and executable in the glpi webinterface
- then I edited the php scripts of fisw and pasted my code above in the appropiate php files (of course not to forget that fichtnerswbystatus has to be changed to fisw in the php code as well )

=> works  big_smile. I don't know why but I don't care  lol

Offline

Board footer

Powered by FluxBB