Exemple #1
1
 public function showResult($output_type, $limit = 0)
 {
     global $DB;
     $arrayRet = $this->execQuery($_POST);
     $result = $arrayRet['query_result'];
     $query = $arrayRet['query'];
     $nbtot = $result ? $DB->numrows($result) : 0;
     if ($limit) {
         $start = isset($_GET["start"]) ? $_GET["start"] : 0;
         if ($start >= $nbtot) {
             $start = 0;
         }
         if ($start > 0 || $start + $limit < $nbtot) {
             $result = $DB->query($query . " LIMIT {$start},{$limit}");
         }
     } else {
         $start = 0;
     }
     $nbCols = $DB->num_fields($result);
     $nbrows = $DB->numrows($result);
     $groupByRackName = true;
     if (isset($_POST['groupByRackName']) && $_POST['groupByRackName'] == "on") {
         $groupByRackName = false;
     }
     $title = date("d/m/Y H:i");
     if ($nbtot == 0) {
         echo "<div class='center'><font class='red b'>" . __("No item found") . "</font></div>";
         Html::footer();
     } else {
         if ($output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) {
             include GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php";
         } else {
             if ($output_type == Search::HTML_OUTPUT) {
                 echo "<div class='center'><table class='tab_cadre_fixe'>";
                 echo "<tr  class='tab_bg_1'><th>{$title}</th></tr>\n";
                 echo "<tr class='tab_bg_2 center'><td class='center'>";
                 echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}' target='_blank'>\n";
                 $param = "";
                 foreach ($_POST as $key => $val) {
                     if (is_array($val)) {
                         foreach ($val as $k => $v) {
                             echo "<input type='hidden' name='" . $key . "[{$k}]' value='{$v}' >";
                             if (!empty($param)) {
                                 $param .= "&";
                             }
                             $param .= $key . "[" . $k . "]=" . urlencode($v);
                         }
                     } else {
                         echo "<input type='hidden' name='{$key}' value='{$val}' >";
                         if (!empty($param)) {
                             $param .= "&";
                         }
                         $param .= "{$key}=" . urlencode($val);
                     }
                 }
                 echo "<input type='hidden' name='result_search_reports' value='searchdone' >";
                 $param .= "&result_search_reports=searchdone&target=_blank";
                 Dropdown::showOutputFormat();
                 Html::closeForm();
                 echo "</td></tr>";
                 echo "</table></div>";
                 Html::printPager($start, $nbtot, $_SERVER['PHP_SELF'], $param);
             }
         }
     }
     if ($nbtot > 0) {
         if ($output_type == Search::HTML_OUTPUT) {
             echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}'>\n";
         }
         echo Search::showHeader($output_type, $nbrows, $nbCols, true);
         $showAllFieds = true;
         $listFields = array();
         $cptField = 0;
         $showAllFieds = (!isset($_POST['cb_object_name']) || $_POST['cb_object_name'] != "on") && (!isset($_POST['cb_object_location']) || $_POST['cb_object_location'] != "on") && (!isset($_POST['cb_group']) || $_POST['cb_group'] != "on") && (!isset($_POST['cb_manufacturer']) || $_POST['cb_manufacturer'] != "on") && (!isset($_POST['cb_model']) || $_POST['cb_model'] != "on") && (!isset($_POST['cb_serial_number']) || $_POST['cb_serial_number'] != "on");
         $num = 1;
         $cptRow = 1;
         if (!$showAllFieds) {
             $this->showTitle($output_type, $num, __("Bay name", "racks"), 'name', false);
             $cptField++;
             $this->showTitle($output_type, $num, _n("Place", "Places", 1, "racks"), 'location', false);
             $cptField++;
             $this->showTitle($output_type, $num, _n("Location", "Locations", 1, "racks"), 'roomlocation', false);
             $cptField++;
             $this->showTitle($output_type, $num, __("U", "racks"), 'u', false);
             $cptField++;
             $this->showTitle($output_type, $num, __("Front", "racks") . " / " . __("Back", "racks"), 'front_rear', false);
             $cptField++;
             if (isset($_POST['cb_object_name']) && $_POST['cb_object_name'] == "on") {
                 $listFields['object_name'] = $_POST['cb_object_name'];
                 $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false);
                 $cptField++;
             }
             // Lieu
             if (isset($_POST['cb_object_location']) && $_POST['cb_object_location'] == "on") {
                 $listFields['object_location'] = $_POST['cb_object_location'];
                 $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false);
                 $cptField++;
             }
             // Groupe
             if (isset($_POST['cb_group']) && $_POST['cb_group'] == "on") {
                 $listFields['group'] = $_POST['cb_group'];
                 $this->showTitle($output_type, $num, __("Group"), 'roomlocation', false);
                 $cptField++;
             }
             // Fabricant
             if (isset($_POST['cb_manufacturer']) && $_POST['cb_manufacturer'] == "on") {
                 $listFields['manufacturer'] = $_POST['cb_manufacturer'];
                 $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false);
                 $cptField++;
             }
             // Modèle
             if (isset($_POST['cb_model']) && $_POST['cb_model'] == "on") {
                 $listFields['model'] = $_POST['cb_model'];
                 $this->showTitle($output_type, $num, __("Model"), 'model', false);
                 $cptField++;
             }
             // Numéro de série
             if (isset($_POST['cb_serial_number']) && $_POST['cb_serial_number'] == "on") {
                 $listFields['serial_number'] = $_POST['cb_serial_number'];
                 $this->showTitle($output_type, $num, __("Serial number", "racks"), 'group', false);
                 $cptField++;
             }
         } else {
             $this->showTitle($output_type, $num, __("Bay name", "racks"), 'rack_name', false);
             $listFields['rack_name'] = true;
             $this->showTitle($output_type, $num, __("Place", "racks"), 'location', false);
             $listFields['location'] = true;
             $this->showTitle($output_type, $num, __("Location", "racks"), 'roomlocation', false);
             $listFields['roomlocation'] = true;
             $this->showTitle($output_type, $num, __("U", "racks"), 'u', false);
             $listFields['u'] = true;
             $this->showTitle($output_type, $num, __("Front", "racks") . " / " . __("Back", "racks"), 'front_rear', false);
             $listFields['front_rear'] = true;
             $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false);
             $listFields['object_name'] = true;
             $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false);
             $listFields['object_location'] = true;
             $this->showTitle($output_type, $num, __("Group"), false);
             $listFields['group'] = true;
             $this->showTitle($output_type, $num, __("Type"), 'type', false);
             $listFields['type'] = true;
             $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false);
             $listFields['manufacturer'] = true;
             $this->showTitle($output_type, $num, __("Model"), 'model', false);
             $listFields['model'] = true;
             $this->showTitle($output_type, $num, __("Serial number", "racks"), 'serial_number', false);
             $listFields['serial_number'] = true;
             $this->showTitle($output_type, $num, __("Inventory number"), 'other_serial', false);
             $listFields['other_serial'] = true;
             $cptField = 13;
         }
         echo Search::showEndLine($output_type);
         $num = 1;
         $currentRack = -1;
         while ($row = $DB->fetch_array($result)) {
             // itemtype
             $itemtype = $row['itemtype'];
             $num = 1;
             $cptRow++;
             echo Search::showNewLine($output_type);
             if (isset($row['itemtype']) && $row['itemtype'] != "") {
                 $class = substr($itemtype, 0, -5);
                 $item = new $class();
                 $table = getTableForItemType($class);
                 $r = $DB->query("SELECT * FROM `" . $table . "` WHERE `id` = '" . $row["items_id"] . "' ");
                 $device = $DB->fetch_array($r);
             }
             // nom
             $link = Toolbox::getItemTypeFormURL("PluginRacksRack");
             if ($groupByRackName || $currentRack != $row['id']) {
                 if ($output_type == Search::HTML_OUTPUT) {
                     echo Search::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["id"] . "\">" . $row["name"] . "</a>", $num, $cptRow);
                 } else {
                     echo Search::showItem($output_type, $row["name"], $num, $cptRow);
                 }
             } else {
                 echo Search::showItem($output_type, "&nbsp;", $num, $cptRow);
             }
             // lieu
             if ($groupByRackName || $currentRack != $row['id']) {
                 $tmpId = $row['locations_id'];
                 $tmpObj = new Location();
                 $tmpObj->getFromDB($tmpId);
                 if (isset($tmpObj->fields['name'])) {
                     echo Search::showItem($output_type, $tmpObj->fields['name'], $num, $cptRow);
                 } else {
                     echo Search::showItem($output_type, "&nbsp;", $num, $cptRow);
                 }
             } else {
                 echo Search::showItem($output_type, "&nbsp;", $num, $cptRow);
             }
             // Emplacement
             if ($groupByRackName || $currentRack != $row['id']) {
                 $tmpId = $row['plugin_racks_roomlocations_id'];
                 $tmpObj = new PluginRacksRoomLocation();
                 $tmpObj->getFromDB($tmpId);
                 if (isset($tmpObj->fields['name'])) {
                     echo Search::showItem($output_type, $tmpObj->fields['name'], $num, $cptRow);
                 } else {
                     echo Search::showItem($output_type, '&nbsp;', $num, $cptRow);
                 }
             } else {
                 echo Search::showItem($output_type, "&nbsp;", $num, $cptRow);
             }
             if (isset($row['itemtype']) && $row['itemtype'] != "") {
                 // U
                 if (isset($row['position']) && $row['position'] != "") {
                     echo Search::showItem($output_type, $row['position'], $num, $cptRow);
                 } else {
                     echo Search::showItem($output_type, "&nbsp;", $num, $cptRow);
                 }
                 // avant / arrière
                 if ($row['faces_id'] == 1) {
                     echo Search::showItem($output_type, __("Front", "racks"), $num, $cptRow);
                 } else {
                     echo Search::showItem($output_type, __("Back", "racks"), $num, $cptRow);
                 }
                 // Nom de l'objet
                 if (array_key_exists("object_name", $listFields)) {
                     $link = Toolbox::getItemTypeFormURL(substr($itemtype, 0, -5));
                     if ($itemtype != 'PluginRacksOtherModel') {
                         if ($output_type == Search::HTML_OUTPUT) {
                             echo Search::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["items_id"] . "\">" . $device["name"] . "</a>", $num, $cptRow);
                         } else {
                             echo Search::showItem($output_type, $device["name"], $num, $cptRow);
                         }
                     } else {
                         echo Search::showItem($output_type, $device["name"], $num, $cptRow);
                     }
                 }
                 // Lieu de l'objet
                 if (array_key_exists("object_location", $listFields)) {
                     if ($itemtype != 'PluginRacksOtherModel') {
                         echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $device["locations_id"]), $num, $cptRow);
                     } else {
                         echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow);
                     }
                 }
                 // Groupe
                 if (array_key_exists("group", $listFields)) {
                     // Groupe
                     if ($itemtype != 'PluginRacksOtherModel') {
                         echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_groups", $device["groups_id_tech"]), $num, $cptRow);
                     } else {
                         echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow);
                     }
                 }
                 // type
                 if (array_key_exists("type", $listFields)) {
                     echo Search::showItem($output_type, $item->getTypeName(), $num, $cptRow);
                 }
                 // fabricant
                 if (array_key_exists("manufacturer", $listFields)) {
                     if ($itemtype != 'PluginRacksOtherModel') {
                         echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_manufacturers", $device["manufacturers_id"]), $num, $cptRow);
                     } else {
                         echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow);
                     }
                 }
                 // modèle //TODO = model du rack => model des objets
                 if (array_key_exists("model", $listFields)) {
                     if ($itemtype != 'PluginRacksOtherModel') {
                         $model_table = getTableForItemType($itemtype);
                         $modelfield = getForeignKeyFieldForTable(getTableForItemType($itemtype));
                         echo Search::showItem($output_type, Dropdown::getDropdownName($model_table, $device[$modelfield]), $num, $cptRow);
                     } else {
                         echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow);
                     }
                 }
                 // numéro de série
                 if (array_key_exists("serial_number", $listFields)) {
                     if ($itemtype != 'PluginRacksOtherModel') {
                         echo Search::showItem($output_type, $device['serial'], $num, $cptRow);
                     } else {
                         echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow);
                     }
                 }
                 // numéro d'inventaire
                 if (array_key_exists("other_serial", $listFields)) {
                     if ($itemtype != 'PluginRacksOtherModel') {
                         echo Search::showItem($output_type, $device['otherserial'], $num, $cptRow);
                     } else {
                         echo Search::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow);
                     }
                 }
                 $currentRack = $row['id'];
             } else {
                 for ($k = 0; $k < $cptField - 3; $k++) {
                     echo Search::showItem($output_type, "&nbsp;", $num, $cptRow, "");
                 }
             }
             echo Search::showEndLine($output_type);
         }
         if ($output_type == Search::HTML_OUTPUT) {
             Html::closeForm();
         }
         echo Search::showFooter($output_type, $title);
     }
 }
Exemple #2
0
-------------------------------------------------------------------------

LICENSE

This file is part of GLPI.

GLPI 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.

GLPI 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 GLPI. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
/** @file
* @brief
* @since version 0.84 (before states.php)
*/
include '../inc/includes.php';
Session::checkCentralAccess();
Html::header(__('Global'), $_SERVER['PHP_SELF'], "assets", "allassets");
Search::show('AllAssets');
Html::footer();
Exemple #3
0
function plugin_surveyticket_post_init()
{
    if (strpos($_SERVER['PHP_SELF'], "ticket.form.php") && !isset($_GET['id']) && (!isset($_POST['id']) || $_POST['id'] == 0) || strpos($_SERVER['PHP_SELF'], "helpdesk.public.php") && isset($_GET['create_ticket']) || strpos($_SERVER['PHP_SELF'], "tracking.injector.php")) {
        if (isset($_POST)) {
            $psQuestion = new PluginSurveyticketQuestion();
            $psAnswer = new PluginSurveyticketAnswer();
            //print_r($_POST);exit;
            $description = '';
            foreach ($_POST as $question => $answer) {
                if (strstr($question, "question") && !strstr($question, "realquestion")) {
                    $psQuestion->getFromDB(str_replace("question", "", $question));
                    if (is_array($answer)) {
                        // Checkbox
                        $description .= _n('Question', 'Questions', 1, 'surveyticket') . " : " . $psQuestion->fields['name'] . "\n";
                        foreach ($answer as $answers_id) {
                            if ($psAnswer->getFromDB($answers_id)) {
                                $description .= _n('Answer', 'Answers', 1, 'surveyticket') . " : " . $psAnswer->fields['name'] . "\n";
                                $qid = str_replace("question", "", $question);
                                if (isset($_POST["text-" . $qid . "-" . $answers_id]) and $_POST["text-" . $qid . "-" . $answers_id] != '') {
                                    $description .= "Texte : " . $_POST["text-" . $qid . "-" . $answers_id] . "\n";
                                }
                            }
                        }
                        $description .= "\n";
                        unset($_POST[$question]);
                    } else {
                        $real = 0;
                        if (isset($_POST['realquestion' . str_replace("question", "", $question)])) {
                            $realanswer = $answer;
                            $answer = $_POST['realquestion' . str_replace("question", "", $question)];
                            $real = 1;
                        }
                        if ($psAnswer->getFromDB($answer)) {
                            $description .= _n('Question', 'Questions', 1, 'surveyticket') . " : " . $psQuestion->fields['name'] . "\n";
                            if ($real == 1) {
                                $description .= _n('Answer', 'Answers', 1, 'surveyticket') . " : " . $realanswer . "\n";
                            } else {
                                $description .= _n('Answer', 'Answers', 1, 'surveyticket') . " : " . $psAnswer->fields['name'] . "\n";
                            }
                            $qid = str_replace("question", "", $question);
                            if (isset($_POST["text-" . $qid . "-" . $answer]) and $_POST["text-" . $qid . "-" . $answer] != '') {
                                $description .= "Texte : " . $_POST["text-" . $qid . "-" . $answer] . "\n";
                            }
                            $description .= "\n";
                            unset($_POST[$question]);
                        }
                    }
                }
            }
            if ($description != '') {
                $_POST['content'] = addslashes($description);
            }
        }
        if (!isset($_POST['add'])) {
            if (strpos($_SERVER['PHP_SELF'], "ticket.form.php")) {
                Html::header(__('New ticket'), '', "maintain", "ticket");
                PluginSurveyticketSurvey::getCentral();
                Html::footer();
                exit;
            } else {
                if (strpos($_SERVER['PHP_SELF'], "helpdesk.public.php") || strpos($_SERVER['PHP_SELF'], "tracking.injector.php")) {
                    Html::helpHeader(__('Simplified interface'), '', $_SESSION["glpiname"]);
                    PluginSurveyticketSurvey::getHelpdesk();
                    Html::helpFooter();
                    exit;
                }
            }
        }
    }
}
Exemple #4
0
    /**
     *  HTML for logged in users
     */
    private function loggendIn($css, $data)
    {
        $mail = '';
        if (isset($_SESSION['__sessiondata']['email'])) {
            $mail = '<span style="font-size:10px;">';
            $mail .= $_SESSION['__sessiondata']['email'];
            $mail .= '</span>';
        }
        $twitterUserForm = '';
        $shortenerForm = 'URL shortener: ';
        if ($data) {
            if (isset($data->twitter) && $data->twitter) {
                foreach ($data->twitter as $tw) {
                    $twitterUserForm .= '<input type="checkbox" name="postdata[twitterUser][]" value="' . $tw['username'] . '" style="float:none;" ><span style="margin-right:3px;">' . $tw['username'] . '</span>';
                    // . '<br />';
                }
            }
            if (isset($data->shortener) && $data->shortener) {
                $i = 1;
                foreach ($data->shortener as $sh) {
                    $shortenerForm .= '<input type="radio" name="postdata[shortener]" value="' . $sh['service'] . '|' . $sh['username'] . '" ' . ($i === 1 ? 'checked=checked' : '') . ' style="margin:0;float:left;" /><span style="margin-right:3px;">' . $sh['username'] . ' ' . $sh['service'] . '</span>';
                    $i++;
                }
            }
        }
        // get Header
        $html = Html::header($css, $mail);
        $html .= <<<HTMLSTUFF
<div id="socialRouter_main">
    <form id="socialRouterForm" name="socialRouterForm" accept-charset="utf-8" action="http://sr2.soluch.at/load/delegateMessage/" method="post" target="_blank" >
        <textarea id="sr_textarea" name="postdata[message]" cols="35" rows="3" >
    
    {$data->shorturl}
    
    </textarea>
    
    {$shortenerForm}
    
    <div style="float:right;">chars used: <span id="sr_charCount" style="color:#D94432;font-weight:bold;"></span></div>
    <hr />
        <!--input id="twitteruser" type="text" maxlength="30" name="postdata[twitteruser]" value="php_live" /-->
        <a href="http://sr2.soluch.at/twitter/add/" target="_blank" >add a twitter account</a><br />
    
        {$twitterUserForm}
    
        <br />
        <hr />
    \t<input type="submit" value="Route" id="submitSocial" />
    </form>
    
    
    <div id="otherContent">
    </div>
</div>
HTMLSTUFF;
        // get Footer
        $html .= Html::footer();
        return $html;
    }
Exemple #5
0
$h->setBackRef();
// Html fejléc
$h->header("2015.  - T5C5");
$h->msgOk("2015. évi T5C5  dátumok");
$h->btnMenu(array("Átfutási idők - diagram" => "t5c52015diagram.php", "Vissza a főmenühöz" => "index.php"));
$sql = "select id, psz, ";
$sql .= "sorszam, erkezett, allapotfelvetel, reszatvetel, vegatvetel, hazaadas, megjegyzes ";
$sql .= "from jarmu_alap where ev=2015 and jarmutipus ilike 't5c5k2mod' order by sorszam";
$res = $pg->query($sql);
// Van-e visszaadott sor
$count = $res->rowCount();
if ($res) {
    if ($count) {
        echo "<table class='jmu-info-table' border=1 style='border-collapse:collapse'>";
        $h->infoTableCaption("2015. évi T5C5 kocsik");
        echo "<tr>\r\n    <th>Pályaszám</th>\r\n    <th>Sorszám</th>\r\n    <th>Érkezett</th>\r\n    <th>Állapotfelvétel</th>\r\n    <th>Részátvétel</th>\r\n    <th>Végátvétel</th>\r\n    <th>Hazaadás</th>\r\n    <th>Megjegyzés</th>\r\n    </tr>";
        while ($row = $res->fetch(PDO::FETCH_BOTH)) {
            echo "<tr onclick=jmuInfo({$row['0']});>\r\n      <td class='tdc5p'>{$row['1']}</td>\r\n      <td class='tdc5p'>{$row['2']}</td>\r\n      <td class='tdc5p'>{$row['3']}</td>\r\n      <td class='tdc5p'>{$row['4']}</td>\r\n      <td class='tdc5p'>{$row['5']}</td>\r\n      <td class='tdc5p'>{$row['6']}</td>\r\n      <td class='tdc5p'>{$row['7']}</td>\r\n      <td class='tdc5p'>{$row['8']}</td>\r\n      </tr>";
        }
        echo "</table>";
    } else {
        $h->msgWarn("A kérés nem hozott eredményt!");
    }
}
// Oldal alja gombok:
$h->separator();
$h->btnBack();
$h->btnExit();
$h->btnPrint();
$h->footer();
Exemple #6
0
 public function showResult($output_type, $limit = 0, $params = array())
 {
     global $DB;
     $arrayRet = $this->execQuery($_REQUEST);
     $result = $arrayRet['query_result'];
     $query = $arrayRet['query'];
     $nbtot = $result ? $DB->numrows($result) : 0;
     if ($limit) {
         $start = isset($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
         if ($start >= $nbtot) {
             $start = 0;
         }
         if ($start > 0 || $start + $limit < $nbtot) {
             $result = $DB->query($query . " LIMIT {$start},{$limit}");
         }
     } else {
         $start = 0;
     }
     $nbCols = $DB->num_fields($result);
     $nbrows = $DB->numrows($result);
     $groupByRackName = true;
     if (isset($_REQUEST['groupByRackName']) && $_REQUEST['groupByRackName'] == "on") {
         $groupByRackName = false;
     }
     $title = date("d/m/Y H:i");
     if ($nbtot == 0) {
         echo "<div class='center'><font class='red b'>" . __("No item found") . "</font></div>";
         Html::footer();
     } else {
         if ($output_type == Search::HTML_OUTPUT) {
             echo "<div class='center'><table class='tab_cadre_fixe'>";
             echo "<tr  class='tab_bg_1'><th>{$title}</th></tr>\n";
             echo "<tr class='tab_bg_2 center'><td class='center'>";
             $parameters = null;
             $parameters .= Toolbox::append_params($_REQUEST, '&amp;');
             $this->printPager($start, $nbtot, $_SERVER["PHP_SELF"], $parameters, 'PluginRacksRack');
         }
     }
     if ($nbtot > 0) {
         if ($output_type == Search::HTML_OUTPUT) {
             echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}'>\n";
         }
         echo Search::showHeader($output_type, $nbrows, $nbCols, true);
         echo Search::showNewLine($output_type);
         $showAllFieds = true;
         $listFields = array();
         $cptField = 0;
         $showAllFieds = (!isset($_REQUEST['cb_object_name']) || $_REQUEST['cb_object_name'] != "on") && (!isset($_REQUEST['cb_object_location']) || $_REQUEST['cb_object_location'] != "on") && (!isset($_REQUEST['cb_group']) || $_REQUEST['cb_group'] != "on") && (!isset($_REQUEST['cb_manufacturer']) || $_REQUEST['cb_manufacturer'] != "on") && (!isset($_REQUEST['cb_model']) || $_REQUEST['cb_model'] != "on") && (!isset($_REQUEST['cb_serial_number']) || $_REQUEST['cb_serial_number'] != "on");
         $num = 1;
         $cptRow = 1;
         if (!$showAllFieds) {
             $this->showTitle($output_type, $num, __("Bay name", "racks"), 'name', false, $params);
             $cptField++;
             $this->showTitle($output_type, $num, __("Location"), 'location', false, $params);
             $cptField++;
             $this->showTitle($output_type, $num, _n("Place", "Places", 1, "racks"), 'roomlocation', false, $params);
             $cptField++;
             $this->showTitle($output_type, $num, __("U", "racks"), 'u', false, $params);
             $cptField++;
             $this->showTitle($output_type, $num, __("Front", "racks") . " / " . _x('Rack enclosure', 'Back', 'racks'), 'front_rear', false, $params);
             $cptField++;
             if (isset($_REQUEST['cb_object_name']) && $_REQUEST['cb_object_name'] == "on") {
                 $listFields['object_name'] = $_REQUEST['cb_object_name'];
                 $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false, $params);
                 $cptField++;
             }
             // Lieu
             if (isset($_REQUEST['cb_object_location']) && $_REQUEST['cb_object_location'] == "on") {
                 $listFields['object_location'] = $_REQUEST['cb_object_location'];
                 $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false, $params);
                 $cptField++;
             }
             // Groupe
             if (isset($_REQUEST['cb_group']) && $_REQUEST['cb_group'] == "on") {
                 $listFields['group'] = $_REQUEST['cb_group'];
                 $this->showTitle($output_type, $num, __("Group"), 'group', false, $params);
                 $cptField++;
             }
             // Fabricant
             if (isset($_REQUEST['cb_manufacturer']) && $_REQUEST['cb_manufacturer'] == "on") {
                 $listFields['manufacturer'] = $_REQUEST['cb_manufacturer'];
                 $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false, $params);
                 $cptField++;
             }
             // Modèle
             if (isset($_REQUEST['cb_model']) && $_REQUEST['cb_model'] == "on") {
                 $listFields['model'] = $_REQUEST['cb_model'];
                 $this->showTitle($output_type, $num, __("Model"), 'model', false, $params);
                 $cptField++;
             }
             // Numéro de série
             if (isset($_REQUEST['cb_serial_number']) && $_REQUEST['cb_serial_number'] == "on") {
                 $listFields['serial_number'] = $_REQUEST['cb_serial_number'];
                 $this->showTitle($output_type, $num, __("Serial number"), 'group', false, $params);
                 $cptField++;
             }
         } else {
             $this->showTitle($output_type, $num, __("Bay name", "racks"), 'rack_name', false, $params);
             $listFields['rack_name'] = true;
             $this->showTitle($output_type, $num, __("Location"), 'location', false, $params);
             $listFields['location'] = true;
             $this->showTitle($output_type, $num, _n("Place", "Places", 1, "racks"), 'roomlocation', false, $params);
             $listFields['roomlocation'] = true;
             $this->showTitle($output_type, $num, __("U", "racks"), 'u', false, $params);
             $listFields['u'] = true;
             $this->showTitle($output_type, $num, __("Front", "racks") . " / " . _x('Rack enclosure', 'Back', 'racks'), 'front_rear', false, $params);
             $listFields['front_rear'] = true;
             $this->showTitle($output_type, $num, __("Object name", "racks"), 'object_name', false, $params);
             $listFields['object_name'] = true;
             $this->showTitle($output_type, $num, __("Object location", "racks"), 'object_location', false, $params);
             $listFields['object_location'] = true;
             $this->showTitle($output_type, $num, __("Group"), 'group', false, $params);
             $listFields['group'] = true;
             $this->showTitle($output_type, $num, __("Type"), 'type', false, $params);
             $listFields['type'] = true;
             $this->showTitle($output_type, $num, __("Manufacturer"), 'manufacturer', false, $params);
             $listFields['manufacturer'] = true;
             $this->showTitle($output_type, $num, __("Model"), 'model', false, $params);
             $listFields['model'] = true;
             $this->showTitle($output_type, $num, __("Serial number"), 'serial_number', false, $params);
             $listFields['serial_number'] = true;
             $this->showTitle($output_type, $num, __("Inventory number"), 'other_serial', false, $params);
             $listFields['other_serial'] = true;
             $cptField = 13;
         }
         echo self::showEndLine($output_type, $params);
         $num = 1;
         $cptRow = 1;
         $currentRack = -1;
         while ($row = $DB->fetch_array($result)) {
             // itemtype
             $itemtype = $row['itemtype'];
             $num = 1;
             $cptRow++;
             echo Search::showNewLine($output_type);
             if (isset($row['itemtype']) && $row['itemtype'] != "") {
                 $class = substr($itemtype, 0, -5);
                 $item = new $class();
                 $table = getTableForItemType($class);
                 $r = $DB->query("SELECT * FROM `" . $table . "` WHERE `id` = '" . $row["items_id"] . "' ");
                 $device = $DB->fetch_array($r);
             }
             // nom
             $link = Toolbox::getItemTypeFormURL("PluginRacksRack");
             if ($groupByRackName || $currentRack != $row['id']) {
                 if ($output_type == Search::HTML_OUTPUT) {
                     echo self::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["id"] . "\">" . $row["name"] . "</a>", $num, $cptRow, null, $params);
                 } else {
                     echo self::showItem($output_type, $row["name"], $num, $cptRow, null, $params);
                 }
             } else {
                 echo self::showItem($output_type, "&nbsp;", $num, $cptRow, null, $params);
             }
             // lieu
             if ($groupByRackName || $currentRack != $row['id']) {
                 if (isset($row['locations_id'])) {
                     echo self::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $row['locations_id']), $num, $cptRow, null, $params);
                 } else {
                     echo self::showItem($output_type, "&nbsp;", $num, $cptRow, null, $params);
                 }
             } else {
                 echo self::showItem($output_type, "&nbsp;", $num, $cptRow, null, $params);
             }
             // Emplacement
             if ($groupByRackName || $currentRack != $row['id']) {
                 $tmpId = $row['plugin_racks_roomlocations_id'];
                 $tmpId = $row['plugin_racks_roomlocations_id'];
                 $tmpObj = new PluginRacksRoomLocation();
                 $trans_name = "";
                 if ($tmpObj->getFromDB($tmpId)) {
                     $trans_name = $tmpObj->fields['name'];
                 }
                 $trans = DropdownTranslation::getTranslatedValue($tmpId, "PluginRacksRoomLocation", 'name', $_SESSION['glpilanguage']);
                 if (!empty($trans)) {
                     $trans_name = $trans;
                 }
                 if (isset($tmpId)) {
                     echo self::showItem($output_type, $trans_name, $num, $cptRow, null, $params);
                 } else {
                     echo self::showItem($output_type, '&nbsp;', $num, $cptRow, null, $params);
                 }
             } else {
                 echo self::showItem($output_type, "&nbsp;", $num, $cptRow, null, $params);
             }
             if (isset($row['itemtype']) && $row['itemtype'] != "") {
                 // U
                 if (isset($row['position']) && $row['position'] != "") {
                     echo self::showItem($output_type, $row['position'], $num, $cptRow, null, $params);
                 } else {
                     echo self::showItem($output_type, "&nbsp;", $num, $cptRow, null, $params);
                 }
                 // avant / arrière
                 if ($row['faces_id'] == 1) {
                     echo self::showItem($output_type, __("Front", "racks"), $num, $cptRow, null, $params);
                 } else {
                     echo self::showItem($output_type, _x('Rack enclosure', 'Back', 'racks'), $num, $cptRow, null, $params);
                 }
                 // Nom de l'objet
                 if (array_key_exists("object_name", $listFields)) {
                     $link = Toolbox::getItemTypeFormURL(substr($itemtype, 0, -5));
                     if ($itemtype != 'PluginRacksOtherModel') {
                         if ($output_type == Search::HTML_OUTPUT) {
                             echo self::showItem($output_type, "<a href=\"" . $link . "?id=" . $row["items_id"] . "\">" . $device["name"] . "</a>", $num, $cptRow, null, $params);
                         } else {
                             echo self::showItem($output_type, $device["name"], $num, $cptRow, null, $params);
                         }
                     } else {
                         echo self::showItem($output_type, $device["name"], $num, $cptRow, null, $params);
                     }
                 }
                 // Lieu de l'objet
                 if (array_key_exists("object_location", $listFields)) {
                     if ($itemtype != 'PluginRacksOtherModel') {
                         echo self::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $device["locations_id"]), $num, $cptRow, null, $params);
                     } else {
                         echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params);
                     }
                 }
                 // Groupe
                 if (array_key_exists("group", $listFields)) {
                     // Groupe
                     if ($itemtype != 'PluginRacksOtherModel') {
                         echo self::showItem($output_type, Dropdown::getDropdownName("glpi_groups", $device["groups_id_tech"]), $num, $cptRow, null, $params);
                     } else {
                         echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params);
                     }
                 }
                 // type
                 if (array_key_exists("type", $listFields)) {
                     echo self::showItem($output_type, $item->getTypeName(), $num, $cptRow, null, $params);
                 }
                 // fabricant
                 if (array_key_exists("manufacturer", $listFields)) {
                     if ($itemtype != 'PluginRacksOtherModel') {
                         echo self::showItem($output_type, Dropdown::getDropdownName("glpi_manufacturers", $device["manufacturers_id"]), $num, $cptRow, null, $params);
                     } else {
                         echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params);
                     }
                 }
                 // modèle
                 if (array_key_exists("model", $listFields)) {
                     $model_table = getTableForItemType($itemtype);
                     $modelfield = getForeignKeyFieldForTable(getTableForItemType($itemtype));
                     echo self::showItem($output_type, Dropdown::getDropdownName($model_table, $device[$modelfield]), $num, $cptRow, null, $params);
                 }
                 // numéro de série
                 if (array_key_exists("serial_number", $listFields)) {
                     if ($itemtype != 'PluginRacksOtherModel') {
                         echo self::showItem($output_type, $device['serial'], $num, $cptRow, null, $params);
                     } else {
                         echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params);
                     }
                 }
                 // numéro d'inventaire
                 if (array_key_exists("other_serial", $listFields)) {
                     if ($itemtype != 'PluginRacksOtherModel') {
                         echo self::showItem($output_type, $device['otherserial'], $num, $cptRow, null, $params);
                     } else {
                         echo self::showItem($output_type, Dropdown::EMPTY_VALUE, $num, $cptRow, null, $params);
                     }
                 }
                 $currentRack = $row['id'];
             } else {
                 for ($k = 0; $k < $cptField - 3; $k++) {
                     echo self::showItem($output_type, "&nbsp;", $num, $cptRow, null, $params);
                 }
             }
             echo self::showEndLine($output_type, $params);
         }
         echo self::showFooter($output_type, $title, $params);
         if ($output_type == Search::HTML_OUTPUT) {
             Html::closeForm();
         }
     }
 }
 /**
  * Execute the report
  *
  * @param $options   array
  **/
 function execute($options = array())
 {
     global $DB, $CFG_GLPI, $HEADER_LOADED;
     // Require (for pager) when not called by displayCriteriasForm
     $this->manageCriteriasValues();
     if (isset($_POST['list_limit'])) {
         $_SESSION['glpilist_limit'] = $_POST['list_limit'];
         unset($_POST['list_limit']);
     }
     $limit = $_SESSION['glpilist_limit'];
     if (isset($_POST["display_type"])) {
         $output_type = $_POST["display_type"];
         if ($output_type < 0) {
             $output_type = -$output_type;
             $limit = 0;
         }
     } else {
         $output_type = Search::HTML_OUTPUT;
     }
     $title = $this->title;
     if ($this->subname) {
         $title = sprintf(__('%1$s - %2$s'), $title, $this->subname);
     }
     $res = $DB->query($this->sql);
     $nbtot = $res ? $DB->numrows($res) : 0;
     if ($limit) {
         $start = isset($_GET["start"]) ? $_GET["start"] : 0;
         if ($start >= $nbtot) {
             $start = 0;
         }
         if ($start > 0 || $start + $limit < $nbtot) {
             $res = $DB->query($this->sql . " LIMIT {$start},{$limit}");
         }
     } else {
         $start = 0;
     }
     if ($nbtot == 0) {
         if (!$HEADER_LOADED) {
             Html::header($title, $_SERVER['PHP_SELF'], "utils", "report");
             Report::title();
         }
         echo "<div class='center'><font class='red b'>" . __('No item found') . "</font></div>";
         Html::footer();
     } else {
         if ($output_type == Search::PDF_OUTPUT_PORTRAIT || $output_type == Search::PDF_OUTPUT_LANDSCAPE) {
             include GLPI_ROOT . "/lib/ezpdf/class.ezpdf.php";
         } else {
             if ($output_type == Search::HTML_OUTPUT) {
                 if (!$HEADER_LOADED) {
                     Html::header($title, $_SERVER['PHP_SELF'], "utils", "report");
                     Report::title();
                 }
                 echo "<div class='center'><table class='tab_cadre_fixe'>";
                 echo "<tr><th>" . $title . "</th></tr>\n";
                 echo "<tr class='tab_bg_2 center'><td class='center'>";
                 echo "<form method='POST' action='" . $_SERVER["PHP_SELF"] . "?start={$start}'>\n";
                 $param = "";
                 foreach ($_POST as $key => $val) {
                     if (is_array($val)) {
                         foreach ($val as $k => $v) {
                             echo "<input type='hidden' name='" . $key . "[{$k}]' value='{$v}' >";
                             if (!empty($param)) {
                                 $param .= "&";
                             }
                             $param .= $key . "[" . $k . "]=" . urlencode($v);
                         }
                     } else {
                         echo "<input type='hidden' name='" . $key . "' value='{$val}' >";
                         if (!empty($param)) {
                             $param .= "&";
                         }
                         $param .= "{$key}=" . urlencode($val);
                     }
                 }
                 Dropdown::showOutputFormat();
                 Html::closeForm();
                 echo "</td></tr>";
                 echo "</table></div>";
                 Html::printPager($start, $nbtot, $_SERVER['PHP_SELF'], $param);
             }
         }
     }
     if (!isset($_POST["display_type"]) || $_POST["display_type"] == Search::HTML_OUTPUT) {
         if (isset($options['withmassiveaction']) && class_exists($options['withmassiveaction'])) {
             echo "<form method='post' name='massiveaction_form' id='massiveaction_form' action=\"" . $CFG_GLPI["root_doc"] . "/front/massiveaction.php\">";
         }
     }
     plugin_reports_checkRight($this->plug, $this->name, "r");
     if ($res && $nbtot > 0) {
         $nbcols = $DB->num_fields($res);
         $nbrows = $DB->numrows($res);
         echo Search::showHeader($output_type, $nbrows, $nbcols, true);
         echo Search::showNewLine($output_type);
         $num = 1;
         // fill $sqlcols with default sql query fields so we can validate $columns
         $sqlcols = array();
         for ($i = 0; $i < $nbcols; $i++) {
             $colname = $DB->field_name($res, $i);
             $sqlcols[] = $colname;
         }
         $colsname = array();
         // if $columns is not empty, display $columns
         if (count($this->columns) > 0) {
             foreach ($this->columns as $colname => $column) {
                 // display only $columns that are valid
                 if (in_array($colname, $sqlcols)) {
                     $column->showTitle($output_type, $num);
                     $colsname[$colname] = $column;
                 }
             }
         } else {
             // else display default columns from SQL query
             foreach ($sqlcols as $colname) {
                 $column = new PluginReportsColumn($colname, $colname);
                 $column->showTitle($output_type, $num);
                 $colsname[$colname] = $column;
             }
         }
         echo Search::showEndLine($output_type);
         $prev = "";
         for ($row_num = 2; $row = $DB->fetch_assoc($res); $row_num++) {
             $crt = "";
             foreach ($this->group_by as $colname) {
                 if (isset($row[$colname])) {
                     $crt .= $row[$colname] . "####";
                 }
             }
             echo Search::showNewLine($output_type);
             $num = 1;
             foreach ($colsname as $colname => $column) {
                 //If value needs to be modified on the fly
                 if (isset($this->columns_mapping[$colname]) && isset($this->columns_mapping[$colname][$row[$colname]])) {
                     $new_value = $this->columns_mapping[$colname][$row[$colname]];
                     $row[$colname] = $new_value;
                 }
                 if (!in_array($colname, $this->group_by)) {
                     $column->showValue($output_type, $row, $num, $row_num);
                 } else {
                     if ($crt == $prev) {
                         $column->showValue($output_type, $output_type == Search::CSV_OUTPUT ? $row : array(), $num, $row_num);
                     } else {
                         $column->showValue($output_type, $row, $num, $row_num, true);
                     }
                 }
             }
             // Each column
             echo Search::showEndLine($output_type);
             $prev = $crt;
         }
         // Each row
         if (isset($options['withtotal']) && $options['withtotal']) {
             echo Search::showNewLine($output_type);
             $num = 1;
             foreach ($colsname as $colname => $column) {
                 $column->showTotal($output_type, $num, $row_num);
             }
             echo Search::showEndLine($output_type);
         }
     }
     echo Search::showFooter($output_type, $title);
     if (!isset($_POST["display_type"]) || $_POST["display_type"] == Search::HTML_OUTPUT) {
         if (isset($options['withmassiveaction']) && class_exists($options['withmassiveaction'])) {
             Html::openArrowMassives("massiveaction_form", true);
             Dropdown::showForMassiveAction($options['withmassiveaction']);
             $options = array();
             Html::closeArrowMassives($options);
             Html::closeForm();
         }
         Html::footer();
     }
 }
 static function selectGroupOnAdd($item)
 {
     global $CFG_GLPI, $DB;
     if (isset($item->input['_auto_import']) || isset($item->input['bypassgrouponadd'])) {
         return;
     }
     $peGroup_group = new self();
     if ($_SESSION['glpiactiveprofile']['interface'] == 'central') {
         $peConfig = new PluginEscalationConfig();
         if ($peConfig->getValue('workflow', $item->fields['entities_id']) == '1') {
             if (isset($_POST['_groups_id_assign']) && $_POST['_groups_id_assign'] > 0) {
                 if (isset($_SESSION['plugin_escalation_files'])) {
                     $_FILES = $_SESSION['plugin_escalation_files'];
                 }
                 return;
             } else {
                 $group = new Group();
                 Html::header(__('Administration'), '', "maintain", "ticket");
                 if (isset($_POST['dropdown__groups_id_requester']) && $_POST['dropdown__groups_id_requester'] > 0) {
                     $_SESSION['plugin_escalation_groups_id_requester'] = $_POST['dropdown__groups_id_requester'];
                 }
                 if (isset($_FILES)) {
                     foreach ($_FILES['filename']['tmp_name'] as $numfile => $datafile) {
                         if ($datafile != '') {
                             $split = explode("/", $datafile);
                             Document::renameForce($datafile, GLPI_DOC_DIR . "/_tmp/" . end($split));
                             $_FILES['filename']['tmp_name'][$numfile] = GLPI_DOC_DIR . "/_tmp/" . end($split);
                         }
                     }
                     $_SESSION['plugin_escalation_files'] = $_FILES;
                 }
                 echo '<form action="' . $CFG_GLPI['root_doc'] . '/front/ticket.form.php"
               enctype="multipart/form-data" name="form_ticket" method="post">';
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<th colspan='2'>Sélection du groupe de techniciens</th>";
                 echo "</tr>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<td>";
                 echo __('Group in charge of the ticket') . "&nbsp;:";
                 echo "</td>";
                 echo "<td>";
                 $a_groups = array();
                 foreach ($_SESSION['glpigroups'] as $groups_id) {
                     $group->getFromDB($groups_id);
                     $a_groups[$groups_id] = $group->getName();
                     $queryg = "SELECT * FROM `" . $peGroup_group->getTable() . "`\n                     WHERE `groups_id_source` = '" . $groups_id . "' ";
                     $resultg = $DB->query($queryg);
                     while ($datag = $DB->fetch_array($resultg)) {
                         $group->getFromDB($datag['groups_id_destination']);
                         $a_groups[$groups_id . "_" . $datag['groups_id_destination']] = "&nbsp;&nbsp;&nbsp;> " . $group->getName();
                     }
                 }
                 $rand = Dropdown::showFromArray("_groups_id_assign_escalation", $a_groups);
                 $params = array('groups_id' => '__VALUE__', 'entity' => $_POST['entities_id'], 'rand' => $rand);
                 Ajax::updateItemOnSelectEvent("dropdown__groups_id_assign" . $rand, "show_assignuser{$rand}", $CFG_GLPI["root_doc"] . "/plugins/escalation/ajax/dropdownUserassign.php", $params);
                 echo "</tr>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<td colspan='2'>";
                 foreach ($_POST as $key => $value) {
                     if (is_array($value)) {
                         foreach ($value as $keyy => $valuee) {
                             echo '<input type="hidden" name="' . $key . '[' . $keyy . ']" value="' . $valuee . '" />';
                         }
                     } else {
                         if ($key == 'content') {
                             $value = Html::cleanPostForTextArea(Toolbox::clean_cross_side_scripting_deep($value));
                             echo '<textarea name="' . $key . '" style="display:none;">' . $value . '</textarea>';
                         } else {
                             if ($key == 'dropdown__groups_id_requester') {
                                 echo '<input type="hidden" name="_groups_id_requester" value="' . $value . '" />';
                             } else {
                                 $value = Html::cleanInputText(Toolbox::clean_cross_side_scripting_deep(stripslashes($value)));
                                 echo '<input type="hidden" name="' . $key . '" value="' . $value . '" />';
                             }
                         }
                     }
                 }
                 if (!isset($_POST['_users_id_assign']) or $_POST['_users_id_assign'] == '0') {
                     echo "<span id='show_assignuser{$rand}'></span>";
                 }
                 echo "</td>";
                 echo "</tr>";
                 echo "<tr class='tab_bg_1'>";
                 echo "<td colspan='2' align='center'>";
                 echo "<input type='submit' name='add' value=\"" . __('Add') . "\" class='submit'>";
                 echo "</td>";
                 echo "</tr>";
                 echo "</table>";
                 Html::closeForm();
                 Html::footer();
                 exit;
             }
         }
     }
 }