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 = Applications by locations and versions
$report = new PluginReportsAutoReport(__('applicationsbylocation_report_title', 'reports'));
$softwarecategories = new PluginReportsSoftwareCategoriesCriteria($report, 'softwarecategories', __('Software category'));
$softwarecategories->setSqlField("`glpi_softwarecategories`.`id`");
$software = new PluginReportsSoftwareCriteria($report, 'software', __('Applications', 'reports'));
$software->setSqlField("`glpi_softwares`.`id`");
$statecpt = new PluginReportsStatusCriteria($report, 'statecpt', __('Computer status', 'reports'));
$statecpt->setSqlField("`glpi_computers`.`states_id`");
$location = new PluginReportsLocationCriteria($report, 'location', _n('Location', 'Locations', 2));
$location->setSqlField("`glpi_computers`.`locations_id`");
$report->displayCriteriasForm();
// Form validate and only one software with license
if ($report->criteriasValidated()) {
    $report->setSubNameAuto();
    $report->setColumns(array(new PluginReportsColumnLink('soft', _n('Software', 'Software', 1), 'Software', array('sorton' => 'soft,version')), new PluginReportsColumnLink('locat', _n('Location', 'Locations', 1), 'Location', array('sorton' => 'glpi_locations.name')), new PluginReportsColumnLink('computer', _n('Computer', 'Computers', 1), 'Computer', array('sorton' => 'glpi_computers.name')), new PluginReportsColumn('statecpt', _n('Status', 'Statuses', 1)), new PluginReportsColumnLink('version', __('Version name'), 'SoftwareVersion'), new PluginReportsColumnLink('user', _n('User', 'Users', 1), 'User', array('sorton' => 'glpi_users.name'))));
    $query = "SELECT `glpi_softwareversions`.`softwares_id` AS soft,\n                    `glpi_softwareversions`.`name` AS software,\n                    `glpi_locations`.`id` AS locat,\n                    `glpi_computers`.`id` AS computer,\n                    `state_ver`.`name` AS statever,\n                    `state_cpt`.`name` AS statecpt,\n                    `glpi_locations`.`name` as location,\n                    `glpi_softwareversions`.`id` AS version,\n                    `glpi_computers`.`users_id` AS user\n             FROM `glpi_softwareversions`\n             INNER JOIN `glpi_computers_softwareversions`\n                   ON (`glpi_computers_softwareversions`.`softwareversions_id` = `glpi_softwareversions`.`id`)\n             INNER JOIN `glpi_computers`\n                   ON (`glpi_computers_softwareversions`.`computers_id` = `glpi_computers`.`id`)\n             INNER JOIN `glpi_softwares`\n                   ON (`glpi_softwares`.`id` = `glpi_softwareversions`.`softwares_id`)\n             LEFT JOIN `glpi_softwarecategories`\n                  ON (`glpi_softwares`.`softwarecategories_id` = `glpi_softwarecategories`.`id`)\n             LEFT JOIN `glpi_locations`\n                  ON (`glpi_locations`.`id` = `glpi_computers`.`locations_id`)\n             LEFT JOIN `glpi_states` state_ver\n                  ON (`state_ver`.`id` = `glpi_softwareversions`.`states_id`)\n             LEFT JOIN `glpi_states` state_cpt\n                  ON (`state_cpt`.`id` = `glpi_computers`.`states_id`) " . getEntitiesRestrictRequest('WHERE', 'glpi_softwareversions') . $report->addSqlCriteriasRestriction() . "ORDER BY soft ASC, locat ASC";
    $report->setSqlRequest($query);
    $report->execute();
}
Esempio n. 2
0
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 = Detailed license report
$report = new PluginReportsAutoReport(__('licenses_report_title', 'reports'));
$license = new PluginReportsSoftwareWithLicenseCriteria($report);
$license->setSqlField("`glpi_softwarelicenses`.`softwares_id`");
$report->displayCriteriasForm();
// Form validate and only one software with license
if ($report->criteriasValidated() && $license->getParameterValue() > 0) {
    $report->setSubNameAuto();
    $report->setColumns(array("license" => _n('License', 'Licenses', 2), "serial" => __('Serial number'), "nombre" => _x('Quantity', 'Number'), "type" => __('Type'), "buy" => __('Purchase version'), "used" => __('Used version', 'reports'), "expire" => __('Expiration'), "comment" => __('Comments'), "name" => __('Computer')));
    $query = "SELECT `glpi_softwarelicenses`.`name` AS license,\n                    `glpi_softwarelicenses`.`serial`,\n                    `glpi_softwarelicenses`.`number` AS nombre,\n                    `glpi_softwarelicensetypes`.`name` AS type,\n                    buyversion.`name` AS buy,\n                    useversion.`name` AS used,\n                    `glpi_softwarelicenses`.`expire`,\n                    `glpi_softwarelicenses`.`comment`,\n                    `glpi_computers`.`name`\n             FROM `glpi_softwarelicenses`\n             LEFT JOIN `glpi_softwares`\n                  ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`)\n             LEFT JOIN `glpi_computers_softwarelicenses`\n                  ON (`glpi_softwarelicenses`.`id`\n                        = `glpi_computers_softwarelicenses`.`softwarelicenses_id`)\n             LEFT JOIN `glpi_computers`\n                  ON (`glpi_computers`.`id` = `glpi_computers_softwarelicenses`.`computers_id`)\n             LEFT JOIN `glpi_softwareversions` AS buyversion\n                  ON (buyversion.`id` = `glpi_softwarelicenses`.`softwareversions_id_buy`)\n             LEFT JOIN `glpi_softwareversions` AS useversion\n                  ON (useversion.`id` = `glpi_softwarelicenses`.`softwareversions_id_use`)\n             LEFT JOIN `glpi_softwarelicensetypes`\n                  ON (`glpi_softwarelicensetypes`.`id`\n                        =`glpi_softwarelicenses`.`softwarelicensetypes_id`)\n             LEFT JOIN `glpi_entities`\n                  ON (`glpi_softwares`.`entities_id` = `glpi_entities`.`id`)" . $report->addSqlCriteriasRestriction("WHERE") . "\n                   AND `glpi_softwares`.`is_deleted` = '0'\n                   AND `glpi_softwares`.`is_template` = '0' " . getEntitiesRestrictRequest(' AND ', 'glpi_softwares') . "\n             ORDER BY license";
    $report->setGroupBy("license");
    $report->setSqlRequest($query);
    $report->execute();
}