mirror of
https://github.com/KeymonSoft/Lanterna.git
synced 2026-04-17 21:06:32 +00:00
1010 lines
44 KiB
QBasic
1010 lines
44 KiB
QBasic
B4A=true
|
|
Group=Default Group
|
|
ModulesStructureVersion=1
|
|
Type=Class
|
|
Version=12.2
|
|
@EndOfDesignText@
|
|
Sub Class_Globals
|
|
Private Root As B4XView 'ignore
|
|
Private xui As XUI 'ignore
|
|
Private p_principal As Panel
|
|
Private WobbleMenu1 As WobbleMenu
|
|
Dim PCLV, PCLVM As PreoptimizedCLV
|
|
Private p_meseros As Panel
|
|
Private clv_prods_ll, clv As CustomListView
|
|
Dim prodsMap As Map
|
|
' Private p_botonesVenta As Panel
|
|
Private b_continuar As Button
|
|
Private lfila As Label
|
|
' Private et_busca As EditText
|
|
' Private b_buscar As Button
|
|
Dim etCantHasFocus, hayPedido As Boolean 'ignore
|
|
Dim ticketId As String
|
|
Dim rutaUsuario, folio As String 'ignore
|
|
Dim query As String
|
|
Dim listaProds, listaHints, listaHintsM, list_prodsPedido As List
|
|
Dim reiniciarlistaProds As Boolean = False 'ignore
|
|
Dim forzarBusqueda As Boolean = False
|
|
' Private lv_promos As ListView
|
|
Private b_prodMenos As Button
|
|
Private et_pCant As EditText
|
|
Private l_pCant As Label
|
|
Private b_prodMas As Button
|
|
Private p_botMasMen As Panel
|
|
Private l_prodX As Label
|
|
Private i_prod As ImageView
|
|
Private p_prods As Panel
|
|
Private p_mesas As Panel
|
|
Private b_terminar As Button
|
|
Private p_historial As Panel
|
|
' Private p_botonesHist As Panel
|
|
Private l_compraTerminada As Label
|
|
Private b_borrar As Button
|
|
Private l_historialVacio As Label
|
|
Private lv_historial As ListView
|
|
Dim clv_mesas As CustomListView
|
|
Private l_mesaX As Label
|
|
Private l_estatus As Label
|
|
Private l_mesa As Label
|
|
Private p_mesa As Panel
|
|
Private b_abrirMesa As Button
|
|
Private cb_comensales As B4XComboBox
|
|
Dim cb_mesero As B4XComboBox
|
|
Private l_mesero As Label
|
|
Private l_comensales As Label
|
|
Private l_pago As Label
|
|
Private cb_pago As B4XComboBox
|
|
Private p_mesaCampos As Panel
|
|
Private p_mesasItem As Panel
|
|
Private l_comensalesAbierta2 As Label
|
|
Private l_meseroAbierta2 As Label
|
|
Private b_mesaEditar As Button
|
|
Private b_mesaCerrar As Button
|
|
Private p_mesaAbierta As Panel
|
|
Private lv_categorias As ListView
|
|
Private p_pago As Panel
|
|
Private Label1 As Label
|
|
Private b_pagoCerrar As Button
|
|
Dim reqManager As DBRequestManager
|
|
Private b_cierraAdmin As Button
|
|
Private b_cierreTotal As Button
|
|
Private p_cierreAdmin As Panel
|
|
Private et_inicioDia As EditText
|
|
Private l_inicioDia As Label
|
|
Private l_cierreAdmin As Label
|
|
Dim p_transparenteCierreAdmin As Panel
|
|
Private cd1 As ColorDrawable
|
|
Private p_botonesCierre As Panel
|
|
Private p_transparenteResumen As Panel
|
|
Private p_resumen As Panel
|
|
Private l_resumen As Label
|
|
Private sv_resumen As ScrollView
|
|
Dim su As StringUtils
|
|
Dim cs As CSBuilder
|
|
End Sub
|
|
|
|
'You can add more parameters here.
|
|
Public Sub Initialize As Object
|
|
Return Me
|
|
End Sub
|
|
|
|
'This event will be called once, before the page becomes visible.
|
|
Private Sub B4XPage_Created (Root1 As B4XView)
|
|
Root = Root1
|
|
'load the layout to Root
|
|
Root.LoadLayout("principal")
|
|
' p_principal.Width = Root.Width
|
|
' p_principal.Height = Root.Height
|
|
Subs.panelWH(p_principal, Root.Width, Root.Height)
|
|
Subs.panelWH(p_mesa, Root.Width, Root.Height - WobbleMenu1.Height)
|
|
If File.Exists(Starter.ruta, "kmt.db") = False Then
|
|
File.Copy(File.DirAssets, "kmt.db", Starter.ruta, "kmt.db")
|
|
End If
|
|
PCLV.Initialize(Me, "PCLV", clv_prods_ll)
|
|
PCLVM.Initialize(Me, "PCLVM", clv_mesas)
|
|
WobbleMenu1.SetTabTextIcon(1,"Mesas", Chr(0xF00A), Typeface.FONTAWESOME)
|
|
WobbleMenu1.SetTabTextIcon(2,"Meseros", Chr(0xF0C0), Typeface.FONTAWESOME)
|
|
WobbleMenu1.SetTabTextIcon(3,"Ordenes", Chr(0xF155), Typeface.FONTAWESOME)
|
|
' WobbleMenu1.SetTabTextIcon(5,"Cinco", Chr(0xF29D), Typeface.FONTAWESOME)
|
|
p_principal.Width = Root.Width
|
|
p_principal.Height = Root.Height
|
|
clv_prods_ll.GetBase.SetLayoutAnimated(0, 5dip, (l_meseroAbierta2.Top + l_meseroAbierta2.Height + 5), Root.Width + 10, Root.Height * 0.55) 'Cambiamos el tamaño y posición de la lista de productos.
|
|
clv_prods_ll.Base_Resize(clv_prods_ll.GetBase.Width, clv_prods_ll.GetBase.Height) 'Cambiamos el tamaño del panel interno de la lista para que se ajuste al nuevo tamaño.
|
|
clv_mesas.GetBase.SetLayoutAnimated(0, 5dip, 80dip, Root.Width - 20, Root.Height * 0.80) 'Cambiamos el tamaño y posición de la lista de mesas.
|
|
clv_mesas.Base_Resize(clv_mesas.GetBase.Width, clv_mesas.GetBase.Height) 'Cambiamos el tamaño del panel interno de las mesas para que se ajuste al nuevo tamaño.
|
|
p_meseros.Width = Root.Width
|
|
p_meseros.Height = Root.Height - WobbleMenu1.Height
|
|
p_mesas.Width = Root.Width
|
|
p_mesaAbierta.Height = Root.Height
|
|
p_mesas.Height = Root.Height - WobbleMenu1.Height
|
|
p_historial.Width = Root.Width
|
|
p_historial.Height = Root.Height - WobbleMenu1.Height
|
|
Subs.panelWH(p_transparenteCierreAdmin, Root.Width, Root.Height)
|
|
p_transparenteCierreAdmin.Top = 0 : p_transparenteCierreAdmin.left = 0
|
|
Subs.panelWH(p_transparenteResumen, Root.Width, Root.Height)
|
|
sv_resumen.Panel.LoadLayout("resumenCont")
|
|
Dim cs As CSBuilder
|
|
cs.Initialize
|
|
l_inicioDia.Text = cs.append("Para iniciar día, ingrese el texto ").bold.Append("INICIO DIA").Pop.Append(" y la tecla ").Bold.Append("Retorno").Pop.Append(" del teclado.").Color(Colors.red).Append(" Los datos del día anterior se borraran.").Popall
|
|
' p_botonesVenta.Top = Root.Height - p_botonesVenta.Height - WobbleMenu1.Height + 10
|
|
Subs.centraPanel(p_pago, p_mesaAbierta.Width)
|
|
Subs.centraBoton(b_abrirMesa, Root.Width)
|
|
b_mesaCerrar.Top = clv_prods_ll.AsView.top + clv_prods_ll.AsView.Height + 15 ' - b_mesaCerrar.Height
|
|
Subs.centraPanel(p_mesaCampos, Root.Width)
|
|
Subs.centraPanel(p_mesaAbierta, Root.Width)
|
|
lv_historial.Height = Root.Height * 0.7
|
|
p_botonesCierre.Top = lv_historial.Top + lv_historial.Height + 20dip
|
|
Subs.centraPanel(p_botonesCierre, p_historial.Width)
|
|
prodsMap.Initialize
|
|
listaProds.Initialize
|
|
listaHints.Initialize
|
|
listaHintsM.Initialize
|
|
p_mesas.Width = Root.Width
|
|
Subs.panelVisible(p_mesas, 0, 0)
|
|
cb_comensales.SetItems(Array As String(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20))
|
|
cb_pago.SetItems(Array As String("Tarjeta","Efectivo"))
|
|
cb_mesero.SetItems(Subs.traeMeserosLista)
|
|
End Sub
|
|
|
|
Sub B4XPage_Appear
|
|
reqManager.Initialize(Me, Starter.DBReqServer)
|
|
clv = clv_prods_ll
|
|
cuentaProds
|
|
LlenaMesas(Null, Null)
|
|
LlenaProdsLL(Null, Null)
|
|
PCLV.lblHint.SetTextSizeAnimated(0,13)
|
|
PCLV.B4XSeekBar1.Color1=Colors.DarkGray
|
|
PCLV.B4XSeekBar1.Color2=Colors.DarkGray
|
|
PCLV.B4XSeekBar1.ThumbColor=Colors.red
|
|
PCLV.B4XSeekBar1.Radius1 = 15
|
|
PCLV.B4XSeekBar1.Radius2 = 20
|
|
PCLV.B4XSeekBar1.mBase.Left=Root.Width * 0.85
|
|
PCLV.B4XSeekBar1.mBase.Width=50dip
|
|
' PCLV.B4XSeekBar1.mBase.Top=-50
|
|
PCLV.B4XSeekBar1.mBase.Height=clv_prods_ll.AsView.Height
|
|
PCLV.pnlOverlay.Height = clv_prods_ll.AsView.Height
|
|
PCLV.pnlOverlay.Width = clv_prods_ll.AsView.Width
|
|
PCLV.B4XSeekBar1.Update
|
|
If clv_mesas.Size > 0 Then
|
|
clv_mesas.JumpToItem(0) 'Vamos al primer artículo de la lista.
|
|
End If
|
|
PCLVM.lblHint.SetTextSizeAnimated(0,13)
|
|
PCLVM.B4XSeekBar1.Color1=Colors.DarkGray
|
|
PCLVM.B4XSeekBar1.Color2=Colors.DarkGray
|
|
PCLVM.B4XSeekBar1.ThumbColor=Colors.red
|
|
PCLVM.B4XSeekBar1.Radius1 = 15
|
|
PCLVM.B4XSeekBar1.Radius2 = 20
|
|
PCLVM.B4XSeekBar1.mBase.Left=Root.Width * 0.88
|
|
' PCLVM.B4XSeekBar1.mBase.Top=-50
|
|
PCLVM.B4XSeekBar1.mBase.Height=clv_mesas.AsView.Height
|
|
PCLVM.pnlOverlay.Height = clv_mesas.AsView.Height
|
|
PCLVM.pnlOverlay.Width = clv_mesas.AsView.Width
|
|
PCLVM.B4XSeekBar1.Update
|
|
p_meseros.Height = Root.Height - WobbleMenu1.Height
|
|
If p_mesas.Visible And Subs.revisaCierreAdmin Then p_transparenteCierreAdmin.Visible = True Else p_transparenteCierreAdmin.Visible = False
|
|
End Sub
|
|
|
|
Sub B4XPage_CloseRequest As ResumableSub
|
|
' BACK key pressed
|
|
'Return True to close, False to cancel
|
|
If p_pago.visible Then
|
|
p_pago.Visible = False
|
|
else If p_mesa.Visible Then
|
|
If Subs.revisaCierreAdmin Then p_transparenteCierreAdmin.Visible = True Else p_transparenteCierreAdmin.Visible = False
|
|
p_mesa.Visible = False
|
|
p_mesas.Visible = True
|
|
LlenaMesas(Null, Null)
|
|
Else if p_transparenteResumen.Visible Then
|
|
p_transparenteResumen.Visible = False
|
|
End If
|
|
Return False
|
|
End Sub
|
|
|
|
Sub b_prodMenos_Click
|
|
etCantHasFocus = False
|
|
clv = clv_prods_ll
|
|
' Log(Sender.As(Button).text & "|" & Sender.As(Button).tag)
|
|
Private buttonTag As String = Sender.As(Button).tag
|
|
LogColor("b_prodMenos_Click", Colors.Magenta)
|
|
Dim index As Int = clv.GetItemFromView(Sender)
|
|
LogColor(clv.GetValue(index), Colors.Magenta)
|
|
Private inv As Int = clv.GetValue(index).As(Map).Get("almacen")
|
|
Dim pnl0 As B4XView = clv.GetPanel(index)
|
|
Log(pnl0.As(Panel))
|
|
Dim pnl As B4XView = pnl0.GetView(0)
|
|
Dim laCant As B4XView = pnl.GetView(2).GetView(4) 'et_pCant
|
|
' Log(pnl.GetView(0).NumberOfViews)
|
|
Dim elNombre As B4XView = pnl.GetView(1)
|
|
If WobbleMenu1.GetCurrentTab = 3 Then laCant = pnl.GetView(2).GetView(4)
|
|
Log($"${pnl.GetView(1)}${CRLF}${pnl.GetView(2).GetView(2)}${CRLF}${pnl.GetView(2).GetView(3)}${CRLF}${pnl.GetView(2).GetView(4)}"$)
|
|
If buttonTag = "vendido" And laCant.Text > 0 Then
|
|
Log(clv.GetValue(index).As(Map))
|
|
clv.GetValue(index).As(Map).Put("almacen",inv + 1)
|
|
Log(clv.GetValue(index).As(Map))
|
|
End If
|
|
If laCant.Text = "" Then laCant.Text = 0
|
|
Log($"|${laCant.Text}|"$)
|
|
laCant.Text = $"$1.0{laCant.Text-1}"$
|
|
If laCant.Text < 0 Then laCant.Text = 0
|
|
Private tmpMap As Map = clv.GetValue(index).As(Map)
|
|
Private precio As String = clv.GetValue(index).As(Map).Get("precio")
|
|
Private id As String=clv.GetValue(index).As(Map).Get("id")
|
|
Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":Subs.traeAlmacen)
|
|
' Log(tmpMap)
|
|
prodsMap.Put(id, tmpMap)
|
|
If laCant.Text = 0 Then prodsMap.Remove(id)
|
|
Private nombreX As String = Subs.traeProdNombre(id)
|
|
Subs.actualizaProducto(precio, laCant.text, nombreX, id, Starter.ticketActual, Subs.traeFecha, Starter.meseroActual, Starter.mesaActual, 0, Starter.tipov, Starter.comensalesActuales)
|
|
cuentaProds
|
|
Dim cs As CSBuilder
|
|
cs.Initialize
|
|
If WobbleMenu1.GetCurrentTab = 3 Then
|
|
Private elTexto As String = clv.GetValue(index).As(Map).Get("prod")
|
|
Private elPrecioU As String = clv.GetValue(index).As(Map).Get("precio")
|
|
Private elTotal As String = elPrecioU * laCant.text
|
|
elNombre.Text = cs.Color(Colors.red).append(elTexto).pop.append(CRLF).Color(0xFF017F01).Append($"Precio $${NumberFormat2(elTotal, 1, 2, 2, True)}"$).Popall
|
|
End If
|
|
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
|
End Sub
|
|
|
|
Sub b_prodMas_Click
|
|
etCantHasFocus = False
|
|
clv = clv_prods_ll
|
|
Private buttonTag As String = Sender.As(Button).tag
|
|
Dim index As Int = clv.GetItemFromView(Sender)
|
|
LogColor("b_prodMas_Click", Colors.Magenta)
|
|
Dim pnl0 As B4XView = clv.GetPanel(index)
|
|
Dim pnl As B4XView = pnl0.GetView(0)
|
|
Dim laCant As B4XView = pnl.GetView(2).GetView(4) 'et_pCant
|
|
Dim elNombre As B4XView = pnl.GetView(1)
|
|
If WobbleMenu1.GetCurrentTab = 3 Then laCant = pnl.GetView(2).GetView(4)
|
|
Log($"${pnl.GetView(2).GetView(1)}${CRLF}${pnl.GetView(2).GetView(2)}${CRLF}${pnl.GetView(2).GetView(3)}${CRLF}${pnl.GetView(2).GetView(4)}"$)
|
|
If laCant.Text = "" Then laCant.Text = 0
|
|
Private precio As String=clv.GetValue(index).As(Map).Get("precio")
|
|
Private inv As Int = clv.GetValue(index).As(Map).Get("almacen")
|
|
Log($"|${laCant.Text}, ${inv}"$)
|
|
If buttonTag = "vendido" Then
|
|
If inv > 0 And (laCant.Text + 1 <= inv) Then
|
|
' Log(clv.GetValue(index).As(Map))
|
|
clv.GetValue(index).As(Map).Put("almacen", (inv - 1))
|
|
inv = inv - 1
|
|
laCant.Text = $"$1.0{laCant.Text+1}"$
|
|
' Log(clv.GetValue(index).As(Map))
|
|
End If
|
|
else If laCant.Text + 1 <= inv Then
|
|
laCant.Text = $"$1.0{laCant.Text + 1}"$
|
|
Log(Subs.totalPedido)
|
|
End If
|
|
Private id As String=clv.GetValue(index).As(Map).Get("id")
|
|
Private nombreX As String = Subs.traeProdNombre(id)
|
|
Private precioX As String = precio
|
|
Subs.actualizaProducto(precioX, laCant.text, nombreX, id, Starter.ticketActual, Subs.traeFecha, Starter.meseroActual, Starter.mesaActual, 0, Starter.tipov, Starter.comensalesActuales)
|
|
cuentaProds
|
|
Dim cs As CSBuilder
|
|
cs.Initialize
|
|
If WobbleMenu1.GetCurrentTab = 3 Then
|
|
Private elTexto As String = clv.GetValue(index).As(Map).Get("prod")
|
|
Private elPrecioU As String = clv.GetValue(index).As(Map).Get("precio")
|
|
Private elTotal As String = elPrecioU * laCant.text
|
|
elNombre.Text = cs.Color(Colors.red).append(elTexto).pop.append(CRLF).Color(0xFF017F01).Append($"Precio $${NumberFormat2(elTotal, 1, 2, 2, True)}"$).Popall
|
|
End If
|
|
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
|
End Sub
|
|
|
|
Sub cuentaProds
|
|
'LogColor($"Productos de la orden: ${c_prodsX.GetString("cantProds")}, Total: ${c_prodsX.GetString("costoTotal")}"$, Colors.red)
|
|
' Log("===========================")
|
|
Private c As Cursor = Starter.skmt.ExecQuery($"select sum(PE_COSTO_TOT) as total, sum(PE_CANT) as cant from PEDIDO where PE_TICKET IN (Select cuenta from cuentaa)"$)
|
|
' LogColor("TIEMPO cuentaProds =" & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
|
' LogColor(prodsMap, Colors.Magenta)
|
|
' p_botonesVenta.Visible = True
|
|
' p_botonesVenta.BringToFront
|
|
c.Position=0
|
|
' Log(Subs.totalPedido)
|
|
Private cant0 As String = "0"
|
|
Private total0 As String = "0"
|
|
If c.GetString("cant") <> Null And c.GetString("cant") <> "null" Then cant0 = c.GetString("cant")
|
|
If c.GetString("total") <> Null And c.GetString("total") <> "null" Then total0 = c.GetString("total")
|
|
Private p As Cursor = Starter.skmt.ExecQuery("select count(PT_TICKET) as ordenes from PEDIDO_TICKET where PT_PAGO <> 'VENTA'")
|
|
p.Position = 0
|
|
' Log($"Total Prods: ${cant0}, Total Compra: $$1.2{total0}"$)
|
|
' l_totalCarrito.text = $"Total: $${NumberFormat2(total0,1,2,2,True)}"$
|
|
c.Close
|
|
If WobbleMenu1.GetCurrentTab = 3 Then LlenaProdsLL(Null, Null)
|
|
If Subs.hayPedido Then WobbleMenu1.SetBadge(3, p.GetString("ordenes"), Colors.white, Colors.red) Else WobbleMenu1.RemoveBadge(3)
|
|
End Sub
|
|
|
|
Sub LlenaProdsLL(p As ResultSet, extra As String)
|
|
' Log("LlenaProdsLL")
|
|
listaProds.Initialize
|
|
hayPedido = Subs.hayPedido
|
|
' Log($"HAYPEDIDO: ${hayPedido}"$)
|
|
If hayPedido Then 'Si hay pedido obtenemos las cantidades de los productos para agregarlos al CLV.
|
|
Dim cantsMap As Map
|
|
cantsMap.Initialize
|
|
Dim pe As ResultSet = Starter.skmt.ExecQuery($"select PE_PROID, PE_CANT from PEDIDO where PE_TICKET = '${Starter.ticketActual}' and PE_MESA = '${Starter.mesaActual}' and PE_TIPO = 'VENTA'"$)
|
|
'Si EXTRA es igual a rmi, entonces regresamos los RMIs existentes.
|
|
If extra = "rmi" Then pe = Starter.skmt.ExecQuery($"select PE_PROID, PE_CANT from PEDIDO where PE_TICKET = '${Starter.ticketActual}' and PE_MESA = 'DUR'"$)
|
|
' LogColor("Ponemos productos de pedido anterior: "&pe.RowCount, Colors.red)
|
|
Do While pe.NextRow
|
|
Private cant As Int = 0
|
|
cantsMap.put(pe.GetString("PE_PROID"), pe.GetString("PE_CANT"))
|
|
Loop
|
|
' Log($"Con pedido: ${pe.RowCount}"$)
|
|
' Log("CANTSMAP: " & cantsMap)
|
|
pe.Close
|
|
End If
|
|
' Log(p.IsInitialized)
|
|
If query = "" Or query = Null Then query = "cat_gunaprod2"
|
|
If p.IsInitialized Then
|
|
Log($"YA HAY RESULSET ${p.RowCount}"$)
|
|
Else
|
|
' Log("NO HAY RESULSET")
|
|
Dim p As ResultSet = Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPOPROD, CAT_GP_IMG from cat_gunaprod where CAT_GP_PRECIO > 0 And CAT_GP_CLASIF <> 'PROMOS' order by CAT_GP_NOMBRE"$)
|
|
End If
|
|
' Log(p.RowCount)
|
|
Do While p.NextRow
|
|
Private cant As Int = 0
|
|
' Dim ins As InputStream
|
|
' Dim bmp As Bitmap
|
|
' Dim jpeg() As Byte
|
|
' jpeg = p.GetBlob("CAT_GP_IMG")
|
|
' ins.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
|
|
' bmp.Initialize2(ins)
|
|
If hayPedido And cantsMap.ContainsKey(p.GetString("CAT_GP_ID")) Then cant = cantsMap.Get(p.GetString("CAT_GP_ID"))
|
|
Dim tempMap As Map = CreateMap("prod":p.GetString("CAT_GP_NOMBRE"), "precio":p.GetString("CAT_GP_PRECIO"), "almacen":p.GetString("CAT_GP_ALMACEN"), "id":p.GetString("CAT_GP_ID"), "cant":cant, "img":Null)
|
|
listaProds.Add(tempMap)
|
|
' Log($"${p.GetString("CAT_GP_ID")}, ${p.GetString("CAT_GP_NOMBRE")}, ${cant}"$)
|
|
Loop
|
|
p.Close
|
|
' Log("LISTAPRODS: " & listaProds)
|
|
PCLV.Commit
|
|
clv_prods_ll.Clear
|
|
Private listaProdsConCant, listaProdsConCantIndex As List
|
|
listaProdsConCant.Initialize
|
|
listaProdsConCantIndex.Initialize
|
|
listaHints.Initialize
|
|
' Log(listaProds)
|
|
For q = 0 To listaProds.Size - 1' Sacamos los productos con cantidad previa.
|
|
If listaProds.Get(q).As(Map).Get("cant").As(Int) <> 0 Then
|
|
' Log(listaProds.Get(q).As(Map).Get("prod"))
|
|
listaProdsConCant.Add(listaProds.Get(q))
|
|
listaProdsConCantIndex.Add(q)
|
|
End If
|
|
Next
|
|
' Log("PRODCONCANT: " & listaProdsConCant)
|
|
' Log(listaProdsConCantIndex)
|
|
Private cont As Int = 0
|
|
For pr0=0 To listaProdsConCant.Size - 1 'Agregamos los productos con cantidad previa.
|
|
Private Pnl As B4XView = xui.CreatePanel("")
|
|
Pnl.SetLayoutAnimated(0, 0, 0, clv_prods_ll.AsView.Width, 70dip)
|
|
clv_prods_ll.Add(Pnl, listaProdsConCant.Get(pr0))
|
|
listaHints.Add(listaProdsConCant.get(pr0).As(Map).Get("prod"))
|
|
cont = cont + 1
|
|
Next
|
|
' LogColor(clv_prods_ll.Size, Colors.red)
|
|
' Log(listaProds.Size)
|
|
For pr = 0 To listaProds.Size - 1
|
|
If listaProdsConCantIndex.IndexOf(pr) = -1 Then
|
|
Private Pnl As B4XView = xui.CreatePanel("")
|
|
If listaProds.Get(pr).As(Map).Get("almacen") < 1 Then
|
|
' Log("EN CERO" & listaProds.Get(pr).As(Map).Get("prod") & "|" & listaProds.Get(pr).As(Map).Get("almacen"))
|
|
Else
|
|
Pnl.SetLayoutAnimated(0, 0, 0, clv_prods_ll.AsView.Width, 70dip)
|
|
' Log(listaProds.Get(pr))
|
|
clv_prods_ll.Add(Pnl, listaProds.Get(pr))
|
|
listaHints.Add(listaProds.get(pr).As(Map).Get("prod"))
|
|
cont = cont + 1
|
|
End If
|
|
End If
|
|
Next
|
|
If clv_prods_ll.Size > 0 Then
|
|
clv_prods_ll.JumpToItem(0) 'Vamos al primer artículo de la lista.
|
|
End If
|
|
PCLV.B4XSeekBar1.MaxValue = clv_prods_ll.Size
|
|
PCLV.B4XSeekBar1.MinValue = 0
|
|
PCLV.B4XSeekBar1.Interval = clv_prods_ll.Size/20
|
|
PCLV.B4XSeekBar1.Value = clv_prods_ll.Size
|
|
PCLV.B4XSeekBar1.Update
|
|
' Log($"Min:0, max:${clv_prods_ll.Size}, Interval:${clv_prods_ll.Size/20}"$)
|
|
reiniciarlistaProds = False
|
|
End Sub
|
|
|
|
Private Sub clv_prods_ll_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
|
|
' Private inicioContador As String = DateTime.Now
|
|
' Log($"clv_prods_ll_VisibleRangeChanged : ${FirstIndex}, ${LastIndex} "$)
|
|
Dim ExtraSize As Int = 30 'List size
|
|
For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, clv_prods_ll.Size - 1)
|
|
Dim Pnl As B4XView = clv_prods_ll.GetPanel(i)
|
|
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
|
|
' Log(listaRenglones)
|
|
' Log(clv_prods_ll.GetValue(i))
|
|
If Pnl.NumberOfViews = 0 Then 'Add each item/layout to the list/main layout
|
|
Pnl.LoadLayout("proditem")
|
|
' p_botMasMen.Left = (p_prods.Width * 0.66) - (p_botMasMen.Width / 2)
|
|
p_prods.Width = Root.Width * 0.99
|
|
' p_botMasMen.Left = p_prods.Width - (p_botMasMen.Width + 5)
|
|
' Log(Root.Width)
|
|
p_botMasMen.Left = (p_prods.Width - p_botMasMen.Width - 75)
|
|
' Log(p_botMasMen.left)
|
|
Private cs As CSBuilder
|
|
cs.Initialize
|
|
l_prodX.SetTextSizeAnimated(0, 13)
|
|
If clv_prods_ll.GetValue(i).As(Map).Get("cant") <> Null And clv_prods_ll.GetValue(i).As(Map).Get("cant") > 0 Then
|
|
p_prods.Color=0xFFE2EEFF
|
|
et_pCant.TextColor=Colors.Red
|
|
' Log("VENDIDO ")
|
|
b_prodMenos.Tag = "vendido"
|
|
b_prodMas.Tag = "vendido"
|
|
End If
|
|
Private precio As String=NumberFormat2(clv_prods_ll.GetValue(i).As(Map).Get("precio").As(Double),1,2,2,False)
|
|
If clv_prods_ll.GetValue(i).As(Map).Get("cant") <> Null Then et_pCant.Text = clv_prods_ll.GetValue(i).As(Map).Get("cant")
|
|
l_prodX.Text = cs.Color(Colors.red).append(clv_prods_ll.GetValue(i).As(Map).Get("prod")).pop.append(CRLF).Color(0xFF017F01).Append($"Precio $${NumberFormat2(precio, 1, 2, 2, True)}"$).Popall
|
|
l_prodX.Tag = clv_prods_ll.GetValue(i).As(Map).Get("almacen")
|
|
l_pCant.Tag = clv_prods_ll.GetValue(i).As(Map).Get("id")
|
|
' Log(clv_prods_ll.GetValue(i).As(Map).Get("id"))
|
|
' Private rs_img As ResultSet = Starter.skmt.ExecQuery($"select CAT_GP_IMG from cat_gunaprod where CAT_GP_ID = '${clv_prods_ll.GetValue(i).As(Map).Get("id")}'"$)
|
|
i_prod.Bitmap = clv_prods_ll.GetValue(i).As(Map).Get("img")
|
|
End If
|
|
' Log($"${i}, ${FirstIndex}, ${LastIndex}, ${Pnl.NumberOfViews}. ${clv_prods_ll.Size}"$)
|
|
Else 'Not visible
|
|
' If Pnl.NumberOfViews > 0 Then
|
|
' Pnl.RemoveAllViews 'Remove none visable item/layouts from the list/main layout
|
|
' End If
|
|
End If
|
|
PCLV.B4XSeekBar1.Value = clv_prods_ll.Size - FirstIndex
|
|
' Log($"Bar value: ${PCLV.B4XSeekBar1.Value}"$)
|
|
Next
|
|
End Sub
|
|
|
|
Sub et_busca_TextChanged (Old As String, New As String)
|
|
'' Private inicioContador As String = DateTime.Now
|
|
' If New.Length = 1 And Not(forzarBusqueda) Then Return
|
|
' forzarBusqueda = False
|
|
' If lfila.text = "PROMOCIONES" Then
|
|
'' If Not(lv_promos.Visible) Then lv_promos.Visible = True
|
|
'' Private cPromo As Cursor=Starter.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from ${query} where CAT_GP_NOMBRE like '%${New}%' and CAT_GP_ALMACEN > 0 AND CAT_GP_TIPO = 'PROMOS' AND CAT_GP_SUBTIPO = 'PROMOS' AND CAT_GP_TIPOPROD <> 1 and (length(CAT_GP_CODPROMO) = 1 OR CAT_GP_CODPROMO = CAT_GP_ID)"$)
|
|
'' Log($"res:${cPromo.RowCount}"$)
|
|
'' If cPromo.RowCount > 0 Then
|
|
'' lv_promos.Clear
|
|
'' For i=0 To cPromo.RowCount -1
|
|
'' cPromo.Position=i
|
|
'' Private tm As Map = Subs.procesaPromocion(cPromo.GetString("CAT_GP_ID"), ticketId)
|
|
'' If tm.Get("status") = "ok" Then 'Solo muestrala si hay producto.
|
|
'' lv_promos.AddTwoLines(cPromo.GetString("CAT_GP_NOMBRE"),"# " & cPromo.GetString("CAT_GP_ALMACEN") & " $ " & cPromo.GetString("CAT_GP_PRECIO") & " F:" & tm.Get("mp").As(Map).Get("prodsFijosCant") & " V:" & tm.Get("mp").As(Map).Get("prodsVariablesCant"))
|
|
'' End If
|
|
'' Next
|
|
'' Else
|
|
'' ToastMessageShow("No hay promociones disponibles.", False)
|
|
'' End If
|
|
'' cPromo.Close
|
|
' Else
|
|
' If Not(clv_prods_ll.AsView.Visible) Then clv_prods_ll.AsView.Visible = True
|
|
' clv_prods_ll.Clear
|
|
' listaProds.Initialize
|
|
' listaHints.Initialize
|
|
' Sleep(0)
|
|
' Dim p As ResultSet = Starter.skmt.ExecQuery($"Select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPOPROD, CAT_GP_IMG from cat_gunaprod where CAT_GP_NOMBRE like '%${New}%' and CAT_GP_PRECIO > 0 And CAT_GP_CLASIF <> 'PROMOS' order by CAT_GP_NOMBRE"$)
|
|
' Log($"Llamamos LlenaProdsLL con ${p.RowCount} registros"$)
|
|
' LlenaProdsLL(p, Null)
|
|
' p.Close
|
|
' End If
|
|
End Sub
|
|
|
|
Sub llenaCarrito 'ignore
|
|
' Private totalPedido As String = 0
|
|
' Private cantPedido As String = 0
|
|
' p_mesas.Visible = False
|
|
'' Subs.agrupador
|
|
'' lv_carrito.Clear
|
|
' clv_carrito.Clear
|
|
' list_prodsPedido.Initialize
|
|
' Private c_prods As Cursor=Starter.skmt.ExecQuery("select PE_PRONOMBRE,PE_COSTO_TOT, PE_COSTOU, PE_CANT, PE_FOLIO, PE_CEDIS, PE_PROID FROM PEDIDO WHERE PE_TICKET IN (Select CUENTA from cuentaa) order by PE_CEDIS, PE_PRONOMBRE")
|
|
'' Log(c_prods.RowCount)
|
|
' If c_prods.RowCount > 0 Then
|
|
' c_prods.Position = 0
|
|
'' lv_carrito.BringToFront
|
|
' clv_carrito.AsView.BringToFront
|
|
' Private cs As CSBuilder
|
|
' For i = 0 To c_prods.RowCount -1
|
|
' cs.Initialize
|
|
' c_prods.Position = i
|
|
'' Dim label1 As Label
|
|
'' lv_carrito.TwoLinesLayout.ItemHeight = 50dip
|
|
'' label1 = lv_carrito.TwoLinesLayout.Label
|
|
'' label1.TextSize = 15
|
|
'' label1.TextColor = Colors.Black
|
|
'' label1.color = Colors.White
|
|
'' label1.Height = 30dip
|
|
' Private textColor As Int = Colors.black 'ignore
|
|
'' Log(c_prods.GetString("PE_CEDIS"))
|
|
' If Not(IsNumber(c_prods.GetString("PE_CEDIS"))) Then textColor = Colors.RGB(210,105,30) 'Si es promo, cambiamos el color del texto.
|
|
' If c_prods.GetString("PE_CEDIS") = "DUR" Then textColor = Colors.red 'Si es promo, cambiamos el color del texto.
|
|
'' Dim label2 As Label
|
|
'' label2 = lv_carrito.TwoLinesLayout.SecondLabel
|
|
'' label2.TextSize = 10
|
|
'' label2.TextColor = Colors.Blue
|
|
'' label2.Tag = i
|
|
'' Log(c_prods.GetString("PE_PRONOMBRE"))
|
|
'' lv_carrito.AddTwoLines(cs.Color(textColor).append(c_prods.GetString("PE_PRONOMBRE")).pop,"Cantidad #"& c_prods.GetString("PE_CANT")& " SubTotal $"& c_prods.GetString("PE_COSTO_TOT")& " Folio "& c_prods.GetString("PE_FOLIO"))
|
|
' Private tempMap As Map = CreateMap("prod":c_prods.GetString("PE_PRONOMBRE"), "almacen":1000, "id": c_prods.GetString("PE_PROID"), "cant": c_prods.GetString("PE_CANT"), "precio": c_prods.GetString("PE_COSTOU"), "precioT": c_prods.GetString("PE_COSTO_TOT"))
|
|
' list_prodsPedido.Add(tempMap)
|
|
'' Private bmp As Bitmap = Subs.traeImgDeDB(c_prods.GetString("PE_PROID"))
|
|
'' Private elTexto As String = cs.Color(Colors.red).append(c_prods.GetString("PE_PRONOMBRE")).pop.append(CRLF).Color(0xFF017F01).Append($"Precio $${NumberFormat2(c_prods.GetString("PE_COSTO_TOT"), 1, 2, 2, True)}"$).Popall
|
|
' clv_carrito.Add(CreateListItem(c_prods.GetString("PE_PRONOMBRE"), c_prods.GetString("PE_CANT"), c_prods.GetString("PE_COSTO_TOT"), 1000, clv_carrito.AsView.Width, 150dip, Null, c_prods.GetString("PE_PROID")), tempMap)
|
|
' folio = 0
|
|
' totalPedido = totalPedido + (c_prods.GetString("PE_COSTOU") * c_prods.GetString("PE_CANT"))
|
|
' cantPedido = cantPedido + c_prods.GetString("PE_CANT")
|
|
' If c_prods.GetString("PE_FOLIO") <> Null Then folio = c_prods.GetString("PE_FOLIO")
|
|
' Next
|
|
' Else
|
|
' l_carritoVacio.Visible = True
|
|
' l_carritoVacio.Text = "No hay productos en tu carrito."
|
|
' End If
|
|
'' Log(list_prodsPedido)
|
|
' c_prods.Close
|
|
'' l_total2.Text = $"$1.2{totalPedido}"$
|
|
'' l_cant.Text = cantPedido
|
|
'' If Subs.revisaImpresa Then b_rechazar.Visible = False Else b_rechazar.Visible = True
|
|
'' p_vistaPreviaTrans.Width = Root.Width
|
|
'' p_vistaPreviaTrans.Height = Root.Height
|
|
'' Subs.centraPanel(p_vistaPrevia, Root.Width)
|
|
'' p_vistaPrevia.Visible=True
|
|
'' p_vistaPreviaTrans.Visible=True
|
|
End Sub
|
|
|
|
'Return the hint that will be displayed when the user fast scrolls the list. It can be a string or CSBuilder.
|
|
Sub PCLV_HintRequested(Index As Int) As Object
|
|
Dim word As String = listaHints.get(Index)
|
|
Return word
|
|
End Sub
|
|
|
|
'Return the hint that will be displayed when the user fast scrolls the list. It can be a string or CSBuilder.
|
|
Sub PCLVM_HintRequested(Index As Int) As Object
|
|
Dim word As String = listaHintsM.get(Index)
|
|
Return word
|
|
End Sub
|
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
|
|
|
Private Sub WobbleMenu1_Tab1Click
|
|
If Subs.revisaCierreAdmin Then p_transparenteCierreAdmin.Visible = True Else p_transparenteCierreAdmin.Visible = False
|
|
LlenaMesas(Null, Null)
|
|
' LlenaProdsLL(Null, Null)
|
|
Subs.panelVisible(p_mesas, 0, 0)
|
|
PCLVM.B4XSeekBar1.mBase.Visible = True
|
|
PCLV.B4XSeekBar1.mBase.Visible = False
|
|
p_meseros.Visible = False
|
|
' p_carrito.Visible = False
|
|
p_historial.Visible = False
|
|
p_mesa.Visible = False
|
|
End Sub
|
|
|
|
Private Sub WobbleMenu1_Tab2Click
|
|
LlenaProdsLL(Null, Null)
|
|
PCLVM.B4XSeekBar1.mBase.Visible = False
|
|
PCLV.B4XSeekBar1.mBase.BringToFront
|
|
PCLV.B4XSeekBar1.mBase.Visible = True
|
|
Subs.panelVisible(p_meseros, 0, 0)
|
|
p_mesas.Visible = False
|
|
' p_carrito.Visible = False
|
|
p_transparenteCierreAdmin.Visible = False
|
|
p_historial.Visible = False
|
|
p_mesa.Visible = False
|
|
End Sub
|
|
|
|
Private Sub WobbleMenu1_Tab3Click
|
|
Subs.panelVisible(p_historial, 0, 0)
|
|
p_meseros.Visible = False
|
|
' p_carrito.Visible = False
|
|
p_mesas.Visible = False
|
|
p_mesa.Visible = False
|
|
p_transparenteCierreAdmin.Visible = False
|
|
If Subs.revisaCierreAdmin Then
|
|
cd1.Initialize(Colors.gray, 10dip)
|
|
b_cierraAdmin.Background = cd1
|
|
Else
|
|
cd1.Initialize(Colors.red, 10dip)
|
|
b_cierraAdmin.Background = cd1
|
|
End If
|
|
llenaHistorial
|
|
End Sub
|
|
|
|
'Private Sub WobbleMenu1_Tab4Click
|
|
' PCLVM.B4XSeekBar1.mBase.Visible = False
|
|
' PCLV.B4XSeekBar1.mBase.Visible = False
|
|
' Subs.panelVisible(p_carrito, 0, 0)
|
|
' p_carrito.BringToFront
|
|
'' p_carrito.BringToFront
|
|
' p_meseros.Visible = False
|
|
' p_mesas.Visible = False
|
|
' p_historial.Visible = False
|
|
' l_carritoVacio.Visible = False
|
|
' l_compraTerminada.Visible = False
|
|
' p_mesa.Visible = False
|
|
' llenaCarrito
|
|
' If clv_carrito.Size > 0 Then p_botonesCarrito.Visible = True Else p_botonesCarrito.Visible = False
|
|
'End Sub
|
|
|
|
Private Sub b_continuar_Click
|
|
WobbleMenu1.SetCurrentTab(2)
|
|
End Sub
|
|
|
|
'Private Sub p_botonesVenta_Click
|
|
'
|
|
'End Sub
|
|
|
|
Private Sub lv_promos_ItemClick (Position As Int, Value As Object)
|
|
|
|
End Sub
|
|
|
|
Private Sub p_historial_Click
|
|
'Para evitar que el clic en pantalla no se siga hacia atras
|
|
End Sub
|
|
|
|
Private Sub p_carrito_Click
|
|
'Para evitar que el clic en pantalla no se siga hacia atras
|
|
End Sub
|
|
|
|
Private Sub b_terminar_Click
|
|
DateTime.DateFormat= $"yyMMdd-HHmmss-${Starter.ticketActual}"$
|
|
Private id As String = DateTime.Date(DateTime.Now)
|
|
Starter.skmt.ExecNonQuery($"insert into cat_hist_compras (H_IDCOMPRA, H_FOLIO, H_MESA, H_CEDIS, H_COSTO_TOT, H_COSTOU, H_CANT, H_PRONOMBRE, H_PROID, H_TICKET, H_FECHA) select '${id}', PE_FOLIO, PE_MESA, PE_CEDIS, PE_COSTO_TOT, PE_COSTOU, PE_CANT, PE_PRONOMBRE, PE_PROID, PE_TICKET, PE_FECHA from pedido where PE_TICKET = '${Starter.ticketActual}'"$)
|
|
Starter.skmt.ExecNonQuery($"delete from pedido where PE_TICKET = '${Starter.ticketActual}'"$)
|
|
LlenaProdsLL(Null, Null)
|
|
l_compraTerminada.Text = $"¡Felicidades!${CRLF}${CRLF}Tu compra con número de orden ${id} ha sido registrada.${CRLF}${CRLF}Llegará en tu siguiente día de entrega."$
|
|
l_compraTerminada.Visible = True
|
|
l_compraTerminada.BringToFront
|
|
End Sub
|
|
|
|
Sub llenaHistorial
|
|
Dim rs_hist As ResultSet = Starter.skmt.ExecQuery($"Select * from pedido_ticket where PT_PAGO <> 'VENTA' order by PT_PAGO, PT_TICKET"$)
|
|
If rs_hist.RowCount > 0 Then
|
|
l_historialVacio.Visible = False
|
|
Private cs As CSBuilder
|
|
lv_historial.Clear
|
|
lv_historial.Visible = True
|
|
Do While rs_hist.NextRow
|
|
cs.Initialize
|
|
Dim Label1 As Label
|
|
Label1 = lv_historial.TwoLinesLayout.Label
|
|
Label1.TextSize = 16
|
|
Private elColor As Int = Colors.Red
|
|
If rs_hist.GetString("PT_PAGO") = "TARJETA" Then elColor = Colors.RGB(0,0,122)
|
|
Label1.color = Colors.White
|
|
Label1.Height = 30dip
|
|
Dim label2 As Label
|
|
label2 = lv_historial.TwoLinesLayout.SecondLabel
|
|
label2.TextSize = 14
|
|
label2.TextColor = Colors.RGB(1,127,1)
|
|
Private fecha As String = rs_hist.GetString("PT_FECHA")
|
|
fecha = fecha.SubString2(1,10)
|
|
lv_historial.AddTwoLines(cs.Color(elColor).Append("Orden: " & rs_hist.GetString("PT_TICKET") & " - Mesa: " & rs_hist.GetString("PT_MESA")).PopAll, $"Fecha: ${fecha}, Productos: ${rs_hist.GetString("PT_NOART")}, Total: $${NumberFormat2(rs_hist.GetString("PT_MONTO"), 1, 2, 2, True)}"$)
|
|
Loop
|
|
Else
|
|
lv_historial.Visible = False
|
|
l_historialVacio.Visible = True
|
|
l_historialVacio.Text = "No hay ordenes en tu historial."
|
|
End If
|
|
rs_hist.Close
|
|
End Sub
|
|
|
|
Sub CreateListItem(Text As String, cant As Int, precioU As String, inv As Int, Width As Int, Height As Int, img As Bitmap, prodId As String) As Panel 'ignore
|
|
' Dim p As B4XView = xui.CreatePanel("")
|
|
' Dim cs As CSBuilder
|
|
' cs.Initialize
|
|
' p.SetLayoutAnimated(0, 0, 0, Width, Height)
|
|
' p.LoadLayout("prodItemCarrito")
|
|
'' i_prod.Bitmap = img
|
|
' l_prodX.TextSize = 15
|
|
' p_prods.Height = Height
|
|
' p_prods.Width = Width - 10
|
|
'' Log($"${clv_carrito.AsView.Width}, ${Root.Width}, ${p_prods.Width}"$)
|
|
' p_botMasMen.Left = p_prods.Width - (p_botMasMen.Width - 75)
|
|
' l_prodX.Height = Height
|
|
' l_prodX.Text = Text&CRLF&"# " & inv & " $ " & precioU
|
|
' l_prodX.Text = cs.Color(Colors.red).append(Text).pop.append(CRLF).Color(0xFF017F01).Append($"Precio $${NumberFormat2(precioU, 1, 2, 2, True)}"$).Popall
|
|
' l_prodX.Tag = $"ID: ${prodId}${CRLF}${Text}${CRLF}Precio: $$1.2{precioU}${CRLF}Inv: ${inv} pzs"$
|
|
' l_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
|
' et_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
|
' et_pCant.Text = cant
|
|
' et_pCant.BringToFront
|
|
' Return p
|
|
End Sub
|
|
|
|
Private Sub b_borrar_Click
|
|
' clv = clv_carrito
|
|
'' Private buttonTag As String = Sender.As(Button).tag
|
|
' Dim index As Int = clv.GetItemFromView(Sender)
|
|
' Msgbox2Async("¿Seguro que deseas borrar este producto?", "Borrar Producto", "Si", "", "No", Null, False)
|
|
' Wait For Msgbox_Result (Result As Int)
|
|
' If Result = DialogResponse.POSITIVE Then
|
|
' LogColor("b_borrar_Click", Colors.Magenta)
|
|
' Private precio As String=clv.GetValue(index).As(Map).Get("precio")
|
|
'' Private inv As Int = clv.GetValue(index).As(Map).Get("almacen")
|
|
' Dim pnl0 As B4XView = clv.GetPanel(index)
|
|
' Dim pnl As B4XView = pnl0.GetView(0)
|
|
' Dim laCant As B4XView = pnl.GetView(2).GetView(2)
|
|
' If WobbleMenu1.GetCurrentTab = 3 Then laCant = pnl.GetView(2).GetView(4)
|
|
' Log(laCant.text)
|
|
' laCant.Text = "0"
|
|
' Private id As String=clv.GetValue(index).As(Map).Get("id")
|
|
'' Private almacenX As String = Subs.traeAlmacen
|
|
' Private nombreX As String = Subs.traeProdNombre(id)
|
|
' Private precioX As String = precio
|
|
' Subs.actualizaProducto(precioX, laCant.text, nombreX, id, Starter.ticketActual, Subs.traeFecha, Starter.meseroActual, Starter.mesaActual, 0, Starter.tipov, Starter.comensalesActuales)
|
|
'' Log($"${almacenX}, ${precioX}, ${laCant.text}, ${nombreX}, ${id}, ${Starter.ticketActual}, ${Subs.traeFecha}, ${Subs.traeUsuarioDeBD}, ${rutaUsuario}, 0, ${Starter.tipov}"$)
|
|
' cuentaProds
|
|
' llenaCarrito
|
|
' End If
|
|
End Sub
|
|
|
|
Private Sub lv_historial_ItemClick (Position As Int, Value As Object)
|
|
|
|
End Sub
|
|
|
|
Private Sub clv_mesas_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
|
|
' Log($"clv_mesa_VisibleRangeChanged : ${FirstIndex}, ${LastIndex} "$)
|
|
Dim ExtraSize As Int = 30 'List size
|
|
Private m As Map
|
|
For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, clv_mesas.Size - 1)
|
|
Dim Pnl As B4XView = clv_mesas.GetPanel(i)
|
|
m = clv_mesas.GetValue(i)
|
|
If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
|
|
If Pnl.NumberOfViews = 0 Then 'Add each item/layout to the list/main layout
|
|
Pnl.LoadLayout("mesasItem")
|
|
p_mesasItem.Width = Root.Width * 0.99
|
|
Private cs As CSBuilder
|
|
cs.Initialize
|
|
l_mesaX.SetTextSizeAnimated(0, 13)
|
|
l_estatus.text = "DISPONIBLE"
|
|
' Log(m)
|
|
If m.Get("estatus") = "ABIERTA" Then l_estatus.Text = "ABIERTA"
|
|
' Log(m)
|
|
If l_estatus.text = "ABIERTA" Then
|
|
l_mesaX.Text = cs.Color(Colors.red).Size(16).Append($"Mesa ${m.Get("id")}"$).pop.append(CRLF).Color(0xFF017F01).Append($"Comensales ${m.Get("comensales")}"$).Append(" - Mesero ").pop.Color(Colors.red).append(m.Get("mesero")).pop.append(CRLF).Color(Colors.black).Append($"Subtotal. $${NumberFormat2(m.Get("subtotal"), 1,2,2,True)} - Articulos: ${m.Get("articulos")}"$).Popall
|
|
Else
|
|
l_mesaX.Text = cs.Color(Colors.red).Size(16).Append($"Mesa ${m.Get("id")}"$).Popall
|
|
End If
|
|
l_mesaX.Tag = m
|
|
p_mesasItem.Tag = m
|
|
End If
|
|
Else 'Not visible
|
|
' If Pnl.NumberOfViews > 0 Then
|
|
' Pnl.RemoveAllViews 'Remove none visable item/layouts from the list/main layout
|
|
' End If
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
Sub LlenaMesas(p As ResultSet, extra As String) 'ignore
|
|
Private o As Cursor = Starter.skmt.ExecQuery("select count(PT_TICKET) as ordenes from PEDIDO_TICKET where PT_PAGO <> 'VENTA'")
|
|
o.Position = 0
|
|
If o.GetInt("ordenes") > 0 Then WobbleMenu1.SetBadge(3, o.GetInt("ordenes"), Colors.white, Colors.red) Else WobbleMenu1.RemoveBadge(3)
|
|
Dim p As ResultSet = Starter.skmt.ExecQuery($"select *, IFNULL(M_ESTATUS, 'CERRADA') as ESTATUS2, IFNULL(M_MESERO, 'NINGUNO') as MESERO, IFNULL(M_COMENSALES, 0) as COMENSALES from cat_mesas"$)
|
|
' Log(p.RowCount)
|
|
PCLVM.Commit
|
|
clv_mesas.Clear
|
|
Private m_mesas As Map
|
|
m_mesas.Initialize
|
|
Do While p.NextRow
|
|
Private SUBTOTAL2 As String = "0"
|
|
Private NO_ARTS2 As String = "0"
|
|
' Log(p.GetString("ESTATUS2"))
|
|
If p.GetString("ESTATUS2") = "ABIERTA" Then
|
|
' Log($"PT_TICKET = '${p.GetString("M_TICKET")}' and PT_MESA = '${p.GetString("M_ID")}"$)
|
|
Private pt As Cursor = Starter.skmt.ExecQuery($"select ifnull(sum(PT_MONTO),0) as SUBTOTAL, ifnull(sum(PT_NOART), 0) as NO_ARTS from PEDIDO_TICKET where PT_TICKET = '${p.GetString("M_TICKET")}' and PT_MESA = '${p.GetString("M_ID")}' and PT_PAGO = 'VENTA'"$)
|
|
If pt.RowCount > 0 Then
|
|
pt.Position = 0
|
|
SUBTOTAL2 = pt.GetString("SUBTOTAL")
|
|
NO_ARTS2 = pt.GetString("NO_ARTS")
|
|
End If
|
|
End If
|
|
' Log($"${SUBTOTAL2}, ${NO_ARTS2}"$)
|
|
Dim tempMap As Map = CreateMap("id":p.GetString("M_ID"), "numero":p.GetString("M_NUMERO"), "nombre":p.GetString("M_NOMBRE"), "zona":p.GetString("M_ZONA"), "ticket":p.GetString("M_TICKET"), "estatus":p.GetString("ESTATUS2"), "mesero":p.GetString("MESERO"), "comensales":p.GetString("COMENSALES"), "subtotal":SUBTOTAL2, "articulos":NO_ARTS2)
|
|
' m_mesas.Put(p.GetString("M_ID"), tempMap)
|
|
Private Pnl As B4XView = xui.CreatePanel("")
|
|
Pnl.SetLayoutAnimated(0, 0, 0, clv_mesas.AsView.Width, 70dip)
|
|
clv_mesas.Add(Pnl, tempMap)
|
|
listaHintsM.Add($"Mesa ${p.GetString("M_ID")}"$)
|
|
Loop
|
|
p.Close
|
|
PCLVM.B4XSeekBar1.MaxValue = clv_mesas.Size
|
|
PCLVM.B4XSeekBar1.MinValue = 0
|
|
PCLVM.B4XSeekBar1.Interval = clv_mesas.Size/20
|
|
PCLVM.B4XSeekBar1.Value = clv_mesas.Size
|
|
PCLVM.B4XSeekBar1.Update
|
|
reiniciarlistaProds = False
|
|
End Sub
|
|
|
|
'Entramos a la mesa seleccionada.
|
|
Private Sub p_mesasItem_Click
|
|
Log(Sender.As(Panel).tag)
|
|
b_abrirMesa.Text = "Abrir Mesa"
|
|
Subs.panelVisible(p_mesa, 0, 0)
|
|
Private m As Map = Sender.As(Panel).tag
|
|
Starter.mesaActual = m.Get("id")
|
|
Starter.meseroActual = m.Get("mesero")
|
|
Starter.ticketActual = m.Get("ticket")
|
|
Starter.comensalesActuales = m.Get("comensales")
|
|
l_mesa.Text = $"MESA NO. ${m.Get("id")}"$
|
|
Log(m)
|
|
b_mesaCerrar.Tag = m
|
|
Starter.skmt.ExecNonQuery("delete from cuentaa")
|
|
Starter.skmt.ExecNonQuery($"insert into cuentaa (cuenta) values ('${m.Get("ticket")}')"$)
|
|
LlenaProdsLL(Null, Null)
|
|
p_mesas.Visible = False
|
|
cb_mesero.SelectedIndex = 0
|
|
cb_pago.SelectedIndex = 0
|
|
cb_comensales.SelectedIndex = 0
|
|
' Private mesero As String = Subs.traeMesero(m.Get("id"))
|
|
If m.Get("mesero") <> "NINGUNO" Then cb_mesero.SelectedIndex = cb_mesero.IndexOf(m.Get("mesero"))
|
|
If m.Get("comensales") <> "0" Then cb_comensales.SelectedIndex = cb_comensales.IndexOf(m.Get("comensales"))
|
|
' Log(Subs.traeMesaEstatus(m.Get("id")))
|
|
If Subs.traeMesaEstatus(m.Get("id")) = "CERRADA" Then
|
|
p_mesaCampos.Visible = True
|
|
b_abrirMesa.Visible = True
|
|
p_mesaAbierta.Visible = False
|
|
Else
|
|
p_mesaCampos.Visible = False
|
|
b_abrirMesa.Visible = False
|
|
p_mesaAbierta.Visible = True
|
|
p_mesaAbierta.BringToFront
|
|
l_meseroAbierta2.Text = m.Get("mesero")
|
|
l_comensalesAbierta2.Text = m.Get("comensales")
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub b_abrirMesa_Click
|
|
If cb_mesero.SelectedIndex <> 0 Then
|
|
Private c As Cursor = Starter.skmt.ExecQuery($"select M_ESTATUS from CAT_MESAS where M_ID = '${Starter.mesaActual}' and M_ESTATUS = 'ABIERTA'"$)
|
|
If c.RowCount > 0 Then
|
|
Starter.skmt.ExecNonQuery($"update CAT_MESAS set M_MESERO = '${cb_mesero.SelectedItem}', M_COMENSALES = '${cb_comensales.SelectedItem}' where M_ID = '${Starter.mesaActual}'"$)
|
|
Log($"update CAT_MESAS set M_MESERO = '${cb_mesero.SelectedItem}', M_COMENSALES = '${cb_comensales.SelectedItem}' where M_ID = '${Starter.mesaActual}'"$)
|
|
Else
|
|
Starter.ticketActual = Subs.traeConsecutivoTicket("ABIERTA", "PENDIENTE")
|
|
Starter.skmt.ExecNonQuery($"update CAT_MESAS set M_TICKET = '${Subs.traeConsecutivoTicket("ABIERTA", "PENDIENTE")}', M_ESTATUS = 'ABIERTA', M_MESERO = '${cb_mesero.SelectedItem}', M_COMENSALES = '${cb_comensales.SelectedItem}' where M_ID = '${Starter.mesaActual}'"$)
|
|
Log($"update CAT_MESAS set M_TICKET = '${Starter.ticketActual}', M_ESTATUS = 'ABIERTA', M_MESERO = '${cb_mesero.SelectedItem}', M_COMENSALES = '${cb_comensales.SelectedItem}' where M_ID = '${Starter.mesaActual}'"$)
|
|
End If
|
|
Starter.meseroActual = cb_mesero.SelectedItem
|
|
Starter.comensalesActuales = cb_comensales.SelectedItem
|
|
Starter.skmt.ExecNonQuery($"insert into usuarioa (usuario) values ('${cb_mesero.SelectedItem}')"$)
|
|
LlenaProdsLL(Null, Null)
|
|
l_comensalesAbierta2.Text = cb_comensales.SelectedItem
|
|
l_meseroAbierta2.Text = cb_mesero.SelectedItem
|
|
p_mesaCampos.Visible = False
|
|
b_abrirMesa.Visible = False
|
|
p_mesaAbierta.Visible = True
|
|
Else
|
|
ToastMessageShow("Es necesario seleccionar un mesero", False)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub p_mesa_Click
|
|
'Para evitar que el clic en pantalla no se siga hacia atras
|
|
End Sub
|
|
|
|
Private Sub cb_comensales_SelectedIndexChanged (Index As Int)
|
|
Log(Index)
|
|
End Sub
|
|
|
|
Private Sub cb_mesero_SelectedIndexChanged (Index As Int)
|
|
Log(Index)
|
|
End Sub
|
|
|
|
Private Sub b_mesaCerrar_Click
|
|
' Log("Cerrar")
|
|
Private c As Cursor = Starter.skmt.ExecQuery($"select PE_MESA from PEDIDO where PE_MESA = '${Starter.mesaActual}' and PE_TIPO = 'VENTA'"$)
|
|
If c.RowCount > 0 Then
|
|
Log(Sender.As(Button).tag)
|
|
p_pago.BringToFront
|
|
p_pago.Visible = True
|
|
Else
|
|
Starter.skmt.ExecNonQuery($"update CAT_MESAS set M_PAGO = null, M_TICKET = null, M_ESTATUS = null, M_MESERO = null, M_COMENSALES = null where M_ID = '${Starter.mesaActual}'"$)
|
|
B4XPage_CloseRequest
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub b_mesaEditar_Click
|
|
b_abrirMesa.Text = "Guardar"
|
|
p_mesaCampos.Visible = True
|
|
b_abrirMesa.Visible = True
|
|
p_mesaAbierta.Visible = False
|
|
End Sub
|
|
|
|
Private Sub p_mesaAbierta_Click
|
|
'Para evitar que el clic en pantalla no se siga hacia atras
|
|
End Sub
|
|
|
|
Private Sub lv_categorias_ItemClick (Position As Int, Value As Object)
|
|
|
|
End Sub
|
|
|
|
Private Sub p_pago_Click
|
|
'Para evitar que el clic en pantalla no se siga hacia atras
|
|
End Sub
|
|
|
|
Private Sub b_pagoCerrar_Click
|
|
p_pago.Visible = False
|
|
If cb_pago.SelectedItem = "Efectivo" Then
|
|
Private tipoPago As String = "EFECTIVO"
|
|
Else
|
|
'Pago con tarjeta
|
|
Private tipoPago As String = "TARJETA"
|
|
End If
|
|
Private sigTicket As String = Subs.traeConsecutivoTicket("CERRADA", tipoPago)
|
|
Starter.skmt.ExecNonQuery($"update CAT_MESAS set M_PAGO = null, M_TICKET = null, M_ESTATUS = null, M_MESERO = null, M_COMENSALES = null where M_ID = '${Starter.mesaActual}'"$)
|
|
' Log($"update CAT_MESAS set M_PAGO = null, M_TICKET = null, M_ESTATUS = null, M_MESERO = null, M_COMENSALES = null where M_ID = '${Starter.mesaActual}'"$)
|
|
Starter.skmt.ExecNonQuery($"update PEDIDO set PE_TIPO = '${tipoPago}', PE_TICKET = '${sigTicket}' where PE_MESA = '${Starter.mesaActual}' and PE_TIPO = 'VENTA' and PE_TICKET = '${Starter.ticketActual}'"$)
|
|
' Log($"update PEDIDO set PE_TIPO = '${tipoPago}', PE_TICKET = '${sigTicket}' where PE_MESA = '${Starter.mesaActual}' and PE_TIPO = 'VENTA' and PE_TICKET = '${Starter.ticketActual}'"$)
|
|
Starter.skmt.ExecNonQuery($"update PEDIDO_TICKET set PT_PAGO = '${tipoPago}', PT_TICKET = '${sigTicket}' where PT_MESA = '${Starter.mesaActual}' and PT_TICKET = '${Starter.ticketActual}' and PT_PAGO = 'VENTA'"$)
|
|
' Log($"update PEDIDO_TICKET set PT_PAGO = '${tipoPago}', PT_TICKET = '${sigTicket}' where PT_MESA = '${Starter.mesaActual}' and PT_TICKET = '${Starter.ticketActual}' and PT_PAGO = 'VENTA"$)
|
|
B4XPage_CloseRequest
|
|
End Sub
|
|
|
|
Private Sub cb_pago_SelectedIndexChanged (Index As Int)
|
|
Log(cb_pago.SelectedItem)
|
|
End Sub
|
|
|
|
Private Sub b_cierraAdmin_Click
|
|
Private c As Cursor = Starter.skmt.ExecQuery($"select M_ESTATUS from CAT_MESAS where M_ESTATUS = 'ABIERTA'"$)
|
|
Log(c.RowCount)
|
|
If c.RowCount = 0 Then
|
|
cd1.Initialize(Colors.gray, 10dip)
|
|
b_cierraAdmin.Background = cd1
|
|
ToastMessageShow("¡Cierre administrativo habilitado!", False)
|
|
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("CIERRE ADMIN"))
|
|
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("CIERRE ADMIN","1"))
|
|
Else
|
|
ToastMessageShow("¡Es necesario que NO haya mesas abiertas para realizar el cierre!", True)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub b_cierraAdmin_LongClick
|
|
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("CIERRE ADMIN"))
|
|
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("CIERRE ADMIN","0"))
|
|
cd1.Initialize(Colors.red, 10dip)
|
|
b_cierraAdmin.Background = cd1
|
|
ToastMessageShow("¡Cierre administrativo cancelado!", False)
|
|
End Sub
|
|
|
|
Private Sub b_cierreTotal_Click
|
|
Log("click")
|
|
sv_resumen.Panel.Height = p_resumen.Height
|
|
cs.Initialize
|
|
Log(l_resumen.text)
|
|
Private c As Cursor = Starter.skmt.ExecQuery("select PE_MESA, PE_TIPO, sum(PE_COSTO_TOT) as SUBTOT from PEDIDO group by PE_MESA, pe_tipo order by PE_MESA, PE_TIPO desc")
|
|
If c.RowCount > 0 Then
|
|
c.Position = 0
|
|
Private mesaAnt As String = ""
|
|
Private tipo As String
|
|
' Private texoResumen As String
|
|
For i = 0 To c.RowCount - 1
|
|
c.Position = i
|
|
If c.GetString("PE_TIPO") = "TARJETA" Then tipo = "Tarjeta " Else tipo = "Efectivo "
|
|
If mesaAnt <> c.GetString("PE_MESA") Then cs.Color(Colors.red).Append("Mesa " & c.GetString("PE_MESA") & CRLF).pop
|
|
cs.Append($"* ${tipo} $${NumberFormat2(c.GetString("SUBTOT"), 0, 2, 2, True)}${CRLF}"$).Popall
|
|
mesaAnt = c.GetString("PE_MESA")
|
|
Next
|
|
l_resumen.Text = cs
|
|
l_resumen.Height = su.MeasureMultilineTextHeight(l_resumen, l_resumen.Text)
|
|
sv_resumen.Panel.Height = l_resumen.Height
|
|
End If
|
|
Subs.panelVisible(p_transparenteResumen, 0, 0)
|
|
End Sub
|
|
|
|
Private Sub et_inicioDia_EnterPressed
|
|
If et_inicioDia.Text.trim = "INICIO DIA" Then
|
|
p_transparenteCierreAdmin.Visible = False
|
|
et_inicioDia.Text = ""
|
|
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("CIERRE ADMIN"))
|
|
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("CIERRE ADMIN","0"))
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub p_transparenteCierreAdmin_Click
|
|
'Para evitar que el clic en pantalla no se siga hacia atras
|
|
End Sub
|
|
|
|
Private Sub p_transparenteResumen_Click
|
|
|
|
End Sub |