#11353 api not null agent downtime add agent

This commit is contained in:
Jonathan 2023-06-15 08:56:16 +02:00
parent 0760d0fdaf
commit 13e404bcd2
1 changed files with 16 additions and 14 deletions

View File

@ -7836,6 +7836,7 @@ function api_set_planned_downtimes_add_agents($id, $thrash1, $other, $thrash3)
$agents = explode(';', $other['data'][0]); $agents = explode(';', $other['data'][0]);
$results = false; $results = false;
foreach ($agents as $agent) { foreach ($agents as $agent) {
if (!empty($agent)) {
if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents tpd WHERE tpd.id_agent = %d AND id_downtime = %d', $agent, $id)) === false) { if (db_get_value_sql(sprintf('SELECT id from tplanned_downtime_agents tpd WHERE tpd.id_agent = %d AND id_downtime = %d', $agent, $id)) === false) {
$res = db_process_sql_insert( $res = db_process_sql_insert(
'tplanned_downtime_agents', 'tplanned_downtime_agents',
@ -7853,6 +7854,7 @@ function api_set_planned_downtimes_add_agents($id, $thrash1, $other, $thrash3)
returnError(" Agent $agent is already at the planned downtime."); returnError(" Agent $agent is already at the planned downtime.");
} }
} }
}
if ($results) { if ($results) {
returnData( returnData(