Tickets, ir al final en nota

This commit is contained in:
Mauricio Baeza 2018-01-10 22:52:17 -06:00
parent bee911504b
commit 59de554b2b
3 changed files with 19 additions and 52 deletions

View File

@ -320,52 +320,11 @@ function calcular_precio_con_impuestos(precio, taxes){
}
function txt_ticket_new_cant_key_press(code, e){
var value = this.getValue()
if(code == 13){
var grid = $$('grid_tdetails')
var row = grid.getItem(grid.getFirstId())
var cant = value.to_float()
if(!cant){
cant = 1.0
}
if(cant != 1){
var precio_final = row.valor_unitario - row.descuento
importe = (cant * precio_final).round(DECIMALES)
grid.updateItem(row.id, {cantidad: cant, importe: importe})
grid.refresh()
}
$$('win_edit_cant').hide()
}
}
function edit_cant(){
function edit_cant(id){
if(!cfg_ticket['edit_cant']){
return
}
var row = $$('grid_tdetails').getItem($$('grid_tdetails').getFirstId())
var win = webix.ui({
view: 'window',
id: 'win_edit_cant',
autoheight: true,
modal: true,
position: 'center',
head: 'Captura la cantidad',
body: {rows: [{view: 'text', id: 'txt_ticket_new_cant', width: 150,
value: 1}]
},
})
$$('txt_ticket_new_cant').attachEvent('onKeyPress', txt_ticket_new_cant_key_press)
win.show(
$$('tsearch_product_name').getInputNode(),
{pos: "bottom", x: 50, y: 10}
)
focus('txt_ticket_new_cant')
$$('txt_ticket_new_cant').getInputNode().select()
$$('grid_tdetails').edit({row: id, column: 'cantidad'})
}
@ -382,8 +341,8 @@ function agregar_producto(values){
producto['valor_unitario'] = calcular_precio_con_impuestos(
parseFloat(producto['valor_unitario']), taxes)
producto['importe'] = producto['valor_unitario']
grid.add(producto, 0)
edit_cant()
var id = grid.add(producto, 0)
edit_cant(id)
}else{
producto['cantidad'] = parseFloat(row.cantidad) + 1
producto['descuento'] = parseFloat(row.descuento)
@ -725,13 +684,10 @@ function cmd_ticket_notes_click(){
var values = $$('form_new_ticket').getValues()
$$('ticket_notes').setValue(values.notas)
$$('win_ticket_notes').show()
to_end('ticket_notes')
}
//~ function ticket_notes_key_up(){
//~ var value = this.getValue()
//~ $$('form_new_ticket').setValues({notas: value}, true)
//~ }
function cmd_ticket_save_note_click(){
var value = $$('ticket_notes').getValue()
$$('form_new_ticket').setValues({notas: value}, true)

View File

@ -50,6 +50,17 @@ function focus(name){
}
function to_end(name){
focus(name)
var txt = $$(name)
var pos = txt.getValue().length
var height = txt.getInputNode().scrollHeight
webix.html.setSelectionRange(txt.getInputNode(), pos)
txt.getInputNode().scrollTop = height
}
function showvar(values){
webix.message(JSON.stringify(values, null, 2))
}

View File

@ -178,7 +178,7 @@ var toolbar_new_ticket = {
view: 'toolbar', elements: [
{view: 'button', id: 'cmd_generar_ticket', label: 'Generar',
icon: 'ticket', type: 'iconButton', autowidth: true,
align: 'center'}, {},
align: 'center', hotkey: 'Ctrl+g'}, {},
{view: 'button', id: 'cmd_ticket_notes', label: 'Notas',
autowidth: true, type: 'iconButton', icon: 'commenting-o'}, {},
{view: 'button', id: 'cmd_cerrar_ticket', label: 'Cerrar',
@ -457,7 +457,8 @@ var body_ticket_notes = {rows: [
placeholder: 'Captura las notas'},
{minHeight: 5, maxHeight: 5},
{cols: [{}, {view: 'button', id: 'cmd_ticket_save_note', autowidth: true,
label: 'Guardar y Cerrar', type: 'iconButton'}, {}]},
label: 'Guardar y Cerrar', type: 'iconButton', hotkey: 'Ctrl+enter'},
{}]},
{minHeight: 5, maxHeight: 5},
]}
@ -474,6 +475,5 @@ var win_ticket_notes = {
head: 'Notas',
body: body_ticket_notes,
})
//~ $$('ticket_notes').attachEvent('onTimedKeyPress', ticket_notes_key_up);
$$('cmd_ticket_save_note').attachEvent('onItemClick', cmd_ticket_save_note_click)
}}