ProcesView.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <?php
  2. Lib::loadClass('RouteBase');
  3. Lib::loadClass('ProcesHelper');
  4. Lib::loadClass('Config');
  5. Lib::loadClass('UI');
  6. Lib::loadClass('Request');
  7. Lib::loadClass('ProcesHelper');
  8. Lib::loadClass('Response');
  9. class Route_UrlAction_ProcesView extends RouteBase {// TODO: UrlActionBase @see Route_UrlAction
  10. public function getAllAjaxAction(){
  11. try {
  12. $rows = DB::getPDO()->fetchAll("
  13. select `ID`, `PARENT_ID`, `DESC`, `OPIS`, `TYPE`
  14. from CRM_PROCES
  15. WHERE `PARENT_ID`>=0
  16. AND `A_STATUS` <> 'DELETED'
  17. AND `ID` <> `PARENT_ID`
  18. ORDER BY `SORT_PRIO` ASC, `ID` DESC
  19. ");
  20. $state = array();
  21. foreach($rows as $key => $value){
  22. $id = intval($value["ID"]);
  23. $parent_id = intval($value["PARENT_ID"]);
  24. $state[$id]["ID"] = $value["ID"];
  25. $state[$id]["DESC"] = $value["DESC"];
  26. $state[$id]["OPIS"] = $value["OPIS"];
  27. $state[$id]["TYPE"] = $value["TYPE"];
  28. if(intval($value["PARENT_ID"]) != 0)
  29. $state[$id]["PARENT_ID"] = intval($value["PARENT_ID"]);
  30. else
  31. $state[$id]["PARENT_ID"] = "#";
  32. $state[$id]["active"] = false;
  33. $state[$id]["details"] = false;
  34. if(!isset($state[$id]["childs"]))
  35. $state[$id]["childs"] = array();
  36. if(!isset($state[$value["PARENT_ID"]])){
  37. $state[$parent_id]["active"] = false;
  38. $state[$parent_id]["details"] = false;
  39. $state[$parent_id]["childs"] = array();
  40. }
  41. $temp = array();
  42. $temp["ID"] = $id;
  43. array_push($state[$parent_id]["childs"], $temp);
  44. }
  45. //print_r($state);
  46. Response::sendJsonExit($state);
  47. } catch (Exception $e) {
  48. UI::alert('danger', "Error: " . $e->getMessage());
  49. }
  50. }
  51. public function handleAuth() {
  52. if (!User::logged()) {
  53. //throw new HttpException('Unauthorized', 401);
  54. User::authByRequest();
  55. }
  56. // zapisać jsona w sesji
  57. }
  58. public function defaultAction() {
  59. UI::gora();
  60. UI::menu();
  61. try {
  62. $this->showView();
  63. } catch (Exception $e) {
  64. UI::alert('danger', "Error: " . $e->getMessage());
  65. }
  66. UI::dol();
  67. }
  68. public function showView() {
  69. echo "<div class=container-fluid>";
  70. echo "<div class=row>";
  71. echo "<div class=col-md-12 style=padding-top:15px;><a id=toggleMenu style=cursor:pointer;>Przełącz menu</a><a style=float:right;cursor:pointer; id=toggleView>Przełącz na widok drzewa</a></div>";
  72. echo "<div class=col-md-12 id=view>";
  73. echo "";
  74. echo "</div>";
  75. echo "</div>";
  76. echo "<script>var BASE_URL = '".Request::getPathUri()."';var ProcesTableId=".ProcesHelper::getZasobTableID('CRM_PROCES').";</script>";
  77. echo '<script src="static/sweetalert2.min.js"></script>';
  78. echo '<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">';
  79. echo '<link rel="stylesheet" href="static/jstree-theme/style.min.css" />';
  80. echo '<script src="static/jstree.min.js"></script>';
  81. echo '<script src="static/procesView.js?v=1"></script>';
  82. $this->showViewCss();
  83. }
  84. public function showViewCss() {
  85. ?>
  86. <style type="text/css">
  87. .singleAdv{
  88. float:left;
  89. padding-bottom:20px;
  90. display:block;
  91. overflow-y:scroll;
  92. cursor:pointer;
  93. width:460px;
  94. }
  95. #procCon{
  96. display:block;
  97. height:100%;
  98. }
  99. .textTable{
  100. float:left;
  101. width:400px;
  102. overflow:hidden;
  103. display:inline-block;
  104. }
  105. .glyph{
  106. opacity:0.4;
  107. }
  108. .glyph:hover{
  109. opacity:1;
  110. }
  111. .detailsTable{
  112. color:black;
  113. display:inline-block;
  114. padding:4px;
  115. padding-top:1px;
  116. padding-bottom:1px;
  117. border-width:1px;
  118. border-color:grey;
  119. }
  120. .detailsTable2{
  121. color:black;
  122. display:inline-block;
  123. padding:3px;
  124. padding-top:0px;
  125. padding-bottom:0px;
  126. border-width:1px;
  127. border-color:grey;
  128. height:24px; line-height:22px; border:1px solid #fff;
  129. }
  130. #ulproc{
  131. background-color: white;
  132. overflow-y: scroll;
  133. height: 70% !important;
  134. border-style:solid;
  135. border-width:1px;
  136. border-color:grey;
  137. margin-top: 10px;
  138. border-radius: 5px;
  139. padding-bottom: 10px;
  140. border-style: solid;
  141. border-width: 1px;
  142. border-color: #e5e5e5;
  143. color: black;
  144. padding-left: 0px;
  145. font-family: tahoma;
  146. font-size: 13px;
  147. }
  148. #tree { overflow:hidden; border:1px solid #ddd; }
  149. </style>
  150. <?php
  151. }
  152. }