summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--frontends/php/actionconf.php8
-rw-r--r--frontends/php/include/actions.inc.php28
-rw-r--r--frontends/php/include/forms.inc.php24
3 files changed, 44 insertions, 16 deletions
diff --git a/frontends/php/actionconf.php b/frontends/php/actionconf.php
index cdd38991..5ab812c0 100644
--- a/frontends/php/actionconf.php
+++ b/frontends/php/actionconf.php
@@ -67,12 +67,7 @@ include_once 'include/page_header.php';
'edit_operationid'=>array(null, O_OPT, P_ACT, DB_ID, null),
'new_operation'=> array(null, O_OPT, null, null, 'isset({add_operation})'),
-
- 'esc_step_from'=> array(T_ZBX_INT, O_OPT, null, null, null),
- 'esc_step_to'=> array(T_ZBX_INT, O_OPT, null, null, null),
-
- 'esc_step_period'=> array(T_ZBX_INT, O_OPT, null, null, null),
-
+
'opconditions'=> array(null, O_OPT, null, null, null),
'g_opconditionid'=> array(null, O_OPT, null, null, null),
@@ -252,7 +247,6 @@ include_once 'include/page_header.php';
}
else if(inarr_isset(array('add_operation','new_operation'))){
$new_operation = $_REQUEST['new_operation'];
-
if(validate_operation($new_operation)){
zbx_rksort($new_operation);
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php
index eceaabfe..bf61e287 100644
--- a/frontends/php/include/actions.inc.php
+++ b/frontends/php/include/actions.inc.php
@@ -840,6 +840,34 @@ function validate_commands($commands){
return TRUE;
}
+function count_operations_delay($operations, $def_period=0){
+ $delays = array(0,0);
+ $periods = array();
+ $max_step = 0;
+ foreach($operations as $num => $operation){
+ $step_from = $operation['esc_step_from']?$operation['esc_step_from']:1;
+ $step_to = $operation['esc_step_to']?$operation['esc_step_to']:9999;
+ $esc_period = $operation['esc_period']?$operation['esc_period']:$def_period;
+
+ $max_step = ($max_step>$step_from)?$max_step:$step_from;
+
+ for($i=$step_from; $i<$step_to; $i++){
+ if(isset($periods[$i]) && ($periods[$i] < $esc_period)){
+ }
+ else{
+ $periods[$i]= $esc_period;
+ }
+ }
+ }
+
+ for($i=1; $i<=$max_step; $i++){
+ $esc_period = isset($periods[$i])?$periods[$i]:$def_period;
+ $delays[$i+1] = $delays[$i] + $esc_period;
+ }
+
+return $delays;
+}
+
function get_history_of_actions($start,$num,$sql_cond=''){
$available_triggers = get_accessible_triggers(PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 88d200dc..69a82f56 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -3210,7 +3210,7 @@
$db_operations = DBselect('SELECT * '.
' FROM operations'.
' WHERE actionid='.$_REQUEST['actionid'].
- ' ORDER BY operationtype,object,operationid');
+ ' ORDER BY esc_step_from,operationtype,object,operationid');
while($operation_data = DBfetch($db_operations)){
$operation_data = array(
@@ -3259,7 +3259,7 @@
zbx_rksort($operations);
- $delay = 0;
+ $delay = count_operations_delay($operations,$esc_period);
foreach($operations as $id => $val){
if( !str_in_array($val['operationtype'], $allowed_operations) ) continue;
@@ -3273,13 +3273,12 @@
$esc_period_txt = null;
$esc_delay_txt = null;
+ if($val['esc_step_from'] < 1) $val['esc_step_from'] = 1;
+
if($esc_period){
$esc_steps_txt = $val['esc_step_from'].' - '.$val['esc_step_to'];
$esc_period_txt = $val['esc_period']?$val['esc_period']:S_DEFAULT;
- $esc_delay_txt = $delay?convert_units($delay,'uptime'):S_AT_MOMENT;
-
- $delay_period = $val['esc_period']?$val['esc_period']:$esc_period;
- $delay += $delay_period*abs($val['esc_step_from']-$val['esc_step_to']);
+ $esc_delay_txt = $delay[$val['esc_step_from']]?convert_units($delay[$val['esc_step_from']],'uptime'):S_AT_MOMENT;
}
$tblOper->AddRow(array(
@@ -3349,7 +3348,11 @@
/* init new_operation variable */
$new_operation = get_request('new_operation', array());
- if( !is_array($new_operation) ) $new_operation = array();
+
+ if(!is_array($new_operation)){
+ $new_operation = array();
+ $new_operation['default_msg'] = 1;
+ }
if(!isset($new_operation['operationtype'])) $new_operation['operationtype'] = OPERATION_TYPE_MESSAGE;
if(!isset($new_operation['object'])) $new_operation['object'] = OPERATION_OBJECT_GROUP;
@@ -3379,11 +3382,14 @@
if(isset($_REQUEST['esc_period']) && ($_REQUEST['esc_period']>0)){
$tblStep = new CTable(null,'nowrap');
- $tblStep->AddRow(array(S_FROM, new CNumericBox('new_operation[esc_step_from]', $new_operation['esc_step_from'],5)));
+ $step_from = new CNumericBox('new_operation[esc_step_from]', $new_operation['esc_step_from'],4);
+ $step_from->AddAction('onchange','javascript:'.$step_from->GetOption('onchange').' if(this.value == 0) this.value=1;');
+
+ $tblStep->AddRow(array(S_FROM, $step_from));
$tblStep->AddRow(array(
S_TO,
new CCol(array(
- new CNumericBox('new_operation[esc_step_to]', $new_operation['esc_step_to'],5),
+ new CNumericBox('new_operation[esc_step_to]', $new_operation['esc_step_to'],4),
' [0-'.S_INFINITY.']'))
));