Configuración de impresora
This commit is contained in:
parent
130180ba14
commit
14b4421eda
|
@ -176,6 +176,12 @@ class AppConfig(object):
|
|||
req.context['result'] = self._db.add_config(values)
|
||||
resp.status = falcon.HTTP_200
|
||||
|
||||
def on_delete(self, req, resp):
|
||||
values = req.params
|
||||
if self._db.delete('config', values['id']):
|
||||
resp.status = falcon.HTTP_200
|
||||
else:
|
||||
resp.status = falcon.HTTP_204
|
||||
|
||||
|
||||
class AppPartners(object):
|
||||
|
|
|
@ -219,6 +219,8 @@ class StorageEngine(object):
|
|||
return main.MovimientosBanco.remove(id)
|
||||
if table == 'usuario':
|
||||
return main.Usuarios.remove(id)
|
||||
if table == 'config':
|
||||
return main.Configuracion.remove(id)
|
||||
return False
|
||||
|
||||
def _get_client(self, values):
|
||||
|
|
|
@ -229,6 +229,31 @@ class Configuracion(BaseModel):
|
|||
|
||||
return values
|
||||
|
||||
if keys['fields'] == 'configotros':
|
||||
fields = (
|
||||
'chk_config_ocultar_metodo_pago',
|
||||
'chk_config_ocultar_condiciones_pago',
|
||||
'chk_config_send_zip',
|
||||
'chk_config_open_pdf',
|
||||
'chk_config_anticipo',
|
||||
'chk_config_cuenta_predial',
|
||||
'chk_config_codigo_barras',
|
||||
'chk_config_precio_con_impuestos',
|
||||
'chk_config_ine',
|
||||
'chk_config_edu',
|
||||
'chk_usar_punto_de_venta',
|
||||
'chk_ticket_pdf_show',
|
||||
'chk_ticket_direct_print',
|
||||
)
|
||||
data = (Configuracion
|
||||
.select()
|
||||
.where(Configuracion.clave.in_(fields))
|
||||
)
|
||||
values = {r.clave: util.get_bool(r.valor) for r in data}
|
||||
tp = 'txt_ticket_printer'
|
||||
values[tp] = Configuracion.get_(tp)
|
||||
return values
|
||||
|
||||
if keys['fields'] == 'correo':
|
||||
fields = ('correo_servidor', 'correo_puerto', 'correo_ssl',
|
||||
'correo_usuario', 'correo_contra', 'correo_copia',
|
||||
|
@ -256,25 +281,6 @@ class Configuracion(BaseModel):
|
|||
.select()
|
||||
.where(Configuracion.clave.in_(fields))
|
||||
)
|
||||
elif keys['fields'] == 'configotros':
|
||||
fields = (
|
||||
'chk_config_ocultar_metodo_pago',
|
||||
'chk_config_ocultar_condiciones_pago',
|
||||
'chk_config_send_zip',
|
||||
'chk_config_open_pdf',
|
||||
'chk_config_anticipo',
|
||||
'chk_config_cuenta_predial',
|
||||
'chk_config_codigo_barras',
|
||||
'chk_config_precio_con_impuestos',
|
||||
'chk_config_ine',
|
||||
'chk_config_edu',
|
||||
'chk_usar_punto_de_venta',
|
||||
'chk_ticket_pdf_show',
|
||||
)
|
||||
data = (Configuracion
|
||||
.select()
|
||||
.where(Configuracion.clave.in_(fields))
|
||||
)
|
||||
elif keys['fields'] == 'timbrar':
|
||||
fields = (
|
||||
'chk_config_ocultar_metodo_pago',
|
||||
|
@ -293,6 +299,7 @@ class Configuracion(BaseModel):
|
|||
|
||||
@classmethod
|
||||
def add(cls, values):
|
||||
print (values)
|
||||
try:
|
||||
for k, v in values.items():
|
||||
#~ print (k, v)
|
||||
|
@ -304,6 +311,11 @@ class Configuracion(BaseModel):
|
|||
log.error(str(e))
|
||||
return {'ok': False, 'msg': str(e)}
|
||||
|
||||
@classmethod
|
||||
def remove(cls, key):
|
||||
q = Configuracion.delete().where(Configuracion.clave==key)
|
||||
return bool(q.execute())
|
||||
|
||||
class Meta:
|
||||
order_by = ('clave',)
|
||||
indexes = (
|
||||
|
@ -4400,12 +4412,32 @@ class Tickets(BaseModel):
|
|||
}
|
||||
return data
|
||||
|
||||
def _get_info_printer(self):
|
||||
info = {}
|
||||
value = Configuracion.get_('txt_ticket_printer')
|
||||
if not value:
|
||||
return info
|
||||
|
||||
values = value.split(':')
|
||||
if len(values) == 1:
|
||||
info = {'ip': values[0], 'usb': ()}
|
||||
elif len(values) == 2:
|
||||
info = {'ip': '', 'usb': (int(values[0], 16), int(values[1], 16))}
|
||||
|
||||
return info
|
||||
|
||||
@classmethod
|
||||
def printer(cls, values):
|
||||
id = int(values['id'])
|
||||
info = {'ip': '', 'usb': (int('1ba0', 16), int('2204', 16))}
|
||||
|
||||
info_printer = cls._get_info_printer(cls)
|
||||
if not info_printer:
|
||||
msg = 'Es necesario configurar una impresora.'
|
||||
result = {'ok': False, 'msg': msg}
|
||||
return result
|
||||
|
||||
data = cls._format_ticket(cls, id)
|
||||
result = util.print_ticket(data, info)
|
||||
result = util.print_ticket(data, info_printer)
|
||||
msg = 'Ticket impreso correctamente'
|
||||
if not result:
|
||||
msg = 'Asegurate de que la impresora este conectada y funcionando.'
|
||||
|
|
|
@ -63,6 +63,8 @@ var controllers = {
|
|||
$$('chk_config_precio_con_impuestos').attachEvent('onItemClick', chk_config_item_click)
|
||||
$$('chk_usar_punto_de_venta').attachEvent('onItemClick', chk_config_item_click)
|
||||
$$('chk_ticket_pdf_show').attachEvent('onItemClick', chk_config_item_click)
|
||||
$$('chk_ticket_direct_print').attachEvent('onItemClick', chk_config_item_click)
|
||||
$$('txt_ticket_printer').attachEvent('onKeyPress', txt_ticket_printer_key_press)
|
||||
|
||||
$$('cmd_subir_bdfl').attachEvent('onItemClick', cmd_subir_bdfl_click)
|
||||
$$('up_bdfl').attachEvent('onUploadComplete', up_bdfl_upload_complete)
|
||||
|
@ -1722,4 +1724,42 @@ function update_grid_usuarios(form, win){
|
|||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
function txt_ticket_printer_key_press(code, e){
|
||||
var value = this.getValue()
|
||||
if(code != 13){
|
||||
return
|
||||
}
|
||||
|
||||
if(!value){
|
||||
webix.ajax().del('/config', {id: 'txt_ticket_printer'}, function(text, xml, xhr){
|
||||
var msg = 'Impresora eliminada correctamente'
|
||||
if(xhr.status == 200){
|
||||
msg_ok(msg)
|
||||
}else{
|
||||
msg = 'No se pudo eliminar'
|
||||
msg_error(msg)
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
webix.ajax().post('/config', {'txt_ticket_printer': value}, {
|
||||
error: function(text, data, xhr) {
|
||||
msg = 'Error al guardar la configuración'
|
||||
msg_error(msg)
|
||||
},
|
||||
success: function(text, data, xhr) {
|
||||
var values = data.json();
|
||||
if (values.ok){
|
||||
msg = 'Impresora guardada correctamente'
|
||||
msg_ok(msg)
|
||||
}else{
|
||||
msg_error(values.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
}
|
|
@ -539,9 +539,13 @@ var options_admin_otros = [
|
|||
labelRight: 'Usar punto de venta'},
|
||||
{view: 'checkbox', id: 'chk_ticket_pdf_show', labelWidth: 0,
|
||||
labelRight: 'Abrir PDF al generar'},
|
||||
{}]},
|
||||
{view: 'checkbox', id: 'chk_ticket_direct_print', labelWidth: 0,
|
||||
labelRight: 'Imprimir al generar'},
|
||||
{view: 'text', id: 'txt_ticket_printer', name: 'ticket_printer',
|
||||
label: 'Impresora: ', labelWidth: 75, labelAlign: 'right',
|
||||
placeholder: 'ENTER para guardar'},
|
||||
{maxWidth: 15}]},
|
||||
|
||||
{maxHeight: 20},
|
||||
{}]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue