Add an agent only if such type has not already beed added
parent
be8f008eb4
commit
27c2682c3f
|
@ -86,7 +86,7 @@ class Agent {
|
|||
jilo_agents
|
||||
WHERE
|
||||
platform_id = :platform_id';
|
||||
$query - $this->db->prepare($sql);
|
||||
$query = $this->db->prepare($sql);
|
||||
$query->bindParam(':platform_id', $platform_id);
|
||||
$query->execute();
|
||||
|
||||
|
|
|
@ -129,6 +129,8 @@ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
|||
switch ($action) {
|
||||
case 'add-agent':
|
||||
$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';
|
||||
break;
|
||||
case 'add':
|
||||
|
|
|
@ -15,7 +15,10 @@
|
|||
<select class="form-control" type="text" name="type" id="agent_type_id" required>
|
||||
<option></option>
|
||||
<?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']) ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
|
|
Loading…
Reference in New Issue