Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.59 KB | None | 0 0
  1. <script type="text/javascript">
  2.  
  3. function modaledit(RoomTypeID, NamaRoomType, Status, BaseAdult, BaseChild, MaxAdult, MaxChild, Banquet, EditType){
  4. // untuk edit, 1=edit, 2=hapus
  5. $('#edit-tipe').val(EditType);
  6. $('#namaRoomType').val('');
  7. $('#baseAdult').val('');
  8. $('#maxAdult').val('');
  9. $('#baseChild').val('');
  10. $('#maxChild').val('');
  11. $('#banquet').val('');
  12. $('#status').val('');
  13. if(EditType==1){
  14. $('#btn-simpan').show();
  15. $('#btn-hapus').hide();
  16. }
  17. if(EditType==2){
  18. $('#btn-hapus').show();
  19. $('#btn-simpan').hide();
  20. }
  21. $('#modal-tambah').modal('show');
  22. $('#namaRoomType').val(NamaRoomType);
  23. $('#baseAdult').val(BaseAdult);
  24. $('#maxAdult').val(MaxAdult);
  25. $('#baseChild').val(BaseChild);
  26. $('#maxChild').val(MaxChild);
  27. $('#banquet').val(Banquet);
  28. $('#status').val(Status);
  29. $('#edit-id').val(RoomTypeID);
  30. }
  31.  
  32. var table;
  33. $(document).ready(function() {
  34.  
  35. $('#btn-tambah-type').click(function(){
  36. $('#edit-tipe').val('0');
  37. $('#edit-id').val('');
  38. $('#form-pesan-tambah').html('');
  39. $('#namaRoomType').val('');
  40. $('#baseAdult').val('');
  41. $('#maxAdult').val('');
  42. $('#baseChild').val('');
  43. $('#maxChild').val('');
  44. $('#banquet').val('');
  45. $('#status').val('');
  46. $('#btn-hapus').hide();
  47. $('#btn-simpan').show();
  48. $('#modal-tambah').modal('show');
  49. });
  50.  
  51. //datatables
  52. table = $('#table-roomtype').DataTable({
  53.  
  54. "lengthMenu": [[10, 25, 50, -1], [ 10, 25, 50, "All"]],
  55. "dom": 'Bfrtip',
  56. "buttons": [
  57. /* 'pageLength','copy','csv','excel','pdfHtml5','print' */
  58. {
  59. "extend": 'pageLength',
  60. },
  61. {
  62. "extend": 'copy',
  63. },
  64. {
  65. "extend": 'csv',
  66. },
  67. {
  68. "extend": 'excel',
  69. },
  70. {
  71. "extend": 'pdf',
  72. "orientation": 'landscape',
  73. "pageSize": 'A4',
  74. },
  75. {
  76. "extend": 'print',
  77. },
  78. ],
  79. "responsive": true,
  80. "processing": false, //Feature control the processing indicator.
  81. "serverSide": true, //Feature control DataTables' server-side processing mode.
  82. "order": [], //Initial no order.
  83. // Load data for the table's content from an Ajax source
  84. "ajax": {
  85. "url": "<?php echo site_url('room_type/ajax_list')?>",
  86. "type": "POST",
  87. "data": function ( data ) {
  88.  
  89. }
  90. },
  91.  
  92.  
  93.  
  94. //Set column definition initialisation properties.
  95. "columnDefs": [
  96. {
  97. "responsivePriority" : 1,
  98. "targets": [0], //first column / numbering column
  99. "orderable": false, //set not orderable
  100. },
  101. {
  102. "responsivePriority" : 2,
  103. "targets": [1], //first column / numbering column
  104. "orderable": false, //set not orderable
  105. },
  106. {
  107. "responsivePriority" : 3,
  108. "targets": [2], //first column / numbering column
  109. "orderable": true, //set not orderable
  110. },
  111. {
  112. "responsivePriority" : 4,
  113. "targets": [3], //first column / numbering column
  114. "orderable": false, //set not orderable
  115. },
  116. {
  117. "responsivePriority" : 5,
  118. "targets": [4], //first column / numbering column
  119. "orderable": false, //set not orderable
  120. },
  121. {
  122. "responsivePriority" : 6,
  123. "targets": [5], //first column / numbering column
  124. "orderable": false, //set not orderable
  125. },
  126. {
  127. "responsivePriority" : 7,
  128. "targets": [6], //first column / numbering column
  129. "orderable": false, //set not orderable
  130. },
  131. {
  132. "responsivePriority" : 8,
  133. "targets": [7], //first column / numbering column
  134. "orderable": false, //set not orderable
  135. },
  136.  
  137. ],
  138.  
  139. });
  140. // Edit
  141. $('#btn-edit').click(function(){
  142. $('#form-tambah').submit();
  143. });
  144. $('#btn-hapus').click(function(){
  145. $('#form-tambah').submit();
  146. });
  147.  
  148. //Tambah
  149. $('#btn-simpan').click(function(){
  150. $('#form-tambah').submit();
  151. $('#btn-simpan').addClass('disabled');
  152. });
  153. $('#form-tambah').submit(function(){
  154. $.ajax({
  155. url:"<?php echo site_url()?>room_type/simpan",
  156. type:"POST",
  157. data:$('#form-tambah').serialize(),
  158. cache: false,
  159. success:function(respon){
  160. var obj = $.parseJSON(respon);
  161. if(obj.status==1){
  162. if(obj.tipe==0){
  163. $('#form-pesan-tambah').html(pesan_succ('Room Type berhasil disimpan !'));
  164. }
  165. if(obj.tipe==1){
  166. $('#form-pesan-tambah').html(pesan_succ('Room Type berhasil diupdate !'));
  167. }
  168. if(obj.tipe==2){
  169. $('#form-pesan-tambah').html(pesan_succ('Room Type berhasil dihapus !'));
  170. }
  171. setTimeout(function(){$('#form-pesan-tambah').html('')}, 2000);
  172. setTimeout(function(){$('#modal-tambah').modal('hide')}, 2500);
  173. setTimeout(function(){ table.ajax.reload(null,false) }, 2500);
  174. }else{
  175. $('#form-pesan-tambah').html(pesan_err(obj.error));
  176. setTimeout(function(){$('#form-pesan-tambah').html('')}, 2000);
  177. }
  178.  
  179. $('#btn-simpan').removeClass('disabled');
  180. }
  181. });
  182. return false;
  183. });
  184.  
  185.  
  186.  
  187.  
  188. });
  189. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement