ProcesEditor.php 12 KB

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