MISView.class.inc 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058
  1. <?php
  2. /*
  3. * DON'T REMOVE THE FOLLOWING LICENSE
  4. * INFORMATION!
  5. * ----------------------------------
  6. * Copyright by
  7. * Global Cube Business Solutions
  8. * Author: Dennis Ritz
  9. * info@global-cube.de
  10. * 2007-2008
  11. * ----------------------------------
  12. */
  13. class MISView extends App {
  14. public function __construct() {
  15. parent::__construct(__file__);
  16. }
  17. /*
  18. * init
  19. * ----
  20. * This function sets the main workaround for this class.
  21. */
  22. public function __init() {
  23. return $this->__COMPONENT();
  24. }
  25. public function getMain($p_view="overview",$p_sectionID = null) {
  26. $MISConfig = new MISConfig();
  27. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  28. $projectDOM->load($MISConfig->getConfigFile());
  29. $projectXpath = new DOMXpath($projectDOM);
  30. if($this->getAuth()) {
  31. $p_args = func_get_args();
  32. array_shift($p_args);
  33. $view = null;
  34. $scorecardList = $projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID='".$p_sectionID."' and ./../../@Directory='".$this->getUsername()."\']");
  35. $reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./../../@ID='".$p_sectionID."' and ./Directory='".$this->getUsername()."\' and ./Active='J']");
  36. $dashboardList = $projectXpath->query("/Configuration/Dashboards/Dashboard/Reviews/Review[./../../@Directory='".$this->getUsername()."\' and ./../../@ID='".$p_sectionID."']");
  37. if($p_view=="reports") {
  38. if(!$reportList->length > 0){
  39. if($scorecardList->length > 0)$p_view = "scorecards";
  40. elseif($dashboardList->length > 0)$p_view = "dashboards";
  41. else $p_view = "overview";
  42. }
  43. }
  44. if($p_view=="scorecards") {
  45. if(!$scorecardList->length > 0){
  46. if($reportList->length > 0)$p_view = "reports";
  47. elseif($dashboardList->length > 0)$p_view = "dashboards";
  48. else $p_view = "overview";
  49. }
  50. }
  51. if($p_view=="dashboards") {
  52. if(!$dashboardList->length > 0){
  53. if($reportList->length > 0)$p_view = "reports";
  54. elseif($scorecardList->length > 0)$p_view = "scorecards";
  55. else $p_view = "overview";
  56. }
  57. }
  58. $eval= '';
  59. $ret = '<div id="content">';
  60. switch($p_view) {
  61. case "overview": $arr = call_user_func_array(array($this, $p_view), $p_args);
  62. $ret.= $arr[0];$eval.=implode(";",$arr[1]);
  63. if($this->isRole("admin")) {
  64. $sectionLabel = new Label(new Icon("img/configurator.png"),$this->_getI18N("configurator"));
  65. $eval .= ';CMgr.getMODEL().setLeftFootbar(\'<div id="sectionItem" onclick="CMgr.getMODEL().getMain(\\\'MISConfigurator\\\',\\\'info\\\');">'.$sectionLabel.'</div>\');';
  66. }
  67. break;
  68. case "reports": $arr = call_user_func_array(array($this, $p_view), $p_args);
  69. $ret.= $arr[0];$eval.=implode(";",$arr[1]);
  70. $sectionLabel = new Label(new Icon("img/arrow_back.png"),$this->_getI18N("back"));
  71. $eval .= ';CMgr.getMODEL().setLeftToolbar(\'<div id="sectionItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'overview\\\');">'.$sectionLabel.'</div>\');';
  72. break;
  73. case "scorecards": $arr = call_user_func_array(array($this, $p_view), $p_args);
  74. $ret.= $arr[0];$eval.=$arr[1];
  75. $sectionLabel = new Label(new Icon("img/arrow_back.png"),$this->_getI18N("back"));
  76. $eval .= ';CMgr.getMODEL().setLeftToolbar(\'<div id="sectionItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'overview\\\');">'.$sectionLabel.'</div>\');';
  77. break;
  78. case "dashboards": $arr = call_user_func_array(array($this, $p_view), $p_args);
  79. $ret.= $arr[0];$eval.=$arr[1];
  80. $sectionLabel = new Label(new Icon("img/arrow_back.png"),$this->_getI18N("back"));
  81. $eval .= ';CMgr.getMODEL().setLeftToolbar(\'<div id="sectionItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'overview\\\');">'.$sectionLabel.'</div>\');';
  82. break;
  83. default: $ret.= $this->_getI18N("noViewAvailableInfoMsg");
  84. $eval.=';CMgr.getMODEL().setLocationName(\''.$p_view.'\');';break;
  85. }
  86. $ret.= '
  87. </div>';
  88. return array($ret,$eval);
  89. } else {
  90. return array('','CMgr.getMODEL().getMain();');
  91. }
  92. }
  93. private function overview() {
  94. if($this->getAuth()) {
  95. $MISConfig = new MISConfig();
  96. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  97. $projectDOM->load($MISConfig->getConfigFile());
  98. $projectXpath = new DOMXpath($projectDOM);
  99. $eval = array();
  100. $menu = new Tree("sectionMenu");
  101. $this->getSectionMenu($menu);
  102. array_push($eval,'CMgr.getMODEL().setNavContainer(\''.addslashes(''.$menu.'').'\')');
  103. array_push($eval,'Tree.setToUserView(Browser.getElementById("sectionMenu"))');
  104. $configName = $projectXpath->query("/Configuration")->item(0)->getAttribute("Name");
  105. $confLabel = new Label($configName);
  106. array_push($eval,'CMgr.getMODEL().setLocationName(\''.addslashes($confLabel).'\')');
  107. array_push($eval,'CMgr.getMODEL().setMainHead(\'\')');
  108. array_push($eval,'CMgr.getMODEL().setLeftToolbar(\'\')');
  109. array_push($eval,'CMgr.getMODEL().setMainToolbar(\'\')');
  110. $tpl = $this->Template();
  111. include(ROOT_DIR."apps/MISView/version.php");
  112. if($projectXpath->query("/Configuration/Version")->item(0)->getAttribute("show") == "true")
  113. $tpl->assign("version",$version);
  114. $ret = $tpl->fetch('overview.tpl');
  115. return array($ret,$eval);
  116. } else {
  117. return array('','CMgr.getMODEL().getMain();');
  118. }
  119. }
  120. private function getSectionMenu($p_node,$p_parentID="",$projectDOM=null,$projectXpath=null) {
  121. if($projectDOM == null) {
  122. $MISConfig = new MISConfig();
  123. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  124. $projectDOM->load($MISConfig->getConfigFile());
  125. }
  126. if($projectXpath == null) {
  127. $projectXpath = new DOMXpath($projectDOM);
  128. }
  129. $childsHaveValue = $sectionHasValue = $isVisible = false;
  130. $PPList = $projectXpath->query('/Configuration/Publishes/Publish[./@parentID = "'.$p_parentID.'"]');
  131. $Hauptampeln = $projectXpath->query('/Configuration/Publishes/Publish[./@User="'.$this->getUsername().'" and ./@Alert="true"]');
  132. if($Hauptampeln->length >0) $Hauptampeln = true;
  133. else $Hauptampeln = false;
  134. for($k=0;$k < $PPList->length;$k++) {
  135. $PP = $PPList->item($k);
  136. if($PP->nodeType != XML_ELEMENT_NODE) continue;
  137. $sectionID = $PP->getAttribute("ID");
  138. $sectionName = $PP->getAttribute("Name");
  139. $sectionHasValue = ($projectXpath->query('/Configuration/Publishes/Publish[./@ID="'.$sectionID.'" and ./Images/Image/Directory="'.$this->getUsername().'\\"]')->length > 0) ? true : false;
  140. $sectionHasReport = $sectionHasValue;
  141. if(!$sectionHasValue) $sectionHasValue = ($projectXpath->query('/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID="'.$sectionID.'" and ./../../@Directory="'.$this->getUsername().'\\"]')->length > 0) ? true : false;
  142. if(!$sectionHasValue) $sectionHasValue = ($projectXpath->query('/Configuration/Dashboards/Dashboard/Reviews/Review[./../../@ID="'.$sectionID.'" and ./../../@Directory="'.$this->getUsername().'\\"]')->length > 0) ? true : false;
  143. if(!$sectionHasReport) $sectionHasReport = ($projectXpath->query('/Configuration/Dashboards/Dashboard/Reviews/Review[./../../@ID="'.$sectionID.'" and ./../../@Directory="'.$this->getUsername().'\\"]')->length > 0) ? true : false;
  144. $subPPList = $projectXpath->query('/Configuration/Publishes/Publish[./@parentID = "'.$sectionID.'"]');
  145. $PPHauptampel = $projectXpath->query('/Configuration/Publishes/Publish/@Alert[./../@ID="'.$sectionID.'"]')->item(0)->nodeValue;
  146. if($PPHauptampel == "true") {
  147. $icon = new Icon("?&rc=MISView&rm=getSectionStatusImg&ras[]=".$sectionID);
  148. $eventListener = new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","scorecards","'.$sectionID.'");');
  149. $icon->addEventListener($eventListener);
  150. $newLabel = new Label($icon,str_replace("_"," ",$sectionName));
  151. }else{
  152. if($Hauptampeln) $newLabel = new Label(new Icon("img/MISView/sectionStatus_blank.png"),str_replace("_"," ",$sectionName));
  153. else $newLabel = new Label(str_replace("_"," ",$sectionName));
  154. }
  155. $newTreeNode = new TreeNode($newLabel,"sectionMenu_".$sectionID);
  156. if($sectionHasReport)
  157. $eventListener = new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","reports","'.$sectionID.'");');
  158. else
  159. $eventListener = new EventListener("onclick",'Tree.expand(this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode);');
  160. $newLabel->addEventListener($eventListener);
  161. $eventListener = new EventListener("onclick",'Tree.select(this.parentNode.parentNode);');
  162. $newTreeNode->addEventListener($eventListener);
  163. if($subPPList->length > 0) {
  164. $childsHaveValue = $this->getSectionMenu($newTreeNode,$sectionID,$projectDOM,$projectXpath);
  165. }else{
  166. $childsHaveValue = false;
  167. }
  168. if($childsHaveValue || $sectionHasValue) {
  169. $p_node->appendChild($newTreeNode);
  170. $isVisible = true;
  171. }
  172. }
  173. if($isVisible) {
  174. return true;
  175. } else {
  176. return false;
  177. }
  178. }
  179. public function getSectionStatusImg($p_sectionID) {
  180. ob_start();
  181. if(!isset($_SESSION["Config"]) && !isset($_SESSION["Config"]["General"]) && !isset($_SESSION["Config"]["General"]["PublishImagePath"])){
  182. $MISConfig = new MISConfig();
  183. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  184. $projectDOM->load($MISConfig->getConfigFile());
  185. $projectXpath = new DOMXpath($projectDOM);
  186. $_SESSION["Config"]["General"]["PublishImagePath"] = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  187. }
  188. $publishImagePath = $_SESSION["Config"]["General"]["PublishImagePath"];
  189. $datensatz = array();
  190. $dom = new DOMDocument('1.0', 'iso-8859-1');
  191. $dom->load(utf8_decode($publishImagePath . $this->getUsername() . "/data.xml"));
  192. $xpath = new DOMXPath($dom);
  193. $berichte = $xpath->query('/Daten/child::*[@ID = ' . $p_sectionID . ']/Scorecards/Bericht');
  194. for ( $i = 0; $i < $berichte->length; $i++ ) {
  195. $element = $berichte->item($i);
  196. $wert = $xpath->query('Wert', $element)->item(0)->nodeValue;
  197. $hoherzielwert = $xpath->query('HoherZielwert', $element)->item(0)->nodeValue;
  198. $niedrigerwert = $xpath->query('NiedrigerWert', $element)->item(0)->nodeValue;
  199. $hoherwert = $xpath->query('HoherWert', $element)->item(0)->nodeValue;
  200. $ampel = getImgAlarmstufeSrc($wert, $niedrigerwert, $hoherwert, $hoherzielwert);
  201. array_push($datensatz, $ampel);
  202. }
  203. $matrix = array(array(1,1,6,6),array(1,8,6,13),array(8,1,13,6),array(8,8,13,13),
  204. array(15,1,20,6),array(15,8,20,13),array(22,1,27,6),
  205. array(22,8,27,13),array(29,1,34,6),array(29,8,34,13),
  206. array(36,1,41,6),array(36,8,41,13),array(43,1,48,6),array(43,8,48,13));
  207. $anzahl = count($datensatz);
  208. if ($anzahl < 14) {
  209. $start = 14 - $anzahl;
  210. } else {
  211. $start = 0;
  212. }
  213. $farbe['g1'] = array(66, 206, 0);
  214. $farbe['g2'] = array(0, 189, 0);
  215. $farbe['g3'] = array(0, 189, 0);
  216. $farbe['g4'] = array(0, 156, 0);
  217. $farbe['g5'] = array(0, 156, 0);
  218. $farbe['g6'] = array(0, 115, 0);
  219. $farbe['g7'] = array(0, 99, 0);
  220. $farbe['r1'] = array(255, 189, 0);
  221. $farbe['r2'] = array(255, 156, 0);
  222. $farbe['r3'] = array(255, 99, 0);
  223. $farbe['r4'] = array(255, 33, 0);
  224. $farbe['r5'] = array(255, 33, 0);
  225. $farbe['r6'] = array(206, 0, 0);
  226. $farbe['r7'] = array(173, 0, 0);
  227. $farbe['r8'] = array(173, 0, 0);
  228. $error = ob_get_clean();
  229. if($error =="") {
  230. $im = new Imagick("./img/MISView/sectionStatus.png");
  231. $i=0;
  232. foreach ($datensatz as $key => $value) {
  233. if (($start > $key)) {
  234. $draw = new ImagickDraw();
  235. $draw->setFillColor(new ImagickPixel( 'rgb('.implode(",",$farbe[$value]).')' ));
  236. $draw->rectangle($matrix[$i][0],$matrix[$i][1],$matrix[$i+1][2],$matrix[$i+1][3]);
  237. $im->drawImage($draw);
  238. $i+=2;
  239. } else {
  240. $draw = new ImagickDraw();
  241. $draw->setFillColor(new ImagickPixel( 'rgb('.implode(",",$farbe[$value]).')' ));
  242. $draw->rectangle($matrix[$i][0],$matrix[$i][1],$matrix[$i][2],$matrix[$i][3]);
  243. $im->drawImage($draw);
  244. $i++;
  245. }
  246. }
  247. }else {
  248. $im = new Imagick("./img/MISView/sectionStatusError.png");
  249. }
  250. $data = $im->getImageBlob ();
  251. header ("Content-Type: image/{$im->getImageFormat()}");
  252. echo $data;
  253. }
  254. private function reports($p_sectionID,$p_reportID=null) {
  255. $MISConfig = new MISConfig();
  256. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  257. $projectDOM->load($MISConfig->getConfigFile());
  258. $projectXpath = new DOMXpath($projectDOM);
  259. $reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./../../@ID='".$p_sectionID."' and ./Directory='".$this->getUsername()."\\' and ./Active='J']");
  260. $tree = new Tree("contentMenu");
  261. $prevReportID = $nextReportID = null;
  262. for($i=0;$i<$reportList->length;$i++){
  263. $report = $reportList->item($i);
  264. $reportName = $report->getElementsByTagName("Name")->item(0)->nodeValue;
  265. if($report->getElementsByTagName("Ansicht")->item(0)->nodeValue == "Client")
  266. $icon = new Icon("img/report.png");
  267. else
  268. $icon = new Icon("img/pdficon_small.gif");
  269. $label = new Label($icon,$reportName);
  270. $node = new TreeNode($label,$p_sectionID."_".$report->getAttribute("ID"));
  271. $node->addEventListener(new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","reports","'.$p_sectionID.'","'.$report->getAttribute('ID').'");'));
  272. $tree->appendChild($node);
  273. if($i==0 && empty($p_reportID)) {
  274. $p_reportID = $report->getAttribute('ID');
  275. }
  276. if($p_reportID == $report->getAttribute('ID')) {
  277. if($i>0)$prevReportID = $reportList->item($i-1)->getAttribute('ID');
  278. if($i+1<$reportList->length)$nextReportID = $reportList->item($i+1)->getAttribute('ID');
  279. }
  280. }
  281. $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;
  282. if($this->_getView() == "Client")
  283. $reportLabel = new Label(new Icon("img/report.png"),$this->_getI18N("reports"));
  284. else
  285. $reportLabel = new Label(new Icon("img/pdficon_small.gif"),$this->_getI18N("reports"));
  286. $reportLink = '<div class="contentItem" style="background:#A3A3A3;">'.$reportLabel.'</div>';
  287. $scorecardList = $projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID='".$p_sectionID."' and ./../../@Directory='".$this->getUsername()."\\']");
  288. if($scorecardList->length > 0) {
  289. $scorecardLabel = new Label(new Icon('img/scorecard.png'),$this->_getI18N('scorecards'));
  290. $scorecardLink = '<div class="contentItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'scorecards\\\',\\\''.$p_sectionID.'\\\');">'.$scorecardLabel.'</div>';
  291. } else {
  292. $scorecardLink = '';
  293. }
  294. $dashboardList = $projectXpath->query("/Configuration/Dashboards/Dashboard[./@ID='".$p_sectionID."']/Reviews/Review[./../../@Directory='".$this->getUsername()."\\']");
  295. if($dashboardList->length > 0) {
  296. $dashboardLabel = new Label(new Icon('img/dashboard.png'),$this->_getI18N('dashboards'));
  297. $dashboardLink = '<div class="contentItem" style="" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'dashboards\\\',\\\''.$p_sectionID.'\\\');">'.$dashboardLabel.'</div>';
  298. }else{
  299. $dashboardLink = '';
  300. }
  301. $sectionName = $projectXpath->query("/Configuration/Publishes/Publish[@ID='".$p_sectionID."']")->item(0)->getAttribute("Name");
  302. $tpl = $this->Template();
  303. if($prevReportID != null){
  304. $icon = new Icon("img/MISView/zurueck.gif");
  305. $icon->addEventListener(new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","reports","'.$p_sectionID.'","'.$prevReportID.'");'));
  306. $tpl->assign("prevLink",$icon);
  307. }
  308. if($nextReportID != null) {
  309. $icon = new Icon("img/MISView/vor.gif");
  310. $icon->addEventListener(new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","reports","'.$p_sectionID.'","'.$nextReportID.'");'));
  311. $tpl->assign("nextLink",$icon);
  312. }
  313. $report = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./Active = 'J' and ./@ID = '".$p_reportID."' and ./Directory='".$this->getUsername()."\\']")->item(0);
  314. $reportPath = $projectXpath->query("/Configuration/General/ReportPath")->item(0)->nodeValue;
  315. $ppx = $report->getElementsByTagName("ppx")->item(0)->nodeValue;
  316. $reportFile = $report->getElementsByTagName("Report")->item(0)->nodeValue;
  317. if($report->getElementsByTagName("Ansicht")->item(0)->nodeValue == "Client") {
  318. if($ppx == "J" && file_exists($reportPath.$reportFile.".ppx")) $filename = $reportPath.$reportFile.".ppx";
  319. else $filename = utf8_decode($reportPath.$reportFile.".ppr");
  320. }else{
  321. if(!isset($_SESSION["Config"]) && !isset($_SESSION["Config"]["General"]) && !isset($_SESSION["Config"]["General"]["PublishImagePath"])){
  322. $_SESSION["Config"]["General"]["PublishImagePath"] = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  323. }
  324. $publishImagePath = $_SESSION["Config"]["General"]["PublishImagePath"];
  325. $filename = utf8_decode($publishImagePath.$this->getUsername()."\\".$sectionName."\\".$reportName.".pdf");
  326. }
  327. if (!file_exists($filename)) {
  328. $tpl->assign("reportLink",'javascript:alert(\''.$this->_getI18N('missingReportFile').'\');');
  329. }else{
  330. $tpl->assign("reportLink",'?&rc=MISView&rm=getReport&ras[]='.$p_reportID);
  331. }
  332. $reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./@ID='".$p_reportID."' and ./Directory='".$this->getUsername()."\\']");
  333. if($reportList->length == 2)
  334. $tpl->assign("imageLink",'?&rc=MISView&rm=reportPreview&ras[]='.$p_sectionID.'&ras[]='.$p_reportID);
  335. else
  336. $tpl->assign("imageLink",'?&rc=MISView&rm=reportPreview&ras[]=NAN');
  337. $PPHauptampel = $projectXpath->query('/Configuration/Publishes/Publish/@Alert[./../@ID="'.$p_sectionID.'"]')->item(0)->nodeValue;
  338. if($PPHauptampel == "true") {
  339. $icon = new Icon("?&rc=MISView&rm=getSectionStatusImg&ras[]=".$p_sectionID);
  340. $eventListener = new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","scorecards","'.$p_sectionID.'");');
  341. $icon->addEventListener($eventListener);
  342. $locLabel = new Label($icon,str_replace("_"," ",$sectionName));
  343. }else{
  344. $locLabel = new Label(str_replace("_"," ",$sectionName));
  345. }
  346. $mainLabel = new Label(str_replace("_"," ",$reportName));
  347. $evalArr = array('CMgr.getMODEL().setLocationName(\''.addslashes($locLabel).'\')',
  348. 'CMgr.getMODEL().setMainHead(\''.addslashes($mainLabel).'\')',
  349. 'CMgr.getMODEL().setNavContainer(\''.addslashes(''.$tree.'').'\')',
  350. 'Tree.setToUserView(Browser.getElementById("contentMenu"));',
  351. 'Tree.select(null,Browser.getElementById(\''.$p_sectionID."_".$p_reportID.'\'));',
  352. 'CMgr.getMODEL().setMainToolbar(\''.$reportLink.$scorecardLink.$dashboardLink.'\')');
  353. return array($tpl->fetch('report.tpl'),$evalArr);
  354. }
  355. public function reportPreview($p_sectionID,$p_reportID=null) {
  356. if($this->getAuth()) {
  357. if(!isset($_SESSION["Config"]) && !isset($_SESSION["Config"]["General"]) && !isset($_SESSION["Config"]["General"]["PublishImagePath"])){
  358. $MISConfig = new MISConfig();
  359. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  360. $projectDOM->load($MISConfig->getConfigFile());
  361. $projectXpath = new DOMXpath($projectDOM);
  362. $_SESSION["Config"]["General"]["PublishImagePath"] = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  363. }
  364. $publishImagePath = $_SESSION["Config"]["General"]["PublishImagePath"];
  365. $p_args = func_get_args();
  366. $MISConfig = new MISConfig();
  367. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  368. $projectDOM->load($MISConfig->getConfigFile());
  369. $projectXpath = new DOMXpath($projectDOM);
  370. $filename= "";
  371. if($p_sectionID != "NAN"){
  372. $imageNodeListGif = $projectXpath->query('/Configuration/Publishes/Publish/Images/Image[./../../@ID = "'.$p_sectionID.'" and ./@ID = "'.$p_reportID.'" and ./Directory = "'.$this->getUsername().'\\" and ./Active = "N" and ./GIFGenerate = "J"]');
  373. $imageNodeListJpg = $projectXpath->query('/Configuration/Publishes/Publish/Images/Image[./../../@ID = "'.$p_sectionID.'" and ./@ID = "'.$p_reportID.'" and ./Directory = "'.$this->getUsername().'\\" and ./Active = "N" and ./JPGGenerate = "J"]');
  374. $reportName = $projectXpath->query('/Configuration/Publishes/Publish/Images/Image/Name[./../../../@ID="'.$p_sectionID.'" and ./../@ID = "'.$p_reportID.'" and ./../Directory = "'.$this->getUsername().'\\" and ./../Active = "N"]')->item(0)->nodeValue;
  375. $sectionName = $projectXpath->query("/Configuration/Publishes/Publish[./@ID='".$p_sectionID."']")->item(0)->getAttribute("Name");
  376. if(count($imageNodeListGif) > 0) {
  377. $filename = $publishImagePath.$this->getUsername()."/".$sectionName."/".$reportName.".gif";
  378. $file_extension = "gif";
  379. } else if(count($imageNodeListJpg) > 0) {
  380. $filename = $publishImagePath.$this->getUsername()."/".$sectionName."/".$reportName.".png";
  381. $file_extension = "jpg";
  382. }
  383. }
  384. $filename = utf8_decode($filename);
  385. if (file_exists($filename)) {
  386. $im = new Imagick($filename);
  387. $im->scaleImage(750,0);
  388. /*
  389. if(date('j-m-y',time()) > date('j-m-y',filemtime(utf8_decode($publishImagePath.$this->getUsername()."/data.xml")))+3) {
  390. $draw = new ImagickDraw();
  391. $draw->setFont( "SociaLAnimaL" );
  392. $draw->setFillColor(new ImagickPixel('red'));
  393. $draw->setFontSize( 45 );
  394. $draw->setFillAlpha( 0.7 );
  395. $draw->setGravity( Imagick::GRAVITY_CENTER );
  396. $im->annotateImage( $draw, 0, 0, 25, "BERICHT IST NICHT AKTUELL!" );
  397. $im->annotateImage( $draw, 0, 65, 15, "STAND: ".date('j.m.y',filemtime(ROOT_DIR."daten/".$this->getUsername()."/data.xml")) );
  398. }
  399. */ }else{
  400. $im = new Imagick();
  401. $im->setResolution(750,500);
  402. $im->newImage(750, 500, new ImagickPixel('white'));
  403. /* Create a drawing object and set the font size */
  404. $draw = new ImagickDraw();
  405. /*** set the font ***/
  406. $draw->setFont( "SociaLAnimaL" );
  407. /*** set color ***/
  408. $draw->setFillColor(new ImagickPixel('red'));
  409. /*** set the font size ***/
  410. $draw->setFontSize( 30 );
  411. /*** add some transparency ***/
  412. $draw->setFillAlpha( 0.7 );
  413. /*** set gravity to the center ***/
  414. $draw->setGravity( Imagick::GRAVITY_CENTER );
  415. /*** overlay the text on the image ***/
  416. $im->annotateImage( $draw, 0, -30, 0, $this->_getI18N("noPreview") );
  417. $im->annotateImage( $draw, 0, +30, 0, $this->_getI18N("clickToOpen") );
  418. $im->setImageFormat('png');
  419. /*** set the font size ***/
  420. //$im->annotateImage( $draw, 0, 65, 15, "STAND: ".date('j.m.y',filemtime(ROOT_DIR."daten/".$this->getUsername()."/data.xml")) );
  421. }
  422. header("Pragma: public");
  423. header("Expires: 0");
  424. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  425. header("Cache-Control: private",false);
  426. header ("Content-Type: image/".$im->getImageFormat());
  427. $data = $im->getImageBlob ();
  428. echo $data;
  429. }
  430. }
  431. public function getReport($p_reportID) {
  432. if($this->getAuth()) {
  433. $p_args = func_get_args();
  434. $MISConfig = new MISConfig();
  435. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  436. $projectDOM->load($MISConfig->getConfigFile());
  437. $projectXpath = new DOMXpath($projectDOM);
  438. $report = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./Active = 'J' and ./@ID = '".$p_reportID."']")->item(0);
  439. $ansicht = $report->getElementsByTagName("Ansicht")->item(0)->nodeValue;
  440. //$ansicht = $this->_getView();
  441. switch($ansicht) {
  442. case "Client": $name = $report->getElementsByTagName("Report")->item(0)->nodeValue;
  443. $reportPath = $projectXpath->query("/Configuration/General/ReportPath")->item(0)->nodeValue;
  444. $ppx = $report->getElementsByTagName("ppx")->item(0)->nodeValue;
  445. if($ppx == "J" && file_exists($reportPath.$name.".ppx")) $filename = utf8_decode($reportPath.$name.".ppx");
  446. else $filename = utf8_decode($reportPath.$name.".ppr");
  447. $file_extension = strtolower(substr(strrchr($filename,"."),1));
  448. switch ($file_extension) {
  449. case "pdf": $ctype="application/pdf"; break;
  450. case "exe": $ctype="application/octet-stream"; break;
  451. case "zip": $ctype="application/zip"; break;
  452. case "doc": $ctype="application/msword"; break;
  453. case "xls": $ctype="application/vnd.ms-excel"; break;
  454. case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
  455. case "gif": $ctype="image/gif"; break;
  456. case "png": $ctype="image/png"; break;
  457. case "jpe": case "jpeg":
  458. case "jpg": $ctype="image/jpeg"; break;
  459. case "ppr": $ctype="application/powerplay"; break;
  460. case "ppx": $ctype="application/powerplay"; break;
  461. default: $ctype="text";
  462. }
  463. if (!file_exists($filename)) {
  464. die("<script type='text/javascript'>alert('" .$this->_getI18N("missingReportFile")."');window.history.back();</script>");
  465. }
  466. header("Pragma: public");
  467. header("Expires: 0");
  468. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  469. header("Cache-Control: private",false);
  470. header("Content-Type: $ctype");
  471. header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
  472. header("Content-Transfer-Encoding: binary");
  473. header("Content-Length: ".@filesize($filename));
  474. set_time_limit(0);
  475. readfile($filename) or die("File not found.");
  476. break;
  477. case "Info-User":$name = $report->getElementsByTagName("Name")->item(0)->nodeValue;
  478. $reportPath = $projectXpath->query("/Configuration/General/PublishImagePath")->item(0)->nodeValue;
  479. $sectionName = $projectXpath->query("/Configuration/Publishes/Publish[./Images/Image/@ID = '".$p_reportID."']")->item(0);
  480. $filename = utf8_decode($reportPath.$this->getUsername()."\\".$sectionName->getAttribute("Name")."\\".$name.".pdf");
  481. $file_extension = strtolower(substr(strrchr($filename,"."),1));
  482. $filename = $filename;
  483. switch ($file_extension) {
  484. case "pdf": $ctype="application/pdf"; break;
  485. case "exe": $ctype="application/octet-stream"; break;
  486. case "zip": $ctype="application/zip"; break;
  487. case "doc": $ctype="application/msword"; break;
  488. case "xls": $ctype="application/vnd.ms-excel"; break;
  489. case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
  490. case "gif": $ctype="image/gif"; break;
  491. case "png": $ctype="image/png"; break;
  492. case "jpe": break;
  493. case "jpeg":break;
  494. case "jpg": $ctype="image/jpeg"; break;
  495. case "ppr": $ctype="application/powerplay"; break;
  496. default: $ctype="text";
  497. }
  498. if (!file_exists($filename)) {
  499. die("<script type='text/javascript'>alert('".$this->_getI18N("missingReportFile")."');window.history.back();</script>");
  500. }
  501. header("Pragma: public");
  502. header("Expires: 0");
  503. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  504. header("Cache-Control: private",false);
  505. header("Content-Type: $ctype");
  506. header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
  507. header("Content-Transfer-Encoding: binary");
  508. header("Content-Length: ".@filesize($filename));
  509. set_time_limit(0);
  510. readfile($filename) or die("File not found.");
  511. break;
  512. case "Web": print "WRONG VIEW MODE!"; break;
  513. default: print "COULDN'T VALIDATE YOUR USER INFORMATION! PLEASE CONTACT YOUR ADMINISTRATOR!"; break;
  514. }
  515. }else{
  516. print "<script type='text/javascript'>window.history.back();</script>";
  517. }
  518. }
  519. public function getScorecardStatusImg($p_sectionID,$p_scorecardID) {
  520. try {
  521. $MISConfig = new MISConfig();
  522. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  523. $projectDOM->load($MISConfig->getConfigFile());
  524. $projectXpath = new DOMXpath($projectDOM);
  525. $publishImagePath = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  526. $dataDOM = new DOMDocument('1.0', 'iso-8859-1');
  527. $dataDOM->load(utf8_decode($publishImagePath.$this->getUsername()."/data.xml"));
  528. $dataXpath = new DOMXpath($dataDOM);
  529. $report = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[../../@ID = "'.$p_sectionID.'"]')->item($p_scorecardID);
  530. $aktwert = $report->getElementsByTagName("Wert")->item(0)->nodeValue;
  531. $niedriger = $report->getElementsByTagName("NiedrigerWert")->item(0)->nodeValue;
  532. $hoher = $report->getElementsByTagName("HoherWert")->item(0)->nodeValue;
  533. $positiv = $report->getElementsByTagName("HoherZielwert")->item(0)->nodeValue;
  534. $farbe = getImgAlarmstufeSrc($aktwert,$niedriger,$hoher,$positiv);
  535. $im = new Imagick(ROOT_DIR."apps/MISView/images/".$farbe.".gif");
  536. header ("Content-Type: image/{$im->getImageFormat()}");
  537. $data = $im->getImageBlob ();
  538. }catch(Exception $e) {
  539. $im = new Imagick(ROOT_DIR."apps/MISView/images/gerror.gif");
  540. header ("Content-Type: image/{$im->getImageFormat()}");
  541. $data = $im->getImageBlob ();
  542. }
  543. echo $data;
  544. }
  545. private function scorecards($p_sectionID,$p_scorecardID=0) {
  546. $MISConfig = new MISConfig();
  547. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  548. $projectDOM->load($MISConfig->getConfigFile());
  549. $projectXpath = new DOMXpath($projectDOM);
  550. $publishImagePath = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  551. $dataDOM = new DOMDocument('1.0', 'iso-8859-1');
  552. $dataDOM->load(utf8_decode($publishImagePath.$this->getUsername()."/data.xml"));
  553. $dataXpath = new DOMXpath($dataDOM);
  554. $p_reportID = $projectXpath->query('/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID = "'.$p_sectionID.'"]')->item($p_scorecardID)->getAttribute("ID");
  555. $scorecardList = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID = "'.$p_sectionID.'"]');
  556. $tree = new Tree("contentMenu");
  557. for($i=0;$i<$scorecardList->length;$i++){
  558. $report = $scorecardList->item($i);
  559. $reportName = $report->getElementsByTagName("Titel")->item(0)->nodeValue;
  560. $icon = new Icon("?&rc=MISView&rm=getScorecardStatusImg&ras[]=".$p_sectionID."&ras[]=".$i);
  561. $label = new Label($icon,$reportName);
  562. $temp = $projectXpath->query('/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID = "'.$p_sectionID.'"]')->item($i)->getAttribute("ID");
  563. $node = new TreeNode($label,$p_sectionID."_".$temp);
  564. $node->addEventListener(new EventListener("onclick",'Tree.select(this.parentNode.parentNode);CMgr.getMODEL().getMain("MISView","scorecards","'.$p_sectionID.'","'.$i.'");'));
  565. $tree->appendChild($node);
  566. if($i==0 && empty($p_scorecardID)) {
  567. $p_reportID = $temp;
  568. $active_reportName = $reportName;
  569. }
  570. if($i==$p_scorecardID) {
  571. $p_reportID = $temp;
  572. $active_reportName = $reportName;
  573. }
  574. }
  575. $scorecardLabel = new Label(new Icon('img/scorecard.png'),$this->_getI18N('scorecards'));
  576. $scorecardLink = '<div class="contentItem" style="background:#A3A3A3;">'.$scorecardLabel.'</div>';
  577. $reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./../../@ID='".$p_sectionID."' and ./Directory='".$this->getUsername()."\' and ./Active='J']");
  578. if($reportList->length > 0) {
  579. if($this->_getView() == "Client")
  580. $icon = new Icon("img/report.png");
  581. else
  582. $icon = new Icon("img/pdficon_small.gif");
  583. $reportLabel = new Label($icon,$this->_getI18N("reports"));
  584. $reportLink = '<div class="contentItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'reports\\\',\\\''.$p_sectionID.'\\\');">'.$reportLabel.'</div>';
  585. }else{
  586. $reportLink ='';
  587. }
  588. $dashboardList = $projectXpath->query("/Configuration/Dashboards/Dashboard[./@ID='".$p_sectionID."']/Reviews/Review[./../../@Directory='".$this->getUsername()."\']");
  589. if($dashboardList->length > 0) {
  590. $dashboardLabel = new Label(new Icon('img/dashboard.png'),$this->_getI18N('dashboards'));
  591. $dashboardLink = '<div class="contentItem" style="" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'dashboards\\\',\\\''.$p_sectionID.'\\\');">'.$dashboardLabel.'</div>';
  592. }else{
  593. $dashboardLink = '';
  594. }
  595. $sectionName = $projectXpath->query("/Configuration/Publishes/Publish[@ID='".$p_sectionID."']")->item(0)->getAttribute("Name");
  596. $tpl = $this->Template();
  597. $scorecard = $scorecardList->item($p_scorecardID);
  598. $tpl->assign("reportLink",'?&rc=MISView&rm=getScorecard&ras[]='.$projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID = '".$p_sectionID."']")->item($p_scorecardID)->getAttribute("ID"));
  599. $tpl->assign('sectionID',$p_sectionID);
  600. $tpl->assign('ID',$projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID = '".$p_sectionID."']")->item($p_scorecardID)->getAttribute("ID"));
  601. $tpl->assign('item',$p_scorecardID);
  602. $tpl->assign('Name',array('desc'=>$this->_getI18N('name'),'value'=>$scorecard->getElementsByTagname("Titel")->item(0)->nodeValue));
  603. $tpl->assign('Description',array('desc'=>$this->_getI18N('description'),'value'=>$scorecard->getElementsByTagName("Beschreibung")->item(0)->nodeValue));
  604. $tpl->assign('Status',array('desc'=>$this->_getI18N('status'),'value'=>'?&rc=MISView&rm=getScorecardDetailStatusImg&ras[]='.$p_sectionID.'&ras[]='.$p_scorecardID));
  605. $tpl->assign('Value',array('desc'=>$this->_getI18N('value'),'value'=>$scorecard->getElementsByTagName("Wert")->item(0)->nodeValue));
  606. $tpl->assign('HighValue',array('desc'=>$this->_getI18N('highValue'),'value'=>$scorecard->getElementsByTagName("HoherWert")->item(0)->nodeValue));
  607. $tpl->assign('LowValue',array('desc'=>$this->_getI18N('lowValue'),'value'=>$scorecard->getElementsByTagName("NiedrigerWert")->item(0)->nodeValue));
  608. $tpl->assign('Tolerance',array('desc'=>$this->_getI18N('tolerance'),'value'=>$scorecard->getElementsByTagName("Toleranz")->item(0)->nodeValue));
  609. $tpl->assign('Weight',array('desc'=>$this->_getI18N('weight'),'value'=>$scorecard->getElementsByTagName("Gewichtung")->item(0)->nodeValue));
  610. $tpl->assign('PositiveValue',array('desc'=>$this->_getI18N('positiveValue'),'value'=>$scorecard->getElementsByTagName("HoherZielwert")->item(0)->nodeValue));
  611. $tpl->assign('Coordinates',array('desc'=>$this->_getI18N('coordinates'),'value'=>$scorecard->getElementsByTagName("Koordinaten")->item(0)->nodeValue));
  612. $tpl->assign('SAVE',$this->_getI18N("save"));
  613. $tpl->assign('OPEN_REPORT',$this->_getI18N("open_report"));
  614. $PPHauptampel = $projectXpath->query('/Configuration/Publishes/Publish/@Alert[./../@ID="'.$p_sectionID.'"]')->item(0)->nodeValue;
  615. if($PPHauptampel == "true") {
  616. $icon = new Icon("?&rc=MISView&rm=getSectionStatusImg&ras[]=".$p_sectionID);
  617. $eventListener = new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","scorecards","'.$p_sectionID.'");');
  618. $icon->addEventListener($eventListener);
  619. $newLabel = new Label($icon,str_replace("_"," ",$sectionName));
  620. }else{
  621. $newLabel = new Label(str_replace("_"," ",$sectionName));
  622. }
  623. $evalArr = array('CMgr.getMODEL().setLocationName(\''.addslashes($newLabel).'\')',
  624. 'CMgr.getMODEL().setMainHead(\''.addslashes(new Label(str_replace("_"," ",$scorecard->getElementsByTagname("Titel")->item(0)->nodeValue))).'\')',
  625. 'CMgr.getMODEL().setNavContainer(\''.addslashes($tree).'\')',
  626. 'CMgr.getMODEL().setMainToolbar(\''.$reportLink.$scorecardLink.$dashboardLink.'\');',
  627. 'Tree.setToUserView(Browser.getElementById("contentMenu"));',
  628. 'Tree.select(null,Browser.getElementById(\''.$p_sectionID."_".$p_reportID.'\'));',
  629. 'CMgr.getMODEL().setMainFootbar(\'\');');
  630. return array($tpl->fetch("scorecard.tpl"),implode(";",$evalArr));
  631. }
  632. public function saveScorecard($p_sectionID,$p_ID,$p_item,$p_highValue,$p_lowValue) {
  633. $MISConfig = new MISConfig();
  634. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  635. $projectDOM->load($MISConfig->getConfigFile());
  636. $projectXpath = new DOMXpath($projectDOM);
  637. $publishImagePath = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  638. $dataDOM = new DOMDocument('1.0', 'iso-8859-1');
  639. $dataDOM->load(utf8_decode($publishImagePath.$this->getUsername()."/data.xml"));
  640. $dataXpath = new DOMXpath($dataDOM);
  641. $PR = $projectXpath->query('/Configuration/Scorecards/Scorecard/Reports/Report[./@ID = "'.$p_ID.'"]')->item(0);
  642. if($PR->getElementsByTagName("Format")->item(0)->nodeValue == "Prozent") {
  643. $p_lowValue = str_replace("%","",$p_lowValue);
  644. $p_highValue = str_replace("%","",$p_highValue);
  645. $MISConfig->setNodeValue("LowValue",number_reformat($p_lowValue, 2, ',',".")/100,$projectDOM,$PR);
  646. $MISConfig->setNodeValue("HighValue",number_reformat($p_highValue, 2, ',',".")/100,$projectDOM,$PR);
  647. $PRR = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID="'.$p_sectionID.'"]')->item($p_item);
  648. $MISConfig->setNodeValue("NiedrigerWert",str_replace(".",",",number_reformat($p_lowValue, 2, ',',"."))." %",$dataDOM,$PRR);
  649. $MISConfig->setNodeValue("HoherWert",str_replace(".",",",number_reformat($p_highValue, 2, ',',"."))." %",$dataDOM,$PRR);
  650. }
  651. if($PR->getElementsByTagName("Format")->item(0)->nodeValue == "Ganzzahlig") {
  652. $MISConfig->setNodeValue("LowValue",number_reformat($p_lowValue, 0, ',',"."),$projectDOM,$PR);
  653. $MISConfig->setNodeValue("HighValue",number_reformat($p_highValue, 0, ',',"."),$projectDOM,$PR);
  654. $PRR = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID="'.$p_sectionID.'"]')->item($p_item);
  655. $MISConfig->setNodeValue("NiedrigerWert",str_replace(".",",",number_reformat($p_lowValue, 0, ',',"."))."",$dataDOM,$PRR);
  656. $MISConfig->setNodeValue("HoherWert",str_replace(".",",",number_reformat($p_highValue, 0, ',',"."))."",$dataDOM,$PRR);
  657. }
  658. if($PR->getElementsByTagName("Format")->item(0)->nodeValue == "Zahl mit Trennz") {
  659. $MISConfig->setNodeValue("LowValue",number_reformat($p_lowValue, 2, ',',"."),$projectDOM,$PR);
  660. $MISConfig->setNodeValue("HighValue",number_reformat($p_highValue, 2, ',',"."),$projectDOM,$PR);
  661. $PRR = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID="'.$p_sectionID.'"]')->item($p_item);
  662. $MISConfig->setNodeValue("NiedrigerWert",str_replace(".",",",number_reformat($p_lowValue, 2, ',',"."))."",$dataDOM,$PRR);
  663. $MISConfig->setNodeValue("HoherWert",str_replace(".",",",number_reformat($p_highValue, 2, ',',"."))."",$dataDOM,$PRR);
  664. }
  665. if($PR->getElementsByTagName("Format")->item(0)->nodeValue == "Zahl ohne Trennz") {
  666. $MISConfig->setNodeValue("LowValue",number_reformat($p_lowValue, 0, ',',"."),$projectDOM,$PR);
  667. $MISConfig->setNodeValue("HighValue",number_reformat($p_highValue, 0, ',',"."),$projectDOM,$PR);
  668. $PRR = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID="'.$p_sectionID.'"]')->item($p_item);
  669. $MISConfig->setNodeValue("NiedrigerWert",str_replace(".",",",number_reformat($p_lowValue, 0, ',',"."))."",$dataDOM,$PRR);
  670. $MISConfig->setNodeValue("HoherWert",str_replace(".",",",number_reformat($p_highValue, 0, ',',"."))."",$dataDOM,$PRR);
  671. }
  672. if($PR->getElementsByTagName("Format")->item(0)->nodeValue == "W�hrung") {
  673. $MISConfig->setNodeValue("LowValue",number_reformat($p_lowValue, 2, ',',"."),$projectDOM,$PR);
  674. $MISConfig->setNodeValue("HighValue",number_reformat($p_highValue, 2, ',',"."),$projectDOM,$PR);
  675. $PRR = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID="'.$p_sectionID.'"]')->item($p_item);
  676. $MISConfig->setNodeValue("NiedrigerWert",str_replace(".",",",number_reformat($p_lowValue, 2, ',',"."))."",$dataDOM,$PRR);
  677. $MISConfig->setNodeValue("HoherWert",str_replace(".",",",number_reformat($p_highValue, 2, ',',"."))."",$dataDOM,$PRR);
  678. }
  679. $dataDOM->save(utf8_decode($publishImagePath.$this->getUsername()."/data.xml"));
  680. $projectDOM->save($MISConfig->getConfigFile());
  681. return array('CMgr.getMODEL().__construct();');
  682. }
  683. public function getScorecard($p_reportID) {
  684. if($this->getAuth()) {
  685. $p_args = func_get_args();
  686. $MISConfig = new MISConfig();
  687. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  688. $projectDOM->load($MISConfig->getConfigFile());
  689. $projectXpath = new DOMXpath($projectDOM);
  690. $report = $projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./@ID = '".$p_reportID."' and ./../../@Directory='".$this->getUsername()."\\']")->item(0);
  691. //$ansicht = $report->getElementsByTagName("Ansicht")->item(0)->nodeValue;
  692. $name = $report->getElementsByTagName("ReportFile")->item(0)->nodeValue;
  693. $reportPath = $projectXpath->query("/Configuration/General/ReportPath")->item(0)->nodeValue;
  694. $filename = $reportPath.$name.".ppr";
  695. $file_extension = strtolower(substr(strrchr($filename,"."),1));
  696. switch ($file_extension) {
  697. case "pdf": $ctype="application/pdf"; break;
  698. case "exe": $ctype="application/octet-stream"; break;
  699. case "zip": $ctype="application/zip"; break;
  700. case "doc": $ctype="application/msword"; break;
  701. case "xls": $ctype="application/vnd.ms-excel"; break;
  702. case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
  703. case "gif": $ctype="image/gif"; break;
  704. case "png": $ctype="image/png"; break;
  705. case "jpe": case "jpeg":
  706. case "jpg": $ctype="image/jpeg"; break;
  707. case "ppr": $ctype="application/powerplay"; break;
  708. default: $ctype="text";
  709. }
  710. if (!file_exists($filename)) {
  711. die("<script type='text/javascript'>alert('".$this->_getI18N("missingReportFile")."');window.history.back();</script>");
  712. }
  713. header("Pragma: public");
  714. header("Expires: 0");
  715. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  716. header("Cache-Control: private",false);
  717. header("Content-Type: $ctype");
  718. header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
  719. header("Content-Transfer-Encoding: binary");
  720. header("Content-Length: ".@filesize($filename));
  721. set_time_limit(0);
  722. readfile($filename) or die("File not found.");
  723. }else{
  724. print "<script type='text/javascript'>window.history.back();</script>";
  725. }
  726. }
  727. public function getScorecardDetailStatusImg($p_sectionID,$p_scorecardID) {
  728. header("Content-Type: image/png\n\n");
  729. $MISConfig = new MISConfig();
  730. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  731. $projectDOM->load($MISConfig->getConfigFile());
  732. $projectXpath = new DOMXpath($projectDOM);
  733. $publishImagePath = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  734. $dataDOM = new DOMDocument('1.0', 'iso-8859-1');
  735. $dataDOM->load(utf8_decode($publishImagePath.$this->getUsername()."/data.xml"));
  736. $dataXpath = new DOMXpath($dataDOM);
  737. $scorecard = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[../../@ID = "'.$p_sectionID.'"]')->item($p_scorecardID);
  738. $anzeige = ImageCreateFromPNG (ROOT_DIR."apps/MISView/scDetail_".$scorecard->getElementsByTagName("HoherZielwert")->item(0)->nodeValue.".png");
  739. $pfeil = ImageCreateFromPNG (ROOT_DIR."apps/MISView/dart.png");
  740. $faktor = 8;
  741. $aktwert = umwandeln($scorecard->getElementsByTagName("Wert")->item(0)->nodeValue);
  742. $niedriger = umwandeln($scorecard->getElementsByTagName("NiedrigerWert")->item(0)->nodeValue);
  743. $hoher = umwandeln($scorecard->getElementsByTagName("HoherWert")->item(0)->nodeValue);
  744. $delta = $hoher - $niedriger;
  745. if ($scorecard->getElementsByTagName("HoherZielwert")->item(0)->nodeValue == "J") {
  746. if (($aktwert > $niedriger) && ($aktwert < $hoher)) {
  747. $pixel = ((($aktwert - $niedriger) * 135) / $delta) + 14;
  748. } elseif ($aktwert > $hoher) {
  749. $pixel = ((($aktwert - $hoher) * 129) / ($delta * $faktor)) + 155;
  750. } else {
  751. $pixel = 13 + ((($aktwert - $niedriger) * 13) / ($delta * 2));
  752. }
  753. } else {
  754. if (($aktwert > $niedriger) && ($aktwert < $hoher)) {
  755. $pixel = ((($aktwert - $niedriger) * 135) / $delta) + 140;
  756. } elseif ($aktwert > $hoher) {
  757. $pixel = ((($aktwert - $hoher) * 13) / ($delta * 2)) + 270;
  758. } else {
  759. $pixel = 140 + ((($aktwert - $niedriger) * 129) / ($delta * $faktor));
  760. }
  761. }
  762. $pixel = round($pixel);
  763. if ($pixel > 285) {
  764. $pixel = 285;
  765. }
  766. if ($pixel < 0) {
  767. $pixel = 0;
  768. }
  769. ImageCopy ($anzeige, $pfeil, $pixel, 8, 0, 0, 11, 24);
  770. $schwarz = ImageColorAllocate ($anzeige, 0, 0, 0);
  771. if ($scorecard->getElementsByTagName("HoherZielwert")->item(0)->nodeValue == "J") {
  772. $minpos = 27;
  773. $maxpos = 162;
  774. } else {
  775. $minpos = 133 - 6 * strlen($niedriger);
  776. $maxpos = 268 - 6 * strlen($hoher);
  777. }
  778. ImageString($anzeige, 2, $minpos, 32, $niedriger, $schwarz);
  779. ImageString($anzeige, 2, $maxpos, 32, $hoher, $schwarz);
  780. ImagePng($anzeige);
  781. }
  782. private function dashboards($p_sectionID,$p_reportID=null) {
  783. $MISConfig = new MISConfig();
  784. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  785. $projectDOM->load($MISConfig->getConfigFile());
  786. $projectXpath = new DOMXpath($projectDOM);
  787. $reportList = $projectXpath->query("/Configuration/Dashboards/Dashboard/Reviews/Review[./../../@Directory='".$this->getUsername()."\' and ./../../@ID='".$p_sectionID."']");
  788. $tree = new Tree("contentMenu");
  789. for($i=0;$i<$reportList->length;$i++){
  790. $report = $reportList->item($i);
  791. $reportName = $report->getElementsByTagName("Name")->item(0)->nodeValue;
  792. $reportDesc = $report->getElementsByTagName("Description")->item(0)->nodeValue;
  793. $icon = new Icon("img/dashboard.png");
  794. $label = new Label($icon,$reportName);
  795. $node = new TreeNode($label,$p_sectionID."_".$report->getAttribute("ID"));
  796. $node->addEventListener(new EventListener("onclick",'Tree.select(this.parentNode.parentNode);CMgr.getMODEL().getMain("MISView","dashboards","'.$p_sectionID.'","'.$report->getAttribute('ID').'");'));
  797. $tree->appendChild($node);
  798. if($i==0 && empty($p_reportID)) {
  799. $p_reportID = $report->getAttribute('ID');
  800. $active_reportName = $reportName;
  801. $active_reportDesc = $reportDesc;
  802. }
  803. if($p_reportID == $report->getAttribute('ID')) {
  804. //$label->active(true);
  805. $active_reportName = $reportName;
  806. $active_reportDesc = $reportDesc;
  807. }
  808. }
  809. if($this->_getView() == "Client")
  810. $icon = new Icon("img/report.png");
  811. else
  812. $icon = new Icon("img/pdficon_small.gif");
  813. $reportLabel = new Label($icon,$this->_getI18N("reports"));
  814. $scorecardLabel = new Label(new Icon('img/scorecard.png'),$this->_getI18N('scorecards'));
  815. $dashboardLabel = new Label(new Icon('img/dashboard.png'),$this->_getI18N('dashboards'));
  816. $reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./Directory='".$this->getUsername()."\' and ./../../@ID='".$p_sectionID."']");
  817. if($reportList->length > 0) {
  818. $reportLink = '<div class="contentItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'reports\\\',\\\''.$p_sectionID.'\\\');">'.$reportLabel.'</div>';
  819. }else{
  820. $reportLink = "";
  821. }
  822. $dashboardLink = '<div class="contentItem" style="background:#A3A3A3;">'.$dashboardLabel.'</div>';
  823. $scorecardList = $projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID='".$p_sectionID."' and ./../../@Directory='".$this->getUsername()."\\']");
  824. if($scorecardList->length > 0) {
  825. $scorecardLink = '<div class="contentItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'scorecards\\\',\\\''.$p_sectionID.'\\\');">'.$scorecardLabel.'</div>';
  826. } else {
  827. $scorecardLink = '';
  828. }
  829. $sectionName = $projectXpath->query("/Configuration/Publishes/Publish[@ID='".$p_sectionID."']")->item(0)->getAttribute("Name");
  830. $tpl = $this->Template();
  831. $tpl->assign('OPEN_REPORT',$this->_getI18N("open_report"));
  832. $tpl->assign('Description',array('desc'=>$this->_getI18N('description'),'value'=>$active_reportDesc));
  833. $tpl->assign("reportLink",'?&rc=MISView&rm=getDashboard&ras[]='.$p_reportID);
  834. $tpl->assign("imageLink",'img/MISView/excel.gif');
  835. $PPHauptampel = $projectXpath->query('/Configuration/Publishes/Publish/@Alert[./../@ID="'.$p_sectionID.'"]')->item(0)->nodeValue;
  836. if($PPHauptampel == "true") {
  837. $icon = new Icon("?&rc=MISView&rm=getSectionStatusImg&ras[]=".$p_sectionID);
  838. $eventListener = new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","scorecards","'.$p_sectionID.'");');
  839. $icon->addEventListener($eventListener);
  840. $newLabel = new Label($icon,str_replace("_"," ",$sectionName));
  841. }else{
  842. $newLabel = new Label(str_replace("_"," ",$sectionName));
  843. }
  844. $evalArr = array('CMgr.getMODEL().setLocationName(\''.addslashes($newLabel).'\')',
  845. 'CMgr.getMODEL().setMainHead(\''.addslashes(new Label(str_replace("_"," ",$active_reportName))).'\')',
  846. 'CMgr.getMODEL().setNavContainer(\''.addslashes(''.$tree.'').'\')',
  847. 'Tree.setToUserView(Browser.getElementById("contentMenu"));',
  848. 'Tree.select(null,Browser.getElementById(\''.$p_sectionID."_".$p_reportID.'\'));',
  849. 'CMgr.getMODEL().setMainToolbar(\''.$reportLink.$scorecardLink.$dashboardLink.'\')',
  850. 'CMgr.getMODEL().setMainFootbar(\'\');');
  851. return array($tpl->fetch('dashboard.tpl'),implode(";",$evalArr));
  852. }
  853. public function getDashboard($p_reportID) {
  854. if($this->getAuth()) {
  855. $p_args = func_get_args();
  856. $MISConfig = new MISConfig();
  857. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  858. $projectDOM->load($MISConfig->getConfigFile());
  859. $projectXpath = new DOMXpath($projectDOM);
  860. $report = $projectXpath->query("/Configuration/Dashboards/Dashboard/Reviews/Review[./@ID = '".$p_reportID."' and ./../../@Directory='".$this->getUsername()."\\']")->item(0);
  861. $name = $report->getElementsByTagName("ReportFile")->item(0)->nodeValue;
  862. $reportPath = $projectXpath->query("/Configuration/General/DashboardPath")->item(0)->nodeValue;
  863. $filename = $reportPath.$name.".xls";
  864. $file_extension = strtolower(substr(strrchr($filename,"."),1));
  865. switch ($file_extension) {
  866. case "pdf": $ctype="application/pdf"; break;
  867. case "exe": $ctype="application/octet-stream"; break;
  868. case "zip": $ctype="application/zip"; break;
  869. case "doc": $ctype="application/msword"; break;
  870. case "xls": $ctype="application/vnd.ms-excel"; break;
  871. case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
  872. case "gif": $ctype="image/gif"; break;
  873. case "png": $ctype="image/png"; break;
  874. case "jpe": case "jpeg":
  875. case "jpg": $ctype="image/jpeg"; break;
  876. case "ppr": $ctype="application/powerplay"; break;
  877. default: $ctype="text";
  878. }
  879. if (!file_exists($filename)) {
  880. die("<script type='text/javascript'>alert('".$this->_getI18N("missingReportFile")."');window.history.back();</script>");
  881. }
  882. header("Pragma: public");
  883. header("Expires: 0");
  884. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  885. header("Cache-Control: private",false);
  886. header("Content-Type: $ctype");
  887. header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
  888. header("Content-Transfer-Encoding: binary");
  889. header("Content-Length: ".@filesize($filename));
  890. set_time_limit(0);
  891. readfile($filename) or die("File not found.");
  892. }else{
  893. print "<script type='text/javascript'>window.history.back();</script>";
  894. }
  895. }
  896. }
  897. ?>