function cStruprogDet(kdprodi, kdstsemester, kdmk, storesObj){
/** STORE for GRID COLUMN EDITOR type COMBO */
var ds_availability = store_availability();
var ds_jdosen = store_jdosen();
var ds_idkelas = storesObj.kelas;
//RH.warning(kdmk);return;
var fields_struprogdet = RH.storeFields('idstruprogdet','kdprodi','kdstsemester','kdmk',
'nidu','nmdosen','kdjenjangstudi','nmjenjangstudi','kdprodidosen',
'nmprodidosen','idkelas','idklsmhs','nmklsmhs','silabus','satuanacarakuliah',
'bahanajar','diktat','idjnsdosen','jmlmhs','jmlniduganti');
var ds_struprogdet = RH.JsonStore({
url : BASE_URL + 'struprogdet_controller/get_struprogdet',
fields : fields_struprogdet,
limit: 10,
params: [
{key:'kdprodi', value: kdprodi}
,{key:'kdstsemester', value: kdstsemester}
,{key:'kdmk', value: kdmk}
],
enableSearch: false,
});
var jnsdosen, jum_koord, niduabsen, idkelasnya ,columnya;
/**
THE GRID COLUMN =====================================
*/
/** RENDERER for GRID COLUMN */
function render_availability(value) {
//RH.getRecordFieldValue(store, field, key, value)
var val = RH.getRecordFieldValue(ds_availability, 'nama', 'kode', value);
return RH.qtipEdit(val,'12px');
}
function render_jdosen(value) {
var val = RH.getRecordFieldValue(ds_jdosen, 'nama', 'id', value);
return RH.qtipEdit(val,'12px');
}
function render_kelas(value) {
var val = RH.getRecordFieldValue(ds_idkelas, 'nama', 'id', value);
return RH.qtipEdit(val,'12px');
}
/** FUNCTION for GRID COLUMN EDITOR */
var fnSelectDet = function(combo, record){
//The ID of THE combo must equals the field (key) to be updated
var field = combo.getId();
var value = '';
if(record.data['kode'])
value = record.data['kode'];
if(record.data['id'])
value = record.data['id'];
updateStruprogDet(field, value);
};
/** GRID COLUMN MODEL */
var cm_struprogdet = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(), //for rows numbering
{
header:'idstruprogdet', dataIndex:'idstruprogdet', hidden:true,
},{
header: RH.h3('NIDU'), width:80,
dataIndex: 'nidu',
sortable: true
},{
header: RH.h3('Dosen Pengajar'), width: 200,
dataIndex: 'nmdosen',
sortable: true,
},{
header: RH.h3('Jenjang'), width: 60,
dataIndex: 'nmjenjangstudi',
},{
header: RH.h3('Program Studi'), width: 200,
dataIndex: 'nmprodidosen',
},{
header: RH.h3('Silabus'), width: 70,
dataIndex: 'silabus',
renderer: render_availability,
editor: RH.getComboEditor('silabus', false, ds_availability, 'kode', 'nama', fnSelectDet),
},{
header: RH.h3('Satuan
Acara Kuliah'), width: 80,
dataIndex: 'satuanacarakuliah',
renderer: render_availability,
editor: RH.getComboEditor('satuanacarakuliah', false, ds_availability, 'kode', 'nama', fnSelectDet),
},{
header: RH.h3('Bahan
Ajar'), width: 70,
dataIndex: 'bahanajar',
renderer: render_availability,
editor: RH.getComboEditor('bahanajar', false, ds_availability, 'kode', 'nama', fnSelectDet),
},{
header: RH.h3('Diktat'), width: 70,
dataIndex: 'diktat',
renderer: render_availability,
editor: RH.getComboEditor('diktat', false, ds_availability, 'kode', 'nama', fnSelectDet),
},{
header: RH.h3('Kelas Perkuliahan'), width: 150,
dataIndex: 'idkelas',
renderer: render_kelas,
editor: RH.getComboEditor('idkelas', false, ds_idkelas, 'id', 'nama', fnSelectDet),
},{
header: RH.h3('Kelas Mahasiswa'), width: 150,
dataIndex: 'nmklsmhs',
},{
header: RH.h3('Jenis Dosen'), width: 150,
dataIndex: 'idjnsdosen',
renderer: render_jdosen,
editor: RH.getComboEditor('idjnsdosen', false, ds_jdosen, 'id', 'nama', fnSelectDet),
},
RH.DeleteColumn(),
{
header: RH.h3('Jumlah
Mahasiswa'), width: 80,
dataIndex: 'jmlmhs', align:'center',
},{
header: RH.h3('Jumlah
Dosen Pengganti'), width: 150,
dataIndex: 'jmlniduganti', align:'center',
},{
xtype: 'actioncolumn',
width: 150,
header: RH.h3('Tambah
Dosen Pengganti'),
align:'center',
items: [{
getClass: function(v, meta, record) {
meta.attr = "style='cursor:pointer;'";
},
icon : 'resources/img/icons/fam/add.gif',
tooltip: 'Tambah Dosen Pengganti',
handler: function(grid, rowIndex) {
var data = grid.getStore().getAt(rowIndex);
fnDosenGanti(data.get('idstruprogdet'));
}
}]
}]
);
// Selection Model
var sm_struprogdet = new Ext.grid.RowSelectionModel({ singleSelect: true });
// Grid View
var gv_struprogdet = new Ext.grid.GridView({emptyText: '< Belum ada Data >'});
/** GRID PANEL */
var gp_struprogdet = new Ext.grid.EditorGridPanel({ //PAKE EditorGridPanel
ds: ds_struprogdet,
cm: cm_struprogdet,
sm: sm_struprogdet,
view: gv_struprogdet,
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:[{
xtype: 'textfield', id: 'hidden.idstruprogdet', hidden:true,
}, {
text: 'Tambah', id: 'tb.add-strudet', iconCls: 'silk-add',
handler: function() { fnAddStruprogDet(); }
}],
bbar: new Ext.PagingToolbar({
store: ds_struprogdet,
displayInfo: true,
pageSize: 10,
mode: 'local',
displayMsg: 'Data {0} - {1} dari {2}',
emptyMsg: "Belum ada data"
}),
listeners: {
cellclick: onCellStrudetClick
}
});
/**
FUNCTIONS
*/
function onCellStrudetClick(grid, rowIndex, columnIndex, e) {
var t = e.getTarget();
var record = grid.getStore().getAt(rowIndex); // Get the Record
RH.setCompValue('hidden.idstruprogdet', record.data['idstruprogdet']);
jnsdosen = record.data['idjnsdosen'];
niduabsen = record.data['nidu'];
idkelasnya = record.data['idkelas'];
columnya = grid.getColumnModel().getDataIndex(columnIndex);
if(columnya=='idjnsdosen') {
get_count_koord(kdprodi, kdstsemester, kdmk, idkelasnya, columnya);
}
if (t.className == 'imgDelete') {
fnDeleteStruprogDet(grid, record);
return true;
}
return true; //back to ClickToEdit=1
}
function fnAddStruprogDet(){
/*for DEBUG: RH.warning(RH.searchObj.params[0].name); return;*/
var masterGrid = gp_struprogdet;
wLookupDosenMatkul(masterGrid, kdprodi, kdstsemester, kdmk, 0)
}
function fnDeleteStruprogDet(grid, record){
var idstruprogdet = record.data['idstruprogdet'];
var kdprodi = record.data['kdprodi'];
var kdstsemester = record.data['kdstsemester'];
var kdmk = record.data['kdmk'];
var nidu = record.data['nidu'];
var idkelas = record.data['idkelas'];
var idjnsdosen = record.data['idjnsdosen'];
var jmlmhs = record.data['jmlmhs'];
var msage = "Hapus data yang dipilih?";
if (jmlmhs > 0 && idjnsdosen == '1') {
msage = "Matakuliah di Kelas ini sudah diikuti Mahasiswa.
Hapus data yang dipilih?"
}
var url = BASE_URL + 'struprogdet_controller/delete_struprogdet';
var params = new Object({
idstruprogdet : record.data['idstruprogdet'],
});
Ext.Msg.show({
title: 'Konfirmasi',
msg: msage,
buttons: Ext.Msg.YESNO,
icon: Ext.MessageBox.QUESTION,
fn: function (response) {
if ('yes' !== response) {
return;
}
Ext.Ajax.request({
url: url,
method: 'POST',
params: params,
success: function() {
Ext.Msg.alert("Info", "Hapus Data Berhasil");
grid.getStore().reload();
},
failure: function(result){
Ext.MessageBox.alert("Info", "Hapus Data Gagal");
}
});
}
});
}
function updateStruprogDet(field, value){
if (field =='idjnsdosen') {
if (jum_koord >= '1' && value=='1' && jnsdosen != '1') { //jika sudah ada dosen koordinator dan nilai inputan dosen koordinator dan jenis dosen yang di edit bukan dosen koordinator
Ext.Msg.alert("Info", "Dosen Koordinator Di Kelas Ini Tidak Boleh Lebih Dari Satu"); return;
} else {
updatefieldstruprogdet(field,value);
}
} else if (field =='idkelas') {
var respons;
Ext.Ajax.request({
url: BASE_URL + 'struprogdet_controller/get_count_koordinator',
params: {
kdprodi : kdprodi,
kdstsemester : kdstsemester,
kdmk : kdmk,
idkelas : value,
column : columnya
},
success: function(response) {
respons = response.responseText
if (respons >= '1' && jnsdosen == '1') { //jika sudah ada dosen koordinator dan nilai inputan dosen koordinator dan jenis dosen yang di edit bukan dosen koordinator
Ext.Msg.alert("Info", "Dosen Koordinator Di Kelas Ini Tidak Boleh Lebih Dari Satu"); return;
} else {
updatefieldstruprogdet(field,value);
}
},
failure: function() {
}
});
} else {
updatefieldstruprogdet(field,value);
}
}
function updatefieldstruprogdet(field,value) {
Ext.Ajax.request({
url: BASE_URL + 'struprogdet_controller/update1field_struprogdet',
params: {
idstruprogdet : RH.getCompValue('hidden.idstruprogdet',true),
field : field,
value : value,
kdstsemester : kdstsemester,
kdprodi : kdprodi,
kdmk : kdmk,
niduabsen : niduabsen
},
success: function() {
ds_struprogdet.reload();
},
failure: function() {
Ext.Msg.alert("Info", "Ubah Data Gagal");
}
});
}
function get_count_koord(kdprodi, kdstsemester, kdmk, idkelas, columnya){ //fungsi menghitung jumlah dosen koordinator dan di simpan ke variabel jum_koord
Ext.Ajax.request({
url: BASE_URL + 'struprogdet_controller/get_count_koordinator',
params: {
kdprodi : kdprodi,
kdstsemester : kdstsemester,
kdmk : kdmk,
idkelas : idkelas,
column : columnya
},
success: function(response) {
jum_koord = response.responseText;
},
failure: function() {
}
});
}
//DOSEN PENGGANTI
function fnDosenGanti(idstruprogdet){
var iddosenpengganti;
var ds_status = new Ext.data.JsonStore({ //from database
proxy: new Ext.data.HttpProxy({
url: BASE_URL + 'data_controller/get_status ',
method: 'POST'
}),
root: 'data', autoLoad: true,
fields: [{ name: "idstatus" }, { name: "nmstatus" }]
});
var ds_dosenganti = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: BASE_URL + 'struprogdet_controller/get_dosenganti',
method: 'POST'
}),
baseParams: {
idstruprogdet:idstruprogdet,
},
totalProperty: 'results',
autoLoad : true,
root: 'data',
fields: [
{ name: "iddosenpengganti"}
, { name: "idstruprogdet"}
, { name: "nidu"}
, { name: "nmdosdgngelar"}
, { name: "tglaktif"}
, { name: "tglaktifrender"}
, { name: "idstatus"}
, { name: "nmstatus"}
, { name: "catatan" }
],
listeners: {
load: function(store, records, options) {
}
}
});
var cm_dosenganti = new Ext.grid.ColumnModel([
{
header: RH.h3('NIDU'), width: 90,
dataIndex: 'nidu', sortable: true
}, {
header: RH.h3('Dosen Pengganti'), width: 200,
dataIndex: 'nmdosdgngelar', sortable: true
}, {
header: RH.h3('Tgl Aktif'), width: 90,
dataIndex: 'tglaktifrender', sortable: true,
editor:{
xtype: 'datefield', id: 'tglaktif',
width: 100, value: new Date(),
format: 'd-m-Y',
listeners:{
select: function(field, newValue){
updatedosenganti('tglaktif',newValue);
},
change : function(field, newValue){
updatedosenganti('tglaktif',newValue);
}
}
}
}, {
header: RH.h3('Status'), width: 90,
dataIndex: 'nmstatus', sortable: true,
editor:{
xtype: 'combo', id: 'cb.frm.idstatus',
fieldLabel: 'Status',
store: ds_status, triggerAction: 'all',
valueField: 'idstatus', displayField: 'nmstatus',
forceSelection: true, submitValue: true,
mode: 'local', emptyText:'Pilih...', width: 90,
allowBlank: false, editable:false,
listeners:{
select: function(combo, record){
updatedosenganti('idstatus',combo.getValue());
}
}
}
}, {
header: RH.h3('Catatan'), width: 200,
dataIndex: 'catatan', sortable: true,
editor: new Ext.form.TextArea({
id: 'tf.catatan', height:75,
listeners : {
change :function(field, newVal, oldVal){
updatedosenganti('catatan',newVal);
}
}
}),
},
RH.DeleteColumn()
]);
var cari_dosenganti = [new Ext.ux.grid.Search({
iconCls: 'btn_search',
minChars: 1,
autoFocus: true,
autoHeight: true,
position: 'top',
mode: 'local',
width: 200
})];
var gp_dosenganti = new Ext.grid.EditorGridPanel({
id: 'gp.dosenganti',
ds: ds_dosenganti,
cm: cm_dosenganti,
plugins: cari_dosenganti,
sm: new Ext.grid.RowSelectionModel({ singleSelect: true}),
view: new Ext.grid.GridView({ emptyText: '< Belum ada Data >'}),
forceFit: true, height: 160, //width: 720,
border: true,
tbar: [{
text: 'Tambah', id: 'tb.add-strudetganti', iconCls: 'silk-add',
handler: function() {
var masterGrid = gp_dosenganti;
wLookupDosenMatkul(masterGrid, kdprodi, kdstsemester, kdmk, 1)
}
},'->'],
//bbar: [],
autoScroll: true,
autoSizeColumns: true,
enableColumnResize: true,
enableColumnHide: false,
enableColumnMove: false,
enableHdaccess: false,
columnLines: true,
loadMask: true,
layout: 'anchor',
listeners: {
cellclick: dosengantiklik
}
});
var wdosenganti = new Ext.Window({
title: 'Daftar Dosen Pengganti',
modal: true,
resizable: false,
layout: 'fit',
width:750, height:220,
items: [gp_dosenganti]
}).show();
function dosengantiklik(grid, rowIndex, columnIndex, e) {
var t = e.getTarget();
var record = grid.getStore().getAt(rowIndex);
iddosenpengganti = record.data['iddosenpengganti'];
if (t.className == 'imgDelete') {
deletedosenganti(grid, record);
return true;
}
}
function updatedosenganti(field,value) {
var stat='0';
if (field=='idstatus') {
ds_dosenganti.each(function (rec) {
if (rec.get('idstatus')=='1') {
stat = rec.get('idstatus');
}
});
}
if (stat=='1' && value=='1') {
Ext.Msg.alert("Info", "Dosen Pengganti Yang Aktif Harus Satu");
ds_dosenganti.reload();
return;
}
Ext.Ajax.request({
url: BASE_URL + 'struprogdet_controller/update_dosenganti',
params: {
iddosenpengganti: iddosenpengganti,
field : field,
value : value,
},
success: function() {
ds_dosenganti.reload();
},
failure: function() {
Ext.Msg.alert("Info", "Ubah Data Gagal");
ds_dosenganti.reload();
}
});
}
function deletedosenganti(grid, record){
var url = BASE_URL + 'struprogdet_controller/delete_dosenganti';
var params = new Object({
iddosenpengganti : iddosenpengganti,
});
RH.deleteGridRecord(url, params, grid );
}
}
//RETURN THE GRID PANEL for DETAIL
return gp_struprogdet;
}
/**
LOOKUP DOSEN FOR ADD STRUPROGDET
*/
function wLookupDosenMatkul(masterGrid, kdprodi, kdstsemester, kdmk, isGanti){
/**
DATA SOURCE
*/
var fieldsLookup = RH.storeFields('nmfakultas','nourutprodi','nmprodi','lnmprodi','nmjenjangstudi',
'nmstaktiv','nmstikj','nmdosen','kdprodi','kdstdosen','nidu','nidn','nmdostpgelar',
'nmdosdgngelar','kdjenjangstudi');
var ds_lookup = RH.JsonStore({
url : BASE_URL + 'data_controller/get_lookup_dos',
fields : fieldsLookup,
limit : 20,
params: [
{key:'kdprodi', value: kdprodi}
],
enableSearch: true,
});
//SEARCH COMPONENT
var sb_lookup = RH.searchComp({
id: 'sb_lookup',
fields : ['nidu:NIDU','nmdosen:Nama Dosen','nmprodi:Program Studi','nmstaktiv:Status Aktif'],
selected : 'kdmk',
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: 'Jenjang', width: 50,
dataIndex: 'nmjenjangstudi', sortable: true
}, {
header: 'Program Studi', width: 160,
dataIndex: 'nmprodi', 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 >' });
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 MATA KULIAH
*/
var wLookup = new Ext.Window({
id: 'w.look-dos',
title: 'Daftar Dosen',
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'];
var kdjenjangstudi = rec.data['kdjenjangstudi'];
//INSERT NEW STRUPROGDET REECORD (Dosen Pengampu)
if (isGanti==1) {
Ext.Ajax.request({
url: BASE_URL +'struprogdet_controller/insert_dosenganti',
method: 'POST',
params: {
idstruprogdet : RH.getCompValue('hidden.idstruprogdet',true),
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");
}
});
} else {
Ext.Ajax.request({
url: BASE_URL +'struprogdet_controller/insert_struprogdet',
method: 'POST',
params: {
kdprodi : kdprodi,
kdstsemester : kdstsemester,
kdmk : kdmk,
nidu : nidu,
kdprodidosen : kdprodidosen,
kdjenjangstudi : kdjenjangstudi
},
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");
}
});
}
}
}