Code:
purchase.core.purchase_requisition.form = Ext.extend(Ext.form.FormPanel,{
constructor: function(config)
{
config = config||{};
config.labelWidth = config.labelWidth || 120;
config.frame = config.frame || true;
config.autoHeight = config.autoHeight || true;
config.title = config.title || 'Purchase Requisition Form';
config.bodyStyle = config.bodyStyle || 'padding:1px 1px 1px';
config.width = config.width || 365;
config.defaults = {width: 200},
config.border = config.border || false;
purchase.core.purchase_requisition.form.superclass.constructor.call(this, config);
},
initComponent: function()
{
Ext.apply(this,{
items: [{
xtype:'fieldset',
layout:'column',
autoHeight:true,
width: 1500,
items:[{
columnWidth:.300,
layout: 'form',
items: [
{
xtype:'textfield',
fieldLabel: 'PR Number',
anchor:'70%',
name: 'pr_number',
id: 'pr_number',
//value:tes,
readOnly:true
},
{
xtype:'textfield',
fieldLabel: 'Order for Delivery to',
anchor:'70%',
name: 'pr_order_for_delivery_to',
id: 'pr_order_for_delivery_to'
}, {
xtype:'textarea',
fieldLabel: 'Purpose Required',
anchor:'70%',
name: 'pr_purposed_required',
id: 'pr_purposed_required'
}, {
xtype:'datefield',
fieldLabel: 'Date required',
name: 'pr_date_required',
id: 'pr_date_required',
anchor:'70%'
},{
xtype:'hidden',
fieldLabel: 'action',
name: 'action',
id: 'action',
value : 'save',
anchor:'80%'
}
]
},
{
columnWidth:.300,
layout: 'form',
items: [{
xtype:'combo',
fieldLabel: 'Branch',
id:'pr_branch',
store: new purchase.core.purchase_requisition.comboStoreBranch(),
name: 'pr_branch',
displayField : 'branch_name',
mode:'remote',
valueField : 'branch_id',
hideTrigger:false,
triggerAction : 'all',
minChars:2,width: 250,
typeAhead : true,
loadingText: 'Please Wait...',
forceSelection : true,
editable: false,
emptyText : 'Select Branch',
selectOnFocus : true,
anchor:'70%',
allowBlank: true,
},
{
xtype:'combo',
fieldLabel: 'Division',
id:'pr_division',
store: new purchase.core.purchase_requisition.comboStoreDivisi(),
name: 'pr_division',
displayField : 'divisi_name',
mode:'remote',
valueField : 'divisi_id',
hideTrigger:false,
triggerAction : 'all',
minChars:2,width: 250,
typeAhead : true,
loadingText: 'Please Wait...',
forceSelection : true,
editable: false,
emptyText : 'Select Divisi',
selectOnFocus : true,
anchor:'70%',
allowBlank: true,
}
,{
xtype:'combo',
fieldLabel: 'Department',
store: new purchase.core.purchase_requisition.comboStoreDepartment(),
id:'pr_department',
name: 'pr_department',
displayField : 'department_name',
mode:'remote',
valueField : 'department_id',
hideTrigger:false,
triggerAction : 'all',
minChars:2,width: 250,
typeAhead : true,
loadingText: 'Please Wait...',
forceSelection : true,
editable: false,
emptyText : 'Select Department',
selectOnFocus : true,
anchor:'70%',
allowBlank: true,
}
,{
xtype:'combo',
fieldLabel: 'Ship Mode',
id:'pr_shipmode',
store: values,
name: 'pr_shipmode',
store: values,
displayField:'value',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'Select Ship Mode...',
loadingText: 'Please Wait...',
selectOnFocus:true,
anchor:'70%',
allowBlank: true,
}
]
},
]}
],
buttonAlign: 'center',
buttons:[
{
text: 'Save',
iconCls:'icon-disk ',
listeners:
{
click:
{
scope: this,
fn: savePurchaseRequisition
}
}
},
{
text: 'Cancel',
listeners:
{
click:
{
scope:this,
fn: function()
{
this.getForm().reset();
}
}
}
}]
});
function savePurchaseRequisition()
{
if(this.getForm().isValid())
{
Ext.Ajax.request
({
url: purchase.core.purchase_requisition.controller +'/save',
params: this.getForm().getValues(),
callback: function(options, success, response)
{
var respon = response.responseText;
console.log('response: '+respon);
if(respon == '1')
{
Ext.getCmp('pr_grid').getStore().reload();
Ext.MessageBox.alert('Status','Purchase Requisition Has Been Saved..',response.responseText);
}
else
{
Ext.MessageBox.alert('Purchase Requisition Saving Failed..',response.responseText);
}
}
});
}
this.getForm().reset();
}
purchase.core.purchase_requisition.form.superclass.initComponent.apply(this, arguments);
},
getFormValues: function()
{
var retVal = {};
this.items.each(function(item) {
retVal[item.name] = item.getValue();
});
return retVal;
}
});