Skip to content

Instantly share code, notes, and snippets.

@orthagh
Last active February 5, 2016 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orthagh/fdc719f44f4c433f1963 to your computer and use it in GitHub Desktop.
Save orthagh/fdc719f44f4c433f1963 to your computer and use it in GitHub Desktop.
diff --git a/front/export.massive.php b/front/export.massive.php
index 5d7347b..e072439 100644
--- a/front/export.massive.php
+++ b/front/export.massive.php
@@ -29,42 +29,11 @@
include ("../../../inc/includes.php");
-Plugin::load('pdf', true);
-
-$type = $_SESSION['plugin_pdf']['type'];
-$item = new $type();
-unset($_SESSION['plugin_pdf']['type']);
-
-$tab_id = unserialize($_SESSION['plugin_pdf']['tab_id']);
-unset($_SESSION['plugin_pdf']['tab_id']);
-
-ini_set('max_execution_time', 0); //no max execution time
-
-$query = "SELECT `tabref`
- FROM `glpi_plugin_pdf_preferences`
- WHERE `users_ID` = '".$_SESSION['glpiID']."'
- AND `itemtype` = '$type'
- ORDER BY id";
-$result = $DB->query($query);
-
-$tab = array();
-
-while ($data = $DB->fetch_array($result)) {
- if ($data['tabref'] == 'landscape') {
- $pag = 1;
- } else {
- $tab[] = $data['tabref'];
- }
-}
-
-if (empty($tab)) {
- $tab[] = '_main_';
-}
-
-if (isset($PLUGIN_HOOKS['plugin_pdf'][$type])) {
-
- $itempdf = new $PLUGIN_HOOKS['plugin_pdf'][$type]($item);
- $itempdf->generatePDF($tab_id, $tab, (isset($pag) ? $pag : 0));
-} else {
- die("Missing hook");
-}
+Html::includeHeader();
+
+echo Html::scriptBlock("
+ $(document).ready(function() {
+ window.open('".$CFG_GLPI['root_doc']."/plugins/pdf/front/export.massive2.php','_newtab');
+ window.history.back();
+ });
+");
\ No newline at end of file
diff --git a/front/export.massive2.php b/front/export.massive2.php
index e69de29..5d7347b 100644
--- a/front/export.massive2.php
+++ b/front/export.massive2.php
@@ -0,0 +1,70 @@
+<?php
+/*
+ * @version $Id: export.massive.php 338 2013-07-22 14:50:38Z yllen $
+ -------------------------------------------------------------------------
+ pdf - Export to PDF plugin for GLPI
+ Copyright (C) 2003-2013 by the pdf Development Team.
+
+ https://forge.indepnet.net/projects/pdf
+ -------------------------------------------------------------------------
+
+ LICENSE
+
+ This file is part of pdf.
+
+ pdf 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.
+
+ pdf 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 pdf. If not, see <http://www.gnu.org/licenses/>.
+ --------------------------------------------------------------------------
+*/
+
+include ("../../../inc/includes.php");
+
+Plugin::load('pdf', true);
+
+$type = $_SESSION['plugin_pdf']['type'];
+$item = new $type();
+unset($_SESSION['plugin_pdf']['type']);
+
+$tab_id = unserialize($_SESSION['plugin_pdf']['tab_id']);
+unset($_SESSION['plugin_pdf']['tab_id']);
+
+ini_set('max_execution_time', 0); //no max execution time
+
+$query = "SELECT `tabref`
+ FROM `glpi_plugin_pdf_preferences`
+ WHERE `users_ID` = '".$_SESSION['glpiID']."'
+ AND `itemtype` = '$type'
+ ORDER BY id";
+$result = $DB->query($query);
+
+$tab = array();
+
+while ($data = $DB->fetch_array($result)) {
+ if ($data['tabref'] == 'landscape') {
+ $pag = 1;
+ } else {
+ $tab[] = $data['tabref'];
+ }
+}
+
+if (empty($tab)) {
+ $tab[] = '_main_';
+}
+
+if (isset($PLUGIN_HOOKS['plugin_pdf'][$type])) {
+
+ $itempdf = new $PLUGIN_HOOKS['plugin_pdf'][$type]($item);
+ $itempdf->generatePDF($tab_id, $tab, (isset($pag) ? $pag : 0));
+} else {
+ die("Missing hook");
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment