@@ -655,19 +655,19 @@ public function saveAnswers($data) {
655655         }
656656
657657         // Update issues table 
658+          $ issue  = new  PluginFormcreatorIssue ();
659+          $ formAnswerId  = $ this  ->getID ();
658660         if  ($ status  != 'refused ' ) {
659661
660662            // If cannot get itemTicket from DB it happens either 
661663            // when no item exist 
662664            // when several rows matches 
663665            // Both are processed the same way 
664-             $ formAnswerId  = $ this  ->getID ();
665666            $ itemTicket  = new  Item_Ticket ();
666667            $ rows  = $ itemTicket ->find ("`itemtype` = 'PluginFormcreatorForm_Answer' AND `items_id` = ' $ formAnswerId' " );
667668            if  (count ($ rows ) != 1 ) {
668669               if  ($ is_newFormAnswer ) {
669670                  // This is a new answer for the form. Create an issue 
670-                   $ issue  = new  PluginFormcreatorIssue ();
671671                  $ issue ->add ([
672672                     'original_id '      => $ id ,
673673                     'sub_itemtype '     => 'PluginFormcreatorForm_Answer ' ,
@@ -682,7 +682,6 @@ public function saveAnswers($data) {
682682                     'comment '          => '' ,
683683                  ]);
684684               } else  {
685-                   $ issue  = new  PluginFormcreatorIssue ();
686685                  $ issue ->getFromDBByQuery ("WHERE `sub_itemtype` = 'PluginFormcreatorForm_Answer' AND `original_id` = ' $ formAnswerId' " );
687686                  $ id  = $ this  ->getID ();
688687                  $ issue ->update ([
@@ -707,7 +706,6 @@ public function saveAnswers($data) {
707706               $ ticket ->getFromDB ($ itemTicket ->getField ('tickets_id ' ));
708707               $ ticketId  = $ ticket ->getID ();
709708               if  ($ is_newFormAnswer ) {
710-                   $ issue  = new  PluginFormcreatorIssue ();
711709                  $ issue ->add ([
712710                     'original_id '      => $ ticketId ,
713711                     'sub_itemtype '     => 'Ticket ' ,
@@ -722,7 +720,6 @@ public function saveAnswers($data) {
722720                     'comment '          => addslashes ($ ticket ->getField ('content ' )),
723721                  ]);
724722               } else  {
725-                   $ issue  = new  PluginFormcreatorIssue ();
726723                  $ issue ->getFromDBByQuery ("WHERE `sub_itemtype` = 'PluginFormcreatorForm_Answer' AND `original_id` = ' $ formAnswerId' " );
727724                  $ issue ->update ([
728725                     'id '               => $ issue ->getID (),
@@ -740,6 +737,14 @@ public function saveAnswers($data) {
740737                  ]);
741738               }
742739            }
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+             ]);
743748         }
744749      }
745750
0 commit comments