Add button for import products from CFDI
This commit is contained in:
parent
cf35cd08cd
commit
535cc9d527
|
@ -32,6 +32,10 @@ var products_controllers = {
|
|||
$$("cmd_save_product").attachEvent("onItemClick", cmd_save_product_click)
|
||||
$$("cmd_cancel_product").attachEvent("onItemClick", cmd_cancel_product_click)
|
||||
$$("cmd_import_products").attachEvent("onItemClick", cmd_import_products_click)
|
||||
$$("cmd_products_add").attachEvent("onItemClick", cmd_products_add_click)
|
||||
$$('cmd_add_products_from_xml').attachEvent('onItemClick', cmd_add_products_from_xml_click)
|
||||
$$('cmd_save_products_add').attachEvent('onItemClick', cmd_save_products_add_click)
|
||||
$$('cmd_close_products_add').attachEvent('onItemClick', cmd_close_products_add_click)
|
||||
$$("chk_automatica").attachEvent("onChange", chk_automatica_change)
|
||||
$$("valor_unitario").attachEvent("onChange", valor_unitario_change)
|
||||
$$('precio_con_impuestos').attachEvent('onChange', precio_con_impuestos_change)
|
||||
|
@ -247,9 +251,7 @@ function cmd_save_product_click(id, e, node){
|
|||
|
||||
|
||||
function cmd_cancel_product_click(id, e, node){
|
||||
|
||||
$$("multi_products").setValue("products_home")
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -429,3 +431,69 @@ function up_products_upload_complete(response){
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
//~ Add products
|
||||
function cmd_products_add_click(id, e, node){
|
||||
$$("multi_products").setValue("product_add")
|
||||
}
|
||||
|
||||
//~ Close add products
|
||||
function cmd_close_products_add_click(id, e, node){
|
||||
$$('multi_invoices').setValue('products_home')
|
||||
}
|
||||
|
||||
//~ Save add products
|
||||
function cmd_save_products_add_click(id, e, node){
|
||||
msg_ok('Guardado')
|
||||
$$('multi_invoices').setValue('products_home')
|
||||
}
|
||||
|
||||
//~ Import from xml
|
||||
function cmd_add_products_from_xml_click(){
|
||||
win_add_products_from_xml.init()
|
||||
$$('win_add_products_from_xml').show()
|
||||
}
|
||||
|
||||
//~ Upload XML
|
||||
function cmd_upload_products_from_xml_click(){
|
||||
var form = $$('form_upload_products_from_xml')
|
||||
|
||||
$$('win_add_products_from_xml').close()
|
||||
|
||||
//~ var values = form.getValues()
|
||||
|
||||
//~ if(!$$('lst_upload_products').count()){
|
||||
//~ $$('win_import_products').close()
|
||||
//~ return
|
||||
//~ }
|
||||
|
||||
//~ if($$('lst_upload_products').count() > 1){
|
||||
//~ msg = 'Selecciona solo un archivo'
|
||||
//~ msg_error(msg)
|
||||
//~ return
|
||||
//~ }
|
||||
|
||||
//~ var template = $$('up_products').files.getItem($$('up_products').files.getFirstId())
|
||||
|
||||
//~ if(template.type.toLowerCase() != 'ods'){
|
||||
//~ msg = 'Archivo inválido.\n\nSe requiere un archivo ODS'
|
||||
//~ msg_error(msg)
|
||||
//~ return
|
||||
//~ }
|
||||
|
||||
//~ msg = '¿Estás seguro de importar este archivo?'
|
||||
//~ webix.confirm({
|
||||
//~ title: 'Importar Productos',
|
||||
//~ ok: 'Si',
|
||||
//~ cancel: 'No',
|
||||
//~ type: 'confirm-error',
|
||||
//~ text: msg,
|
||||
//~ callback:function(result){
|
||||
//~ if(result){
|
||||
//~ $$('up_products_from_xml').send()
|
||||
//~ }
|
||||
//~ }
|
||||
//~ })
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ var toolbar_products = [
|
|||
{},
|
||||
{view: 'button', id: 'cmd_import_products', label: 'Importar',
|
||||
type: 'iconButton', autowidth: true, icon: 'upload'},
|
||||
{view: "button", id: "cmd_products_add", label: "Altas",
|
||||
type: "iconButton", autowidth: true, icon: "plus"},
|
||||
]
|
||||
|
||||
|
||||
|
@ -158,7 +160,7 @@ var controls_generals = [
|
|||
label: 'Inventario', labelAlign: 'right', labelWidth: 130},
|
||||
{view: 'counter', id: 'txt_existencia', name: 'existencia',
|
||||
hidden: true, label: 'Existencia', step: 5, value: 0, min: 0,
|
||||
disabled: true},
|
||||
disabled: true, readonly: true},
|
||||
{view: 'counter', id: 'txt_minimo', name: 'minimo', hidden: true,
|
||||
label: 'Mínimo', step: 5, value: 0, min: 0, disabled: true},
|
||||
{},]},
|
||||
|
@ -176,8 +178,8 @@ var controls_products = [
|
|||
],
|
||||
},
|
||||
{rows: [
|
||||
{ template:"", type: "section" },
|
||||
{ margin: 10, cols: [{},
|
||||
{template: "", type: "section"},
|
||||
{margin: 10, cols: [{},
|
||||
{view: "button", id: "cmd_save_product", label: "Guardar" , type: "form", autowidth: true, align:"center"},
|
||||
{view: "button", id: "cmd_cancel_product", label: "Cancelar" , type: "danger", autowidth: true, align:"center"},
|
||||
{}]
|
||||
|
@ -202,6 +204,126 @@ var form_product = {
|
|||
}
|
||||
|
||||
|
||||
var toolbar_products_add = {view: 'toolbar', elements: [{},
|
||||
{view: 'button', id: 'cmd_add_products_from_xml', label: 'Desde XML',
|
||||
type: 'iconButton', autowidth: true, icon: 'upload'},
|
||||
{}]}
|
||||
|
||||
|
||||
var rows_pro_add_partner = [
|
||||
{view: 'fieldset', label: 'Buscar Proveedor', body: {rows: [
|
||||
{cols: [
|
||||
{view: 'search', id: 'search_partner_id', label: 'por Clave',
|
||||
labelPosition: 'top', maxWidth: 200, placeholder: 'Captura la clave'},
|
||||
{view: 'search', id: 'search_partner_name', label: 'por Nombre o RFC',
|
||||
labelPosition: 'top', placeholder: 'Captura al menos tres letras'},
|
||||
]},
|
||||
{cols: [
|
||||
{view: 'label', id: 'lbl_partner_title', label: 'Seleccionado: ', autowidth: true},
|
||||
{view: 'label', id: 'lbl_partner', label: 'Ninguno'},
|
||||
]}
|
||||
]}},
|
||||
]
|
||||
|
||||
|
||||
var grid_partner_products_cols = [
|
||||
{id: 'select', header: '', template:'{common.checkbox()}', width:35},
|
||||
{id: 'key', header: {text: 'Clave', css: 'center'}, width: 100,
|
||||
adjust: 'data'},
|
||||
{id: 'key_sat', header:{text: 'Clave SAT', css: 'center'}, width: 100,
|
||||
adjust: 'data'},
|
||||
{id: 'description', header:{text: 'Descripción', css: 'center'},
|
||||
fillspace: true, editor: 'popup'},
|
||||
{id: "pedimento", header: 'Pedimento', editor: 'text', hidden: true},
|
||||
{id: 'unit', header:{text: 'Unidad', css: 'center'}, width: 100,
|
||||
editor: 'select', options: 'values/unidades'},
|
||||
{id: 'unit_value', header:{text: 'Valor Unitario', css: 'center'},
|
||||
width: 100, format: format_currency, css: 'right', editor: 'text'},
|
||||
//~ {id: 'descuento', header:{text: 'Descuento', css: 'center'},
|
||||
//~ width: 100, format: format_currency, css: 'right', editor: 'text'},
|
||||
//~ {id: 'precio_final', hidden: true, header: 'precio_final', width: 80,
|
||||
//~ format: webix.i18n.priceFormat, css: 'right'},
|
||||
{id: 'import', header:{text: 'Importe', css: 'center'}, width: 100,
|
||||
format: webix.i18n.priceFormat, css: 'right'},
|
||||
{id: 'cantidad', header: {text: 'Cantidad', css: 'center'}, width: 50,
|
||||
format: webix.i18n.numberFormat, css: 'right', editor: 'text'},
|
||||
{id: 'separate', header: '', width: 25},
|
||||
{id: 'id_product', header: '', hidden: true},
|
||||
{id: 'key1', header:{text: 'Clave', css: 'center'}, width: 100,
|
||||
adjust: 'data'},
|
||||
{id: 'key_sat1', header:{text: 'Clave SAT', css: 'center'}, width: 100,
|
||||
adjust: 'data'},
|
||||
{id: 'description1', header:{text: 'Descripción', css: 'center'},
|
||||
fillspace: true, editor: 'popup'},
|
||||
]
|
||||
|
||||
|
||||
var grid_partner_products = {
|
||||
view: 'datatable',
|
||||
id: 'grid_partner_products',
|
||||
select: 'row',
|
||||
adjust: true,
|
||||
autoheight: true,
|
||||
editable: true,
|
||||
columns: grid_partner_products_cols,
|
||||
data: [],
|
||||
fixedRowHeight: false,
|
||||
}
|
||||
|
||||
|
||||
var controls_products_add = [
|
||||
{minHeight: 10, maxHeight: 10},
|
||||
toolbar_products_add,
|
||||
{minHeight: 10, maxHeight: 10},
|
||||
{cols: [
|
||||
{rows: rows_pro_add_partner},
|
||||
{maxWidth: 10},
|
||||
{},
|
||||
]},
|
||||
{view: 'label', label: 'Detalle', height: 30, align: 'left'},
|
||||
{cols: [
|
||||
grid_partner_products,
|
||||
//~ grid_products_add,
|
||||
]},
|
||||
{rows: [
|
||||
{template:"", type: "section" },
|
||||
{margin: 10, cols: [{},
|
||||
{view: 'button', id: 'cmd_save_products_add', label: 'Guardar',
|
||||
autowidth: true, align: 'center'},
|
||||
{},
|
||||
{view: 'button', id: 'cmd_close_products_add', label: 'Cancelar',
|
||||
type: 'danger', autowidth: true, align: 'center'}
|
||||
]
|
||||
},
|
||||
]}
|
||||
]
|
||||
|
||||
|
||||
var controls_form_products_add = [
|
||||
{
|
||||
view: 'tabview',
|
||||
id: 'tv_invoice',
|
||||
animate: true,
|
||||
cells: [
|
||||
{id: 'Altas a inventario', rows: controls_products_add},
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
var form_products_add = {
|
||||
type: 'space',
|
||||
responsive: true,
|
||||
cols: [{
|
||||
view: 'form',
|
||||
id: 'form_products_add',
|
||||
complexData: true,
|
||||
scroll: true,
|
||||
elements: controls_form_products_add,
|
||||
}]
|
||||
}
|
||||
|
||||
|
||||
var multi_products = {
|
||||
id: "multi_products",
|
||||
animate: true,
|
||||
|
@ -210,7 +332,8 @@ var multi_products = {
|
|||
{view:"toolbar", elements: toolbar_products},
|
||||
grid_products,
|
||||
]},
|
||||
{id: "product_new", rows:[form_product]}
|
||||
{id: "product_new", rows:[form_product]},
|
||||
{id: "product_add", rows:[form_products_add]}
|
||||
],
|
||||
}
|
||||
|
||||
|
@ -255,3 +378,35 @@ var win_import_products = {
|
|||
$$('up_products').attachEvent('onUploadComplete', up_products_upload_complete)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var body_add_products_from_xml = {rows: [
|
||||
{view: 'form', id: 'form_upload_products_from_xml', rows: [
|
||||
{cols: [{},
|
||||
{view: 'uploader', id: 'up_products_from_xml', autosend: false,
|
||||
link: 'lst_up_products_from_xml', value: 'Seleccionar Archivo',
|
||||
upload: '/files/productsadd'}, {}]},
|
||||
{cols: [
|
||||
{view: 'list', id: 'lst_up_products_from_xml', type: 'uploader',
|
||||
autoheight: true, borderless: true}]},
|
||||
{cols: [{}, {view: 'button', id: 'cmd_upload_products_from_xml',
|
||||
label: 'Cargar Productos'}, {}]},
|
||||
]},
|
||||
]}
|
||||
|
||||
|
||||
var win_add_products_from_xml = {
|
||||
init: function(){
|
||||
webix.ui({
|
||||
view: 'window',
|
||||
id: 'win_add_products_from_xml',
|
||||
width: 400,
|
||||
modal: true,
|
||||
position: 'center',
|
||||
head: 'Agregar Productos desde XML',
|
||||
body: body_add_products_from_xml,
|
||||
})
|
||||
$$('cmd_upload_products_from_xml').attachEvent('onItemClick', cmd_upload_products_from_xml_click)
|
||||
//~ $$('up_products').attachEvent('onUploadComplete', up_products_upload_complete)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue