ProcesView.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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`, `IF_TRUE_GOTO`, `IF_TRUE_GOTO_FLAG`, `SORT_PRIO`
  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. $state[$id]["IF_TRUE_GOTO"] = intval($value["IF_TRUE_GOTO"]);
  29. $state[$id]["IF_TRUE_GOTO_FLAG"] = $value["IF_TRUE_GOTO_FLAG"];
  30. $state[$id]["PARENT_ID"] = (intval($value["PARENT_ID"]) != 0) ? intval($value["PARENT_ID"]) : "#";
  31. $state[$id]["SORT_PRIO"] = $value["SORT_PRIO"];
  32. if (!isset($state[$id]["childs"])) $state[$id]["childs"] = array();
  33. if (!isset($state[$parent_id]["childs"])) $state[$parent_id]["childs"] = array();
  34. $temp = array();
  35. $temp["ID"] = $id;
  36. array_push($state[$parent_id]["childs"], $temp);
  37. }
  38. Response::sendJsonExit($state);
  39. } catch (Exception $e) {
  40. UI::alert('danger', "Error: " . $e->getMessage());
  41. }
  42. }
  43. public function getConnectedProcAjaxAction(){
  44. try {
  45. $id = V::get('id', 0, $_REQUEST, 'int');
  46. $rows = DB::getPDO()->fetchAll("
  47. SELECT * FROM `CRM_WSKAZNIK` WHERE `ID_ZASOB` = $id AND `A_STATUS` <> 'DELETED'
  48. ");
  49. $state = array();
  50. $state["wsk"] = array();
  51. foreach($rows as $key => $value){
  52. $temp["ID"] = $value["ID"];
  53. $temp["ID_PROCES"] = $value["ID_PROCES"];
  54. $temp["ID_ZASOB"] = $value["ID_ZASOB"];
  55. array_push($state["wsk"], $temp);
  56. }
  57. Response::sendJsonExit($state);
  58. } catch (Exception $e) {
  59. UI::alert('danger', "Error: " . $e->getMessage());
  60. }
  61. }
  62. public function getDetailsAjaxAction(){
  63. try {
  64. $id = V::get('id', 0, $_REQUEST, 'int');
  65. $rows = DB::getPDO()->fetchAll("
  66. SELECT * FROM `CRM_WSKAZNIK` WHERE `ID_PROCES` = {$id} AND `A_STATUS` <> 'DELETED'
  67. ");
  68. $state = array();
  69. $state["wsk"] = array();
  70. foreach($rows as $key => $value){
  71. $temp["ID"] = $value["ID"];
  72. $temp["ID_PROCES"] = $value["ID_PROCES"];
  73. $temp["ID_ZASOB"] = $value["ID_ZASOB"];
  74. array_push($state["wsk"], $temp);
  75. }
  76. $count = DB::getPDO()->fetchAll("
  77. SELECT count(*) as imgCount FROM `CRM_IMAGE` WHERE `REMOTE_ID` = {$id} AND `REMOTE_TABLE` = 'CRM_PROCES'
  78. ");
  79. $state["IMG_COUNT"] = $count[0]["imgCount"];
  80. Response::sendJsonExit($state);
  81. } catch (Exception $e) {
  82. UI::alert('danger', "Error: " . $e->getMessage());
  83. }
  84. }
  85. public function getAllResAjaxAction(){
  86. try {
  87. $rows = DB::getPDO()->fetchAll("
  88. select `ID`, `PARENT_ID`, `DESC`, `OPIS`, `ALIAS_ID`, `TYPE`
  89. from CRM_LISTA_ZASOBOW
  90. WHERE `PARENT_ID`>=0
  91. AND `A_STATUS` <> 'DELETED'
  92. AND `ID` <> `PARENT_ID`
  93. ORDER BY `SORT_PRIO` ASC, `ID` DESC
  94. ");
  95. $state = array();
  96. foreach ($rows as $key => $value) {
  97. $id = intval($value["ID"]);
  98. $parent_id = intval($value["PARENT_ID"]);
  99. $state[$id]["ALIAS_ID"] = intval($value["ALIAS_ID"]);
  100. $state[$id]["ID"] = $value["ID"];
  101. $state[$id]["DESC"] = $value["DESC"];
  102. $state[$id]["TYPE"] = $value["TYPE"];
  103. $state[$id]["OPIS"] = $value["OPIS"];
  104. $state[$id]["PARENT_ID"] = (intval($value["PARENT_ID"]) != 0) ? intval($value["PARENT_ID"]) : "#";
  105. if (!isset($state[$id]["childs"])) $state[$id]["childs"] = array();
  106. if (!isset($state[$value["PARENT_ID"]])) $state[$parent_id]["childs"] = array();
  107. $temp = array();
  108. $temp["ID"] = $id;
  109. array_push($state[$parent_id]["childs"], $temp);
  110. }
  111. Response::sendJsonExit($state);
  112. } catch (Exception $e) {
  113. UI::alert('danger', "Error: " . $e->getMessage());
  114. }
  115. }
  116. public function handleAuth() {
  117. if (!User::logged()) User::authByRequest();
  118. }
  119. public function defaultAction() {
  120. UI::gora();
  121. UI::menu();
  122. try {
  123. $start_id = V::get('START_ID', 0, $_REQUEST, 'int');
  124. $type = V::get('TYPE', '', $_REQUEST, 'string');
  125. $type = ($type == "zasoby") ? "res" : "childs";
  126. $this->showView($start_id, $type);
  127. } catch (Exception $e) {
  128. UI::alert('danger', "Error: " . $e->getMessage());
  129. }
  130. UI::dol();
  131. }
  132. public function showView($start_id, $type) {
  133. echo "<div class=container-fluid>";
  134. echo "<div class=row>";
  135. 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 widok</a></div>";
  136. echo "<div class=col-md-12 id=view>";
  137. echo "";
  138. echo "</div>";
  139. echo "</div>";
  140. echo "<script>var TYPE = '".$type."';var START_ID = '".$start_id."';var BASE_URL = '".Request::getPathUri()."';var ProcesTableId=".ProcesHelper::getZasobTableID('CRM_PROCES').";</script>";
  141. echo '<script src="static/sweetalert2.min.js"></script>';
  142. echo '<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">';
  143. echo '<link rel="stylesheet" href="static/jstree-theme/style.min.css" />';
  144. echo '<script src="static/jstree.min.js"></script>';
  145. echo '<script src="static/procesView.js?v=2'.((V::get('DBG', '', $_GET)) ? time() : '').'"></script>';// TODO: static v, only in DBG
  146. $this->showViewCss();
  147. }
  148. public function showViewCss() {
  149. ?>
  150. <style type="text/css">
  151. .singleAdv{
  152. float:left;
  153. padding-bottom:20px;
  154. display:block;
  155. width:460px;
  156. }
  157. .toggleRoute{
  158. text-align:center;
  159. margin-top:10px;
  160. padding:5px;
  161. background-color:#ededed;
  162. opacity:0.6;
  163. cursor:pointer;
  164. }
  165. .route{
  166. border-style:solid;
  167. border-width:2px;
  168. padding:5px;
  169. display:none;
  170. border-radius:2px;
  171. border-color:#ededed;
  172. }
  173. .toggleRoute:hover{
  174. opacity:1;
  175. }
  176. .goto{
  177. }
  178. .singleAdvList{
  179. overflow-y:scroll;
  180. }
  181. .gotoInfo{
  182. background-color:#e5a100;
  183. color:white;
  184. padding:10px;
  185. margin-left:50px;
  186. font-size:1.0em;
  187. }
  188. .gotoWay{
  189. background-color:#ededed;
  190. padding:10px;
  191. }
  192. .normalChilds{
  193. background-color: #ededed;
  194. }
  195. #procCon{
  196. display:block;
  197. height:100%;
  198. }
  199. .textTable{
  200. float:left;
  201. width:400px;
  202. overflow:hidden;
  203. display:inline-block;
  204. }
  205. .glyph{
  206. opacity:0.4;
  207. }
  208. .glyph:hover{
  209. opacity:1;
  210. }
  211. .detailsTable{
  212. color:black;
  213. display:inline-block;
  214. padding:4px;
  215. padding-top:1px;
  216. padding-bottom:1px;
  217. border-width:1px;
  218. border-color:grey;
  219. }
  220. .detailsTable2{
  221. color:black;
  222. display:inline-block;
  223. padding:3px;
  224. padding-top:0px;
  225. padding-bottom:0px;
  226. border-width:1px;
  227. border-color:grey;
  228. height:24px; line-height:22px; border:1px solid #fff;
  229. }
  230. #ulproc{
  231. background-color: white;
  232. overflow-y: scroll;
  233. height: 70% !important;
  234. border-style:solid;
  235. border-width:1px;
  236. border-color:grey;
  237. margin-top: 10px;
  238. border-radius: 5px;
  239. padding-bottom: 10px;
  240. border-style: solid;
  241. border-width: 1px;
  242. border-color: #e5e5e5;
  243. color: black;
  244. padding-left: 0px;
  245. font-family: tahoma;
  246. font-size: 13px;
  247. }
  248. #tree { overflow:hidden; border:1px solid #ddd; }
  249. </style>
  250. <?php
  251. }
  252. }