function showQuestions($items_id) { global $CFG_GLPI; $psQuestion = new PluginSurveyticketQuestion(); echo "<form method='post' name='form_addquestion' action='" . $CFG_GLPI['root_doc'] . "/plugins/surveyticket/front/surveyquestion.form.php'>"; echo "<table class='tab_cadre' width='700'>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . _n('Question', 'Questions', 1, 'surveyticket') . " :</td>"; echo "<td>"; $a_questions = $this->find("`plugin_surveyticket_surveys_id`='" . $items_id . "'", "`order`"); $a_used = array(); foreach ($a_questions as $data) { $a_used[] = $data['plugin_surveyticket_questions_id']; } Dropdown::show("PluginSurveyticketQuestion", array("name" => "plugin_surveyticket_questions_id", "used" => $a_used)); echo "</td>"; echo "<td>" . __('Position') . " :</td>"; echo "<td>"; Dropdown::showInteger("order", "0", 0, 20); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class='tab_bg_2 top' colspan='4'>"; echo "<input type='hidden' name='plugin_surveyticket_surveys_id' value='" . $items_id . "'>"; echo "<div class='center'>"; echo "<input type='submit' name='add' value=\"" . __('Add') . "\" class='submit'>"; echo "</div></td></tr>"; echo "</table>"; Html::closeForm(); // list questions echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; echo _n('Question', 'Questions', 1, 'surveyticket'); echo "</th>"; echo "<th>"; echo __('Type'); echo "</th>"; echo "<th>"; echo __('Position'); echo "</th>"; echo "<th>"; echo "</th>"; echo "</tr>"; foreach ($a_questions as $data) { echo "<tr class='tab_bg_1'>"; echo "<td>"; $psQuestion->getFromDB($data['plugin_surveyticket_questions_id']); echo $psQuestion->getLink(1); echo "</td>"; echo "<td>"; echo PluginSurveyticketQuestion::getQuestionTypeName($psQuestion->fields['type']); echo "</td>"; echo "<td>"; echo $data['order']; echo "</td>"; echo "<td align='center'>"; echo "<form method='post' name='form_addquestion' action='" . $CFG_GLPI['root_doc'] . "/plugins/surveyticket/front/surveyquestion.form.php'>"; echo "<input type='hidden' name='id' value='" . $data['id'] . "'>"; echo "<input type='submit' name='delete' value=\"" . _sx('button', 'Delete permanently') . "\" class='submit'>"; Html::closeForm(); echo "</td>"; echo "</tr>"; } echo "</table>"; }
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') . " :</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') . " :</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') . " :"; } 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') . " :</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') . " :</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; }