function pDosenWali(){ /** 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: 'Dosen Wali', 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], tbar: [{ text: 'Salin Dosen Wali dari Tahun Semester Sebelumnya', id: 'tb.copy-doswal', iconCls: 'silk-page-copy', handler: function() { fnCopyDoswal(); } }] }, RH.vSpacer(5), { xtype: 'panel', layout:'fit', /*hidden:true,*/ title:'Daftar Mahasiswa', id:'fp.doswal-detil', frame:true, height:350, //items: [gp_doswaldet], }] }] }); 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 fnCopyDoswal(){ RH.removeDetail('fp.doswal-detil'); gp_doswal 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; }; if(ds_doswal.getCount() > 0){ RH.warning('Data sudah ada. Hapus terlebih dahulu'); return; } var combo_prodi = Ext.getCmp('cb.prodi-doswal'); var combo_tahun = Ext.getCmp('cb.smt-doswal'); wFormCopyDosenWali(combo_prodi, combo_tahun, grid) } } /** FORM COPY DOSEN WALI */ function wFormCopyDosenWali(combo_prodi, combo_tahun, masterGrid){ //the store must same (shared store) var ds_stsmt = store_stsmt(); var ds_prodireg = combo_prodi.getStore(); var ds_years = combo_tahun.getStore(); var kdprodi = combo_prodi.getValue(); var thmasuk = combo_tahun.getValue(); var copy_form = new Ext.form.FormPanel({ xtype:'form', id: 'frm.copy', buttonAlign: 'left', labelWidth: 180, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 160, width: 500, 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.thbaru-copy', fieldLabel: 'Semester (Baru)', store: ds_stsmt, triggerAction: 'all', allowBlank: false, valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', width: 150, },{ id: 'cb.thlama-copy', fieldLabel: 'Semester (Lama)', store: ds_stsmt, triggerAction: 'all', editable: true, valueField: 'kdstsemester', displayField: 'nmsmt', forceSelection: true, submitValue: true, mode: 'local', emptyText:'Pilih...', width:150, }], buttons: [{ text: 'Simpan', iconCls:'silk-save', handler: function() { fnSaveCopy(); } }, { text: 'Kembali', iconCls:'', handler: function() { wCopyDoswal.close(); } }] }); /**SET THE FORM */ setForm(); var wCopyDoswal = new Ext.Window({ title: 'Salin Dosen Wali dari Semester Sebelumnya', modal: true, closable:false, items: [copy_form] }).show(); /** FUNCTIONS */ function setForm(){ Ext.getCmp('cb.prodi-copy').disable(); Ext.getCmp('cb.thbaru-copy').disable(); RH.setCompValue('cb.prodi-copy', kdprodi); RH.setCompValue('cb.thbaru-copy', thmasuk); } /** SAVE COPY FUNCTIONS */ function fnSaveCopy(){ var thlama = RH.getCompValue('cb.thlama-copy',true); if(thlama == '') { RH.warning('Semester (Lama) harus diisi'); return; }; var idForm = 'frm.copy'; var sUrl = BASE_URL +'dosenwali_controller/copy_dosenwali'; var sParams = new Object({ kdprodi : RH.getCompValue('cb.prodi-copy'), thbaru : RH.getCompValue('cb.thbaru-copy'), thlama : thlama }); 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, wCopyDoswal, msgWait, msgSuccess, msgFail, msgInvalid); } } function wAddDosenWali(masterGrid, kdprodi, kdstsemester){ var fieldsLookup = RH.storeFields('nmfakultas','nourutprodi','nmprodi','lnmprodi' ,'nmjabak','nmstaktiv','nmstikj', 'kdjnskelamin' ,'nmdosen'//extract //TABLE DOSEN ,'kdprodi','kdstdosen','nidu','nidn' ,'nmdostpgelar','nmdosdgngelar','kdjabakademik','nmprodi'); var ds_lookup = RH.JsonStore({ url : BASE_URL + 'dosenwali_controller/lookup_add_doswal', fields : fieldsLookup, limit : 100, 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 */ //Checkbox pada Grid var cbGrid = new Ext.grid.CheckboxSelectionModel(); // COLUMN MODEL var cm_lookup = new Ext.grid.ColumnModel({ columns: [ cbGrid, new Ext.grid.RowNumberer(), //for rows numbering { header: 'NIDU', width: 100, dataIndex: 'nidu', sortable: true }, { header: 'NIDN', width: 100, hidden:true, dataIndex: 'nidn', sortable: true }, { header: 'Nama Dosen', width: 210, dataIndex: 'nmdosen', sortable: true }, { header: '(L/P)', width: 55, dataIndex: 'kdjnskelamin', sortable: true, align:'center' }, { header: 'Program Studi (Home Base)', width: 250, dataIndex: 'nmprodi', sortable: true }, { header: 'Jabatan Akademik', width: 200, dataIndex: 'nmjabak', sortable: true }, { header: 'Status', 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 >' }); //BUTTON TAMBAH var tbDsn = new Ext.Toolbar({ items:[{ text: 'Add', iconCls: 'silk-add', handler: function(){ var select = gp_lookup.getSelectionModel().getSelections(); if(select.length > 0){ Ext.MessageBox.confirm('Message', 'Anda Yakin Menambah Data?', add); }else{ Ext.MessageBox.alert('Message', 'Data Belum Di Pilih!'); } } }] }); //GridPanel var gp_lookup = new Ext.grid.GridPanel({ ds: ds_lookup, cm: cm_lookup, sm: cbGrid, //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:[tbDsn, sb_lookup], bbar: new Ext.PagingToolbar({ store: ds_lookup, displayInfo: true, pageSize: 100, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { rowdblclick: onRowDblClick } }); function add(btn, grid, rowIdx){ console.log(btn); if(btn == 'yes') { var m = gp_lookup.getSelectionModel().getSelections(); var store = gp_lookup.getStore(); //var store = ds_lookup; var record = store.getAt(rowIdx); for(var i=0; i< m.length; i++){ var rec = m[i]; console.log(rec); if(rec){ var nidu = rec.data['nidu']; //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() { masterGrid.getStore().reload(); Ext.Msg.alert("Info", "Simpan Data Berhasil"); //ds_doswal.reload(); wLookup.close(); }, failure: function(result){ Ext.Msg.alert("Info", "Simpan Data Gagal"); } }); } /* //Ext.MessageBox.alert('Message', 'Tambah Data Berhasil..'); RH.setCompValue('tf.total', RH.sumRecVal(ds_tpumum, 'total')); ds_tpumum.reload(); */ } } } /** 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(); //ds_doswal.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 : 100, 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','thnmasuk:Tahun Masuk'], selected : 'nmmhs', store : ds_lookup, textWidth : 200 }); /** GRID LOOKUP MAHASISWA PERWALIAN */ //Checkbox pada Grid var cbGrid = new Ext.grid.CheckboxSelectionModel(); // COLUMN MODEL var cm_lookup = new Ext.grid.ColumnModel({ columns: [ cbGrid, { 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, align: 'center' }, { header: 'Tahun Masuk', width: 100, dataIndex: 'thnmasuk', sortable: true, align: 'center' }, { header: 'Status Daftar', width: 90, dataIndex: 'stdaftar', sortable: true }, { header: 'Jenis Kelas', width: 125, 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 >' }); //BUTTON TAMBAH var tbMhs = new Ext.Toolbar({ items:[{ text: 'Add', iconCls: 'silk-add', handler: function(){ var select = gp_lookup.getSelectionModel().getSelections(); if(select.length > 0){ Ext.MessageBox.confirm('Message', 'Anda Yakin Menambah Data?', add); }else{ Ext.MessageBox.alert('Message', 'Data Belum Di Pilih!'); } } }] }); //GridPanel var gp_lookup = new Ext.grid.GridPanel({ ds: ds_lookup, cm: cm_lookup, sm: cbGrid, //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:[tbMhs, sb_lookup], bbar: new Ext.PagingToolbar({ store: ds_lookup, displayInfo: true, pageSize: 100, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { rowdblclick: onRowDblClick } }); function add(btn, grid, rowIdx){ console.log(btn); if(btn == 'yes'){ var m = gp_lookup.getSelectionModel().getSelections(); //var store = ds_lookup; var store = gp_lookup.getStore(); var record = store.getAt(rowIdx); for(var i=0; i< m.length; i++){ var rec = m[i]; console.log(rec); if(rec){ 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() { masterGrid.getStore().reload(); Ext.Msg.alert("Info", "Tambah Data Berhasil"); //ds_lookup.reload(); wLookup.close(); }, failure: function(result){ Ext.Msg.alert("Info", "Tambah Data Gagal"); } }); } /* //Ext.MessageBox.alert('Message', 'Tambah Data Berhasil..'); RH.setCompValue('tf.total', RH.sumRecVal(ds_tpumum, 'total')); ds_tpumum.reload(); */ } } } /** 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(); //ds_lookup.reload(); wLookup.close(); }, failure: function(result){ Ext.Msg.alert("Info", "Tambah Data Gagal"); } }); } }