diff --git a/front/targetticket.form.php b/front/targetticket.form.php index b8411de30..f7fe103c9 100644 --- a/front/targetticket.form.php +++ b/front/targetticket.form.php @@ -41,7 +41,7 @@ $targetticket = new PluginFormcreatorTargetTicket(); // Edit an existing target ticket -if (isset($_POST["update"])) { +if (isset($_POST['update'])) { $targetticket->update($_POST); Html::back(); diff --git a/inc/targetbase.class.php b/inc/targetbase.class.php index 011d6aa6c..26a49a554 100644 --- a/inc/targetbase.class.php +++ b/inc/targetbase.class.php @@ -776,7 +776,7 @@ protected function showDueDateSettings(PluginFormcreatorForm $form, $rand) { Dropdown::showFromArray('due_date_rule', self::getEnumDueDateRule(), [ 'value' => $this->fields['due_date_rule'], - 'on_change' => 'formcreatorChangeDueDate(this.value)', + 'on_change' => 'plugin_formcreator_formcreatorChangeDueDate(this.value)', 'display_emptychoice' => true ] ); @@ -1102,27 +1102,27 @@ protected function showActorsSettings() { // Requester header echo '
'; echo ''; - echo ''; + echo ''; echo ''; echo '
'; @@ -1283,12 +1274,12 @@ protected function showActorsSettings() { unset($dropdownItems['supplier']); unset($dropdownItems['question_supplier']); Dropdown::showFromArray('actor_type', - $dropdownItems, ['on_change' => 'formcreatorChangeActorWatcher(this.value)'] + $dropdownItems, ['on_change' => 'plugin_formcreator_ChangeActorWatcher(this.value)'] ); echo ''; echo ''; - echo ''; + echo ''; echo ''; echo '
'; @@ -1422,13 +1404,13 @@ protected function showActorsSettings() { Dropdown::showFromArray( 'actor_type', $dropdownItems, [ - 'on_change' => 'formcreatorChangeActorAssigned(this.value)' + 'on_change' => 'plugin_formcreator_ChangeActorAssigned(this.value)' ] ); echo ''; echo ''; - echo ''; + echo ''; echo ''; echo '
'; @@ -1816,23 +1786,25 @@ public function prepareInputForUpdate($input) { } public function post_addItem() { - if (!$this->skipCreateActors) { - $target_actor = $this->getItem_Actor(); - $myFk = self::getForeignKeyField(); - $target_actor->add([ - $myFk => $this->getID(), - 'actor_role' => PluginFormcreatorTarget_Actor::ACTOR_ROLE_REQUESTER, - 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_CREATOR, - 'use_notification' => '1', - ]); - $target_actor = $this->getItem_Actor(); - $target_actor->add([ - $myFk => $this->getID(), - 'actor_role' => PluginFormcreatorTarget_Actor::ACTOR_ROLE_OBSERVER, - 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_VALIDATOR, - 'use_notification' => '1', - ]); - } + if ($this->skipCreateActors) { + return; + } + + $target_actor = $this->getItem_Actor(); + $myFk = self::getForeignKeyField(); + $target_actor->add([ + $myFk => $this->getID(), + 'actor_role' => PluginFormcreatorTarget_Actor::ACTOR_ROLE_REQUESTER, + 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_CREATOR, + 'use_notification' => '1', + ]); + $target_actor = $this->getItem_Actor(); + $target_actor->add([ + $myFk => $this->getID(), + 'actor_role' => PluginFormcreatorTarget_Actor::ACTOR_ROLE_OBSERVER, + 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_VALIDATOR, + 'use_notification' => '1', + ]); } protected static function getDeleteImage($id) { diff --git a/js/scripts.js.php b/js/scripts.js.php index 77d1c6e55..98243b01b 100644 --- a/js/scripts.js.php +++ b/js/scripts.js.php @@ -603,7 +603,7 @@ function formcreatorShowFields(form) { } // DESTINATION -function formcreatorChangeDueDate(value) { +function plugin_formcreator_formcreatorChangeDueDate(value) { $('#due_date_questions').hide(); $('#due_date_time').hide(); switch (value) { @@ -620,91 +620,100 @@ function formcreatorChangeDueDate(value) { } } -function displayRequesterForm() { +function plugin_formcreator_displayRequesterForm() { $('#form_add_requester').show(); $('#btn_add_requester').hide(); $('#btn_cancel_requester').show(); } -function hideRequesterForm() { +function plugin_formcreator_hideRequesterForm() { $('#form_add_requester').hide(); $('#btn_add_requester').show(); $('#btn_cancel_requester').hide(); } -function displayWatcherForm() { +function plugin_formcreator_displayWatcherForm() { $('#form_add_watcher').show(); $('#btn_add_watcher').hide(); $('#btn_cancel_watcher').show(); } -function hideWatcherForm() { +function plugin_formcreator_hideWatcherForm() { $('#form_add_watcher').hide(); $('#btn_add_watcher').show(); $('#btn_cancel_watcher').hide(); } -function displayAssignedForm() { +function plugin_formcreator_displayAssignedForm() { $('#form_add_assigned').show(); $('#btn_add_assigned').hide(); $('#btn_cancel_assigned').show(); } -function hideAssignedForm() { +function plugin_formcreator_hideAssignedForm() { $('#form_add_assigned').hide(); $('#btn_add_assigned').show(); $('#btn_cancel_assigned').hide(); } -function formcreatorChangeActorRequester(value) { +function plugin_formcreator_ChangeActorRequester(value) { $('#block_requester_user').hide(); - $('#block_requester_group').hide(); $('#block_requester_question_user').hide(); + $('#block_requester_group').hide(); $('#block_requester_question_group').hide(); $('#block_requester_question_actors').hide(); + $('#block_requester_supplier').hide(); + $('#block_requester_question_supplier').hide(); switch (value) { - case 'person' : $('#block_requester_user').show(); break; - case 'question_person' : $('#block_requester_question_user').show(); break; - case 'group' : $('#block_requester_group').show(); break; - case 'question_group' : $('#block_requester_question_group').show(); break; - case 'question_actors' : $('#block_requester_question_actors').show(); break; + case '3' : $('#block_requester_user').show(); break; + case '4' : $('#block_requester_question_user').show(); break; + case '5' : $('#block_requester_group').show(); break; + case '6' : $('#block_requester_question_group').show(); break; + case '9' : $('#block_requester_question_actors').show(); break; + case '7' : $('#block_requester_supplier').show(); break; + case '8' : $('#block_requester_question_supplier').show(); break; } } -function formcreatorChangeActorWatcher(value) { +function plugin_formcreator_ChangeActorWatcher(value) { $('#block_watcher_user').hide(); - $('#block_watcher_group').hide(); $('#block_watcher_question_user').hide(); + $('#block_watcher_group').hide(); $('#block_watcher_question_group').hide(); $('#block_watcher_question_actors').hide(); + $('#block_watcher_supplier').hide(); + $('#block_watcher_question_supplier').hide(); switch (value) { - case 'person' : $('#block_watcher_user').show(); break; - case 'question_person' : $('#block_watcher_question_user').show(); break; - case 'group' : $('#block_watcher_group').show(); break; - case 'question_group' : $('#block_watcher_question_group').show(); break; - case 'question_actors' : $('#block_watcher_question_actors').show(); break; + case '3' : $('#block_watcher_user').show(); break; + case '4' : $('#block_watcher_question_user').show(); break; + case '5' : $('#block_watcher_group').show(); break; + case '6' : $('#block_watcher_question_group').show(); break; + case '9' : $('#block_watcher_question_actors').show(); break; + case '7' : $('#block_watcher_supplier').show(); break; + case '8' : $('#block_watcher_question_supplier').show(); break; } } -function formcreatorChangeActorAssigned(value) { +function plugin_formcreator_ChangeActorAssigned(value) { $('#block_assigned_user').hide(); - $('#block_assigned_group').hide(); $('#block_assigned_question_user').hide(); + $('#block_assigned_group').hide(); $('#block_assigned_question_group').hide(); $('#block_assigned_question_actors').hide(); $('#block_assigned_supplier').hide(); $('#block_assigned_question_supplier').hide(); + // The numbers match PluginFormcreatorTarget_Actor::ACTOR_TYPE_* constants switch (value) { - case 'person' : $('#block_assigned_user').show(); break; - case 'question_person' : $('#block_assigned_question_user').show(); break; - case 'group' : $('#block_assigned_group').show(); break; - case 'question_group' : $('#block_assigned_question_group').show(); break; - case 'question_actors' : $('#block_assigned_question_actors').show(); break; - case 'supplier' : $('#block_assigned_supplier').show(); break; - case 'question_supplier' : $('#block_assigned_question_supplier').show(); break; + case '3' : $('#block_assigned_user').show(); break; + case '4' : $('#block_assigned_question_user').show(); break; + case '5' : $('#block_assigned_group').show(); break; + case '6' : $('#block_assigned_question_group').show(); break; + case '9' : $('#block_assigned_question_actors').show(); break; + case '7' : $('#block_assigned_supplier').show(); break; + case '8' : $('#block_assigned_question_supplier').show(); break; } }