<?php
Class ManageServiceMon extends Management {
private $servicemon;
public function __construct(){
parent::__construct();
$this->servicemon = new ServiceMon();
}
public function show(){
parent::show();
}
public function remove(){
parent::remove();
}
public function removeItem(){
$this->servicemon->remove($_POST['id']);
}
public function populateShowContent(){
$array_column = array('Agent','Service Name','Start Time','Finish Time','Warning Threshold','Critical Threshold');
$this->xml->addTable($this->servicemon->select($this->offset,$this->pglimit),
$array_column,'Table Service Monitoring',$this->navigator->getAccess($this),$this->offset,'rightcontent',0);
}
public function populateAddForm(){
$servicesdef = new ServicesDef();
$this->xml->addSelectAction('Service',$servicesdef->selectCouple('id','name'),'','service_id',$this->getName().'/addSelect');
$this->xml->addSelect('Agent',$this->servicemon->selectRemaining($servicesdef->getHead('id')),'','agent_id');
$this->xml->addTextField('Start Time',null,'start','text');
$this->xml->addTextField('Finish Time',null,'finish','text');
$this->xml->addTextField('Warning',null,'green','text');
$this->xml->addTextField('Critical',null,'red','text');
}
public function populateEditForm(){
$this->servicemon->selectByID($_POST['id']);
$this->xml->addTextField('Start Time',$this->servicemon->getStartTime(),'start','text');
$this->xml->addTextField('Finish Time',$this->servicemon->getFinishTime(),'finish','text');
$this->xml->addTextField('Warning',$this->servicemon->getGreenLine(),'green','text');
$this->xml->addTextField('Critical',$this->servicemon->getRedLine(),'red','text');
}
public function setEditCaption(){
$this->xml->addText('Edit Monitoring no. '.$_POST['itemnumber'],'headbox',1);
}
//return string to set the title
public function getTitle(){
return SITENAME.' -service-monitoring';
}
public function getFormPlace(){
return 'panel';
}
public function editItem(){
$array = array('starttime'=>$_POST['start'],'finishtime'=>$_POST['finish'],'red'=>$_POST['red'],'green'=>$_POST['green']);
return $this->servicemon->update($array,$_POST['id']);
}
public function getKeyVar(){
return 'start';
}
public function getTotal(){
return $this->servicemon->getTotal();
}
public function addItem(){
$array = array('',$_POST['service_id'],$_POST['agent_id'],$_POST['start'],$_POST['finish'],$_POST['green'],$_POST['red']);
$this->servicemon->add($array);
}
public function checkAdd(){
if($_POST['agent_id']==''){
die('Hostname selection empty. Must be no agent left to be monitored for this service!');
}
}
public function checkEdit(){
}
public function postAddAction(){
parent::postAddAction();
$this->xml->addRedirPOST($this->getName().'/addSelect','selected='.$_POST['service_id']);
}
//special derived class
public function addSelect(){
if(isset($_POST['service_id'])){
$this->xml->addSingleSelect($this->servicemon->selectRemaining($_POST['service_id']),'','agent_id','divselectagent_id');
}
$this->xml->flush();
}
}
?>