summaryrefslogtreecommitdiffstats
path: root/frontends/php/services.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-09-14 12:44:51 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-09-14 12:44:51 +0000
commit3a131834335bf51798f2283f48f1aa002821bf44 (patch)
treeb252f7946f8956743783b838e427352fe4a1b0f0 /frontends/php/services.php
parent8755f9643aba3cffc5320321618fbe8e7b78b73b (diff)
downloadzabbix-3a131834335bf51798f2283f48f1aa002821bf44.tar.gz
zabbix-3a131834335bf51798f2283f48f1aa002821bf44.tar.xz
zabbix-3a131834335bf51798f2283f48f1aa002821bf44.zip
- 'sql' fixes in 'trunk/frontends/php/popup.php' (Eugene)
- minor fix of 'trunk/src/libs/zbxcommon/misc.c' (Eugene) - developed SLA calculation periods (Eugene) - developed flexible update intervals for items (Eugene) ported r3213 (fix for 'delay_flex' collumn) from 'branches/1.1-lk/' ported r3202 (flexible update intervals) from 'branches/1.1-lk/' ported r3207 (SLA calculation periods) from 'branches/1.1-lk/' git-svn-id: svn://svn.zabbix.com/trunk@3307 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/services.php')
-rw-r--r--frontends/php/services.php143
1 files changed, 140 insertions, 3 deletions
diff --git a/frontends/php/services.php b/frontends/php/services.php
index 5de908d9..52692c01 100644
--- a/frontends/php/services.php
+++ b/frontends/php/services.php
@@ -19,7 +19,7 @@
**/
?>
<?php
- include "include/config.inc.php";
+ include_once "include/config.inc.php";
$page["title"] = "S_IT_SERVICES";
$page["file"] = "services.php";
@@ -75,20 +75,24 @@
}
elseif(isset($_REQUEST["save_service"]))
{
+ $service_times = get_request('service_times',array());
+
$showsla = isset($_REQUEST["showsla"]) ? 1 : 0;
$triggerid = isset($_REQUEST["linktrigger"]) ? $_REQUEST["triggerid"] : NULL;
if(isset($_REQUEST["serviceid"]))
{
$result = update_service($_REQUEST["serviceid"],
$_REQUEST["name"],$triggerid,$_REQUEST["algorithm"],
- $showsla,$_REQUEST["goodsla"],$_REQUEST["sortorder"]);
+ $showsla,$_REQUEST["goodsla"],$_REQUEST["sortorder"],
+ $service_times);
show_messages($result, S_SERVICE_UPDATED, S_CANNOT_UPDATE_SERVICE);
}
else
{
$result = add_service(
$_REQUEST["name"],$triggerid,$_REQUEST["algorithm"],
- $showsla,$_REQUEST["goodsla"],$_REQUEST["sortorder"]);
+ $showsla,$_REQUEST["goodsla"],$_REQUEST["sortorder"],
+ $service_times);
show_messages($result, S_SERVICE_ADDED, S_CANNOT_ADD_SERVICE);
}
}
@@ -112,6 +116,41 @@
$result=add_host_to_services($_REQUEST["serverid"],$_REQUEST["serviceid"]);
show_messages($result, S_TRIGGER_ADDED, S_CANNOT_ADD_TRIGGER);
}
+ elseif(isset($_REQUEST["add_service_time"]) && isset($_REQUEST["new_service_time"]))
+ {
+ $_REQUEST['service_times'] = get_request('service_times',array());
+
+ $new_service_time['type'] = $_REQUEST["new_service_time"]['type'];
+
+ if($_REQUEST["new_service_time"]['type'] == SERVICE_TIME_TYPE_ONETIME_DOWNTIME)
+ {
+ $new_service_time['from'] = strtotime($_REQUEST["new_service_time"]['from']);
+ $new_service_time['to'] = strtotime($_REQUEST["new_service_time"]['to']);
+ $new_service_time['note'] = $_REQUEST["new_service_time"]['note'];
+ }
+ else
+ {
+ $new_service_time['from'] = strtotime(
+ $_REQUEST["new_service_time"]['from_week'].' '.$_REQUEST["new_service_time"]['from']
+ );
+ $new_service_time['to'] = strtotime(
+ $_REQUEST["new_service_time"]['to_week'].' '.$_REQUEST["new_service_time"]['to']
+ );
+ $new_service_time['note'] = $_REQUEST["new_service_time"]['note'];
+ }
+
+ while($new_service_time['to'] <= $new_service_time['from']) $new_service_time['to'] += 7*24*3600;
+
+ if(!in_array($_REQUEST['service_times'], $new_service_time))
+ array_push($_REQUEST['service_times'],$new_service_time);
+ }
+ elseif(isset($_REQUEST["del_service_times"]) && isset($_REQUEST["rem_service_times"]))
+ {
+ $_REQUEST["service_times"] = get_request("service_times",array());
+ foreach($_REQUEST["rem_service_times"] as $val){
+ unset($_REQUEST["service_times"][$val]);
+ }
+ }
?>
<?php
@@ -252,6 +291,9 @@
$frmService->SetHelp("web.services.service.php");
$frmService->AddVar("parentid",$_REQUEST["parentid"]);
+ $service_times = get_request('service_times',array());
+ $new_service_time = get_request('new_service_time',array('type' => SERVICE_TIME_TYPE_UPTIME));
+
if(isset($_REQUEST["serviceid"]))
{
$frmService->AddVar("serviceid",$_REQUEST["serviceid"]);
@@ -271,6 +313,19 @@
$triggerid =$service["triggerid"];
$linktrigger = isset($triggerid) ? 'yes' : 'no';
if(!isset($triggerid)) $triggerid = 0;
+
+ $result = DBselect('select * from services_times where serviceid='.$_REQUEST['serviceid']);
+ while($db_stime = DBfetch($result))
+ {
+ $stime = array(
+ 'type'=> $db_stime['type'],
+ 'from'=> $db_stime['ts_from'],
+ 'to'=> $db_stime['ts_to'],
+ 'note'=> $db_stime['note']
+ );
+ if(in_array($stime, $service_times)) continue;
+ array_push($service_times, $stime);
+ }
}
else
{
@@ -302,6 +357,88 @@
else
$frmService->AddVar("goodsla",$goodsla);
+ $stime_el = array();
+ $i = 0;
+ foreach($service_times as $val)
+ {
+ switch($val['type'])
+ {
+ case SERVICE_TIME_TYPE_UPTIME:
+ $type = new CSpan(S_UPTIME,'enabled');
+ $from = date('l H:i', $val['from']);
+ $to = date('l H:i', $val['to']);
+ break;
+ case SERVICE_TIME_TYPE_DOWNTIME:
+ $type = new CSpan(S_DOWNTIME,'disabled');
+ $from = date('l H:i', $val['from']);
+ $to = date('l H:i', $val['to']);
+ break;
+ case SERVICE_TIME_TYPE_ONETIME_DOWNTIME:
+ $type = new CSpan(S_ONE_TIME_DOWNTIME,'disabled');
+ $from = date('d M Y H:i', $val['from']);
+ $to = date('d M Y H:i', $val['to']);
+ break;
+ }
+ array_push($stime_el, array(new CCheckBox("rem_service_times[]", 'no', NULL,$i),
+ $type,':'.SPACE, $from, SPACE.'-'.SPACE, $to,
+ (!empty($val['note']) ? BR.'['.htmlspecialchars($val['note']).']' : '' ),BR));
+
+ $frmService->AddVar('service_times['.$i.'][type]', $val['type']);
+ $frmService->AddVar('service_times['.$i.'][from]', $val['from']);
+ $frmService->AddVar('service_times['.$i.'][to]', $val['to']);
+ $frmService->AddVar('service_times['.$i.'][note]', $val['note']);
+
+ $i++;
+ }
+
+ if(count($stime_el)==0)
+ array_push($stime_el, S_NO_TIMES_DEFINED);
+ else
+ array_push($stime_el, new CButton('del_service_times','delete selected'));
+
+ $frmService->AddRow(S_SERVICE_TIMES, $stime_el);
+
+ $cmbTimeType = new CComboBox("new_service_time[type]",$new_service_time['type'],'submit()');
+ $cmbTimeType->AddItem(SERVICE_TIME_TYPE_UPTIME, S_UPTIME);
+ $cmbTimeType->AddItem(SERVICE_TIME_TYPE_DOWNTIME, S_DOWNTIME);
+ $cmbTimeType->AddItem(SERVICE_TIME_TYPE_ONETIME_DOWNTIME, S_ONE_TIME_DOWNTIME);
+
+ $time_param = new CTable();
+ if($new_service_time['type'] == SERVICE_TIME_TYPE_ONETIME_DOWNTIME)
+ {
+ $time_param->AddRow(array(S_NOTE, new CTextBox('new_service_time[note]','<short description>',40)));
+ $time_param->AddRow(array(S_FROM, new CTextBox('new_service_time[from]','d M Y H:i',20)));
+ $time_param->AddRow(array(S_TILL, new CTextBox('new_service_time[to]','d M Y H:i',20)));
+ }
+ else
+ {
+ $cmbWeekFrom = new CComboBox('new_service_time[from_week]','Sunday');
+ $cmbWeekTo = new CComboBox('new_service_time[to_week]','Sunday');
+ foreach(array(
+ 'Sunday' =>S_SUNDAY,
+ 'Monday' =>S_MONDAY,
+ 'Tuesday' =>S_TUESDAY,
+ 'Wednesday'=>S_WEDNESDAY,
+ 'Thursday'=>S_THURSDAY,
+ 'Friday' =>S_FRIDAY,
+ 'Saturday' =>S_SATURDAY
+ ) as $day_num => $day_str)
+ {
+ $cmbWeekFrom->AddItem($day_num, $day_str);
+ $cmbWeekTo->AddItem($day_num, $day_str);
+ }
+
+ $time_param->AddRow(array(S_FROM, $cmbWeekFrom, new CTextBox('new_service_time[from]','H:i',9)));
+ $time_param->AddRow(array(S_TILL, $cmbWeekTo, new CTextBox('new_service_time[to]','H:i',9)));
+ $frmService->AddVar('new_service_time[note]','');
+ }
+
+ $frmService->AddRow(S_NEW_SERVICE_TIME, array(
+ $cmbTimeType, BR,
+ $time_param, BR,
+ new CButton('add_service_time','add')
+ ));
+
$frmService->AddRow(S_LINK_TO_TRIGGER_Q, new CCheckBox("linktrigger",$linktrigger,"submit();"));
if($linktrigger == 'yes')