Code:
var record;
var idadd;
var keydoc;
var keydoc_fact;
var i = 1;
var ifact = 1;
var total;
var username;
var winfact;
var win;
var wincomproveedores;
var winrpagos;
var bcenterid;
var vergasto=false;
var verfactura=false;
var idgasto;
var tempagos = new Array();
/*
* ================ Start page config =======================
*/
// The default start page, also a simple example of a FitLayout.
Ext.Ajax.request({
url: 'ws-session.php',
failure:function(response, request){
var redirect = 'index.html';
window.location = redirect;
},
success: function (response, request) {
var data = Ext.util.JSON.decode(response.responseText);
username = data.usuario;
Ext.getCmp('usuario').setValue(username);
Ext.getCmp('factusuario').setValue(username);
}
});
var start = {
id: 'start-panel',
title: 'ALLWARE 2009',
layout: 'fit',
bodyStyle: 'padding:25px',
contentEl: 'start-div'
};
//REGISTRO DE DETALLE DOCUMENTO
var registro=[
'ALDD_IdDoc',
'ALDD_Line',
{name:'ALDD_Date', type: 'date',dateFormat: 'Y-m-d'},
{name:'ALDD_Type', type: 'int'},
{name:'ALDD_BCENTER', type: 'string'},
{name:'ALDD_Number', type: 'string'},
{name:'ALDD_Param1', type:'string'},
{name:'ALDD_ACCOUNT', type:'string'},
{name:'ALDD_SACCOUNT', type:'string'},
{name:'ALDD_Text', type:'string'},
{name:'ALDD_Total', type:'float'}
];
//FIN REGISTRO DE DETALLE DOCUMENTO
//REGISTRO DE DETALLE FACTURA
var registro_fact=[
'ALDD_IdDoc',
'ALDD_Line',
{name:'ALDD_Text', type:'string'},
{name:'ALDD_ACCOUNT', type:'string'},
{name:'ALDD_SACCOUNT', type:'string'},
{name:'ALDD_Total', type:'float'}
];
//FIN REGISTRO DE DETALLE FACTURA
//REGISTRO COMENTARIOS
var registro_comentarios=[
{name: 'ALTD_Id', type:'int'},
{name: 'ALTD_IdDoc', type:'int'},
{name: 'ALTD_UID', type:'string'},
{name: 'ALTD_Date', type:'date',dateFormat: 'Y-m-d'},
{name: 'ALTD_Text', type:'string'}
];
//FIN REGISTRO COMENTARIOS
//REGISTRO MIS COMENTARIOS
var registro_miscomentarios=[
{name: 'ALTD_Id', type:'int'},
{name: 'ALTD_IdDoc', type:'int'},
{name: 'ALTD_UID', type:'string'},
{name: 'ALTD_Date', type:'date', dateFormat: 'Y-m-d'},
{name: 'ALTD_Text', type:'string'}
];
//FIN REGISTRO MIS COMENTARIOS
//REGISTRO DOCUMENTO REND DE GASTOS
var registro_doc=[
{name: 'ALD_IdDoc', type:'int'},
{name: 'ALD_DCreation', type:'date',dateFormat: 'Y-m-d'},
{name: 'ALD_DVenc', type:'date',dateFormat: 'Y-m-d'},
{name: 'ALD_Type', type:'int'},
{name: 'ALD_Rut', type:'string'},
{name:'ALD_BCENTER', type: 'string'},
{name: 'ALD_UID', type:'string'},
{name: 'ALD_Text', type:'string'},
{name: 'ALD_BCode', type:'int'},
{name: 'ALD_Total', type:'float'},
{name: 'ALD_UID_ChkBy', type:'string'},
{name: 'ALD_Status', type:'int'}
];
//FIN REGISTRO DE DOCUMENTO REND DE GASTOS
//REGISTRO DOCUMENTO REV FACTURA
var registro_docfact=[
{name: 'ALD_IdDoc', type:'int'},
{name: 'ALD_DCreation', type:'date',dateFormat: 'Y-m-d'},
{name: 'ALD_DVenc', type:'date',dateFormat: 'Y-m-d'},
{name: 'ALD_DFact', type:'date',dateFormat: 'Y-m-d'},
{name: 'ALD_Type', type:'int'},
{name: 'ALD_Rut', type:'string'},
{name: 'nproveedor', type:'string'},
{name:'ALD_BCENTER', type: 'string'},
{name: 'ALD_UID', type:'string'},
{name: 'ALD_Text', type:'string'},
{name: 'ALD_BCode', type:'int'},
{name: 'ALD_Total', type:'float'},
{name: 'ALD_UID_ChkBy', type:'string'},
{name: 'ALD_Status', type:'int'}
];
//FIN REGISTRO DE DOCUMENTO REV FACTURA
//REGISTRO MIS DOCUMENTO
var registro_misdoc=[
{name: 'ALD_IdDoc', type:'int'},
{name: 'ALD_DCreation', type:'date',dateFormat: 'Y-m-d'},
{name: 'ALD_Type', type:'int'},
{name: 'ALD_Rut', type:'string'},
{name: 'ALD_DVenc', type:'date',dateFormat: 'Y-m-d'},
{name:'ALD_BCENTER', type: 'string'},
{name: 'ALD_UID', type:'string'},
{name: 'ALD_Text', type:'string'},
{name: 'ALD_BCode', type:'int'},
{name: 'ALD_Total', type:'float'},
{name: 'ALD_UID_ChkBy', type:'string'},
{name: 'ALD_Status', type:'int'}
];
//FIN REGISTRO DE MIS DOCUMENTO
//STORES
//STORE USUARIOS
var store_usuarios = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams: {oper:"usuarios"},
method:'POST',
fields:[
{name: 'IdEmpleado', type:'int'},
{name: 'Nombre', type:'string'}
]
});
store_usuarios.load();
//FIN STORE USUARIOS
//STORE TIPO PROVEEDORES
var store_tipoproveedor = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams: {oper:"querytipoproveedor"},
method:'POST',
fields:[
{name: 'id_tipo', type:'int'},
{name: 'descripcion', type:'string'}
]
});
//FIN TIPO PROVEEDORES
//STORE tipo factura
var store_tipofactura = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams: {oper:"tipofactura"},
method:'POST',
fields:[
{name: 'IdTpoFactura', type:'int'},
{name: 'TipoFactura', type:'string'}
]
});
store_tipofactura.load();
//FIN STORE tipo factura
//STORE PERIODO CONTABLE
var store_percontable = new Ext.data.JsonStore({
url:"ws_percontable.php",
method:'POST',
fields:[
{name: 'IdPeriodo', type:'int'},
{name: 'Periodo', type:'string'},
{name: 'EstadoRem', type:'string'},
{name: 'FechaLog', type:'date'},
{name: 'Estado', type:'string'}
]
});
store_percontable.load();
//FIN STORE PERIODO CONTABLE
//STORE PERIODO RESUMEN PROVEEDORES
var store_rproveedores = new Ext.data.JsonStore({
url:"ws_datos.php",
totalProperty :'total',
method:'POST',
root:'data',
fields:[
{name: 'ALD_IdDoc', type:'int'},
{name: 'ALD_Text', type:'string'},
{name: 'ALD_Total', type:'int'},
{name: 'ALD_Status', type:'int'}
]
});
//FIN STORE RESUMEN PROVEEDORES
//STORE AL_BCENTER
var store_bcenter = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams: {oper:"bcenters"},
method:'POST',
fields:[
{name: 'ALBC_Id', type:'string'},
{name: 'ALBC_Type', type:'string'},
{name: 'ALBC_Text', type:'string'},
{name: 'ALBC_ParentId', type:'string'}
]
});
store_bcenter.load();
//FIN STORE UAL_BCENTER
//STORE ACCOUNT
var store_Items = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams: {oper:"items"},
method:'POST',
fields:[
{name: 'ALI_Code', type:'string'},
{name: 'ALI_Text', type:'string'}
]
});
store_Items.load();
//FIN STORE ACCOUNT
//STORE subACCOUNT
var store_subitems = new Ext.data.JsonStore({
url:"ws_datos.php",
method:'POST',
root:'data',
fields:[
{name: 'ALSI_SItems', type:'string'},
{name: 'ALSI_Text', type:'string'}
]
});
//FIN STORE subACCOUNT
//STORE ACCOUNTfact
var store_Itemsfact = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams: {oper:"items"},
fields:[
{name: 'ALI_Code', type:'string'},
{name: 'ALI_Text', type:'string'}
]
});
store_Itemsfact.load();
//FIN STORE ACCOUNTfact
//STORE subACCOUNTfact
var store_subitemsfact = new Ext.data.JsonStore({
url:"ws_datos.php",
method:'POST',
root:'data',
fields:[
{name: 'ALSI_SItems', type:'string'},
{name: 'ALSI_Text', type:'string'}
]
});
//FIN STORE subACCOUNTfact
//STORE boleta - factura - otro PAGO GASTOS
var store_fbogastos = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams: {oper:"query",sql:"select * from TipoDocumento where IdTipoDocumento=1 OR IdTipoDocumento=2 OR IdTipoDocumento=5"},
root:'data',
method:'POST',
fields:[
{name: 'IdTipoDocumento', type:'int'},
{name: 'TipoDocumento', type:'string'}
]
});
store_fbogastos.load();
//FIN STORE BOLETA - FACTURA - OTRA PAGO GASTOS
//STORE tipo cargo
var store_tipocargo = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams:{oper:"tipocargo"},
method:'POST',
fields:[
{name: 'IdTipoCargo', type:'int'},
{name: 'Descripcion', type:'string'}
]
});
store_tipocargo.load();
//FIN STORE tipo cargo
//STORE PROVEEDORES
//COMBOS PROVEEDORES NO MUESTRA LOS SIN RUT
var store_cproveedores = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams: {oper:"querycmbproveedores"},
root:'data',
method:'POST',
fields:[
{name: 'Rut', type:'string'},
{name: 'RazonSocial', type:'string'}
]
});
store_cproveedores.load();
//COMBO PROVEEDORES
//GRID PROVEEDORES MUESTRA TODOS
var store_proveedores = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams: {oper:"queryproveedores"},
totalProperty :'total',
root:'data',
method:'POST',
fields:[
{name: 'Id_Proveedor', type:'int'},
{name: 'Rut', type:'string'},
{name: 'RazonSocial', type:'string'},
{name: 'Direccion', type:'string'},
{name: 'Telefono', type:'string'},
{name: 'Giro', type:'string'},
{name: 'Banco', type:'string'},
{name: 'CuentaBanco', type:'string'},
{name: 'Email', type:'string'},
{name: 'Contacto', type:'string'},
{name: 'tipo', type:'int'},
{name: 'FechaLog', type:'date' , dateformat:'Y-m-d'}
]
});
store_proveedores.load({params:{start:0, limit:15}});
//FIN GRID PROVEEDORES
//FIN PROVEEDORES
//STORE DETALLE RENDICION
var store2 = new Ext.data.JsonStore({
url: 'ws_datos.php',
baseParams: {oper:"query",sql:"select * from AL_DetDocs"},
method:'POST',
root: 'data',
remoteSort:false,
fields: registro
});
//FIN STORE DETALLE RENDICION
//STORE DETALLE FACTURA
var store_fact = new Ext.data.JsonStore({
url: 'ws_datos.php',
baseParams: {oper:"query",sql:"select * from AL_DetDocs"},
method:'POST',
root: 'data',
remoteSort:false,
fields: registro_fact
});
//FIN STORE DETALLE FACTURA
//STORE DOCUMENTOS
var store_listadoc = new Ext.data.JsonStore({
url:"ws_datos.php",
totalProperty :'total',
root:'data',
method:'POST',
baseParams: {oper:"querychkgastos"},
fields:registro_doc
});
store_listadoc.setDefaultSort('ALD_IdDoc', 'desc');
store_listadoc.load({params:{start:0, limit:15}});
var store_misdoc = new Ext.data.JsonStore({
url:"ws_datos.php",
root:'data',
method:'POST',
totalProperty :'total',
baseParams: {oper:"querymisdoc"},
fields:registro_misdoc
});
store_misdoc.setDefaultSort('ALD_IdDoc', 'desc');
store_misdoc.load({params:{start:0, limit:15}});
//FIN STORE DOCUMENTOS
//STORE DOCUMENTOS GASTOS
var store_comentarios = new Ext.data.JsonStore({
url:"ws_datos.php",
method:'POST',
root:'data',
fields:registro_comentarios
});
//FIN STORE DOCUMENTOS GASTOS
//STORE COMENTARIOS FACT
var store_comentariosfact = new Ext.data.JsonStore({
url:"ws_datos.php",
method:'POST',
root:'data',
fields:registro_comentarios
});
//FIN STORE COMENTARIOS FACT
// STORE FACTURAS
var store_listafact = new Ext.data.JsonStore({
url:"ws_datos.php",
method:'POST',
totalProperty :'total',
root:'data',
baseParams: {oper:"querychkfacturas"},
fields:registro_docfact
});
store_listafact.setDefaultSort('ALD_IdDoc', 'desc');
store_listafact.load({params:{start:0, limit:15}});
var store_misfact = new Ext.data.JsonStore({
url:"ws_datos.php",
method:'POST',
totalProperty :'total',
baseParams:{oper:"querymisfact"},
root:'data',
fields:registro_misdoc
});
store_misfact.setDefaultSort('ALD_IdDoc', 'desc');
store_misfact.load({params:{start:0, limit:15}});
//STORE PROVEEDORES COMENTARIOS
var store_comproveedores = new Ext.data.JsonStore({
url:"ws_datos.php",
method:'POST',
fields:[
{name: 'Idcomentarios', type:'int'},
{name: 'Rutproveedor', type:'string'},
{name: 'Uid', type:'string'},
{name: 'Descripcion', type:'string'},
{name: 'FechaLog', type:'date' , dateFormat: 'Y-m-d'}
]
});
//FIN STORE PROVEEDORES COMENTARIOS
//STORE MIS DOCUMENTOS
var store_miscomentarios = new Ext.data.JsonStore({
url:"ws_datos.php",
method:'POST',
root:'data',
fields:registro_miscomentarios
});
//FIN STORE MIS DOCUMENTOS
//STORE MIS DOCUMENTOS
var store_miscomentariosfact = new Ext.data.JsonStore({
url:"ws_datos.php",
method:'POST',
root:'data',
fields:registro_miscomentarios
});
//FIN STORE MIS DOCUMENTOS
//STORE TIPO STATUD
var store_tipostatus = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams:{oper:"tipostatusrend"},
method:'POST',
fields:[
{name: 'IdTipoStatus', type:'int'},
{name: 'Descripcion', type:'string'}
]
});
store_tipostatus.load();
// FIN TIPO ESTATUS
//STORE TIPO STATUS FACT
var store_tipostatusfact = new Ext.data.JsonStore({
url:"ws_datos.php",
baseParams:{oper:"tipostatusfact"},
method:'POST',
fields:[
{name: 'IdEstadoFactura', type:'int'},
{name: 'Estado', type:'string'}
]
});
store_tipostatusfact.load();
// FIN TIPO ESTATUS
//FIN STORES
//RECORDS
var myRecordObj= Ext.data.Record.create(registro);
var myRecordObj_doc = Ext.data.Record.create(registro_doc);
var myRecordObj_com = Ext.data.Record.create(registro_comentarios);
var myRecordObj_misdoc = Ext.data.Record.create(registro_misdoc);
var myRecordObj_miscomentarios = Ext.data.Record.create(registro_miscomentarios);
//FIN RECORDS
//PAGINADORES
//REVISION RENDICIONES
var paglistadoc = new Ext.PagingToolbar({
pageSize: 15,
store: store_listadoc,
displayInfo: true,
displayMsg: 'Mostrando {0} - {1} de {2}',
emptyMsg: "No existen datos"
});
var pagproveedores = new Ext.PagingToolbar({
pageSize: 15,
store: store_proveedores,
displayInfo: true,
displayMsg: 'Mostrando {0} - {1} de {2}',
emptyMsg: "No existen datos"
});
var pagrproveedores = new Ext.PagingToolbar({
pageSize: 7,
store: store_rproveedores,
displayInfo: true,
displayMsg: 'Mostrando {0} - {1} de {2}',
emptyMsg: "No existen datos"
});
//MIS RENDICIONES
var pagmisdoc = new Ext.PagingToolbar({
pageSize: 15,
store: store_misdoc,
displayInfo: true,
displayMsg: 'Mostrando {0} - {1} de {2}',
emptyMsg: "No existen datos"
});
//PAGINADORES
//revision factura compra
var paglistafact = new Ext.PagingToolbar({
pageSize: 15,
store: store_listafact,
displayInfo: true,
displayMsg: 'Mostrando {0} - {1} de {2}',
emptyMsg: "No existen datos"
});
//revision factura compra
//revision mis fact
var pagmisfact = new Ext.PagingToolbar({
pageSize: 15,
store: store_misfact,
displayInfo: true,
displayMsg: 'Mostrando {0} - {1} de {2}',
emptyMsg: "No existen datos"
});
//revision mis fact
/*
* ================ GRIDS config =======================
*/
//COLUMNA DOCUMENTO
var cm_doc = new Ext.grid.ColumnModel([
{id:"ALD_IdDoc",header: "ID", width: 40, sortable: true, dataIndex: 'ALD_IdDoc'},
{header: "F. CREACION", width: 100, sortable: true, dataIndex: 'ALD_DCreation',renderer: Ext.util.Format.dateRenderer('d-m-Y')},
{header: "T. DOCUMENTO", width: 100, sortable: true,dataIndex: 'ALD_Type'},
{header: "BCENTER", width: 100,renderer:albcenter, sortable: true,dataIndex: 'ALD_BCENTER'},
{header: "USUARIO", width: 100, sortable: true, dataIndex: 'ALD_UID'},
{header: "DESCRIPCION", width: 300, sortable: true, dataIndex: 'ALD_Text'},
{header: "N CHEQUE", width: 100, sortable: true, dataIndex: 'ALD_BCode'},
{header: "TOTAL", width: 100, sortable: true,renderer:clmoney,align:'right',dataIndex: 'ALD_Total'},
{header: "RESPONSABLE", width: 100, sortable: true,aling:'center',dataIndex: 'ALD_UID_ChkBy'},
{header: "ESTADO", width: 100, renderer:estado,sortable: true, dataIndex: 'ALD_Status'}
]);
cm_doc.defaultSortable = true;
//FIN COLUMNA DOCUMENTO
//COLUMNA DOCUMENT rFACTURAS
var cm_rdocfact = new Ext.grid.ColumnModel([
{id:"ALD_IdDoc",header: "ID", width: 40, sortable: true, dataIndex: 'ALD_IdDoc'},
{header: "TIPO", width: 70, sortable: true, dataIndex: 'ALD_Type', renderer:renderfbogastos},
{header: "F. EMI ", width: 70, sortable: true, dataIndex: 'ALD_DFact',renderer: Ext.util.Format.dateRenderer('d-m-Y')},
{header: "F. VENC ", width: 70, sortable: true, dataIndex: 'ALD_DVenc',renderer: Ext.util.Format.dateRenderer('d-m-Y')},
{header: "PROVEEDOR", width: 80, sortable: true,dataIndex: 'ALD_Rut'},
{header: "N. PROVEEDOR", width: 125, sortable: true, dataIndex:'nproveedor'},
{header: "BCENTER", width: 80,renderer:albcenter, sortable: true,dataIndex: 'ALD_BCENTER'},
{header: "USUARIO", width: 60, sortable: true, dataIndex: 'ALD_UID'},
{header: "DESCRIPCION", width: 150, sortable: true, dataIndex: 'ALD_Text'},
{header: "FACT/BOL", width: 60, sortable: true, dataIndex: 'ALD_BCode'},
{header: "TOTAL", width: 60,aling:'center',sortable: true,renderer:clmoney,align:'right',dataIndex: 'ALD_Total'},
{header: "ESTADO", width: 80, renderer:estadofact,sortable: true, dataIndex: 'ALD_Status'}
]);
cm_rdocfact.defaultSortable = true;
//FIN COLUMNA DOCUMENTO rfacturas
//COLUMNA PROVEEDORES
var cm_proveedores = new Ext.grid.ColumnModel([
{id:"Id_Proveedor",header: "ID", width: 80, sortable: true, dataIndex: 'Id_Proveedor'},
{id:"Rut",header: "Rut", width:80, sortable: true, dataIndex: 'Rut'},
{header: "R. Social", width: 180, sortable: true,dataIndex: 'RazonSocial'},
{header: "Direccion", width: 100,sortable: true,dataIndex: 'Direccion'},
{header: "Telefono", width: 80, sortable: true, dataIndex: 'Telefono'},
{header: "Giro", width: 100, sortable: true, dataIndex: 'Giro'},
{header: "Banco", width: 100, sortable: true, dataIndex: 'Banco'},
{header: "Cuenta", width: 80, sortable: true, dataIndex: 'CuentaBanco'},
{header: "E-Mail", width: 100, sortable: true, dataIndex: 'Email'},
{header: "Contacto", width: 100, sortable: true, dataIndex: 'Contacto'},
{header: "tipo", width:100, sortable:true, dataIndex: 'tipo'}
]);
cm_proveedores.defaultSortable = true;
//FIN COLUMNA PROVEEDORES
//COLUMNA MIS DOCUMENTO
var cm_misdoc = new Ext.grid.ColumnModel([
{id:"ALD_IdDoc",header: "ID", width: 40, sortable: true, dataIndex: 'ALD_IdDoc'},
{header: "F. CREACION", width: 100,sortable: true, dataIndex: 'ALD_DCreation',renderer: Ext.util.Format.dateRenderer('d-m-Y')},
{header: "T. DOCUMENTO", width: 100, sortable: true,dataIndex: 'ALD_Type'},
{header: "BCENTER", width: 100,renderer:albcenter, sortable: true,dataIndex: 'ALD_BCENTER'},
{header: "USUARIO", width: 100, sortable: true, dataIndex: 'ALD_UID'},
{header: "DESCRIPCION", width: 300, sortable: true, dataIndex: 'ALD_Text'},
{header: "N CHEQUE", width: 100, sortable: true, dataIndex: 'ALD_BCode'},
{header: "TOTAL", width: 100, sortable: true,renderer:clmoney,align:'right', dataIndex: 'ALD_Total'},
{header: "RESPONSABLE", width: 100, sortable: true, dataIndex: 'ALD_UID_ChkBy'},
{header: "ESTADO", width: 100, renderer:estado,sortable: true, dataIndex: 'ALD_Status'}
]);
cm_doc.defaultSortable = true;
//FIN COLUMNA MIS DOCUMENTO
//COLUMNA MIS DOCUMENTO
var cm_misdocfact = new Ext.grid.ColumnModel([
{id:"ALD_IdDoc",header: "ID", width: 40, sortable: true, dataIndex: 'ALD_IdDoc'},
{header: "Tipo", width: 80, sortable: true,dataIndex: 'ALD_Type',renderer:renderfbogastos},
{header: "F. VENC ", width: 80, sortable: true, dataIndex: 'ALD_DVenc',renderer: Ext.util.Format.dateRenderer('d-m-Y')},
{header: "PROVEEDOR", width: 80, sortable: true,dataIndex: 'ALD_Rut'},
{header: "T. DOCUMENTO", width: 100, sortable: true,dataIndex: 'ALD_Type'},
{header: "BCENTER", width: 60,renderer:albcenter, sortable: true,dataIndex: 'ALD_BCENTER'},
{header: "DESCRIPCION", width: 200, sortable: true, dataIndex: 'ALD_Text'},
{header: "FACT/BOL", width: 60, sortable: true, dataIndex: 'ALD_BCode'},
{header: "TOTAL", width: 60, sortable: true,renderer:clmoney,align:'right', dataIndex: 'ALD_Total'},
{header: "RESPONSABLE", width: 100, sortable: true, dataIndex: 'ALD_UID_ChkBy'},
{header: "ESTADO", width: 80, renderer:estadofact,sortable: true, dataIndex: 'ALD_Status'}
]);
cm_doc.defaultSortable = true;
//FIN COLUMNA MIS DOCUMENTO
//COLUMNA RESUMEN PROVEEDORES
var cm_rproveedores = new Ext.grid.ColumnModel([
{id:"ALD_IdDoc",header: "ID", width: 40, sortable: true, dataIndex: 'ALD_IdDoc'},
{header: "DESCRIPCION", width: 260, sortable: true, dataIndex: 'ALD_Text'},
{header: "TOTAL", width: 60, sortable: true,renderer:clmoney,align:'right', dataIndex: 'ALD_Total'},
{header: "ESTADO", width: 80, renderer:estadofact,sortable: true, dataIndex: 'ALD_Status'}
]);
cm_rproveedores.defaultSortable = true;
//FIN COLUMNA RESUMEN PROVEEDORES
//COLUMNA DETALLE FACT
var cm_fact = new Ext.grid.ColumnModel([
{id:'ALDD_IdDoc',header: "ALDD_IdDoc", width:100, sortable: true, dataIndex: 'ALDD_IdDoc'},
{id:'ALDD_Line',header: "N", width:40, dataIndex: 'ALDD_Line'},
{header: "DESCRIPCION", width:300, dataIndex: 'ALDD_Text', editor: new Ext.form.TextField()},
{
header: "Cuenta",
width:80,
sortable:true,
dataIndex: 'ALDD_ACCOUNT',
editor: new Ext.grid.GridEditor(new Ext.form.ComboBox({
id:'al_accountfact',
listWidth : 150,
hiddenName: 'ALI_Code',
store:store_Itemsfact,
displayField:'ALI_Text',
valueField:'ALI_Code',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true
}))
},{
header: "SubCuenta",
width:100,
sortable:true,
dataIndex: 'ALDD_SACCOUNT',
editor: new Ext.grid.GridEditor(new Ext.form.ComboBox({
id:'al_subaccountfact',
listWidth : 150,
hiddenName: 'ALSI_SItems',
store:store_subitemsfact,
displayField:'ALSI_Text',
valueField:'ALSI_SItems',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true
}))
},{header: "TOTAL", width:100, dataIndex: 'ALDD_Total',renderer:clmoney,align:'right', editor: new Ext.form.NumberField({allowNegative: false})}
]);
cm_fact.defaultSortable = true;
//FIN COLUMNA DETALLE FACT
//COLUMNA DETALLE GASTOS
var cm = new Ext.grid.ColumnModel([
{id:'ALDD_IdDoc',header: "ALDD_IdDoc", width:100, sortable: true, dataIndex: 'ALDD_IdDoc'},
{id:'ALDD_Line',header: "N", width:40, dataIndex: 'ALDD_Line'},
{header: "FECHA", width:120, dataIndex: 'ALDD_Date',renderer: Ext.util.Format.dateRenderer('d-m-Y'), editor: new Ext.form.DateField({format: 'd-m-Y'})},
{
header: "F/B/O",
width:115,
dataIndex:'ALDD_Type',
renderer:renderfbogastos,
editor: new Ext.grid.GridEditor(new Ext.form.ComboBox({
id:'fbogastos',
listWidth : 300,
hiddenName: 'IdTipoDocumento',
store:store_fbogastos,
displayField:'TipoDocumento',
valueField:'IdTipoDocumento',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
selectOnFocus:true,
fieldLabel: 'fbogastos',
name: 'fbogastos'
}))
},
{
header: "BCENTER",
width: 180,
renderer:albcenter,
sortable: true,
dataIndex: 'ALDD_BCENTER',
editor: new Ext.grid.GridEditor(new Ext.form.ComboBox({
id:'albcenterdet',
listWidth : 300,
hiddenName: 'ALBC_Id',
store:store_bcenter,
displayField:'ALBC_Text',
valueField:'ALBC_Id',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
selectOnFocus:true,
fieldLabel: 'BCENTER'
}))
},
{header: "N BOL/FACT", width:120, dataIndex: 'ALDD_Number', editor: new Ext.form.TextField()},
{
header: "PROVEEDOR",
width:150,
dataIndex: 'ALDD_Param1',
editor: new Ext.form.TextField({
id:'idprovegasto',
autoCreate: {
tag: "input",
type: "text",
autocomplete:"off",
maxlength: 35
}
})
},{
header: "Cuenta",
width:80,
sortable:true,
dataIndex: 'ALDD_ACCOUNT',
editor: new Ext.grid.GridEditor(new Ext.form.ComboBox({
id:'al_account',
listWidth : 150,
hiddenName: 'ALI_Code',
store:store_Items,
displayField:'ALI_Text',
valueField:'ALI_Code',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true
}))
},{
header: "SubCuenta",
width:100,
sortable:true,
dataIndex: 'ALDD_SACCOUNT',
editor: new Ext.grid.GridEditor(new Ext.form.ComboBox({
id:'al_subaccount',
listWidth : 150,
hiddenName: 'ALSI_SItems',
store:store_subitems,
displayField:'ALSI_Text',
valueField:'ALSI_SItems',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true
}))
},
{header: "DESCRIPCION", width:300, dataIndex: 'ALDD_Text',
editor: new Ext.form.TextField({
autoCreate: {
tag:"input",
type:"text",
autocomplete:"off",
maxlength: 39
}
})
},
{header: "MONTO", width:100, dataIndex: 'ALDD_Total', editor: new Ext.form.NumberField({allowNegative: false})}
]);
cm.defaultSortable = true;
//FIN COLUMNA DETALLE
//COLUMNA COMENTARIOS PROVEEDORES
var cm_comproveedores= new Ext.grid.ColumnModel([
{id:'Idcomentarios',header: "ID", width:100, sortable: true, dataIndex:'Idcomentarios'},
{header: "Rut", width:100, dataIndex:'Rutproveedor'},
{header: "Fecha", width:100,dataIndex:'FechaLog',renderer: Ext.util.Format.dateRenderer('d-m-Y')},
{header: "Usuario", width:100, dataIndex:'Uid'},
{header: "Comentarios", width:740, dataIndex: 'Descripcion'}
]);
cm_comproveedores.defaultSortable = true;
//FIN COMENTARIOS PROVEEDORES
//COLUMNA COMENTARIOS DOC
var cm_comentarios = new Ext.grid.ColumnModel([
{id:'ALTD_Id',header: "ID", width:100, sortable: true, dataIndex: 'ALTD_Id'},
{header: "COD DOCUMENTO", width:40, dataIndex: 'ALTD_IdDoc'},
{header: "USUARIO", width:100, dataIndex: 'ALTD_UID', editor: new Ext.form.TextField()},
{header: "FECHA", width:100,dataIndex: 'ALTD_Date',renderer: Ext.util.Format.dateRenderer('d-m-Y')},
{header: "COMENTARIO", width:740, dataIndex: 'ALTD_Text'}
]);
cm_comentarios.defaultSortable = true;
//FIN COMENTARIOS DOC
//COLUMNA MIS COMENTARIOS DOC
var cm_miscomentarios = new Ext.grid.ColumnModel([
{id:'ALTD_Id',header: "ALTD_Id", width:100, sortable: true, dataIndex: 'ALTD_Id'},
{header: "COD DOCUMENTO", width:40, dataIndex: 'ALTD_IdDoc'},
{header: "USUARIO", width:100, dataIndex: 'ALTD_UID', editor: new Ext.form.TextField()},
{header: "FECHA", width:100,dataIndex: 'ALTD_Date',renderer:Ext.util.Format.dateRenderer('d-m-Y')},
{header: "COMENTARIO", width:740, dataIndex: 'ALTD_Text'}
]);
cm_comentarios.defaultSortable = true;
//FIN MIS COMENTARIOS DOC
//SELMODEL
var sm = new Ext.grid.RowSelectionModel({singleSelect:true});
var sm_gastos = new Ext.grid.RowSelectionModel({singleSelect:false});
var sm_rfact = new Ext.grid.RowSelectionModel({singleSelect:false});
var sm_comentarios = new Ext.grid.RowSelectionModel({singleSelect:false});
var sm_misdoc = new Ext.grid.RowSelectionModel({singleSelect:false});
var sm_misdocfact = new Ext.grid.RowSelectionModel({singleSelect:false});
var sm_miscomentarios = new Ext.grid.RowSelectionModel({singleSelect:false});
var sm_fact = new Ext.grid.RowSelectionModel({singleSelect:false});
var sm_proveedores = new Ext.grid.RowSelectionModel({singleSelect:false});
var sm_comproveedores = new Ext.grid.RowSelectionModel({singleSelect:false});
var sm_rproveedores = new Ext.grid.RowSelectionModel({singleSelect:true});
//FIN SELMODEL
/*
* ================ FormLayout config =======================
*/
// NOTE: While you can create a basic Panel with layout:'form', practically
// you should usually use a FormPanel to also get its form-specific functionality.
// Note that the layout config is not required on FormPanels.
var columnas_creafact = new Ext.FormPanel({
url:'crea_factura.php',
id:'columnas-creafact-panel',
frame:true,
title: 'Crear Facturas',
autoScroll:true,
width: 1024,
items:[{
layout:'column',
items: [{
width:350,
xtype:'fieldset',
border:false,
autoHeight:true,
bodyStyle:'padding:5px 5px 5px 5px',
labelWidth:100,
defaults: {
width: 200,
msgTarget: 'side'
},
items:[{
xtype:'hidden',
id:'acciondocfact'
},{
xtype:'numberfield',
id:'idfactura',
fieldLabel: 'ID',
name: 'idfactura'
},{
xtype:'numberfield',
id:'numerofact',
fieldLabel:'N. Fact/Bol',
enableKeyEvents: true,
listeners: {
'blur': {
fn: function(t){
if(Ext.getCmp('numerofact').getValue() != "" && Ext.getCmp('factrutproveedor').getValue() != ""){
Ext.Ajax.request({
url: 'ws_datos.php',
params: {
oper:"validarfact",numero:Ext.getCmp('numerofact').getValue(),proveedor:Ext.getCmp('factrutproveedor').getValue()},
success: function (response, request) { // When saving data success
var datos = Ext.util.JSON.decode(response.responseText);
var total = datos.total;
if(total > 0){
Ext.MessageBox.alert("Mensaje","Factura Para Este Proveedor Existe");
Ext.getCmp('columnas-creafact-panel').getForm().reset();
return true;
}
},
failure: function () {}
});
}
}
}
}
},{
xtype:'combo',
id:'factrutproveedor',
listWidth : 300,
hiddenName: 'Rut',
store:store_cproveedores,
displayField:'RazonSocial',
valueField:'Rut',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true,
fieldLabel:'N. Proveedor',
listeners: {
'change': {
fn: function(t){
if(Ext.getCmp('numerofact').getValue() != "" && Ext.getCmp('factrutproveedor').getValue() != ""){
Ext.Ajax.request({
url: 'ws_datos.php',
params: {
oper:"validarfact",numero:Ext.getCmp('numerofact').getValue(),proveedor:Ext.getCmp('factrutproveedor').getValue()},
success: function (response, request) { // When saving data success
var datos = Ext.util.JSON.decode(response.responseText);
var total = datos.total;
if(total > 0){
Ext.MessageBox.alert("Mensaje","Factura Para Este Proveedor Existe");
Ext.getCmp('columnas-creafact-panel').getForm().reset();
return true;
}
},
failure: function () {}
});
}
}
}
}
},{
xtype:'combo',
id:'factpercontable',
listWidth : 200,
hiddenName: 'IdPeriodo',
store:store_percontable,
displayField:'Periodo',
valueField:'IdPeriodo',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true,
fieldLabel: 'Periodo Contable'
},{
xtype:'combo',
id:'tipofact',
listWidth : 200,
hiddenName: 'IdTpoFactura',
store:store_tipofactura,
displayField:'TipoFactura',
valueField:'IdTpoFactura',
typeAhead: true,
mode: 'remote',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true,
fieldLabel: 'Tipo de Fact/Bol'
},{
xtype:'combo',
id:'albcenterfact',
listWidth : 200,
hiddenName: 'ALBC_Id',
store:store_bcenter,
displayField:'ALBC_Text',
valueField:'ALBC_Id',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true,
fieldLabel: 'Bcenter'
},{
xtype:'combo',
id:'cuentagastosfact',
listWidth : 200,
hiddenName: 'ALI_Code',
store:store_Items,
displayField:'ALI_Text',
valueField:'ALI_Code',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true,
fieldLabel: 'Cta Gastos'
},{
xtype:'combo',
id:'cuentasubgastosfact',
listWidth : 200,
hiddenName: 'ALSI_SItems',
store:store_subitems,
displayField:'ALSI_Text',
valueField:'ALSI_SItems',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true,
fieldLabel: 'Cta SubGastos'
},{
xtype:'combo',
id:'tpocargo',
listWidth : 200,
hiddenName: 'IdTipoCargo',
store:store_tipocargo,
valueField:'IdTipoCargo',
displayField:'Descripcion',
typeAhead: true,
mode: 'remote',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true,
fieldLabel: 'Tipo de Cargo'
}]
},{
xtype:'fieldset',
border:false,
bodyStyle:'padding:5px 5px 5px 5px',
autoHeight:true,
width: 380,
labelWidth:100,
defaults: {
width: 200,
msgTarget: 'side'
},
items:[{
xtype:'datefield',
id:'fechafact',
fieldLabel: 'Fecha Emision',
format:'d-m-Y',
value:new Date(),
name: 'fechafact'
},{
xtype:'datefield',
id:'fechafactvenc',
fieldLabel: 'Fecha Venc',
format:'d-m-Y',
value:new Date(),
name: 'fechafactvenc'
},{
xtype:'datefield',
id:'fechafactingre',
fieldLabel: 'Fecha Ingreso',
name: 'fechafactingre',
format:'d-m-Y',
value:new Date(),
disabled:true
}]
},{
xtype:'fieldset',
bodyStyle:'padding:5px 5px 5px 5px',
border:false,
autoHeight:true,
width: 380,
monitorValid:true,
labelWidth:100,
defaults: {
width: 200,
msgTarget: 'side'
},
items:[{
xtype:'numberfield',
id:'factneto',
fieldLabel: 'Neto',
disabled:true,
enableKeyEvents: true,
listeners: {
'keypress': {
fn: function(t){
if(Ext.getCmp('factpercontable').getValue() != ""){
Ext.Ajax.request(
{
url: 'ws_datos.php',
params: {
oper: "queryiva",
sql: "select Iva,honor from PeriodosContables where IdPeriodo="+Ext.getCmp('factpercontable').getValue()
},
success: function (response, request) { // When saving data success
if(Ext.getCmp('tipofact').getValue() == 4){
var datos = Ext.util.JSON.decode(response.responseText);
var phonor = datos.honor;
var neto = Ext.getCmp('factneto').getValue();
Ext.getCmp('facthonordesc').setValue(neto*phonor);
var thonor = Ext.getCmp('facthonordesc').getValue();
var ttotal = neto-thonor;
ttotal = Math.round(ttotal);
Ext.getCmp('facttotal').setValue(ttotal);
return true;
}
else{
var datos = Ext.util.JSON.decode(response.responseText);
var piva = datos.iva;
var neto = Ext.getCmp('factneto').getValue();
Ext.getCmp('factiva').setValue(neto*piva);
var tiva = Ext.getCmp('factiva').getValue();
var ttotal = neto+tiva;
ttotal = Math.round(ttotal);
Ext.getCmp('facttotal').setValue(ttotal);
return true;
}
},
failure: function () {}
});
}
else{
Ext.getCmp('factneto').setValue(0);
Ext.MessageBox.alert("Error","Seleccione Periodo Contable");
return false;
}
}
}
},
name: 'factneto'
},{
xtype:'numberfield',
id:'factiva',
fieldLabel: 'I.V.A',
readOnly:true,
disabled:true,
name: 'factiva'
},{
xtype:'numberfield',
id:'facthonordesc',
fieldLabel: 'Desc. Honor',
readOnly:true,
disabled:true
},{
xtype:'numberfield',
id:'factexento',
fieldLabel: 'Exento',
name: 'factexento',
disabled:true,
enableKeyEvents: true,
listeners: {
'keypress': {
fn: function(){
if(Ext.getCmp('factpercontable').getValue() != ""){
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "queryiva", //pass task to do to the server script
sql: "select Iva,honor from PeriodosContables where IdPeriodo="+Ext.getCmp('factpercontable').getValue()//pass to server same 'id' that the reader used
},//end params
success: function (response, request) { // When saving data success
var datos = Ext.util.JSON.decode(response.responseText);
var piva = datos.iva;
var neto = Ext.getCmp('factneto').getValue();
Ext.getCmp('factiva').setValue(neto*piva);
var tiva = Ext.getCmp('factiva').getValue();
var exento = Ext.getCmp('factexento').getValue();
var ttotal = neto+tiva+exento;
ttotal = Math.round(ttotal);
Ext.getCmp('facttotal').setValue(ttotal);
return true;
},
failure: function () {}
});//end ajax request config
}
else{
Ext.getCmp('factneto').setValue(0);
Ext.MessageBox.alert("Error","Seleccione Periodo Contable");
return false;
}
}
}
}
},{
xtype:'numberfield',
id:'facttotal',
disabled:true,
fieldLabel: 'Total',
ReadOnly:true,
name: 'facttotal'
}]
},{
xtype:'fieldset',
bodyStyle:'padding:5px 5px 5px 5px',
autoHeight:true,
border:false,
width: 380,
labelWidth:100,
defaults: {
width: 200,
msgTarget: 'side'
},
items:[{
xtype:'textfield',
id:'factusuario',
fieldLabel: 'Usuario',
name: 'factusuario',
readOnly:true
},{
xtype:'combo',
id:'encargadofact',
listWidth : 300,
hiddenName: 'IdEmpleado',
store:store_usuarios,
displayField:'Nombre',
valueField:'IdEmpleado',
typeAhead: true,
mode: 'remote',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE...',
selectOnFocus:true,
fieldLabel: 'Aprobado por'
},{
xtype:'textfield',
id:'comentfact',
fieldLabel: 'Descripcion',
name: 'comentfact'
}]
}]
},{
xtype: 'editorgrid',
name: 'gridfact',
id:'gridfact',
bodyStyle:'padding:0px 0px 10px 0px',
ds: store_fact,
autoHeight:true,
autoScroll:true,
cm: cm_fact,
selModel:sm_fact,
viewConfig: {
forceFit: true,
autoHeight:true,
autoScroll:true
},
width:840,
stripeRows: true,
clicksToEdit: 'auto',
tbar:[{
text: "AGREGAR",
iconCls:'add',
handler : function(){
if (verfactura) {
keydoc_fact = Ext.getCmp('idfactura').getValue();
}
Ext.getCmp('gridfact').stopEditing();
store_fact.insert(0, new myRecordObj({
ALDD_IdDoc:keydoc_fact,
ALDD_Line:ifact,
ALDD_Text: "",
ALDD_Total:''
}));
Ext.getCmp('gridfact').startEditing(0, 0);
}
},{
text: "ELIMINAR",
iconCls:'drop',
handler : function(){
Ext.getCmp('gridfact').stopEditing();
if(Ext.getCmp('gridfact').selModel.getCount() > 0)
{
Ext.MessageBox.confirm('Mensaje','¿Estas Seguro Que Deseas Eliminar?',
function(btn) {
if(btn=='yes')
{
//todo: por cada seleccionado
var record= Ext.getCmp('gridfact').selModel.getSelected();
var IdDoc = record.get('ALDD_IdDoc');
var Line = record.get('ALDD_Line');
Ext.getCmp('gridfact').getStore().remove(record);
}
}
);
}
else
{
Ext.MessageBox.alert('Message','POR FAVOR SELECCIONE UN DOCUMENTO');
}
Ext.getCmp('gridfact').startEditing(0,0);
}
},{
text: "ACTUALIZAR",
iconCls:'refresh',
handler : function(){
store_fact.baseParams= {oper:"query",sql:"select * from AL_DetDocs where ALDD_IdDoc="+Ext.getCmp('idfactura').getValue()};
store_fact.load();
}
}]
}],
buttons: [{
text: 'Ver Factura',
id:'verfactura',
handler: function () {
idfactura = Ext.getCmp('idfactura').getValue();
if(idfactura != ""){
Ext.Ajax.request({
url: 'ws_datos.php',
params: {
oper: "queryverfactura",
sql: idfactura+"-"+username
},
success: function (response, request) {
var datos = Ext.util.JSON.decode(response.responseText);
var correcto = datos.failure;
if(!correcto){
Ext.getCmp('crafact').setText('Actualizar');
Ext.getCmp('verfactura').disable(true);
Ext.getCmp('nuevafact').enable(true);
Ext.getCmp('borrarfact').enable(true);
Ext.getCmp('genpdffact').enable(true);
idfactura = "";
verfactura = true;
idfactura = Ext.getCmp('idfactura').getValue();
Ext.getCmp('idfactura').disable(true);
Ext.getCmp('gridfact').show();
var fecha = datos.fecha;
fecha = fecha.split(" ");
var fechavenc = datos.fechavenc;
var fechafact = datos.fechafact;
var account = datos.account;
var saccount = datos.saccount;
var proveedor = datos.proveedor;
var aprobado = datos.aprobado;
var nfactura = datos.nfactura;
var bcenter = datos.bcenter;
var exento = datos.exento;
var total = datos.total;
var neto = datos.neto;
var iva = datos.iva;
var honor = datos.honor;
var idline = datos.idline;
var percontable = datos.percontable;
var tipogasto = datos.tipogasto;
var descripcion = datos.comentfact;
var tipofact = datos.tipofact;
ifact = datos.idline;
store_subitems.baseParams = {oper:"query",sql:"select * from AL_nSItems where ALSI_Items="+account};
store_subitems.load();
switch(tipofact)
{
case 1:
Ext.getCmp('factneto').enable(true); //neto
Ext.getCmp('factiva').enable(true); //iva
Ext.getCmp('facttotal').enable(true); //iva
Ext.getCmp('factexento').enable(true);
Ext.getCmp('facthonordesc').disable(true);
break;
case 2:
Ext.getCmp('factneto').disable(true); //neto
Ext.getCmp('factiva').disable(true); //iva
Ext.getCmp('facttotal').enable(true); //iva
Ext.getCmp('factexento').enable(true);
Ext.getCmp('facthonordesc').disable(true);
break;
case 3:
break;
case 4:
Ext.getCmp('factneto').enable(true); //neto
Ext.getCmp('factiva').disable(true); //iva
Ext.getCmp('facthonordesc').enable(true);
Ext.getCmp('facttotal').enable(true);
Ext.getCmp('factexento').disable(true);
break;
}
store_Items.reload();
Ext.getCmp('factrutproveedor').setValue(proveedor);
Ext.getCmp('fechafactvenc').setValue(fechavenc);
Ext.getCmp('fechafact').setValue(fechafact);
Ext.getCmp('fechafactingre').setValue(fecha[0]);
Ext.getCmp('factneto').setValue(neto);
Ext.getCmp('factiva').setValue(iva);
Ext.getCmp('facthonordesc').setValue(honor);
Ext.getCmp('factexento').setValue(exento);
Ext.getCmp('facttotal').setValue(total);
Ext.getCmp('albcenterfact').setValue(bcenter);
Ext.getCmp('encargadofact').setValue(aprobado);
Ext.getCmp('cuentasubgastosfact').setValue(saccount);
Ext.getCmp('numerofact').setValue(nfactura);
Ext.getCmp('tpocargo').setValue(tipogasto);
Ext.getCmp('factpercontable').setValue(percontable);
Ext.getCmp('acciondocfact').setValue('verfactura');
Ext.getCmp('comentfact').setValue(descripcion);
Ext.getCmp('tipofact').setValue(tipofact);
Ext.getCmp('cuentagastosfact').setValue(account);
Ext.getCmp('cuentasubgastosfact').setValue(saccount);
store_fact.baseParams = {oper:"query",sql:"select * from AL_DetDocs where ALDD_IdDoc="+idfactura};
store_fact.load();
}
else{
Ext.getCmp('idfactura').reset(true);
Ext.getCmp('idfactura').enable(true);
verfactura=false;
Ext.MessageBox.alert ('Mensaje','No Tiene Derecho Sobre Este Documento');
}
},
failure: function () { // when saving data failed
}
}//end ajax request config
); //end ajax reques
}
else{
Ext.MessageBox.alert("Error","No Ingreso ID Factura");
}
}
},{
text: 'Crear Factura',
id:'crafact',
handler: function () {
if(verfactura){
Ext.getCmp('idfactura').enable(true);
columnas_creafact.getForm().submit({
waitMsg: 'Guardando...',
success: function (form, action){
Ext.getCmp('idfactura').disable(true);
Ext.getCmp('verfactura').disable(true);
Ext.getCmp('nuevafact').enable(true);
Ext.getCmp('borrarfact').enable(true);
Ext.getCmp('genpdffact').enable(true);
},
failure:function(form, action) {
Ext.getCmp('idfactura').disable(true);
Ext.MessageBox.alert('Error', 'Ingreso no se actualizo');
}
});
}
else{
columnas_creafact.getForm().submit({
waitMsg: 'Guardando...', // Wait Messag
success: function (form, action){
keydoc_fact = action.result.primarykey;
Ext.getCmp('idfactura').setValue(keydoc_fact);
Ext.getCmp('gridfact').stopEditing();
Ext.getCmp('gridfact').show();
store_fact.insert(0, new myRecordObj({
ALDD_IdDoc:keydoc_fact,
ALDD_Line:ifact,
ALDD_Text: "",
ALDD_Total:''
}));
store_fact.baseParams = {oper:"query",sql:"select * from AL_DetDocs where ALDD_IdDoc="+Ext.getCmp('idfactura').getValue()};
store_fact.load();
Ext.getCmp('acciondocfact').setValue('verfactura');
verfactura = true;
Ext.getCmp('crafact').setText('Actualizar');
Ext.getCmp('verfactura').disable(true);
Ext.getCmp('idfactura').disable(true);
Ext.getCmp('borrarfact').enable(true);
},
failure:function(form, action) {
Ext.MessageBox.alert('Error', 'Ingrese responsable del documento');
}
});
Ext.getCmp('gridfact').startEditing(0, 0);
}
}
},{
text: 'Nueva',
id:'nuevafact',
disabled:true,
handler: function () {
Ext.getCmp('idfactura').enable(true);
verfactura = false;
Ext.getCmp('idfactura').enable(true);
Ext.getCmp('idfactura').reset();
Ext.getCmp('tipofact').reset();
Ext.getCmp('numerofact').reset();
Ext.getCmp('factrutproveedor').reset();
Ext.getCmp('factpercontable').reset();
Ext.getCmp('fechafact').reset();
Ext.getCmp('fechafactvenc').reset();
Ext.getCmp('fechafactingre').reset();
Ext.getCmp('factneto').reset();
Ext.getCmp('factiva').reset();
Ext.getCmp('factexento').reset();
Ext.getCmp('facthonordesc').reset();
Ext.getCmp('facttotal').reset();
Ext.getCmp('albcenterfact').reset();
Ext.getCmp('cuentagastosfact').reset();
Ext.getCmp('cuentasubgastosfact').reset();
Ext.getCmp('encargadofact').reset();
Ext.getCmp('tpocargo').reset();
Ext.getCmp('comentfact').reset();
Ext.getCmp('acciondocfact').reset();
Ext.getCmp('nuevafact').disable(true);
Ext.getCmp('genpdffact').disable(true);
Ext.getCmp('borrarfact').disable(true);
Ext.getCmp('verfactura').enable(true);
Ext.getCmp('gridfact').hide();
Ext.getCmp('crafact').setText('Crear Factura');
ifact=1;
}
},{
text: 'Borrar',
id:'borrarfact',
disabled:true,
handler: function () {
Ext.Ajax.request({
url: 'ws_datos.php',
params: {
oper: "delete",
sql: "delete from AL_TextDocs where ALTD_IdDoc="+Ext.getCmp('idfactura').getValue()
},
success: function () {
Ext.Ajax.request({
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DOCS where ALD_IdDoc="+Ext.getCmp('idfactura').getValue() //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DetDocs where ALDD_IdDoc="+Ext.getCmp('idfactura').getValue() //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
verfactura = false;
Ext.getCmp('idfactura').enable(true);
Ext.getCmp('idfactura').reset();
Ext.getCmp('tipofact').reset();
Ext.getCmp('factrutproveedor').reset();
Ext.getCmp('numerofact').reset();
Ext.getCmp('factpercontable').reset();
Ext.getCmp('fechafact').reset();
Ext.getCmp('fechafactvenc').reset();
Ext.getCmp('fechafactingre').reset();
Ext.getCmp('fechafactingre').reset();
Ext.getCmp('factneto').reset();
Ext.getCmp('factiva').reset();
Ext.getCmp('factexento').reset();
Ext.getCmp('facttotal').reset();
Ext.getCmp('albcenterfact').reset();
Ext.getCmp('cuentagastosfact').reset();
Ext.getCmp('cuentasubgastosfact').reset();
Ext.getCmp('factusuario').reset();
Ext.getCmp('encargadofact').reset();
Ext.getCmp('tpocargo').reset();
Ext.getCmp('comentfact').reset();
Ext.getCmp('acciondocfact').reset();
Ext.getCmp('nuevafact').disable(true);
Ext.getCmp('borrarfact').disable(true);
Ext.getCmp('verfactura').enable(true);
Ext.getCmp('gridfact').hide();
Ext.getCmp('crafact').setText('Crear Factura');
ifact=1;
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No Se Borro detalle factura');
}
}); //end ajax reques
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No Se Borro la factura');
}
}); //end ajax reques FIN BORRAR DOCUMENTOS
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No Se Borro comentarios');
}}); //end ajax reques
}
},{
text:'Generar PDF',
id:'genpdffact',
disabled:true,
tooltip:'Generar PDF de Factura',
handler: function(){
window.open('generadores/ver_factcompra.php?keydoc='+Ext.getCmp('idfactura').getValue());
}
}]
});
var form_proveedor = new Ext.FormPanel({
xtype:'form',
id: 'form-proveedor-panel',
url:'crea_proveedor.php',
title: 'Administrar Proveedores',
bodyStyle:'padding:10px',
frame:true,
autoScroll:true,
defaults: {
msgTarget: 'side'
},
layout:'column',
items: [{
xtype:'fieldset',
border:false,
labelWidth: 90,
height:320,
labelPad: 10,
width:400,
defaults: {
width: 250
},
items:[{
xtype:'hidden',
id:'proveedor'
},{
xtype:'textfield',
id:'rutproevedor',
fieldLabel: 'Rut'
},{
xtype:'textfield',
id:'rsproveedor',
fieldLabel: 'Razon Social'
},{
xtype:'combo',
id:'tipoproveedor',
listWidth : 250,
hiddenName: 'id_tipo',
store:store_tipoproveedor,
valueField:'id_tipo',
displayField:'descripcion',
typeAhead: true,
mode: 'remote',
forceSelection:false,
triggerAction: 'all',
emptyText:'SELECCIONE CATEGORIA...',
selectOnFocus:true,
fieldLabel: 'Categoria',
listeners: {
click:function(cmb,record,index){
store_tipoproveedor.load();
}
}
},{
xtype:'textfield',
id:'direproveedor',
fieldLabel: 'Direccion'
},{
xtype:'textfield',
id:'fonoproveedor',
fieldLabel: 'Telefono'
},{
xtype:'textfield',
id:'giroproveedor',
fieldLabel: 'Giro'
},{
xtype:'textfield',
id:'banco',
fieldLabel: 'Banco'
},{
xtype:'textfield',
id:'cuentabanco',
fieldLabel: 'Cuenta'
},{
xtype:'textfield',
id:'email',
vtype:'email',
fieldLabel: 'E-Mail'
},{
xtype:'textfield',
id:'contacto',
fieldLabel: 'Contacto'
},{
buttons: [{
text: 'Actualizar',
id:'creaprove',
formBind: true,
handler: function () {
Ext.getCmp('rutproevedor').enable(true);
form_proveedor.getForm().submit({
waitMsg: 'Guardando...',
success: function (form, action){
Ext.getCmp('gridfact').stopEditing();
store_proveedores.load({params:{start:0, limit:15}});
store_cproveedores.load();
Ext.getCmp('form-proveedor-panel').getForm().reset();
Ext.getCmp('gridfact').startEditing(0, 0);
},
failure:function(form, action) {
var error = action.result.error;
Ext.MessageBox.alert('Mensaje',error);
}
});
}
},{
text: 'Nuevo',
id:'limpiarproveedor',
handler: function (){
Ext.getCmp('form-proveedor-panel').getForm().reset();
Ext.getCmp('rutproevedor').enable(true);
}
}]
}]
},{
xtype:'grid',
id:'gridrproveedores',
ds:store_rproveedores,
cm:cm_rproveedores,
selModel:sm_rproveedores,
bbar:pagrproveedores,
scroll:false,
width:460,
height:250,
stripeRows: true,
frame:true,
title:'RESUMEN FACTURAS',
iconCls:'icon-grid'
},{
xtype:'fieldset',
border:false,
bodyStyle:'padding:0px 0px 10px 0px',
autoHeight:true,
items:[{
xtype:'grid',
id:'gridproveedores',
name:'gridproveedores',
ds:store_proveedores,
cm:cm_proveedores,
tbar: [{
text: "ELIMINAR",
iconCls:'drop',
handler : function(){
if(Ext.getCmp('gridproveedores').selModel.getCount() > 0){
Ext.MessageBox.confirm('Mensaje','¿Estas Seguro Que Deseas Eliminar?',
function(btn){
if(btn=='yes'){
var record = Ext.getCmp('gridproveedores').selModel.getSelected();
var rutp = record.get('Rut');
Ext.Ajax.request({
url: 'ws_datos.php',
params: {oper:'deleteprove',rut:rutp},
success:function(response,request){
var record= Ext.getCmp('gridproveedores').selModel.getSelected();
var id_proveedor = record.get('Id_Proveedor');
Ext.getCmp('gridproveedores').getStore().remove(record);
Ext.getCmp('form-proveedor-panel').getForm().reset();
},
failure:function(response,request){
var error = action.result.error;
Ext.MessageBox.alert('Mensaje',error);
}
});
}
}
);
}
else{
Ext.MessageBox.alert('Message','POR FAVOR SELECCIONE UN DOCUMENTO');
}
}
},{
xtype:'combo',
id:'filtro_tipoproveedor',
listWidth : 250,
store:store_tipoproveedor,
valueField:'id_tipo',
displayField:'descripcion',
typeAhead: true,
mode: 'remote',
forceSelection:false,
triggerAction: 'all',
emptyText:'SELECCIONE CATEGORIA...',
selectOnFocus:true,
fieldLabel: 'Categoria',
listeners: {
click:function(cmb,record,index){
store_tipoproveedor.load();
},
select:function(cmb,record,index){
var buscar = '';
var tipoproveedor = Ext.getCmp('filtro_tipoproveedor').getValue();
if(tipoproveedor != 8){
store_proveedores.baseParams = {oper:"querybuscarproveedor",busca:buscar,filtro:tipoproveedor};
store_proveedores.load({params:{start:0, limit:15}});
}else{
store_proveedores.baseParams = {oper:"queryproveedores"};
store_proveedores.load({params:{start:0, limit:15}});
}
}
}
},new Ext.Toolbar.Fill(),{
text: 'VER PDF',
iconCls:'pdf',
handler : function(){
var record = Ext.getCmp('griddocfact').selModel.getSelected();
var doc = record.get('ALD_IdDoc');
window.open('generadores/ver_factcompra.php?keydoc='+doc);
}
},{
text: 'PLANILLA',
handler : function(){
var record = Ext.getCmp('griddocfact').selModel.getSelected();
var doc = record.get('ALD_IdDoc');
window.open('generadores/ver_factcompra.php?keydoc='+doc);
}
}],
selModel:sm_proveedores,
bbar:pagproveedores,
width:940,
height:350,
stripeRows: true,
frame:true,
title:'LISTA PROVEEDORES',
iconCls:'icon-grid'
}]
},{
xtype:'fieldset',
border:false,
bodyStyle:'padding:0px 0px 10px 0px',
autoHeight:true,
items:[{
xtype:'grid',
id:'gridcomproveedores',
name:'gridcomproveedores',
ds:store_comproveedores,
cm:cm_comproveedores,
selModel:sm_comproveedores,
width:940,
autoHeight:true,
autoScroll:true,
stripeRows: true,
frame:true,
title:"Comentarios",
iconCls:'icon-grid'
}]
}]
});
var form_rendgastos = new Ext.FormPanel({
xtype: 'form',
url:'crea_rendgastos.php',
id: 'form-panel',
name: 'form_rendgastos',
labelWidth:120,
title: 'Rendicion de Gastos',
bodyStyle:'padding:10px',
width: 1024,
labelPad: 10,
frame:true,
resizable: true,
plain: true,
border: true,
autoScroll:true,
defaults: {
width: 300,
msgTarget: 'side'
},
items: [{
xtype:'numberfield',
id:'idgasto',
fieldLabel: 'ID GASTO',
name: 'idgasto'
},{
xtype:'textfield',
id:'usuario',
fieldLabel: 'USUARIO',
readOnly:true,
name: 'usuario'
},{
xtype:'datefield',
id:'fechagasto',
fieldLabel: 'FECHA RENDICION',
format:'d-m-Y',
value:new Date(),
name: 'fecha',
readOnly:true,
disabled:true,
allowBlank:false
},{
xtype:'combo',
id:'encargado',
listWidth : 300,
hiddenName: 'IdEmpleado',
store:store_usuarios,
displayField:'Nombre',
valueField:'IdEmpleado',
typeAhead: true,
mode: 'remote',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE ENCARGADO...',
selectOnFocus:true,
fieldLabel: 'APROBADO POR'
},{
xtype:'combo',
id:'albcenter',
listWidth : 300,
hiddenName: 'ALBC_Id',
store:store_bcenter,
displayField:'ALBC_Text',
valueField:'ALBC_Id',
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE BCENTER...',
selectOnFocus:true,
fieldLabel: 'Bcenter',
name: 'albcenter'
},{
xtype:'textfield',
id:'descripcion',
fieldLabel: 'DESCRIPCION',
name: 'descripcion'
},{
xtype: 'editorgrid',
name: 'grid',
id:'grid',
bodyStyle:'padding:0px 0px 10px 0px',
ds: store2,
cm: cm,
viewConfig: {
forceFit: true
},
selModel:sm,
width:840,
autoHeight:true,
stripeRows: true,
clicksToEdit: 'auto',
tbar:[{
text: "AGREGAR",
iconCls:'add',
handler : function(){
Ext.getCmp('grid').stopEditing();
store2.insert(i, new myRecordObj({
ALDD_IdDoc:keydoc,
ALDD_Line:i,
ALDD_Date:new Date(),
ALDD_Type:'',
ALDD_BCENTER:bcenterid,
ALDD_Number: "",
ALDD_Param1: "",
ALDD_ACCOUNT: "",
ALDD_Text: "",
ALDD_Total:''
}));
Ext.getCmp('grid').startEditing(0, 0);
}
},{
text: "ELIMINAR",
iconCls:'drop',
handler : function(){
Ext.getCmp('grid').stopEditing();
if(Ext.getCmp('grid').selModel.getCount() > 0)
{
Ext.MessageBox.confirm('Mensaje','¿Estas Seguro Que Deseas Eliminar?',
function(btn) {
if(btn=='yes')
{
//todo: por cada seleccionado
var record= Ext.getCmp('grid').selModel.getSelected();
var IdDoc = record.get('ALDD_IdDoc');
var Line = record.get('ALDD_Line');
Ext.getCmp('grid').getStore().remove(record);
}
}
);
}
else
{
Ext.MessageBox.alert('Message','POR FAVOR SELECCIONE UN DOCUMENTO');
}//end if/else block
Ext.getCmp('grid').startEditing(0, 0);
}
},{
text: "ACTUALIZAR",
iconCls:'refresh',
handler : function(){
store2.baseParams= {oper:"query",sql:"select * from AL_DetDocs where ALDD_IdDoc="+Ext.getCmp('idgasto').getValue()};
store2.load();
}
}],
cls:'x-panel-blue',
frame:true,
title:'Detalle',
iconCls:'icon-grid',
renderTo: document.body
},{
xtype:'numberfield',
name:'totalgasto',
id:'totalgasto',
fieldLabel: 'TOTAL RENDIDO',
readOnly:true,
value:'0'
},{
xtype:'hidden',
id:'acciondoc'
}],
buttons: [{
text: 'Ver Gasto',
id:'vdocgasto',
handler: function () {
idgasto = Ext.getCmp('idgasto').getValue();
if(idgasto != ""){
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "queryvergasto", //pass task to do to the server script
sql: idgasto+"-"+username //pass to server same 'id' that the reader used
},//end params
success: function (response, request) { // When saving data success
idgasto = "";
vergasto = true;
var datos = Ext.util.JSON.decode(response.responseText);
var correcto = datos.failure;
if(!correcto){
Ext.getCmp('borrargasto').enable(true);
Ext.getCmp('genexcel').enable(true);
idgasto = Ext.getCmp('idgasto').getValue();
Ext.getCmp('idgasto').disable(true);
Ext.getCmp('grid').show();
Ext.getCmp('totalgasto').show();
var descripcion = datos.descripcion;
var fecha = datos.fecha;
var bcenter = datos.bcenter;
bcenterid = bcenter;
var total = datos.total;
var aprobado = datos.aprobado;
i = datos.idline;
Ext.getCmp('totalgasto').setValue(total);
Ext.getCmp('descripcion').setValue(descripcion);
Ext.getCmp('fechagasto').setValue(fecha);
Ext.getCmp('encargado').setValue(aprobado);
Ext.getCmp('albcenter').setValue(bcenter);
Ext.getCmp('acciondoc').setValue('vergasto');
Ext.getCmp('nuevorendgasto').enable(true);
Ext.getCmp('genpdfgasto').enable(true);
Ext.getCmp('nuevorendgasto').enable(true);
Ext.getCmp('creadoc').setText('Actualizar');
store2.baseParams = {oper:"query",sql:"select * from AL_DetDocs where ALDD_IdDoc="+idgasto};
store2.reload();
}
else{
Ext.getCmp('idgasto').reset(true);
Ext.getCmp('idgasto').enable(true);
vergasto = false;
Ext.MessageBox.alert ('Mensaje','No Tiene Derecho Sobre Este Documento');
}
},
failure: function () { // when saving data failed
}
}//end ajax request config
); //end ajax reques
}
else{
Ext.MessageBox.alert ('Mensaje','No ingreso ID de Gasto');
}
}
},{
text: 'Hoja de Calculo',
id:'genexcel',
disabled:true,
handler: function () {
idgasto = Ext.getCmp('idgasto').getValue();
if (vergasto) {
keydoc = idgasto;
}
location.href='generadores/ver_exceldetalle.php?keydoc='+keydoc;
}
},{
text: 'Crear Gasto',
id:'creadoc',
handler: function () {
if(vergasto){
Ext.getCmp('idgasto').enable(true);
form_rendgastos.getForm().submit({
waitMsg: 'Guardando...',
success: function (form, action){
Ext.getCmp('idgasto').disable(true);
Ext.getCmp('genexcel').enable(true);
bcenterid = action.result.bcenter;
},
failure:function(form, action) {
Ext.getCmp('idgasto').reset(true);
Ext.getCmp('idgasto').enable(true);
Ext.MessageBox.alert('Error', 'Ingrese no se actualiza');
}
});
}
else
{
form_rendgastos.getForm().submit({
waitMsg: 'Guardando...',
success: function (form, action){
keydoc = action.result.primarykey;
Ext.getCmp('idgasto').setValue(keydoc);
Ext.getCmp('idgasto').disable(true);
bcenterid = action.result.bcenter;
Ext.getCmp('vdocgasto').disable(true);
Ext.getCmp('encargado').disable(true);
Ext.getCmp('descripcion').disable(true);
Ext.getCmp('albcenter').disable(true);
Ext.getCmp('guardarrendgasto').enable(true);
Ext.getCmp('borrargasto').enable(true);
Ext.getCmp('grid').show();
Ext.getCmp('totalgasto').show();
Ext.getCmp('creadoc').disable(true);
Ext.getCmp('guardarrendgasto').enable(true);
Ext.getCmp('grid').stopEditing();
store2.insert(0, new myRecordObj({
ALDD_IdDoc:keydoc,
ALDD_Line:i,
ALDD_Date:'',
ALDD_Type:'',
ALDD_BCENTER:bcenterid,
ALDD_Number: "",
ALDD_Param1: "",
ALDD_ACCOUNT: "",
ALDD_Text: "",
ALDD_Total:''
}));
Ext.getCmp('grid').startEditing(0, 0);
},
failure:function(form, action) {
Ext.MessageBox.alert('Error', 'Ingrese responsable del documento');
}
});
}
}
},{
text: 'Guardar',
id:'guardarrendgasto',
disabled:true,
handler: function () {
var gastototal = Ext.getCmp('totalgasto').getValue();
var id = Ext.getCmp('idgasto').getValue();
var usuario = Ext.getCmp('usuario').getValue();
var encargado = Ext.getCmp('encargado').getValue();
Ext.Ajax.request({
url: 'ws_datos.php',
waitMsg: 'Guardando...',
modal:true,
params: {oper: "updateguardar", idrend:id,totalrend:gastototal,userrend:usuario,userchk:encargado,descrip:Ext.getCmp('descripcion').getValue()},
success: function () {
Ext.getCmp('genpdfgasto').enable(true);
Ext.getCmp('genexcel').enable(true);
Ext.getCmp('nuevorendgasto').enable(true);
},
failure: function () {
Ext.MessageBox.alert ('Mensaje','No Se Guardo el Documento');
}
});
}
},{
text: 'Borrar',
id:'borrargasto',
disabled:true,
handler: function () {
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_TextDocs where ALTD_IdDoc="+Ext.getCmp('idgasto').getValue() //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
//INICIO DOCUMENTO GASTO
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DOCS where ALD_IdDoc="+Ext.getCmp('idgasto').getValue() //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
if (vergasto) {
keydoc = Ext.getCmp('idgasto').getValue();
}
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DetDocs where ALDD_IdDoc="+Ext.getCmp('idgasto').getValue() //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
vergasto = false;
Ext.getCmp('acciondoc').reset();
Ext.getCmp('genexcel').enable(true);
Ext.getCmp('nuevorendgasto').enable(true);
Ext.getCmp('vdocgasto').enable(true);
Ext.getCmp('idgasto').reset();
Ext.getCmp('idgasto').enable(true);
Ext.getCmp('albcenter').reset();
Ext.getCmp('borrargasto').disable(true);
Ext.getCmp('genexcel').disable(true);
Ext.getCmp('encargado').reset();
Ext.getCmp('descripcion').reset();
Ext.getCmp('totalgasto').reset();
Ext.getCmp('grid').hide();
Ext.getCmp('totalgasto').hide();
Ext.getCmp('creadoc').enable(true);
Ext.getCmp('nuevorendgasto').disable(true);
Ext.getCmp('genpdfgasto').disable(true);
Ext.getCmp('guardarrendgasto').disable(true);
Ext.getCmp('encargado').enable(true);
Ext.getCmp('descripcion').enable(true);
Ext.getCmp('albcenter').enable(true);
Ext.getCmp('creadoc').setText('Crear Gasto');
i=1;
store_listadoc.reload();
store_misdoc.reload();
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No Se Borro el Gasto');
}
}); //end ajax reques
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No Se Borro el Gasto');
}
}//end ajax request config
); //end ajax reques
//FIN DOCUMENTO GASTOS
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No Se Borro el Gasto');
}}//end ajax request config
); //end ajax reques
}
},{
text: 'Nuevo',
id:'nuevorendgasto',
disabled:true,
handler: function () {
store_subitems.baseParams = {oper:"query",sql:"select * from AL_nSItems where ALSI_Items=0"};
store_subitems.load();
vergasto = false;
Ext.getCmp('genexcel').disable(true);
Ext.getCmp('vdocgasto').enable(true);
Ext.getCmp('acciondoc').reset();
Ext.getCmp('albcenter').reset();
Ext.getCmp('descripcion').reset();
Ext.getCmp('encargado').reset();
Ext.getCmp('idgasto').reset();
Ext.getCmp('idgasto').enable(true);
Ext.getCmp('totalgasto').reset();
Ext.getCmp('grid').hide();
Ext.getCmp('totalgasto').hide();
Ext.getCmp('creadoc').enable(true);
Ext.getCmp('nuevorendgasto').disable(true);
Ext.getCmp('genpdfgasto').disable(true);
Ext.getCmp('guardarrendgasto').disable(true);
Ext.getCmp('borrargasto').disable(true);
Ext.getCmp('encargado').enable(true);
Ext.getCmp('descripcion').enable(true);
Ext.getCmp('albcenter').enable(true);
Ext.getCmp('creadoc').setText('Crear Gasto');
i=1;
store_listadoc.reload();
store_misdoc.reload();
}
},{
text:'Generar PDF',
id:'genpdfgasto',
disabled:true,
tooltip:'Generar PDF de Gastos',
handler: function(){
if (vergasto) {
keydoc = idgasto;
}
window.open('generadores/ver_rendgastos.php?keydoc='+keydoc);
}
}]
});
var form_revisiongastos = new Ext.FormPanel({
xtype: 'form', // since we are not using the default 'panel' xtype, we must specify it
id: 'form-revisiongastos-panel',
name: 'form_revisiongastos',
labelWidth:120,
bodyStyle:'padding:10px',
title:'Revision de Gastos',
width: 1024,
labelPad: 10,
labelAlign: 'top',
frame:true,
resizable: true,
plain: true,
border: true,
autoScroll:true,
defaults: {
width: 300,
msgTarget: 'side'
},
items: [{
xtype:'grid',
id:'griddocgastos',
name:'griddocgastos',
ds:store_listadoc,
cm:cm_doc,
loadMask: true,
viewConfig: {
forceFit: true
},
bodyStyle:'padding:0px 0px 10px 0px',
selModel:sm_gastos,
width:940,
autoHeight:true,
autoScroll:true,
stripeRows: true,
clicksToEdit: 'auto',
tbar: [{
text: 'VER PDF',
iconCls:'pdf',
handler : function(){
var record = Ext.getCmp('griddocgastos').selModel.getSelected();
var doc = record.get('ALD_IdDoc');
window.open('generadores/ver_rendgastos.php?keydoc='+doc);
}
}],
bbar: paglistadoc,
cls:'x-panel-blue',
frame:true,
title:'Gastos',
iconCls:'icon-grid',
renderTo: document.body
},{
xtype:'grid',
id:'gridcomentarios',
name:'gridcomentarios',
ds:store_comentarios,
cm:cm_comentarios,
viewConfig: {
forceFit: true
},
bodyStyle:'padding:0px 0px 10px 0px',
selModel:sm_comentarios,
width:940,
autoHeight:true,
autoScroll:true,
stripeRows: true,
clicksToEdit: 'auto',
cls:'x-panel-blue',
frame:true,
title:'Comentarios',
iconCls:'icon-grid',
renderTo: document.body
}]
});
var form_misdoc = new Ext.FormPanel({
xtype: 'form',
id: 'form-misdoc-panel',
name: 'form_misdoc',
labelWidth:120,
bodyStyle:'padding:10px',
title:'Revision de mis gastos',
width: 1024,
labelPad: 10,
labelAlign: 'top',
frame:true,
resizable: true,
plain: true,
border: true,
autoScroll:true,
defaults: {
width: 300,
msgTarget: 'side'
},
items: [{
xtype:'grid',
id:'gridmisdoc',
name:'gridmisdoc',
ds:store_misdoc,
cm:cm_misdoc,
loadMask: true,
viewConfig: {
forceFit: true
},
bodyStyle:'padding:0px 0px 10px 0px',
selModel:sm_misdoc,
width:940,
autoHeight:true,
autoScroll:true,
stripeRows: true,
clicksToEdit: 'auto',
tbar: [{
text: 'VER PDF',
iconCls:'pdf',
handler : function(){
var record = Ext.getCmp('gridmisdoc').selModel.getSelected();
var doc = record.get('ALD_IdDoc');
window.open('generadores/ver_rendgastos.php?keydoc='+doc);
}
},{
text: 'ELIMINAR',
iconCls:'drop',
handler : function(){
Ext.getCmp('gridmisdoc').stopEditing();
var records = Ext.getCmp('gridmisdoc').selModel.getSelected();
var estado = records.get('ALD_Status');
if(Ext.getCmp('gridmisdoc').selModel.getCount() > 0 && estado == 1 )
{
Ext.MessageBox.confirm('Mensaje','¿Seguro que desea eliminar el documento?',
function(btn) {
if(btn=='yes')
{
//todo: por cada seleccionado
var record = Ext.getCmp('gridmisdoc').selModel.getSelected();
var data = record.get('ALD_IdDoc');
Ext.getCmp('gridmisdoc').getStore().remove(record);
}
}
);
}
else
{
if(estado != 1){
Ext.MessageBox.alert('Mensaje','DOCUMENTO YA POSEE ESTADO');
}
else{
Ext.MessageBox.alert('Mensaje','POR FAVOR SELECCIONE UN DOCUMENTO');
}
}
//Ext.getCmp('griddocgastos').startEditing(0,0);
}
}],
bbar:pagmisdoc,
cls:'x-panel-blue',
frame:true,
title:'Gastos',
iconCls:'icon-grid',
renderTo: document.body
},{
xtype:'grid',
id:'gridmiscomentarios',
name:'gridmiscomentarios',
ds:store_miscomentarios,
cm:cm_miscomentarios,
viewConfig: {
forceFit: true
},
bodyStyle:'padding:0px 0px 10px 0px',
selModel:sm_miscomentarios,
width:940,
autoHeight:true,
autoScroll:true,
stripeRows: true,
clicksToEdit: 'auto',
cls:'x-panel-blue',
frame:true,
title:'Comentarios',
iconCls:'icon-grid',
renderTo: document.body
}]
});
var form_revisionfact = new Ext.FormPanel({
xtype: 'form',
id: 'form-revisionfact-panel',
labelWidth:120,
bodyStyle:'padding:10px',
title:'Revision Facturas',
width: 1024,
plain: true,
border: true,
autoScroll:true,
frame:true,
height:200,
defaults: {
width: 300,
msgTarget: 'side'
},
items: [{
xtype:'grid',
id:'griddocfact',
name:'griddocfact',
ds:store_listafact,
cm:cm_rdocfact,
autoHeight:true,
viewConfig: {
forceFit: true
},
selModel:sm_rfact,
height:200,
width:980,
tbar: ['Buscar',':',{
xtype:'textfield',
id:'factrevbuscar',
fieldLabel: 'Buscar',
width:250,
enableKeyEvents:true
},{
iconCls:'search',
handler : function(){
var buscar = Ext.getCmp('factrevbuscar').getValue();
store_listafact.baseParams = {oper:"querybuscarfact",busca:buscar};
store_listafact.load({params:{start:0, limit:15}});
store_listafact.baseParams = {oper:"querychkfacturas"};
}
},
new Ext.Toolbar.Fill(),{
text: 'VER PDF',
iconCls:'pdf',
handler : function(){
var record = Ext.getCmp('griddocfact').selModel.getSelected();
var doc = record.get('ALD_IdDoc');
window.open('generadores/ver_factcompra.php?keydoc='+doc);
}
}],
bbar: paglistafact,
cls:'x-panel-blue',
frame:true,
title:'Facturas',
iconCls:'icon-grid',
renderTo: document.body
},{
xtype:'grid',
id:'gridcomentarios',
name:'gridcomentarios',
ds:store_comentariosfact,
cm:cm_comentarios,
viewConfig: {
forceFit: true
},
bodyStyle:'padding:0px 0px 10px 0px',
selModel:sm_comentarios,
width:980,
autoHeight:true,
autoScroll:true,
stripeRows: true,
clicksToEdit: 'auto',
cls:'x-panel-blue',
frame:true,
title:'Comentarios',
iconCls:'icon-grid',
renderTo: document.body
}]
});
var form_misfact = new Ext.FormPanel({
xtype: 'form',
id: 'form-misfact-panel',
name: 'form_misfact',
labelWidth:120,
title: 'Mis Facturas',
bodyStyle:'padding:10px',
width: 1024,
labelPad: 10,
labelAlign: 'top',
frame:true,
resizable: true,
plain: true,
border: true,
autoScroll:true,
defaults: {
width: 300,
msgTarget: 'side'
},
items: [{
xtype:'grid',
id:'gridmisfact',
name:'gridmisfact',
ds:store_misfact,
cm:cm_misdocfact,
viewConfig: {
forceFit: true
},
bodyStyle:'padding:0px 0px 10px 0px',
selModel:sm_misdocfact,
width:940,
autoHeight:true,
autoScroll:true,
stripeRows: true,
clicksToEdit: 'auto',
tbar: [{
text: 'VER PDF',
iconCls:'pdf',
handler : function(){
var record = Ext.getCmp('gridmisfact').selModel.getSelected();
var doc = record.get('ALD_IdDoc');
window.open('generadores/ver_factcompra.php?keydoc='+doc);
}
},{
text: 'ELIMINAR',
iconCls:'drop',
handler : function(){
Ext.getCmp('gridmisfact').stopEditing();
var records = Ext.getCmp('gridmisfact').selModel.getSelected();
var estado = records.get('ALD_Status');
if(Ext.getCmp('gridmisfact').selModel.getCount() > 0 && estado == 1 )
{
Ext.MessageBox.confirm('Mensaje','¿Seguro que desea eliminar el documento?',
function(btn) {
if(btn=='yes'){
//todo: por cada seleccionado
var record = Ext.getCmp('gridmisfact').selModel.getSelected();
var data = record.get('ALD_IdDoc');
Ext.getCmp('gridmisfact').getStore().remove(record);
}
}
);
}
else
{
if(estado != 1){
Ext.MessageBox.alert('Mensaje','DOCUMENTO YA POSEE ESTADO');
}
else{
Ext.MessageBox.alert('Mensaje','POR FAVOR SELECCIONE UN DOCUMENTO');
}
}
}
}],
bbar:pagmisfact,
cls:'x-panel-blue',
frame:true,
title:'Facturas',
iconCls:'icon-grid',
renderTo: document.body
},{
xtype:'grid',
id:'gridmiscomentariosfact',
name:'gridmiscomentariosfact',
ds:store_miscomentariosfact,
cm:cm_miscomentarios,
viewConfig: {
forceFit: true
},
bodyStyle:'padding:0px 0px 10px 0px',
selModel:sm_miscomentarios,
width:940,
autoHeight:true,
autoScroll:true,
stripeRows: true,
clicksToEdit: 'auto',
cls:'x-panel-blue',
title:'Comentarios',
frame:true,
iconCls:'icon-grid',
renderTo: document.body
}]
});
//CAMPOS OCULTOS
//FORMULARIO DETALLE DOC
Ext.getCmp('grid').hide();
Ext.getCmp('totalgasto').hide();
Ext.getCmp('gridfact').hide();
// FIN DETALLE DOC
//DOCUMENTOS GASTOS
Ext.getCmp('griddocgastos').getColumnModel().setHidden(2, true);
Ext.getCmp('griddocgastos').getColumnModel().setHidden(6, true);
//FIN DOCUMENTOS GASTOS
//DOCUMENTOS MIS GASTOS
Ext.getCmp('gridmisdoc').getColumnModel().setHidden(2, true);
Ext.getCmp('gridmisdoc').getColumnModel().setHidden(6, true);
//FIN DOCUMENTOS MIS GASTOS
//DETALLE FACTURA
Ext.getCmp('gridfact').getColumnModel().setHidden(0, true);
//FIN DETALLE FACTURA
//Mis Factura
Ext.getCmp('gridmisfact').getColumnModel().setHidden(4, true);
//FIN Mis Factura
//COMENTARIOS DOC
Ext.getCmp('gridcomentarios').getColumnModel().setHidden(0, true);
Ext.getCmp('gridcomentarios').getColumnModel().setHidden(1, true);
//COMENTARIOS DOC
//COMENTARIOS MIS DOC
Ext.getCmp('gridmiscomentarios').getColumnModel().setHidden(0, true);
Ext.getCmp('gridmiscomentarios').getColumnModel().setHidden(1, true);
//COMENTARIOS MIS DOC
//PROVEDORES
Ext.getCmp('gridproveedores').getColumnModel().setHidden(0, true);
//PROVEEDORES
//COMENTARIOS PROVEDORES
Ext.getCmp('gridcomproveedores').getColumnModel().setHidden(0, true);
Ext.getCmp('gridcomproveedores').getColumnModel().setHidden(1, true);
//COMENTARIOS PROVEEDORES
//DETALLE
Ext.getCmp('grid').getColumnModel().setHidden(0, true);//iddoc
//FIN DETALLE
//FIN CAMPOS OCULTOS
//EVENTOS
// ELIMINA DOCUMENTO,DETALLE y COMENTARIOS MIS FACTURAS
store_misfact.on("remove", function (ds,record,index)
{
var idremove = record.get("ALD_IdDoc");
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_TextDocs where ALTD_IdDoc="+idremove //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DetDocs where ALDD_IdDoc="+idremove //pass to server same 'id' that the reader used
},//end params
success: function(){
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DOCS where ALD_IdDoc="+idremove //pass to server same 'id' that the reader used
},//end params
success: function(){
store_misfact.reload();
},
failure: function(){
//FALLA ELIMINAR DOCUMENTO
}
}//end ajax request config
); //end ajax reques
},
failure: function(){
//FALLA BORRA DETALLE
}
}//end ajax request config
); //end ajax reques
},
failure: function () { // when saving data failed
//FALLA BORRAR COMENTARIOS
}
}//end ajax request config
); //end ajax reques
});
//FIN ELIMINA DOCUMENTOS GASTOS Y DETALLE
//ELIMINA DOCUMENTO GASTOS Y DETALLE
store_listadoc.on("remove", function (ds,record,index)
{
var idremove = record.get("ALD_IdDoc");
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_TextDocs where ALTD_IdDoc="+idremove //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DetDocs where ALDD_IdDoc="+idremove //pass to server same 'id' that the reader used
},//end params
success: function(){
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DOCS where ALD_IdDoc="+idremove //pass to server same 'id' that the reader used
},//end params
success: function(){
store_listadoc.reload();
},
failure: function(){
//FALLA ELIMINAR DOCUMENTO
}
}//end ajax request config
); //end ajax reques
},
failure: function(){
//FALLA BORRA DETALLE
}
}//end ajax request config
); //end ajax reques
},
failure: function () { // when saving data failed
//FALLA BORRAR COMENTARIOS
}
}//end ajax request config
); //end ajax reques
});
//FIN ELIMINA DOCUMENTOS GASTOS Y DETALLE
//ELIMINA PROVEEDOR Y COMENTARIOS
store_proveedores.on("remove", function (ds,record,index)
{
var id_proveedor = record.get("Id_Proveedor");
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "deleteproveedor", //pass task to do to the server script
sql: id_proveedor//pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "deletedproveedor", //pass task to do to the server script
sql: id_proveedor
}//end params
}//end ajax request config
); //end ajax reques
store_comproveedores.reload();
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No ELIMINA PROVEEDOR');
}
}//end ajax request config
); //end ajax reques
});
//FIN ELIMINA PROVEEDOR Y COMENTARIOS
//ELIMINA DOCUMENTO GASTOS Y DETALLE
store_misdoc.on("remove", function (ds,record,index)
{
var idremove = record.get("ALD_IdDoc");
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_TextDocs where ALTD_IdDoc="+idremove //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
//INICIO DOCUMENTO GASTO
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DOCS where ALD_IdDoc="+idremove //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
if (vergasto) {
keydoc = Ext.getCmp('idgasto').getValue();
}
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DetDocs where ALDD_IdDoc="+idremove //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
Ext.MessageBox.alert ('Mensaje','Gasto Eliminado');
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No Se Borro el Gasto');
}
}); //end ajax reques
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No Se Borro el Gasto');
}
}//end ajax request config
); //end ajax reques
//FIN DOCUMENTO GASTOS
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No Se Borro el Gasto');
}}//end ajax request config
); //end ajax reques
});
//FIN ELIMINA DOCUMENTOS GASTOS Y DETALLE
//ADD DETALLE RENDICION DE GASTOS
store2.on("add", function (ds,records,index){
Ext.getCmp('grid').stopEditing();
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "insert", //pass task to do to the server script
sql: "INSERT INTO AL_DetDocs (ALDD_IdDoc,ALDD_Line) VALUES ("+Ext.getCmp('idgasto').getValue()+","+i+")"
},//end params
success: function () { // When saving data success
Ext.Ajax.request({
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "update", //pass task to do to the server script
sql: "ALDD_BCENTER"+"|"+bcenterid+"|"+i+"|"+Ext.getCmp('idgasto').getValue() //pass to server same 'id' that the reader used
},
success: function() {
Ext.Ajax.request({
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "updateidate", //pass task to do to the server script
sql: "ALDD_Date"+"|"+hoy()+"|"+i+"|"+Ext.getCmp('idgasto').getValue() //pass to server same 'id' that the reader used
},
success: function() {//end params
store2.baseParams = {oper:"query",sql:"select * from AL_DetDocs where ALDD_IdDoc="+Ext.getCmp('idgasto').getValue()};
store2.reload();
i++;
/*POSIBLE ARREGLO RENDICION BUG*/
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "updatetotal", //pass task to do to the server script
sql:keydoc //pass to server same 'id' that the reader used
},//end params
//AJAX SUBMIT
success: function (response, request) { // When saving data success
var numero = Ext.util.JSON.decode(response.responseText);
total = numero.total;
Ext.getCmp('totalgasto').setValue(total);
},
failure: function () {
//SI FALLA EL UPDATE DE TOTAL CUANDO AGREGO
}
// FIN AJAX SUBMIT
});//end ajax request config
},
failure: function() {
//FALLA UPDATE FECHA
}
});//end ajax request config
},
failure: function() {
//FALLA UPDATE FECHA
}
});
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No inserta');
}
}//end ajax request config
); //end ajax reques
});
//FIN ADD DETALLE RENDICION DE GASTOS
//ADD DETALLE FACTURA
store_fact.on("add", function (ds,records,index){
Ext.getCmp('gridfact').stopEditing();
var idadd = Ext.getCmp('idfactura').getValue();
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "insert", //pass task to do to the server script
sql: "INSERT INTO AL_DetDocs (ALDD_IdDoc,ALDD_Line) VALUES ("+idadd+","+(ifact)+")"
},//end params
success: function () { // When saving data success
store_fact.baseParams = {oper:"query",sql:"select * from AL_DetDocs where ALDD_IdDoc="+Ext.getCmp('idfactura').getValue()};
store_fact.reload();
ifact++;
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No inserta');
}
}//end ajax request config
); //end ajax reques
Ext.getCmp('grid').startEditing(0, 0);
});
//FIN ADD FACTURA
//REMOVER LINEA DETALLE
store2.on("remove", function (ds,record,index){
Ext.getCmp('grid').stopEditing();
var iddoc = record.get("ALDD_IdDoc");
var idline = record.get("ALDD_Line");
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DetDocs where ALDD_Line="+idline+" AND ALDD_IdDoc="+iddoc//pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "updatetotal", //pass task to do to the server script
sql:keydoc //pass to server same 'id' that the reader used
},//end params
//AJAX SUBMIT
success: function (response, request) { // When saving data success
var numero = Ext.util.JSON.decode(response.responseText);
total = numero.total;
Ext.getCmp('totalgasto').setValue(total);
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No se pudo eliminar el detalle');
}
// FIN AJAX SUBMIT
});//end ajax request config
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No se pudo eliminar el detalle');
}
}//end ajax request config
); //end ajax request
Ext.getCmp('grid').startEditing(0, 0);
});
//FIN LINEA DETALLE
//REMOVER LINEA DETALLE FACTURA
store_fact.on("remove", function (ds,record,index){
var iddoc = record.get("ALDD_IdDoc");
var idline = record.get("ALDD_Line");
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "delete", //pass task to do to the server script
sql: "delete from AL_DetDocs where ALDD_Line="+idline+" AND ALDD_IdDoc="+iddoc//pass to server same 'id' that the reader used
}//end params
}//end ajax request config
); //end ajax request
});
//FIN LINEA DETALLE FACTURA
//CUANDO EN LA FACTURA SELECCIONA EL COMBO DE CUENTA PARA ASIGNAR VALORES A SUBCUENTA
Ext.getCmp('cuentagastosfact').on('select',function(cmb,record,index){
Ext.getCmp('cuentasubgastosfact').clearValue();
store_subitems.baseParams = {oper:"query",sql:"select * from AL_nSItems where ALSI_Items="+Ext.getCmp('cuentagastosfact').getValue()};
store_subitems.load();
},this);
//FIN COMBO FACTURAS DE CUENTA
//SELECCIONADOR DE COMBOS
//CUANDO SELECCIONA EL TIPO DE FACTRA PARA DEJAR DISABLES ALGUNOS CAMPOS
Ext.getCmp('tipofact').on('select',function(cmb,record,index){
//QUE PASA EN CASO DE QUE SE SELECCIONE UN TIPO DE FACTURA
switch(Ext.getCmp('tipofact').getValue())
{
case 1:
Ext.getCmp('factneto').reset();
Ext.getCmp('facthonordesc').reset();
Ext.getCmp('factiva').reset();
Ext.getCmp('facttotal').reset();
Ext.getCmp('factexento').reset();
Ext.getCmp('factneto').enable(true); //neto
Ext.getCmp('factiva').enable(true); //iva
Ext.getCmp('facttotal').enable(true); //iva
Ext.getCmp('factexento').enable(true);
Ext.getCmp('facthonordesc').disable(true);
break;
case 2:
Ext.getCmp('factneto').reset();
Ext.getCmp('factiva').reset();
Ext.getCmp('facthonordesc').reset();
Ext.getCmp('facttotal').reset();
Ext.getCmp('factexento').reset();
Ext.getCmp('factneto').disable(true); //neto
Ext.getCmp('factiva').disable(true); //iva
Ext.getCmp('factexento').enable(true);
Ext.getCmp('facttotal').enable(true); //iva
Ext.getCmp('facthonordesc').disable(true);
break;
case 4:
Ext.getCmp('factneto').reset();
Ext.getCmp('factiva').reset();
Ext.getCmp('facttotal').reset();
Ext.getCmp('facthonordesc').reset();
Ext.getCmp('factexento').reset();
Ext.getCmp('factneto').enable(true); //neto
Ext.getCmp('factiva').disable(true); //iva
Ext.getCmp('facthonordesc').enable(true);
Ext.getCmp('facttotal').enable(true);
Ext.getCmp('factexento').disable(true);
break;
}
},this);
//FIN SELECCION TIPO FACTURA DISABLE BOTONES
//UPDATE GRID DETALLE
Ext.getCmp('grid').addListener('afteredit', function (e){
Ext.getCmp('grid').stopEditing();
var field=e.field;
var valor;
switch(field){
case "ALDD_Date":
valor = e.record.data.ALDD_Date;
break;
case "ALDD_Type":
valor = e.record.data.ALDD_Type;
break;
case "ALDD_Number":
valor = e.record.data.ALDD_Number;
break;
case "ALDD_Param1":
valor = e.record.data.ALDD_Param1;
break;
case "ALDD_ACCOUNT":
valor = e.record.data.ALDD_ACCOUNT;
break;
case "ALDD_SACCOUNT":
valor = e.record.data.ALDD_SACCOUNT;
break;
case "ALDD_Text":
valor = e.record.data.ALDD_Text;
break;
case "ALDD_Total":
valor = e.record.data.ALDD_Total;
break;
case "ALDD_BCENTER":
valor = e.record.data.ALDD_BCENTER;
break;
default:
break;
}
idline = e.record.data.ALDD_Line;
if (vergasto) {
iddoc = Ext.getCmp('idgasto').getValue();
}
else {
iddoc = e.record.data.ALDD_IdDoc;
}
if(field == "ALDD_Date"){
Ext.Ajax.request(
//ERROR FECHA EXPLORER
//CREAR FUNCION PARA LA feCHA EN EL UPDATE DEL GRID!
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "updateidate", //pass task to do to the server script
sql: field+"|"+fecha(valor)+"|"+idline+"|"+iddoc //pass to server same 'id' that the reader used
}//end params
});//end ajax request config
}
else if(field == "ALDD_Total"){
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "update", //pass task to do to the server script
sql: field+"|"+valor+"|"+idline+"|"+iddoc //pass to server same 'id' that the reader used
},
success: function () { // When saving data success
if (vergasto) {
keydoc = Ext.getCmp('idgasto').getValue();
}
Ext.Ajax.request({
url: 'ws_datos.php',
params: {
oper: "updatetotal",sql:keydoc },
success: function (response, request) {
var numero = Ext.util.JSON.decode(response.responseText);
total = numero.total;
Ext.getCmp('totalgasto').setValue(total);
},
failure: function () {
Ext.MessageBox.alert ('Mensaje','No se puede crear el Documento');
}
});
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No se puede crear el Documento');
}//end params
});//end ajax request config
}
else{
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "update", //pass task to do to the server script
sql: field+"|"+valor+"|"+idline+"|"+iddoc //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
if(field == "ALDD_ACCOUNT"){
var idcuenta = Ext.getCmp('al_account').getValue();
store_subitems.baseParams = {oper:"query",sql:"select * from AL_nSItems where ALSI_Items="+idcuenta};
store_subitems.load();
}
},
failure: function () { // when saving data failed
}
});//end ajax request config
}
Ext.getCmp('grid').startEditing(0, 0);
});
//FIN UPDATE GRID DETALLE
//UPDATE FACTURA DETALLE fact
Ext.getCmp('gridfact').addListener('afteredit',function (e){
var field=e.field;
var valor;
switch(field){
case "ALDD_Date":
valor = e.record.data.ALDD_Date;
break;
case "ALDD_Type":
valor = e.record.data.ALDD_Type;
break;
case "ALDD_Number":
valor = e.record.data.ALDD_Number;
break;
case "ALDD_Param1":
valor = e.record.data.ALDD_Param1;
break;
case "ALDD_ACCOUNT":
valor = e.record.data.ALDD_ACCOUNT;
break;
case "ALDD_SACCOUNT":
valor = e.record.data.ALDD_SACCOUNT;
break;
case "ALDD_Text":
valor = e.record.data.ALDD_Text;
break;
case "ALDD_Total":
valor = e.record.data.ALDD_Total;
break;
case "ALDD_BCENTER":
valor = e.record.data.ALDD_BCENTER;
break;
default:
break;
}
idline = e.record.data.ALDD_Line;
iddoc = e.record.data.ALDD_IdDoc;
if(field == "ALDD_Total"){
if (verfactura) {
iddoc = Ext.getCmp('idfactura').getValue();
}
Ext.Ajax.request({ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "update", //pass task to do to the server script
sql: field+"|"+valor+"|"+idline+"|"+iddoc //pass to server same 'id' that the reader used
}//end params
});//end ajax request config
}
else{
if (verfactura) {
iddoc = Ext.getCmp('idfactura').getValue();
}
Ext.Ajax.request(
{ //ajax request configuration
url: 'ws_datos.php', //url to server side script
params: { //these will be available via $_POST or $_REQUEST:
oper: "update", //pass task to do to the server script
sql: field+"|"+valor+"|"+idline+"|"+iddoc //pass to server same 'id' that the reader used
},//end params
success: function () { // When saving data success
if(field == "ALDD_ACCOUNT"){
var idcuenta = Ext.getCmp('al_accountfact').getValue();
store_subitemsfact.baseParams = {oper:"query",sql:"select * from AL_nSItems where ALSI_Items="+idcuenta};
store_subitemsfact.load();
}
},
failure: function () {}
});//end ajax request config
}
});
//FIN UPDATE GRID DETALLE facr
//UN CLICK LISTA DOC
Ext.getCmp('griddocgastos').on('rowclick',function( grid, row, evt) {
var record = Ext.getCmp('griddocgastos').selModel.getSelected();
var iddoc = record.get("ALD_IdDoc");
store_comentarios.baseParams = {oper:"query",sql:"select * from AL_TextDocs where ALTD_IdDoc="+iddoc };
store_comentarios.reload();
});
//FIN UN CLICK LISTA DOC
//UN CLICK LISTA DOC
Ext.getCmp('griddocfact').on('rowclick',function( grid, row, evt) {
var record = Ext.getCmp('griddocfact').selModel.getSelected();
var iddoc = record.get("ALD_IdDoc");
store_comentariosfact.baseParams = {oper:"query",sql:"select * from AL_TextDocs where ALTD_IdDoc="+iddoc };
store_comentariosfact.reload();
});
//FIN UN CLICK LISTA DOC
//UN CLICK DETALLE GASTO
Ext.getCmp('grid').on('rowclick',function( grid, row, evt) {
var record = Ext.getCmp('grid').selModel.getSelected();
var subaccount = record.get("ALDD_ACCOUNT");
if(subaccount != ""){
store_subitems.baseParams = {oper:"query",sql:"select * from AL_nSItems where AL_SItems="+subaccount};
store_subitems.reload();
}
});
//FIN UN CLICK DETALLE GASTO
//UN CLICK DETALLE factura
Ext.getCmp('gridfact').on('rowclick',function( grid, row, evt) {
var record = Ext.getCmp('gridfact').selModel.getSelected();
var subaccount = record.get("ALDD_ACCOUNT");
if(subaccount != ""){
store_subitemsfact.baseParams = {oper:"query",sql:"select * from AL_nSItems where ALSI_Items="+subaccount};
store_subitemsfact.reload();
}
});
//FIN UN CLICK DETALLE factura
//UN CLICK LISTA MIS DOC
Ext.getCmp('gridmisdoc').on('rowclick',function( grid, row, evt) {
var record = Ext.getCmp('gridmisdoc').selModel.getSelected();
var iddoc = record.get("ALD_IdDoc");
store_miscomentarios.baseParams = {oper:"query",sql:"select * from AL_TextDocs where ALTD_IdDoc="+iddoc};
store_miscomentarios.reload();
});
//FIN UN CLICK LISTA MIS DOC
//UN CLICK LISTA MIS FACT
Ext.getCmp('gridmisfact').on('rowclick',function( grid, row, evt) {
var record = Ext.getCmp('gridmisfact').selModel.getSelected();
var iddoc = record.get("ALD_IdDoc");
store_miscomentariosfact.baseParams = {oper:"query",sql:"select * from AL_TextDocs where ALTD_IdDoc="+iddoc};
store_miscomentariosfact.reload();
});
//FIN UN CLICK LISTA MIS FACT
//UN DOBLE CLICK RESUMEN PROVEEDORES
Ext.getCmp('gridrproveedores').on('rowdblclick',function( grid, row, evt) {
var record = Ext.getCmp('gridrproveedores').selModel.getSelected();
var idfact = record.get("ALD_IdDoc");
Ext.Ajax.request({
url: 'ws_datos.php',
params: {oper: "queryfactaccess",id:idfact},
success: function(response, request){
Ext.getCmp('tree-panel').getNodeById('facturacompra').expand();
store_listafact.baseParams = {oper:"queryfactrprove",id:idfact};
store_listafact.load({params:{start:0, limit:15}});
var node = Ext.getCmp('tree-panel').getNodeById('form-revisionfact');
node.select();
node.fireEvent('click',node);
Ext.getCmp('content-panel').layout.setActiveItem('form-revisionfact-panel');
store_listafact.baseParams = {oper:"querychkfacturas"};
},
failure: function (response, request){
var data = Ext.util.JSON.decode(response.responseText);
var error = data.error;
Ext.MessageBox.alert ('Mensaje',error);
}
});
});
//FIN DOBLE CLICK ResuMEN PROVEEdOreS
//UN CLICK PROVEEDORES
Ext.getCmp('gridproveedores').on('rowclick',function( grid, row, evt) {
Ext.getCmp('form-proveedor-panel').getForm().reset();
store_tipoproveedor.load();
var record = Ext.getCmp('gridproveedores').selModel.getSelected();
var id_proveedor = record.get("Id_Proveedor");
var rutproveedor = record.get("Rut");
var rs = record.get("RazonSocial");
var direccion = record.get("Direccion");
var telefono = record.get("Telefono");
var giro = record.get("Giro");
var banco = record.get("Banco");
var cbanco = record.get("CuentaBanco");
var email = record.get("Email");
var contacto = record.get("Contacto");
var tipo = record.get("tipo");
Ext.getCmp('proveedor').setValue(id_proveedor);
Ext.getCmp('rutproevedor').setValue(rutproveedor);
Ext.getCmp('rutproevedor').disable(true);
Ext.getCmp('rsproveedor').setValue(rs);
Ext.getCmp('direproveedor').setValue(direccion);
Ext.getCmp('fonoproveedor').setValue(telefono);
Ext.getCmp('giroproveedor').setValue(giro);
Ext.getCmp('banco').setValue(banco);
Ext.getCmp('cuentabanco').setValue(cbanco);
Ext.getCmp('email').setValue(email);
Ext.getCmp('contacto').setValue(contacto);
if(tipo != '0'){
Ext.getCmp('tipoproveedor').setValue(tipo);
}
store_comproveedores.baseParams = {oper:"querycomproveedores",sql:id_proveedor};
store_comproveedores.load();
store_rproveedores.baseParams = {oper:"rproveedores",sql:rutproveedor};
store_rproveedores.load({params:{start:0, limit:7}});
});
//FIN UN CLICK PROVEEDORES
//DOBLE CLICK LISTA DOC
Ext.getCmp('griddocgastos').on('rowdblclick',function( grid, row, evt) {
var record = Ext.getCmp('griddocgastos').selModel.getSelected();
var iddoc = record.get("ALD_IdDoc");
win = new Ext.Window({
layout:'fit',
width:340,
height:400,
closable: false,
resizable: false,
plain: true,
border: true,
modal: true,
items: [{
xtype:'form',
id:'form_status',
name:'form_status',
labelWidth: 75, // label settings here cascade unless overridden
url:'crea_status.php?keydoc='+iddoc+'&usuario='+username, // when this form submitted, data goes here
method:'POST',
frame:true,
title: 'STATUS RENDICION DE GASTOS',
bodyStyle:'padding:5px 5px 0',
width: 1024,
height:280,
defaults: {width: 300},
labelAlign: 'top',
plain: true,
border: true,
items:[{
xtype: 'combo',
name: 'combostatus',
id: 'combostatus',
hiddenName:'IdTipoStatus',
displayField:'Descripcion',
valueField:'IdTipoStatus',
fieldLabel: 'STATUS DOCUMENTO',
store:store_tipostatus,
typeAhead: true,
mode: 'local',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE STATUS...',
selectOnFocus:true
},{
xtype:'combo',
id:'encargado_rev',
listWidth : 300,
hiddenName: 'IdEmpleado',
store:store_usuarios,
displayField:'Nombre',
valueField:'IdEmpleado',
typeAhead: true,
mode: 'remote',
forceSelection: true,
triggerAction: 'all',
emptyText:'SELECCIONE ENCARGADO...',
selectOnFocus:true,
fieldLabel: 'CAMBIAR RESPONSABLE(OPCIONAL)'
},{
xtype:'textarea',
fieldLabel: 'COMENTARIOS',
id:'textstatus',
name: 'textstatus',
height:180
}]
}],
buttons: [{
text: 'Enviar',
handler: function () {
// when this button clicked, sumbit this form
Ext.getCmp('form_status').getForm().submit({
waitMsg: 'Saving...', // Wait Message
success: function () { // When saving data success
Ext.getCmp('form_status').getForm().reset();
store_listadoc.reload();
store_comentarios.load();
win.close();
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No se puede crear el Documento');
}
});
}
},{
text: 'Cerrar',
handler: function(){
win.close();
}
}]
});
win.show();
});
//FIN DOBLE CLICK LISTA DOC
//DOBLE CLICK LISTA DOC
Ext.getCmp('griddocfact').on('rowdblclick',function( grid, row, evt) {
var record = Ext.getCmp('griddocfact').selModel.getSelected();
var iddoc = record.get("ALD_IdDoc");
//store_tipostatus.baseParams= {oper:"query",sql:"select * from AL_DetDocs where ALDD_IdDoc="+keydoc_fact};
winfact = new Ext.Window({
layout:'fit',
width:340,
height:400,
closable: false,
resizable: false,
plain: true,
border: true,
modal: true,
items: [{
xtype:'form',
id:'form_statusfact',
name:'form_statusfact',
labelWidth: 75, // label settings here cascade unless overridden
url:'crea_statusfact.php?keydoc='+iddoc+'&usuario='+username, // when this form submitted, data goes here
method:'POST',
frame:true,
title: 'STATUS FACTURA COMPRA',
bodyStyle:'padding:5px 5px 0',
width: 1024,
height:280,
defaults: {width: 300},
labelAlign: 'top',
plain: true,
border: true,
items:[{
xtype: 'combo',
name: 'combostatusfact',
id: 'combostatusfact',
hiddenName: 'IdEstadoFactura',
displayField:'Estado',
valueField:'IdEstadoFactura',
fieldLabel: 'STATUS DOCUMENTO',
store:store_tipostatusfact,
typeAhead: true,
mode: 'local',
triggerAction: 'all',
emptyText:'SELECCIONE STATUS...',
selectOnFocus:true
},{
xtype:'combo',
id:'encargado_revfact',
listWidth : 300,
hiddenName: 'IdEmpleado',
store:store_usuarios,
displayField:'Nombre',
valueField:'IdEmpleado',
typeAhead: true,
mode: 'remote',
triggerAction: 'all',
emptyText:'SELECCIONE ENCARGADO...',
selectOnFocus:true,
fieldLabel: 'CAMBIAR RESPONSABLE(OPCIONAL)'
},{
xtype:'textarea',
fieldLabel: 'COMENTARIOS',
id:'textstatusfact',
name: 'textstatusfact',
height:180
}]
}],
buttons: [{
text: 'Enviar',
handler: function () {
// when this button clicked, sumbit this form
Ext.getCmp('form_statusfact').getForm().submit({
waitMsg: 'Saving...', // Wait Message
success: function () { // When saving data success
Ext.getCmp('form_statusfact').getForm().reset();
store_listafact.reload();
store_comentariosfact.load();
winfact.close();
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No se puede crear el Documento');
}
});
}
},{
text: 'Cerrar',
handler: function(){
winfact.close();
}
}]
});
winfact.show();
});
//FIN DOBLE CLICK LISTA DOC
Ext.getCmp('cuentagastosfact').on('rowdblclick',function( grid, row, evt) {
});
//DOBLE CLICK PROVEEDORES
Ext.getCmp('gridproveedores').on('rowdblclick',function( grid, row, evt) {
var record = Ext.getCmp('gridproveedores').selModel.getSelected();
var idproveedor = record.get("Id_Proveedor");
wincomproveedores = new Ext.Window({
layout:'fit',
width:340,
height:320,
closable: false,
resizable: false,
plain: true,
border: true,
modal: true,
items: [{
xtype:'form',
id:'form_winproveedores',
name:'form_winproveedores',
labelWidth: 75,
url:'crea_comproveedor.php?idproveedor='+idproveedor+'&usuario='+username, // when this form submitted, data goes here
method:'POST',
frame:true,
title: 'COMETARIOS PROVEEDOR',
bodyStyle:'padding:5px 5px 0',
width: 1024,
height:200,
defaults: {width: 300},
labelAlign: 'top',
plain: true,
border: true,
items:[{
xtype:'textarea',
fieldLabel: 'COMENTARIOS',
id:'textcomproveedor',
name: 'textcomproveedor',
height:180
}]
}],
buttons: [{
text: 'Enviar',
handler: function () {
// when this button clicked, sumbit this form
Ext.getCmp('form_winproveedores').getForm().submit({
waitMsg: 'Guardando...', // Wait Message
success: function () { // When saving data success
Ext.getCmp('form_winproveedores').getForm().reset();
store_comproveedores.load();
wincomproveedores.close();
},
failure: function () { // when saving data failed
Ext.MessageBox.alert ('Mensaje','No se puede crear el comentario');
}
});
}
},{
text: 'Cerrar',
handler: function(){
wincomproveedores.close();
}
}]
});
wincomproveedores.show();
});
//FIN DOBLE CLICK PROVEEDORES
Thanks