Exemplo n.º 1
0
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();
}