function daftar_hadir_dosen(){ /** COMMON STORES */ var ds_prodireg = store_prodireg(); var ds_stsmt = store_stsmt(); var fields_doswal = RH.storeFields('kdprodi','kdstsemester','nidu','nmdosen', 'kdjnskelamin','nmjabak'); /** GRID STORE */ var pageSize = 5; var ds_doswal = RH.JsonStore({ url : BASE_URL + 'dosenwali_controller/get_doswal', fields : fields_doswal, limit : pageSize, params: [ {key:'kdprodi', id: 'cb.prodi-doswal'} ,{key:'kdstsemester', id: 'cb.smt-doswal'} ], enableSearch: true, }); ds_doswal.on('load', function(){ RH.removeDetail('fp.doswal-detil');}); //SEARCH COMPONENT var sb_doswal = RH.searchComp({ id : 'sbdoswal', fields : ['nidu:NIDU','nmdosen:Nama Dosen'], selected : 'nmdosen', store : ds_doswal, textWidth : 250 }); /** GRID COLUMN MODEL */ var cm_doswal = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), //for rows numbering { header: 'NIDU', width:100, dataIndex: 'nidu', sortable: true, align:'center', renderer: RH.keyToDetil, }, { header: 'Nama Dosen', width: 300, dataIndex: 'nmdosen', sortable: true, }, { header: '(L/P)', width: 70, dataIndex: 'kdjnskelamin', align:'center', }, { header: 'Jabatan Akademik', width: 300, dataIndex: 'nmjabak', }, RH.DeleteColumn() ] ); // Selection Model var sm_doswal = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_doswal = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); /** GRID PANEL */ var gp_doswal = RH.GridPanel_T1({ ds: ds_doswal, cm: cm_doswal, singleSelect: true, searchComp: sb_doswal, allowAdd: true, fnAdd: fnAddDoswal, pageSize: pageSize, cellclick: onCellClickDoswal }); var fp_doswal = new Ext.Panel({ xtype: 'form', title: 'Daftar Hadir Dosen', iconCls:'silk-user', buttonAlign: 'left', bodyStyle: 'padding: 5px', border: false, layout: 'border', waitMsg: 'Waiting...', maskDisabled: false, monitorValid: true, autoScroll:true, frame: true, items: [{ layout: 'form', region:'north', height:45, //autoHeight:true, items:[ headerProdiSmt({ idcb_prodi : 'cb.prodi-doswal', cb_prodi_width: 300, idcb_stsmt : 'cb.smt-doswal', cb_stsmt_width : 150, space : 50, fnReload : function(){reloadGridDoswal();} }), { xtype: 'textfield', id: 'hidden.nidu', hidden:true, }] },{ layout: 'form', region:'center', autoScroll:true, items:[{ xtype: 'panel', layout:'fit', frame:true, height:240, //title:'Daftar Dosen Wali', id:'fp.master', items: [gp_doswal], }, RH.vSpacer(5), ] }] }); SET_PAGE_CONTENT(fp_doswal); /** FUNCTIONS ========== */ function onCellClickDoswal(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 nidu = record.data['nidu']; RH.removeDetail('fp.doswal-detil'); //hide panel detail RH.setCompValue('hidden.nidu', nidu); RH.DeleteClick(e, function(){fnDeleteDoswal(grid, record)}); if (t.className == 'keyMasterDetail'){ var gridPanelDet = pDosenwaliDet(kdprodi, kdstsemester, nidu); RH.loadDetail('fp.doswal-detil',gridPanelDet); } } function reloadGridDoswal(){ //remove-hide detail RH.removeDetail('fp.doswal-detil'); //reload master-grid ds_doswal.reload({ params: { kdprodi: RH.getCompValue('cb.prodi-doswal', true), kdstsemester: RH.getCompValue('cb.smt-doswal', true) } }); } function fnAddDoswal(){ //remove-hide detail RH.removeDetail('fp.doswal-detil'); var grid = gp_doswal; var kdprodi = RH.getCompValue('cb.prodi-doswal', true); var kdstsemester = RH.getCompValue('cb.smt-doswal', true); if(kdprodi == '') { RH.warning('Program Studi harus diisi'); return; }; if(kdstsemester == '') { RH.warning('Status Semester harus diisi'); return; }; wAddDosenWali(grid, kdprodi, kdstsemester); } function fnDeleteDoswal(grid, record){ //remove-hide detail RH.removeDetail('fp.doswal-detil'); var url = BASE_URL + 'dosenwali_controller/delete_doswal'; var params = new Object({ kdprodi : record.data['kdprodi'], kdstsemester : record.data['kdstsemester'], nidu : record.data['nidu'], }); RH.deleteGridRecord(url, params, grid ); } } function wAddDosenWali(masterGrid, kdprodi, kdstsemester){ var fieldsLookup = RH.storeFields('nmfakultas','nourutprodi','nmprodi','lnmprodi' ,'nmjabak','nmstaktiv','nmstikj' ,'nmdosen'//extract //TABLE DOSEN ,'kdprodi','kdstdosen','nidu','nidn' ,'nmdostpgelar','nmdosdgngelar','kdjabakademik'); var ds_lookup = RH.JsonStore({ url : BASE_URL + 'dosenwali_controller/lookup_add_doswal', fields : fieldsLookup, limit : 20, params: [ {key:'kdprodi', value: kdprodi} ,{key:'kdstsemester', value: kdstsemester} ], enableSearch: true, }); //SEARCH COMPONENT var sb_lookup = RH.searchComp({ id: 'sb_lookup', fields : ['nidu:NIDU','nmdosen:Nama Dosen'], selected : 'nmdosen', store : ds_lookup, textWidth : 200 }); /** GRID LOOKUP MATA KULIAH */ // COLUMN MODEL var cm_lookup = new Ext.grid.ColumnModel([{ header: 'NIDU', width: 100, dataIndex: 'nidu', sortable: true }, { header: 'NIDN', width: 100, hidden:true, dataIndex: 'nidn', sortable: true }, { header: 'Nama Dosen', width: 200, dataIndex: 'nmdosen', sortable: true }, { header: '(L/P)', width: 40, dataIndex: 'kdjnskelamin', sortable: true }, { header: 'Jabatan Akademik', width: 150, dataIndex: 'nmjabak', sortable: true }, { header: 'Status Aktiv', width: 100, dataIndex: 'nmstaktiv', sortable: true }] ); // Selection Model var sm_lookup = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_lookup = new Ext.grid.GridView({ emptyText: '< Belum ada Data >' }); //GridPanel var gp_lookup = new Ext.grid.GridPanel({ ds: ds_lookup, cm: cm_lookup, sm: sm_lookup, view: gv_lookup, forceFit: true, layout:'anchor', autoSizeColumns: true, //autoExpandColumn: 'nmmkind', autoScroll:true, enableColumnResize: true, enableColumnHide: false, enableColumnMove: false, columnLines: true, loadMask: true, tbar:[sb_lookup], bbar: new Ext.PagingToolbar({ store: ds_lookup, displayInfo: true, pageSize: 18, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { rowdblclick: onRowDblClick } }); /** WIN LOOKUP */ var wLookup = new Ext.Window({ id: 'w.look-dos', title: 'Daftar Dosen Prodi', modal: true, layout: 'fit', width:720, height:400, items: [gp_lookup] }).show(); /** FUNCTIONS */ function onRowDblClick(grid, rowIdx) { var store = ds_lookup; var rec = store.getAt(rowIdx); var nidu = rec.data['nidu']; var kdprodidosen = rec.data['kdprodi']; //INSERT NEW STRUPROGDET REECORD (Dosen Pengampu) Ext.Ajax.request({ url: BASE_URL +'dosenwali_controller/insert_doswal', method: 'POST', params: { kdprodi : kdprodi, kdstsemester : kdstsemester, nidu : nidu, }, waitMsg: 'Tunggu, sedang proses menyimpan...', success: function() { Ext.Msg.alert("Info", "Simpan Data Berhasil"); masterGrid.getStore().reload(); wLookup.close(); }, failure: function(result){ Ext.Msg.alert("Info", "Simpan Data Gagal"); } }); } } function pDosenwaliDet(kdprodi, kdstsemester, nidu){ var fields_doswaldet = RH.storeFields('kdprodi','kdstsemester','nidu','nim','nmmhs', 'kdjnskelamin','thnmasuk','stdaftar','idklsmhs','nmklsmhs'); var pageSize = 10; var ds_doswaldet = RH.JsonStore({ url : BASE_URL + 'dosenwali_controller/get_doswaldet', fields : fields_doswaldet, limit: pageSize, params: [ {key:'kdprodi', value: kdprodi} ,{key:'kdstsemester', value: kdstsemester} ,{key:'nidu', value: nidu} ], enableSearch: true, }); //SEARCH COMPONENT var sb_doswaldet = RH.searchComp({ id: 'sb_doswaldet', fields : ['nim:NPM','nmmhs:Nama Mahasiswa'], selected : 'nmmhs', store : ds_doswaldet, textWidth : 250 }); /** GRID COLUMN MODEL */ var cm_doswaldet = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), //for rows numbering { header: 'NPM', width:100, dataIndex: 'nim', sortable: true, align:'center', }, { header: 'Nama Mahasiswa', width: 300, dataIndex: 'nmmhs', sortable: true, }, { header: '(L/P)', width: 70, dataIndex: 'kdjnskelamin', align:'center', }, { header: 'Tahun Masuk', width: 80, dataIndex: 'thnmasuk', }, { header: 'Status Pendaftar', width: 100, dataIndex: 'stdaftar', }, { header: 'Kelas Mahasiswa', width: 120, dataIndex: 'nmklsmhs', }, RH.DeleteColumn() ] ); /** GRID PANEL */ var gp_doswaldet = RH.GridPanel_T1({ ds: ds_doswaldet, cm: cm_doswaldet, singleSelect: true, searchComp: sb_doswaldet, allowAdd: true, fnAdd: fnAddDoswaldet, pageSize: pageSize, cellclick: onCellClickDoswaldet });return gp_doswaldet; /** ====== FUNCTIONS ======== */ function onCellClickDoswaldet(grid, rowIndex, columnIndex, e) { var record = grid.getStore().getAt(rowIndex); // Get the Record RH.DeleteClick(e, function(){fnDeleteDoswalDet(grid, record)}); } function fnAddDoswaldet(){ /*for DEBUG: RH.warning(RH.searchObj.params[0].name); return;*/ var masterGrid = gp_doswaldet; wAddDosenWaliDet(masterGrid, kdprodi, kdstsemester, nidu); } function fnDeleteDoswalDet(grid, record){ var url = BASE_URL + 'dosenwali_controller/delete_doswaldet'; var params = new Object({ kdprodi : record.data['kdprodi'], kdstsemester : record.data['kdstsemester'], nidu : record.data['nidu'], nim : record.data['nim'], }); RH.deleteGridRecord(url, params, grid ); } } function wAddDosenWaliDet(masterGrid, kdprodi, kdstsemester, nidu){ /** DATA STORE ========*/ var fieldsLookup = RH.storeFields('nim','nmmhs','kdjnskelamin','thnmasuk', 'stdaftar','idklsmhs','nmklsmhs'); var ds_lookup = RH.JsonStore({ url : BASE_URL + 'dosenwali_controller/lookup_add_doswaldet', fields : fieldsLookup, limit : 20, params: [ {key:'kdprodi', value: kdprodi} ,{key:'kdstsemester', value: kdstsemester} ], enableSearch: true, }); //SEARCH COMPONENT var sb_lookup = RH.searchComp({ id: 'sb_lookup', fields : ['nim:NPM','nmmhs:Nama Mahasiswa'], selected : 'nmmhs', store : ds_lookup, textWidth : 200 }); /** GRID LOOKUP MAHASISWA PERWALIAN */ // COLUMN MODEL var cm_lookup = new Ext.grid.ColumnModel([{ header: 'NPM', width: 100, dataIndex: 'nim', sortable: true }, { header: 'Nama Mahasiswa', width: 200, dataIndex: 'nmmhs', sortable: true }, { header: '(L/P)', width: 50, dataIndex: 'kdjnskelamin', sortable: true }, { header: 'Tahun Masuk', width: 70, dataIndex: 'thnmasuk', sortable: true }, { header: 'Status Daftar', width: 100, dataIndex: 'stdaftar', sortable: true }, { header: 'Jenis Kelas', width: 100, dataIndex: 'nmklsmhs', sortable: true }] ); // Selection Model var sm_lookup = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_lookup = new Ext.grid.GridView({ emptyText: '< Belum ada Data >' }); //GridPanel var gp_lookup = new Ext.grid.GridPanel({ ds: ds_lookup, cm: cm_lookup, sm: sm_lookup, view: gv_lookup, forceFit: true, layout:'anchor', autoSizeColumns: true, //autoExpandColumn: 'nmmkind', autoScroll:true, enableColumnResize: true, enableColumnHide: false, enableColumnMove: false, columnLines: true, loadMask: true, tbar:[sb_lookup], bbar: new Ext.PagingToolbar({ store: ds_lookup, displayInfo: true, pageSize: 18, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { rowdblclick: onRowDblClick } }); /** WIN LOOKUP */ var wLookup = new Ext.Window({ id: 'w.look-mhs', title: 'Daftar Mahasiswa Prodi', modal: true, layout: 'fit', width:720, height:400, items: [gp_lookup] }).show(); /** FUNCTIONS */ function onRowDblClick(grid, rowIdx) { var store = ds_lookup; var rec = store.getAt(rowIdx); var nim = rec.data['nim']; //INSERT NEW DOSENWALIDET RECORD (Mahasiswa) Ext.Ajax.request({ url: BASE_URL +'dosenwali_controller/insert_doswaldet', method: 'POST', params: { kdprodi : kdprodi, kdstsemester : kdstsemester, nidu : nidu, nim : nim }, waitMsg: 'Tunggu, sedang proses menyimpan...', success: function() { Ext.Msg.alert("Info", "Tambah Data Berhasil"); masterGrid.getStore().reload(); wLookup.close(); }, failure: function(result){ Ext.Msg.alert("Info", "Tambah Data Gagal"); } }); } }