forked from elmau/empresa-libre
107 lines
2.8 KiB
JavaScript
107 lines
2.8 KiB
JavaScript
var msg = ''
|
|
|
|
var bancos_controllers = {
|
|
init: function(){
|
|
$$('lst_cuentas_banco').attachEvent('onChange', lst_cuentas_banco_change)
|
|
$$('cmd_agregar_retiro').attachEvent('onItemClick', cmd_agregar_retiro_click)
|
|
$$('cmd_agregar_deposito').attachEvent('onItemClick', cmd_agregar_deposito_click)
|
|
set_year_month()
|
|
}
|
|
}
|
|
|
|
|
|
function set_year_month(){
|
|
var d = new Date()
|
|
var y = $$('filtro_cuenta_year')
|
|
var m = $$('filtro_cuenta_mes')
|
|
|
|
webix.ajax().get('/values/cuentayears', {
|
|
error:function(text, data, XmlHttpRequest){
|
|
msg = 'Ocurrio un error, consulta a soporte técnico'
|
|
msg_error(msg)
|
|
},
|
|
success:function(text, data, XmlHttpRequest){
|
|
var values = data.json()
|
|
y.getList().parse(values)
|
|
y.blockEvent()
|
|
m.blockEvent()
|
|
y.setValue(d.getFullYear())
|
|
m.setValue(d.getMonth() + 1)
|
|
y.unblockEvent()
|
|
m.unblockEvent()
|
|
}
|
|
})
|
|
|
|
}
|
|
|
|
|
|
function get_cuentas_banco(){
|
|
var list = $$('lst_cuentas_banco')
|
|
|
|
webix.ajax().get('/cuentasbanco', {'tipo': 1}, {
|
|
error:function(text, data, XmlHttpRequest){
|
|
msg = 'Ocurrio un error, consulta a soporte técnico'
|
|
msg_error(msg)
|
|
},
|
|
success:function(text, data, XmlHttpRequest){
|
|
var values = data.json()
|
|
if(values.ok){
|
|
list.getList().parse(values.rows)
|
|
list.blockEvent()
|
|
list.setValue(values.rows[0].id)
|
|
list.unblockEvent()
|
|
$$('txt_cuenta_moneda').setValue(values.moneda)
|
|
$$('txt_cuenta_saldo').setValue(values.saldo)
|
|
get_estado_cuenta()
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
function get_estado_cuenta(rango){
|
|
if(rango == undefined){
|
|
var filtro = {
|
|
cuenta: $$('lst_cuentas_banco').getValue(),
|
|
year: $$('filtro_cuenta_year').getValue(),
|
|
mes: $$('filtro_cuenta_mes').getValue(),
|
|
}
|
|
}else{
|
|
var filtro = {
|
|
cuenta: $$('lst_cuentas_banco').getValue(),
|
|
fechas: rango,
|
|
}
|
|
}
|
|
|
|
var grid = $$('grid_cuentabanco')
|
|
|
|
webix.ajax().get('/movbanco', filtro, {
|
|
error:function(text, data, XmlHttpRequest){
|
|
msg = 'Ocurrio un error, consulta a soporte técnico'
|
|
msg_error(msg)
|
|
},
|
|
success:function(text, data, XmlHttpRequest){
|
|
var values = data.json()
|
|
grid.clearAll()
|
|
if (values.ok){
|
|
grid.parse(values.rows, 'json')
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
function lst_cuentas_banco_change(nv, ov){
|
|
show('Cuenta change')
|
|
}
|
|
|
|
|
|
function cmd_agregar_retiro_click(){
|
|
show('Retiro')
|
|
}
|
|
|
|
|
|
function cmd_agregar_deposito_click(){
|
|
show('Depósito')
|
|
}
|