Mostrar plantillas de acuerdo a configuración
This commit is contained in:
parent
caee632ebb
commit
05c540495e
|
@ -1307,6 +1307,15 @@ def upload_file(rfc, opt, file_obj):
|
||||||
|
|
||||||
name = '{}_3.3.json'.format(rfc.lower())
|
name = '{}_3.3.json'.format(rfc.lower())
|
||||||
path = _join(PATH_MEDIA, 'templates', name)
|
path = _join(PATH_MEDIA, 'templates', name)
|
||||||
|
elif opt == 'txt_plantilla_ticket':
|
||||||
|
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 = '{}_ticket.ods'.format(rfc.lower())
|
||||||
|
path = _join(PATH_MEDIA, 'templates', name)
|
||||||
elif opt == 'txt_plantilla_donataria':
|
elif opt == 'txt_plantilla_donataria':
|
||||||
tmp = file_obj.filename.split('.')
|
tmp = file_obj.filename.split('.')
|
||||||
ext = tmp[-1].lower()
|
ext = tmp[-1].lower()
|
||||||
|
|
|
@ -211,6 +211,24 @@ class Configuracion(BaseModel):
|
||||||
values['default_unidad'] = SATUnidades.get_default()
|
values['default_unidad'] = SATUnidades.get_default()
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
if keys['fields'] == 'configtemplates':
|
||||||
|
try:
|
||||||
|
emisor = Emisor.select()[0]
|
||||||
|
is_ong = emisor.es_ong
|
||||||
|
except IndexError:
|
||||||
|
is_ong = False
|
||||||
|
|
||||||
|
values = {'txt_plantilla_donataria': is_ong}
|
||||||
|
fields = (
|
||||||
|
('chk_usar_punto_de_venta', 'txt_plantilla_ticket'),
|
||||||
|
)
|
||||||
|
|
||||||
|
for s, key in fields:
|
||||||
|
value = util.get_bool(Configuracion.get_(s))
|
||||||
|
values[key] = value
|
||||||
|
|
||||||
|
return values
|
||||||
|
|
||||||
if keys['fields'] == 'correo':
|
if keys['fields'] == 'correo':
|
||||||
fields = ('correo_servidor', 'correo_puerto', 'correo_ssl',
|
fields = ('correo_servidor', 'correo_puerto', 'correo_ssl',
|
||||||
'correo_usuario', 'correo_contra', 'correo_copia',
|
'correo_usuario', 'correo_contra', 'correo_copia',
|
||||||
|
@ -231,6 +249,7 @@ class Configuracion(BaseModel):
|
||||||
'txt_plantilla_factura_32',
|
'txt_plantilla_factura_32',
|
||||||
'txt_plantilla_factura_33',
|
'txt_plantilla_factura_33',
|
||||||
'txt_plantilla_factura_33j',
|
'txt_plantilla_factura_33j',
|
||||||
|
'txt_plantilla_ticket',
|
||||||
'txt_plantilla_donataria',
|
'txt_plantilla_donataria',
|
||||||
)
|
)
|
||||||
data = (Configuracion
|
data = (Configuracion
|
||||||
|
|
|
@ -49,6 +49,7 @@ var controllers = {
|
||||||
$$('txt_plantilla_factura_32').attachEvent('onItemClick', txt_plantilla_factura_32_click)
|
$$('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)
|
||||||
$$('txt_plantilla_factura_33j').attachEvent('onItemClick', txt_plantilla_factura_33j_click)
|
$$('txt_plantilla_factura_33j').attachEvent('onItemClick', txt_plantilla_factura_33j_click)
|
||||||
|
$$('txt_plantilla_ticket').attachEvent('onItemClick', txt_plantilla_ticket_click)
|
||||||
$$('txt_plantilla_donataria').attachEvent('onItemClick', txt_plantilla_donataria_click)
|
$$('txt_plantilla_donataria').attachEvent('onItemClick', txt_plantilla_donataria_click)
|
||||||
$$('chk_config_ocultar_metodo_pago').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_ocultar_metodo_pago').attachEvent('onItemClick', chk_config_item_click)
|
||||||
$$('chk_config_ocultar_condiciones_pago').attachEvent('onItemClick', chk_config_item_click)
|
$$('chk_config_ocultar_condiciones_pago').attachEvent('onItemClick', chk_config_item_click)
|
||||||
|
@ -330,13 +331,29 @@ function get_admin_usuarios(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function set_config_templates(){
|
||||||
|
webix.ajax().get('/config', {'fields': 'configtemplates'}, {
|
||||||
|
error: function(text, data, xhr) {
|
||||||
|
msg = 'Error al consultar'
|
||||||
|
msg_error(msg)
|
||||||
|
},
|
||||||
|
success: function(text, data, xhr) {
|
||||||
|
var values = data.json()
|
||||||
|
Object.keys(values).forEach(function(key){
|
||||||
|
show(key, values[key])
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_config_values(opt){
|
function get_config_values(opt){
|
||||||
if(opt == undefined){
|
if(opt == undefined){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if(opt == 'templates'){
|
if(opt == 'templates'){
|
||||||
show('txt_plantilla_donataria', $$('chk_ong').getValue())
|
set_config_templates()
|
||||||
}
|
}
|
||||||
|
|
||||||
webix.ajax().get('/config', {'fields': opt}, {
|
webix.ajax().get('/config', {'fields': opt}, {
|
||||||
|
@ -822,6 +839,44 @@ function txt_plantilla_factura_33_click(e){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function txt_plantilla_ticket_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_ticket',
|
||||||
|
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 Ticket ODT',
|
||||||
|
body: {
|
||||||
|
view: 'form',
|
||||||
|
elements: body_elements,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
w.show()
|
||||||
|
|
||||||
|
$$('up_template').attachEvent('onUploadComplete', function(response){
|
||||||
|
if(response.ok){
|
||||||
|
$$('txt_plantilla_ticket').setValue(response.name)
|
||||||
|
msg_ok('Plantilla cargada correctamente')
|
||||||
|
}else{
|
||||||
|
msg_error(response.name)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function txt_plantilla_factura_32_click(e){
|
function txt_plantilla_factura_32_click(e){
|
||||||
|
|
||||||
var body_elements = [
|
var body_elements = [
|
||||||
|
|
|
@ -27,6 +27,7 @@ var form_editar_usuario_elementos = [
|
||||||
]}
|
]}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
var admin_ui_windows = {
|
var admin_ui_windows = {
|
||||||
init: function(){
|
init: function(){
|
||||||
webix.ui({
|
webix.ui({
|
||||||
|
@ -470,12 +471,12 @@ var options_templates = [
|
||||||
{maxHeight: 15},
|
{maxHeight: 15},
|
||||||
{cols: [{maxWidth: 15},
|
{cols: [{maxWidth: 15},
|
||||||
{view: 'search', id: 'txt_plantilla_factura_32', name: 'plantilla_factura_32',
|
{view: 'search', id: 'txt_plantilla_factura_32', name: 'plantilla_factura_32',
|
||||||
label: 'Plantilla Factura v3.2 (ODT): ', labelPosition: 'top',
|
label: 'Plantilla Factura v3.2 (ODS): ', labelPosition: 'top',
|
||||||
icon: 'file'}, {}]},
|
icon: 'file'}, {}]},
|
||||||
{maxHeight: 20},
|
{maxHeight: 20},
|
||||||
{cols: [{maxWidth: 15},
|
{cols: [{maxWidth: 15},
|
||||||
{view: 'search', id: 'txt_plantilla_factura_33', labelPosition: 'top',
|
{view: 'search', id: 'txt_plantilla_factura_33', labelPosition: 'top',
|
||||||
label: 'Plantilla Factura v3.3 (ODT): ', icon: 'file'}, {}]},
|
label: 'Plantilla Factura v3.3 (ODS): ', icon: 'file'}, {}]},
|
||||||
{maxHeight: 20},
|
{maxHeight: 20},
|
||||||
{cols: [{maxWidth: 15},
|
{cols: [{maxWidth: 15},
|
||||||
{view: 'search', id: 'txt_plantilla_factura_33j', name: 'plantilla_factura_33j',
|
{view: 'search', id: 'txt_plantilla_factura_33j', name: 'plantilla_factura_33j',
|
||||||
|
@ -483,9 +484,14 @@ var options_templates = [
|
||||||
icon: 'file'}, {}]},
|
icon: 'file'}, {}]},
|
||||||
{maxHeight: 20},
|
{maxHeight: 20},
|
||||||
{cols: [{maxWidth: 15},
|
{cols: [{maxWidth: 15},
|
||||||
|
{view: 'search', id: 'txt_plantilla_ticket', name: 'plantilla_ticket',
|
||||||
|
label: 'Plantilla para Tickets (ODS): ', labelPosition: 'top',
|
||||||
|
icon: 'file'},
|
||||||
{view: 'search', id: 'txt_plantilla_donataria', name: 'plantilla_donataria',
|
{view: 'search', id: 'txt_plantilla_donataria', name: 'plantilla_donataria',
|
||||||
label: 'Plantilla Donataria (solo ONGs): ', labelPosition: 'top',
|
label: 'Plantilla Donataria (solo ONGs): ', labelPosition: 'top',
|
||||||
icon: 'file'}, {}]},
|
icon: 'file'},
|
||||||
|
{}]},
|
||||||
|
{maxHeight: 20},
|
||||||
{}]
|
{}]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue