示例#1
0
 function showForm($items_id, $options = array())
 {
     if ($items_id != '') {
         $this->getFromDB($items_id);
     } else {
         $this->getEmpty();
         if (isset($_SESSION['glpi_plugins_surveyticket']['questions_id'])) {
             $this->fields['plugin_surveyticket_questions_id'] = $_SESSION['glpi_plugins_surveyticket']['questions_id'];
         }
     }
     $this->initForm($items_id, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Answer', 'Answers', 1, 'surveyticket') . "&nbsp;:</td>";
     echo "<td colspan='3'>";
     $psQuestion = new PluginSurveyticketQuestion();
     $psQuestion->getFromDB($this->fields['plugin_surveyticket_questions_id']);
     echo $psQuestion->getLink();
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Label') . "&nbsp;:</td>";
     echo "<td>";
     if ($psQuestion->fields['type'] == 'date') {
         echo '<i>' . __('date') . '</i>';
     } else {
         if ($psQuestion->fields['type'] == 'input') {
             echo '<i>' . __('Short text', 'surveyticket') . '</i>';
         } else {
             echo '<textarea maxlength="255" cols="70" rows="3"
         name="name">' . $this->fields["name"] . '</textarea>';
         }
     }
     echo "</td>";
     echo "<td>";
     $psQuestion = new PluginSurveyticketQuestion();
     $psQuestion->getFromDB($_SESSION['glpi_plugins_surveyticket']['questions_id']);
     if ($psQuestion->fields['type'] != 'date' && $psQuestion->fields['type'] != 'input') {
         echo __('+ field', 'surveyticket') . "&nbsp;:";
     }
     echo "</td>";
     echo "<td>";
     $texttype = array();
     $texttype[''] = Dropdown::EMPTY_VALUE;
     $texttype['shorttext'] = __('Text') . " - court";
     $texttype['longtext'] = __('Text') . " - long";
     $texttype['date'] = __('Date');
     $texttype['number'] = __('Number');
     if ($psQuestion->fields['type'] != 'date' && $psQuestion->fields['type'] != 'input') {
         Dropdown::showFromArray("answertype", $texttype, array('value' => $this->fields['answertype']));
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Linked to question', 'surveyticket') . "&nbsp;:</td>";
     echo "<td colspan='3'>";
     Dropdown::show("PluginSurveyticketQuestion", array('name' => 'plugin_surveyticket_questions_id', 'value' => $this->fields['plugin_surveyticket_questions_id']));
     echo "</td>";
     echo "</tr>";
     if ($psQuestion->fields['type'] != "checkbox") {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Go to question', 'surveyticket') . "&nbsp;:</td>";
         echo "<td colspan='3'>";
         Dropdown::show("PluginSurveyticketQuestion", array('name' => 'link', 'value' => $this->fields['link'], 'used' => array($psQuestion->getID())));
         echo "</td>";
         echo "</tr>";
     }
     $this->showFormButtons($options);
     return true;
 }