ProcesEditor.php 12 KB

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