function pPtinggi(){
//store data kolom
var fields_ptinggi = RH.storeFields('kdbadanhukum','kdpt','nmpt','alamat1','alamat2','kota','kdpos','notelp','nofax',
'tglakta','noakta','email','website','tglberdiri','gambar1','gambar2');
var pageSize = 15;
var ds_ptinggi = RH.JsonStore({
url : BASE_URL + 'ptinggi_controller/get_ptinggi',
fields : fields_ptinggi,
limit: pageSize,
enableSearch: true,
});
//badan hukum
var ds_bdnhkm = new Ext.data.JsonStore({ //from database
proxy: new Ext.data.HttpProxy({
url: BASE_URL + 'data_controller/get_bdnhkm',
method: 'POST'
}),
autoLoad: true,
root: 'data',
fields: [
{ name: "kdbadanhukum", mapping: "kdbadanhukum" }
, { name: "nmbadanhukum", mapping: "nmbadanhukum" }
]
});
//SEARCH COMPONENT
var sb_ptinggi = RH.searchComp({
id : 'sb_ptinggi',
fields : ['kdbadanhukum:Kode', 'nmbadanhukum:Nama'],
selected : 'kdbadanhukum',
store : ds_ptinggi
});
//render gambar1
function renderGbr1(val1) {
return '';
}
//render gambar2
function renderGbr2(val2) {
return '';
}
//kolom
var cm_ptinggi = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),
{
header: "Gambar 1",
renderer: renderGbr1,
align:'center',
dataIndex: 'gambar1',
sortable: true,
},
{
header: "Gambar 2",
renderer: renderGbr2,
align:'center',
dataIndex: 'gambar2',
sortable: true,
},
{
header: 'Nama',width: 200,
dataIndex: 'nmpt',
sortable: true
},
{
header: 'Alamat',width: 200,
dataIndex: 'alamat1',
sortable: true
},
{
header: 'Kode Pos',width: 80,
dataIndex: 'kdpos',
sortable: true
},
{
header: 'No.Tlp',width: 80,
dataIndex: 'notelp',
sortable: true
},
{
header: 'No.Fax',width: 80,
dataIndex: 'nofax',
sortable: true
},
{
header: 'Email',width: 80,
dataIndex: 'email',
sortable: true
},
{
header: 'Website',width: 80,
dataIndex: 'website',
sortable: true
},
RH.EditColumn(), RH.DeleteColumn()
]
);
/** THE GRID */
var gp_ptinggi = RH.GridPanel_T1({
ds: ds_ptinggi,
cm: cm_ptinggi,
singleSelect: true,
allowAdd: true,
searchComp: sb_ptinggi,
fnAdd: fnAddptinggi,
pageSize: pageSize,
cellclick: onCellptinggiClick
});
var fp_ptinggi = RH.GPContainer1({
title: 'Perguruan Tinggi', iconCls:'silk-house',
gridPanel: gp_ptinggi,
}); SET_PAGE_CONTENT(fp_ptinggi);
//cekdata row
function cekrow(){
var allowAdd;
/* gp_ptinggi.getStore().each(function(rec){ // ambil seluruh grid prodi
var rowData = rec.data; */
if (gp_ptinggi.getStore().getCount() == 0) {
allowAdd= true;
} else {
allowAdd= false;
}
/* if (rowData['kdbadanhukum']) {
allowAdd= false
}else{
allowAdd= true
} */
/* }); */
return allowAdd;
}
/** FUNCTIONS*/
function onCellptinggiClick(grid, rowIndex, columnIndex, e) {
var record = grid.getStore().getAt(rowIndex); // Get the Record
RH.EditClick(e, function(){fnEditptinggi(grid, record)});
RH.DeleteClick(e, function(){fnDeleteptinggi(grid, record)});
}
function reloadptinggi(){
ds_ptinggi.reload();
}
function fnAddptinggi(){
var grid = gp_ptinggi;
var cek= cekrow();
//kodisi rows
//if (cek) {
wform_ptinggi(false, grid, null);
//} else if (!cek) {
//Ext.Msg.alert("Info", "Data sudah ada, maaf anda tidak bisa menambah data");
//}
}
function fnEditptinggi(grid, record){
wform_ptinggi(true, grid, record);
}
function fnDeleteptinggi(grid, record){
var url = BASE_URL + 'ptinggi_controller/delete_ptinggi';
var params = new Object({
kdpt : record.data['kdpt'],
gambar1 : record.data['gambar1'],
gambar2 : record.data['gambar2']
});
RH.deleteGridRecord(url, params, grid );
}
/* form panel */
function wform_ptinggi(isUpdate, grid, record){
var winTitle = (isUpdate)?'Perguruan Tinggi (Edit)':'Perguruan Tinggi (Entry)';
var ptinggi_form = new Ext.form.FormPanel({
xtype:'form',
id: 'frm.ptinggi',
fileUpload: true,
buttonAlign: 'left',
labelWidth: 250, labelAlign: 'right',
bodyStyle: 'padding:10px 3px 3px 5px', // atas, kanan, bawah, kiri
monitorValid: true,
height: 500, width: 700,
autoScroll: true,
layout: 'form',
frame: false,
items: [
{
xtype: 'combo', id: 'cb.frm.bdnhukum',
fieldLabel: 'Badan Hukum',
store: ds_bdnhkm, triggerAction: 'all',
valueField: 'kdbadanhukum', displayField: 'nmbadanhukum',
forceSelection: true, submitValue: true,
mode: 'local', emptyText:'Pilih...', width: 250,
editable: false
},
{
xtype: 'textfield',
id: 'idkdpt',
fieldLabel: 'Kode PT',
width: 250,
allowBlank: false,
},
{
xtype: 'textfield',
id: 'idnmpt',
fieldLabel: 'Nama PT',
width: 250,
allowBlank: false,
},
{
xtype: 'textfield',
id: 'idalamat1',
fieldLabel: 'Alamat 1',
width: 300,
allowBlank: false,
},
{
xtype: 'textfield',
id: 'idalamat2',
fieldLabel: 'Alamat 2',
width: 300,
allowBlank: false,
},
{
xtype: 'textfield',
id: 'idkota',
fieldLabel: 'Kota',
width: 250,
allowBlank: false,
},
{
xtype: 'textfield',
id: 'idkdpos',
fieldLabel: 'Kode Pos',
width: 250,
allowBlank: false,
},
{
xtype: 'textfield',
id: 'idnotelp',
fieldLabel: 'No.Tlp',
width: 250,
allowBlank: false,
},
{
xtype: 'textfield',
id: 'idnofax',
fieldLabel: 'No.Fax',
width: 250,
allowBlank: false,
},
{
xtype: 'datefield',
id: 'idtglakta',
fieldLabel: 'Tgl.Akta/SK',
width: 100,
allowBlank: false,
},
{
xtype: 'textfield',
id: 'idnoakta',
fieldLabel: 'No.Akta/SK',
width: 250,
allowBlank: false,
},
{
xtype: 'textfield',
vtype:'email',
id: 'idemail',
fieldLabel: 'Email',
width: 250,
allowBlank: false,
},
{
xtype: 'textfield',
id: 'idwebsite',
fieldLabel: 'website',
width: 250,
allowBlank: false,
},
{
xtype: 'datefield',
id: 'idtglberdiri',
fieldLabel: 'Tgl.Berdiri PT',
width: 100,
allowBlank: false,
},
{
xtype: 'textfield',
id: 'idimage1',
fieldLabel: 'image2',
hidden: true,
},
{
xtype: 'textfield',
id: 'idimage2',
fieldLabel: 'image2',
hidden: true,
},
{
xtype: 'fileuploadfield',
id: 'filedata1',
//name: 'filedata1',
emptyText: 'Select an image to upload...',
fieldLabel: 'Gambar 1',
width: 230,
allowBlank: false,
buttonText: 'Browse'
},
{
xtype: 'fileuploadfield',
id: 'filedata2',
//name: 'filedata2',
emptyText: 'Select an image to upload...',
fieldLabel: 'Gambar 2',
width: 230,
allowBlank: false,
buttonText: 'Browse'
}],
buttons: [{
text: 'Simpan', iconCls:'silk-save',
handler: function() {
fnSaveptinggi(record);
}
}, {
text: 'Kembali', iconCls:'',
handler: function() {
wptinggi.close();
}
}]
});
//variable show window
var wptinggi = new Ext.Window({
title: winTitle,
modal: true, closable:false,
items: [ptinggi_form]
});
/**CALL SET FORM AND SHOW THE FORM (WINDOW)*/
setptinggi(isUpdate, record);
wptinggi.show();
/**FORM FUNCTIONS*/
function setptinggi(isUpdate, record){
if(isUpdate){
if(record != null){
//Ext.getCmp('idkdpt').hide();
RH.setCompValue('cb.frm.bdnhukum', record.data['kdbadanhukum']);
RH.setCompValue('idkdpt', record.data['kdpt']);
RH.setCompValue('idnmpt', record.data['nmpt']);
RH.setCompValue('idalamat1', record.data['alamat1']);
RH.setCompValue('idalamat2', record.data['alamat2']);
RH.setCompValue('idkota', record.data['kota']);
RH.setCompValue('idkdpos', record.data['kdpos']);
RH.setCompValue('idnotelp', record.data['notelp']);
RH.setCompValue('idnofax', record.data['nofax']);
RH.setCompValue('idtglakta', record.data['tglakta']);
RH.setCompValue('idnoakta', record.data['noakta']);
//RH.setCompValue('idtglpengesahan', record.data['tglpengesahan']);
//RH.setCompValue('idnopengesahan', record.data['nopengesahan']);
RH.setCompValue('idemail', record.data['email']);
RH.setCompValue('idwebsite', record.data['website']);
RH.setCompValue('idtglberdiri', record.data['tglberdiri']);
RH.setCompValue('filedata1', record.data['gambar1']);
RH.setCompValue('filedata2', record.data['gambar2']);
RH.setCompValue('idimage1', record.data['gambar1']);
RH.setCompValue('idimage2', record.data['gambar2']);
return;
return;
}
}
}
//fungsi simpan
function fnSaveptinggi(record){
//var idForm = 'frm.ptinggi';
var idForm = Ext.getCmp('frm.ptinggi');
var sUrl = BASE_URL +'ptinggi_controller/insert_ptinggi';
var sParams = getInsertptinggiParams();
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)!';
if(isUpdate){
sUrl = BASE_URL +'ptinggi_controller/update_ptinggi';
msgSuccess = 'Update data berhasil';
msgFail = 'Update data gagal';
}
//call form grid submit function (common function by RH)
//RH.submitGridForm(idForm, sUrl, sParams, grid, wptinggi,
//msgWait, msgSuccess, msgFail, msgInvalid);
idForm.getForm().submit({
url: sUrl,
method: 'POST',
params: getInsertptinggiParams,
success: function(form_bp_general, o) {
if (o.result.success == 'true') {
Ext.MessageBox.alert('Informasi', o.result.message);
ds_ptinggi.reload();
} else if (o.result.success == 'false') {
Ext.MessageBox.alert('Informasi', o.result.message);
ds_ptinggi.reload();
}
wptinggi.close();
}
});
}
function getInsertptinggiParams(){
return new Object({
kdbdnhukum : RH.getCompValue('cb.frm.bdnhukum'),
kdpt : RH.getCompValue('idkdpt'),
nmpt : RH.getCompValue('idnmpt'),
alamat1 : RH.getCompValue('idalamat1'),
alamat2 : RH.getCompValue('idalamat2'),
kota : RH.getCompValue('idkota'),
kdpos : RH.getCompValue('idkdpos'),
notelp : RH.getCompValue('idnotelp'),
nofax : RH.getCompValue('idnofax'),
tglakta : RH.getCompValue('idtglakta'),
noakta : RH.getCompValue('idnoakta'),
//tglpengesahan : RH.getCompValue('idtglpengesahan'),
//nopengesahan : RH.getCompValue('idnopengesahan'),
email : RH.getCompValue('idemail'),
website : RH.getCompValue('idwebsite'),
tglberdiri : RH.getCompValue('idtglberdiri'),
userfile1 : RH.getCompValue('filedata1'),
userfile2 : RH.getCompValue('filedata2'),
/* image1 : RH.getCompValue('idimage1'),
image2 : RH.getCompValue('idimage2'), */
//tempgbr1 : record.data['gambar1'],
//tempgbr2 : record.data['gambar2'],
});
}
}
}