function pStdossemester(){ /** COMMON STORES */ var ds_prodireg = store_prodireg(); var ds_stsmt = store_stsmt(); var ds_stdosen = store_staktivdos(); var ds_jstudi = store_jstudi(); /** STORE for GRID COLUMN EDITOR type COMBO */ var dcUrl = BASE_URL + 'data_controller/'; var obj2Fields = new Object([ { name: 'kode' }, { name: 'nama' } ]); var obj4Fields = new Object([ { name: 'id' }, { name: 'kode' }, { name: 'nama' }, { name: 'deskripsi' } ]); var ds_semester = RH.getCommonJsonStore(obj4Fields, dcUrl + 'get_semester'); /** GRID STORE: ds_stdossmt */ var fields_stdossmt = RH.storeFields('idstdossemester','kdprodi','nidu','kdstsemester','kdjenjangstudi', 'kdstaktivitasdosen','keterangan','nmstaktivitasdos','nmdos','kdjnskelamin','nidn'); var pageSize = 20; var ds_stdossmt = RH.JsonStore({ url : BASE_URL + 'stdossemester_controller/get_stdossemester', fields : fields_stdossmt, limit : pageSize, params: [ {key:'kdprodi', id: 'cb.prodi-stru'} ,{key:'kdstsemester', id: 'cb.smt-stru'} ], enableSearch: true, }); ds_stdossmt.on('beforeload', function(){ RH.removeDetail('fp.detil') }); //SEARCH COMPONENT var sb_stdossmt = RH.searchComp({ id : 'sb_stdossmt', fields : ['nidu:NIDU','nmdos:Nama Dosen'], selected : 'idstdossemester', store : ds_stdossmt, }); /** GRID COLUMN MODEL */ var cm_stdossmt = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), //for rows numbering { header: RH.h3('NIDU'), width:150, dataIndex: 'nidu', sortable: true, },{ header: RH.h3('NIDN'), width:150, sortable: true, align:'center', }, { header: RH.h3('Nama Dosen'), width: 200, dataIndex: 'nmdos', sortable: true, }, { header: RH.h3('(L/P)'), width: 70, dataIndex: 'kdjnskelamin', align:'center', }, { header: RH.h3('Status Dosen'), width: 100, dataIndex: 'nmstaktivitasdos', }, { header: RH.h3('Keterangan'), width: 300, dataIndex: 'keterangan', }, RH.EditColumn(), RH.DeleteColumn() ] ); // Selection Model var sm_stdossmt = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_stdossmt = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); /** GRID PANEL */ var gp_stdossmt = new Ext.grid.EditorGridPanel({ //PAKE EditorGridPanel ds: ds_stdossmt, cm: cm_stdossmt, sm: sm_stdossmt, view: gv_stdossmt, clicksToEdit: 1, //for cell editing (single click =1, dblclick=2) forceFit: true, //autoHeight: true, layout:'anchor', //autoSizeColumns: true, //autoExpandColumn: 'nmmkind', autoScroll:true, //enableColumnResize: true, columnLines: true, loadMask: true, tbar:[sb_stdossmt], bbar: new Ext.PagingToolbar({ store: ds_stdossmt, displayInfo: true, pageSize: pageSize, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { cellclick: onCellStsmtdosClick } }); var fp_stdossmt = new Ext.Panel({ xtype: 'panel', title: 'Status Aktivitas Dosen', iconCls:'silk-user', buttonAlign: 'left', bodyStyle: 'padding: 5px', border: false, layout: 'border', waitMsg: 'Waiting...', maskDisabled: false, monitorValid: true, autoScroll:true, frame: true, items: [{ xtype: 'fieldset', flex: 1, region:'north', layout:'form', autoHeight:true, items: [{ xtype: 'container', layout: 'hbox', items:[{ layout:'form', labelWidth:90, labelAlign:'right', items: [ RH.ActionCombo({ id: 'cb.prodi-stru', label: 'Program Studi', width: 300, data: ds_prodireg, key: 'kdprodi', display: 'lnmprodi', fnSelect: function(){ reloadGridStdossmt(); } }) ] },{ layout:'form', labelWidth:200, labelAlign:'right', items: [ RH.ActionCombo({ id: 'cb.smt-stru', label: 'Tahun Akademik-Semester', width: 160, data: ds_stsmt, key: 'kdstsemester', display: 'nmsmt', fnSelect: function(){ reloadGridStdossmt(); }, }) ] },{ xtype: 'textfield', id: 'hidden.idstdossemester', hidden:true, }] }] },{ region: 'center', layout:'form', autoScroll:true, items:[{ xtype: 'panel', layout:'fit', height:510, title:'Data Status Dosen', id:'fp.master', frame:true, items: [gp_stdossmt], tbar: [{ text: 'Tambah', id: 'idadd-stdossmt', iconCls: 'silk-add', handler: function(){ var prodi = Ext.getCmp('cb.prodi-stru').getRawValue(); var tahun = Ext.getCmp('cb.smt-stru').getRawValue(); if(prodi == '') { Ext.Msg.alert("Info", "Program Studi Harus Diisi"); } else if(tahun == '') { Ext.Msg.alert("Info", "Tahun Akademik Harus Diisi"); } else if(prodi != '' && tahun != '') { fnAddstdossmt(); } } }, { text: 'Cetak', id: 'idcetak-stmhssmt', iconCls: 'silk-printer', handler: function(){ var prodi = Ext.getCmp('cb.prodi-stru').getRawValue(); var tahun = Ext.getCmp('cb.smt-stru').getRawValue(); if(prodi == '') { Ext.Msg.alert("Info", "Program Studi Harus Diisi"); } else if(tahun == '') { Ext.Msg.alert("Info", "Tahun Akademik Harus Diisi"); } fnPrintStdossmt(); } }, { text: 'Salin Status Aktivitas Dosen Dari Tahun Akademik - Semester Sebelumnya', id: 'tb.copy-staktivdosen', iconCls: 'silk-page-copy', handler: function() { fnCopyStAktivDos(); } }] }], }] }); SET_PAGE_CONTENT(fp_stdossmt); /**AKSI ONCELL**/ function onCellStsmtdosClick(grid, rowIndex, columnIndex, e) { var t = e.getTarget(); var record = grid.getStore().getAt(rowIndex); // Get the Record var kdprodi = record.data['kdprodi']; var kdstsemester = record.data['kdstsemester']; var idstdossemester = record.data['idstdossemester']; RH.removeDetail('fp.detil'); RH.setCompValue('hidden.idstdossemester', idstdossemester); RH.EditClick(e, function(){fnEditstdossmt(grid, record)}); RH.DeleteClick(e, function(){fnDeletestdossmt(grid, record)}); return true; //back to ClickToEdit=1 } //input// function fnAddstdossmt(){ var grid = gp_stdossmt; var combo_stsmt = Ext.getCmp('cb.smt-stru'); var combo_prodi = Ext.getCmp('cb.prodi-stru'); wform_stdossmt(false, grid, combo_prodi, combo_stsmt, null); } //edit// function fnEditstdossmt(grid, record){ var combo_stsmt = Ext.getCmp('cb.smt-stru'); var combo_prodi = Ext.getCmp('cb.prodi-stru'); wform_stdossmt(true, grid, combo_prodi, combo_stsmt, record); } //delete// function fnDeletestdossmt(grid, record){ var url = BASE_URL + 'stdossemester_controller/delete_stdossemester'; var params = new Object({ idstdossemester : record.data['idstdossemester'] }); RH.deleteGridRecord(url, params, grid ); } //print// function fnPrintStdossmt(){ var kdprodi = RH.getCompValue('cb.prodi-stru'); var kdstsemester = RH.getCompValue('cb.smt-stru'); if(kdprodi && kdstsemester){ RH.ShowReport(BASE_URL + 'rpt/rpt_stdossmt/get_st_dos_smt/'+kdprodi+'/'+kdstsemester); } else {} } function reloadGridStdossmt(){ //remove detail RH.removeDetail('fp.detil'); //reload master-grid ds_stdossmt.reload({ params: { kdprodi: RH.getCompValue('cb.prodi-stru', true), kdstsemester: RH.getCompValue('cb.smt-stru', true) } }); } //FORM PANEL HALAMAN TAMBAH// function wform_stdossmt(isUpdate, grid, combo_prodi, combo_stsmt, record){ var winTitle = (isUpdate)?'Status Aktivitas Dosen (Edit)':'Status Aktivitas Dosen (Entry)'; var ds_stsmt = combo_stsmt.getStore(); var ds_prodireg = combo_prodi.getStore(); var kdstsemester = combo_stsmt.getValue(); var kdprodi = combo_prodi.getValue(); //Form Utama var stdossmt_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.stdossemester', buttonAlign: 'left', labelWidth: 200, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 350, width: 600, autoScroll: true, layout: 'form', frame: false, defaultType:'textfield', items: [ { id: 'idstdossemester', hidden: true, }, { xtype: 'compositefield', name: 'nidu', fieldLabel: 'NIDU', allowBlank: false, id: 'nidu', items: [{ id: 'tf.frm.nidu', xtype:'textfield', fieldLabel: 'NIDU', width: 150, allowBlank: false, disabled: true, }, { xtype: 'button', fieldLabel: 'Cari', hidden:false, labelStyle: 'width:160px', id: 'btncari', name: 'btncari', width: 50, handler: function() { wGridDosProdi('stdossmt',kdprodi,kdstsemester); } }] }, { id: 'id.nidn', fieldLabel: 'NIDN', width: 150, allowBlank: false, disabled: true, }, { id: 'id.nmdos', fieldLabel: 'Nama Dosen', width: 250, allowBlank: false, disabled: true, }, { xtype: 'combo', id: 'cb.prodireg', fieldLabel: 'Program Studi', store: ds_prodireg, triggerAction: 'all', valueField: 'kdprodi', displayField: 'lnmprodi', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, allowBlank: false, editable: false }, { xtype: 'combo', id: 'cb.kdstsemester', fieldLabel: 'Tahun Akademik-Semester', store: ds_stsmt, triggerAction: 'all', valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, allowBlank: false }, { xtype: 'combo', id: 'cb.jstudi', fieldLabel: 'Jenjang Studi', store: ds_jstudi, triggerAction: 'all', valueField: 'kode', displayField: 'nama', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, editable: false, allowBlank: false, }, { xtype: 'combo', id: 'cb.staktvdos', fieldLabel: 'Status Dosen', store: ds_stdosen, triggerAction: 'all', valueField: 'kode', displayField: 'nama', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width: 250, editable: false, allowBlank: false, }, { xtype: 'textarea', id: 'id.ket', fieldLabel: 'Keterangan', width: 300, height: 100, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveStdossemester(); } }, { text: 'Kembali', iconCls:'', handler: function() { wStdossemester.close(); } }] }); /**SET THE FORM */ setForm(); var wStdossemester = new Ext.Window({ title: winTitle, modal: true, closable:false, items: [stdossmt_form] }); /** CALL SET FORM AND SHOW THE FORM (WINDOW) */ setStdossmt(isUpdate, record); wStdossemester.show(); /** FUNCTIONS */ function setForm(){ Ext.getCmp('cb.prodireg').disable(); Ext.getCmp('cb.kdstsemester').disable(); RH.setCompValue('cb.prodireg', kdprodi); RH.setCompValue('cb.kdstsemester', kdstsemester); } /** /** FORM FUNCTIONS */ function setStdossmt(isUpdate, record){ if(isUpdate){ if(record != null){ Ext.getCmp('btncari').disable(); RH.setCompValue('idstdossemester', record.data['idstdossemester']); RH.setCompValue('tf.frm.nidu', record.data['nidu']); RH.setCompValue('id.nidn', record.data['nidn']); RH.setCompValue('id.nmdos', record.data['nmdos']); RH.setCompValue('cb.prodireg', record.data['kdprodi']); RH.setCompValue('cb.kdstsemester', record.data['kdstsemester']); RH.setCompValue('cb.jstudi', record.data['kdjenjangstudi']); RH.setCompValue('cb.staktvdos', record.data['kdstaktivitasdosen']); RH.setCompValue('id.ket', record.data['keterangan']); return; } } } function fnSaveStdossemester(){ var idForm = 'frm.stdossemester'; var sUrl = BASE_URL +'stdossemester_controller/insert_stdossemester'; var sParams = getInsertStdossmtParams(); 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 +'stdossemester_controller/update_stdossemester'; msgSuccess = 'Update data berhasil'; msgFail = 'Update data gagal'; } //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wStdossemester, msgWait, msgSuccess, msgFail, msgInvalid); //RH.submitGridForm(idForm, sUrl, sParams, grid, wStdossemester, msgWait, msgSuccess, msgFail, msgInvalid); } function getInsertStdossmtParams(){ return new Object({ idstdossemester : RH.getCompValue('idstdossemester'), nidu : RH.getCompValue('tf.frm.nidu'), nidn : RH.getCompValue('id.nidn'), nmdos : RH.getCompValue('id.nmdos'), kdprodi : RH.getCompValue('cb.prodireg'), kdsemester : RH.getCompValue('cb.kdstsemester'), kdjstudi : RH.getCompValue('cb.jstudi'), kdaktivitasdosen : RH.getCompValue('cb.staktvdos'), keterangan : RH.getCompValue('id.ket'), }); } } //===============================================================//copy staktivdos function fnCopyStAktivDos(){ var grid = gp_stdossmt; var kdprodi = RH.getCompValue('cb.prodi-stru', true); var kdstsemester = RH.getCompValue('cb.smt-stru', true); if(kdprodi == '') { RH.warning('Program Studi harus diisi'); return; }; if(kdstsemester == '') { RH.warning('Tahun Akademik - Semester harus diisi'); return; }; if(ds_stdossmt.getCount() > 0){ RH.warning('Data sudah ada. Hapus terlebih dahulu'); return; } var combo_prodi = Ext.getCmp('cb.prodi-stru'); var combo_stsmt = Ext.getCmp('cb.smt-stru'); wFormCopyStAktivDos(combo_prodi, combo_stsmt, grid); } function wFormCopyStAktivDos(combo_prodi, combo_stsmt, masterGrid){ //the store must same (shared store) var ds_prodireg = combo_prodi.getStore(); var ds_stsmt = combo_stsmt.getStore(); var kdprodi = combo_prodi.getValue(); var kdstsemester = combo_stsmt.getValue(); var copy_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.copy', buttonAlign: 'left', labelWidth: 215, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 160, width: 545, layout: 'form', frame: false, defaultType:'combo', items: [{ id: 'cb.prodi-copy', fieldLabel: 'Program Studi', store: ds_prodireg, triggerAction: 'all', valueField: 'kdprodi', displayField: 'lnmprodi', forceSelection: true, submitValue: true, mode: 'local', allowBlank: false, editable: false, width: 300, },{ id: 'cb.smtbaru-copy', fieldLabel: 'Tahun Akademik - Semester (Baru)', store: ds_stsmt, triggerAction: 'all', allowBlank: false, valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', width: 250, },{ id: 'cb.smtlama-copy', fieldLabel: 'Tahun Akademik - Semester (Lama)', store: ds_stsmt, triggerAction: 'all', valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width:250, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveCopy(); } }, { text: 'Kembali', iconCls:'', handler: function() { wCopyStAktivDos.close(); } }] }); /**SET THE FORM */ setForm(); var wCopyStAktivDos = new Ext.Window({ title: 'Salin Status Aktivitas Dosen Dari Tahun Akademik - Semester Sebelumnya', modal: true, closable:false, items: [copy_form] }).show(); /** FUNCTIONS */ function setForm(){ Ext.getCmp('cb.prodi-copy').disable(); Ext.getCmp('cb.smtbaru-copy').disable(); RH.setCompValue('cb.prodi-copy', kdprodi); RH.setCompValue('cb.smtbaru-copy', kdstsemester); } /** SAVE COPY FUNCTIONS */ function fnSaveCopy(){ var smtlama = RH.getCompValue('cb.smtlama-copy',true); if(smtlama == '') { RH.warning('Tahun Akademik - Semester (Lama) harus diisi'); return; }; var idForm = 'frm.copy'; var sUrl = BASE_URL +'stdossemester_controller/copy_stdossemester'; var sParams = new Object({ kdprodi : RH.getCompValue('cb.prodi-copy'), smtbaru : RH.getCompValue('cb.smtbaru-copy'), smtlama : smtlama }); var grid = masterGrid; var msgWait = 'Tunggu, sedang proses menyimpan...'; var msgSuccess = 'Salin data berhasil'; var msgFail = 'Salin data gagal'; var msgInvalid = 'Data belum valid (data primer belum terisi)!'; //call form grid submit function (common function by RH) RH.submitGridForm(idForm, sUrl, sParams, grid, wCopyStAktivDos, msgWait, msgSuccess, msgFail, msgInvalid); } } }