ProcesEditor.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  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 id="main" style="margin-left:40px">
  120. <center>Uruchamianie aplikacji.</center>
  121. </div>
  122. </div>
  123. </div>
  124. <script>var BASE_URL = '<?= Request::getPathUri(); ?>';var mainProces_id = <?= $id; ?>;</script>
  125. <script src="static/sweetalert2.min.js"></script>
  126. <script src="static/procesEditor.js?v=17<?php if (V::get('DBG', '', $_GET)) echo "&_time=" . time(); ?>"></script>
  127. <?php
  128. }
  129. public function showEditorCss() {
  130. ?>
  131. <style type="text/css">
  132. .activeDrop{
  133. background-color:#f1f1f1;
  134. }
  135. .treeInfo{
  136. overflow: hidden;
  137. text-align: right;
  138. display:inline-block;
  139. color:grey;
  140. font-size:0.9em;
  141. white-space: nowrap;
  142. max-width: 90%;
  143. }
  144. .treeInfo div{
  145. float:right;
  146. }
  147. #left{
  148. padding:0px;
  149. }
  150. .sDescAdd, .hDescAdd, .step{
  151. padding-left:10px;
  152. }
  153. .lButton{
  154. -webkit-transform: translate3d(0,0,0);
  155. position:fixed;
  156. padding:0px;
  157. outline:none;
  158. margin:0px;
  159. width: 40px;
  160. height:160px;
  161. z-index:30;
  162. border-top-left-radius: 0px;
  163. border-bottom-left-radius: 0px;
  164. }
  165. .lButton p
  166. {
  167. margin-bottom:-50px;
  168. -moz-transform:rotate(-90deg);
  169. -ms-transform:rotate(-90deg);
  170. -o-transform:rotate(-90deg);
  171. -webkit-transform:rotate(-90deg);
  172. }
  173. .ico {
  174. float: right;
  175. margin-top: 10px;
  176. margin-left: 5px;
  177. cursor: pointer;
  178. }
  179. #wrapper {
  180. padding-left: 0;
  181. -webkit-transition: all 0.5s ease;
  182. -moz-transition: all 0.5s ease;
  183. -o-transition: all 0.5s ease;
  184. transition: all 0.5s ease;
  185. }
  186. #wrapper.toggled {
  187. padding-left: 600px;
  188. }
  189. #wrapper #left { width:40px }
  190. #wrapper #left .lButton {
  191. width:40px;
  192. -webkit-transition: all 0.5s ease;
  193. -moz-transition: all 0.5s ease;
  194. -o-transition: all 0.5s ease;
  195. transition: all 0.5s ease;
  196. }
  197. #wrapper.toggled #left .lButton { width:39px }
  198. #side {
  199. padding: 15px;
  200. height: 100%;
  201. border-top-style:solid;
  202. border-top-width:1px;
  203. border-right-style: solid;
  204. border-color: #A61C2E;
  205. border-width: 2px;
  206. }
  207. ul {
  208. list-style: none;
  209. }
  210. #advCon{
  211. width:870px;
  212. min-width:100%;
  213. }
  214. .detailsTable{
  215. color:grey;
  216. float:left;
  217. display:inline;
  218. text-align:center;
  219. margin-left:5px;
  220. height:23px;
  221. }
  222. .tree{
  223. color:grey;
  224. text-overflow:ellipsis;
  225. white-space:nowrap;
  226. overflow:hidden;
  227. display:block;
  228. cursor:pointer;
  229. }
  230. .detailsTable2{
  231. color:grey;
  232. display:block;
  233. font-size:0.8em;
  234. text-align:left;
  235. margin-left:5px;
  236. height:23px;
  237. }
  238. .textTable{
  239. float:left;
  240. width:200px;
  241. text-overflow:ellipsis;
  242. white-space:nowrap;
  243. overflow:hidden;
  244. cursor:pointer;
  245. display:inline-block;
  246. }
  247. #dropPic{
  248. height:250px;
  249. border-radius:5px;
  250. border-style:solid;
  251. border-color:#ededed;
  252. background-color: #fbfbfb;
  253. border-width:1px;
  254. }
  255. .upload-drop-zone {
  256. height: 100px;
  257. border-width: 2px;
  258. margin-bottom: 0px;
  259. }
  260. /* skin.css Style*/
  261. .upload-drop-zone {
  262. color: #ccc;
  263. border-style: dashed;
  264. border-color: #ccc;
  265. line-height: 100px;
  266. text-align: center
  267. }
  268. .upload-drop-zone.drop {
  269. color: #222;
  270. border-color: #222;
  271. }
  272. .anim-refresh {
  273. -animation: spin .7s infinite linear;
  274. -webkit-animation: spin2 .7s infinite linear;
  275. }
  276. @-webkit-keyframes spin2 {
  277. from { -webkit-transform: rotate(0deg);}
  278. to { -webkit-transform: rotate(360deg);}
  279. }
  280. @keyframes spin {
  281. from { transform: scale(1) rotate(0deg);}
  282. to { transform: scale(1) rotate(360deg);}
  283. }
  284. .list-group-item{
  285. cursor:pointer;
  286. }
  287. .list-group-item:hover{
  288. background-color:#eeeeee;
  289. }
  290. .list-group-item:hover .glyphicon{
  291. opacity:1 !important;
  292. }
  293. .textTable2{
  294. float:left;
  295. width:230px;
  296. text-overflow:ellipsis;
  297. white-space:nowrap;
  298. overflow:hidden;
  299. cursor:pointer;
  300. display:inline-block;
  301. }
  302. .pbody{
  303. padding-left:20px;
  304. padding-right:20px;
  305. text-align:justify;
  306. }
  307. .singleAdv{
  308. float:left;
  309. height:100%;
  310. width:290px;
  311. }
  312. #side #adv{
  313. }
  314. #side #ulcon, #side #ulproc, #side #adv {
  315. background-color: white;
  316. overflow-y: scroll;
  317. height: 70% !important;
  318. border-style:solid;
  319. border-width:1px;
  320. border-color:grey;
  321. margin-top: 10px;
  322. border-radius: 5px;
  323. padding-bottom: 10px;
  324. border-style: solid;
  325. border-width: 1px;
  326. border-color: #e5e5e5;
  327. color: black;
  328. padding-left: 0px;
  329. font-family: tahoma;
  330. font-size: 13px;
  331. }
  332. .selectedAdv{
  333. background-color:#e4e4e4;
  334. }
  335. .selectedAdv:hover{
  336. background-color:#e4e4e4;
  337. }
  338. #side .dragStyle {
  339. padding-left: 8px;
  340. padding-top: 4px;
  341. padding-bottom: 4px;
  342. border-bottom-style: dotted;
  343. border-width: 1px;
  344. cursor: pointer;
  345. border-color: #e5e5e5;
  346. background-color: white;
  347. display: block;
  348. }
  349. #side .showMore {
  350. padding-left: 2px;
  351. padding-top: 4px;
  352. padding-bottom: 4px;
  353. border-width: 1px;
  354. border-color: #e5e5e5;
  355. }
  356. #side .gIco {
  357. padding-left: 2px;
  358. padding-top: 4px;
  359. padding-bottom: 4px;
  360. border-width: 1px;
  361. border-color: #e5e5e5;
  362. cursor: pointer;
  363. }
  364. #side .hov,
  365. #side .grad {
  366. cursor: pointer;
  367. }
  368. #side .click {
  369. float: left;
  370. color: grey;
  371. font-size: 10px;
  372. cursor: pointer;
  373. }
  374. .delRes,
  375. .btnEdit,
  376. .hdesc,
  377. .sdesc {
  378. cursor: pointer;
  379. }
  380. .goto{
  381. padding-left:10px;
  382. }
  383. #side .tabelaName {
  384. white-space: nowrap;
  385. margin-right: 10px;
  386. overflow: hidden;
  387. width: 350px;
  388. float: left;
  389. text-overflow: ellipsis;
  390. display: block;
  391. cursor: pointer;
  392. }
  393. #side .hov:hover {
  394. background-color: #e5e5e5;
  395. }
  396. #sidebar-wrapper {
  397. position: fixed;
  398. left: 600px;
  399. width: 0;
  400. height: 100%;
  401. color: white;
  402. margin-left: -600px;
  403. overflow-y: auto;
  404. background: #222;
  405. -webkit-transition: all 0.5s ease;
  406. -moz-transition: all 0.5s ease;
  407. -o-transition: all 0.5s ease;
  408. transition: all 0.5s ease;
  409. }
  410. #wrapper.toggled #sidebar-wrapper {
  411. width: 600px;
  412. }
  413. #page-content-wrapper {
  414. width: 100%;
  415. position: absolute;
  416. z-index:0 !important;
  417. padding-top: 15px;
  418. padding-left:0px !important;
  419. }
  420. #wrapper.toggled #page-content-wrapper {
  421. position: absolute;
  422. margin-right: -600px;
  423. }
  424. #wrapper {
  425. padding-left: 600px;
  426. }
  427. #wrapper.toggled {
  428. padding-left: 0 !important;
  429. }
  430. #sidebar-wrapper {
  431. width: 600px;
  432. }
  433. #wrapper.toggled #sidebar-wrapper {
  434. width: 0 !important;
  435. }
  436. #page-content-wrapper {
  437. padding: 20px;
  438. position: relative;
  439. }
  440. #wrapper.toggled #page-content-wrapper {
  441. position: relative;
  442. margin-right: 0;
  443. }
  444. .drop {
  445. margin-top: 10px;
  446. }
  447. .sdesc{
  448. margin-bottom:10px;
  449. }
  450. .hdesc textarea,
  451. .sdesc textarea {
  452. min-width: 100%;
  453. padding: 10px;
  454. }
  455. .step,
  456. .sDescAdd {
  457. margin-top:5px;
  458. color: grey;
  459. cursor: pointer;
  460. display:block;
  461. font-size:10px;
  462. }
  463. .sDescAdd:hover{
  464. color:black;
  465. }
  466. .goto{
  467. }
  468. .editGoto{
  469. cursor:pointer;
  470. }
  471. .sdesc {
  472. display: block;
  473. }
  474. .hDescAdd {
  475. cursor: pointer;
  476. }
  477. #saveBtn {} .changable {
  478. padding-left: 10px;
  479. }
  480. .changed {
  481. border-left-style: solid;
  482. border-width: 3px;
  483. border-color: #ffc107;
  484. padding-left: 7px;
  485. }
  486. .del {
  487. }
  488. .liRes:hover{
  489. background-color:#fafafa;
  490. }
  491. span.glyphicon{
  492. opacity:0.6;
  493. cursor:pointer;
  494. margin-left:3px;
  495. }
  496. span.glyphicon:hover{
  497. opacity:1;
  498. }
  499. .delRes:hover{
  500. color:red;
  501. }
  502. .delGoto:hover{
  503. color:red;
  504. cursor:pointer;
  505. }
  506. .del:hover{
  507. color:red;
  508. }
  509. .ids {
  510. color: grey;
  511. font-size: 12px;
  512. }
  513. .more {
  514. margin-left: 15px;
  515. }
  516. .resSelected {
  517. background-color: #d3d3d3;
  518. }
  519. </style>
  520. <?php
  521. }
  522. }