empresa-libre/source/static/js/controller/main.js

231 lines
6.1 KiB
JavaScript
Raw Normal View History

2017-10-10 18:49:05 -05:00
var gi = null
2017-06-27 15:43:02 -05:00
2017-11-22 00:46:23 -06:00
function configuracion_inicial(){
webix.ajax().get('/values/admin', function(text, data){
var values = data.json()
show('cmd_ir_al_admin', values)
2017-11-22 00:46:23 -06:00
})
webix.ajax().sync().get('/values/main', function(text, data){
2017-11-26 23:40:14 -06:00
var values = data.json()
$$('lbl_title_main').setValue(values.empresa)
2018-01-29 01:55:42 -06:00
var pos = 4
if(values.escuela){
var node = {
id: 'app_school',
icon: 'graduation-cap',
value: 'Escuela'}
$$('main_sidebar').add(node, pos)
pos += 1
}
2018-01-15 23:49:33 -06:00
if(values.nomina){
var node = {
id: 'app_nomina',
icon: 'users',
value: 'Nómina'}
$$('main_sidebar').add(node, pos)
pos += 1
}
2017-12-04 22:09:22 -06:00
if(values.punto_de_venta){
var node = {
id: 'app_tickets',
icon: 'money',
value: 'Punto de venta'}
2018-01-29 01:55:42 -06:00
$$('main_sidebar').add(node, pos)
2017-12-04 22:09:22 -06:00
}
2018-02-13 23:12:21 -06:00
$$('cmd_update_timbres').define('badge', values.timbres)
$$('cmd_update_timbres').refresh()
2018-07-10 23:34:32 -05:00
add_config({'key': 'decimales_precios', 'value': values.decimales_precios})
add_config({'key': 'used_cfdi_pays', 'value': values.pagos})
add_config({'key': 'multi_currency', 'value': values.multi_currency})
2018-10-12 01:14:01 -05:00
add_config({'key': 'pays_data_bank', 'value': values.pays_data_bank})
2023-12-26 21:37:45 -06:00
add_config({'key': 'show_filter_by_day', 'value': values.show_filter_by_day})
2017-11-26 23:40:14 -06:00
})
2017-12-04 22:09:22 -06:00
2018-08-23 00:55:45 -05:00
get_way_payment()
2017-11-22 00:46:23 -06:00
}
function cmd_ir_al_admin_click(){
window.location = '/admin'
}
2017-06-27 15:43:02 -05:00
var controllers = {
init: function(){
//~ Main
2017-06-27 23:58:03 -05:00
$$('menu_user').attachEvent('onMenuItemClick', menu_user_click);
2017-11-22 00:46:23 -06:00
configuracion_inicial()
2017-11-05 00:13:48 -06:00
var tb_invoice = $$('tv_invoice').getTabbar()
tb_invoice.attachEvent('onChange', tb_invoice_change)
$$('prefilter_year').attachEvent('onChange', prefilter_year_change)
$$('prefilter_month').attachEvent('onChange', prefilter_month_change)
$$('cmd_delete_preinvoice').attachEvent('onItemClick', cmd_delete_preinvoice_click)
$$('cmd_facturar_preinvoice').attachEvent('onItemClick', cmd_facturar_preinvoice_click)
2018-02-13 23:12:21 -06:00
$$('cmd_update_timbres').attachEvent('onItemClick', cmd_update_timbres_click)
2017-11-05 19:53:27 -06:00
$$('grid_preinvoices').attachEvent('onItemClick', grid_preinvoices_click)
2017-11-16 01:17:22 -06:00
partners_controllers.init()
2017-12-23 23:54:47 -06:00
products_controllers.init()
2017-11-16 22:49:17 -06:00
bancos_controllers.init()
2017-12-29 04:09:02 -06:00
invoices_controllers.init()
2018-01-29 01:55:42 -06:00
controllers_school.init()
2018-01-15 23:49:33 -06:00
nomina_controllers.init()
2017-12-19 00:56:55 -06:00
tickets_controllers.init()
2017-06-27 15:43:02 -05:00
}
2017-10-05 12:16:20 -05:00
}
2017-06-27 15:43:02 -05:00
2017-10-04 00:11:49 -05:00
2017-11-12 21:56:45 -06:00
function get_uso_cfdi_to_table(){
webix.ajax().sync().get('/values/usocfdi', function(text, data){
2017-10-06 00:10:27 -05:00
var values = data.json()
table_usocfdi.clear()
table_usocfdi.insert(values)
})
}
2017-06-27 15:43:02 -05:00
function get_partners(){
2017-11-16 01:17:22 -06:00
webix.ajax().get('/partners', {}, {
2017-06-27 15:43:02 -05:00
error: function(text, data, xhr) {
2017-11-25 20:26:15 -06:00
msg_error('Error al consultar')
2017-06-27 15:43:02 -05:00
},
success: function(text, data, xhr) {
var values = data.json();
2017-11-16 01:17:22 -06:00
$$('grid_partners').clearAll();
if (values.data){
$$('grid_partners').parse(values.data, 'json');
2017-06-27 15:43:02 -05:00
};
}
2017-11-16 01:17:22 -06:00
})
2017-06-27 15:43:02 -05:00
}
2017-10-04 00:11:49 -05:00
2017-06-27 15:43:02 -05:00
function menu_user_click(id, e, node){
if (id == 1){
window.location = '/logout';
return
}
}
2017-10-28 00:30:42 -05:00
function current_dates(){
var fy = $$('filter_year')
var fm = $$('filter_month')
2023-12-26 21:37:45 -06:00
var fd = $$('filter_day')
2017-11-05 00:13:48 -06:00
var pfy = $$('prefilter_year')
var pfm = $$('prefilter_month')
2017-10-28 00:30:42 -05:00
var d = new Date()
fy.blockEvent()
fm.blockEvent()
2023-12-26 21:37:45 -06:00
fd.blockEvent()
2017-11-05 00:13:48 -06:00
pfy.blockEvent()
pfm.blockEvent()
2017-10-28 00:30:42 -05:00
fm.setValue(d.getMonth() + 1)
2023-12-26 21:37:45 -06:00
fd.setValue(d.getDate())
2017-11-05 00:13:48 -06:00
pfm.setValue(d.getMonth() + 1)
2017-10-28 00:30:42 -05:00
webix.ajax().sync().get('/values/filteryears', function(text, data){
var values = data.json()
2017-11-05 00:13:48 -06:00
fy.getList().parse(values[0])
pfy.getList().parse(values[1])
2017-10-28 00:30:42 -05:00
fy.setValue(d.getFullYear())
2017-11-05 00:13:48 -06:00
pfy.setValue(d.getFullYear())
2017-10-28 00:30:42 -05:00
})
fy.unblockEvent()
fm.unblockEvent()
2023-12-26 21:37:45 -06:00
fd.unblockEvent()
2017-11-05 00:13:48 -06:00
pfy.unblockEvent()
pfm.unblockEvent()
2017-10-28 00:30:42 -05:00
}
function multi_change(prevID, nextID){
2018-01-29 01:55:42 -06:00
if(nextID == 'app_partners'){
active = $$('multi_partners').getActiveId()
if(active == 'partners_home'){
get_partners()
}
2017-10-04 00:11:49 -05:00
return
}
2017-10-04 00:11:49 -05:00
if(nextID == 'app_products'){
active = $$('multi_products').getActiveId()
if(active == 'products_home'){
get_products()
}
return
}
2017-11-16 22:49:17 -06:00
if(nextID == 'app_bancos'){
active = $$('multi_bancos').getActiveId()
2017-11-21 00:48:51 -06:00
if(active == 'banco_home'){
2017-11-16 22:49:17 -06:00
get_cuentas_banco()
}
return
}
2018-01-29 01:55:42 -06:00
if(nextID == 'app_school'){
active = $$('multi_school').getActiveId()
if(active == 'school_home'){
init_config_school()
}
return
}
2018-01-15 23:49:33 -06:00
if(nextID == 'app_nomina'){
active = $$('multi_nomina').getActiveId()
if(active == 'nomina_home'){
default_config_nomina()
}
return
}
2017-12-04 22:09:22 -06:00
if(nextID == 'app_tickets'){
2017-12-21 01:13:28 -06:00
active = $$('multi_tickets').getActiveId()
if(active == 'tickets_home'){
configuracion_inicial_ticket()
}
2017-12-04 22:09:22 -06:00
return
}
2017-10-06 00:10:27 -05:00
if(nextID == 'app_invoices'){
active = $$('multi_invoices').getActiveId()
if(active == 'invoices_home'){
2017-10-28 00:30:42 -05:00
current_dates()
2017-10-06 00:10:27 -05:00
get_invoices()
2017-12-13 00:13:34 -06:00
validar_timbrar()
2017-10-06 00:10:27 -05:00
}
2017-10-10 18:49:05 -05:00
gi = $$('grid_invoices')
2017-10-06 00:10:27 -05:00
return
}
2017-10-04 00:11:49 -05:00
}
function get_taxes(){
webix.ajax().sync().get('/values/taxes', function(text, data){
var values = data.json()
table_taxes.clear()
table_taxes.insert(values)
$$("grid_product_taxes").clearAll()
$$("grid_product_taxes").parse(values, 'json')
})
}
2018-02-13 23:12:21 -06:00
function cmd_update_timbres_click(){
webix.ajax().get('/values/timbres', function(text, data){
var value = data.json()
$$('cmd_update_timbres').define('badge', value)
$$('cmd_update_timbres').refresh()
})
2018-07-10 23:34:32 -05:00
}