function pPimpinan(){ var ds_jabatan = store_jabatan(); var fields_Pimpinan = RH.storeFields('idpimpinan','kode','kdprodi','nomer','nip','nmpimpinan','jabatan','gelar', 'catatan','idstatus','kdfakultas','nmfakultas','nmjabatan'); var pageSize = 20; var ds_Pimpinan = RH.JsonStore({ url : BASE_URL + 'pimpinan_controller/get_pimpinan', fields : fields_Pimpinan, limit: pageSize, enableSearch: true, }); //SEARCH COMPONENT var sb_Pimpinan = RH.searchComp({ id : 'sb_pimpinan', fields : ['nip:NIP', 'nmpimpinan:Nama'], selected : 'nip', store : ds_Pimpinan }); var cm_Pimpinan = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header: 'NIDU/ NIP',width: 100, dataIndex: 'nip', sortable: true }, { header: 'Nama',width: 250, dataIndex: 'nmpimpinan', sortable: true }, { header: 'Jabatan',width: 100, dataIndex: 'nmjabatan', sortable: true }, { header: 'Gelar',width: 250, dataIndex: 'gelar', sortable: true }, { header: 'Fakultas',width: 250, dataIndex: 'nmfakultas', sortable: true }, RH.EditColumn(), RH.DeleteColumn() ] ); /** THE GRID */ var gp_Pimpinan = RH.GridPanel_T1({ ds: ds_Pimpinan, cm: cm_Pimpinan, singleSelect: true, searchComp: sb_Pimpinan, allowAdd: true, fnAdd: fnAddPimpinan, pageSize: pageSize, cellclick: onCellPimpinanClick }); var fp_Pimpinan = RH.GPContainer1({ title: 'Pimpinan', iconCls:'silk-user', gridPanel: gp_Pimpinan, }); SET_PAGE_CONTENT(fp_Pimpinan); /** FUNCTIONS */ function onCellPimpinanClick(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.EditClick(e, function(){fnEditPimpinan(grid, record)}); RH.DeleteClick(e, function(){fnDeletePimpinan(grid, record)}); //RH.PrintClick(e, function(){fnPrintPimpinan(grid, record)}); } function reloadPimpinan(){ ds_Pimpinan.reload(); } function fnAddPimpinan(){ var grid = gp_Pimpinan; wform_Pimpinan(false, grid, null); } //function fnPrintPimpinan(grid, record){ // // var nim = record.data['nim'] // RH.ShowReport(BASE_URL + 'surat/surat_observasi/get_surat_observasi/' // +nim); // // } function fnEditPimpinan(grid, record){ wform_Pimpinan(true, grid, record); } function fnDeletePimpinan(grid, record){ var url = BASE_URL + 'pimpinan_controller/delete_pimpinan'; var params = new Object({ idpimpinan : record.data['idpimpinan'] }); RH.deleteGridRecord(url, params, grid ); } /* DATA STORE */ //fakultas var ds_fakultas = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_fakultas', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "kdfakultas", mapping: "kdfakultas" } , { name: "nmfakultas", mapping: "nmfakultas" } ], listeners : { load : function() { var rec = new this.recordType({kdfakultas:null, nmfakultas:'-'}); rec.commit(); this.add(rec); } } }); //status var ds_status = new Ext.data.JsonStore({ //from database proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_status', method: 'POST' }), autoLoad: true, root: 'data', fields: [ { name: "idstatus", mapping: "idstatus" } , { name: "nmstatus", mapping: "nmstatus" } ] }); function wform_Pimpinan(isUpdate, grid, record){ var winTitle = (isUpdate)?'Pimpinan (Edit)':'Pimpinan (Entry)'; var Pimpinan_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.Pimpinan', buttonAlign: 'left', labelWidth: 200, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 300, width: 600, autoScroll: true, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'idpimpinan', hidden: true, }, { store: ds_jabatan, xtype: 'combo', id: 'cb.jabatan', fieldLabel: 'Jabatan', triggerAction: 'all', valueField: 'idjabatan', displayField: 'nmjabatan', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, editable: false, allowBlank: true, listeners:{ select: function() { var rekdek = Ext.getCmp('cb.jabatan').getRawValue(); if (rekdek == "Rektor" || rekdek == "Wakil Rektor I" || rekdek == "Wakil Rektor II" || rekdek == "Wakil Rektor III"){ Ext.getCmp('cb.frm.fakultas').disable(); Ext.getCmp('cb.frm.fakultas').setValue(''); } else if (rekdek == "Dekan" || rekdek == "Wakil Dekan") { Ext.getCmp('cb.frm.fakultas').enable(); } } } }, { xtype: 'combo', id: 'cb.frm.fakultas', fieldLabel: 'Fakultas', store: ds_fakultas, triggerAction: 'all', valueField: 'kdfakultas', displayField: 'nmfakultas', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, editable: false, listeners:{ select: function() { Ext.getCmp('idnip').setValue(''); Ext.getCmp('idnm').setValue(''); } } }, { xtype: 'compositefield', name: 'nidu', fieldLabel: 'NIDU/ NIP', id: 'nidu', items: [{ id: 'idnip', xtype:'textfield', fieldLabel: 'NIDU', width: 197, readOnly: true, }, { xtype: 'button', fieldLabel: 'Cari', hidden:false, labelStyle: 'width:160px', id: 'btncari', name: 'btncari', width: 50, handler: function() { lookup_dosen_P(); } }] }, /* { id: 'idnip', fieldLabel: 'NIP', width: 250, allowBlank: true, }, */ { id: 'idnm', fieldLabel: 'Nama', width: 250, allowBlank: true, readOnly: false, }, { xtype: 'combo', id: 'cb.frm.status', fieldLabel: 'Status', store: ds_status, triggerAction: 'all', valueField: 'idstatus', displayField: 'nmstatus', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, editable: false }, { id: 'idgelar', fieldLabel: 'Gelar', width: 250, allowBlank: true, }, { xtype: 'textarea', id: 'idcatatan', fieldLabel: 'catatan', width: 250, allowBlank: true, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSavePimpinan(); } }, { text: 'Kembali', iconCls:'', handler: function() { wPimpinan.close(); } }] }); var wPimpinan = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [Pimpinan_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setPimpinan(isUpdate, record); wPimpinan.show(); /** FORM FUNCTIONS */ function setPimpinan(isUpdate, record){ if(isUpdate){ if(record != null){ RH.setCompValue('idpimpinan', record.data['idpimpinan']); RH.setCompValue('cb.jabatan', record.data['jabatan']); RH.setCompValue('idnip', record.data['nip']); RH.setCompValue('idnm', record.data['nmpimpinan']); RH.setCompValue('cb.frm.fakultas', record.data['kdfakultas']); RH.setCompValue('cb.frm.status', record.data['idstatus']); RH.setCompValue('idgelar', record.data['gelar']); RH.setCompValue('idcatatan', record.data['catatan']); return; } } } function fnSavePimpinan(){ var idForm = 'frm.Pimpinan'; var sUrl = BASE_URL +'pimpinan_controller/insert_pimpinan'; var sParams = getInsertPimpinanParams(); var msgWait = 'Tunggu, sedang proses menyimpan...'; var msgSuccess = 'Tambah data berhasil'; var msgFail = 'Tambah data gagal'; var msgInvalid = 'Data belum valid (data primer belum terisi)!'; if(isUpdate){ sUrl = BASE_URL +'pimpinan_controller/update_pimpinan'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wPimpinan, msgWait, msgSuccess, msgFail, msgInvalid); } function getInsertPimpinanParams(){ return new Object({ idpimpinan : RH.getCompValue('idpimpinan'), jabatan : RH.getCompValue('cb.jabatan'), idnip : RH.getCompValue('idnip'), idnm : RH.getCompValue('idnm'), kdfakultas : RH.getCompValue('cb.frm.fakultas'), idstatus : RH.getCompValue('cb.frm.status'), gelar : RH.getCompValue('idgelar'), catatan : RH.getCompValue('idcatatan'), }); } //DOSEN MHS function lookup_dosen_P(){ var ds_dosen = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'data_controller/get_dosenP', method: 'POST' }), baseParams: {kdfakultas:RH.getCompValue('cb.frm.fakultas')}, autoLoad: true, root: 'data', totalProperty: 'results', fields: [{ name: 'nidu', mapping: 'nidu' },{ name: 'nidn', mapping: 'nidn' },{ name: 'nmdosdgngelar', mapping: 'nmdosdgngelar' },{ name: 'nmfakultas', mapping: 'nmfakultas' },{ name: 'kdjnskelamin', mapping: 'kdjnskelamin' }] }); var cm_dosen = new Ext.grid.ColumnModel([{ header: 'NIDU/ NIP', width: 70, dataIndex: 'nidu', sortable: true }, { header: 'NIDN', width: 100, dataIndex: 'nidn', sortable: true }, { header: 'Nama Dosen', width: 230, dataIndex: 'nmdosdgngelar', sortable: true }, { header: 'L/P', width: 50, dataIndex: 'kdjnskelamin', sortable: true }, { header: 'Fakultas', width: 200, dataIndex: 'nmfakultas', sortable: true }] ); var sm_dosen = new Ext.grid.RowSelectionModel({ singleSelect: true }); var vw_dosen = new Ext.grid.GridView({ emptyText: '< Belum ada Data >' }); var paging_dosen = new Ext.PagingToolbar({ pageSize: 50, store: ds_dosen, displayInfo: true, displayMsg: 'Data Dari {0} - {1} of {2}', emptyMsg: 'No data to display' }); var cari_dosen = [new Ext.ux.grid.Search({ iconCls: 'btn_search', minChars: 1, autoFocus: true, position: 'top', mode: 'local', width: 200 })]; var sb_cari_dosen = RH.searchComp({ id : 'sb_cari_dosen', fields : ['nidu:NIDU/ NIP', 'nidn:NIDN', 'nmdosdgngelar:Nama Dosen', 'kdjnskelamin:L/P', 'nmfakultas:Fakultas'], selected : 'nidu', store : ds_dosen }); var grid_find_dosen = new Ext.grid.GridPanel({ ds: ds_dosen, cm: cm_dosen, sm: sm_dosen, view: vw_dosen, height: 350, width: 550, //plugins: cari_dosen, autoSizeColumns: true, enableColumnResize: true, enableColumnHide: false, enableColumnMove: false, enableHdaccess: false, columnLines: true, loadMask: true, buttonAlign: 'left', layout: 'anchor', anchorSize: { width: 550, height: 550 }, tbar: [sb_cari_dosen], bbar: paging_dosen, listeners: { rowdblclick: dobelklikdosen } }); var win_find_dosen = new Ext.Window({ title: "Data Pimpinan", modal: true, items: [grid_find_dosen] }).show(); function dobelklikdosen(grid, rowIdx) { var rec_dosen = ds_dosen.getAt(rowIdx); Ext.getCmp("idnip").setValue(rec_dosen.data["nidu"]); Ext.getCmp("idnm").setValue(rec_dosen.data["nmdosdgngelar"]); win_find_dosen.close(); } } } }