diff --git a/source/static/js/controller/invoices.js b/source/static/js/controller/invoices.js index a614683..dbefa83 100644 --- a/source/static/js/controller/invoices.js +++ b/source/static/js/controller/invoices.js @@ -1113,7 +1113,6 @@ function grid_details_header_click(id){ callback:function(result){ if (result){ grid.clearAll() - //~ calculate_taxes() calcular_impuestos() } } @@ -1121,8 +1120,53 @@ function grid_details_header_click(id){ } +function refacturar_invoice(id){ + //~ webix.ajax().get('/values/preproductos', {'id': id}, { + //~ error: function(text, data, xhr) { + //~ msg_error('Error al consultar') + //~ }, + //~ success: function(text, data, xhr){ + //~ var values = data.json() + //~ set_client(values.receptor) + //~ for(var p of values.rows){ + //~ agregar_preproducto(p) + //~ } + //~ calcular_impuestos() + //~ $$('tv_invoice').getTabbar().setValue('Generar') + //~ } + //~ }) +} + + function cmd_refacturar_click(){ - showvar('Refacturar') + if(gi.count() == 0){ + return + } + + var row = gi.getSelectedItem() + if (row == undefined){ + msg_error('Selecciona una factura') + return + } + if (row instanceof Array){ + msg_error('Selecciona solo una factura') + return + } + + var msg = '¿Estás seguro de refacturar la siguiente factura?

' + msg += '(' + row['serie'] + '-' + row['folio'] + ') ' + row['cliente'] + webix.confirm({ + title: 'Refacturar', + ok: 'Si', + cancel: 'No', + type: 'confirm-error', + text: msg, + callback:function(result){ + if (result){ + refacturar_invoice(row['id']) + } + } + }) }