diff --git a/inc/abstracttarget.class.php b/inc/abstracttarget.class.php
index fdf3228b6..924ea95c8 100644
--- a/inc/abstracttarget.class.php
+++ b/inc/abstracttarget.class.php
@@ -1880,6 +1880,8 @@ protected function showActorSettingsHeader($type) {
* @return void
*/
protected function showActorSettingsForType($actorType, array $actors) {
+ global $DB;
+
$itemActor = new PluginFormcreatorTarget_Actor();
$dropdownItems = ['' => Dropdown::EMPTY_VALUE] + $itemActor::getEnumActorType();
@@ -1929,6 +1931,21 @@ protected function showActorSettingsForType($actorType, array $actors) {
echo '';
echo '
';
+ // find already used items
+ $request = $DB->request([
+ 'FROM' => PluginFormcreatorTarget_Actor::getTable(),
+ 'WHERE' => [
+ 'itemtype' => $this->getType(),
+ 'items_id' => $this->getID(),
+ 'actor_role' => $actorRole,
+ 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON,
+ ]
+ ]);
+ $used = [];
+ foreach ($request as $row) {
+ $used[$row['actor_value']] = $row['actor_value'];
+ }
+
PluginFormcreatorQuestion::dropdownForForm(
$this->getForm()->getID(),
[
@@ -1943,11 +1960,29 @@ protected function showActorSettingsForType($actorType, array $actors) {
],
],
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_PERSON,
- 0
+ 0,
+ [
+ 'used' => $used,
+ ]
);
echo '
';
echo '';
+ // find already used items
+ $request = $DB->request([
+ 'FROM' => PluginFormcreatorTarget_Actor::getTable(),
+ 'WHERE' => [
+ 'itemtype' => $this->getType(),
+ 'items_id' => $this->getID(),
+ 'actor_role' => $actorRole,
+ 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_GROUP,
+ ]
+ ]);
+ $used = [];
+ foreach ($request as $row) {
+ $used[$row['actor_value']] = $row['actor_value'];
+ }
+
PluginFormcreatorQuestion::dropdownForForm(
$this->getForm()->getID(),
[
@@ -1955,51 +1990,139 @@ protected function showActorSettingsForType($actorType, array $actors) {
'values' => ['LIKE', '%"itemtype":"' . Group::class . '"%'],
],
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_GROUP,
- 0
+ 0,
+ [
+ 'used' => $used,
+ ]
);
echo '
';
echo '';
+ // find already used items
+ $request = $DB->request([
+ 'FROM' => PluginFormcreatorTarget_Actor::getTable(),
+ 'WHERE' => [
+ 'itemtype' => $this->getType(),
+ 'items_id' => $this->getID(),
+ 'actor_role' => $actorRole,
+ 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_GROUP,
+ ]
+ ]);
+ $used = [];
+ foreach ($request as $row) {
+ $used[$row['actor_value']] = $row['actor_value'];
+ }
+
PluginFormcreatorQuestion::dropdownForForm(
$this->getForm()->getID(),
[
'fieldtype' => ['glpiselect'],
],
- 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_GROUP_FROM_OBJECT,
- 0
+ 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_GROUP,
+ 0,
+ [
+ 'used' => $used,
+ ]
);
echo '
';
echo '';
+ // find already used items
+ $request = $DB->request([
+ 'FROM' => PluginFormcreatorTarget_Actor::getTable(),
+ 'WHERE' => [
+ 'itemtype' => $this->getType(),
+ 'items_id' => $this->getID(),
+ 'actor_role' => $actorRole,
+ 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_TECH_GROUP_FROM_OBJECT,
+ ]
+ ]);
+ $used = [];
+ foreach ($request as $row) {
+ $used[$row['actor_value']] = $row['actor_value'];
+ }
+
PluginFormcreatorQuestion::dropdownForForm(
$this->getForm()->getID(),
[
'fieldtype' => ['glpiselect'],
],
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_TECH_GROUP_FROM_OBJECT,
- 0
+ 0,
+ [
+ 'used' => $used,
+ ]
);
echo '
';
echo '';
+ // find already used items
+ $request = $DB->request([
+ 'FROM' => PluginFormcreatorTarget_Actor::getTable(),
+ 'WHERE' => [
+ 'itemtype' => $this->getType(),
+ 'items_id' => $this->getID(),
+ 'actor_role' => $actorRole,
+ 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS,
+ ]
+ ]);
+ $used = [];
+ foreach ($request as $row) {
+ $used[$row['actor_value']] = $row['actor_value'];
+ }
+
PluginFormcreatorQuestion::dropdownForForm(
$this->getForm()->getID(),
[
'fieldtype' => ['actor'],
],
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_ACTORS,
- 0
+ 0,
+ [
+ 'used' => $used,
+ ]
);
echo '
';
if ($actorType == CommonITILActor::ASSIGN) {
echo '';
+ // find already used items
+ $request = $DB->request([
+ 'FROM' => PluginFormcreatorTarget_Actor::getTable(),
+ 'WHERE' => [
+ 'itemtype' => $this->getType(),
+ 'items_id' => $this->getID(),
+ 'actor_role' => $actorRole,
+ 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_SUPPLIER,
+ ]
+ ]);
+ $used = [];
+ foreach ($request as $row) {
+ $used[$row['actor_value']] = $row['actor_value'];
+ }
+
Supplier::dropdown([
'name' => 'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_SUPPLIER,
+ 'used' => $used,
]);
echo '
';
echo '';
+ // find already used items
+ $request = $DB->request([
+ 'FROM' => PluginFormcreatorTarget_Actor::getTable(),
+ 'WHERE' => [
+ 'itemtype' => $this->getType(),
+ 'items_id' => $this->getID(),
+ 'actor_role' => $actorRole,
+ 'actor_type' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_SUPPLIER,
+ ]
+ ]);
+ $used = [];
+ foreach ($request as $row) {
+ $used[$row['actor_value']] = $row['actor_value'];
+ }
+
PluginFormcreatorQuestion::dropdownForForm(
$this->getForm()->getID(),
[
@@ -2007,7 +2130,10 @@ protected function showActorSettingsForType($actorType, array $actors) {
'values' => ['LIKE', '%"itemtype":"' . Supplier::class . '"%'],
],
'actor_value_' . PluginFormcreatorTarget_Actor::ACTOR_TYPE_QUESTION_SUPPLIER,
- 0
+ 0,
+ [
+ 'used' => $used,
+ ]
);
echo '
';
}