superedit-PROCES_ADD_ZASOB.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <?php
  2. /**
  3. * @param $_GET['procesID'] - id procesu
  4. *
  5. * example:
  6. * index.php?MENU_INIT=PROCES_ADD_ZASOB&procesID=3885
  7. */
  8. function PROCES_ADD_ZASOB() {
  9. $taskMsgs = array();
  10. $taskErrors = array();
  11. $task = V::get('_task', '', $_REQUEST);
  12. switch ($task) {
  13. case 'FRM_RM_ZASOB': {
  14. $procesID = V::get('procesID', 0, $_GET, 'int');
  15. $rmWskID = V::get('rmWskID', 0, $_POST, 'int');
  16. if (!$procesID || !$rmWskID) {
  17. $taskErrors[] = "Wrong param proces id or remove wskaźnik id!";
  18. }
  19. else {
  20. $db = DB::getDB();
  21. $sql_obj = new stdClass();
  22. $sql_obj->ID = $rmWskID;
  23. $sql_obj->A_STATUS = 'DELETED';
  24. $affected = $db->UPDATE_OBJ('CRM_WSKAZNIK', $sql_obj);
  25. if ($affected == 2) {
  26. $taskMsgs[] = "Usunieto wskaznik";
  27. } else if ($affected == 1) {
  28. $taskMsgs[] = "Usunieto wskaznik (nie zapisano historii)";
  29. } else if ($affected < 0) {
  30. $taskErrors[] = "Nie udało się usunąć zasobu - nic nie zmieniono";
  31. }
  32. }
  33. break;
  34. }
  35. case 'FRM_ADD_ZASOB': {
  36. if(V::get('DBG_NG', '', $_GET)){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">post (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($_POST);echo'</pre>';}
  37. $procesID = V::get('procesID', 0, $_GET, 'int');
  38. $addZasobID = V::get('addZasobID', 0, $_POST, 'int');
  39. $addPrzypadekID = V::get('addPrzypadekID', 0, $_POST, 'int');
  40. if ($procesID > 0 && $addZasobID > 0 && $addPrzypadekID > 0) {
  41. $addComment = V::get('addComment', '', $_POST);
  42. $db = DB::getDB();
  43. $sql_obj = new stdClass();
  44. $sql_obj->ID_PROCES = $procesID;
  45. $sql_obj->ID_ZASOB = $addZasobID;
  46. $sql_obj->ID_PRZYPADEK = $addPrzypadekID;
  47. $sql_obj->OPIS_ZASOB = $db->_($addComment);
  48. $sql_obj->SORT_PRIO = 0;
  49. // nowy wskaznik na koniec listy pod procesem
  50. $sql = "select max(cw.`SORT_PRIO`) as MAX_SORT_PRIO
  51. from `CRM_WSKAZNIK` as cw
  52. where
  53. cw.`ID_PROCES`='{$sql_obj->ID_PROCES}'
  54. ";
  55. $res = $db->query($sql);
  56. while ($r = $db->fetch($res)) {
  57. $sql_obj->SORT_PRIO = $r->MAX_SORT_PRIO + 1;
  58. }
  59. $new_id = $db->ADD_NEW_OBJ('CRM_WSKAZNIK', $sql_obj);
  60. if ($new_id > 0) {
  61. $taskMsgs[] = "Dodano zasób [{$addZasobID}] do procesu [{$procesID}]";
  62. } else {
  63. $taskErrors[] = "Nie udało się dodać zasobu";
  64. }
  65. }
  66. else if (!$addPrzypadekID) {
  67. $taskErrors[] = "Brak okreśłonego uprawnienia";
  68. }
  69. else if (!$addZasobID) {
  70. $taskErrors[] = "Brak numeru zasobu";
  71. }
  72. break;
  73. }
  74. case 'TYPESPECIAL': {
  75. $DBG = ('1' == V::get('DBG', '', $_REQUEST));
  76. header("Content-type: application/json");
  77. $fld = V::get('fld', '', $_GET);
  78. switch ($fld) {
  79. case 'editZasobID':
  80. case 'addZasobID': {
  81. Lib::loadClass('TypespecialVariable');
  82. $typeSpecialZasob = TypespecialVariable::getInstance(-1, '__ZASOB');
  83. $query = V::get('q', '', $_REQUEST);
  84. $rawRows = null;
  85. $jsonData = array();
  86. $rows = $typeSpecialZasob->getValuesWithExports($query);
  87. if($DBG){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">rows('.$query.') (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($rows);echo'</pre>';}
  88. foreach ($rows as $kID => $vItem) {
  89. $itemJson = new stdClass();
  90. $itemJson->id = $vItem->id;
  91. $itemJson->name = $vItem->param_out;
  92. if (!empty($vItem->exports)) {
  93. $itemJson->exports = $vItem->exports;
  94. }
  95. $jsonData[] = $itemJson;
  96. }
  97. echo json_encode($jsonData);
  98. break;
  99. }
  100. }
  101. exit;
  102. }
  103. case 'EDIT_WSKAZNIK_SAVE': {
  104. $procesID = V::get('procesID', 0, $_GET, 'int');
  105. $cw_id = V::get('cw_id', 0, $_GET, 'int');
  106. $editZasobID = V::get('editZasobID', 0, $_POST, 'int');
  107. $editPrzypadekID = V::get('editPrzypadekID', 0, $_POST, 'int');
  108. $editComment = V::get('editComment', '', $_POST);
  109. if (!$procesID || !$cw_id || !$editZasobID) {
  110. header('HTTP/1.0 406 Not Acceptable');
  111. echo "Wrong param proces ID or Wskaznik ID or Zasob ID!";
  112. exit;
  113. }
  114. $db = DB::getDB();
  115. if (!$db) {
  116. header('HTTP/1.0 406 Not Acceptable');
  117. echo "No DB!";
  118. exit;
  119. }
  120. $proces = $db->get_by_id('CRM_PROCES', $procesID);
  121. if (!$proces) {
  122. header('HTTP/1.0 406 Not Acceptable');
  123. echo "Proces not exists!";
  124. exit;
  125. }
  126. Lib::loadClass('ProcesHelper');
  127. $proces->_zasoby = ProcesHelper::get_wskazniki($proces->ID);
  128. if (!isset($proces->_zasoby[$cw_id])) {
  129. header('HTTP/1.0 406 Not Acceptable');
  130. echo "Wskaznik not exists!";
  131. exit;
  132. }
  133. $wskaznik = $proces->_zasoby[$cw_id];
  134. $sqlObj = new stdClass();
  135. $sqlObj->ID = $wskaznik->CW_ID;
  136. $toChange = false;
  137. if ($wskaznik->ID != $editZasobID) {
  138. $sqlObj->ID_ZASOB = $editZasobID;
  139. $toChange = true;
  140. }
  141. if ($wskaznik->ID_PRZYPADEK != $editPrzypadekID) {
  142. $sqlObj->ID_PRZYPADEK = $editPrzypadekID;
  143. $toChange = true;
  144. }
  145. if ($wskaznik->OPIS_ZASOB != $editComment) {
  146. $sqlObj->OPIS_ZASOB = $editComment;
  147. $toChange = true;
  148. }
  149. if (!$toChange) {
  150. echo 'Nie wprowadzono żadnych zmian.';
  151. }
  152. else {
  153. $ret = $db->UPDATE_OBJ('CRM_WSKAZNIK', $sqlObj);
  154. if ($ret < 0) {
  155. header('HTTP/1.0 406 Not Acceptable');
  156. echo "Wystąpiły błędy podczas zapisu zmian w bazie danych!";
  157. exit;
  158. }
  159. else if ($ret > 0) {
  160. //echo 'OK';
  161. }
  162. else {
  163. //echo 'Nie wprowadzono żadnych zmian.';
  164. }
  165. }
  166. // TODO: return json object wskaznik to fix layout without page reload
  167. header("Content-type: application/json");
  168. $data = new stdClass();
  169. $data->msg = "Zmiany wprowadzono pomyślnie";
  170. $data->wskaznik = $db->get_by_id('CRM_WSKAZNIK', $cw_id);
  171. if ($data->wskaznik->ID_ZASOB > 0) {
  172. $data->wskaznik->_zasob = $db->get_by_id('CRM_LISTA_ZASOBOW', $data->wskaznik->ID_ZASOB);
  173. }
  174. if ($data->wskaznik->ID_PRZYPADEK > 0) {
  175. $data->wskaznik->_przypadek = $db->get_by_id('CRM_PRZYPADEK', $data->wskaznik->ID_PRZYPADEK);
  176. }
  177. echo json_encode($data);
  178. exit;
  179. }
  180. case 'EDIT_WSKAZNIK': {
  181. $procesID = V::get('procesID', 0, $_GET, 'int');
  182. $cw_id = V::get('cw_id', 0, $_GET, 'int');
  183. if (!$procesID || !$cw_id) {
  184. header('HTTP/1.0 406 Not Acceptable');
  185. echo "Wrong param proces ID or Wskaznik ID!";
  186. exit;
  187. }
  188. $db = DB::getDB();
  189. if (!$db) {
  190. header('HTTP/1.0 406 Not Acceptable');
  191. echo "No DB!";
  192. exit;
  193. }
  194. $proces = $db->get_by_id('CRM_PROCES', $procesID);
  195. if (!$proces) {
  196. header('HTTP/1.0 406 Not Acceptable');
  197. echo "Proces not exists!";
  198. exit;
  199. }
  200. Lib::loadClass('ProcesHelper');
  201. $proces->_zasoby = ProcesHelper::get_wskazniki($proces->ID);
  202. if (!isset($proces->_zasoby[$cw_id])) {
  203. header('HTTP/1.0 406 Not Acceptable');
  204. echo "Wskaznik not exists!";
  205. exit;
  206. }
  207. $wskaznik = $proces->_zasoby[$cw_id];
  208. Lib::loadClass('TypespecialVariable');
  209. $typeSpecialZasob = TypespecialVariable::getInstance(-1, '__ZASOB');
  210. if (!$typeSpecialZasob) {
  211. header('HTTP/1.0 406 Not Acceptable');
  212. echo "TypeSpecial Zasob not exists!";
  213. exit;
  214. }
  215. ?>
  216. <form action="" method="POST" class="form conn_wsk-frm">
  217. <div class="control-group">
  218. <label class="control-label" for="editZasobID">Zasób</label>
  219. <div class="controls">
  220. <?php
  221. $fName = 'editZasobID';
  222. $fldParams = array();
  223. $fldParams['allowCreate'] = false;
  224. $fldParams['ajaxDataUrlBase'] = "index.php?FUNCTION_INIT=" . __FUNCTION__ . "&HEADER_NOT_INIT=YES&_task=TYPESPECIAL&fld={$fName}";
  225. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  226. $tsValues = $typeSpecialZasob->getEditSelectedValuesByIds($tblId = null, $id = null, $fieldName = '', $fieldValue = $wskaznik->ID);
  227. $fldParams['typespecialValue'] = (!empty($tsValues))? reset($tsValues) : '';
  228. echo $typeSpecialZasob->showFormItem($tblID = -1, $fName, $selValue = $wskaznik->ID, $fldParams);
  229. ?>
  230. </div>
  231. </div>
  232. <div class="control-group">
  233. <label class="control-label" for="editPrzypadekID">Uprawnienia</label>
  234. <div class="controls">
  235. <?php
  236. $uprawnienia = array();
  237. $db = DB::getDB();
  238. $sql = "select p.* from `CRM_PRZYPADEK` as p ";
  239. $res = $db->query($sql);
  240. while ($r = $db->fetch($res)) {
  241. $uprawnienia[$r->ID] = "{$r->FORM_TREAT}: {$r->OPIS}";// {$r->NAZWA} | {$r->PYTANIE} |
  242. }
  243. ?>
  244. <select name="editPrzypadekID" style="width:366px;" size="6">
  245. <?php foreach($uprawnienia as $kId => $vPermLabel) : ?>
  246. <?php $sel = ($wskaznik->CW_ID_PRZYPADEK == $kId)? ' selected="selected"' : ''; ?>
  247. <option value="<?php echo $kId; ?>"<?php echo $sel; ?>><?php echo $vPermLabel; ?></option>
  248. <?php endforeach; ?>
  249. </select>
  250. </div>
  251. </div>
  252. <div class="control-group">
  253. <label class="control-label" for="editComment">Komentarz</label>
  254. <div class="controls">
  255. <textarea name="editComment" cols="80" rows="6" style="width:354px;"><?php echo $wskaznik->OPIS_ZASOB; ?></textarea>
  256. </div>
  257. </div>
  258. <div class="control-group">
  259. <div class="controls">
  260. <button type="submit" class="btn btn-primary">Zapisz</button>
  261. </div>
  262. </div>
  263. </form>
  264. <?php
  265. exit;
  266. }
  267. }
  268. SE_Layout::menu();
  269. Lib::loadClass('UserActivity');
  270. Lib::loadClass('ProcesHelper');
  271. /* TODO: permy do pokazania tej funkcji
  272. $zasobID = ProcesHelper::getZasobTableID('CRM_WSKAZNIK');
  273. if ($zasobID <= 0) {
  274. echo UserActivity::showListInContainer();
  275. return;
  276. }
  277. $zasobObj = ProcesHelper::getZasobTableInfo($zasobID);
  278. if (!$zasobObj) {
  279. echo '<div class="alert alert-error">' . "Zasob TABELA ID={$zasobID} nie istnieje" . '</div>';
  280. echo UserActivity::showSimpleList();
  281. return;
  282. }
  283. */
  284. $procesID = V::get('procesID', '', $_GET);
  285. if (!$procesID) {
  286. echo '<div class="alert alert-error">' . "Wrong param proces ID!" . '</div>';
  287. return;
  288. }
  289. $db = DB::getDB();
  290. $proces = $db->get_by_id('CRM_PROCES', $procesID);
  291. Lib::loadClass('ProcesHelper');
  292. $proces->_zasoby = ProcesHelper::get_wskazniki($proces->ID);
  293. Lib::loadClass('TypespecialVariable');
  294. $typeSpecialZasob = TypespecialVariable::getInstance(-1, '__ZASOB');
  295. ?>
  296. <style type="text/css">
  297. .conn_wsk {}
  298. .conn_wsk .conn_wsk-list {}
  299. .conn_wsk .conn_wsk-list .conn_wsk-list_item { line-height:22px; }
  300. .conn_wsk .conn_wsk-list .conn_wsk-list_item form { display:inline; margin:0; }
  301. .conn_wsk .conn_wsk-list_item-rmBtn,
  302. .conn_wsk .conn_wsk-list_item-editBtn { /*display:none;*/ opacity:0.3; margin:0; padding:0; border:none; }
  303. .conn_wsk .conn_wsk-list_item-rmBtn { margin:0 0 0 10px; }
  304. .conn_wsk .conn_wsk-list_item-editBtn { margin:0 0 0 10px; }
  305. .conn_wsk .conn_wsk-list_item:hover .conn_wsk-list_item-rmBtn,
  306. .conn_wsk .conn_wsk-list_item:hover .conn_wsk-list_item-editBtn { /*display:inline;*/ opacity:0.6; }
  307. .conn_wsk .conn_wsk-list_item .conn_wsk-list_item-rmBtn:hover,
  308. .conn_wsk .conn_wsk-list_item .conn_wsk-list_item-editBtn:hover { /*display:inline;*/ opacity:1; }
  309. .conn_wsk-frm {}
  310. .conn_wsk .conn_wsk-opisyShowBtn { padding:0 0 0 10px; font-size:12px; font-weight:normal; color:#08C; cursor:pointer; }
  311. .conn_wsk-list_item-desc,
  312. .conn_wsk-list_item-longDesc { display:none; }
  313. .opisyShow .conn_wsk-list_item-desc,
  314. .opisyShow .conn_wsk-list_item-longDesc { display:block; }
  315. .editWskModal-loading .modal-body { padding-left:40px; background:url(./icon/loading.gif) no-repeat left top; background-position:20px 20px; }
  316. </style>
  317. <div class="container conn_wsk">
  318. <h3>Edycja procesu</h3>
  319. <blockquote>
  320. <b>Proces [<?php echo $proces->ID; ?>]</b>: <?php echo $proces->TYPE; ?> <?php echo $proces->DESC; ?>
  321. <p><?php echo $proces->OPIS; ?></p>
  322. </blockquote>
  323. <?php if (!empty($taskErrors)) : ?>
  324. <div class="alert alert-error">
  325. <button type="button" class="close" data-dismiss="alert">×</button>
  326. <?php echo implode('<br>', $taskErrors); ?>
  327. </div>
  328. <?php endif; ?>
  329. <?php if (!empty($taskMsgs)) : ?>
  330. <div class="alert alert-success">
  331. <button type="button" class="close" data-dismiss="alert">×</button>
  332. <?php echo implode('<br>', $taskMsgs); ?>
  333. </div>
  334. <?php endif; ?>
  335. <h5>Przypisane zasoby <em>(<?php echo (!empty($proces->_zasoby))? count($proces->_zasoby) : 0; ?>)</em>: <span class="conn_wsk-opisyShowBtn" onclick="jQuery(this).parent().parent().toggleClass('opisyShow')">+/- opisy</span></h5>
  336. <ul class="conn_wsk-list">
  337. <?php if (!empty($proces->_zasoby)) : ?>
  338. <?php foreach ($proces->_zasoby as $vZasob) : ?>
  339. <li class="conn_wsk-list_item conn_wsk-list_item-<?php echo $vZasob->CW_ID; ?>">
  340. <span class="conn_wsk-list_item-title"><?php echo $vZasob->CP_FORM_TREAT; ?> [<?php echo $vZasob->ID; ?>] <?php echo $vZasob->TYPE; ?> <b><?php echo $vZasob->DESC; ?></b></span>
  341. <form action="" method="POST" class="form-inline conn_wsk-list_item-frm-rm">
  342. <input type="hidden" name="_task" value="FRM_RM_ZASOB">
  343. <button name="rmWskID" value="<?php echo $vZasob->CW_ID; ?>" class="btn-link btn-small conn_wsk-list_item-rmBtn" title="usuń zasób"><i class="icon icon-remove"></i></button>
  344. </form>
  345. <p class="conn_wsk-list_item-desc">
  346. <?php if (!empty($vZasob->OPIS)) : ?>
  347. <?php echo $vZasob->OPIS; ?>
  348. <?php endif; ?>
  349. </p>
  350. <p class="conn_wsk-list_item-longDesc">
  351. <?php if (!empty($vZasob->OPIS_ZASOB)) : ?>
  352. <?php echo $vZasob->OPIS_ZASOB; ?>
  353. <?php endif; ?>
  354. </p>
  355. </li>
  356. <?php endforeach; ?>
  357. <?php endif; ?>
  358. </ul>
  359. <?php if ($typeSpecialZasob) : ?>
  360. <h5>Dodaj zasób:</h5>
  361. <form action="" method="POST" class="form-horizontal conn_wsk-frm">
  362. <input type="hidden" name="_task" value="FRM_ADD_ZASOB">
  363. <div class="control-group">
  364. <label class="control-label" for="addZasobID">Zasób</label>
  365. <div class="controls">
  366. <?php
  367. $fName = 'addZasobID';
  368. $fldParams = array();
  369. $fldParams['allowCreate'] = false;
  370. $fldParams['ajaxDataUrlBase'] = "index.php?FUNCTION_INIT=" . __FUNCTION__ . "&HEADER_NOT_INIT=YES&_task=TYPESPECIAL&fld={$fName}";
  371. //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
  372. echo $typeSpecialZasob->showFormItem($tblID = -1, $fName, $selValue = '', $fldParams);
  373. ?>
  374. </div>
  375. </div>
  376. <div class="control-group">
  377. <label class="control-label" for="addPrzypadekID">Uprawnienia</label>
  378. <div class="controls">
  379. <?php
  380. $uprawnienia = array();
  381. $db = DB::getDB();
  382. $sql = "select p.* from `CRM_PRZYPADEK` as p ";
  383. $res = $db->query($sql);
  384. while ($r = $db->fetch($res)) {
  385. $uprawnienia[$r->ID] = "{$r->FORM_TREAT}: {$r->OPIS}";// {$r->NAZWA} | {$r->PYTANIE} |
  386. }
  387. ?>
  388. <select name="addPrzypadekID" style="width:366px;" size="6">
  389. <?php foreach($uprawnienia as $kId => $vPermLabel) : ?>
  390. <option value="<?php echo $kId; ?>"><?php echo $vPermLabel; ?></option>
  391. <?php endforeach; ?>
  392. </select>
  393. </div>
  394. </div>
  395. <div class="control-group">
  396. <label class="control-label" for="addComment">Komentarz</label>
  397. <div class="controls">
  398. <textarea name="addComment" cols="80" rows="6" style="width:354px;"></textarea>
  399. </div>
  400. </div>
  401. <div class="control-group">
  402. <div class="controls">
  403. <button type="submit" class="btn">dodaj</button>
  404. </div>
  405. </div>
  406. </form>
  407. <?php endif; ?>
  408. </div>
  409. <!-- Modal -->
  410. <div id="editWskModal" class="modal hide fade editWskModal-loading" tabindex="-1" role="dialog" aria-labelledby="editWskModalLabel" aria-hidden="true">
  411. <div class="modal-header">
  412. <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  413. <h3 id="editWskModalLabel">Edycja wskaźnika</h3>
  414. </div>
  415. <div class="modal-body">
  416. <p>One fine body...</p>
  417. </div>
  418. <!--
  419. <div class="modal-footer">
  420. <button class="btn" data-dismiss="modal" aria-hidden="true">Anuluj</button>
  421. <button class="btn btn-primary">Zapisz</button>
  422. </div>
  423. -->
  424. </div>
  425. <script>
  426. jQuery(document).ready(function() {
  427. jQuery('.conn_wsk-list_item-rmBtn').each(function(ind, n) {
  428. var btn = jQuery('<button class="btn-link btn-small conn_wsk-list_item-editBtn" title="edytuj wskaźnik"><i class="icon icon-edit"></i></button>');
  429. btn.data('cw_id', n.value);
  430. btn.on('click', function(e) {
  431. e.preventDefault();
  432. e.stopPropagation();
  433. var trg = jQuery(event.currentTarget),
  434. cw_id = trg.data('cw_id');
  435. if (cw_id > 0) {
  436. var modal = jQuery('#editWskModal');
  437. modal.addClass('editWskModal-loading');
  438. modal.modal();
  439. jQuery.ajax({
  440. data: null,
  441. type: "GET",
  442. url: 'index.php?FUNCTION_INIT=<?php echo __FUNCTION__; ?>&HEADER_NOT_INIT=YES&_task=EDIT_WSKAZNIK&procesID=<?php echo $proces->ID; ?>&cw_id=' + cw_id,
  443. })
  444. .done(function(data, textStatus, jqXHR){
  445. modal.find('.modal-body').html(data);
  446. modal.find('.modal-body').find('form').on('submit', function() {
  447. var frm = jQuery(this);
  448. jQuery.ajax({
  449. data: frm.serialize(),
  450. type: "POST",
  451. dataType: 'json',
  452. url: 'index.php?FUNCTION_INIT=<?php echo __FUNCTION__; ?>&HEADER_NOT_INIT=YES&_task=EDIT_WSKAZNIK_SAVE&procesID=<?php echo $proces->ID; ?>&cw_id=' + cw_id
  453. })
  454. .done(function(data, textStatus, jqXHR){
  455. if (data.msg) {
  456. modal.find('.modal-body').html('<div class="alert alert-success">' + data.msg + '</div>');
  457. } else {
  458. modal.find('.modal-body').html(data);
  459. }
  460. if (data.wskaznik) {
  461. var trgWrap = jQuery('.conn_wsk-list_item-' + cw_id),
  462. trgTitle = trgWrap.find('.conn_wsk-list_item-title'),
  463. trgDesc = trgWrap.find('.conn_wsk-list_item-desc'),
  464. trgZasobDesc = trgWrap.find('.conn_wsk-list_item-longDesc')
  465. ;
  466. if (trgTitle && trgTitle.length > 0) {
  467. var outTrgTitle = '';
  468. if (undefined !== data.wskaznik._przypadek) {
  469. if (undefined !== data.wskaznik._przypadek.FORM_TREAT) {
  470. outTrgTitle += data.wskaznik._przypadek.FORM_TREAT + ' ';
  471. }
  472. }
  473. if (undefined !== data.wskaznik._zasob) {
  474. if (undefined !== data.wskaznik._zasob.ID) outTrgTitle += '[' + data.wskaznik._zasob.ID + '] ';
  475. if (undefined !== data.wskaznik._zasob.TYPE) outTrgTitle += data.wskaznik._zasob.TYPE + ' ';
  476. if (undefined !== data.wskaznik._zasob.DESC) outTrgTitle += '<b>' + data.wskaznik._zasob.DESC + '</b>';
  477. }
  478. trgTitle.html(outTrgTitle);
  479. }
  480. if (trgDesc && trgDesc.length > 0) {
  481. if (undefined !== data.wskaznik._zasob) {
  482. if (undefined !== data.wskaznik._zasob.OPIS) {
  483. trgDesc.html(data.wskaznik._zasob.OPIS);
  484. }
  485. }
  486. }
  487. if (trgZasobDesc && trgZasobDesc.length > 0) {
  488. if (undefined !== data.wskaznik.OPIS_ZASOB) {
  489. trgZasobDesc.html(data.wskaznik.OPIS_ZASOB);
  490. }
  491. }
  492. }
  493. })
  494. .fail(function(jqXHR){// jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
  495. var txt = jqXHR.responseText || 'Error';
  496. modal.find('.modal-body').html('<div class="alert alert-error">' + txt + '</div>');
  497. })
  498. return false;
  499. });
  500. })
  501. .fail(function(jqXHR){// jqXHR.fail(function( jqXHR, textStatus, errorThrown ) {});
  502. var txt = jqXHR.responseText || 'Error';
  503. modal.find('.modal-body').html('<div class="alert alert-error">' + txt + '</div>');
  504. })
  505. .always(function(data, textStatus, jqXHR) {
  506. modal.removeClass('editWskModal-loading');
  507. });
  508. }
  509. });
  510. btn.insertBefore(n);
  511. });
  512. });
  513. </script>
  514. <?php
  515. }