@@ -655,19 +655,19 @@ public function saveAnswers($data) {
655
655
}
656
656
657
657
// Update issues table
658
+ $ issue = new PluginFormcreatorIssue ();
659
+ $ formAnswerId = $ this ->getID ();
658
660
if ($ status != 'refused ' ) {
659
661
660
662
// If cannot get itemTicket from DB it happens either
661
663
// when no item exist
662
664
// when several rows matches
663
665
// Both are processed the same way
664
- $ formAnswerId = $ this ->getID ();
665
666
$ itemTicket = new Item_Ticket ();
666
667
$ rows = $ itemTicket ->find ("`itemtype` = 'PluginFormcreatorForm_Answer' AND `items_id` = ' $ formAnswerId' " );
667
668
if (count ($ rows ) != 1 ) {
668
669
if ($ is_newFormAnswer ) {
669
670
// This is a new answer for the form. Create an issue
670
- $ issue = new PluginFormcreatorIssue ();
671
671
$ issue ->add ([
672
672
'original_id ' => $ id ,
673
673
'sub_itemtype ' => 'PluginFormcreatorForm_Answer ' ,
@@ -682,7 +682,6 @@ public function saveAnswers($data) {
682
682
'comment ' => '' ,
683
683
]);
684
684
} else {
685
- $ issue = new PluginFormcreatorIssue ();
686
685
$ issue ->getFromDBByQuery ("WHERE `sub_itemtype` = 'PluginFormcreatorForm_Answer' AND `original_id` = ' $ formAnswerId' " );
687
686
$ id = $ this ->getID ();
688
687
$ issue ->update ([
@@ -707,7 +706,6 @@ public function saveAnswers($data) {
707
706
$ ticket ->getFromDB ($ itemTicket ->getField ('tickets_id ' ));
708
707
$ ticketId = $ ticket ->getID ();
709
708
if ($ is_newFormAnswer ) {
710
- $ issue = new PluginFormcreatorIssue ();
711
709
$ issue ->add ([
712
710
'original_id ' => $ ticketId ,
713
711
'sub_itemtype ' => 'Ticket ' ,
@@ -722,7 +720,6 @@ public function saveAnswers($data) {
722
720
'comment ' => addslashes ($ ticket ->getField ('content ' )),
723
721
]);
724
722
} else {
725
- $ issue = new PluginFormcreatorIssue ();
726
723
$ issue ->getFromDBByQuery ("WHERE `sub_itemtype` = 'PluginFormcreatorForm_Answer' AND `original_id` = ' $ formAnswerId' " );
727
724
$ issue ->update ([
728
725
'id ' => $ issue ->getID (),
@@ -740,6 +737,14 @@ public function saveAnswers($data) {
740
737
]);
741
738
}
742
739
}
740
+ } else {
741
+ $ issue ->getFromDBByQuery ("WHERE `sub_itemtype` = 'PluginFormcreatorForm_Answer' AND `original_id` = ' $ formAnswerId' " );
742
+ $ issue ->update ([
743
+ 'id ' => $ issue ->getID (),
744
+ 'sub_itemtype ' => 'PluginFormcreatorForm_Answer ' ,
745
+ 'original_id ' => $ formAnswerId ,
746
+ 'status ' => $ status ,
747
+ ]);
743
748
}
744
749
}
745
750
0 commit comments