forked from elmau/empresa-libre
Cargar plantillas ODS
This commit is contained in:
parent
f1dff39e1b
commit
6f30d42d40
|
@ -1121,6 +1121,15 @@ def upload_file(rfc, opt, file_obj):
|
||||||
|
|
||||||
name = '{}_3.3.ods'.format(rfc.lower())
|
name = '{}_3.3.ods'.format(rfc.lower())
|
||||||
path = _join(PATH_MEDIA, 'templates', name)
|
path = _join(PATH_MEDIA, 'templates', name)
|
||||||
|
elif opt == 'txt_plantilla_factura_32':
|
||||||
|
tmp = file_obj.filename.split('.')
|
||||||
|
ext = tmp[-1].lower()
|
||||||
|
if ext != 'ods':
|
||||||
|
msg = 'Extensión de archivo incorrecta, selecciona un archivo ODS'
|
||||||
|
return {'status': 'server', 'name': msg, 'ok': False}
|
||||||
|
|
||||||
|
name = '{}_3.2.ods'.format(rfc.lower())
|
||||||
|
path = _join(PATH_MEDIA, 'templates', name)
|
||||||
|
|
||||||
if save_file(path, file_obj.file.read()):
|
if save_file(path, file_obj.file.read()):
|
||||||
return {'status': 'server', 'name': file_obj.filename, 'ok': True}
|
return {'status': 'server', 'name': file_obj.filename, 'ok': True}
|
||||||
|
|
|
@ -29,6 +29,7 @@ var controllers = {
|
||||||
//~ Opciones
|
//~ Opciones
|
||||||
tb_options = $$('tab_options').getTabbar()
|
tb_options = $$('tab_options').getTabbar()
|
||||||
tb_options.attachEvent('onChange', tab_options_change)
|
tb_options.attachEvent('onChange', tab_options_change)
|
||||||
|
$$('txt_plantilla_factura_32').attachEvent('onItemClick', txt_plantilla_factura_32_click)
|
||||||
$$('txt_plantilla_factura_33').attachEvent('onItemClick', txt_plantilla_factura_33_click)
|
$$('txt_plantilla_factura_33').attachEvent('onItemClick', txt_plantilla_factura_33_click)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -686,7 +687,7 @@ function txt_plantilla_factura_33_click(e){
|
||||||
id: 'win_template',
|
id: 'win_template',
|
||||||
modal: true,
|
modal: true,
|
||||||
position: 'center',
|
position: 'center',
|
||||||
head: 'Subir Plantilla',
|
head: 'Subir Plantilla 3.3 ODT',
|
||||||
body: {
|
body: {
|
||||||
view: 'form',
|
view: 'form',
|
||||||
elements: body_elements,
|
elements: body_elements,
|
||||||
|
@ -706,6 +707,44 @@ function txt_plantilla_factura_33_click(e){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function txt_plantilla_factura_32_click(e){
|
||||||
|
|
||||||
|
var body_elements = [
|
||||||
|
{cols: [{width: 100}, {view: 'uploader', id: 'up_template', autosend: true, link: 'lst_files',
|
||||||
|
value: 'Seleccionar archivo', upload: '/files/txt_plantilla_factura_32',
|
||||||
|
width: 200}, {width: 100}]},
|
||||||
|
{view: 'list', id: 'lst_files', type: 'uploader', autoheight:true,
|
||||||
|
borderless: true},
|
||||||
|
{},
|
||||||
|
{cols: [{}, {view: 'button', label: 'Cerrar', autowidth: true,
|
||||||
|
click:("$$('win_template').close();")}, {}]}
|
||||||
|
]
|
||||||
|
|
||||||
|
var w = webix.ui({
|
||||||
|
view: 'window',
|
||||||
|
id: 'win_template',
|
||||||
|
modal: true,
|
||||||
|
position: 'center',
|
||||||
|
head: 'Subir Plantilla 3.2 ODT',
|
||||||
|
body: {
|
||||||
|
view: 'form',
|
||||||
|
elements: body_elements,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
w.show()
|
||||||
|
|
||||||
|
$$('up_template').attachEvent('onUploadComplete', function(response){
|
||||||
|
if(response.ok){
|
||||||
|
$$('txt_plantilla_factura_32').setValue(response.name)
|
||||||
|
msg_sucess('Plantilla cargada correctamente')
|
||||||
|
}else{
|
||||||
|
msg_error(response.name)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function tab_options_change(nv, ov){
|
function tab_options_change(nv, ov){
|
||||||
var cv = {
|
var cv = {
|
||||||
Plantillas: 'templates',
|
Plantillas: 'templates',
|
||||||
|
|
Loading…
Reference in New Issue