Skip to content

Commit

Permalink
fix(targetticket,targetchange): repair supplier actors edition
Browse files Browse the repository at this point in the history
Signed-off-by: Thierry Bugier <tbugier@teclib.com>
  • Loading branch information
btry committed Jan 29, 2020
1 parent cfdc629 commit 5c7aeb5
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions inc/targetbase.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1517,19 +1517,19 @@ protected function showActorSettingsHeader($type) {
/**
* Show header for actors edition
*
* @param integer $type see CommonITILActor constants
* @param integer $actorType see CommonITILActor constants
* @param array $actors actors to show
* @return void
*/
protected function showActorSettingsForType($type, array $actors) {
protected function showActorSettingsForType($actorType, array $actors) {
$itemActor = $this->getItem_Actor();
$dropdownItems = ['' => Dropdown::EMPTY_VALUE] + $itemActor::getEnumActorType();

switch ($type) { // Values from CommonITILObject::getSearchOptionsActors()
switch ($actorType) { // Values from CommonITILObject::getSearchOptionsActors()
case CommonITILActor::REQUESTER:
$type = 'requester';
unset($dropdownItems['supplier']);
unset($dropdownItems['question_supplier']);
unset($dropdownItems[PluginFormcreatorTarget_Actor::ACTOR_TYPE_SUPPLIER]);
unset($dropdownItems[PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_SUPPLIER]);
$changeActorJSFunction = 'plugin_formcreator_ChangeActorRequester(this.value)';
$actorRole = PluginFormcreatorTarget_Actor::ACTOR_ROLE_REQUESTER;
break;
Expand Down Expand Up @@ -1643,6 +1643,28 @@ protected function showActorSettingsForType($type, array $actors) {
);
echo '</div>';

if ($actorType == CommonITILActor::ASSIGN) {
echo '<div id="block_' . $type . '_supplier" style="display:none">';
Supplier::dropdown([
'name' => 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_SUPPLIER,
]);
echo '</div>';

echo '<div id="block_' . $type . '_question_supplier" style="display:none">';
PluginFormcreatorQuestion::dropdownForForm(
$this->getForm()->getID(),
[
'fieldtype' => ['glpiselect'],
'values' => Supplier::class,
],
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_SUPPLIER,
[
'value' => 0
]
);
echo '</div>';
}

echo '<div>';
echo __('Email followup');
Dropdown::showYesNo('use_notification', 1);
Expand Down Expand Up @@ -1713,6 +1735,17 @@ protected function showActorSettingsForType($type, array $actors) {
echo $img_user . ' <b>' . __('Actors from the question', 'formcreator')
. '</b> "' . $question->getName() . '"';
break;
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_SUPPLIER :
$supplier = new Supplier();
$supplier->getFromDB($values['actor_value']);
echo $img_supplier . ' <b>' . __('Supplier') . ' </b> "' . $supplier->getName() . '"';
break;
case PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_SUPPLIER :
$question = new PluginFormcreatorQuestion();
$question->getFromDB($values['actor_value']);
echo $img_supplier . ' <b>' . __('Supplier from the question', 'formcreator')
. '</b> "' . $question->getName() . '"';
break;
}
echo $values['use_notification'] ? ' ' . $img_mail . ' ' : ' ' . $img_nomail . ' ';
echo self::getDeleteImage($id);
Expand Down

0 comments on commit 5c7aeb5

Please sign in to comment.