MISView.class.inc 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136
  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. $xpath = $this->getScorecardFileDOM();
  182. $datensatz = array();
  183. $berichte = $xpath->query('/Daten/child::*[@ID = ' . $p_sectionID . ']/Scorecards/Bericht');
  184. for ( $i = 0; $i < $berichte->length; $i++ ) {
  185. $element = $berichte->item($i);
  186. $wert = $xpath->query('Wert', $element)->item(0)->nodeValue;
  187. $hoherzielwert = $xpath->query('HoherZielwert', $element)->item(0)->nodeValue;
  188. $niedrigerwert = $xpath->query('NiedrigerWert', $element)->item(0)->nodeValue;
  189. $hoherwert = $xpath->query('HoherWert', $element)->item(0)->nodeValue;
  190. $ampel = $this->getImgAlarmstufeSrc($wert, $niedrigerwert, $hoherwert, $hoherzielwert);
  191. array_push($datensatz, $ampel);
  192. }
  193. $matrix = array(array(1,1,6,6),array(1,8,6,13),array(8,1,13,6),array(8,8,13,13),
  194. array(15,1,20,6),array(15,8,20,13),array(22,1,27,6),
  195. array(22,8,27,13),array(29,1,34,6),array(29,8,34,13),
  196. array(36,1,41,6),array(36,8,41,13),array(43,1,48,6),array(43,8,48,13));
  197. $anzahl = count($datensatz);
  198. if ($anzahl < 14) {
  199. $start = 14 - $anzahl;
  200. } else {
  201. $start = 0;
  202. }
  203. $farbe['g1'] = array(66, 206, 0);
  204. $farbe['g2'] = array(0, 189, 0);
  205. $farbe['g3'] = array(0, 189, 0);
  206. $farbe['g4'] = array(0, 156, 0);
  207. $farbe['g5'] = array(0, 156, 0);
  208. $farbe['g6'] = array(0, 115, 0);
  209. $farbe['g7'] = array(0, 99, 0);
  210. $farbe['r1'] = array(255, 189, 0);
  211. $farbe['r2'] = array(255, 156, 0);
  212. $farbe['r3'] = array(255, 99, 0);
  213. $farbe['r4'] = array(255, 33, 0);
  214. $farbe['r5'] = array(255, 33, 0);
  215. $farbe['r6'] = array(206, 0, 0);
  216. $farbe['r7'] = array(173, 0, 0);
  217. $farbe['r8'] = array(173, 0, 0);
  218. $error = ob_get_clean();
  219. if($error =="") {
  220. $im = new Imagick("./img/MISView/sectionStatus.png");
  221. $i=0;
  222. foreach ($datensatz as $key => $value) {
  223. if (($start > $key)) {
  224. $draw = new ImagickDraw();
  225. $draw->setFillColor(new ImagickPixel( 'rgb('.implode(",",$farbe[$value]).')' ));
  226. $draw->rectangle($matrix[$i][0],$matrix[$i][1],$matrix[$i+1][2],$matrix[$i+1][3]);
  227. $im->drawImage($draw);
  228. $i+=2;
  229. } else {
  230. $draw = new ImagickDraw();
  231. $draw->setFillColor(new ImagickPixel( 'rgb('.implode(",",$farbe[$value]).')' ));
  232. $draw->rectangle($matrix[$i][0],$matrix[$i][1],$matrix[$i][2],$matrix[$i][3]);
  233. $im->drawImage($draw);
  234. $i++;
  235. }
  236. }
  237. } else {
  238. return $error;
  239. $im = new Imagick("./img/MISView/sectionStatusError.png");
  240. }
  241. header ("Content-Type: image/{$im->getImageFormat()}");
  242. echo $im->getImageBlob ();
  243. }
  244. private function reports($p_sectionID,$p_reportID=null) {
  245. $MISConfig = new MISConfig();
  246. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  247. $projectDOM->load($MISConfig->getConfigFile());
  248. $projectXpath = new DOMXpath($projectDOM);
  249. $reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./../../@ID='".$p_sectionID."' and ./Directory='".$this->getUsername()."\\' and ./Active='J']");
  250. $tree = new Tree("contentMenu");
  251. $prevReportID = $nextReportID = null;
  252. for($i=0;$i<$reportList->length;$i++){
  253. $report = $reportList->item($i);
  254. $reportName = $report->getElementsByTagName("Name")->item(0)->nodeValue;
  255. if($report->getElementsByTagName("Ansicht")->item(0)->nodeValue == "Client")
  256. $icon = new Icon("img/report.png");
  257. else
  258. $icon = new Icon("img/pdficon_small.gif");
  259. $label = new Label($icon,$reportName);
  260. $node = new TreeNode($label,$p_sectionID."_".$report->getAttribute("ID"));
  261. $node->addEventListener(new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","reports","'.$p_sectionID.'","'.$report->getAttribute('ID').'");'));
  262. $tree->appendChild($node);
  263. if($i==0 && empty($p_reportID)) {
  264. $p_reportID = $report->getAttribute('ID');
  265. }
  266. if($p_reportID == $report->getAttribute('ID')) {
  267. if($i>0)$prevReportID = $reportList->item($i-1)->getAttribute('ID');
  268. if($i+1<$reportList->length)$nextReportID = $reportList->item($i+1)->getAttribute('ID');
  269. }
  270. }
  271. $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;
  272. if($this->_getView() == "Client")
  273. $reportLabel = new Label(new Icon("img/report.png"),$this->_getI18N("reports"));
  274. else
  275. $reportLabel = new Label(new Icon("img/pdficon_small.gif"),$this->_getI18N("reports"));
  276. $reportLink = '<div class="contentItem" style="background:#A3A3A3;">'.$reportLabel.'</div>';
  277. $scorecardList = $projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID='".$p_sectionID."' and ./../../@Directory='".$this->getUsername()."\\']");
  278. if($scorecardList->length > 0) {
  279. $scorecardLabel = new Label(new Icon('img/scorecard.png'),$this->_getI18N('scorecards'));
  280. $scorecardLink = '<div class="contentItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'scorecards\\\',\\\''.$p_sectionID.'\\\');">'.$scorecardLabel.'</div>';
  281. } else {
  282. $scorecardLink = '';
  283. }
  284. $dashboardList = $projectXpath->query("/Configuration/Dashboards/Dashboard[./@ID='".$p_sectionID."']/Reviews/Review[./../../@Directory='".$this->getUsername()."\\']");
  285. if($dashboardList->length > 0) {
  286. $dashboardLabel = new Label(new Icon('img/dashboard.png'),$this->_getI18N('dashboards'));
  287. $dashboardLink = '<div class="contentItem" style="" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'dashboards\\\',\\\''.$p_sectionID.'\\\');">'.$dashboardLabel.'</div>';
  288. }else{
  289. $dashboardLink = '';
  290. }
  291. $sectionName = $projectXpath->query("/Configuration/Publishes/Publish[@ID='".$p_sectionID."']")->item(0)->getAttribute("Name");
  292. $tpl = $this->Template();
  293. if($prevReportID != null){
  294. $icon = new Icon("img/MISView/zurueck.gif");
  295. $icon->addEventListener(new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","reports","'.$p_sectionID.'","'.$prevReportID.'");'));
  296. $tpl->assign("prevLink",$icon);
  297. }
  298. if($nextReportID != null) {
  299. $icon = new Icon("img/MISView/vor.gif");
  300. $icon->addEventListener(new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","reports","'.$p_sectionID.'","'.$nextReportID.'");'));
  301. $tpl->assign("nextLink",$icon);
  302. }
  303. $report = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./Active = 'J' and ./@ID = '".$p_reportID."' and ./Directory='".$this->getUsername()."\\']")->item(0);
  304. $reportPath = $projectXpath->query("/Configuration/General/ReportPath")->item(0)->nodeValue;
  305. $ppx = $report->getElementsByTagName("ppx")->item(0)->nodeValue;
  306. $reportFile = $report->getElementsByTagName("Report")->item(0)->nodeValue;
  307. if($report->getElementsByTagName("Ansicht")->item(0)->nodeValue == "Client") {
  308. if($ppx == "J" && file_exists($reportPath.$reportFile.".ppx")) $filename = $reportPath.$reportFile.".ppx";
  309. else $filename = utf8_decode($reportPath.$reportFile.".ppr");
  310. }else{
  311. if(!isset($_SESSION["Config"]) && !isset($_SESSION["Config"]["General"]) && !isset($_SESSION["Config"]["General"]["PublishImagePath"])){
  312. $_SESSION["Config"]["General"]["PublishImagePath"] = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  313. }
  314. $publishImagePath = $_SESSION["Config"]["General"]["PublishImagePath"];
  315. $layer = $report->getElementsByTagName("PDFImageLayer")->item(0)->nodeValue;
  316. $configFile = substr($_SESSION[CONFIG_SESSION]['configFile'], 0, -4);
  317. $filename = utf8_decode($publishImagePath . $configFile . "\\" . $reportFile . "_" . $layer . ".pdf");
  318. if (!file_exists($filename)) {
  319. $filename = utf8_decode($publishImagePath.$this->getUsername()."\\".$sectionName."\\".$reportName.".pdf");
  320. }
  321. }
  322. if (!file_exists($filename)) {
  323. $tpl->assign("reportLink",'javascript:alert(\''.$this->_getI18N('missingReportFile').'\');');
  324. }else{
  325. $tpl->assign("reportLink",'?&rc=MISView&rm=getReport&ras[]='.$p_reportID);
  326. }
  327. $reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./@ID='".$p_reportID."' and ./Directory='".$this->getUsername()."\\']");
  328. if($reportList->length == 2)
  329. $tpl->assign("imageLink",'?&rc=MISView&rm=reportPreview&ras[]='.$p_sectionID.'&ras[]='.$p_reportID);
  330. else
  331. $tpl->assign("imageLink",'?&rc=MISView&rm=reportPreview&ras[]=NAN');
  332. $PPHauptampel = $projectXpath->query('/Configuration/Publishes/Publish/@Alert[./../@ID="'.$p_sectionID.'"]')->item(0)->nodeValue;
  333. if($PPHauptampel == "true") {
  334. $icon = new Icon("?&rc=MISView&rm=getSectionStatusImg&ras[]=".$p_sectionID);
  335. $eventListener = new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","scorecards","'.$p_sectionID.'");');
  336. $icon->addEventListener($eventListener);
  337. $locLabel = new Label($icon,str_replace("_"," ",$sectionName));
  338. }else{
  339. $locLabel = new Label(str_replace("_"," ",$sectionName));
  340. }
  341. $mainLabel = new Label(str_replace("_"," ",$reportName));
  342. $evalArr = array('CMgr.getMODEL().setLocationName(\''.addslashes($locLabel).'\')',
  343. 'CMgr.getMODEL().setMainHead(\''.addslashes($mainLabel).'\')',
  344. 'CMgr.getMODEL().setNavContainer(\''.addslashes(''.$tree.'').'\')',
  345. 'Tree.setToUserView(Browser.getElementById("contentMenu"));',
  346. 'Tree.select(null,Browser.getElementById(\''.$p_sectionID."_".$p_reportID.'\'));',
  347. 'CMgr.getMODEL().setMainToolbar(\''.$reportLink.$scorecardLink.$dashboardLink.'\')');
  348. return array($tpl->fetch('report.tpl'),$evalArr);
  349. }
  350. public function reportPreview($p_sectionID,$p_reportID=null) {
  351. if($this->getAuth()) {
  352. if(!isset($_SESSION["Config"]) && !isset($_SESSION["Config"]["General"]) && !isset($_SESSION["Config"]["General"]["PublishImagePath"])){
  353. $MISConfig = new MISConfig();
  354. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  355. $projectDOM->load($MISConfig->getConfigFile());
  356. $projectXpath = new DOMXpath($projectDOM);
  357. $_SESSION["Config"]["General"]["PublishImagePath"] = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  358. }
  359. $publishImagePath = $_SESSION["Config"]["General"]["PublishImagePath"];
  360. $p_args = func_get_args();
  361. $MISConfig = new MISConfig();
  362. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  363. $projectDOM->load($MISConfig->getConfigFile());
  364. $projectXpath = new DOMXpath($projectDOM);
  365. $filename= "";
  366. if($p_sectionID != "NAN"){
  367. $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"]');
  368. $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"]');
  369. $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;
  370. $sectionName = $projectXpath->query("/Configuration/Publishes/Publish[./@ID='".$p_sectionID."']")->item(0)->getAttribute("Name");
  371. $pprName = $projectXpath->query('/Configuration/Publishes/Publish/Images/Image/Report[./../../../@ID="'.$p_sectionID.'" and ./../@ID = "'.$p_reportID.'" and ./../Directory = "'.$this->getUsername().'\\" and ./../Active = "N"]')->item(0)->nodeValue;
  372. if (preg_match("/_graf/is", $pprName)) {
  373. $pprName = substr($pprName, 0, -5);
  374. }
  375. $layer = $projectXpath->query('/Configuration/Publishes/Publish/Images/Image/ImageLayer[./../../../@ID="'.$p_sectionID.'" and ./../@ID = "'.$p_reportID.'" and ./../Directory = "'.$this->getUsername().'\\" and ./../Active = "N"]')->item(0)->nodeValue;
  376. if ($layer == 0) {
  377. $layer = 1;
  378. }
  379. $configFile = substr($_SESSION[CONFIG_SESSION]['configFile'], 0, -4);
  380. $filename = utf8_decode($publishImagePath . $configFile . "\\" . $pprName . "_" . $layer . ".jpg");
  381. $file_extension = "jpg";
  382. if (!file_exists($filename)) {
  383. if(count($imageNodeListGif) > 0) {
  384. $filename = $publishImagePath.$this->getUsername()."/".$sectionName."/".$reportName.".gif";
  385. $file_extension = "gif";
  386. } else if(count($imageNodeListJpg) > 0) {
  387. $filename = $publishImagePath.$this->getUsername()."/".$sectionName."/".$reportName.".png";
  388. $file_extension = "jpg";
  389. }
  390. $filename = utf8_decode($filename);
  391. }
  392. }
  393. if (file_exists($filename)) {
  394. $im = new Imagick($filename);
  395. $im->scaleImage(750,0);
  396. }else{
  397. $im = new Imagick();
  398. $im->setResolution(750,500);
  399. $im->newImage(750, 500, new ImagickPixel('white'));
  400. /* Create a drawing object and set the font size */
  401. $draw = new ImagickDraw();
  402. /*** set the font ***/
  403. $draw->setFont( "SociaLAnimaL" );
  404. /*** set color ***/
  405. $draw->setFillColor(new ImagickPixel('red'));
  406. /*** set the font size ***/
  407. $draw->setFontSize( 30 );
  408. /*** add some transparency ***/
  409. $draw->setFillAlpha( 0.7 );
  410. /*** set gravity to the center ***/
  411. $draw->setGravity( Imagick::GRAVITY_CENTER );
  412. /*** overlay the text on the image ***/
  413. $im->annotateImage( $draw, 0, -30, 0, $this->_getI18N("noPreview") );
  414. $im->annotateImage( $draw, 0, +30, 0, $this->_getI18N("clickToOpen") );
  415. $im->setImageFormat('png');
  416. }
  417. header("Pragma: public");
  418. header("Expires: 0");
  419. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  420. header("Cache-Control: private",false);
  421. header ("Content-Type: image/".$im->getImageFormat());
  422. $data = $im->getImageBlob ();
  423. echo $data;
  424. //echo $filename;
  425. }
  426. }
  427. public function getReport($p_reportID) {
  428. if($this->getAuth()) {
  429. $p_args = func_get_args();
  430. $MISConfig = new MISConfig();
  431. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  432. $projectDOM->load($MISConfig->getConfigFile());
  433. $projectXpath = new DOMXpath($projectDOM);
  434. $report = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./Active = 'J' and ./@ID = '".$p_reportID."']")->item(0);
  435. $ansicht = $report->getElementsByTagName("Ansicht")->item(0)->nodeValue;
  436. //$ansicht = $this->_getView();
  437. switch($ansicht) {
  438. case "Client": $name = $report->getElementsByTagName("Report")->item(0)->nodeValue;
  439. $reportPath = $projectXpath->query("/Configuration/General/ReportPath")->item(0)->nodeValue;
  440. $ppx = $report->getElementsByTagName("ppx")->item(0)->nodeValue;
  441. if($ppx == "J" && file_exists($reportPath.$name.".ppx")) $filename = utf8_decode($reportPath.$name.".ppx");
  442. else $filename = utf8_decode($reportPath.$name.".ppr");
  443. $file_extension = strtolower(substr(strrchr($filename,"."),1));
  444. switch ($file_extension) {
  445. case "pdf": $ctype="application/pdf"; break;
  446. case "exe": $ctype="application/octet-stream"; break;
  447. case "zip": $ctype="application/zip"; break;
  448. case "doc": $ctype="application/msword"; break;
  449. case "xls": $ctype="application/vnd.ms-excel"; break;
  450. case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
  451. case "gif": $ctype="image/gif"; break;
  452. case "png": $ctype="image/png"; break;
  453. case "jpe": case "jpeg":
  454. case "jpg": $ctype="image/jpeg"; break;
  455. case "ppr": $ctype="application/powerplay"; break;
  456. case "ppx": $ctype="application/powerplay"; break;
  457. default: $ctype="text";
  458. }
  459. if (!file_exists($filename)) {
  460. die("<script type='text/javascript'>alert('" .$this->_getI18N("missingReportFile")."');window.history.back();</script>");
  461. }
  462. header("Pragma: public");
  463. header("Expires: 0");
  464. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  465. header("Cache-Control: private",false);
  466. header("Content-Type: $ctype");
  467. header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
  468. header("Content-Transfer-Encoding: binary");
  469. header("Content-Length: ".@filesize($filename));
  470. set_time_limit(0);
  471. readfile($filename) or die("File not found.");
  472. break;
  473. case "Info-User":
  474. $name = $report->getElementsByTagName("Name")->item(0)->nodeValue;
  475. $reportPath = $projectXpath->query("/Configuration/General/PublishImagePath")->item(0)->nodeValue;
  476. $sectionName = $projectXpath->query("/Configuration/Publishes/Publish[./Images/Image/@ID = '".$p_reportID."']")->item(0);
  477. $pprName = $report->getElementsByTagName("Report")->item(0)->nodeValue;
  478. $layer = $report->getElementsByTagName("PDFImageLayer")->item(0)->nodeValue;
  479. $configFile = substr($_SESSION[CONFIG_SESSION]['configFile'], 0, -4);
  480. $filename = utf8_decode($reportPath . $configFile . "\\" . $pprName . "_" . $layer . ".pdf");
  481. if (!file_exists($filename)) {
  482. $filename = utf8_decode($reportPath.$this->getUsername()."\\".$sectionName->getAttribute("Name")."\\".$name.".pdf");
  483. }
  484. $file_extension = strtolower(substr(strrchr($filename,"."),1));
  485. switch ($file_extension) {
  486. case "pdf": $ctype="application/pdf"; break;
  487. case "exe": $ctype="application/octet-stream"; break;
  488. case "zip": $ctype="application/zip"; break;
  489. case "doc": $ctype="application/msword"; break;
  490. case "xls": $ctype="application/vnd.ms-excel"; break;
  491. case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
  492. case "gif": $ctype="image/gif"; break;
  493. case "png": $ctype="image/png"; break;
  494. case "jpe": break;
  495. case "jpeg":break;
  496. case "jpg": $ctype="image/jpeg"; break;
  497. case "ppr": $ctype="application/powerplay"; break;
  498. default: $ctype="text";
  499. }
  500. if (!file_exists($filename)) {
  501. die("<script type='text/javascript'>alert('".$this->_getI18N("missingReportFile")."');window.history.back();</script>");
  502. }
  503. header("Pragma: public");
  504. header("Expires: 0");
  505. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  506. header("Cache-Control: private",false);
  507. header("Content-Type: $ctype");
  508. header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
  509. header("Content-Transfer-Encoding: binary");
  510. header("Content-Length: ".@filesize($filename));
  511. set_time_limit(0);
  512. readfile($filename) or die("File not found.");
  513. break;
  514. case "Web": print "WRONG VIEW MODE!"; break;
  515. default: print "COULDN'T VALIDATE YOUR USER INFORMATION! PLEASE CONTACT YOUR ADMINISTRATOR!"; break;
  516. }
  517. }else{
  518. print "<script type='text/javascript'>window.history.back();</script>";
  519. }
  520. }
  521. public function getScorecardStatusImg($p_sectionID,$p_scorecardID) {
  522. try {
  523. $dataXpath = $this->getScorecardFileDOM();
  524. $report = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[../../@ID = "'.$p_sectionID.'"]')->item($p_scorecardID);
  525. $aktwert = $report->getElementsByTagName("Wert")->item(0)->nodeValue;
  526. $niedriger = $report->getElementsByTagName("NiedrigerWert")->item(0)->nodeValue;
  527. $hoher = $report->getElementsByTagName("HoherWert")->item(0)->nodeValue;
  528. $positiv = $report->getElementsByTagName("HoherZielwert")->item(0)->nodeValue;
  529. $farbe = $this->getImgAlarmstufeSrc($aktwert,$niedriger,$hoher,$positiv);
  530. $im = new Imagick(ROOT_DIR."apps/MISView/images/".$farbe.".gif");
  531. header ("Content-Type: image/{$im->getImageFormat()}");
  532. $data = $im->getImageBlob ();
  533. }catch(Exception $e) {
  534. $im = new Imagick(ROOT_DIR."apps/MISView/images/gerror.gif");
  535. header ("Content-Type: image/{$im->getImageFormat()}");
  536. $data = $im->getImageBlob ();
  537. }
  538. echo $data;
  539. }
  540. private function getImgAlarmstufeSrc($aktwert,$niedriger,$hoher,$positiv) {
  541. $aktwert = $this->convertValue($aktwert);
  542. $niedriger = $this->convertValue($niedriger);
  543. $hoher = $this->convertValue($hoher);
  544. $differenz = $hoher - $niedriger;
  545. $faktor = 8;
  546. if ($hoher == 0 || $niedriger == 0) {
  547. $hoher = $hoher + 0.001;
  548. $niedriger = $niedriger + 0.001;
  549. }
  550. if ($positiv=="J") {
  551. $basis = pow($faktor,(1/7));
  552. if (($aktwert-$niedriger) > ($differenz/$faktor)) {
  553. $exp = log10((($aktwert-$niedriger) / $differenz) * $faktor) / log10($basis);
  554. } elseif ($aktwert > $niedriger) {
  555. $exp = 0;
  556. } else {
  557. $exp = -1;
  558. }
  559. } else {
  560. $basis = pow((1/$faktor),(1/7));
  561. if (($hoher-$aktwert) > ($differenz/$faktor)) {
  562. $exp = log10(-(($aktwert-$hoher) / ($differenz * $faktor))) / log10($basis);
  563. $exp = ceil(13 - $exp);
  564. } elseif ($aktwert < $hoher) {
  565. $exp = -0;
  566. } else {
  567. $exp = -1;
  568. }
  569. }
  570. $stufe = floor($exp+0.001);
  571. if ($stufe < 7) {
  572. $stufe = 7 - $stufe;
  573. if ($stufe > 8) { $stufe = 8; }
  574. $farbe = "red";
  575. } else {
  576. $stufe = round($stufe - 6);
  577. if ($stufe > 7) { $stufe = 7; }
  578. $farbe = "green";
  579. }
  580. return substr($farbe,0,1) . $stufe;
  581. }
  582. private function scorecards($p_sectionID,$p_scorecardID=0) {
  583. $MISConfig = new MISConfig();
  584. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  585. $projectDOM->load($MISConfig->getConfigFile());
  586. $projectXpath = new DOMXpath($projectDOM);
  587. $publishImagePath = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  588. $dataXpath = $this->getScorecardFileDOM();
  589. $p_reportID = $projectXpath->query('/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID = "'.$p_sectionID.'"]')->item($p_scorecardID)->getAttribute("ID");
  590. $scorecardList = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID = "'.$p_sectionID.'"]');
  591. $tree = new Tree("contentMenu");
  592. for($i=0;$i<$scorecardList->length;$i++) {
  593. $report = $scorecardList->item($i);
  594. $reportName = $report->getElementsByTagName("Titel")->item(0)->nodeValue;
  595. $icon = new Icon("?&rc=MISView&rm=getScorecardStatusImg&ras[]=".$p_sectionID."&ras[]=".$i);
  596. $label = new Label($icon,$reportName);
  597. $temp = $projectXpath->query('/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID = "'.$p_sectionID.'"]')->item($i)->getAttribute("ID");
  598. $node = new TreeNode($label,$p_sectionID."_".$temp);
  599. $node->addEventListener(new EventListener("onclick",'Tree.select(this.parentNode.parentNode);CMgr.getMODEL().getMain("MISView","scorecards","'.$p_sectionID.'","'.$i.'");'));
  600. $tree->appendChild($node);
  601. if($i==0 && empty($p_scorecardID)) {
  602. $p_reportID = $temp;
  603. $active_reportName = $reportName;
  604. }
  605. if($i==$p_scorecardID) {
  606. $p_reportID = $temp;
  607. $active_reportName = $reportName;
  608. }
  609. }
  610. $scorecardLabel = new Label(new Icon('img/scorecard.png'),$this->_getI18N('scorecards'));
  611. $scorecardLink = '<div class="contentItem" style="background:#A3A3A3;">'.$scorecardLabel.'</div>';
  612. $reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./../../@ID='".$p_sectionID."' and ./Directory='".$this->getUsername()."\' and ./Active='J']");
  613. if($reportList->length > 0) {
  614. if($this->_getView() == "Client")
  615. $icon = new Icon("img/report.png");
  616. else
  617. $icon = new Icon("img/pdficon_small.gif");
  618. $reportLabel = new Label($icon,$this->_getI18N("reports"));
  619. $reportLink = '<div class="contentItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'reports\\\',\\\''.$p_sectionID.'\\\');">'.$reportLabel.'</div>';
  620. }else{
  621. $reportLink ='';
  622. }
  623. $dashboardList = $projectXpath->query("/Configuration/Dashboards/Dashboard[./@ID='".$p_sectionID."']/Reviews/Review[./../../@Directory='".$this->getUsername()."\']");
  624. if($dashboardList->length > 0) {
  625. $dashboardLabel = new Label(new Icon('img/dashboard.png'),$this->_getI18N('dashboards'));
  626. $dashboardLink = '<div class="contentItem" style="" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'dashboards\\\',\\\''.$p_sectionID.'\\\');">'.$dashboardLabel.'</div>';
  627. }else{
  628. $dashboardLink = '';
  629. }
  630. $sectionName = $projectXpath->query("/Configuration/Publishes/Publish[@ID='".$p_sectionID."']")->item(0)->getAttribute("Name");
  631. $tpl = $this->Template();
  632. $scorecard = $scorecardList->item($p_scorecardID);
  633. $tpl->assign("reportLink",'?&rc=MISView&rm=getScorecard&ras[]='.$projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID = '".$p_sectionID."']")->item($p_scorecardID)->getAttribute("ID"));
  634. $tpl->assign('sectionID',$p_sectionID);
  635. $tpl->assign('ID',$projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID = '".$p_sectionID."']")->item($p_scorecardID)->getAttribute("ID"));
  636. $tpl->assign('item',$p_scorecardID);
  637. $tpl->assign('Name',array('desc'=>$this->_getI18N('name'),'value'=>$scorecard->getElementsByTagname("Titel")->item(0)->nodeValue));
  638. $tpl->assign('Description',array('desc'=>$this->_getI18N('description'),'value'=>$scorecard->getElementsByTagName("Beschreibung")->item(0)->nodeValue));
  639. $tpl->assign('Status',array('desc'=>$this->_getI18N('status'),'value'=>'?&rc=MISView&rm=getScorecardDetailStatusImg&ras[]='.$p_sectionID.'&ras[]='.$p_scorecardID));
  640. $tpl->assign('Value',array('desc'=>$this->_getI18N('value'),'value'=>$this->numberFormat($scorecard->getElementsByTagName("Wert")->item(0)->nodeValue)));
  641. $tpl->assign('HighValue',array('desc'=>$this->_getI18N('highValue'),'value'=>$this->numberFormat($scorecard->getElementsByTagName("HoherWert")->item(0)->nodeValue)));
  642. $tpl->assign('LowValue',array('desc'=>$this->_getI18N('lowValue'),'value'=>$this->numberFormat($scorecard->getElementsByTagName("NiedrigerWert")->item(0)->nodeValue)));
  643. $tpl->assign('Tolerance',array('desc'=>$this->_getI18N('tolerance'),'value'=>$scorecard->getElementsByTagName("Toleranz")->item(0)->nodeValue));
  644. $tpl->assign('Weight',array('desc'=>$this->_getI18N('weight'),'value'=>$scorecard->getElementsByTagName("Gewichtung")->item(0)->nodeValue));
  645. $tpl->assign('PositiveValue',array('desc'=>$this->_getI18N('positiveValue'),'value'=>$scorecard->getElementsByTagName("HoherZielwert")->item(0)->nodeValue));
  646. $tpl->assign('Coordinates',array('desc'=>$this->_getI18N('coordinates'),'value'=>$scorecard->getElementsByTagName("Koordinaten")->item(0)->nodeValue));
  647. $tpl->assign('SAVE',$this->_getI18N("save"));
  648. $tpl->assign('OPEN_REPORT',$this->_getI18N("open_report"));
  649. $PPHauptampel = $projectXpath->query('/Configuration/Publishes/Publish/@Alert[./../@ID="'.$p_sectionID.'"]')->item(0)->nodeValue;
  650. if($PPHauptampel == "true") {
  651. $icon = new Icon("?&rc=MISView&rm=getSectionStatusImg&ras[]=".$p_sectionID);
  652. $eventListener = new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","scorecards","'.$p_sectionID.'");');
  653. $icon->addEventListener($eventListener);
  654. $newLabel = new Label($icon,str_replace("_"," ",$sectionName));
  655. }else{
  656. $newLabel = new Label(str_replace("_"," ",$sectionName));
  657. }
  658. $evalArr = array('CMgr.getMODEL().setLocationName(\''.addslashes($newLabel).'\')',
  659. 'CMgr.getMODEL().setMainHead(\''.addslashes(new Label(str_replace("_"," ",$scorecard->getElementsByTagname("Titel")->item(0)->nodeValue))).'\')',
  660. 'CMgr.getMODEL().setNavContainer(\''.addslashes($tree).'\')',
  661. 'CMgr.getMODEL().setMainToolbar(\''.$reportLink.$scorecardLink.$dashboardLink.'\');',
  662. 'Tree.setToUserView(Browser.getElementById("contentMenu"));',
  663. 'Tree.select(null,Browser.getElementById(\''.$p_sectionID."_".$p_reportID.'\'));',
  664. 'CMgr.getMODEL().setMainFootbar(\'\');');
  665. return array($tpl->fetch("scorecard.tpl"),implode(";",$evalArr));
  666. }
  667. public function saveScorecard($p_sectionID,$p_ID,$p_item,$p_highValue,$p_lowValue) {
  668. $MISConfig = new MISConfig();
  669. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  670. $projectDOM->load($MISConfig->getConfigFile());
  671. $projectXpath = new DOMXpath($projectDOM);
  672. $publishImagePath = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  673. $dataFilename = $this->getScorecardFilename();
  674. $dataDOM = new DOMDocument('1.0', 'iso-8859-1');
  675. $dataDOM->load($dataFilename);
  676. $dataXpath = new DOMXpath($dataDOM);
  677. $PR = $projectXpath->query('/Configuration/Scorecards/Scorecard/Reports/Report[./@ID = "'.$p_ID.'"]')->item(0);
  678. if($PR->getElementsByTagName("Format")->item(0)->nodeValue == "Prozent") {
  679. $p_lowValue = str_replace("%","",$p_lowValue);
  680. $p_highValue = str_replace("%","",$p_highValue);
  681. $MISConfig->setNodeValue("LowValue",number_reformat($p_lowValue, 2, ',',".")/100,$projectDOM,$PR);
  682. $MISConfig->setNodeValue("HighValue",number_reformat($p_highValue, 2, ',',".")/100,$projectDOM,$PR);
  683. $PRR = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID="'.$p_sectionID.'"]')->item($p_item);
  684. $MISConfig->setNodeValue("NiedrigerWert",str_replace(".",",",number_reformat($p_lowValue, 2, ',',"."))." %",$dataDOM,$PRR);
  685. $MISConfig->setNodeValue("HoherWert",str_replace(".",",",number_reformat($p_highValue, 2, ',',"."))." %",$dataDOM,$PRR);
  686. }
  687. if($PR->getElementsByTagName("Format")->item(0)->nodeValue == "Ganzzahlig") {
  688. $MISConfig->setNodeValue("LowValue",number_reformat($p_lowValue, 0, ',',"."),$projectDOM,$PR);
  689. $MISConfig->setNodeValue("HighValue",number_reformat($p_highValue, 0, ',',"."),$projectDOM,$PR);
  690. $PRR = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID="'.$p_sectionID.'"]')->item($p_item);
  691. $MISConfig->setNodeValue("NiedrigerWert",str_replace(".",",",number_reformat($p_lowValue, 0, ',',"."))."",$dataDOM,$PRR);
  692. $MISConfig->setNodeValue("HoherWert",str_replace(".",",",number_reformat($p_highValue, 0, ',',"."))."",$dataDOM,$PRR);
  693. }
  694. if($PR->getElementsByTagName("Format")->item(0)->nodeValue == "Zahl mit Trennz") {
  695. $MISConfig->setNodeValue("LowValue",number_reformat($p_lowValue, 2, ',',"."),$projectDOM,$PR);
  696. $MISConfig->setNodeValue("HighValue",number_reformat($p_highValue, 2, ',',"."),$projectDOM,$PR);
  697. $PRR = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID="'.$p_sectionID.'"]')->item($p_item);
  698. $MISConfig->setNodeValue("NiedrigerWert",str_replace(".",",",number_reformat($p_lowValue, 2, ',',"."))."",$dataDOM,$PRR);
  699. $MISConfig->setNodeValue("HoherWert",str_replace(".",",",number_reformat($p_highValue, 2, ',',"."))."",$dataDOM,$PRR);
  700. }
  701. if($PR->getElementsByTagName("Format")->item(0)->nodeValue == "Zahl ohne Trennz") {
  702. $MISConfig->setNodeValue("LowValue",number_reformat($p_lowValue, 0, ',',"."),$projectDOM,$PR);
  703. $MISConfig->setNodeValue("HighValue",number_reformat($p_highValue, 0, ',',"."),$projectDOM,$PR);
  704. $PRR = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID="'.$p_sectionID.'"]')->item($p_item);
  705. $MISConfig->setNodeValue("NiedrigerWert",str_replace(".",",",number_reformat($p_lowValue, 0, ',',"."))."",$dataDOM,$PRR);
  706. $MISConfig->setNodeValue("HoherWert",str_replace(".",",",number_reformat($p_highValue, 0, ',',"."))."",$dataDOM,$PRR);
  707. }
  708. if($PR->getElementsByTagName("Format")->item(0)->nodeValue == "W�hrung") {
  709. $MISConfig->setNodeValue("LowValue",number_reformat($p_lowValue, 2, ',',"."),$projectDOM,$PR);
  710. $MISConfig->setNodeValue("HighValue",number_reformat($p_highValue, 2, ',',"."),$projectDOM,$PR);
  711. $PRR = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[./../../@ID="'.$p_sectionID.'"]')->item($p_item);
  712. $MISConfig->setNodeValue("NiedrigerWert",str_replace(".",",",number_reformat($p_lowValue, 2, ',',"."))."",$dataDOM,$PRR);
  713. $MISConfig->setNodeValue("HoherWert",str_replace(".",",",number_reformat($p_highValue, 2, ',',"."))."",$dataDOM,$PRR);
  714. }
  715. $dataDOM->save($dataFilename);
  716. $projectDOM->save($MISConfig->getConfigFile());
  717. return array('CMgr.getMODEL().__construct();');
  718. }
  719. public function getScorecard($p_reportID) {
  720. if($this->getAuth()) {
  721. $p_args = func_get_args();
  722. $MISConfig = new MISConfig();
  723. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  724. $projectDOM->load($MISConfig->getConfigFile());
  725. $projectXpath = new DOMXpath($projectDOM);
  726. $report = $projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./@ID = '".$p_reportID."' and ./../../@Directory='".$this->getUsername()."\\']")->item(0);
  727. //$ansicht = $report->getElementsByTagName("Ansicht")->item(0)->nodeValue;
  728. $name = $report->getElementsByTagName("ReportFile")->item(0)->nodeValue;
  729. $reportPath = $projectXpath->query("/Configuration/General/ReportPath")->item(0)->nodeValue;
  730. $filename = $reportPath.$name.".ppr";
  731. $file_extension = strtolower(substr(strrchr($filename,"."),1));
  732. switch ($file_extension) {
  733. case "pdf": $ctype="application/pdf"; break;
  734. case "exe": $ctype="application/octet-stream"; break;
  735. case "zip": $ctype="application/zip"; break;
  736. case "doc": $ctype="application/msword"; break;
  737. case "xls": $ctype="application/vnd.ms-excel"; break;
  738. case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
  739. case "gif": $ctype="image/gif"; break;
  740. case "png": $ctype="image/png"; break;
  741. case "jpe": case "jpeg":
  742. case "jpg": $ctype="image/jpeg"; break;
  743. case "ppr": $ctype="application/powerplay"; break;
  744. default: $ctype="text";
  745. }
  746. if (!file_exists($filename)) {
  747. die("<script type='text/javascript'>alert('".$this->_getI18N("missingReportFile")."');window.history.back();</script>");
  748. }
  749. header("Pragma: public");
  750. header("Expires: 0");
  751. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  752. header("Cache-Control: private",false);
  753. header("Content-Type: $ctype");
  754. header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
  755. header("Content-Transfer-Encoding: binary");
  756. header("Content-Length: ".@filesize($filename));
  757. set_time_limit(0);
  758. readfile($filename) or die("File not found.");
  759. }else{
  760. print "<script type='text/javascript'>window.history.back();</script>";
  761. }
  762. }
  763. private function getPublishImagePath () {
  764. if (!isset($_SESSION["Config"]) && !isset($_SESSION["Config"]["General"]) && !isset($_SESSION["Config"]["General"]["PublishImagePath"])) {
  765. $MISConfig = new MISConfig();
  766. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  767. $projectDOM->load($MISConfig->getConfigFile());
  768. $projectXpath = new DOMXpath($projectDOM);
  769. $_SESSION["Config"]["General"]["PublishImagePath"] = $projectXpath->query('/Configuration/General/PublishImagePath')->item(0)->nodeValue;
  770. }
  771. return $_SESSION["Config"]["General"]["PublishImagePath"];
  772. }
  773. private function getConfigFilename () {
  774. $MISConfig = new MISConfig();
  775. return basename($MISConfig->getConfigFile(), ".xml");
  776. }
  777. private function getScorecardFilename() {
  778. $publishImagePath = $this->getPublishImagePath();
  779. $configFile = $this->getConfigFilename();
  780. $dataFilename = utf8_decode($publishImagePath . $configFile . "\\" . $this->getUsername() . ".xml");
  781. if (!file_exists($dataFilename)) {
  782. $dataFilename = utf8_decode($publishImagePath.$this->getUsername()."/data.xml"); // alte Variante
  783. }
  784. return $dataFilename;
  785. }
  786. private function getScorecardFileDOM () {
  787. $dataDOM = new DOMDocument('1.0', 'iso-8859-1');
  788. $dataDOM->load($this->getScorecardFilename());
  789. return new DOMXpath($dataDOM);
  790. }
  791. private function convertValue ($value) {
  792. if (preg_match("/[%,]/is", $value)) {
  793. $value = str_replace("%","",$value);
  794. $value = str_replace(".","",$value);
  795. $value = str_replace(",",".",$value);
  796. }
  797. return floatval($value);
  798. }
  799. private function numberFormat ($value) {
  800. if (preg_match("/[%,]/is", $value)) {
  801. return $value;
  802. }
  803. return number_format($value * 100, 2, ",", "") . " %";
  804. }
  805. public function getScorecardDetailStatusImg($p_sectionID,$p_scorecardID) {
  806. header("Content-Type: image/png\n\n");
  807. $dataXpath = $this->getScorecardFileDOM();
  808. $scorecard = $dataXpath->query('/Daten/child::*/Scorecards/Bericht[../../@ID = "'.$p_sectionID.'"]')->item($p_scorecardID);
  809. $anzeige = ImageCreateFromPNG (ROOT_DIR."apps/MISView/scDetail_".$scorecard->getElementsByTagName("HoherZielwert")->item(0)->nodeValue.".png");
  810. $pfeil = ImageCreateFromPNG (ROOT_DIR."apps/MISView/dart.png");
  811. $faktor = 8;
  812. $aktwert = $this->convertValue($scorecard->getElementsByTagName("Wert")->item(0)->nodeValue);
  813. $niedriger = $this->convertValue($scorecard->getElementsByTagName("NiedrigerWert")->item(0)->nodeValue);
  814. $hoher = $this->convertValue($scorecard->getElementsByTagName("HoherWert")->item(0)->nodeValue);
  815. $delta = $hoher - $niedriger;
  816. if ($scorecard->getElementsByTagName("HoherZielwert")->item(0)->nodeValue == "J") {
  817. if (($aktwert > $niedriger) && ($aktwert < $hoher)) {
  818. $pixel = ((($aktwert - $niedriger) * 135) / $delta) + 14;
  819. } elseif ($aktwert > $hoher) {
  820. $pixel = ((($aktwert - $hoher) * 129) / ($delta * $faktor)) + 155;
  821. } else {
  822. $pixel = 13 + ((($aktwert - $niedriger) * 13) / ($delta * 2));
  823. }
  824. } else {
  825. if (($aktwert > $niedriger) && ($aktwert < $hoher)) {
  826. $pixel = ((($aktwert - $niedriger) * 135) / $delta) + 140;
  827. } elseif ($aktwert > $hoher) {
  828. $pixel = ((($aktwert - $hoher) * 13) / ($delta * 2)) + 270;
  829. } else {
  830. $pixel = 140 + ((($aktwert - $niedriger) * 129) / ($delta * $faktor));
  831. }
  832. }
  833. $pixel = round($pixel);
  834. if ($pixel > 285) {
  835. $pixel = 285;
  836. }
  837. if ($pixel < 0) {
  838. $pixel = 0;
  839. }
  840. ImageCopy ($anzeige, $pfeil, $pixel, 8, 0, 0, 11, 24);
  841. $schwarz = ImageColorAllocate ($anzeige, 0, 0, 0);
  842. if ($scorecard->getElementsByTagName("HoherZielwert")->item(0)->nodeValue == "J") {
  843. $minpos = 27;
  844. $maxpos = 162;
  845. } else {
  846. $minpos = 133 - 6 * strlen($niedriger);
  847. $maxpos = 268 - 6 * strlen($hoher);
  848. }
  849. ImageString($anzeige, 2, $minpos, 32, $niedriger, $schwarz);
  850. ImageString($anzeige, 2, $maxpos, 32, $hoher, $schwarz);
  851. ImagePng($anzeige);
  852. }
  853. private function dashboards($p_sectionID,$p_reportID=null) {
  854. $MISConfig = new MISConfig();
  855. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  856. $projectDOM->load($MISConfig->getConfigFile());
  857. $projectXpath = new DOMXpath($projectDOM);
  858. $reportList = $projectXpath->query("/Configuration/Dashboards/Dashboard/Reviews/Review[./../../@Directory='".$this->getUsername()."\' and ./../../@ID='".$p_sectionID."']");
  859. $tree = new Tree("contentMenu");
  860. for($i=0;$i<$reportList->length;$i++){
  861. $report = $reportList->item($i);
  862. $reportName = $report->getElementsByTagName("Name")->item(0)->nodeValue;
  863. $reportDesc = $report->getElementsByTagName("Description")->item(0)->nodeValue;
  864. $icon = new Icon("img/dashboard.png");
  865. $label = new Label($icon,$reportName);
  866. $node = new TreeNode($label,$p_sectionID."_".$report->getAttribute("ID"));
  867. $node->addEventListener(new EventListener("onclick",'Tree.select(this.parentNode.parentNode);CMgr.getMODEL().getMain("MISView","dashboards","'.$p_sectionID.'","'.$report->getAttribute('ID').'");'));
  868. $tree->appendChild($node);
  869. if($i==0 && empty($p_reportID)) {
  870. $p_reportID = $report->getAttribute('ID');
  871. $active_reportName = $reportName;
  872. $active_reportDesc = $reportDesc;
  873. }
  874. if($p_reportID == $report->getAttribute('ID')) {
  875. //$label->active(true);
  876. $active_reportName = $reportName;
  877. $active_reportDesc = $reportDesc;
  878. }
  879. }
  880. if($this->_getView() == "Client")
  881. $icon = new Icon("img/report.png");
  882. else
  883. $icon = new Icon("img/pdficon_small.gif");
  884. $reportLabel = new Label($icon,$this->_getI18N("reports"));
  885. $scorecardLabel = new Label(new Icon('img/scorecard.png'),$this->_getI18N('scorecards'));
  886. $dashboardLabel = new Label(new Icon('img/dashboard.png'),$this->_getI18N('dashboards'));
  887. $reportList = $projectXpath->query("/Configuration/Publishes/Publish/Images/Image[./Directory='".$this->getUsername()."\' and ./../../@ID='".$p_sectionID."']");
  888. if($reportList->length > 0) {
  889. $reportLink = '<div class="contentItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'reports\\\',\\\''.$p_sectionID.'\\\');">'.$reportLabel.'</div>';
  890. }else{
  891. $reportLink = "";
  892. }
  893. $dashboardLink = '<div class="contentItem" style="background:#A3A3A3;">'.$dashboardLabel.'</div>';
  894. $scorecardList = $projectXpath->query("/Configuration/Scorecards/Scorecard/Reports/Report[./../../@ID='".$p_sectionID."' and ./../../@Directory='".$this->getUsername()."\\']");
  895. if($scorecardList->length > 0) {
  896. $scorecardLink = '<div class="contentItem" onclick="CMgr.getMODEL().getMain(\\\'MISView\\\',\\\'scorecards\\\',\\\''.$p_sectionID.'\\\');">'.$scorecardLabel.'</div>';
  897. } else {
  898. $scorecardLink = '';
  899. }
  900. $sectionName = $projectXpath->query("/Configuration/Publishes/Publish[@ID='".$p_sectionID."']")->item(0)->getAttribute("Name");
  901. $tpl = $this->Template();
  902. $tpl->assign('OPEN_REPORT',$this->_getI18N("open_report"));
  903. $tpl->assign('Description',array('desc'=>$this->_getI18N('description'),'value'=>$active_reportDesc));
  904. $tpl->assign("reportLink",'?&rc=MISView&rm=getDashboard&ras[]='.$p_reportID);
  905. $tpl->assign("imageLink",'img/MISView/excel.gif');
  906. $PPHauptampel = $projectXpath->query('/Configuration/Publishes/Publish/@Alert[./../@ID="'.$p_sectionID.'"]')->item(0)->nodeValue;
  907. if($PPHauptampel == "true") {
  908. $icon = new Icon("?&rc=MISView&rm=getSectionStatusImg&ras[]=".$p_sectionID);
  909. $eventListener = new EventListener("onclick",'CMgr.getMODEL().getMain("MISView","scorecards","'.$p_sectionID.'");');
  910. $icon->addEventListener($eventListener);
  911. $newLabel = new Label($icon,str_replace("_"," ",$sectionName));
  912. }else{
  913. $newLabel = new Label(str_replace("_"," ",$sectionName));
  914. }
  915. $evalArr = array('CMgr.getMODEL().setLocationName(\''.addslashes($newLabel).'\')',
  916. 'CMgr.getMODEL().setMainHead(\''.addslashes(new Label(str_replace("_"," ",$active_reportName))).'\')',
  917. 'CMgr.getMODEL().setNavContainer(\''.addslashes(''.$tree.'').'\')',
  918. 'Tree.setToUserView(Browser.getElementById("contentMenu"));',
  919. 'Tree.select(null,Browser.getElementById(\''.$p_sectionID."_".$p_reportID.'\'));',
  920. 'CMgr.getMODEL().setMainToolbar(\''.$reportLink.$scorecardLink.$dashboardLink.'\')',
  921. 'CMgr.getMODEL().setMainFootbar(\'\');');
  922. return array($tpl->fetch('dashboard.tpl'),implode(";",$evalArr));
  923. }
  924. public function getDashboard($p_reportID) {
  925. if($this->getAuth()) {
  926. $p_args = func_get_args();
  927. $MISConfig = new MISConfig();
  928. $projectDOM = new DOMDocument('1.0', 'iso-8859-1');
  929. $projectDOM->load($MISConfig->getConfigFile());
  930. $projectXpath = new DOMXpath($projectDOM);
  931. $report = $projectXpath->query("/Configuration/Dashboards/Dashboard/Reviews/Review[./@ID = '".$p_reportID."' and ./../../@Directory='".$this->getUsername()."\\']")->item(0);
  932. $name = $report->getElementsByTagName("ReportFile")->item(0)->nodeValue;
  933. $reportPath = $projectXpath->query("/Configuration/General/DashboardPath")->item(0)->nodeValue;
  934. $filename = $reportPath.$name.".xls";
  935. $file_extension = strtolower(substr(strrchr($filename,"."),1));
  936. switch ($file_extension) {
  937. case "pdf": $ctype="application/pdf"; break;
  938. case "exe": $ctype="application/octet-stream"; break;
  939. case "zip": $ctype="application/zip"; break;
  940. case "doc": $ctype="application/msword"; break;
  941. case "xls": $ctype="application/vnd.ms-excel"; break;
  942. case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
  943. case "gif": $ctype="image/gif"; break;
  944. case "png": $ctype="image/png"; break;
  945. case "jpe": case "jpeg":
  946. case "jpg": $ctype="image/jpeg"; break;
  947. case "ppr": $ctype="application/powerplay"; break;
  948. default: $ctype="text";
  949. }
  950. if (!file_exists($filename)) {
  951. die("<script type='text/javascript'>alert('".$this->_getI18N("missingReportFile")."');window.history.back();</script>");
  952. }
  953. header("Pragma: public");
  954. header("Expires: 0");
  955. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  956. header("Cache-Control: private",false);
  957. header("Content-Type: $ctype");
  958. header("Content-Disposition: attachment; filename=\"".basename($filename)."\";");
  959. header("Content-Transfer-Encoding: binary");
  960. header("Content-Length: ".@filesize($filename));
  961. set_time_limit(0);
  962. readfile($filename) or die("File not found.");
  963. }else{
  964. print "<script type='text/javascript'>window.history.back();</script>";
  965. }
  966. }
  967. }
  968. ?>