Skip to content

Commit

Permalink
fix(issue): issue not updated to refused status
Browse files Browse the repository at this point in the history
  • Loading branch information
btry committed Dec 5, 2017
1 parent f1ac36b commit 8b1e3b8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
7 changes: 6 additions & 1 deletion front/form_answer.form.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
$_POST['plugin_formcreator_forms_id'] = intval($_POST['formcreator_form']);
$_POST['status'] = 'waiting';
$formanswer->saveAnswers($_POST);
$formanswer->redirectToList();
if (plugin_formcreator_replaceHelpdesk()) {
$issue = new PluginFormcreatorIssue();
$issue->redirectToList();
} else {
$formanswer->redirectToList();
}

// Show target ticket form
} else {
Expand Down
1 change: 0 additions & 1 deletion inc/form.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,6 @@ public function showServiceCatalog() {
}

public function showWizard($service_catalog = false) {

echo '<div id="plugin_formcreator_wizard_categories">';
echo '<div><h2>'._n("Category", "Categories", 2, 'formcreator').'</h2></div>';
echo '<div><a href="#" id="wizard_seeall">' . __('see all', 'formcreator') . '</a></div>';
Expand Down
15 changes: 10 additions & 5 deletions inc/form_answer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -655,19 +655,19 @@ public function saveAnswers($data) {
}

// Update issues table
$issue = new PluginFormcreatorIssue();
$formAnswerId = $this->getID();
if ($status != 'refused') {

// If cannot get itemTicket from DB it happens either
// when no item exist
// when several rows matches
// Both are processed the same way
$formAnswerId = $this->getID();
$itemTicket = new Item_Ticket();
$rows = $itemTicket->find("`itemtype` = 'PluginFormcreatorForm_Answer' AND `items_id` = '$formAnswerId'");
if (count($rows) != 1) {
if ($is_newFormAnswer) {
// This is a new answer for the form. Create an issue
$issue = new PluginFormcreatorIssue();
$issue->add([
'original_id' => $id,
'sub_itemtype' => 'PluginFormcreatorForm_Answer',
Expand All @@ -682,7 +682,6 @@ public function saveAnswers($data) {
'comment' => '',
]);
} else {
$issue = new PluginFormcreatorIssue();
$issue->getFromDBByQuery("WHERE `sub_itemtype` = 'PluginFormcreatorForm_Answer' AND `original_id` = '$formAnswerId'");
$id = $this->getID();
$issue->update([
Expand All @@ -707,7 +706,6 @@ public function saveAnswers($data) {
$ticket->getFromDB($itemTicket->getField('tickets_id'));
$ticketId = $ticket->getID();
if ($is_newFormAnswer) {
$issue = new PluginFormcreatorIssue();
$issue->add([
'original_id' => $ticketId,
'sub_itemtype' => 'Ticket',
Expand All @@ -722,7 +720,6 @@ public function saveAnswers($data) {
'comment' => addslashes($ticket->getField('content')),
]);
} else {
$issue = new PluginFormcreatorIssue();
$issue->getFromDBByQuery("WHERE `sub_itemtype` = 'PluginFormcreatorForm_Answer' AND `original_id` = '$formAnswerId'");
$issue->update([
'id' => $issue->getID(),
Expand All @@ -740,6 +737,14 @@ public function saveAnswers($data) {
]);
}
}
} else {
$issue->getFromDBByQuery("WHERE `sub_itemtype` = 'PluginFormcreatorForm_Answer' AND `original_id` = '$formAnswerId'");
$issue->update([
'id' => $issue->getID(),
'sub_itemtype' => 'PluginFormcreatorForm_Answer',
'original_id' => $formAnswerId,
'status' => $status,
]);
}
}

Expand Down

0 comments on commit 8b1e3b8

Please sign in to comment.