Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function modaledit(RoomTypeID, NamaRoomType, Status, BaseAdult, BaseChild, MaxAdult, MaxChild, Banquet, EditType){
- // untuk edit, 1=edit, 2=hapus
- $('#edit-tipe').val(EditType);
- $('#namaRoomType').val('');
- $('#baseAdult').val('');
- $('#maxAdult').val('');
- $('#baseChild').val('');
- $('#maxChild').val('');
- $('#banquet').val('');
- $('#status').val('');
- if(EditType==1){
- $('#btn-simpan').show();
- $('#btn-hapus').hide();
- }
- if(EditType==2){
- $('#btn-hapus').show();
- $('#btn-simpan').hide();
- }
- $('#modal-tambah').modal('show');
- $('#namaRoomType').val(NamaRoomType);
- $('#baseAdult').val(BaseAdult);
- $('#maxAdult').val(MaxAdult);
- $('#baseChild').val(BaseChild);
- $('#maxChild').val(MaxChild);
- $('#banquet').val(Banquet);
- $('#status').val(Status);
- $('#edit-id').val(RoomTypeID);
- }
- var table;
- $(document).ready(function() {
- $('#btn-tambah-type').click(function(){
- $('#edit-tipe').val('0');
- $('#edit-id').val('');
- $('#form-pesan-tambah').html('');
- $('#namaRoomType').val('');
- $('#baseAdult').val('');
- $('#maxAdult').val('');
- $('#baseChild').val('');
- $('#maxChild').val('');
- $('#banquet').val('');
- $('#status').val('');
- $('#btn-hapus').hide();
- $('#btn-simpan').show();
- $('#modal-tambah').modal('show');
- });
- //datatables
- table = $('#table-roomtype').DataTable({
- "lengthMenu": [[10, 25, 50, -1], [ 10, 25, 50, "All"]],
- "dom": 'Bfrtip',
- "buttons": [
- /* 'pageLength','copy','csv','excel','pdfHtml5','print' */
- {
- "extend": 'pageLength',
- },
- {
- "extend": 'copy',
- },
- {
- "extend": 'csv',
- },
- {
- "extend": 'excel',
- },
- {
- "extend": 'pdf',
- "orientation": 'landscape',
- "pageSize": 'A4',
- },
- {
- "extend": 'print',
- },
- ],
- "responsive": true,
- "processing": false, //Feature control the processing indicator.
- "serverSide": true, //Feature control DataTables' server-side processing mode.
- "order": [], //Initial no order.
- // Load data for the table's content from an Ajax source
- "ajax": {
- "url": "<?php echo site_url('room_type/ajax_list')?>",
- "type": "POST",
- "data": function ( data ) {
- }
- },
- //Set column definition initialisation properties.
- "columnDefs": [
- {
- "responsivePriority" : 1,
- "targets": [0], //first column / numbering column
- "orderable": false, //set not orderable
- },
- {
- "responsivePriority" : 2,
- "targets": [1], //first column / numbering column
- "orderable": false, //set not orderable
- },
- {
- "responsivePriority" : 3,
- "targets": [2], //first column / numbering column
- "orderable": true, //set not orderable
- },
- {
- "responsivePriority" : 4,
- "targets": [3], //first column / numbering column
- "orderable": false, //set not orderable
- },
- {
- "responsivePriority" : 5,
- "targets": [4], //first column / numbering column
- "orderable": false, //set not orderable
- },
- {
- "responsivePriority" : 6,
- "targets": [5], //first column / numbering column
- "orderable": false, //set not orderable
- },
- {
- "responsivePriority" : 7,
- "targets": [6], //first column / numbering column
- "orderable": false, //set not orderable
- },
- {
- "responsivePriority" : 8,
- "targets": [7], //first column / numbering column
- "orderable": false, //set not orderable
- },
- ],
- });
- // Edit
- $('#btn-edit').click(function(){
- $('#form-tambah').submit();
- });
- $('#btn-hapus').click(function(){
- $('#form-tambah').submit();
- });
- //Tambah
- $('#btn-simpan').click(function(){
- $('#form-tambah').submit();
- $('#btn-simpan').addClass('disabled');
- });
- $('#form-tambah').submit(function(){
- $.ajax({
- url:"<?php echo site_url()?>room_type/simpan",
- type:"POST",
- data:$('#form-tambah').serialize(),
- cache: false,
- success:function(respon){
- var obj = $.parseJSON(respon);
- if(obj.status==1){
- if(obj.tipe==0){
- $('#form-pesan-tambah').html(pesan_succ('Room Type berhasil disimpan !'));
- }
- if(obj.tipe==1){
- $('#form-pesan-tambah').html(pesan_succ('Room Type berhasil diupdate !'));
- }
- if(obj.tipe==2){
- $('#form-pesan-tambah').html(pesan_succ('Room Type berhasil dihapus !'));
- }
- setTimeout(function(){$('#form-pesan-tambah').html('')}, 2000);
- setTimeout(function(){$('#modal-tambah').modal('hide')}, 2500);
- setTimeout(function(){ table.ajax.reload(null,false) }, 2500);
- }else{
- $('#form-pesan-tambah').html(pesan_err(obj.error));
- setTimeout(function(){$('#form-pesan-tambah').html('')}, 2000);
- }
- $('#btn-simpan').removeClass('disabled');
- }
- });
- return false;
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement