forked from elmau/empresa-libre
161 lines
3.9 KiB
JavaScript
161 lines
3.9 KiB
JavaScript
var query = []
|
|
var grid = null
|
|
|
|
|
|
function get_series(){
|
|
webix.ajax().get('/values/series', function(text, data){
|
|
var values = data.json()
|
|
table_series.clear()
|
|
table_series.insert(values)
|
|
pre = values[0]
|
|
$$('lst_serie').getList().parse(values)
|
|
$$('lst_serie').setValue(pre.id)
|
|
if(pre.usar_con){
|
|
$$('lst_tipo_comprobante').setValue(pre.usar_con)
|
|
$$('lst_tipo_comprobante').config.readonly = true
|
|
$$('lst_tipo_comprobante').refresh()
|
|
}
|
|
})
|
|
}
|
|
|
|
|
|
function get_forma_pago(){
|
|
webix.ajax().get('/values/formapago', function(text, data){
|
|
var values = data.json()
|
|
pre = values[0]
|
|
$$('lst_forma_pago').getList().parse(values)
|
|
$$('lst_forma_pago').setValue(pre.id)
|
|
})
|
|
}
|
|
|
|
|
|
function get_monedas(){
|
|
webix.ajax().get('/values/monedas', function(text, data){
|
|
var values = data.json()
|
|
pre = values[0]
|
|
$$('lst_moneda').getList().parse(values)
|
|
$$('lst_moneda').setValue(pre.id)
|
|
})
|
|
}
|
|
|
|
|
|
function get_uso_cfdi(){
|
|
webix.ajax().get('/values/usocfdi', function(text, data){
|
|
var values = data.json()
|
|
pre = values[0]
|
|
table_usocfdi.clear()
|
|
table_usocfdi.insert(values)
|
|
$$('lst_uso_cfdi').getList().parse(values)
|
|
$$('lst_uso_cfdi').setValue(pre.id)
|
|
})
|
|
}
|
|
|
|
|
|
function default_config(){
|
|
get_series()
|
|
get_forma_pago()
|
|
get_monedas()
|
|
get_uso_cfdi()
|
|
table_pt.clear()
|
|
table_totals.clear()
|
|
}
|
|
|
|
|
|
function cmd_new_invoice_click(id, e, node){
|
|
var form = $$('form_invoice')
|
|
var grid_totals = $$('grid_totals')
|
|
grid = $$('grid_details')
|
|
|
|
default_config()
|
|
form.adjust()
|
|
form.setValues({id: 0, id_partner: 0, lbl_partner: 'Ninguno'})
|
|
grid.clearAll()
|
|
grid_totals.clearAll()
|
|
grid_totals.add({id: 1, concepto: 'SubTotal', importe: 0})
|
|
$$('multi_invoices').setValue('invoices_new')
|
|
form.focus('search_partner_id')
|
|
}
|
|
|
|
|
|
function cmd_edit_invoice_click(id, e, node){
|
|
|
|
$$("multi_invoices").setValue("invoices_new")
|
|
|
|
};
|
|
|
|
|
|
function cmd_delete_invoice_click(id, e, node){
|
|
|
|
webix.message({type:"success", text: "OK Delete"});
|
|
|
|
};
|
|
|
|
|
|
function cmd_timbrar_click(id, e, node){
|
|
var form = this.getFormView()
|
|
|
|
if (!form.validate()) {
|
|
webix.message({type: 'error', text: 'Valores inválidos'})
|
|
return
|
|
}
|
|
|
|
$$('form_invoice').clear();
|
|
$$('multi_invoices').setValue('invoices_home')
|
|
webix.message({type:"success", text: "Factura guardada correctamente"})
|
|
}
|
|
|
|
|
|
function cmd_close_invoice_click(id, e, node){
|
|
$$('multi_invoices').setValue('invoices_home')
|
|
}
|
|
|
|
|
|
function search_partner_by_id(id){
|
|
var msg = ''
|
|
webix.ajax().get('/values/partner', {'id': id}, {
|
|
error: function(text, data, xhr) {
|
|
webix.message({type: 'error', text: 'Error al consultar'})
|
|
},
|
|
success: function(text, data, xhr){
|
|
var values = data.json()
|
|
if (values.ok){
|
|
set_partner(values.row)
|
|
}else{
|
|
msg = 'No se encontró un cliente con la clave: ' + id
|
|
webix.message({type:'error', text: msg})
|
|
}
|
|
}
|
|
})
|
|
|
|
}
|
|
|
|
|
|
function set_partner(row){
|
|
var form = $$('form_invoice')
|
|
var html = '<span class="webix_icon fa-user"></span><span class="lbl_partner">'
|
|
|
|
form.setValues({
|
|
id_partner:row.id, search_partner_id:'', search_partner_name:''}, true)
|
|
html += row.nombre + ' (' + row.rfc + ')</span>'
|
|
$$('lbl_partner').setValue(html)
|
|
form.focus('search_product_id')
|
|
}
|
|
|
|
|
|
function grid_partners_found_click(obj){
|
|
set_partner(obj)
|
|
}
|
|
|
|
|
|
function search_partner_id_key_press(code, e){
|
|
var value = this.getValue()
|
|
if(code == 13 && value.length > 0){
|
|
var id = parseInt(value, 10)
|
|
if (isNaN(id)){
|
|
webix.message({type:'error', text:'Captura una clave válida'});
|
|
}else{
|
|
search_partner_by_id(id)
|
|
}
|
|
}
|
|
}
|