<?php
//this class should be not management class
//still mess up
Class NetworkMapAgent extends Management {
private $netmap;
private $agent;
public function __construct(){
parent::__construct();
$this->netmap = new NetMapAgent();
$this->agent = new Agent();
}
public function show(){
$this->xml->addRedir('managenetworkmap/index');
$this->xml->flush();
}
public function remove(){
parent::remove();
}
public function removeItem(){
$this->netmap->remove($_POST['id']);
}
public function populateShowContent(){
}
public function populateAddForm(){
$arrayagent = $this->netmap->selectRemaining();
if(sizeof($arrayagent)==0){
die('NOTE: No Agent left to be added at network map');
}
$this->xml->addSelect('Hostname',$arrayagent,'','agent_id');
$this->xml->addTextField('Axis',null,'axis','text');
$this->xml->addTextField('Ordinat',null,'ordinat','text');
}
public function populateEditForm(){
$this->netmap->selectByID($_POST['id']);
$this->xml->addTextField('Axis',$this->netmap->getX(),'axis','text');
$this->xml->addTextField('Ordinat',$this->netmap->getY(),'ordinat','text');
}
public function setEditCaption(){
$this->xml->addText('Edit Agent Position No. '.$_POST['itemnumber'],'headbox',1);
}
//return string to set the title
public function getTitle(){
return SITENAME.' -netmap';
}
public function getFormPlace(){
return 'panel';
}
public function editItem(){
$array = array('x'=>$_POST['axis'],'y'=>$_POST['ordinat']);
return $this->netmap->update($array,$_POST['id']);
}
public function getKeyVar(){
return 'axis';
}
public function getTotal(){
return $this->netmap->getTotal();
}
public function addItem(){
$array = array($_POST['agent_id'],$_POST['axis'],$_POST['ordinat']);
$this->netmap->add($array);
}
//not implemented
public function checkAdd(){
}
public function checkEdit(){
}
//redefine post add action
public function postAddAction(){
$this->xml->addText('Adding Agent ID '.$_POST['agent_id'].' to be painted in network map','note',0);
$arrayagent = $this->netmap->selectRemaining();
if(sizeof($arrayagent)==0){
$this->xml->addText(null,'panel',0);
}else{
$this->xml->addRedir($this->getName().'/add');
}
}
}
?>