Merge branch 'ent-3279-planned-downtime-creation-api-cli' into 'develop'
API/CLI: fixed planned downtime creation See merge request artica/pandorafms!2184 Former-commit-id: 84f21e2c9762af3a1c1c04c24dc6e35848c0f437
This commit is contained in:
commit
a54903d9c6
|
@ -6175,17 +6175,29 @@ function api_set_planned_downtimes_deleted($id, $thrash1, $thrash2, $returnType)
|
|||
|
||||
/**
|
||||
* Create a new planned downtime.
|
||||
* e.g.: api.php?op=set&op2=planned_downtimes_created&id=pepito&other=testing|08-22-2015|08-31-2015|0|1|1|1|1|1|1|1|17:06:00|19:06:00|1|31|quiet|periodically|weekly&other_mode=url_encode_separator_|
|
||||
*
|
||||
* @param $id name of planned downtime.
|
||||
* @param $thrash1 Don't use.
|
||||
* @param array $other it's array, $other as param is <description>;<date_from>;<date_to>;<id_group>;<monday>;
|
||||
* <tuesday>;<wednesday>;<thursday>;<friday>;<saturday>;<sunday>;<periodically_time_from>;<periodically_time_to>;
|
||||
* <periodically_day_from>;<periodically_day_to>;<type_downtime>;<type_execution>;<type_periodicity>; in this order
|
||||
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
|
||||
* example:
|
||||
*
|
||||
* api.php?op=set&op2=planned_downtimes_created&id=pepito&other=testing|08-22-2015|08-31-2015|0|1|1|1|1|1|1|1|17:06:00|19:06:00|1|31|quiet|periodically|weekly&other_mode=url_encode_separator_|
|
||||
*
|
||||
* @param array $other Contains the following elements (in order):
|
||||
* <description>
|
||||
* <date_from>
|
||||
* <date_to>
|
||||
* <id_group>
|
||||
* <monday>
|
||||
* <tuesday>
|
||||
* <wednesday>
|
||||
* <thursday>
|
||||
* <friday>
|
||||
* <saturday>
|
||||
* <sunday>
|
||||
* <periodically_time_from>
|
||||
* <periodically_time_to>
|
||||
* <periodically_day_from>
|
||||
* <periodically_day_to>
|
||||
* <type_downtime>
|
||||
* <type_execution>
|
||||
* <type_periodicity>
|
||||
* @param $thrash3 Don't use.
|
||||
*/
|
||||
|
||||
|
@ -6249,20 +6261,16 @@ function api_set_planned_downtimes_created($id, $thrash1, $other, $thrash3)
|
|||
|
||||
/**
|
||||
* Add new items to planned Downtime.
|
||||
* e.g.: api.php?op=set&op2=planned_downtimes_additem&id=123&other=1;2;3;4|Status;Unkown_modules&other_mode=url_encode_separator_|
|
||||
*
|
||||
* @param $id id of planned downtime.
|
||||
* @param $thrash1 Don't use.
|
||||
* @param array $other it's array, $other as param is <id_agent1;id_agent2;id_agent3;....id_agentn;>;
|
||||
* <name_module1;name_module2;name_module3;......name_modulen;> in this order
|
||||
* and separator char (after text ; ) and separator (pass in param othermode as othermode=url_encode_separator_<separator>)
|
||||
* example:
|
||||
*
|
||||
* api.php?op=set&op2=planned_downtimes_additem&id=123&other=1;2;3;4|Status;Unkown_modules&other_mode=url_encode_separator_|
|
||||
*
|
||||
* @param array $other
|
||||
* The first index contains a list of agent Ids.
|
||||
* The second index contains a list of module names.
|
||||
* The list separator is the character ';'.
|
||||
* @param $thrash3 Don't use.
|
||||
*/
|
||||
|
||||
|
||||
function api_set_planned_downtimes_additem($id, $thrash1, $other, $thrash3)
|
||||
{
|
||||
if (defined('METACONSOLE')) {
|
||||
|
|
|
@ -725,8 +725,6 @@ function planned_downtimes_created($values)
|
|||
$check_group = (bool) db_get_value('id_grupo', 'tgrupo', 'id_grupo', $values['id_group']);
|
||||
$check = (bool) db_get_value('name', 'tplanned_downtime', 'name', $values['name']);
|
||||
|
||||
$datetime_from = strtotime($values['once_date_from'].' '.$values['once_time_from']);
|
||||
$datetime_to = strtotime($values['once_date_to'].' '.$values['once_time_to']);
|
||||
$now = time();
|
||||
$result = false;
|
||||
|
||||
|
@ -735,16 +733,16 @@ function planned_downtimes_created($values)
|
|||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data. Start time must be higher than the current time'),
|
||||
];
|
||||
} else if ($values['type_execution'] == 'once' && !$config['past_planned_downtimes'] && $values['date_to'] <= $now) {
|
||||
return [
|
||||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the current time'),
|
||||
];
|
||||
} else if ($values['type_execution'] == 'once' && $values['date_from'] >= $values['date_to']) {
|
||||
return [
|
||||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the start date'),
|
||||
];
|
||||
} else if ($values['type_execution'] == 'once' && $values['date_to'] <= $now) {
|
||||
return [
|
||||
'return' => false,
|
||||
'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the current time'),
|
||||
];
|
||||
} else if ($values['type_execution'] == 'periodically'
|
||||
&& (($values['type_periodicity'] == 'weekly' && $values['periodically_time_from'] >= $values['periodically_time_to'])
|
||||
|| ($values['type_periodicity'] == 'monthly' && $values['periodically_day_from'] == $values['periodically_day_to'] && $values['periodically_time_from'] >= $values['periodically_time_to']))
|
||||
|
|
Loading…
Reference in New Issue