__COMPONENT();
}
public function getMain($p_view="overview",$p_sectionID = null) {
$MISConfig = new MISConfig();
$projectDOM = new DOMDocument('1.0', 'iso-8859-1');
$projectDOM->load($MISConfig->getConfigFile());
$projectXpath = new DOMXpath($projectDOM);
if($this->getAuth()) {
$p_args = func_get_args();
array_shift($p_args);
$view = null;
$scorecardList = $projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID='".$p_sectionID."' and ./../../@Directory='".$this->getUsername()."\']");
$reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./../../@ID='".$p_sectionID."' and ./Directory='".$this->getUsername()."\' and ./Active='J']");
$dashboardList = $projectXpath->query("/Configuration/Dashboards/Dashboard/Reviews/Review[./../../@Directory='".$this->getUsername()."\' and ./../../@ID='".$p_sectionID."']");
if($p_view=="reports") {
if(!$reportList->length > 0){
if($scorecardList->length > 0)$p_view = "scorecards";
elseif($dashboardList->length > 0)$p_view = "dashboards";
else $p_view = "overview";
}
}
if($p_view=="scorecards") {
if(!$scorecardList->length > 0){
if($reportList->length > 0)$p_view = "reports";
elseif($dashboardList->length > 0)$p_view = "dashboards";
else $p_view = "overview";
}
}
if($p_view=="dashboards") {
if(!$dashboardList->length > 0){
if($reportList->length > 0)$p_view = "reports";
elseif($scorecardList->length > 0)$p_view = "scorecards";
else $p_view = "overview";
}
}
$eval= '';
$ret = '
';
switch($p_view) {
case "overview": $arr = call_user_func_array(array($this, $p_view), $p_args);
$ret.= $arr[0];$eval.=implode(";",$arr[1]);
if($this->isRole("admin")) {
$sectionLabel = new Label(new Icon("img/configurator.png"),$this->_getI18N("configurator"));
$eval .= ';CMgr.getMODEL().setLeftFootbar(\'
'.$sectionLabel.'
\');';
}
break;
case "reports": $arr = call_user_func_array(array($this, $p_view), $p_args);
$ret.= $arr[0];$eval.=implode(";",$arr[1]);
$sectionLabel = new Label(new Icon("img/arrow_back.png"),$this->_getI18N("back"));
$eval .= ';CMgr.getMODEL().setLeftToolbar(\'
'.$sectionLabel.'
\');';
break;
case "scorecards": $arr = call_user_func_array(array($this, $p_view), $p_args);
$ret.= $arr[0];$eval.=$arr[1];
$sectionLabel = new Label(new Icon("img/arrow_back.png"),$this->_getI18N("back"));
$eval .= ';CMgr.getMODEL().setLeftToolbar(\'
'.$sectionLabel.'
\');';
break;
case "dashboards": $arr = call_user_func_array(array($this, $p_view), $p_args);
$ret.= $arr[0];$eval.=$arr[1];
$sectionLabel = new Label(new Icon("img/arrow_back.png"),$this->_getI18N("back"));
$eval .= ';CMgr.getMODEL().setLeftToolbar(\'
'.$sectionLabel.'
\');';
break;
default: $ret.= $this->_getI18N("noViewAvailableInfoMsg");
$eval.=';CMgr.getMODEL().setLocationName(\''.$p_view.'\');';break;
}
$ret.= '
';
return array($ret,$eval);
} else {
return array('','CMgr.getMODEL().getMain();');
}
}
private function overview() {
if($this->getAuth()) {
$MISConfig = new MISConfig();
$projectDOM = new DOMDocument('1.0', 'iso-8859-1');
$projectDOM->load($MISConfig->getConfigFile());
$projectXpath = new DOMXpath($projectDOM);
$eval = array();
$menu = new Tree("sectionMenu");
$this->getSectionMenu($menu);
array_push($eval,'CMgr.getMODEL().setNavContainer(\''.addslashes(''.$menu.'').'\')');
array_push($eval,'Tree.setToUserView(Browser.getElementById("sectionMenu"))');
$configName = $projectXpath->query("/Configuration")->item(0)->getAttribute("Name");
$confLabel = new Label($configName);
array_push($eval,'CMgr.getMODEL().setLocationName(\''.addslashes($confLabel).'\')');
array_push($eval,'CMgr.getMODEL().setMainHead(\'\')');
array_push($eval,'CMgr.getMODEL().setLeftToolbar(\'\')');
array_push($eval,'CMgr.getMODEL().setMainToolbar(\'\')');
$tpl = $this->Template();
include(ROOT_DIR."apps/MISView/version.php");
if($projectXpath->query("/Configuration/Version")->item(0)->getAttribute("show") == "true")
$tpl->assign("version",$version);
$ret = $tpl->fetch('overview.tpl');
return array($ret,$eval);
} else {
return array('','CMgr.getMODEL().getMain();');
}
}
private function getSectionMenu($p_node,$p_parentID="",$projectDOM=null,$projectXpath=null) {
if($projectDOM == null) {
$MISConfig = new MISConfig();
$projectDOM = new DOMDocument('1.0', 'iso-8859-1');
$projectDOM->load($MISConfig->getConfigFile());
}
if($projectXpath == null) {
$projectXpath = new DOMXpath($projectDOM);
}
$childsHaveValue = $sectionHasValue = $isVisible = false;
$PPList = $projectXpath->query('/Configuration/Publishes/Publish[./@parentID = "'.$p_parentID.'"]');
$Hauptampeln = $projectXpath->query('/Configuration/Publishes/Publish[./@User="'.$this->getUsername().'" and ./@Alert="true"]');
if($Hauptampeln->length >0) $Hauptampeln = true;
else $Hauptampeln = false;
for($k=0;$k < $PPList->length;$k++) {
$PP = $PPList->item($k);
if($PP->nodeType != XML_ELEMENT_NODE) continue;
$sectionID = $PP->getAttribute("ID");
$sectionName = $PP->getAttribute("Name");
$sectionHasValue = ($projectXpath->query('/Configuration/Publishes/Publish[./@ID="'.$sectionID.'" and ./Images/Image/Directory="'.$this->getUsername().'\\"]')->length > 0) ? true : false;
$sectionHasReport = $sectionHasValue;
if(!$sectionHasValue) $sectionHasValue = ($projectXpath->query('/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID="'.$sectionID.'" and ./../../@Directory="'.$this->getUsername().'\\"]')->length > 0) ? true : false;
if(!$sectionHasValue) $sectionHasValue = ($projectXpath->query('/Configuration/Dashboards/Dashboard/Reviews/Review[./../../@ID="'.$sectionID.'" and ./../../@Directory="'.$this->getUsername().'\\"]')->length > 0) ? true : false;
if(!$sectionHasReport) $sectionHasReport = ($projectXpath->query('/Configuration/Dashboards/Dashboard/Reviews/Review[./../../@ID="'.$sectionID.'" and ./../../@Directory="'.$this->getUsername().'\\"]')->length > 0) ? true : false;
$subPPList = $projectXpath->query('/Configuration/Publishes/Publish[./@parentID = "'.$sectionID.'"]');
$PPHauptampel = $projectXpath->query('/Configuration/Publishes/Publish/@Alert[./../@ID="'.$sectionID.'"]')->item(0)->nodeValue;
if($PPHauptampel == "true") {
$icon = new Icon("?&rc=MISView&rm=getSectionStatusImg&ras[]=".$sectionID);
$eventListener = new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","scorecards","'.$sectionID.'");');
$icon->addEventListener($eventListener);
$newLabel = new Label($icon,str_replace("_"," ",$sectionName));
}else{
if($Hauptampeln) $newLabel = new Label(new Icon("img/MISView/sectionStatus_blank.png"),str_replace("_"," ",$sectionName));
else $newLabel = new Label(str_replace("_"," ",$sectionName));
}
$newTreeNode = new TreeNode($newLabel,"sectionMenu_".$sectionID);
if($sectionHasReport)
$eventListener = new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","reports","'.$sectionID.'");');
else
$eventListener = new EventListener("onclick",'Tree.expand(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode);');
$newLabel->addEventListener($eventListener);
$eventListener = new EventListener("onclick",'Tree.select(this.parentNode.parentNode);');
$newTreeNode->addEventListener($eventListener);
if($subPPList->length > 0) {
$childsHaveValue = $this->getSectionMenu($newTreeNode,$sectionID,$projectDOM,$projectXpath);
}else{
$childsHaveValue = false;
}
if($childsHaveValue || $sectionHasValue) {
$p_node->appendChild($newTreeNode);
$isVisible = true;
}
}
if($isVisible) {
return true;
} else {
return false;
}
}
public function getSectionStatusImg($p_sectionID) {
ob_start();
if(!isset($_SESSION["Config"]) && !isset($_SESSION["Config"]["General"]) && !isset($_SESSION["Config"]["General"]["PublishImagePath"])){
$MISConfig = new MISConfig();
$projectDOM = new DOMDocument('1.0', 'iso-8859-1');
$projectDOM->load($MISConfig->getConfigFile());
$projectXpath = new DOMXpath($projectDOM);
$_SESSION["Config"]["General"]["PublishImagePath"] = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
}
$publishImagePath = $_SESSION["Config"]["General"]["PublishImagePath"];
$datensatz = array();
$dom = new DOMDocument('1.0', 'iso-8859-1');
$dom->load(utf8_decode($publishImagePath . $this->getUsername() . "/data.xml"));
$xpath = new DOMXPath($dom);
$berichte = $xpath->query('/Daten/child::*[@ID = ' . $p_sectionID . ']/Scorecards/Bericht');
for ( $i = 0; $i < $berichte->length; $i++ ) {
$element = $berichte->item($i);
$wert = $xpath->query('Wert', $element)->item(0)->nodeValue;
$hoherzielwert = $xpath->query('HoherZielwert', $element)->item(0)->nodeValue;
$niedrigerwert = $xpath->query('NiedrigerWert', $element)->item(0)->nodeValue;
$hoherwert = $xpath->query('HoherWert', $element)->item(0)->nodeValue;
$ampel = getImgAlarmstufeSrc($wert, $niedrigerwert, $hoherwert, $hoherzielwert);
array_push($datensatz, $ampel);
}
$matrix = array(array(1,1,6,6),array(1,8,6,13),array(8,1,13,6),array(8,8,13,13),
array(15,1,20,6),array(15,8,20,13),array(22,1,27,6),
array(22,8,27,13),array(29,1,34,6),array(29,8,34,13),
array(36,1,41,6),array(36,8,41,13),array(43,1,48,6),array(43,8,48,13));
$anzahl = count($datensatz);
if ($anzahl < 14) {
$start = 14 - $anzahl;
} else {
$start = 0;
}
$farbe['g1'] = array(66, 206, 0);
$farbe['g2'] = array(0, 189, 0);
$farbe['g3'] = array(0, 189, 0);
$farbe['g4'] = array(0, 156, 0);
$farbe['g5'] = array(0, 156, 0);
$farbe['g6'] = array(0, 115, 0);
$farbe['g7'] = array(0, 99, 0);
$farbe['r1'] = array(255, 189, 0);
$farbe['r2'] = array(255, 156, 0);
$farbe['r3'] = array(255, 99, 0);
$farbe['r4'] = array(255, 33, 0);
$farbe['r5'] = array(255, 33, 0);
$farbe['r6'] = array(206, 0, 0);
$farbe['r7'] = array(173, 0, 0);
$farbe['r8'] = array(173, 0, 0);
$error = ob_get_clean();
if($error =="") {
$im = new Imagick("./img/MISView/sectionStatus.png");
$i=0;
foreach ($datensatz as $key => $value) {
if (($start > $key)) {
$draw = new ImagickDraw();
$draw->setFillColor(new ImagickPixel( 'rgb('.implode(",",$farbe[$value]).')' ));
$draw->rectangle($matrix[$i][0],$matrix[$i][1],$matrix[$i+1][2],$matrix[$i+1][3]);
$im->drawImage($draw);
$i+=2;
} else {
$draw = new ImagickDraw();
$draw->setFillColor(new ImagickPixel( 'rgb('.implode(",",$farbe[$value]).')' ));
$draw->rectangle($matrix[$i][0],$matrix[$i][1],$matrix[$i][2],$matrix[$i][3]);
$im->drawImage($draw);
$i++;
}
}
}else {
$im = new Imagick("./img/MISView/sectionStatusError.png");
}
$data = $im->getImageBlob ();
header ("Content-Type: image/{$im->getImageFormat()}");
echo $data;
}
private function reports($p_sectionID,$p_reportID=null) {
$MISConfig = new MISConfig();
$projectDOM = new DOMDocument('1.0', 'iso-8859-1');
$projectDOM->load($MISConfig->getConfigFile());
$projectXpath = new DOMXpath($projectDOM);
$reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./../../@ID='".$p_sectionID."' and ./Directory='".$this->getUsername()."\\' and ./Active='J']");
$tree = new Tree("contentMenu");
$prevReportID = $nextReportID = null;
for($i=0;$i<$reportList->length;$i++){
$report = $reportList->item($i);
$reportName = $report->getElementsByTagName("Name")->item(0)->nodeValue;
if($report->getElementsByTagName("Ansicht")->item(0)->nodeValue == "Client")
$icon = new Icon("img/report.png");
else
$icon = new Icon("img/pdficon_small.gif");
$label = new Label($icon,$reportName);
$node = new TreeNode($label,$p_sectionID."_".$report->getAttribute("ID"));
$node->addEventListener(new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","reports","'.$p_sectionID.'","'.$report->getAttribute('ID').'");'));
$tree->appendChild($node);
if($i==0 && empty($p_reportID)) {
$p_reportID = $report->getAttribute('ID');
}
if($p_reportID == $report->getAttribute('ID')) {
if($i>0)$prevReportID = $reportList->item($i-1)->getAttribute('ID');
if($i+1<$reportList->length)$nextReportID = $reportList->item($i+1)->getAttribute('ID');
}
}
$reportName = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./@ID='".$p_reportID."' and ./Directory='".$this->getUsername()."\\' and ./Active='J']")->item(0)->getElementsByTagname("Name")->item(0)->nodeValue;
if($this->_getView() == "Client")
$reportLabel = new Label(new Icon("img/report.png"),$this->_getI18N("reports"));
else
$reportLabel = new Label(new Icon("img/pdficon_small.gif"),$this->_getI18N("reports"));
$reportLink = '