Cita:
Muchas gracias por su ayuda... empresasTab = function(p){
this.empresasSelModel = new Ext.grid.CheckboxSelectionModel({
singleSelect:true,
moveEditorOnEnter: false
});
var escritura=true;
if(p) escritura=false;
this.empresasColumnModel = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),this.empresasSelModel,
{dataIndex: 'idempresa',hidden: true},{dataIndex:'ruc',header:'RUC',renderer:addTo oltip,width: 60},{dataIndex:'razonsocial',header:'Razon Social',renderer:addTooltip,hidden:false,width: 200},{dataIndex:'emp_alias',header:'Alias',rendere r:addTooltip,hidden:false,width:200},{dataIndex:'t elefono',header:'Telefono',renderer:addTooltip,hid den:false,width:70},{dataIndex:'email',header:'Ema il',renderer:addTooltip,hidden:false,width:120},{d ataIndex:'cliente',header:'Cliente',renderer:addTo oltip,hidden:false,sortable:true,width:120},{dataI ndex:'proveedor',header:'Proveedor',renderer:addTo oltip,hidden:false,sortable:true,width: 120},{dataIndex:'transportista',header:'Transporti sta',renderer:addTooltip,hidden:false,sortable:tru e,width: 120},{dataIndex:'zonatrabajo',header:'Zona',render er:addTooltip,hidden:false,width:120}]);
this.empresasColumnModel.defaultSortable = true;
this.empresasDataStore = new Ext.data.GroupingStore({
id: 'empresasDataStore',reader: new Ext.data.JsonReader({
fields:[
{name: 'idempresa', type: 'string'},{name: 'razonsocial', type: 'string'},{name: 'ruc', type: 'string'},{name: 'cliente', type: 'string'},
{name: 'proveedor', type: 'string'},{name: 'activo', type: 'numeric'},{name: 'telefono', type: 'string'},{name: 'emp_alias', type: 'string'},
{name: 'transportista', type: 'string'},{name: 'email', type: 'string'},{name: 'zonatrabajo', type: 'string'}
],root: 'rows',totalProperty: 'results'
}),proxy: new Ext.data.HttpProxy({url:BASE_URL+'mantenimientos/empresa/ext_get_all',method: 'POST'}),remoteSort: true
});
this.verDetalle = function(){
Ext.getCmp('detalleEmpresaForm').expand();
Ext.getCmp('btnFrmEmpresaGuardar').hide();
Ext.getCmp('btnFrmEmpresaCancelar').hide();
Ext.getCmp('btnFrmEmpresaEditar').show();
Ext.getCmp('btnFrmEmpresaEditar').enable();
}
this.empresasGrid = new Ext.grid.GridPanel({
id: 'empresasGridPanel',store: this.empresasDataStore,plugins:[filters,new Ext.grid.GridSummary()],view: new Ext.grid.GroupingView({forceFit:true}),sm:this.emp resasSelModel,cm:this.empresasColumnModel,enableCo lLock:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:false}),t bar:new Ext.Toolbar({
items:[
{text: 'Agregar',icon: BASE_PATH + 'assets/img/iconos/add.gif',handler: this.agregarEmpresa,disabled: escritura}, '-',
{text: 'Eliminar',icon: BASE_PATH + 'assets/img/iconos/delete.gif',disabled: escritura,handler: this.confirmarEliminacion}, '-',
//{text: 'Exportar',icon: BASE_PATH + 'assets/img/iconos/excel.png',handler: this.exportarExcel},'-',
{text: 'Ver Detalle',id: 'btnFrmEmpresaDetalle',icon: BASE_PATH + 'assets/img/iconos/detalle.png',handler: this.verDetalle},
]
}),
bbar: new Ext.PagingToolbar({
pageSize: 15,store: this.empresasDataStore,displayInfo: true
}),listeners : {
render: function(grid){
loadMask(grid,true,'Cargando...')
grid.getStore().load({callback: function(grid){loadMask(tabEmpresas.empresasGrid,f alse,'')}
});
}
}
});
/*FORMULARIO*/
var categoriesRecord = new Ext.data.Record.create([
{name: 'EmpresaFormIdEmpresa', type: 'int',mapping: 'idempresa'},
{name: 'EmpresaFormRazonSocial',type: 'string',mapping: 'razonsocial'},
{name: 'EmpresaFormRuc', type: 'string',mapping: 'ruc'},
{name: 'EmpresaFormCliente', type: 'string',mapping: 'cliente'},
{name: 'EmpresaFormProveedor', type: 'string',mapping: 'proveedor'},
{name: 'EmpresaFormTransportista',type: 'string',mapping: 'transportista'},
{name: 'EmpresaFormActivo', type: 'numeric',mapping: 'activo'},
{name: 'EmpresaFormNroTlf', type: 'string',mapping: 'telefono'},
{name: 'EmpresaFormEmpAlias', type: 'string',mapping: 'emp_alias'},
{name: 'EmpresaFormEmail', type: 'string',mapping: 'email'},
{name: 'EmpresaFormZonaTrab', type: 'string',mapping: 'zonatrabajo'}
]);
var categoriesFormReader = new Ext.data.JsonReader({
root : 'rows',
successProperty : 'success',
totalProperty: 'total',
id: 'cad_id'
},categoriesRecord);
this.resetForm = function(opt){
Ext.getCmp('empresasForm').getForm().reset();
Ext.getCmp('empresasGridPanel').getSelectionModel( ).clearSelections();
Ext.getCmp('primerPanelEmpresa').expand();
}
this.enableFields=function(){
this.empresasForm.getForm().items.each(function(f) {
if(f.isFormField && f.initialConfig.id!='EmpresaFormRuc'){f.enable();}
f.addClass("green-field");
});
}
this.disableFields=function(){
this.empresasForm.getForm().items.each(function(f) {
if(f.isFormField){
f.disable();
}
f.removeClass("green-field");
});
}
this.loadForm=function(){
tabEmpresas.disableFields();
Ext.getCmp('btnFrmEmpresaEditar').show();
Ext.getCmp('btnFrmEmpresaCancelar').hide();
Ext.getCmp('btnFrmEmpresaGuardar').hide();
r=Ext.getCmp('empresasGridPanel').getSelectionMode l().getSelected();
if(r!=undefined){Ext.getCmp('empresasForm').load({ params:{idempresa:r.data.idempresa},waitMsg:'Carga ndo...'});}}
this.empresasForm = new Ext.FormPanel({
id : 'empresasForm',
frame : false, border: false, buttonAlign: 'center',
height : 430,
waitMsgTarget:true,
autoScroll : true,
listeners :{
beforeaction: function(){
if(r!=undefined){
PStores.storeBooleano.load({params:{cliente:r.data .cliente}})
PStores.storeBooleano.load({params:proveedor:r.dat a.proveedor}})
PStores.storeBooleano.load({params:transportista:r .data.transportista}})
return true;
}
return true;
}
},
url:BASE_URL +'mantenimentos/empresa/getEmpresas', method: 'POST',
reader:categoriesFormReader,
items : [
{xtype: 'tabpanel',border: false,activeTab: 0,enableTabScroll: true,
items :[
{layout: 'fit',id:'primerPanelEmpresa',xtype: 'panel',autoHeight: true, padding: '5px 5px',margins: '2px',name: 'panelAcordion',title: 'Empresa',
items:[
{layout: 'form',xtype: 'fieldset',autoHeight: true,labelWidth: 90,padding: '2px 2px',title: 'Informacion de la Empresa',
items:[
{xtype: 'numberfield',id:'EmpresaFormIdEmpresa',hidden : true},{xtype: 'numberfield',fieldLabel: 'Número RUC',id:'EmpresaFormRuc',allowBlank: false,maxlength: '11',autocomplete: 'off'},
{xtype: 'textfield',fieldLabel:'Razon Social',id:'EmpresaFormRazonSocial',allowBlank: false},{xtype:'textfield',fieldLabel: 'Alias',id:'EmpresaFormEmpAlias',allowBlank: false},{xtype:'numberfield',fieldLabel:'Telefono', id:'EmpresaFormNroTlf',allowBlank: false},{xtype: 'textfield',fieldLabel:'Email',id:'EmpresaFormEmai l',allowBlank:false},{xtype:'combo',listWidth:200, editable:true,mode:'local',store:PStores.storeBool eano,hiddenName:'EmpresaFormCliente',fieldLabel:'C liente',displayField:'name',id: 'EmpresaFormCliente',valueField:'id',hiddenValue:' id',allowBlank:false,triggerAction:'all' ,anchor: '60%'},{xtype:'combo',listWidth:200,editable:true, mode:'local',store:PStores.storeBooleano,hiddenNam e:'EmpresaFormProveedor',fieldLabel:'Proveedor',di splayField:'name',id:'EmpresaFormProveedor',valueF ield:'id',hiddenValue:'id',allowBlank:false,trigge rAction:'all' ,anchor:'60%'},{xtype:'combo',listWidth:200,editab le:true,mode:'local', store:PStores.storeBooleano,hiddenName:'EmpresaFor mTransportista',fieldLabel:'Transportista',display Field:'name',id:'EmpresaFormTransportista',valueFi eld:'id',hiddenValue:'id',allowBlank:false,trigger Action:'all' ,anchor: '60%'},{xtype:'textfield',fieldLabel: 'Zona',id:'EmpresaFormZonaTrab',allowBlank: false}
]
}
]
}
]
}
],
buttons: []
});
this.panel = [
{xtype : 'panel',border : false,height : 480,layout : 'border',
items : [
{title: 'Listado de Empresas',region: 'center',layout: 'fit',autoScroll: true,items: this.empresasGrid},
{title: 'Detalle de la Empresa',id: 'detalleEmpresaForm',collapsed: true,
split: true,collapsible : true,width: 420,autoScroll: true,region: 'east',
items: this.empresasForm
}
]
}
]
this.loadStore=function(){};
this.empresasGrid.getSelectionModel().on('rowselec t', this.loadForm);
}
this.empresasSelModel = new Ext.grid.CheckboxSelectionModel({
singleSelect:true,
moveEditorOnEnter: false
});
var escritura=true;
if(p) escritura=false;
this.empresasColumnModel = new Ext.grid.ColumnModel([
new Ext.grid.RowNumberer(),this.empresasSelModel,
{dataIndex: 'idempresa',hidden: true},{dataIndex:'ruc',header:'RUC',renderer:addTo oltip,width: 60},{dataIndex:'razonsocial',header:'Razon Social',renderer:addTooltip,hidden:false,width: 200},{dataIndex:'emp_alias',header:'Alias',rendere r:addTooltip,hidden:false,width:200},{dataIndex:'t elefono',header:'Telefono',renderer:addTooltip,hid den:false,width:70},{dataIndex:'email',header:'Ema il',renderer:addTooltip,hidden:false,width:120},{d ataIndex:'cliente',header:'Cliente',renderer:addTo oltip,hidden:false,sortable:true,width:120},{dataI ndex:'proveedor',header:'Proveedor',renderer:addTo oltip,hidden:false,sortable:true,width: 120},{dataIndex:'transportista',header:'Transporti sta',renderer:addTooltip,hidden:false,sortable:tru e,width: 120},{dataIndex:'zonatrabajo',header:'Zona',render er:addTooltip,hidden:false,width:120}]);
this.empresasColumnModel.defaultSortable = true;
this.empresasDataStore = new Ext.data.GroupingStore({
id: 'empresasDataStore',reader: new Ext.data.JsonReader({
fields:[
{name: 'idempresa', type: 'string'},{name: 'razonsocial', type: 'string'},{name: 'ruc', type: 'string'},{name: 'cliente', type: 'string'},
{name: 'proveedor', type: 'string'},{name: 'activo', type: 'numeric'},{name: 'telefono', type: 'string'},{name: 'emp_alias', type: 'string'},
{name: 'transportista', type: 'string'},{name: 'email', type: 'string'},{name: 'zonatrabajo', type: 'string'}
],root: 'rows',totalProperty: 'results'
}),proxy: new Ext.data.HttpProxy({url:BASE_URL+'mantenimientos/empresa/ext_get_all',method: 'POST'}),remoteSort: true
});
this.verDetalle = function(){
Ext.getCmp('detalleEmpresaForm').expand();
Ext.getCmp('btnFrmEmpresaGuardar').hide();
Ext.getCmp('btnFrmEmpresaCancelar').hide();
Ext.getCmp('btnFrmEmpresaEditar').show();
Ext.getCmp('btnFrmEmpresaEditar').enable();
}
this.empresasGrid = new Ext.grid.GridPanel({
id: 'empresasGridPanel',store: this.empresasDataStore,plugins:[filters,new Ext.grid.GridSummary()],view: new Ext.grid.GroupingView({forceFit:true}),sm:this.emp resasSelModel,cm:this.empresasColumnModel,enableCo lLock:false,selModel:new Ext.grid.RowSelectionModel({singleSelect:false}),t bar:new Ext.Toolbar({
items:[
{text: 'Agregar',icon: BASE_PATH + 'assets/img/iconos/add.gif',handler: this.agregarEmpresa,disabled: escritura}, '-',
{text: 'Eliminar',icon: BASE_PATH + 'assets/img/iconos/delete.gif',disabled: escritura,handler: this.confirmarEliminacion}, '-',
//{text: 'Exportar',icon: BASE_PATH + 'assets/img/iconos/excel.png',handler: this.exportarExcel},'-',
{text: 'Ver Detalle',id: 'btnFrmEmpresaDetalle',icon: BASE_PATH + 'assets/img/iconos/detalle.png',handler: this.verDetalle},
]
}),
bbar: new Ext.PagingToolbar({
pageSize: 15,store: this.empresasDataStore,displayInfo: true
}),listeners : {
render: function(grid){
loadMask(grid,true,'Cargando...')
grid.getStore().load({callback: function(grid){loadMask(tabEmpresas.empresasGrid,f alse,'')}
});
}
}
});
/*FORMULARIO*/
var categoriesRecord = new Ext.data.Record.create([
{name: 'EmpresaFormIdEmpresa', type: 'int',mapping: 'idempresa'},
{name: 'EmpresaFormRazonSocial',type: 'string',mapping: 'razonsocial'},
{name: 'EmpresaFormRuc', type: 'string',mapping: 'ruc'},
{name: 'EmpresaFormCliente', type: 'string',mapping: 'cliente'},
{name: 'EmpresaFormProveedor', type: 'string',mapping: 'proveedor'},
{name: 'EmpresaFormTransportista',type: 'string',mapping: 'transportista'},
{name: 'EmpresaFormActivo', type: 'numeric',mapping: 'activo'},
{name: 'EmpresaFormNroTlf', type: 'string',mapping: 'telefono'},
{name: 'EmpresaFormEmpAlias', type: 'string',mapping: 'emp_alias'},
{name: 'EmpresaFormEmail', type: 'string',mapping: 'email'},
{name: 'EmpresaFormZonaTrab', type: 'string',mapping: 'zonatrabajo'}
]);
var categoriesFormReader = new Ext.data.JsonReader({
root : 'rows',
successProperty : 'success',
totalProperty: 'total',
id: 'cad_id'
},categoriesRecord);
this.resetForm = function(opt){
Ext.getCmp('empresasForm').getForm().reset();
Ext.getCmp('empresasGridPanel').getSelectionModel( ).clearSelections();
Ext.getCmp('primerPanelEmpresa').expand();
}
this.enableFields=function(){
this.empresasForm.getForm().items.each(function(f) {
if(f.isFormField && f.initialConfig.id!='EmpresaFormRuc'){f.enable();}
f.addClass("green-field");
});
}
this.disableFields=function(){
this.empresasForm.getForm().items.each(function(f) {
if(f.isFormField){
f.disable();
}
f.removeClass("green-field");
});
}
this.loadForm=function(){
tabEmpresas.disableFields();
Ext.getCmp('btnFrmEmpresaEditar').show();
Ext.getCmp('btnFrmEmpresaCancelar').hide();
Ext.getCmp('btnFrmEmpresaGuardar').hide();
r=Ext.getCmp('empresasGridPanel').getSelectionMode l().getSelected();
if(r!=undefined){Ext.getCmp('empresasForm').load({ params:{idempresa:r.data.idempresa},waitMsg:'Carga ndo...'});}}
this.empresasForm = new Ext.FormPanel({
id : 'empresasForm',
frame : false, border: false, buttonAlign: 'center',
height : 430,
waitMsgTarget:true,
autoScroll : true,
listeners :{
beforeaction: function(){
if(r!=undefined){
PStores.storeBooleano.load({params:{cliente:r.data .cliente}})
PStores.storeBooleano.load({params:proveedor:r.dat a.proveedor}})
PStores.storeBooleano.load({params:transportista:r .data.transportista}})
return true;
}
return true;
}
},
url:BASE_URL +'mantenimentos/empresa/getEmpresas', method: 'POST',
reader:categoriesFormReader,
items : [
{xtype: 'tabpanel',border: false,activeTab: 0,enableTabScroll: true,
items :[
{layout: 'fit',id:'primerPanelEmpresa',xtype: 'panel',autoHeight: true, padding: '5px 5px',margins: '2px',name: 'panelAcordion',title: 'Empresa',
items:[
{layout: 'form',xtype: 'fieldset',autoHeight: true,labelWidth: 90,padding: '2px 2px',title: 'Informacion de la Empresa',
items:[
{xtype: 'numberfield',id:'EmpresaFormIdEmpresa',hidden : true},{xtype: 'numberfield',fieldLabel: 'Número RUC',id:'EmpresaFormRuc',allowBlank: false,maxlength: '11',autocomplete: 'off'},
{xtype: 'textfield',fieldLabel:'Razon Social',id:'EmpresaFormRazonSocial',allowBlank: false},{xtype:'textfield',fieldLabel: 'Alias',id:'EmpresaFormEmpAlias',allowBlank: false},{xtype:'numberfield',fieldLabel:'Telefono', id:'EmpresaFormNroTlf',allowBlank: false},{xtype: 'textfield',fieldLabel:'Email',id:'EmpresaFormEmai l',allowBlank:false},{xtype:'combo',listWidth:200, editable:true,mode:'local',store:PStores.storeBool eano,hiddenName:'EmpresaFormCliente',fieldLabel:'C liente',displayField:'name',id: 'EmpresaFormCliente',valueField:'id',hiddenValue:' id',allowBlank:false,triggerAction:'all' ,anchor: '60%'},{xtype:'combo',listWidth:200,editable:true, mode:'local',store:PStores.storeBooleano,hiddenNam e:'EmpresaFormProveedor',fieldLabel:'Proveedor',di splayField:'name',id:'EmpresaFormProveedor',valueF ield:'id',hiddenValue:'id',allowBlank:false,trigge rAction:'all' ,anchor:'60%'},{xtype:'combo',listWidth:200,editab le:true,mode:'local', store:PStores.storeBooleano,hiddenName:'EmpresaFor mTransportista',fieldLabel:'Transportista',display Field:'name',id:'EmpresaFormTransportista',valueFi eld:'id',hiddenValue:'id',allowBlank:false,trigger Action:'all' ,anchor: '60%'},{xtype:'textfield',fieldLabel: 'Zona',id:'EmpresaFormZonaTrab',allowBlank: false}
]
}
]
}
]
}
],
buttons: []
});
this.panel = [
{xtype : 'panel',border : false,height : 480,layout : 'border',
items : [
{title: 'Listado de Empresas',region: 'center',layout: 'fit',autoScroll: true,items: this.empresasGrid},
{title: 'Detalle de la Empresa',id: 'detalleEmpresaForm',collapsed: true,
split: true,collapsible : true,width: 420,autoScroll: true,region: 'east',
items: this.empresasForm
}
]
}
]
this.loadStore=function(){};
this.empresasGrid.getSelectionModel().on('rowselec t', this.loadForm);
}