Add an agent only if such type has not already beed added
parent
be8f008eb4
commit
27c2682c3f
|
@ -86,7 +86,7 @@ class Agent {
|
||||||
jilo_agents
|
jilo_agents
|
||||||
WHERE
|
WHERE
|
||||||
platform_id = :platform_id';
|
platform_id = :platform_id';
|
||||||
$query - $this->db->prepare($sql);
|
$query = $this->db->prepare($sql);
|
||||||
$query->bindParam(':platform_id', $platform_id);
|
$query->bindParam(':platform_id', $platform_id);
|
||||||
$query->execute();
|
$query->execute();
|
||||||
|
|
||||||
|
|
|
@ -129,6 +129,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'add-agent':
|
case 'add-agent':
|
||||||
$jilo_agent_types = $agentObject->getAgentTypes();
|
$jilo_agent_types = $agentObject->getAgentTypes();
|
||||||
|
$jilo_agents_in_platform = $agentObject->getPlatformAgentTypes($platform_id);
|
||||||
|
$jilo_agent_types_in_platform = array_column($jilo_agents_in_platform, 'agent_type_id');
|
||||||
include '../app/templates/config-add-agent.php';
|
include '../app/templates/config-add-agent.php';
|
||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
|
|
|
@ -15,7 +15,10 @@
|
||||||
<select class="form-control" type="text" name="type" id="agent_type_id" required>
|
<select class="form-control" type="text" name="type" id="agent_type_id" required>
|
||||||
<option></option>
|
<option></option>
|
||||||
<?php foreach ($jilo_agent_types as $agent_type) { ?>
|
<?php foreach ($jilo_agent_types as $agent_type) { ?>
|
||||||
<option value="<?= htmlspecialchars($agent_type['id']) ?>">
|
<option value="<?= htmlspecialchars($agent_type['id']) ?>"<?php
|
||||||
|
if (in_array($agent_type['id'], $jilo_agent_types_in_platform)) {
|
||||||
|
echo 'disabled="disabled"';
|
||||||
|
} ?>>
|
||||||
<?= htmlspecialchars($agent_type['description']) ?>
|
<?= htmlspecialchars($agent_type['description']) ?>
|
||||||
</option>
|
</option>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
Loading…
Reference in New Issue