Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

custom_datatable.js 60KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513
  1. "use strict";
  2. // Class definition
  3. var global = function () {
  4. // Private functions
  5. // basic demo
  6. var datatablenya = function (id_datatable, url_ajax, column) {
  7. var datatable = $(id_datatable).DataTable({
  8. language: {
  9. processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span> ',
  10. paginate: {
  11. next: '<span><i class="fa fa-angle-right" aria-hidden="true"></i></span>',
  12. previous: '<span><i class="fa fa-angle-left" aria-hidden="true"></i></span>'
  13. }
  14. },
  15. createdRow: function (row, data, dataIndex) {
  16. $(row).find('td').addClass('text-left');
  17. },
  18. processing: true,
  19. serverSide: true,
  20. lengthMenu: [
  21. [10, 25, 50, -1],
  22. [10, 25, 50, "All"]
  23. ],
  24. ajax: url_ajax,
  25. columns: column
  26. });
  27. $(id_datatable).css("width", "100%");
  28. $(id_datatable).addClass("nowrap");
  29. $("select").removeClass("custom-select-sm");
  30. $("select").removeClass("custom-select");
  31. $(id_datatable).on('click', '.btn-delete', function (e) {
  32. e.preventDefault();
  33. var el = this;
  34. var route = $(this).attr("data-route");
  35. Swal.fire({
  36. title: "Apakah yakin hapus data ini ?",
  37. text: "Lanjutkan untuk menghapus",
  38. icon: "warning",
  39. showCancelButton: true,
  40. confirmButtonColor: '#DD6B55',
  41. confirmButtonText: 'Yes',
  42. }).then((result) => {
  43. $.ajaxSetup({
  44. headers: {
  45. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  46. }
  47. });
  48. if (result.value) {
  49. $.ajax({
  50. url: route,
  51. type: 'get', // replaced from put
  52. dataType: "JSON",
  53. beforeSend: function () {
  54. $.blockUI();
  55. },
  56. success: function (response) {
  57. if (response.status == true) {
  58. $(id_datatable).DataTable().ajax.reload();
  59. swal.fire("Deleted!", response.message, "success");
  60. } else {
  61. swal.fire("Failed!", response.message, "error");
  62. }
  63. $.unblockUI();
  64. },
  65. error: function (xhr) {
  66. console.log(xhr.responseText);
  67. }
  68. });
  69. };
  70. });
  71. });
  72. $(id_datatable).on('click', '.btn-musnahkan', function (e) {
  73. e.preventDefault();
  74. var el = this;
  75. var route = $(this).attr("data-route");
  76. Swal.fire({
  77. title: "Apakah yakin memusnahkan darah ini ?",
  78. text: "Lanjutkan untuk mengmemusnahkan",
  79. icon: "warning",
  80. showCancelButton: true,
  81. confirmButtonColor: '#DD6B55',
  82. confirmButtonText: 'Yes',
  83. }).then((result) => {
  84. $.ajaxSetup({
  85. headers: {
  86. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  87. }
  88. });
  89. if (result.value) {
  90. $.ajax({
  91. url: route,
  92. type: 'get', // replaced from put
  93. dataType: "JSON",
  94. beforeSend: function () {
  95. $.blockUI();
  96. },
  97. success: function (response) {
  98. if (response.status == true) {
  99. $(id_datatable).DataTable().ajax.reload();
  100. swal.fire("Berhasil!", response.message, "success");
  101. } else {
  102. swal.fire("Gagal!", response.message, "error");
  103. }
  104. $.unblockUI();
  105. },
  106. error: function (xhr) {
  107. console.log(xhr.responseText);
  108. }
  109. });
  110. };
  111. });
  112. });
  113. $(id_datatable).on('click', '.btn-pindahkerelease', function (e) {
  114. e.preventDefault();
  115. var el = this;
  116. var route = $(this).attr("data-route");
  117. Swal.fire({
  118. title: "Apakah yakin merelase darah ini ke SIDONI RS ?",
  119. text: "Lanjutkan untuk relaese",
  120. icon: "warning",
  121. showCancelButton: true,
  122. confirmButtonColor: '#DD6B55',
  123. confirmButtonText: 'Yes',
  124. }).then((result) => {
  125. $.ajaxSetup({
  126. headers: {
  127. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  128. }
  129. });
  130. if (result.value) {
  131. $.ajax({
  132. url: route,
  133. type: 'get', // replaced from put
  134. dataType: "JSON",
  135. beforeSend: function () {
  136. $.blockUI();
  137. },
  138. success: function (response) {
  139. if (response.status == true) {
  140. $(id_datatable).DataTable().ajax.reload();
  141. swal.fire("Berhasil!", response.message, "success");
  142. } else {
  143. swal.fire("Gagal!", response.message, "error");
  144. }
  145. $.unblockUI();
  146. },
  147. error: function (xhr) {
  148. console.log(xhr.responseText);
  149. }
  150. });
  151. };
  152. });
  153. });
  154. $(id_datatable).on('click', '.btn-pindah-gudang-aftap', function (e) {
  155. e.preventDefault();
  156. var el = this;
  157. var route = $(this).attr("data-route");
  158. Swal.fire({
  159. title: "Apakah yakin memindahkan ke gudang aftap ?",
  160. text: "Lanjutkan untuk memindahkan",
  161. icon: "warning",
  162. showCancelButton: true,
  163. confirmButtonColor: '#DD6B55',
  164. confirmButtonText: 'Yes',
  165. }).then((result) => {
  166. $.ajaxSetup({
  167. headers: {
  168. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  169. }
  170. });
  171. if (result.value) {
  172. $.ajax({
  173. url: route,
  174. type: 'get', // replaced from put
  175. dataType: "JSON",
  176. beforeSend: function () {
  177. $.blockUI();
  178. },
  179. success: function (response) {
  180. if (response.status == true) {
  181. $(id_datatable).DataTable().ajax.reload();
  182. swal.fire("Berhasil!", response.message, "success");
  183. } else {
  184. swal.fire("Gagal!", response.message, "error");
  185. }
  186. $.unblockUI();
  187. },
  188. error: function (xhr) {
  189. console.log(xhr.responseText);
  190. }
  191. });
  192. };
  193. });
  194. });
  195. $(id_datatable).on('click', '.btn-cancel', function (e) {
  196. e.preventDefault();
  197. var el = this;
  198. var route = $(this).attr("data-route");
  199. Swal.fire({
  200. title: "Apakah yakin membatalkan order ini ?",
  201. text: "Lanjutkan untuk membatalkan",
  202. icon: "warning",
  203. showCancelButton: true,
  204. confirmButtonColor: '#DD6B55',
  205. confirmButtonText: 'Yes',
  206. }).then((result) => {
  207. if (result.value) {
  208. $.ajax({
  209. url: route,
  210. type: 'get', // replaced from put
  211. dataType: "JSON",
  212. beforeSend: function () {
  213. $.blockUI();
  214. },
  215. success: function (response) {
  216. if (response.status == true) {
  217. $(id_datatable).DataTable().ajax.reload();
  218. swal.fire("Berhasil", response.message, "success");
  219. } else {
  220. swal.fire("Gagal!", response.message, "error");
  221. }
  222. $.unblockUI();
  223. },
  224. error: function (xhr) {
  225. console.log(xhr.responseText);
  226. }
  227. });
  228. };
  229. });
  230. });
  231. $(id_datatable).on('click', '.btn-masukan-stock-release', function (e) {
  232. e.preventDefault();
  233. var el = this;
  234. var route = $(this).attr("data-route");
  235. Swal.fire({
  236. title: "Apakah yakin memasukan ke Stock Release ?",
  237. text: "Lanjutkan untuk membatalkan",
  238. icon: "warning",
  239. showCancelButton: true,
  240. confirmButtonColor: '#DD6B55',
  241. confirmButtonText: 'Yes',
  242. }).then((result) => {
  243. if (result.value) {
  244. $.ajax({
  245. url: route,
  246. type: 'get', // replaced from put
  247. dataType: "JSON",
  248. beforeSend: function () {
  249. $.blockUI();
  250. },
  251. success: function (response) {
  252. if (response.status == true) {
  253. $(id_datatable).DataTable().ajax.reload();
  254. swal.fire("Berhasil", response.message, "success");
  255. } else {
  256. swal.fire("Gagal!", response.message, "error");
  257. }
  258. $.unblockUI();
  259. },
  260. error: function (xhr) {
  261. console.log(xhr.responseText);
  262. }
  263. });
  264. };
  265. });
  266. });
  267. $(id_datatable).on('click', '.btn-non-aktif-reagen', function (e) {
  268. e.preventDefault();
  269. var el = this;
  270. var route = $(this).attr("data-route");
  271. Swal.fire({
  272. title: "Apakah yakin menonaktifkan reagen ?",
  273. text: "Lanjutkan untuk menonaktifkan",
  274. icon: "warning",
  275. showCancelButton: true,
  276. confirmButtonColor: '#DD6B55',
  277. confirmButtonText: 'Yes',
  278. }).then((result) => {
  279. $.ajaxSetup({
  280. headers: {
  281. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  282. }
  283. });
  284. if (result.value) {
  285. $.ajax({
  286. url: route,
  287. type: 'get', // replaced from put
  288. dataType: "JSON",
  289. beforeSend: function () {
  290. $.blockUI();
  291. },
  292. success: function (response) {
  293. if (response.status == true) {
  294. $(id_datatable).DataTable().ajax.reload();
  295. swal.fire("Berhasil!", response.message, "success");
  296. } else {
  297. swal.fire("Gagal!", response.message, "error");
  298. }
  299. $.unblockUI();
  300. },
  301. error: function (xhr) {
  302. console.log(xhr.responseText);
  303. }
  304. });
  305. };
  306. });
  307. });
  308. $(id_datatable).on('click', '.btn-aktif-reagen', function (e) {
  309. e.preventDefault();
  310. var el = this;
  311. var route = $(this).attr("data-route");
  312. Swal.fire({
  313. title: "Apakah yakin mengaktifkan reagen ?",
  314. text: "Lanjutkan untuk mengaktifkan",
  315. icon: "warning",
  316. showCancelButton: true,
  317. confirmButtonColor: '#DD6B55',
  318. confirmButtonText: 'Yes',
  319. }).then((result) => {
  320. $.ajaxSetup({
  321. headers: {
  322. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  323. }
  324. });
  325. if (result.value) {
  326. $.ajax({
  327. url: route,
  328. type: 'get', // replaced from put
  329. dataType: "JSON",
  330. beforeSend: function () {
  331. $.blockUI();
  332. },
  333. success: function (response) {
  334. if (response.status == true) {
  335. $(id_datatable).DataTable().ajax.reload();
  336. swal.fire("Berhasil!", response.message, "success");
  337. } else {
  338. swal.fire("Gagal!", response.message, "error");
  339. }
  340. $.unblockUI();
  341. },
  342. error: function (xhr) {
  343. console.log(xhr.responseText);
  344. }
  345. });
  346. };
  347. });
  348. });
  349. $(id_datatable).on('click', '.btn-rotasi-selesai', function (e) {
  350. e.preventDefault();
  351. var el = this;
  352. var route = $(this).attr("data-route");
  353. Swal.fire({
  354. title: "Apakah yakin menyelesaikan rotasi ini ?",
  355. text: "Data rotasi selesai akan berada di list rotasi selesai",
  356. icon: "warning",
  357. showCancelButton: true,
  358. confirmButtonColor: '#DD6B55',
  359. confirmButtonText: 'Yes',
  360. }).then((result) => {
  361. $.ajaxSetup({
  362. headers: {
  363. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  364. }
  365. });
  366. if (result.value) {
  367. $.ajax({
  368. url: route,
  369. type: 'get', // replaced from put
  370. dataType: "JSON",
  371. beforeSend: function () {
  372. $.blockUI();
  373. },
  374. success: function (response) {
  375. if (response.status == true) {
  376. $(id_datatable).DataTable().ajax.reload();
  377. swal.fire("Berhasil!", response.message, "success");
  378. } else {
  379. swal.fire("Gagal!", response.message, "error");
  380. }
  381. $.unblockUI();
  382. },
  383. error: function (xhr) {
  384. console.log(xhr.responseText);
  385. }
  386. });
  387. };
  388. });
  389. });
  390. $(id_datatable).on('click', '.btn-finish-penapisan', function (e) {
  391. e.preventDefault();
  392. var el = this;
  393. var route = $(this).attr("data-route");
  394. Swal.fire({
  395. title: "Apakah yakin menyelesaikan Log Book ini ?",
  396. text: "Data Log book selesai akan berada di list Log Book",
  397. icon: "warning",
  398. showCancelButton: true,
  399. confirmButtonColor: '#DD6B55',
  400. confirmButtonText: 'Yes',
  401. }).then((result) => {
  402. $.ajaxSetup({
  403. headers: {
  404. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  405. }
  406. });
  407. if (result.value) {
  408. $.ajax({
  409. url: route,
  410. type: 'get', // replaced from put
  411. dataType: "JSON",
  412. beforeSend: function () {
  413. $.blockUI();
  414. },
  415. success: function (response) {
  416. if (response.status == true) {
  417. $(id_datatable).DataTable().ajax.reload();
  418. swal.fire("Berhasil!", response.message, "success");
  419. } else {
  420. swal.fire("Gagal!", response.message, "error");
  421. }
  422. $.unblockUI();
  423. },
  424. error: function (xhr) {
  425. console.log(xhr.responseText);
  426. }
  427. });
  428. };
  429. });
  430. });
  431. };
  432. var datatableList = function (id_datatable, url_ajax, column) {
  433. var datatable = $(id_datatable).DataTable({
  434. language: {
  435. processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span> ',
  436. paginate: {
  437. next: '<span><i class="fa fa-angle-right" aria-hidden="true"></i></span>',
  438. previous: '<span><i class="fa fa-angle-left" aria-hidden="true"></i></span>'
  439. }
  440. },
  441. createdRow: function (row, data, dataIndex) {
  442. $(row).find('td').addClass('text-left');
  443. if(data["no_prefix_produksi"] != null){
  444. $('td', row).eq(5).css('background-color', '#5cb85c');
  445. }
  446. },
  447. processing: true,
  448. serverSide: true,
  449. lengthMenu: [
  450. [10, 25, 50, -1],
  451. [10, 25, 50, "All"]
  452. ],
  453. ajax: url_ajax,
  454. columns: column
  455. });
  456. $(id_datatable).css("width", "100%");
  457. $(id_datatable).addClass("nowrap");
  458. $("select").removeClass("custom-select-sm");
  459. $("select").removeClass("custom-select");
  460. $(id_datatable).on('click', '.btn-delete', function (e) {
  461. e.preventDefault();
  462. var el = this;
  463. var route = $(this).attr("data-route");
  464. Swal.fire({
  465. title: "Apakah yakin hapus data ini ?",
  466. text: "Lanjutkan untuk menghapus",
  467. icon: "warning",
  468. showCancelButton: true,
  469. confirmButtonColor: '#DD6B55',
  470. confirmButtonText: 'Yes',
  471. }).then((result) => {
  472. $.ajaxSetup({
  473. headers: {
  474. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  475. }
  476. });
  477. if (result.value) {
  478. $.ajax({
  479. url: route,
  480. type: 'get', // replaced from put
  481. dataType: "JSON",
  482. beforeSend: function () {
  483. $.blockUI();
  484. },
  485. success: function (response) {
  486. if (response.status == true) {
  487. $(id_datatable).DataTable().ajax.reload();
  488. swal.fire("Deleted!", response.message, "success");
  489. } else {
  490. swal.fire("Failed!", response.message, "error");
  491. }
  492. $.unblockUI();
  493. },
  494. error: function (xhr) {
  495. console.log(xhr.responseText);
  496. }
  497. });
  498. };
  499. });
  500. });
  501. $(id_datatable).on('click', '.btn-musnahkan', function (e) {
  502. e.preventDefault();
  503. var el = this;
  504. var route = $(this).attr("data-route");
  505. Swal.fire({
  506. title: "Apakah yakin memusnahkan darah ini ?",
  507. text: "Lanjutkan untuk mengmemusnahkan",
  508. icon: "warning",
  509. showCancelButton: true,
  510. confirmButtonColor: '#DD6B55',
  511. confirmButtonText: 'Yes',
  512. }).then((result) => {
  513. $.ajaxSetup({
  514. headers: {
  515. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  516. }
  517. });
  518. if (result.value) {
  519. $.ajax({
  520. url: route,
  521. type: 'get', // replaced from put
  522. dataType: "JSON",
  523. beforeSend: function () {
  524. $.blockUI();
  525. },
  526. success: function (response) {
  527. if (response.status == true) {
  528. $(id_datatable).DataTable().ajax.reload();
  529. swal.fire("Berhasil!", response.message, "success");
  530. } else {
  531. swal.fire("Gagal!", response.message, "error");
  532. }
  533. $.unblockUI();
  534. },
  535. error: function (xhr) {
  536. console.log(xhr.responseText);
  537. }
  538. });
  539. };
  540. });
  541. });
  542. $(id_datatable).on('click', '.btn-pindahkerelease', function (e) {
  543. e.preventDefault();
  544. var el = this;
  545. var route = $(this).attr("data-route");
  546. Swal.fire({
  547. title: "Apakah yakin merelase darah ini ke SIDONI RS ?",
  548. text: "Lanjutkan untuk relaese",
  549. icon: "warning",
  550. showCancelButton: true,
  551. confirmButtonColor: '#DD6B55',
  552. confirmButtonText: 'Yes',
  553. }).then((result) => {
  554. $.ajaxSetup({
  555. headers: {
  556. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  557. }
  558. });
  559. if (result.value) {
  560. $.ajax({
  561. url: route,
  562. type: 'get', // replaced from put
  563. dataType: "JSON",
  564. beforeSend: function () {
  565. $.blockUI();
  566. },
  567. success: function (response) {
  568. if (response.status == true) {
  569. $(id_datatable).DataTable().ajax.reload();
  570. swal.fire("Berhasil!", response.message, "success");
  571. } else {
  572. swal.fire("Gagal!", response.message, "error");
  573. }
  574. $.unblockUI();
  575. },
  576. error: function (xhr) {
  577. console.log(xhr.responseText);
  578. }
  579. });
  580. };
  581. });
  582. });
  583. $(id_datatable).on('click', '.btn-pindah-gudang-aftap', function (e) {
  584. e.preventDefault();
  585. var el = this;
  586. var route = $(this).attr("data-route");
  587. Swal.fire({
  588. title: "Apakah yakin memindahkan ke gudang aftap ?",
  589. text: "Lanjutkan untuk memindahkan",
  590. icon: "warning",
  591. showCancelButton: true,
  592. confirmButtonColor: '#DD6B55',
  593. confirmButtonText: 'Yes',
  594. }).then((result) => {
  595. $.ajaxSetup({
  596. headers: {
  597. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  598. }
  599. });
  600. if (result.value) {
  601. $.ajax({
  602. url: route,
  603. type: 'get', // replaced from put
  604. dataType: "JSON",
  605. beforeSend: function () {
  606. $.blockUI();
  607. },
  608. success: function (response) {
  609. if (response.status == true) {
  610. $(id_datatable).DataTable().ajax.reload();
  611. swal.fire("Berhasil!", response.message, "success");
  612. } else {
  613. swal.fire("Gagal!", response.message, "error");
  614. }
  615. $.unblockUI();
  616. },
  617. error: function (xhr) {
  618. console.log(xhr.responseText);
  619. }
  620. });
  621. };
  622. });
  623. });
  624. $(id_datatable).on('click', '.btn-cancel', function (e) {
  625. e.preventDefault();
  626. var el = this;
  627. var route = $(this).attr("data-route");
  628. Swal.fire({
  629. title: "Apakah yakin membatalkan order ini ?",
  630. text: "Lanjutkan untuk membatalkan",
  631. icon: "warning",
  632. showCancelButton: true,
  633. confirmButtonColor: '#DD6B55',
  634. confirmButtonText: 'Yes',
  635. }).then((result) => {
  636. if (result.value) {
  637. $.ajax({
  638. url: route,
  639. type: 'get', // replaced from put
  640. dataType: "JSON",
  641. beforeSend: function () {
  642. $.blockUI();
  643. },
  644. success: function (response) {
  645. if (response.status == true) {
  646. $(id_datatable).DataTable().ajax.reload();
  647. swal.fire("Berhasil", response.message, "success");
  648. } else {
  649. swal.fire("Gagal!", response.message, "error");
  650. }
  651. $.unblockUI();
  652. },
  653. error: function (xhr) {
  654. console.log(xhr.responseText);
  655. }
  656. });
  657. };
  658. });
  659. });
  660. $(id_datatable).on('click', '.btn-masukan-stock-release', function (e) {
  661. e.preventDefault();
  662. var el = this;
  663. var route = $(this).attr("data-route");
  664. Swal.fire({
  665. title: "Apakah yakin memasukan ke Stock Release ?",
  666. text: "Lanjutkan untuk membatalkan",
  667. icon: "warning",
  668. showCancelButton: true,
  669. confirmButtonColor: '#DD6B55',
  670. confirmButtonText: 'Yes',
  671. }).then((result) => {
  672. if (result.value) {
  673. $.ajax({
  674. url: route,
  675. type: 'get', // replaced from put
  676. dataType: "JSON",
  677. beforeSend: function () {
  678. $.blockUI();
  679. },
  680. success: function (response) {
  681. if (response.status == true) {
  682. $(id_datatable).DataTable().ajax.reload();
  683. swal.fire("Berhasil", response.message, "success");
  684. } else {
  685. swal.fire("Gagal!", response.message, "error");
  686. }
  687. $.unblockUI();
  688. },
  689. error: function (xhr) {
  690. console.log(xhr.responseText);
  691. }
  692. });
  693. };
  694. });
  695. });
  696. $(id_datatable).on('click', '.btn-non-aktif-reagen', function (e) {
  697. e.preventDefault();
  698. var el = this;
  699. var route = $(this).attr("data-route");
  700. Swal.fire({
  701. title: "Apakah yakin menonaktifkan reagen ?",
  702. text: "Lanjutkan untuk menonaktifkan",
  703. icon: "warning",
  704. showCancelButton: true,
  705. confirmButtonColor: '#DD6B55',
  706. confirmButtonText: 'Yes',
  707. }).then((result) => {
  708. $.ajaxSetup({
  709. headers: {
  710. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  711. }
  712. });
  713. if (result.value) {
  714. $.ajax({
  715. url: route,
  716. type: 'get', // replaced from put
  717. dataType: "JSON",
  718. beforeSend: function () {
  719. $.blockUI();
  720. },
  721. success: function (response) {
  722. if (response.status == true) {
  723. $(id_datatable).DataTable().ajax.reload();
  724. swal.fire("Berhasil!", response.message, "success");
  725. } else {
  726. swal.fire("Gagal!", response.message, "error");
  727. }
  728. $.unblockUI();
  729. },
  730. error: function (xhr) {
  731. console.log(xhr.responseText);
  732. }
  733. });
  734. };
  735. });
  736. });
  737. $(id_datatable).on('click', '.btn-aktif-reagen', function (e) {
  738. e.preventDefault();
  739. var el = this;
  740. var route = $(this).attr("data-route");
  741. Swal.fire({
  742. title: "Apakah yakin mengaktifkan reagen ?",
  743. text: "Lanjutkan untuk mengaktifkan",
  744. icon: "warning",
  745. showCancelButton: true,
  746. confirmButtonColor: '#DD6B55',
  747. confirmButtonText: 'Yes',
  748. }).then((result) => {
  749. $.ajaxSetup({
  750. headers: {
  751. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  752. }
  753. });
  754. if (result.value) {
  755. $.ajax({
  756. url: route,
  757. type: 'get', // replaced from put
  758. dataType: "JSON",
  759. beforeSend: function () {
  760. $.blockUI();
  761. },
  762. success: function (response) {
  763. if (response.status == true) {
  764. $(id_datatable).DataTable().ajax.reload();
  765. swal.fire("Berhasil!", response.message, "success");
  766. } else {
  767. swal.fire("Gagal!", response.message, "error");
  768. }
  769. $.unblockUI();
  770. },
  771. error: function (xhr) {
  772. console.log(xhr.responseText);
  773. }
  774. });
  775. };
  776. });
  777. });
  778. $(id_datatable).on('click', '.btn-rotasi-selesai', function (e) {
  779. e.preventDefault();
  780. var el = this;
  781. var route = $(this).attr("data-route");
  782. Swal.fire({
  783. title: "Apakah yakin menyelesaikan rotasi ini ?",
  784. text: "Data rotasi selesai akan berada di list rotasi selesai",
  785. icon: "warning",
  786. showCancelButton: true,
  787. confirmButtonColor: '#DD6B55',
  788. confirmButtonText: 'Yes',
  789. }).then((result) => {
  790. $.ajaxSetup({
  791. headers: {
  792. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  793. }
  794. });
  795. if (result.value) {
  796. $.ajax({
  797. url: route,
  798. type: 'get', // replaced from put
  799. dataType: "JSON",
  800. beforeSend: function () {
  801. $.blockUI();
  802. },
  803. success: function (response) {
  804. if (response.status == true) {
  805. $(id_datatable).DataTable().ajax.reload();
  806. swal.fire("Berhasil!", response.message, "success");
  807. } else {
  808. swal.fire("Gagal!", response.message, "error");
  809. }
  810. $.unblockUI();
  811. },
  812. error: function (xhr) {
  813. console.log(xhr.responseText);
  814. }
  815. });
  816. };
  817. });
  818. });
  819. $(id_datatable).on('click', '.btn-finish-penapisan', function (e) {
  820. e.preventDefault();
  821. var el = this;
  822. var route = $(this).attr("data-route");
  823. Swal.fire({
  824. title: "Apakah yakin menyelesaikan Log Book ini ?",
  825. text: "Data Log book selesai akan berada di list Log Book",
  826. icon: "warning",
  827. showCancelButton: true,
  828. confirmButtonColor: '#DD6B55',
  829. confirmButtonText: 'Yes',
  830. }).then((result) => {
  831. $.ajaxSetup({
  832. headers: {
  833. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  834. }
  835. });
  836. if (result.value) {
  837. $.ajax({
  838. url: route,
  839. type: 'get', // replaced from put
  840. dataType: "JSON",
  841. beforeSend: function () {
  842. $.blockUI();
  843. },
  844. success: function (response) {
  845. if (response.status == true) {
  846. $(id_datatable).DataTable().ajax.reload();
  847. swal.fire("Berhasil!", response.message, "success");
  848. } else {
  849. swal.fire("Gagal!", response.message, "error");
  850. }
  851. $.unblockUI();
  852. },
  853. error: function (xhr) {
  854. console.log(xhr.responseText);
  855. }
  856. });
  857. };
  858. });
  859. });
  860. };
  861. var dataTableManajemenKantong = function (id_datatable, url_ajax, column) {
  862. var datatable = $(id_datatable).DataTable({
  863. language: {
  864. processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span> ',
  865. paginate: {
  866. next: '<span><i class="fa fa-angle-right" aria-hidden="true"></i></span>',
  867. previous: '<span><i class="fa fa-angle-left" aria-hidden="true"></i></span>'
  868. }
  869. },
  870. createdRow: function (row, data, dataIndex) {
  871. $(row).find('td').addClass('text-left');
  872. if(data["is_cetak"] == 'sudah'){
  873. $('td', row).eq(6).css('background-color', '#5cb85c');
  874. }
  875. },
  876. processing: true,
  877. serverSide: true,
  878. lengthMenu: [
  879. [10, 25, 50, -1],
  880. [10, 25, 50, "All"]
  881. ],
  882. ajax: url_ajax,
  883. columns: column
  884. });
  885. $(id_datatable).css("width", "100%");
  886. $(id_datatable).addClass("nowrap");
  887. $("select").removeClass("custom-select-sm");
  888. $("select").removeClass("custom-select");
  889. $(id_datatable).on('click', '.btn-delete', function (e) {
  890. e.preventDefault();
  891. var el = this;
  892. var route = $(this).attr("data-route");
  893. Swal.fire({
  894. title: "Apakah yakin hapus data ini ?",
  895. text: "Lanjutkan untuk menghapus",
  896. icon: "warning",
  897. showCancelButton: true,
  898. confirmButtonColor: '#DD6B55',
  899. confirmButtonText: 'Yes',
  900. }).then((result) => {
  901. $.ajaxSetup({
  902. headers: {
  903. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  904. }
  905. });
  906. if (result.value) {
  907. $.ajax({
  908. url: route,
  909. type: 'get', // replaced from put
  910. dataType: "JSON",
  911. beforeSend: function () {
  912. $.blockUI();
  913. },
  914. success: function (response) {
  915. if (response.status == true) {
  916. $(id_datatable).DataTable().ajax.reload();
  917. swal.fire("Deleted!", response.message, "success");
  918. } else {
  919. swal.fire("Failed!", response.message, "error");
  920. }
  921. $.unblockUI();
  922. },
  923. error: function (xhr) {
  924. console.log(xhr.responseText);
  925. }
  926. });
  927. };
  928. });
  929. });
  930. $(id_datatable).on('click', '.btn-musnahkan', function (e) {
  931. e.preventDefault();
  932. var el = this;
  933. var route = $(this).attr("data-route");
  934. Swal.fire({
  935. title: "Apakah yakin memusnahkan darah ini ?",
  936. text: "Lanjutkan untuk mengmemusnahkan",
  937. icon: "warning",
  938. showCancelButton: true,
  939. confirmButtonColor: '#DD6B55',
  940. confirmButtonText: 'Yes',
  941. }).then((result) => {
  942. $.ajaxSetup({
  943. headers: {
  944. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  945. }
  946. });
  947. if (result.value) {
  948. $.ajax({
  949. url: route,
  950. type: 'get', // replaced from put
  951. dataType: "JSON",
  952. beforeSend: function () {
  953. $.blockUI();
  954. },
  955. success: function (response) {
  956. if (response.status == true) {
  957. $(id_datatable).DataTable().ajax.reload();
  958. swal.fire("Berhasil!", response.message, "success");
  959. } else {
  960. swal.fire("Gagal!", response.message, "error");
  961. }
  962. $.unblockUI();
  963. },
  964. error: function (xhr) {
  965. console.log(xhr.responseText);
  966. }
  967. });
  968. };
  969. });
  970. });
  971. $(id_datatable).on('click', '.btn-pindahkerelease', function (e) {
  972. e.preventDefault();
  973. var el = this;
  974. var route = $(this).attr("data-route");
  975. Swal.fire({
  976. title: "Apakah yakin merelase darah ini ke SIDONI RS ?",
  977. text: "Lanjutkan untuk relaese",
  978. icon: "warning",
  979. showCancelButton: true,
  980. confirmButtonColor: '#DD6B55',
  981. confirmButtonText: 'Yes',
  982. }).then((result) => {
  983. $.ajaxSetup({
  984. headers: {
  985. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  986. }
  987. });
  988. if (result.value) {
  989. $.ajax({
  990. url: route,
  991. type: 'get', // replaced from put
  992. dataType: "JSON",
  993. beforeSend: function () {
  994. $.blockUI();
  995. },
  996. success: function (response) {
  997. if (response.status == true) {
  998. $(id_datatable).DataTable().ajax.reload();
  999. swal.fire("Berhasil!", response.message, "success");
  1000. } else {
  1001. swal.fire("Gagal!", response.message, "error");
  1002. }
  1003. $.unblockUI();
  1004. },
  1005. error: function (xhr) {
  1006. console.log(xhr.responseText);
  1007. }
  1008. });
  1009. };
  1010. });
  1011. });
  1012. $(id_datatable).on('click', '.btn-pindah-gudang-aftap', function (e) {
  1013. e.preventDefault();
  1014. var el = this;
  1015. var route = $(this).attr("data-route");
  1016. Swal.fire({
  1017. title: "Apakah yakin memindahkan ke gudang aftap ?",
  1018. text: "Lanjutkan untuk memindahkan",
  1019. icon: "warning",
  1020. showCancelButton: true,
  1021. confirmButtonColor: '#DD6B55',
  1022. confirmButtonText: 'Yes',
  1023. }).then((result) => {
  1024. $.ajaxSetup({
  1025. headers: {
  1026. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  1027. }
  1028. });
  1029. if (result.value) {
  1030. $.ajax({
  1031. url: route,
  1032. type: 'get', // replaced from put
  1033. dataType: "JSON",
  1034. beforeSend: function () {
  1035. $.blockUI();
  1036. },
  1037. success: function (response) {
  1038. if (response.status == true) {
  1039. $(id_datatable).DataTable().ajax.reload();
  1040. swal.fire("Berhasil!", response.message, "success");
  1041. } else {
  1042. swal.fire("Gagal!", response.message, "error");
  1043. }
  1044. $.unblockUI();
  1045. },
  1046. error: function (xhr) {
  1047. console.log(xhr.responseText);
  1048. }
  1049. });
  1050. };
  1051. });
  1052. });
  1053. $(id_datatable).on('click', '.btn-cancel', function (e) {
  1054. e.preventDefault();
  1055. var el = this;
  1056. var route = $(this).attr("data-route");
  1057. Swal.fire({
  1058. title: "Apakah yakin membatalkan order ini ?",
  1059. text: "Lanjutkan untuk membatalkan",
  1060. icon: "warning",
  1061. showCancelButton: true,
  1062. confirmButtonColor: '#DD6B55',
  1063. confirmButtonText: 'Yes',
  1064. }).then((result) => {
  1065. if (result.value) {
  1066. $.ajax({
  1067. url: route,
  1068. type: 'get', // replaced from put
  1069. dataType: "JSON",
  1070. beforeSend: function () {
  1071. $.blockUI();
  1072. },
  1073. success: function (response) {
  1074. if (response.status == true) {
  1075. $(id_datatable).DataTable().ajax.reload();
  1076. swal.fire("Berhasil", response.message, "success");
  1077. } else {
  1078. swal.fire("Gagal!", response.message, "error");
  1079. }
  1080. $.unblockUI();
  1081. },
  1082. error: function (xhr) {
  1083. console.log(xhr.responseText);
  1084. }
  1085. });
  1086. };
  1087. });
  1088. });
  1089. $(id_datatable).on('click', '.btn-masukan-stock-release', function (e) {
  1090. e.preventDefault();
  1091. var el = this;
  1092. var route = $(this).attr("data-route");
  1093. Swal.fire({
  1094. title: "Apakah yakin memasukan ke Stock Release ?",
  1095. text: "Lanjutkan untuk membatalkan",
  1096. icon: "warning",
  1097. showCancelButton: true,
  1098. confirmButtonColor: '#DD6B55',
  1099. confirmButtonText: 'Yes',
  1100. }).then((result) => {
  1101. if (result.value) {
  1102. $.ajax({
  1103. url: route,
  1104. type: 'get', // replaced from put
  1105. dataType: "JSON",
  1106. beforeSend: function () {
  1107. $.blockUI();
  1108. },
  1109. success: function (response) {
  1110. if (response.status == true) {
  1111. $(id_datatable).DataTable().ajax.reload();
  1112. swal.fire("Berhasil", response.message, "success");
  1113. } else {
  1114. swal.fire("Gagal!", response.message, "error");
  1115. }
  1116. $.unblockUI();
  1117. },
  1118. error: function (xhr) {
  1119. console.log(xhr.responseText);
  1120. }
  1121. });
  1122. };
  1123. });
  1124. });
  1125. $(id_datatable).on('click', '.btn-non-aktif-reagen', function (e) {
  1126. e.preventDefault();
  1127. var el = this;
  1128. var route = $(this).attr("data-route");
  1129. Swal.fire({
  1130. title: "Apakah yakin menonaktifkan reagen ?",
  1131. text: "Lanjutkan untuk menonaktifkan",
  1132. icon: "warning",
  1133. showCancelButton: true,
  1134. confirmButtonColor: '#DD6B55',
  1135. confirmButtonText: 'Yes',
  1136. }).then((result) => {
  1137. $.ajaxSetup({
  1138. headers: {
  1139. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  1140. }
  1141. });
  1142. if (result.value) {
  1143. $.ajax({
  1144. url: route,
  1145. type: 'get', // replaced from put
  1146. dataType: "JSON",
  1147. beforeSend: function () {
  1148. $.blockUI();
  1149. },
  1150. success: function (response) {
  1151. if (response.status == true) {
  1152. $(id_datatable).DataTable().ajax.reload();
  1153. swal.fire("Berhasil!", response.message, "success");
  1154. } else {
  1155. swal.fire("Gagal!", response.message, "error");
  1156. }
  1157. $.unblockUI();
  1158. },
  1159. error: function (xhr) {
  1160. console.log(xhr.responseText);
  1161. }
  1162. });
  1163. };
  1164. });
  1165. });
  1166. $(id_datatable).on('click', '.btn-aktif-reagen', function (e) {
  1167. e.preventDefault();
  1168. var el = this;
  1169. var route = $(this).attr("data-route");
  1170. Swal.fire({
  1171. title: "Apakah yakin mengaktifkan reagen ?",
  1172. text: "Lanjutkan untuk mengaktifkan",
  1173. icon: "warning",
  1174. showCancelButton: true,
  1175. confirmButtonColor: '#DD6B55',
  1176. confirmButtonText: 'Yes',
  1177. }).then((result) => {
  1178. $.ajaxSetup({
  1179. headers: {
  1180. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  1181. }
  1182. });
  1183. if (result.value) {
  1184. $.ajax({
  1185. url: route,
  1186. type: 'get', // replaced from put
  1187. dataType: "JSON",
  1188. beforeSend: function () {
  1189. $.blockUI();
  1190. },
  1191. success: function (response) {
  1192. if (response.status == true) {
  1193. $(id_datatable).DataTable().ajax.reload();
  1194. swal.fire("Berhasil!", response.message, "success");
  1195. } else {
  1196. swal.fire("Gagal!", response.message, "error");
  1197. }
  1198. $.unblockUI();
  1199. },
  1200. error: function (xhr) {
  1201. console.log(xhr.responseText);
  1202. }
  1203. });
  1204. };
  1205. });
  1206. });
  1207. $(id_datatable).on('click', '.btn-rotasi-selesai', function (e) {
  1208. e.preventDefault();
  1209. var el = this;
  1210. var route = $(this).attr("data-route");
  1211. Swal.fire({
  1212. title: "Apakah yakin menyelesaikan rotasi ini ?",
  1213. text: "Data rotasi selesai akan berada di list rotasi selesai",
  1214. icon: "warning",
  1215. showCancelButton: true,
  1216. confirmButtonColor: '#DD6B55',
  1217. confirmButtonText: 'Yes',
  1218. }).then((result) => {
  1219. $.ajaxSetup({
  1220. headers: {
  1221. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  1222. }
  1223. });
  1224. if (result.value) {
  1225. $.ajax({
  1226. url: route,
  1227. type: 'get', // replaced from put
  1228. dataType: "JSON",
  1229. beforeSend: function () {
  1230. $.blockUI();
  1231. },
  1232. success: function (response) {
  1233. if (response.status == true) {
  1234. $(id_datatable).DataTable().ajax.reload();
  1235. swal.fire("Berhasil!", response.message, "success");
  1236. } else {
  1237. swal.fire("Gagal!", response.message, "error");
  1238. }
  1239. $.unblockUI();
  1240. },
  1241. error: function (xhr) {
  1242. console.log(xhr.responseText);
  1243. }
  1244. });
  1245. };
  1246. });
  1247. });
  1248. $(id_datatable).on('click', '.btn-finish-penapisan', function (e) {
  1249. e.preventDefault();
  1250. var el = this;
  1251. var route = $(this).attr("data-route");
  1252. Swal.fire({
  1253. title: "Apakah yakin menyelesaikan Log Book ini ?",
  1254. text: "Data Log book selesai akan berada di list Log Book",
  1255. icon: "warning",
  1256. showCancelButton: true,
  1257. confirmButtonColor: '#DD6B55',
  1258. confirmButtonText: 'Yes',
  1259. }).then((result) => {
  1260. $.ajaxSetup({
  1261. headers: {
  1262. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  1263. }
  1264. });
  1265. if (result.value) {
  1266. $.ajax({
  1267. url: route,
  1268. type: 'get', // replaced from put
  1269. dataType: "JSON",
  1270. beforeSend: function () {
  1271. $.blockUI();
  1272. },
  1273. success: function (response) {
  1274. if (response.status == true) {
  1275. $(id_datatable).DataTable().ajax.reload();
  1276. swal.fire("Berhasil!", response.message, "success");
  1277. } else {
  1278. swal.fire("Gagal!", response.message, "error");
  1279. }
  1280. $.unblockUI();
  1281. },
  1282. error: function (xhr) {
  1283. console.log(xhr.responseText);
  1284. }
  1285. });
  1286. };
  1287. });
  1288. });
  1289. };
  1290. var datatablePost = function (id_datatable, url_ajax, column, param) {
  1291. // console.log(id_datatable)
  1292. // console.log(id_datatable);
  1293. var datatable = $(id_datatable).DataTable({
  1294. language: {
  1295. processing: '<i class="fa fa-spinner fa-spin fa-3x fa-fw"></i><span class="sr-only">Loading...</span> ',
  1296. paginate: {
  1297. next: '<span><i class="fa fa-angle-right" aria-hidden="true"></i></span>',
  1298. previous: '<span><i class="fa fa-angle-left" aria-hidden="true"></i></span>'
  1299. }
  1300. },
  1301. createdRow: function (row, data, dataIndex) {
  1302. $(row).find('td').addClass('text-left');
  1303. },
  1304. processing: true,
  1305. serverSide: true,
  1306. destroy: true,
  1307. searching: false,
  1308. lengthMenu: [
  1309. [10, 25, 50, -1],
  1310. [10, 25, 50, "All"]
  1311. ],
  1312. ajax: {
  1313. url: url_ajax,
  1314. type: 'get',
  1315. headers: {
  1316. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  1317. },
  1318. data: param,
  1319. },
  1320. columns: column,
  1321. });
  1322. $(id_datatable).css("width", "100%");
  1323. $(id_datatable).addClass("nowrap");
  1324. $("select").removeClass("custom-select-sm");
  1325. $("select").removeClass("custom-select");
  1326. $(id_datatable).on('click', '.btn-delete', function (e) {
  1327. e.preventDefault();
  1328. var el = this;
  1329. var route = $(this).attr("data-route");
  1330. Swal.fire({
  1331. title: "Apakah yakin hapus data ini ?",
  1332. text: "Lanjutkan untuk menghapus",
  1333. icon: "warning",
  1334. showCancelButton: true,
  1335. confirmButtonColor: '#DD6B55',
  1336. confirmButtonText: 'Yes',
  1337. }).then((result) => {
  1338. $.ajaxSetup({
  1339. headers: {
  1340. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  1341. }
  1342. });
  1343. if (result.value) {
  1344. $.ajax({
  1345. url: route,
  1346. type: 'get', // replaced from put
  1347. dataType: "JSON",
  1348. beforeSend: function () {
  1349. $.blockUI();
  1350. },
  1351. success: function (response) {
  1352. if (response.status == true) {
  1353. $(id_datatable).DataTable().ajax.reload();
  1354. swal.fire("Deleted!", response.message, "success");
  1355. } else {
  1356. swal.fire("Failed!", response.message, "error");
  1357. }
  1358. $.unblockUI();
  1359. },
  1360. error: function (xhr) {
  1361. console.log(xhr.responseText);
  1362. }
  1363. });
  1364. };
  1365. });
  1366. });
  1367. $(id_datatable).on('click', '.btn-musnahkan', function (e) {
  1368. e.preventDefault();
  1369. var el = this;
  1370. var route = $(this).attr("data-route");
  1371. Swal.fire({
  1372. title: "Apakah yakin memusnahkan darah ini ?",
  1373. text: "Lanjutkan untuk mengmemusnahkan",
  1374. icon: "warning",
  1375. showCancelButton: true,
  1376. confirmButtonColor: '#DD6B55',
  1377. confirmButtonText: 'Yes',
  1378. }).then((result) => {
  1379. $.ajaxSetup({
  1380. headers: {
  1381. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  1382. }
  1383. });
  1384. if (result.value) {
  1385. $.ajax({
  1386. url: route,
  1387. type: 'get', // replaced from put
  1388. dataType: "JSON",
  1389. beforeSend: function () {
  1390. $.blockUI();
  1391. },
  1392. success: function (response) {
  1393. if (response.status == true) {
  1394. $(id_datatable).DataTable().ajax.reload();
  1395. swal.fire("Berhasil!", response.message, "success");
  1396. } else {
  1397. swal.fire("Gagal!", response.message, "error");
  1398. }
  1399. $.unblockUI();
  1400. },
  1401. error: function (xhr) {
  1402. console.log(xhr.responseText);
  1403. }
  1404. });
  1405. };
  1406. });
  1407. });
  1408. $(id_datatable).on('click', '.btn-cancel', function (e) {
  1409. e.preventDefault();
  1410. var el = this;
  1411. var route = $(this).attr("data-route");
  1412. Swal.fire({
  1413. title: "Apakah yakin membatalkan order ini ?",
  1414. text: "Lanjutkan untuk membatalkan",
  1415. icon: "warning",
  1416. showCancelButton: true,
  1417. confirmButtonColor: '#DD6B55',
  1418. confirmButtonText: 'Yes',
  1419. }).then((result) => {
  1420. if (result.value) {
  1421. $.ajax({
  1422. url: route,
  1423. type: 'get', // replaced from put
  1424. dataType: "JSON",
  1425. beforeSend: function () {
  1426. $.blockUI();
  1427. },
  1428. success: function (response) {
  1429. if (response.status == true) {
  1430. $(id_datatable).DataTable().ajax.reload();
  1431. swal.fire("Berhasil", response.message, "success");
  1432. } else {
  1433. swal.fire("Gagal!", response.message, "error");
  1434. }
  1435. $.unblockUI();
  1436. },
  1437. error: function (xhr) {
  1438. console.log(xhr.responseText);
  1439. }
  1440. });
  1441. };
  1442. });
  1443. });
  1444. };
  1445. return {
  1446. // public functions
  1447. init_datatable: function (id_datatable, url_ajax, column) {
  1448. datatablenya(id_datatable, url_ajax, column);
  1449. },
  1450. init_datatable_post: function (id_datatable, url_ajax, column, param) {
  1451. datatablePost(id_datatable, url_ajax, column, param);
  1452. },
  1453. init_datatable_list: function (id_datatable, url_ajax, column, param) {
  1454. datatableList(id_datatable, url_ajax, column, param);
  1455. },
  1456. init_datatable_manajemen_kantong: function (id_datatable, url_ajax, column, param) {
  1457. dataTableManajemenKantong(id_datatable, url_ajax, column, param);
  1458. },
  1459. };
  1460. }();