function pNilaiManual(){ /** COMMON STORES */ var ds_prodireg = store_prodireg(); var ds_years = store_tahun(); var ds_stsmt = store_stsmt(); /** 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' } ]); /** MAIN GRID STORE: DS_KURIKULUM */ var fields_kur = RH.storeFields('idkurikulum','kdprodi','thnmasuk','kdmk','nmmkind','idsemester','kdstsemester'); var pageSize = 15; var ds_kur = RH.JsonStore({ url : BASE_URL + 'nilaimanual_controller/get_makulkurikulum', fields : fields_kur, limit: pageSize, params: [ {key:'kdprodi', id:'cb.prodi-kur'} ,{key:'thnmasuk', id:'cb.thmasuk-kur'} ], enableSearch: true, }); ds_kur.on('beforeload', function(){ RH.removeDetail('fp.detilkur') }); //SEARCH COMPONENT var sb_kur = RH.searchComp({ id: 'sb_kur', fields : ['kdmk:Kode Mata Kuliah','nmmkind:Nama Mata Kuliah (Ind)','idsemester:Semester'], selected : 'nmmkind', store : ds_kur, textWidth : 250 }); function render_stsemester(value) { var val = RH.getRecordFieldValue(ds_stsmt, 'nmsmt', 'kdstsemester', value); return val; } /** THE GRID COLUMN ===================================== */ /** FUNCTION for GRID COLUMN EDITOR */ /** GRID COLUMN MODEL */ var cm_kur = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), //for rows numbering { header: RH.h3('Kode','c'), width:70, dataIndex: 'kdmk', renderer: RH.keyToDetil, sortable: true }, { header: RH.h3('Nama Mata Kuliah (Ind)'), width: 250, dataIndex: 'nmmkind', sortable: true, }, { header: RH.h3('Semester'), width: 66, dataIndex: 'idsemester', }, { header: RH.h3('Tahun Akademik - Semester'), width: 150, dataIndex: 'kdstsemester', renderer: render_stsemester } ] ); // Selection Model var sm_kur = new Ext.grid.RowSelectionModel({ singleSelect: true }); // Grid View var gv_kur = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); /** GRID PANEL */ var gp_kur = new Ext.grid.EditorGridPanel({ //PAKE EditorGridPanel ds: ds_kur, cm: cm_kur, sm: sm_kur, view: gv_kur, 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_kur], bbar: new Ext.PagingToolbar({ store: ds_kur, displayInfo: true, pageSize: pageSize, mode: 'local', displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data" }), listeners: { cellclick: onCellKurClick } }); var fp_kur = new Ext.Panel({ xtype: 'panel', title: 'Entry Nilai Manual', iconCls:'silk-book', 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-kur', label: 'Program Studi', width: 300, data: ds_prodireg, key: 'kdprodi', display: 'lnmprodi', fnSelect: function(){ reloadGridKur(); } }) ] },{ layout:'form', labelWidth:190, labelAlign:'right', items: [ RH.ActionCombo({ id: 'cb.thmasuk-kur', label: 'Tahun Masuk/Angkatan', width: 100, data: ds_years, key: 'kode', display: 'nama', fnSelect: function(){ reloadGridKur(); } }) ] },{ xtype: 'textfield', id: 'hidden.kdmkkur', hidden:true, },{ xtype:'button', text: 'Import Nilai TRLNM', id:'btntrnlm', iconCls: 'silk-add', margins:'0 0 0 10', handler:function(){ importTrlnm(); } }] }] },{ region: 'center', layout:'border', autoScroll:true, items:[{ region:'center', xtype: 'panel', layout:'fit', height:400, title:'Mata Kuliah', id:'fp.makul', frame:true, items: [gp_kur], },{ region:'east',width:'50%',split: true, xtype: 'panel', layout:'fit', height:400, title:'Daftar Nilai', id:'fp.nilai', frame:true, }], }] }); /** FUNCTIONS */ function onCellKurClick(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 kdmk = record.data['kdmk']; var thnmasuk = record.data['thnmasuk']; RH.removeDetail('fp.nilai'); if (t.className == 'keyMasterDetail') { var gridPanelMhs = nilaimahasiswa(kdprodi, kdstsemester, kdmk, thnmasuk); RH.loadDetail('fp.nilai',gridPanelMhs); } } function reloadGridKur(){ RH.removeDetail('fp.nilai'); ds_kur.reload({ params: { kdprodi: RH.getCompValue('cb.prodi-kur', true), thnmasuk: RH.getCompValue('cb.thmasuk-kur', true) } }); } SET_PAGE_CONTENT(fp_kur); //==============nilai function nilaimahasiswa(kdprodi, kdstsemester, kdmk, thnmasuk){ var fields_setnilai = RH.storeFields('kdprodi','kdstsemester','nilaihuruf','bobotnilai'); var ds_setnilai = RH.JsonStore({ url : BASE_URL + 'nilai_controller/get_bonilaiByProdiSmt', fields : fields_setnilai, params: [ {key:'kdprodi', value: kdprodi} ,{key:'kdstsemester', value: kdstsemester} ], enableSearch: false, }); var ds_stsmtambil = store_stsmt(); var fields_stambilmk = RH.storeFields('idstambilmk','nmstambilmk'); var ds_stambilmk = RH.JsonStore({ url : BASE_URL + 'nilaimanual_controller/get_stambilmk', fields : fields_stambilmk, enableSearch: false, }); var fields_stsetuju = RH.storeFields('idstsetuju','nmstsetuju'); var ds_stsetuju = RH.JsonStore({ url : BASE_URL + 'nilaimanual_controller/get_stsetuju', fields : fields_stsetuju, enableSearch: false, }); var fields_mhsmk = RH.storeFields('idnilai', 'nim', 'nmmhs', 'kdjnskelamin', 'nilaihuruf','bobotnilai','nmthnakademik','nmstambilmk','nmstsetuju'); var ds_mhsmk = RH.JsonStore({ url : BASE_URL + 'nilaimanual_controller/get_nilaimhs', fields : fields_mhsmk, limit: 50, params: [ {key:'kdprodi', value: kdprodi} ,{key:'kdstsemester', value: kdstsemester} ,{key:'kdmk', value: kdmk} ,{key:'thnmasuk', value: thnmasuk} ], enableSearch: false, }); var sb_mhsmk = RH.searchComp({ id: 'sb_mhsmk', fields : ['nim:NPM','nmmhs:Nama Mahasiswa','kdjnskelamin:(L/P)', 'nilaihuruf:Nilai Huruf','bobotnilai:Bobot Nilai','nmthnakademik:Semester Ambil', 'nmstambilmk:Keterangan','nmstsetuju:Status'], selected : 'nmmhs', store : ds_mhsmk, textWidth : 200 }); var fnSelectNilai = function(combo, record){ var nilaihuruf = record.data['nilaihuruf']; var bobotnilai = record.data['bobotnilai']; Ext.Ajax.request({ url: BASE_URL + 'nilai_controller/update_nilai', params: { idnilai : RH.getCompValue('hidden.idnilai'), nilaihuruf : nilaihuruf, bobotnilai : bobotnilai, }, success: function() { ds_mhsmk.reload(); }, failure: function() { Ext.Msg.alert("Info", "Ubah Data Gagal"); } }); }; var fnSelectSmtAmbil = function(combo, record){ var kdstsemester = record.data['kdstsemester']; Ext.Ajax.request({ url: BASE_URL + 'nilaimanual_controller/update_smtambil', params: { idnilai : RH.getCompValue('hidden.idnilai'), kdstsemester : kdstsemester, }, success: function() { ds_mhsmk.reload(); }, failure: function() { Ext.Msg.alert("Info", "Ubah Data Gagal"); } }); }; var fnSelectAmbil = function(combo, record){ var idstambilmk = record.data['idstambilmk']; Ext.Ajax.request({ url: BASE_URL + 'nilaimanual_controller/update_stambilmk', params: { idnilai : RH.getCompValue('hidden.idnilai'), idstambilmk : idstambilmk, }, success: function() { ds_mhsmk.reload(); }, failure: function() { Ext.Msg.alert("Info", "Ubah Data Gagal"); } }); }; var fnSelectSetuju = function(combo, record){ var idstsetuju = record.data['idstsetuju']; Ext.Ajax.request({ url: BASE_URL + 'nilaimanual_controller/update_stsetuju', params: { idnilai : RH.getCompValue('hidden.idnilai'), idstsetuju : idstsetuju, }, success: function() { ds_mhsmk.reload(); }, failure: function() { Ext.Msg.alert("Info", "Ubah Data Gagal"); } }); }; var cm_mhsmk = new Ext.grid.ColumnModel([ new Ext.grid.RowNumberer(), { header:'idnilai', dataIndex:'idnilai', hidden:true }, { header: 'NPM', width:100, dataIndex: 'nim', sortable: true }, { header: 'Nama Mahasiswa', width: 220, dataIndex: 'nmmhs',sortable: true, }, { header: '(L/P)', width: 35, dataIndex: 'kdjnskelamin', align:'center' }, { header: 'Nilai Huruf', width:80, align:'center', dataIndex: 'nilaihuruf', renderer: render_nilaihuruf, editor: RH.getComboEditor('nilaihuruf', false, ds_setnilai, 'nilaihuruf', 'nilaihuruf', fnSelectNilai) }, { header: 'Bobot Nilai', width:80, align:'center', dataIndex: 'bobotnilai', }, { header: 'Semester Ambil', width:150, dataIndex: 'nmthnakademik', renderer: function(value) { return '' + value + ''; }, editor: RH.getComboEditor('kdstsemester', false, ds_stsmtambil, 'nmsmt', 'nmsmt', fnSelectSmtAmbil) }, { header: 'Keterangan', width:150, dataIndex: 'nmstambilmk', renderer: function(value) { return '' + value + ''; }, editor: RH.getComboEditor('nmstambilmk', false, ds_stambilmk, 'nmstambilmk', 'nmstambilmk', fnSelectAmbil) }, { header: 'Status', width:150, dataIndex: 'nmstsetuju', renderer: function(value) { return '' + value + ''; }, editor: RH.getComboEditor('nmstsetuju', false, ds_stsetuju, 'nmstsetuju', 'nmstsetuju', fnSelectSetuju) }, RH.DeleteColumn()] ); function render_nilaihuruf(value) { var val = RH.getRecordFieldValue(ds_setnilai, 'nilaihuruf', 'nilaihuruf', value); if (value == 'A' || value == 'B') { return '' + value + ''; } else if (value == 'C') { return '' + value + ''; } else if (value == 'D' || value == 'E' || value == 'T') { return '' + value + ''; } return value; } function onCellClick(grid, rowIndex, cellIndex, e) { var rec = ds_mhsmk.getAt(rowIndex); var record = grid.getStore().getAt(rowIndex); // Get the Record var idnilai = record.data['idnilai']; RH.setCompValue('hidden.idnilai', idnilai); RH.DeleteClick(e, function(){fnDeleteNilaiManual(grid, record)}); } function fnDeleteNilaiManual(grid, record){ var url = BASE_URL + 'nilaimanual_controller/delete_nilaimanual'; var params = new Object({ idnilai : record.data['idnilai'], }); RH.deleteGridRecord(url, params, grid ); } var gp_mhsmk = RH.EditorGridPanel_T1({ ds: ds_mhsmk, cm: cm_mhsmk, singleSelect: true, clicksToEdit: 1, searchComp: [sb_mhsmk,{ xtype:'button', text: 'Tambah Mahasiswa', id:'btntmbhmhs', iconCls: 'silk-add', margins:'0 0 0 10', handler:function(){ wGridMhsAddNilai(kdprodi, kdstsemester, kdmk, thnmasuk, gp_mhsmk); } }], allowAdd: false, pageSize: 50, cellclick: onCellClick, customButton: { xtype:'textfield', id:'hidden.idnilai', hidden:true }, }); return gp_mhsmk; function wGridMhsAddNilai(kdprodi, kdstsemester, kdmk, thnmasuk, gnilaimhs){ //,kdstsemester var fields_addmhs = RH.storeFields('nim','nmmhs','kdjnskelamin','thnmasuk','stdaftar','staktif'); //DATA STORE var pageSize = 20; var ds_lookup_mhs = RH.JsonStore({ url : BASE_URL + 'nilaimanual_controller/get_addmhs', fields : fields_addmhs, autoLoad: true, root: 'data', params: [ {key:'kdprodi', value: kdprodi} ,{key:'kdstsemester', value: kdstsemester} ,{key:'kdmk', value: kdmk} ,{key:'thnmasuk', value: thnmasuk} ], limit: pageSize, }); //SEARCH COMPONENT var sb_lookup = RH.searchComp({ id: 'sb_lookup', fields : ['nim:NPM','nmmhs:Nama Mahasiswa','kdjnskelamin:(L/P)'], selected : 'nmmhs', store : ds_lookup_mhs, textWidth : 200 }); // Selection Model var sm_mhs_prodi = new Ext.grid.CheckboxSelectionModel(); //COLUMN MODEL var cm_mahasiswa_prodi = new Ext.grid.ColumnModel( [sm_mhs_prodi,new Ext.grid.RowNumberer(), { 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: 100, dataIndex: 'thnmasuk', sortable: true }, { header: 'Status Daftar', width: 100, dataIndex: 'stdaftar', sortable: true }, { header: 'Status Aktifitas', width: 100, dataIndex: 'staktif', sortable: true }] ); // Grid View var gv_mhs_prodi = new Ext.grid.GridView({emptyText: '< Belum ada Data >'}); //GRID PANEL var gp_mhs_prodi = new Ext.grid.GridPanel({ id: 'gp.search-mhs', ds: ds_lookup_mhs, cm: cm_mahasiswa_prodi, sm: sm_mhs_prodi, view: gv_mhs_prodi, forceFit: true,//height: 400,width: 720, autoSizeColumns: true, enableColumnResize: true, enableColumnHide: false, enableColumnMove: false, enableHdaccess: false, columnLines: true, loadMask: true, //buttonAlign: 'left', layout: 'anchor', tbar:[sb_lookup,{ text: 'Tambah', iconCls: 'silk-add', handler: function(){ var select = gp_mhs_prodi.getSelectionModel().getSelections(); if(select.length > 0){ Ext.MessageBox.confirm('Message', 'Anda Yakin Menambah Data?', add); }else{ Ext.MessageBox.alert('Message', 'Data Belum Di Pilih!'); } } }], bbar: new Ext.PagingToolbar({ store: ds_lookup_mhs, displayInfo: true, displayMsg: 'Data {0} - {1} dari {2}', emptyMsg: "Belum ada data", }), listeners: { rowdblclick: function(grid, rowIdx) { } } }); var win_mhs_prodi = new Ext.Window({ id: 'w.search-mhs', title: 'Daftar Mahasiswa', modal: true, layout: 'fit', width:720, height:400, items: [gp_mhs_prodi] }).show(); function add(btn, grid, rowIdx){ if(btn == 'yes'){ var m = gp_mhs_prodi.getSelectionModel().getSelections(); var par =''; var split ='x'; var rec =''; var endpar = ';'; for(var i=0; i< m.length; i++){ if (i == m.length-1) { endpar = ''; } rec = m[i]; par += rec.data['nim'] + split + kdprodi + split + kdstsemester + split + kdmk + split + endpar; } Ext.Ajax.request({ url: BASE_URL +'nilaimanual_controller/insert_nilai_bypass', method: 'POST', params: { par : par }, waitMsg: 'Tunggu, sedang proses menyimpan...', success: function() { Ext.Msg.alert("Info", "Simpan Data Berhasil"); gnilaimhs.getStore().reload(); win_mhs_prodi.close(); }, failure: function(result){ Ext.Msg.alert("Info", "Simpan Data Gagal"); } }); } } }; } //=================end nilai function importTrlnm(){ var ds_grid = new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: BASE_URL + 'nilaimanual_controller/get_import_nilai_trlnm', method: 'POST', }), baseParams: { }, totalProperty: 'results', autoLoad : false, root: 'data', fields: [ { name: 'nim' } , { name: 'nmmhs' } , { name: 'kdprodi' } , { name: 'nmprodi' } , { name: 'kdstsemester' } , { name: 'nmthnakademik' } , { name: 'kdmk' } , { name: 'nmmk' } , { name: 'nilaihuruf' } , { name: 'bobotnilai' } , { name: 'keterangan' } ] }); var cm = new Ext.grid.ColumnModel({ columns: [ new Ext.grid.RowNumberer({width: 35}), { header: RH.h3('NPM'), width: 100, dataIndex: 'nim', align: 'center', sortable: true }, { header: RH.h3('Nama Mahasiswa'), width: 200, dataIndex: 'nmmhs', sortable: true }, { header: RH.h3('Kode Prodi'), width: 80, dataIndex: 'kdprodi', align: 'center', sortable: true }, { header: RH.h3('Nama Prodi'), width: 200, dataIndex: 'nmprodi', sortable: true }, { header: RH.h3('Kode Semester'), width: 100, align: 'center', dataIndex: 'kdstsemester', sortable: true }, { header: RH.h3('Tahun Akademik - Semester'), width: 200, dataIndex: 'nmthnakademik', sortable: true }, { header: RH.h3('Kode MK'), width: 80, dataIndex: 'kdmk', sortable: true }, { header: RH.h3('Nama MK'), width: 200, dataIndex: 'nmmk', sortable: true }, { header: RH.h3('Nilai Huruf'), width: 80, align: 'center', dataIndex: 'nilaihuruf', sortable: true }, { header: RH.h3('Bobot Nilai'), width: 80, align: 'center', dataIndex: 'bobotnilai', sortable: true }, { header: RH.h3('Keterangan'), width: 120, dataIndex: 'keterangan', sortable: true }] }); var cari_data_nya = [new Ext.ux.grid.Search({ iconCls: 'btn_search', minChars: 1, autoFocus: true, autoHeight: true, position: 'top', mode: 'local', width: 200 })]; var grid_nya = new Ext.grid.EditorGridPanel({ id: 'gp.grid_nya', plugins: cari_data_nya, ds: ds_grid, cm: cm, sm: new Ext.grid.RowSelectionModel({ singleSelect: true}), view: new Ext.grid.GridView({ emptyText: '< Belum ada Data >'}), forceFit: true, //autoHeight: true, width: 720, border: true, tbar: [{ text: 'File Excel:' },{ xtype: 'fileuploadfield', id: 'f_excel', emptyText: 'Select an file', fieldLabel: 'File Excel', name: 'f_excel', width: 200, buttonText: '', buttonCfg: { iconCls: 'silk-page-copy' }, listeners: { valid: function() { } } },'-',{ xtype: 'button', text: ' Import ', iconCls: 'silk-add', id: 'import_data', width: 3, handler: function() { get_data('formnya'); } },'-',{ xtype: 'button', id: 'save_import', iconCls: 'silk-save', text: 'Simpan', handler: function() { if (grid_nya.getStore().getCount()>0) { importnilai(); } else { Ext.MessageBox.alert('Informasi', 'Data Kosong'); } } },'->'], autoSizeColumns: true, enableColumnResize: true, enableColumnHide: false, enableColumnMove: false, enableHdaccess: false, columnLines: true, loadMask: true, layout: 'anchor', }); var formnya = new Ext.form.FormPanel({ xtype:'form', id: 'formnya', buttonAlign: 'left', labelWidth: 200, labelAlign: 'right', bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri monitorValid: true, height: 400, width: 1300, layout: 'fit', frame: true, fileUpload: true, items: [grid_nya] }); var win = new Ext.Window({ title: 'Import Nilai TRLNM', modal: true, height: 400, width: 1300, layout: 'fit', items: [formnya] }).show(); function Right(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } } function get_data(namaForm) { var form_nya = Ext.getCmp(namaForm); var xls = Right(Ext.getCmp('f_excel').getValue(),3); if (xls) { if (xls=="xls") { ds_grid.removeAll(); form_nya.getForm().submit({ url: BASE_URL + 'nilaimanual_controller/upload_data', method: 'POST', waitMsg: 'Tunggu, sedang proses...', success: function(form_nya, o) { ds_grid.setBaseParam('excel',Ext.getCmp('f_excel').getValue()); ds_grid.load(); }, failure: function() { Ext.MessageBox.alert('Informasi', 'Proses Import Gagal'); } }); } else { Ext.MessageBox.alert('Informasi', 'File Harus Berekstensi .xls'); } } else { Ext.MessageBox.alert('Informasi', 'Pilih File Excel'); } } function importnilai(){ var form_nya = Ext.getCmp('formnya'); var par=''; var a= 1; grid_nya.getStore().each(function(rec){ var rowData = rec.data; if (rowData['keterangan'] == 'Data Belum Ada') { par += rowData['nim'] + 'x' + rowData['kdprodi'] + 'x' + rowData['kdstsemester'] + 'x' + rowData['kdmk'] + 'x' + rowData['nilaihuruf'] + 'x' + rowData['bobotnilai'] + 'x' + ';'; a= a+1; } }); var waitmhssave = Ext.MessageBox.wait('Menyimpan Data...', 'Info'); Ext.Ajax.request({ url: BASE_URL +'nilaimanual_controller/import_nilai_trlnm', method: 'POST', params: { par : par.substr(0, par.length-1) }, waitMsg: 'Tunggu, sedang proses menyimpan...', success: function(result) { var jsonData = Ext.decode(result.responseText); waitmhssave.hide(); Ext.Msg.alert("Info", jsonData.message + ", Total Import: " + jsonData.count); Ext.getCmp('f_excel').setValue(); ds_grid.removeAll(); }, failure: function(result){ waitmhssave.hide(); Ext.Msg.alert("Info", "Simpan Data Gagal"); } }); } } }