2017-06-27 15:43:02 -05:00
var toolbar _invoices = [
{ view : "button" , id : "cmd_new_invoice" , label : "Nueva" , type : "iconButton" ,
autowidth : true , icon : "plus" } ,
{ view : "button" , id : "cmd_edit_invoice" , label : "Editar" , type : "iconButton" ,
autowidth : true , icon : "pencil" } ,
{ view : "button" , id : "cmd_delete_invoice" , label : "Eliminar" , type : "iconButton" ,
autowidth : true , icon : "minus" } ,
2017-10-04 23:22:05 -05:00
]
function doc _xml ( obj ) {
var node = "<img src='/static/img/file-xml.png' height='20' width='20' style='margin: 5px 0px'/>"
return node
}
2017-06-27 15:43:02 -05:00
var grid _invoices _cols = [
{ id : "id" , header : "ID" , hidden : true } ,
2017-10-04 23:22:05 -05:00
{ id : "serie" , header : [ "Serie" , { content : "selectFilter" } ] , adjust : "data" ,
sort : "string" } ,
{ id : "folio" , header : [ "Folio" , { content : "numberFilter" } ] , adjust : "data" ,
sort : "int" , css : "cell_right" } ,
{ id : 'xml' , header : '' , adjust : 'data' , template : doc _xml } ,
{ id : "uuid" , header : [ "UUID" , { content : "textFilter" } ] , adjust : "data" ,
sort : "string" } ,
2017-06-27 15:43:02 -05:00
{ id : "fecha" , header : [ "Fecha y Hora" ] , adjust : "data" , sort : "string" } ,
2017-10-04 23:22:05 -05:00
{ id : "tipo_comprobante" , header : [ "Tipo" , { content : "selectFilter" } ] ,
adjust : 'header' , sort : 'string' } ,
{ id : "estatus" , header : [ "Estatus" , { content : "selectFilter" } ] ,
adjust : "data" , sort : "string" } ,
{ id : 'total_mn' , header : [ 'Total M.N.' , { content : 'numberFilter' } ] , width : 150 ,
sort : 'int' , format : webix . i18n . priceFormat , css : 'right' } ,
{ id : "cliente" , header : [ "Razón Social" , { content : "selectFilter" } ] ,
fillspace : true , sort : "string" } ,
]
2017-06-27 15:43:02 -05:00
var grid _invoices = {
view : "datatable" ,
id : "grid_invoices" ,
select : "row" ,
adjust : true ,
footer : true ,
resizeColumn : true ,
headermenu : true ,
columns : grid _invoices _cols ,
} ;
var grid _details _cols = [
2017-10-04 23:22:05 -05:00
{ id : "id" , header : "ID" , hidden : true } ,
{ id : 'delete' , header : '' , width : 30 , css : 'delete' } ,
{ id : "key" , header : { text : 'Clave' , css : 'center' } , width : 100 } ,
{ id : "description" , header : { text : 'Descripción' , css : 'center' } ,
fillspace : true } ,
{ id : "unit" , header : { text : 'Unidad' , css : 'center' } , width : 100 } ,
{ id : 'cant' , header : { text : 'Cantidad' , css : 'center' } , width : 100 ,
format : webix . i18n . numberFormat , css : 'right' , editor : 'text' } ,
{ id : "price" , header : { text : 'Valor Unitario' , css : 'center' } , width : 100 ,
format : webix . i18n . priceFormat , css : 'right' , editor : 'text' } ,
{ id : "importe" , header : { text : 'Importe' , css : 'center' } , width : 150 , format : webix . i18n . priceFormat , css : 'right' } ,
]
2017-06-27 15:43:02 -05:00
var grid _details = {
view : "datatable" ,
id : "grid_details" ,
select : "row" ,
adjust : true ,
autoheight : true ,
columns : grid _details _cols ,
2017-10-04 23:22:05 -05:00
data : [ ]
}
var grid _totals _cols = [
{ id : 'id' , header : 'ID' , hidden : true } ,
{ id : 'concepto' , header : 'Concepto' , width : 200 ,
footer : { text : 'TOTAL' , css : 'right_footer' } , css : 'right' } ,
{ id : 'importe' , header : 'Importe' , width : 150 ,
footer : { content : 'summColumn' , css : 'right_footer' } ,
format : webix . i18n . priceFormat , css : 'right' } ,
]
var grid _totals = {
view : 'datatable' ,
id : 'grid_totals' ,
select : false ,
width : 350 ,
header : false ,
footer : true ,
autoheight : true ,
columns : grid _totals _cols ,
data : [ { id : 1 , concepto : 'SubTotal' , importe : 0 } ]
}
var suggest _partners = {
view : 'gridsuggest' ,
id : 'grid_partners_found' ,
name : 'grid_partners_found' ,
body : {
autoConfig : false ,
header : false ,
2017-10-05 12:16:20 -05:00
columns : [
{ id : 'id' , hidden : true } ,
{ id : 'nombre' , adjust : 'data' } ,
{ id : 'rfc' , adjust : 'data' } ] ,
2017-10-04 23:22:05 -05:00
dataFeed : function ( text ) {
if ( text . length > 2 ) {
this . load ( '/values/partner?name=' + text )
} else {
this . hide ( )
}
}
}
}
var suggest _products = {
view : 'gridsuggest' ,
id : 'grid_products_found' ,
name : 'grid_products_found' ,
body : {
autoConfig : false ,
header : true ,
columns : [
{ id : 'id' , hidden : true } ,
{ id : 'key' , adjust : 'data' } ,
{ id : 'description' , adjust : 'data' } ,
{ id : 'unit' , adjust : 'data' } ,
{ id : 'price' , adjust : 'data' , format : webix . i18n . priceFormat }
] ,
dataFeed : function ( text ) {
if ( text . length > 2 ) {
this . load ( '/values/product?name=' + text )
} else {
this . hide ( )
}
}
}
}
var body _comprobante = { cols : [
{
view : 'richselect' ,
id : 'lst_tipo_comprobante' ,
label : 'Tipo' ,
labelPosition : 'top' ,
required : true ,
value : 'I' ,
options : [
{ id : 'I' , value : 'Ingreso' } ,
{ id : 'E' , value : 'Egreso' } ,
{ id : 'T' , value : 'Traslado' }
]
} ,
{
view : 'richselect' ,
id : 'lst_serie' ,
label : 'Serie' ,
labelPosition : 'top' ,
options : [ ] ,
//~ options: '/values/series',
//~ on: {
//~ onAfterRender: webix.once(function(){
//~ this.getPopup().getList().waitData.then(webix.bind(function(){
//~ this.setValue(this.getPopup().getList().getFirstId())
//~ }, this))
//~ }),
//~ }
}
] }
var opt _metodo _pago = [
{ id : 'PUE' , value : 'Pago en una sola exhibición' } ,
{ id : 'PPD' , value : 'Pago en parcialidades o diferido' }
]
var body _opciones = { rows : [
{ view : 'richselect' , id : 'lst_forma_pago' , label : 'Forma de Pago' ,
labelPosition : 'top' , required : true , options : [ ] } ,
{ view : 'richselect' , id : 'lst_metodo_pago' , label : 'Método de Pago' ,
labelPosition : 'top' , options : opt _metodo _pago , value : 'PUE' ,
required : true } ,
{ view : 'text' , id : 'txt_condicion_pago' , label : 'Condiciones de Pago' ,
labelPosition : 'top' } ,
] }
var body _moneda = { cols : [
{ view : 'richselect' , id : 'lst_moneda' , label : 'Nombre' ,
labelPosition : 'top' , required : true , options : [ ] } ,
{ view : 'text' , type : 'text' , id : 'txt_tipo_cambio' , value : '1.00' ,
label : 'Tipo de Cambio' , labelPosition : 'top' , required : true ,
invalidMessage : 'Captura un valor númerico' , inputAlign : 'right' ,
readonly : true }
] }
var body _uso _cfdi = {
view : 'richselect' ,
id : 'lst_uso_cfdi' ,
required : true ,
options : [ ]
}
2017-06-27 15:43:02 -05:00
var controls _generate = [
2017-10-04 23:22:05 -05:00
{ cols : [ { rows : [
{ view : 'fieldset' , label : 'Buscar Cliente' , body : { rows : [
{ cols : [
{ view : "search" , id : "search_partner_id" , name : "search_partner_id" ,
label : "por Clave" , labelPosition : 'top' , maxWidth : 200 ,
placeholder : 'Captura la clave' } ,
2017-10-05 12:16:20 -05:00
{ view : 'search' , id : 'search_partner_name' ,
name : 'search_partner_name' , label : 'por Nombre o RFC' ,
labelPosition : 'top' , suggest : suggest _partners ,
placeholder : 'Captura al menos tres letras' } ,
2017-10-04 23:22:05 -05:00
] } ,
{ cols : [ { view : "label" , id : "lbl_partner_title" , name : "lbl_partner_title" , label : 'Seleccionado: ' , autowidth : true } ,
{ view : "label" , id : "lbl_partner" , name : "lbl_partner" , label : 'Ninguno' } ,
] }
] } } ,
{ view : 'fieldset' , label : 'Buscar Producto' , body : { rows : [
{ cols : [ { view : "search" , id : "search_product_id" , name : "search_product_id" , label : "por Clave" , labelPosition : 'top' , maxWidth : 200 , placeholder : 'Captura la clave' } ,
{ view : "search" , id : "search_product_name" , name : "search_product_name" , label : "por Descripción" , labelPosition : 'top' , suggest : suggest _products , placeholder : 'Captura al menos tres letras' } ,
] } ,
] } }
] } ,
{ maxWidth : 10 } ,
{ maxWidth : 300 , rows : [
{ view : 'fieldset' , label : 'Comprobante' , body : body _comprobante } ,
{ view : 'fieldset' , label : 'Opciones de Pago' , body : body _opciones } ,
{ view : 'fieldset' , label : 'Moneda' , body : body _moneda } ,
{ view : 'fieldset' , label : 'Uso del CFDI' , body : body _uso _cfdi } ,
] }
] } ,
{ view : 'label' , label : 'Detalle' , height : 30 , align : 'left' } ,
2017-06-27 15:43:02 -05:00
grid _details ,
2017-10-04 23:22:05 -05:00
{ minHeight : 15 , maxHeight : 15 } ,
{ cols : [ { } , grid _totals ] }
2017-06-27 15:43:02 -05:00
]
var controls _invoices = [
{
view : "tabview" ,
tabbar : { options : [ "Generar" ] } , animate : true ,
cells : [
{ id : "Generar" , rows : controls _generate } ,
]
} ,
{ rows : [
{ template : "" , type : "section" } ,
{ margin : 10 , cols : [ { } ,
2017-10-04 23:22:05 -05:00
{ view : "button" , id : "cmd_timbrar" , label : "Timbrar" ,
type : "form" , autowidth : true , align : "center" } ,
{ view : 'button' , id : 'cmd_close_invoice' , label : 'Salir' ,
type : 'danger' , autowidth : true , align : 'center' } ,
2017-06-27 15:43:02 -05:00
{ } ]
} ,
] }
2017-10-04 23:22:05 -05:00
]
2017-06-27 15:43:02 -05:00
var form _invoice = {
type : "space" ,
cols : [ {
view : "form" ,
id : "form_invoice" ,
complexData : true ,
elements : controls _invoices ,
} ]
} ;
var multi _invoices = {
id : "multi_invoices" ,
2017-10-04 23:22:05 -05:00
view : 'multiview' ,
2017-06-27 15:43:02 -05:00
animate : true ,
cells : [
{ id : "invoices_home" , rows : [
2017-10-04 23:22:05 -05:00
{ view : "toolbar" , elements : toolbar _invoices } ,
2017-06-27 15:43:02 -05:00
grid _invoices ,
] } ,
{ id : "invoices_new" , rows : [ form _invoice , { } ] }
]
} ;
var app _invoices = {
id : "app_invoices" ,
rows : [
{ view : "template" , id : "th_invoices" , type : "header" , template : "Administración de Facturas" } ,
multi _invoices
]
} ;