function setNameWTitle(){ //RH.setNameWTitle(idFrontT, idBackT, idName, idNameWT) RH.setNameWTitle('tf.glrdpn-dos', 'tf.glrblk-dos', 'tf.nama-dos', 'tf.namawgelar-dos'); } function fnAddDosen(){ Ext.getCmp('tp.dosTabs').setActiveTab(0); Ext.getCmp('tb.save-dos').enable(); Ext.getCmp('tb.save-dos').show(); Ext.getCmp('tb.update-dos').hide(); var tabRiwayatpdk = Ext.getCmp('tab.history-dos'); RH.removeDetail('pn.riwayatpdk'); tabRiwayatpdk.disable(); enableDosContents(); resetDosContents(); // ENABLING the combos which create NIDU Ext.getCmp('cb.prodi-dos').enable(); Ext.getCmp('cb.status-dos').enable(); Ext.getCmp('fp.dosDispPanel').getForm().reset(); sett_oto_nidu(); } function fnGetRiwayatpdk(nidu){ var tabPanel = Ext.getCmp('tp.dosTabs'); var tabRiwayatpdk = Ext.getCmp('tab.history-dos'); var gpRiwayatpdk = grid_riwayatdos(nidu); RH.loadDetail('pn.riwayatpdk',gpRiwayatpdk); tabRiwayatpdk.enable(); tabPanel.doLayout(tabRiwayatpdk); } function fnEditDosen(){ Ext.getCmp('tb.save-dos').hide(); Ext.getCmp('tb.update-dos').enable(); Ext.getCmp('tb.update-dos').show(); enableDosContents(); //NIDU disable Ext.getCmp('tf.nidu-dos').disable(); // disabling the combos which create NIDU Ext.getCmp('cb.prodi-dos').disable(); Ext.getCmp('cb.status-dos').disable(); } function fnSaveDosen(sType){ //DEFAULT FOR NAMA DOSEN DG GELAR var nmdos = Ext.getCmp('tf.nama-dos').getValue(); var nmdosWgelar = Ext.getCmp('tf.namawgelar-dos').getValue(); var glrdpn = Ext.getCmp('tf.glrdpn-dos').getValue(); var glrblk = Ext.getCmp('tf.glrblk-dos').getValue(); if(glrdpn == '' || glrdpn == null) glrdpn = ''; else glrdpn = glrdpn + '. '; if(glrblk == '' || glrblk == null) glrblk = ''; else glrblk = ', ' + glrblk; if(nmdosWgelar == '' || nmdosWgelar == null) nmdosWgelar = glrdpn + nmdos + glrblk; Ext.getCmp('tf.namawgelar-dos').setValue(nmdosWgelar); if(sType == 'insert'){ insertDos(); } if(sType == 'update'){ updateDos(); } } function insertDos(){ // SETUP PARAMETER (variabel), untuk parameter berupa fungsi langsung saat submit di-call var idForm = 'fp.dosFTabPanel'; var sUrl = BASE_URL +'dosen_controller/insert_dos'; 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)!'; // SET AUTO NIDU %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% var kdfakultas = RH.getFieldValue('cb.prodi-dos','kdprodi','kdfakultas'); //kdfakultas = kdfakultas.replace(/^\s+|\s+$/g,''); //for trim kdfakultas = kdfakultas.trim(); var noprodi = RH.getFieldValue('cb.prodi-dos','kdprodi','nourutprodi'); //fungsi dari rhFunctions //noprodi = noprodi.replace(/^\s+|\s+$/g,''); // from trim noprodi = noprodi.trim(); noprodi = noprodi.substr(noprodi.length - 1, 1); var kdstatus = Ext.getCmp('cb.status-dos').getValue().trim(); var prefixNIDU = kdfakultas + noprodi + kdstatus; if (Ext.getCmp('oto1').getValue()=="Auto-Generate") { Ext.Ajax.request({ url: BASE_URL + 'dosen_controller/get_autoNIDU', method: 'POST', params :{ prefix : prefixNIDU }, scope: this, async:false, waitMsg: "NIDU sedang diproses...", success: function(result){ var jsonData = Ext.decode(result.responseText); //bisa utk Ext3 dan Ext4 var nidu = jsonData.nidu; Ext.getCmp('tf.nidu-dos').setValue(nidu); if(RH.isEmpty('tf.nidu-dos')) { RH.warning('NIDU gagal dibuat'); return; } else { Ext.Msg.alert("Info:", "NIDU : " + Ext.getCmp('tf.nidu-dos').getValue()); var sParams = getInsertDosParams(); //call form submit function (common function by RH) RH.submitForm(idForm, sUrl, sParams, afterSaveDosSuccess(), msgWait, msgSuccess, msgFail, msgInvalid); } } }); } else { var sParams = getInsertDosParams(); //call form submit function (common function by RH) RH.submitForm(idForm, sUrl, sParams, afterSaveDosSuccess(), msgWait, msgSuccess, msgFail, msgInvalid); } } function updateDos(){ // SETUP PARAMETER var idForm = 'fp.dosFTabPanel'; var sUrl = BASE_URL +'dosen_controller/update_dos'; var sParams = getInsertDosParams(); //getUpdateDosParams(); var msgWait = 'Tunggu, sedang proses update...'; var msgSuccess = 'Update data berhasil'; var msgFail = 'Update data gagal'; var msgInvalid = 'Data belum valid (data primer belum terisi)!'; /* RH.submitForm(idForm, sUrl, sParams, afterSaveDosSuccess(), msgWait, msgSuccess, msgFail, msgInvalid); */ var waitmsg = Ext.MessageBox.wait('Tunggu, sedang proses...', 'Info'); Ext.Ajax.request({ url: sUrl, method: 'POST', params: sParams, success: function() { waitmsg.hide(); Ext.Msg.alert("Info", "Ubah Data Berhasil"); afterSaveDosSuccess(); }, failure: function(result){ waitmsg.hide(); Ext.MessageBox.alert("Info", "Ubah Data Gagal"); } }); } function enableDosContents(){ Ext.getCmp('content.personal-dos').enable(); Ext.getCmp('content.kontak-dos').enable(); Ext.getCmp('content.lain-dos').enable(); } function disableDosContents(){ Ext.getCmp('content.personal-dos').disable(); Ext.getCmp('content.kontak-dos').disable(); Ext.getCmp('content.lain-dos').disable(); } function resetDosContents(){ Ext.getCmp('fp.dosFTabPanel').getForm().reset(); /* Ext.getCmp('content.personal-dos').getForm().reset(); Ext.getCmp('content.kontak-dos').getForm().reset(); Ext.getCmp('content.lain-dos').getForm().reset(); */ } function afterSaveDosSuccess(){ Ext.getCmp('tb.save-dos').disable(); Ext.getCmp('tb.update-dos').disable(); disableDosContents(); setDisplayDos(); } function setDisplayDos(){ var nidu = Ext.getCmp('tf.nidu-dos').getValue(); var nidn = Ext.getCmp('tf.nidn-dos').getValue(); var name_l = Ext.getCmp('tf.namawgelar-dos').getValue(); var faculty = RH.getFieldValue('cb.prodi-dos', 'kdprodi', 'nmfakultas'); var prody = RH.getFieldValue('cb.prodi-dos', 'kdprodi', 'nmprodi'); var stactiv = RH.getFieldValue('cb.staktiv-dos', 'kode', 'nama'); var stikj = RH.getFieldValue('cb.stikj-dos', 'kode', 'nama'); Ext.getCmp('frm.nidu').setValue(nidu); Ext.getCmp('frm.nidn').setValue(nidn); Ext.getCmp('frm.nama_l-dos').setValue(name_l); Ext.getCmp('frm.fakultas-dos').setValue(faculty); Ext.getCmp('frm.prodi-dos').setValue(prody); Ext.getCmp('frm.staktiv-dos').setValue(stactiv); Ext.getCmp('frm.stikj-dos').setValue(stikj); } // GET PARAMETERS FOR INSERT function getInsertDosParams(){ return new Object({ //PERSONAL TAB's Fields kdprodi : Ext.getCmp('cb.prodi-dos').getValue(), kdstdosen : Ext.getCmp('cb.status-dos').getValue(), nidu : Ext.getCmp('tf.nidu-dos').getValue(), nup : Ext.getCmp('tf.nup-dos').getValue(), nidn : Ext.getCmp('tf.nidn-dos').getValue(), nmdostpgelar : Ext.getCmp('tf.nama-dos').getValue(), nmdosdgngelar : Ext.getCmp('tf.namawgelar-dos').getValue(), gelardpn : Ext.getCmp('tf.glrdpn-dos').getValue(), gelarblk : Ext.getCmp('tf.glrblk-dos').getValue(), gelartertinggi : Ext.getCmp('tf.glrtop-dos').getValue(), tptlahir : Ext.getCmp('tf.tplahir-dos').getValue(), tgllahir : Ext.getCmp('df.tglahir-dos').getValue(), kdjnskelamin : Ext.getCmp('cb.gender-dos').getValue(), kdjabakademik : Ext.getCmp('cb.jabak-dos').getValue(), noktp : Ext.getCmp('tf.noktp-dos').getValue(), kdpendidikantertinggi : Ext.getCmp('cb.pdktop-dos').getValue(), kdstikatankerjadosen : Ext.getCmp('cb.stikj-dos').getValue(), kdstaktivitasdosen : Ext.getCmp('cb.staktiv-dos').getValue(), kdstsemester : Ext.getCmp('cb.smt-dos').getValue(), nippns : Ext.getCmp('tf.nip-dos').getValue(), kdpt : Ext.getCmp('tf.kdhome-dos').getValue(), idgoldarah : Ext.getCmp('cb.goldarah-dos').getValue(), kdwarga : Ext.getCmp('cb.wn-dos').getValue(), foto : Ext.getCmp('frm.foto').getValue(), //KONTAK alamat : Ext.getCmp('tf.alamat-dos').getValue(), kelurahan : Ext.getCmp('tf.kel-dos').getValue(), kecamatan : Ext.getCmp('tf.kec-dos').getValue(), kdkotkab : Ext.getCmp('tf.kdkota-dos').getValue(), kdpos : Ext.getCmp('tf.kdpos-dos').getValue(), notelp : Ext.getCmp('tf.telp-dos').getValue(), email : Ext.getCmp('tf.email-dos').getValue(), facebook : Ext.getCmp('tf.fb-dos').getValue(), twitter : Ext.getCmp('tf.twit-dos').getValue(), pinbb : Ext.getCmp('tf.pinbb-dos').getValue(), website : Ext.getCmp('tf.web-dos').getValue(), //LAINNYA catatan : Ext.getCmp('ta.notes-dos').getValue(), tglhariini : Ext.getCmp('df.tglhri-dos').getValue(), pass: Ext.getCmp('df.tglahir-dos').getValue().format('dmY'), }); } function upload_foto_dosen(namaForm, Opsi) { var form_nya = Ext.getCmp(namaForm); /* var isi = Ext.getCmp('file_gambar').getValue(); if (isi) { fnSaveDosen(Opsi); } else { */ if (Ext.getCmp('oto1').getValue()!='Auto-Generate') { if(RH.isEmpty('tf.nidu-dos')){ RH.warning('NIDU Dosen harus diisi'); return; }; } if(RH.isEmpty('cb.prodi-dos')){ RH.warning('Program Studi harus diisi'); return; }; //if(RH.isEmpty('tf.nidu-dos')){ RH.warning('Nomor Induk Dosen Unla (NIDU) harus diisi'); return; }; if(RH.isEmpty('tf.nama-dos')){ RH.warning('Nama Dosen harus diisi'); return; }; if(RH.isEmpty('tf.glrtop-dos')){ RH.warning('Gelar Profesional Tertinggi harus diisi'); return; }; //if(RH.isEmpty('cb.gender-dos')){ RH.warning('Jenis Kelamin harus diisi'); return; }; //if(RH.isEmpty('cb.agama-dos')){ RH.warning('Agama harus diisi'); return; }; // NO Religion in Form //if(RH.isEmpty('cb.wn-dos')){ RH.warning('Kewarganegaraan harus diisi'); return; }; //if(RH.isEmpty('cb.stikj-dos')){ RH.warning('Status Iktan Kerja harus diisi'); return; }; //if(RH.isEmpty('cb.staktiv-dos')){ RH.warning('Status Aktivasi harus diisi'); return; }; form_nya.getForm().submit({ url: BASE_URL + 'dosen_controller/upload', method: 'POST', params: { oldphoto:Ext.getCmp('frm.foto').getValue(), newphoto:Ext.getCmp('file_gambar').getValue() }, success: function(form_bp_general, o) { if (o.result.success == 'true') { dosen_foto_ori(o.result.newfile); Ext.getCmp('frm.foto').setValue(o.result.newfile); fnSaveDosen(Opsi); } else if (o.result.success == 'false1') { Ext.MessageBox.alert('Informasi', 'File ' + o.result.nama + ' gagal di upload, Ukuran file maksimal 800kb'); } else if (o.result.success == 'false2') { Ext.MessageBox.alert('Informasi', 'File ' + o.result.nama + ' gagal di upload, File harus ber tipe image'); } } }); //} }