ProcesEditor.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  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('Response');
  8. Lib::loadClass('Api_WfsNs');
  9. class Route_UrlAction_ProcesEditor extends RouteBase {// TODO: UrlActionBase @see Route_UrlAction
  10. public function getResByParentAjaxAction() {
  11. try {
  12. $idParent = V::get('parent_id', 0, $_GET, 'int');
  13. if ($idParent <= 0) throw new Exception("ID is not set.");
  14. $sqlIdParent = DB::getPDO()->quote($idParent, PDO::PARAM_INT);
  15. $rows = DB::getPDO()->fetchAll("
  16. select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
  17. from CRM_LISTA_ZASOBOW g
  18. left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
  19. left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
  20. left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
  21. where g.`PARENT_ID` = {$sqlIdParent}
  22. ORDER BY g.SORT_PRIO ASC, g.ID DESC
  23. ");
  24. Response::sendJsonExit($rows);
  25. } catch (Exception $e) {
  26. UI::alert('danger', "Error: " . $e->getMessage());
  27. }
  28. }
  29. public function getResAjaxAction() {
  30. try {
  31. $word = V::get('word', '', $_GET);
  32. $filter = isset($_GET['filter']) ? (int)$_GET['filter'] : 0;
  33. $sqlFilter = "";
  34. if (!empty($word)) {
  35. $sqlWord = DB::getPDO()->quote("%{$word}%", PDO::PARAM_STR);
  36. if (is_numeric($word)) {
  37. $sqlFilter .= "AND (g.`DESC` LIKE {$sqlWord} OR g.`ID` LIKE {$sqlWord})" . "\n";
  38. } else {
  39. $sqlFilter .= "AND g.`DESC` LIKE {$sqlWord}" . "\n";
  40. }
  41. }
  42. switch ($filter) {
  43. case 2: $sqlFilter .= "AND (g.`TYPE` = 'TABELA' OR g.`TYPE` = 'KOMORKA')" . "\n"; break;
  44. case 1: $sqlFilter .= "AND (g.`TYPE` = 'STANOWISKO' OR g.`TYPE` = 'DZIAL' OR g.`TYPE` = 'PODMIOT')" . "\n"; break;
  45. }
  46. $sql = "
  47. select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
  48. from CRM_LISTA_ZASOBOW g
  49. left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
  50. left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
  51. left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
  52. where g.`A_STATUS` not in ('DELETED')
  53. and (p1.ID is null or p1.`A_STATUS` not in ('DELETED'))
  54. and (p2.ID is null or p2.`A_STATUS` not in ('DELETED'))
  55. and (p3.ID is null or p3.`A_STATUS` not in ('DELETED'))
  56. {$sqlFilter}
  57. limit 100
  58. ";
  59. DBG::_('DBG_SQL', '>1', 'sql', $sql, __CLASS__, __FUNCTION__, __LINE__);
  60. $rows = DB::getPDO()->fetchAll($sql);
  61. Response::sendJsonExit($rows);
  62. } catch (Exception $e) {
  63. UI::alert('danger', "Error: " . $e->getMessage());
  64. }
  65. }
  66. public function getSingleResAjaxReponseCallback() {
  67. if (!isset($_POST['data'])) throw new Exception("data is not set.");
  68. $ids = V::get('data', null, $_POST, 'uint_array');
  69. if (empty($ids)) throw new Exception("data is not correct.");
  70. $sqlWhereIdIn = array();
  71. foreach ($ids as $value) {
  72. $sqlWhereIdIn[] = DB::getPDO()->quote($value, PDO::PARAM_INT);
  73. }
  74. $sqlWhereIdIn = "g.ID in(" . implode(", ", $sqlWhereIdIn) . ")";
  75. $rows = DB::getPDO()->fetchAll("
  76. select g.*, p1.ID as p1_ID, p1.DESC as p1_DESC,p2.ID as p2_ID, p2.DESC as p2_DESC, p3.ID as p3_ID, p3.DESC as p3_DESC
  77. from CRM_LISTA_ZASOBOW g
  78. left join CRM_LISTA_ZASOBOW p1 on(p1.ID = g.PARENT_ID)
  79. left join CRM_LISTA_ZASOBOW p2 on(p2.ID = p1.PARENT_ID)
  80. left join CRM_LISTA_ZASOBOW p3 on(p3.ID = p2.PARENT_ID)
  81. where {$sqlWhereIdIn}
  82. ");
  83. return $rows;
  84. }
  85. public function getSingleResAjaxAction() {
  86. Response::sendTryCatchJson(array($this, 'getSingleResAjaxReponseCallback'));
  87. }
  88. public function handleAuth() {
  89. if (!User::logged()) {
  90. //throw new HttpException('Unauthorized', 401);
  91. User::authByRequest();
  92. }
  93. // zapisać jsona w sesji
  94. }
  95. public function defaultAction() {
  96. UI::gora();
  97. UI::menu();
  98. try {
  99. $id = V::get('id', 0, $_REQUEST, 'int');
  100. if ($id <= 0) throw new Exception("Wrong ID");
  101. UI::setTitleJsTag("Edytor Procesu {{$id}}");
  102. $this->showEditor($id);
  103. } catch (Exception $e) {
  104. UI::alert('danger', "Error: " . $e->getMessage());
  105. }
  106. UI::dol();
  107. }
  108. public function showEditor($id) {
  109. echo '<link rel="stylesheet" type="text/css" href="static/sweetalert2.min.css">';
  110. $this->showEditorCss();
  111. ?>
  112. <div id="wrapper" class="toggled" style="overflow:hidden">
  113. <div id='sidebar-wrapper'><div id="side"></div></div>
  114. <div id='page-content-wrapper'>
  115. <div id="left">
  116. <button class='lButton btn btn-default' id="btnZasoby" style="top:150px"><p>Zasoby</p></button>
  117. <button class='lButton btn btn-default' style="top:315px" id="btnProcesy"><p>Procesy</p></button>
  118. <!--<button class='lButton btn btn-default' id="btnPhotos" style="top:480px"><p>Zdjęcia</p></button>-->
  119. </div>
  120. <div class=col-md-12 ><a id=toggleMenu style=cursor:pointer;>Przełącz menu</a></div>
  121. <div id="main" style="margin-left:40px">
  122. <center>Uruchamianie aplikacji.</center>
  123. </div>
  124. </div>
  125. </div>
  126. <script>var BASE_URL = '<?= Request::getPathUri(); ?>';var BASE_WFS_URL = '<?= Api_WfsNs::getBaseWfsUri(); ?>';var mainProces_id = <?= $id; ?>;</script>
  127. <script src="static/sweetalert2.min.js"></script>
  128. <script src="static/procesEditor.js?v=19<?php if (V::get('DBG', '', $_GET)) echo "&_time=" . time(); ?>"></script>
  129. <?php
  130. }
  131. public function showEditorCss() {
  132. ?>
  133. <style type="text/css">
  134. .activeDrop{
  135. background-color:#f1f1f1;
  136. }
  137. .treeInfo{
  138. overflow: hidden;
  139. text-align: right;
  140. display:inline-block;
  141. color:grey;
  142. font-size:0.9em;
  143. white-space: nowrap;
  144. max-width: 90%;
  145. }
  146. .treeInfo div{
  147. float:right;
  148. }
  149. #left{
  150. padding:0px;
  151. }
  152. .sDescAdd, .hDescAdd, .step{
  153. padding-left:10px;
  154. }
  155. #clipboard{
  156. color:black;
  157. }
  158. .lButton{
  159. -webkit-transform: translate3d(0,0,0);
  160. position:fixed;
  161. padding:0px;
  162. outline:none;
  163. margin:0px;
  164. width: 40px;
  165. height:160px;
  166. z-index:30;
  167. border-top-left-radius: 0px;
  168. border-bottom-left-radius: 0px;
  169. }
  170. .lButton p
  171. {
  172. margin-bottom:-50px;
  173. -moz-transform:rotate(-90deg);
  174. -ms-transform:rotate(-90deg);
  175. -o-transform:rotate(-90deg);
  176. -webkit-transform:rotate(-90deg);
  177. }
  178. .ico {
  179. float: right;
  180. margin-top: 10px;
  181. margin-left: 5px;
  182. cursor: pointer;
  183. }
  184. #wrapper {
  185. padding-left: 0;
  186. -webkit-transition: all 0.5s ease;
  187. -moz-transition: all 0.5s ease;
  188. -o-transition: all 0.5s ease;
  189. transition: all 0.5s ease;
  190. }
  191. #wrapper.toggled {
  192. padding-left: 600px;
  193. }
  194. #wrapper #left { width:40px }
  195. #wrapper #left .lButton {
  196. width:40px;
  197. -webkit-transition: all 0.5s ease;
  198. -moz-transition: all 0.5s ease;
  199. -o-transition: all 0.5s ease;
  200. transition: all 0.5s ease;
  201. }
  202. #wrapper.toggled #left .lButton { width:39px }
  203. #side {
  204. padding: 15px;
  205. height: 100%;
  206. border-top-style:solid;
  207. border-top-width:1px;
  208. border-right-style: solid;
  209. border-color: #A61C2E;
  210. border-width: 2px;
  211. }
  212. ul {
  213. list-style: none;
  214. }
  215. #advCon{
  216. width:870px;
  217. min-width:100%;
  218. }
  219. .detailsTable{
  220. color:grey;
  221. float:left;
  222. display:inline;
  223. text-align:center;
  224. margin-left:5px;
  225. height:23px;
  226. }
  227. .tree{
  228. color:grey;
  229. text-overflow:ellipsis;
  230. white-space:nowrap;
  231. overflow:hidden;
  232. display:block;
  233. cursor:pointer;
  234. }
  235. .detailsTable2{
  236. color:grey;
  237. display:block;
  238. font-size:0.8em;
  239. text-align:left;
  240. margin-left:5px;
  241. height:23px;
  242. }
  243. .textTable{
  244. float:left;
  245. width:200px;
  246. text-overflow:ellipsis;
  247. white-space:nowrap;
  248. overflow:hidden;
  249. cursor:pointer;
  250. display:inline-block;
  251. }
  252. #dropPic{
  253. height:250px;
  254. border-radius:5px;
  255. border-style:solid;
  256. border-color:#ededed;
  257. background-color: #fbfbfb;
  258. border-width:1px;
  259. }
  260. /* skin.css Style*/
  261. #inp {
  262. height: 100px;
  263. border-width: 2px;
  264. margin-bottom: 0px;
  265. color: #ccc;
  266. border-style: dashed;
  267. border-color: #ccc;
  268. line-height: 100px;
  269. text-align: center;
  270. display:block;
  271. width:100%;
  272. }
  273. .upload-drop-zone.drop {
  274. color: #222;
  275. border-color: #222;
  276. }
  277. .anim-refresh {
  278. -animation: spin .7s infinite linear;
  279. -webkit-animation: spin2 .7s infinite linear;
  280. }
  281. @-webkit-keyframes spin2 {
  282. from { -webkit-transform: rotate(0deg);}
  283. to { -webkit-transform: rotate(360deg);}
  284. }
  285. @keyframes spin {
  286. from { transform: scale(1) rotate(0deg);}
  287. to { transform: scale(1) rotate(360deg);}
  288. }
  289. .list-group-item{
  290. cursor:pointer;
  291. }
  292. .list-group-item:hover{
  293. background-color:#eeeeee;
  294. }
  295. .list-group-item:hover .glyphicon{
  296. opacity:1 !important;
  297. }
  298. .textTable2{
  299. float:left;
  300. width:230px;
  301. text-overflow:ellipsis;
  302. white-space:nowrap;
  303. overflow:hidden;
  304. cursor:pointer;
  305. display:inline-block;
  306. }
  307. .pbody{
  308. padding-left:20px;
  309. padding-right:20px;
  310. text-align:justify;
  311. }
  312. .singleAdv{
  313. float:left;
  314. height:100%;
  315. width:290px;
  316. }
  317. #side #adv{
  318. }
  319. #side #ulcon, #side #ulproc, #side #adv {
  320. background-color: white;
  321. overflow-y: scroll;
  322. height: 70% !important;
  323. border-style:solid;
  324. border-width:1px;
  325. border-color:grey;
  326. margin-top: 10px;
  327. border-radius: 5px;
  328. padding-bottom: 10px;
  329. border-style: solid;
  330. border-width: 1px;
  331. border-color: #e5e5e5;
  332. color: black;
  333. padding-left: 0px;
  334. font-family: tahoma;
  335. font-size: 13px;
  336. }
  337. .selectedAdv{
  338. background-color:#e4e4e4;
  339. }
  340. .selectedAdv:hover{
  341. background-color:#e4e4e4;
  342. }
  343. #side .dragStyle {
  344. padding-left: 8px;
  345. padding-top: 4px;
  346. padding-bottom: 4px;
  347. border-bottom-style: dotted;
  348. border-width: 1px;
  349. cursor: pointer;
  350. border-color: #e5e5e5;
  351. background-color: white;
  352. display: block;
  353. }
  354. #side .showMore {
  355. padding-left: 2px;
  356. padding-top: 4px;
  357. padding-bottom: 4px;
  358. border-width: 1px;
  359. border-color: #e5e5e5;
  360. }
  361. #side .gIco {
  362. padding-left: 2px;
  363. padding-top: 4px;
  364. padding-bottom: 4px;
  365. border-width: 1px;
  366. border-color: #e5e5e5;
  367. cursor: pointer;
  368. }
  369. #side .hov,
  370. #side .grad {
  371. cursor: pointer;
  372. }
  373. #side .click {
  374. float: left;
  375. color: grey;
  376. font-size: 10px;
  377. cursor: pointer;
  378. }
  379. .delRes,
  380. .btnEdit,
  381. .hdesc,
  382. .sdesc {
  383. cursor: pointer;
  384. }
  385. .goto{
  386. padding-left:10px;
  387. }
  388. #side .tabelaName {
  389. white-space: nowrap;
  390. margin-right: 10px;
  391. overflow: hidden;
  392. width: 350px;
  393. float: left;
  394. text-overflow: ellipsis;
  395. display: block;
  396. cursor: pointer;
  397. }
  398. #side .hov:hover {
  399. background-color: #e5e5e5;
  400. }
  401. #sidebar-wrapper {
  402. position: fixed;
  403. left: 600px;
  404. width: 0;
  405. height: 100%;
  406. color: white;
  407. margin-left: -600px;
  408. overflow-y: auto;
  409. background: #222;
  410. -webkit-transition: all 0.5s ease;
  411. -moz-transition: all 0.5s ease;
  412. -o-transition: all 0.5s ease;
  413. transition: all 0.5s ease;
  414. }
  415. #wrapper.toggled #sidebar-wrapper {
  416. width: 600px;
  417. }
  418. #page-content-wrapper {
  419. width: 100%;
  420. position: absolute;
  421. z-index:0 !important;
  422. padding-top: 15px;
  423. padding-left:0px !important;
  424. }
  425. #wrapper.toggled #page-content-wrapper {
  426. position: absolute;
  427. margin-right: -600px;
  428. }
  429. #wrapper {
  430. padding-left: 600px;
  431. }
  432. #wrapper.toggled {
  433. padding-left: 0 !important;
  434. }
  435. #sidebar-wrapper {
  436. width: 600px;
  437. }
  438. #wrapper.toggled #sidebar-wrapper {
  439. width: 0 !important;
  440. }
  441. #page-content-wrapper {
  442. padding: 20px;
  443. position: relative;
  444. }
  445. #wrapper.toggled #page-content-wrapper {
  446. position: relative;
  447. margin-right: 0;
  448. }
  449. .drop {
  450. margin-top: 10px;
  451. }
  452. .sdesc{
  453. margin-bottom:10px;
  454. }
  455. .hdesc textarea,
  456. .sdesc textarea {
  457. min-width: 100%;
  458. padding: 10px;
  459. }
  460. .step,
  461. .sDescAdd {
  462. margin-top:5px;
  463. color: grey;
  464. cursor: pointer;
  465. display:block;
  466. font-size:10px;
  467. }
  468. .sDescAdd:hover{
  469. color:black;
  470. }
  471. .goto{
  472. }
  473. .editGoto{
  474. cursor:pointer;
  475. }
  476. .sdesc {
  477. display: block;
  478. }
  479. .hDescAdd {
  480. cursor: pointer;
  481. }
  482. #saveBtn {} .changable {
  483. padding-left: 10px;
  484. }
  485. .changed {
  486. border-left-style: solid;
  487. border-width: 3px;
  488. border-color: #ffc107;
  489. padding-left: 7px;
  490. }
  491. .del {
  492. }
  493. .liRes:hover{
  494. background-color:#fafafa;
  495. }
  496. span.glyphicon{
  497. opacity:0.6;
  498. cursor:pointer;
  499. margin-left:3px;
  500. }
  501. span.glyphicon:hover{
  502. opacity:1;
  503. }
  504. .delRes:hover{
  505. color:red;
  506. }
  507. .delGoto:hover{
  508. color:red;
  509. cursor:pointer;
  510. }
  511. .del:hover{
  512. color:red;
  513. }
  514. .ids {
  515. color: grey;
  516. font-size: 12px;
  517. }
  518. .more {
  519. margin-left: 15px;
  520. }
  521. .resSelected {
  522. background-color: #d3d3d3;
  523. }
  524. </style>
  525. <?php
  526. }
  527. }