forked from elmau/empresa-libre
114 lines
4.2 KiB
JavaScript
114 lines
4.2 KiB
JavaScript
|
|
|
|
var controllers = {
|
|
init: function(){
|
|
//~ Main
|
|
$$('menu_user').attachEvent('onMenuItemClick', menu_user_click);
|
|
//~ Partner
|
|
$$('cmd_new_partner').attachEvent('onItemClick', cmd_new_partner_click);
|
|
$$('cmd_new_contact').attachEvent('onItemClick', cmd_new_contact_click);
|
|
$$('cmd_edit_partner').attachEvent('onItemClick', cmd_edit_partner_click);
|
|
$$('cmd_delete_partner').attachEvent('onItemClick', cmd_delete_partner_click);
|
|
$$('cmd_save_partner').attachEvent('onItemClick', cmd_save_partner_click);
|
|
$$('cmd_cancel_partner').attachEvent('onItemClick', cmd_cancel_partner_click);
|
|
$$('cmd_cancel_contact').attachEvent('onItemClick', cmd_cancel_contact_click);
|
|
$$('codigo_postal').attachEvent('onKeyPress', postal_code_key_press);
|
|
$$('codigo_postal').attachEvent('onTimedKeyPress', postal_code_key_up);
|
|
$$('colonia').attachEvent('onFocus', colonia_on_focus)
|
|
$$("tipo_persona").attachEvent( "onChange", opt_tipo_change)
|
|
$$("es_cliente").attachEvent( "onChange", is_client_change)
|
|
$$("es_proveedor").attachEvent( "onChange", is_supplier_change)
|
|
$$("rfc").attachEvent( "onBlur", rfc_lost_focus)
|
|
$$('multi').attachEvent('onViewChange', multi_change)
|
|
//~ Products
|
|
$$("cmd_new_product").attachEvent("onItemClick", cmd_new_product_click);
|
|
$$("cmd_edit_product").attachEvent("onItemClick", cmd_edit_product_click);
|
|
$$("cmd_delete_product").attachEvent("onItemClick", cmd_delete_product_click);
|
|
$$("cmd_save_product").attachEvent("onItemClick", cmd_save_product_click);
|
|
$$("cmd_cancel_product").attachEvent("onItemClick", cmd_cancel_product_click);
|
|
$$("chk_automatica").attachEvent("onChange", chk_automatica_change)
|
|
$$("valor_unitario").attachEvent("onChange", valor_unitario_change)
|
|
//~ Invoices
|
|
$$("cmd_new_invoice").attachEvent("onItemClick", cmd_new_invoice_click)
|
|
$$("cmd_edit_invoice").attachEvent("onItemClick", cmd_edit_invoice_click)
|
|
$$("cmd_delete_invoice").attachEvent("onItemClick", cmd_delete_invoice_click)
|
|
$$('cmd_timbrar').attachEvent('onItemClick', cmd_timbrar_click)
|
|
$$('cmd_close_invoice').attachEvent('onItemClick', cmd_close_invoice_click)
|
|
$$('search_partner_id').attachEvent('onKeyPress', search_partner_id_key_press)
|
|
$$('grid_partners_found').attachEvent('onValueSuggest', grid_partners_found_click);
|
|
}
|
|
}
|
|
|
|
|
|
function get_partners(){
|
|
webix.ajax().get("/partners", {}, {
|
|
error: function(text, data, xhr) {
|
|
webix.message({ type:"error", text: "Error al consultar"});
|
|
},
|
|
success: function(text, data, xhr) {
|
|
var values = data.json();
|
|
$$("grid_partners").clearAll();
|
|
if (values.ok){
|
|
$$("grid_partners").parse(values.rows, 'json');
|
|
};
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
function get_products(){
|
|
var grid = $$('grid_products')
|
|
webix.ajax().get('/products', {}, {
|
|
error: function(text, data, xhr) {
|
|
webix.message({type: 'error', text: 'Error al consultar'})
|
|
},
|
|
success: function(text, data, xhr) {
|
|
var values = data.json();
|
|
grid.clearAll();
|
|
if (values.ok){
|
|
grid.parse(values.rows, 'json');
|
|
};
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
function menu_user_click(id, e, node){
|
|
if (id == 1){
|
|
window.location = '/logout';
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
function multi_change(prevID, nextID){
|
|
//~ webix.message(prevID)
|
|
if(nextID == 'app_partners'){
|
|
active = $$('multi_partners').getActiveId()
|
|
if(active == 'partners_home'){
|
|
get_partners()
|
|
}
|
|
return
|
|
}
|
|
|
|
if(nextID == 'app_products'){
|
|
active = $$('multi_products').getActiveId()
|
|
if(active == 'products_home'){
|
|
get_products()
|
|
}
|
|
return
|
|
}
|
|
|
|
}
|
|
|
|
|
|
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')
|
|
})
|
|
}
|