ProcesView.php 7.6 KB

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