ProcesEditor.php 12 KB

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