/**
  * Print the hidden fields
  *
  * @since version 0.83
  *
  * @param $tt                       Ticket Template
  * @param $withtemplate    boolean  Template or basic item (default '')
  *
  * @return Nothing (call to classes members)
  **/
 static function showForTicketTemplate(TicketTemplate $tt, $withtemplate = '')
 {
     global $DB;
     $ID = $tt->fields['id'];
     if (!$tt->getFromDB($ID) || !$tt->can($ID, READ)) {
         return false;
     }
     $ttm = new self();
     $used = $ttm->getHiddenFields($ID);
     $canedit = $tt->canEdit($ID);
     $fields = $tt->getAllowedFieldsNames(false, isset($used['itemtype']));
     $rand = mt_rand();
     $query = "SELECT `glpi_tickettemplatehiddenfields`.*\n                FROM `glpi_tickettemplatehiddenfields`\n                WHERE (`tickettemplates_id` = '{$ID}')";
     if ($result = $DB->query($query)) {
         $hiddenfields = array();
         $used = array();
         if ($numrows = $DB->numrows($result)) {
             while ($data = $DB->fetch_assoc($result)) {
                 $hiddenfields[$data['id']] = $data;
                 $used[$data['num']] = $data['num'];
             }
         }
         if ($canedit) {
             echo "<div class='firstbloc'>";
             echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n                   action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a hidden field') . "</th></tr>";
             echo "<tr class='tab_bg_2'><td class='right'>";
             echo "<input type='hidden' name='tickettemplates_id' value='{$ID}'>";
             Dropdown::showFromArray('num', $fields, array('used' => $used));
             echo "</td><td class='center'>";
             echo "&nbsp;<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             echo "</td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
         echo "<div class='spaced'>";
         if ($canedit && $numrows) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr class='noHover'><th colspan='2'>";
         echo self::getTypeName($DB->numrows($result));
         echo "</th></tr>";
         if ($numrows) {
             $header_begin = "<tr>";
             $header_top = '';
             $header_bottom = '';
             $header_end = '';
             if ($canedit) {
                 $header_top .= "<th width='10'>";
                 $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
                 $header_bottom .= "<th width='10'>";
                 $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
             }
             $header_end .= "<th>" . __('Name') . "</th>";
             $header_end .= "</tr>";
             echo $header_begin . $header_top . $header_end;
             foreach ($hiddenfields as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
                 }
                 echo "<td>" . $fields[$data['num']] . "</td>";
                 echo "</tr>";
             }
             echo $header_begin . $header_bottom . $header_end;
         } else {
             echo "<tr><th colspan='2'>" . __('No item found') . "</th></tr>";
         }
         echo "</table>";
         if ($canedit && $numrows) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
         echo "</div>";
     }
 }