Skip to content

Commit

Permalink
refactor(formanswer): use HTML class, remove unused var
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Oct 17, 2019
1 parent fa86deb commit 75f7b0b
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions inc/formanswer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ public function showForm($ID, $options = []) {

$canEdit = $this->fields['status'] == self::STATUS_REFUSED
&& $_SESSION['glpiID'] == $this->fields['requester_id'];
$canValidate = $this->canValidate();

echo '<tr><td colspan="4" class="formcreator_form form_horizontal">';

Expand Down Expand Up @@ -612,23 +611,29 @@ public function showForm($ID, $options = []) {
echo '</div>';

// Display validation form
} else if (($this->fields['status'] == self::STATUS_WAITING) && $canValidate) {
} else if (($this->fields['status'] == self::STATUS_WAITING) && $this->canValidate()) {
echo '<div class="form-group required line1">';
echo '<label for="comment">' . __('Comment', 'formcreator') . ' <span class="red">*</span></label>';
echo '<textarea class="form-control"
rows="5"
name="comment"
id="comment">' . $this->fields['comment'] . '</textarea>';
Html::textarea([
'name' => 'comment',
'value' => $this->fields['comment']
]);
echo '<div class="help-block">' . __('Required if refused', 'formcreator') . '</div>';
echo '</div>';

echo '<div class="form-group line1">';
echo '<div class="center" style="float: left; width: 50%;">';
echo '<input type="submit" name="refuse_formanswer" class="submit_button"
value="' . __('Refuse', 'formcreator') . '" onclick="return checkComment(this);" />';
echo Html::submit(
__('Refuse', 'formcreator'), [
'name' => 'refuse_formanswer',
'onclick' => 'return checkComment(this)',
]);
echo '</div>';
echo '<div class="center">';
echo '<input type="submit" name="accept_formanswer" class="submit_button" value="' . __('Accept', 'formcreator') . '" />';
echo Html::submit(
__('Accept', 'formcreator'), [
'name' => 'accept_formanswer',
]);
echo '</div>';
echo '</div>';
$options['canedit'] = true;
Expand All @@ -643,7 +648,7 @@ public function showForm($ID, $options = []) {
// echo '</form>';
echo '<script type="text/javascript">
function checkComment(field) {
if (document.getElementById("comment").value == "") {
if ($("textarea[name=comment]").val() == "") {
alert("' . __('Refused comment is required!', 'formcreator') . '");
return false;
}
Expand Down

0 comments on commit 75f7b0b

Please sign in to comment.