- VERSION 5.06.24

- Se Agregó un switch para activar/descativar la geocerca, solo se puede modficar dentro del almacen y requiere contraseña de supervisor de un solo uso.
- Se agregaron recordatorios de "Envío de venta", a las 10:30, 13:00 y 15:30 y por cada uno de esos horarios, 10, 5, 1 minutos antes.
This commit is contained in:
2025-06-25 17:44:54 -06:00
parent 4a3f94d492
commit 896ce0519f
19 changed files with 442 additions and 86 deletions

View File

@@ -94,6 +94,18 @@ Sub Class_Globals
Private b_importarBD As Button
Private p_importarBDWA As Panel
Dim cb_importarBDWA As CheckBox
Private cb_geocerca As CheckBox
Private passSupervisor As String = ""
Private p_transparente As Panel
Private p_passGeocerca As Panel
Private et_passGeocerca As EditText
Private b_passGeocerca As Button
Private l_geocerca As Label
Private ime As IME
Dim latAlmacen As String = "0"
Dim lonAlmacen As String = "0"
Dim pantallaActual As B4XView
Dim recordatorio As C_Recordatorio
End Sub
Public Sub Initialize
@@ -105,6 +117,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.GetManager.LogEvents = True
Root = Root1
Root.LoadLayout("login")
recordatorio.Initialize(Root)
s.Initialize(Me, "Subs")
B4XPages.SetTitle(Me, "Mariana Preventa")
login.Initialize
@@ -290,10 +303,14 @@ Private Sub B4XPage_Created (Root1 As B4XView)
Wait For MES_StorageAvailable
End If
End If
p_transparente.Left = 0 : p_transparente.top = 0
p_transparente.Width = Root.Width : p_transparente.Height = Root.Height
Subs.centraPanel(p_passGeocerca, Root.Width)
End Sub
Sub B4XPage_Appear
B4XPages.mainpage.pantallaActual = Root
passSupervisor = ""
If Starter.muestraProgreso = 1 Then
muestraProgreso("Descargando actualización")
Starter.muestraProgreso = 0
@@ -339,26 +356,26 @@ Sub B4XPage_Appear
'Obtenemos el usuario registrado
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
dameUsuario
' If Not(CheckNotificationAccess) Then
' Msgbox2Async($"Se necesita acceso a las notificaciones, haga clic en "Aceptar" y en la siguiente pantalla permita el acceso a la aplicación "${Application.LabelName}"."$, "Permisos necesarios", "Aceptar", "Cancelar", "", Null, True)
' Wait For Msgbox_Result (resultado As Int)
' If resultado = DialogResponse.POSITIVE Then
' Dim In As Intent
' In.Initialize("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS", "")
' StartActivity(In)
' End If
'' Private cd1 As ColorDrawable
'' cd1.Initialize(Colors.red, 10dip)
'' b_notifAccess.Background = cd1
'' b_notifAccess.TextColor = Colors.White
'' b_notifAccess.Text = "Activar Permisos"
' Else
'' Private cd1 As ColorDrawable
'' cd1.Initialize(Colors.RGB(109, 221, 101), 10dip)
'' b_notifAccess.Background = cd1
'' b_notifAccess.TextColor = Colors.White
'' b_notifAccess.Text = "Permisos Activos"
' End If
If Not(CheckNotificationAccess) Then
Msgbox2Async($"Se necesita acceso a las notificaciones, haga clic en "Aceptar" y en la siguiente pantalla permita el acceso a la aplicación "${Application.LabelName}"."$, "Permisos necesarios", "Aceptar", "Cancelar", "", Null, True)
Wait For Msgbox_Result (resultado As Int)
If resultado = DialogResponse.POSITIVE Then
Dim In As Intent
In.Initialize("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS", "")
StartActivity(In)
End If
' Private cd1 As ColorDrawable
' cd1.Initialize(Colors.red, 10dip)
' b_notifAccess.Background = cd1
' b_notifAccess.TextColor = Colors.White
' b_notifAccess.Text = "Activar Permisos"
Else
' Private cd1 As ColorDrawable
' cd1.Initialize(Colors.RGB(109, 221, 101), 10dip)
' b_notifAccess.Background = cd1
' b_notifAccess.TextColor = Colors.White
' b_notifAccess.Text = "Permisos Activos"
End If
' ks.Initialize(Me, "ks")
' ks.vacuum
' ks.centraEtiqueta(l_version, Root.Width)
@@ -546,7 +563,34 @@ Sub JobDone(Job As HttpJob)
IMEI_BASE = ""
IMEI = ""
End If
If result.Tag = "traePassGeocerca" Then 'query tag
Subs.logJobDoneResultados(result)
Log(result.Rows.Size)
For Each records() As Object In result.Rows
Log($"|${records(result.Columns.Get("TMP_PASS"))}|"$)
Dim tmp_pass As String = records(result.Columns.Get("TMP_PASS")).As(String)
Log(tmp_pass)
If et_passGeocerca.Text = tmp_pass Then
passSupervisor = et_passGeocerca.Text
p_transparente.Visible = False
et_passGeocerca.Text = ""
p_geocerca_Click
Else
Msgbox("Contraseña equivocada","ATENCIÓN")
End If
cmd.Initialize
cmd.Name = "borraPassGeocerca"
cmd.Parameters = Array As Object(Subs.traeAlmacen, Subs.traeRuta)
reqManager.ExecuteCommand(cmd , "borraPassGeocerca")
Next
If result.Rows.Size = 0 Then
Msgbox("Contraseña equivocada","ATENCIÓN")
End If
End If
End If
Job.Release
End If
Log($"Paso1 = ${paso1} - Name: ${name} - IMEI: ${IMEI} - IMEI_BASE: ${IMEI_BASE}"$)
@@ -610,10 +654,16 @@ Private Sub B4XPage_CloseRequest As ResumableSub
End Sub
Sub GPS_LocationChanged (Location1 As Location)
If user.text = "GPS" Then
user.Text=Location1.Latitude
pass.text=Location1.Longitude
End If
Log("LocationChanged")
l_geocerca.Text = "Habilitar Geocerca"
Dim l2 As Location
l2.Initialize2(latAlmacen, lonAlmacen) ' Coordenadas del almacen
Dim distance As Long = Location1.DistanceTo(l2) 'the result is in meters
Log("Distancia a almacen: " & distance)
' If user.text = "GPS" Then
' user.Text=Location1.Latitude
' pass.text=Location1.Longitude
' End If
End Sub
Sub PopupMenu_Dismiss
@@ -714,14 +764,45 @@ Sub ocultaProgreso
End Sub
Sub i_engrane_Click
Log(123456789)
l_geocerca.Text = "Buscando ubicación ..."
CallSubDelayed(Tracker, "StartFLPSmall")
If Tracker.FLP.IsInitialized And Tracker.FLP.GetLastKnownLocation.IsInitialized Then 'Si tenemos "UltimaUbicaccionConocida" la usamos.
B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
Log($"Tenemos UUC: ${Tracker.FLP.GetLastKnownLocation.Latitude},${Tracker.FLP.GetLastKnownLocation.Longitude}"$)
GPS_LocationChanged(Tracker.FLP.GetLastKnownLocation)
End If
' Log($"Coordenadas de la tienda - lat:${m_lat}, lon:${m_lon}"$)
Private x As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'COORDS_ALMACEN'"$)
If x.RowCount > 0 Then
x.Position = 0
' Log(x.GetString("CAT_VA_VALOR"))
Dim coords() As String = Regex.Split(",", x.GetString("CAT_VA_VALOR"))
Dim latAlmacen As String = coords(0)
Dim lonAlmacen As String = coords(1)
End If
Log($"lat:${latAlmacen}, lon: ${lonAlmacen}"$)
lv_server.Clear
lv_server.AddSingleLine("http://keymon.net:1781")
If user.Text = "KMTS1" Then lv_server.AddSingleLine("http://192.99.93.204:1781")
' l_server.Text = Starter.DBReqServer
et_server.Text = Starter.DBReqServer
Log(222)
p_transparente.Visible = False
passSupervisor = ""
Dim c As Cursor = Starter.skmt.ExecQuery("select * from cat_variables where cat_va_descripcion = 'GEOCERCA_ACTIVA'")
' cb_geocerca.Checked = True
If c.RowCount > 0 Then
c.Position = 0
' Log(c.GetString("CAT_VA_VALOR") & " <-------")
If c.GetString("CAT_VA_VALOR") = 0 Then cb_geocerca.Checked = False Else cb_geocerca.Checked = True
' Log("----> " & cb_geocerca.Checked)
End If
' Starter.skmt.ExecNonQuery("delete from cat_variables where cat_va_descripcion = 'GEOCERCA_ACTIVA'")
' Starter.skmt.ExecNonQuery($"insert into cat_variables (cat_va_descripcion, cat_va_valor) values ('GEOCERCA_ACTIVA', ${cb_geocerca.Checked})"$)
' Log("----> " & cb_geocerca.Checked)
cb_importarBDWA.Checked = s.traeUsarIntentBDWA
Log(333)
If user.Text.Trim = "KMTS1" Then
p_importarBDWA.Visible = True
Else
@@ -807,3 +888,55 @@ Private Sub cb_importarBDWA_CheckedChange(Checked As Boolean)
Starter.skmt.ExecNonQuery("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'")
Starter.skmt.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('IMPORTAR_BD_WA', '${Checked}')"$)
End Sub
Private Sub p_transparente_Click
p_transparente.Visible = False
End Sub
Private Sub b_passGeocerca_Click
Log("b_passGeocerca clicked")
cmd.Initialize
cmd.Name = "traePassGeocerca"
cmd.Parameters = Array As Object(Subs.traeAlmacen, Subs.traeRuta, et_passGeocerca.text)
Log($"${Subs.traeAlmacen}, ${Subs.traeRuta}, ${et_passGeocerca.text}"$)
reqManager.ExecuteQuery(cmd , 0, "traePassGeocerca")
' If et_passGeocerca.Text = "12345" Then
' passSupervisor = et_passGeocerca.Text
' p_transparente.Visible = False
' et_passGeocerca.Text = ""
' Else
' Msgbox("Contraseña equivocada","ATENCIÓN")
' End If
ime.HideKeyboard
End Sub
Private Sub p_geocerca_Click
Log("CLICKED")
Dim activa As Int = 1
If Subs.estamosEnAlmacen(50) Then
If l_geocerca.Text <> "Buscando ubicación ..." Then
If passSupervisor = "" Then
p_transparente.Visible = True
Else
If cb_geocerca.Checked = False Then
cb_geocerca.Checked = True
activa = 1
Else
cb_geocerca.Checked = False
activa = 0
End If
Starter.skmt.ExecNonQuery("delete from cat_variables where cat_va_descripcion = 'GEOCERCA_ACTIVA'")
Starter.skmt.ExecNonQuery($"insert into cat_variables (cat_va_descripcion, cat_va_valor) values ('GEOCERCA_ACTIVA', ${activa})"$)
End If
Else
ToastMessageShow("Es necesario tener ubicación", True)
End If
Else
ToastMessageShow("Es necesario estar en el almacen para esta operación", True)
End If
End Sub
Private Sub p_geocerca2_Click
p_geocerca_Click
End Sub

View File

@@ -144,6 +144,8 @@ Sub Class_Globals
Private b_pedidoYalo As Button
Private p_transYalo As Panel
Private lv_yalo As ListView
Dim distance As Long = 500000000000
Dim enGeocerca As Boolean = False
End Sub
'You can add more parameters here.
@@ -202,8 +204,11 @@ End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub B4XPage_Appear
B4XPages.mainpage.pantallaActual = Root
b_noVenta.Enabled = True
b_venta.Enabled = True
b_noVenta.Visible = False 'Boton deshabilitado por default.
b_venta.Visible = False 'Boton deshabilitado por default.
' c = Starter.skmt.ExecQuery("SELECT ID FROM VENDIDOS WHERE ID IN (Select cuenta from cuentaa)")
' If c.RowCount > 0 Then
' b_noVenta.Enabled = False
@@ -302,11 +307,11 @@ Sub B4XPage_Appear
ALMACEN = C.GetString("ID_ALMACEN")
End If
c.Close
If ALMACEN = "1" Then
b_noVenta.Visible = False
b_venta.Visible = False
' B_GPS.Visible = False
End If
' If ALMACEN = "1" Then
' b_noVenta.Visible = False
' b_venta.Visible = False
'' B_GPS.Visible = False
' End If
If ALMACEN = "4" Then
' b_like.Visible = True
DD=skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM HIST_VENTAS WHERE HVD_CLIENTE IN (Select cuenta from cuentaa) AND HVD_PRONOMBRE =?", Array As String("KNORR RINDE MAS 70 GR"))
@@ -327,10 +332,10 @@ Sub B4XPage_Appear
Else
' b_like.Visible = False
End If
If ALMACEN = "16" Or ALMACEN = "13" Then
b_noVenta.Visible = True
b_venta.Visible = True
End If
' If ALMACEN = "16" Or ALMACEN = "13" Then
' b_noVenta.Visible = True
' b_venta.Visible = True
' End If
CallSubDelayed(Tracker, "Track")
If Not(Starter.GPS.GPSEnabled) Then
@@ -347,8 +352,14 @@ Sub B4XPage_Appear
' Log($"Tenemos UUC: ${Tracker.FLP.GetLastKnownLocation.Latitude},${Tracker.FLP.GetLastKnownLocation.Longitude}"$)
GPS_LocationChanged(Tracker.FLP.GetLastKnownLocation)
End If
b_noVenta.Visible = True
b_venta.Visible = True
Log("DISTANCIA: " & distance)
If Subs.hayPedido Or distance <= 50 Then ' Si estamos dentro de la geocerca, habilitamos los botones de Venta y noVenta
b_noVenta.Visible = True
b_venta.Visible = True
Log("Botones visibles")
End If
'Si el cliente es nuevo, no aparece el boton de venta
If la_cuenta.text.SubString2(0,1) = "N" Then
b_venta.Visible = False
@@ -363,7 +374,7 @@ Sub GPS_LocationChanged (Location1 As Location)
B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
' Log("Coords set to: " & B4XPages.MainPage.lat_gps & " and " & B4XPages.MainPage.lon_gps)
End If
Dim l1, l2 As Location
l1.Initialize2(B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps)
' Log($"Coordenadas de la tienda - lat:${m_lat}, lon:${m_lon}"$)
@@ -372,15 +383,21 @@ Sub GPS_LocationChanged (Location1 As Location)
BT_QR.Enabled = True
LA_GPS.TextColor = Colors.Blue
LA_GPS.Text = "CON UBICACION GPS"
' B_GPS.Enabled = True
'now we need the distance between our location and the target location
Dim distance As Long
distance = l1.DistanceTo(l2) 'the result is in meter
' b_venta.Visible = True
' If distance < 100 Then
If distance <= 50 Then ' Si estamos dentro de la geocerca, habilitamos los botones de Venta y noVenta
b_noVenta.Visible = True
b_venta.Visible = True
' Log("Botones visibles")
End If
If Subs.estamosEnAlmacen(50) And Not(Subs.geocercaHabilitada) Then
b_noVenta.Visible = True
b_venta.Visible = True
' Log("Botones visibles")
End If
LA_GEO.TextColor = Colors.Blue
b_noVenta.Visible = True
b_venta.Visible = True
' b_noVenta.Visible = True
' b_venta.Visible = True
If la_cuenta.text.SubString2(0,1) = "N" Then
b_venta.Visible = False
b_noVenta.Visible = False
@@ -397,7 +414,7 @@ Sub GPS_LocationChanged (Location1 As Location)
If Location1.Accuracy > 200 Then
l_ubicacion2.TextColor = Colors.Red
l_ubicacion2.TextSize = 16
l_ubicacion2.Text = $"Mala señal $1.0{Location1.Accuracy} m"$
l_ubicacion2.Text = $"Mala señal GPS $1.0{Location1.Accuracy} m"$
End If
CallSubDelayed(Tracker, "CreateLocationRequest")

View File

@@ -64,6 +64,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
End Sub
Sub B4XPage_Appear
B4xPages.mainpage.pantallaActual = Root
B4XPages.SetTitle(Me, $"Clientes - ${Starter.dia_semana} - ${Application.VersionName}"$)
busca.Text = ""
entro ="2"

View File

@@ -56,6 +56,7 @@ End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub B4XPage_Appear
B4xPages.mainpage.pantallaActual = Root
reqManager.Initialize(Me, Starter.DBReqServer)
e_comm.Text=""
tgl.Initialize

View File

@@ -62,6 +62,7 @@ End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub B4XPage_Appear
B4xPages.mainpage.pantallaActual = Root
If Not(Starter.gps.GPSEnabled) Then
ToastMessageShow("Es necesario tener el GPS encendido", True)
StartActivity(Starter.gps.LocationSettingsIntent)

View File

@@ -246,6 +246,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
l_version.Text = Application.VersionName
' rd.Initialize 'Inicializamos el respaldo diario.
' rd.vacuum
EJECUTANDO=1
Dim ruta As String
img2.Visible =False
@@ -315,6 +316,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
End Sub
Sub B4XPage_Appear
B4XPages.mainpage.pantallaActual = Root
checaPedido
' s.reqManagerReInit 'Reiniciamos el DBReqManager de C_Subs por si hay modificacion en el servidor.
reqManager.Initialize(Me, Starter.DBReqServer)
@@ -518,7 +520,7 @@ Sub Subir_Click
'ELSE IF c.GetString("DESCUENTO") = 0 Then
PASO = 1
'End If
If PASO =1 Then
If PASO = 1 Then
Starter.skmt.ExecNonQuery2("delete from PEDIDO WHERE PE_PRONOMBRE = ? ", Array As String("N/A") )
Starter.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE not In (select PE_CLIENTE from pedido)")
c=Starter.skmt.ExecQuery("select usuario from usuarioa")
@@ -541,7 +543,7 @@ Sub Subir_Click
c=Starter.skmt.ExecQuery("SELECT PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT, PC_COSTO_SIN, PC_RUTA, PC_ALMACEN, PC_FACTURA FROM PEDIDO_CLIENTE ")
d=Starter.skmt.ExecQuery("SELECT COUNT(*) as CUANTOS_PEDIDOSC FROM PEDIDO_CLIENTE ")
If c.RowCount>0 Then
If c.RowCount > 0 Then
For i=0 To c.RowCount -1
c.Position=i
Dim cmd As DBCommand
@@ -549,13 +551,14 @@ Sub Subir_Click
cmd.Name = "insert_pedidos_MARDS"
cmd.Parameters = Array As Object(c.GetString("PC_CLIENTE"), c.GetString("PC_FECHA"), c.GetString("PC_USER"), c.GetString("PC_NOART"), c.GetString("PC_MONTO"), c.GetString("PC_LON"), c.GetString("PC_LAT"), ALMACEN, l_ruta.text, c.GetString("PC_COSTO_SIN"), c.GetString("PC_FACTURA"))
reqManager.ExecuteCommand(cmd , "ins_pedidos")
Starter.skmt.ExecNonQuery($"UPDATE PEDIDO_CLIENTE set PC_ENVIO_OK = 1 where PC_CLIENTE = '${c.GetString("PC_CLIENTE")}'"$)
Next
End If
c.Close
d.Position=0
cuantos_pedidosc = D.GetString("CUANTOS_PEDIDOSC")
d.Close
' ENVIO DE LOS CODIGOS QR
'c=skmt.ExecQuery2("SELECT CAT_CL_NUM_SERIEFISICO,CAT_CL_CODIGO ,CAT_CL_LONG,CAT_CL_LAT, CAT_CL_FOTO FROM kmt_info where CAT_CL_NUM_SERIEFISICO = ?", Array As String("OK"))
@@ -840,7 +843,7 @@ Sub cargar_Click
sTime=DateTime.Time(DateTime.Now)
Dim P As PhoneId
' imei = P.GetDeviceId
' imei = P.GetDeviceId
imei = "yyyy"
cmd.Initialize
cmd.Name ="insert_drop_MARDS_3" 'Se cambio el query de 2 a 3 para agregar la version de la app al tmp_drop
@@ -968,7 +971,12 @@ Sub cargar_Click
cmd.Name = "select_promosXruta_MARDS"
cmd.Parameters = Array As Object(ALMACEN, e_ruta.text)
reqManager.ExecuteQuery(cmd , 0, "promosXruta")
cmd.Initialize
cmd.Name = "traeCoordenadasAlmacen_MARDS"
cmd.Parameters = Array As Object(ALMACEN)
reqManager.ExecuteQuery(cmd , 0, "traeCoordsAlmacen")
' cmd.Initialize
' cmd.Name = "select_CUEST_INTMEX"
' cmd.Parameters = Array As Object(ALMACEN)
@@ -1789,6 +1797,18 @@ Sub JobDone(Job As HttpJob)
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_PEDIDOS_YALO(PY_IDCLIENTE, PY_PRODID, PY_PRODNOMBRE, PY_MARCANOMBRE, PY_COSTO_TOT, PY_CANT, PY_FECHA, PY_TICKET) VALUES (?,?,?,?,?,?,?,?)", Array As Object (PY_IDCLIENTE, PY_PRODID, PY_PRODNOMBRE, PY_MARCANOMBRE, PY_COSTO_TOT, PY_CANT, PY_FECHA, PY_TICKET))
Next
End If
Dim RESULT As DBResult = reqManager.HandleJob(Job)
If RESULT.Tag = "traeCoordsAlmacen" Then 'query tag
For Each records() As Object In RESULT.Rows
Dim CAT_AL_LATITUD As String = records(RESULT.Columns.Get("CAT_AL_LATITUD"))
Dim CAT_AL_LONGITUD As String = records(RESULT.Columns.Get("CAT_AL_LONGITUD"))
Starter.skmt.ExecNonQuery("DELETE FROM CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = 'COORDS_ALMACEN'")
Starter.skmt.ExecNonQuery($"INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES ('COORDS_ALMACEN','${CAT_AL_LATITUD},${CAT_AL_LONGITUD}')"$)
B4XPages.MainPage.latAlmacen = CAT_AL_LATITUD
B4XPages.MainPage.lonAlmacen = CAT_AL_LONGITUD
Next
End If
End If
End If
Job.Release
@@ -1812,9 +1832,11 @@ End Sub
'############################################################################################
'################### Codigo de prueba JAGU, no poner atencion ############################
Sub connecta_LongClick
ProgressDialogShow("Enviamos")
' ProgressDialogShow("Enviamos")
' s.reqManagerReInit 'Reiniciamos el DBReqManager por si hay modificacion en el servidor.
s.envioTest 'Llamamos envioTest de C_Subs.
' s.envioTest 'Llamamos envioTest de C_Subs.
Subs.notiHigh("¡¡ATENCION!!", "Recuerda enviar tu venta.", Main)
b4xpages.MainPage.recordatorio.agregaPanelRecordatorio(Root)
End Sub
Sub tickets_dia_LongClick

View File

@@ -131,6 +131,7 @@ End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub B4XPage_Appear
B4xPages.mainpage.pantallaActual = Root
clienteId = Subs.traeCliente
rutaUsuario = Subs.traeRuta
Starter.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("PRIORITARIO","1"))
@@ -253,12 +254,12 @@ Sub lv_catalogos_ItemClick (Position As Int, Value As Object)
If c2.RowCount > 0 Then
For i=0 To c2.RowCount -1
c2.Position = i
LogColor(">>>>>>>>> " & c2.GetString("CAT_GP_ID") & " <<<<<<<<<<", Colors.red)
LogColor(">>>>>>>>> INICIAMOS REVISION DE PROMO " & c2.GetString("CAT_GP_ID") & " <<<<<<<<<<", Colors.red)
LogColor(">>>>>>>>> " & c2.GetString("CAT_GP_NOMBRE") & " <<<<<<<<<<", Colors.red)
Private tm As Map = Subs.procesaPromocion(c2.GetString("CAT_GP_ID"), clienteId)
' Log(c2.GetString("CAT_GP_ID"))
Log($"Promo ${c2.GetString("CAT_GP_ID")} - ${tm.Get("status")}"$)
If tm.Get("status") = "ok" Then 'Solo muestrala si hay producto.
Log($"Promo OK ${CRLF}${tm}"$)
Log($"Promo OK - ${c2.GetString("CAT_GP_NOMBRE")} ${CRLF}${tm}"$)
lv_promos.AddTwoLines(c2.GetString("CAT_GP_NOMBRE"),"# " & c2.GetString("CAT_GP_ALMACEN") & " $ " & c2.GetString("CAT_GP_PRECIO") & " F:" & tm.Get("mp").As(Map).Get("prodsFijosCant") & " V:" & tm.Get("mp").As(Map).Get("prodsVariablesCant"))
End If
Next
@@ -884,6 +885,8 @@ Private Sub clv_prods_ll_VisibleRangeChanged (FirstIndex As Int, LastIndex As In
et_pCant.Enabled = False
' b_prodMas.Enabled = False
b_prodMenos.Enabled = False
' b_prodMenos.Color = Colors.LightGray
End If
End If
Private precio As String=NumberFormat2(clv_prods_ll.GetValue(i).As(Map).Get("precio").As(Double),1,2,2,False)

View File

@@ -56,7 +56,7 @@ End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.SetTitle(Me, $"${subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
B4XPages.SetTitle(Me, $"${Subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
Root = Root1
'load the layout to Root
Root.LoadLayout("promociones")
@@ -64,6 +64,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
End Sub
Sub B4XPage_Appear
B4xPages.mainpage.pantallaActual = Root
' LogColor(B4XPages.MainPage.productos.prodsMap, Colors.blue)
p_promociones.Top=0
p_promociones.Left=0

84
B4A/C_Recordatorio.bas Normal file
View File

@@ -0,0 +1,84 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=12.8
@EndOfDesignText@
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Dim panelSombra As Panel 'Panel de sombra.
Dim panelActual As Panel
Private Root2 As B4XView
Private b_Aceptar As Button
End Sub
'You can add more parameters here.
Public Sub Initialize (Root1 As B4XView) As Object
Root = Root1
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
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub agregaPanelRecordatorio (vRoot As B4XView) 'ignore
' vRoot.GetAllViewsRecursive
For Each v As B4XView In vRoot.GetAllViewsRecursive
' Log("Tag: " & v.Tag)
If v.Tag.As(String) = "panelSombra" Then
Log("--> " & v.tag)
v.RemoveViewFromParent
End If
Next
Try
Private su As StringUtils
panelSombra.Initialize("panelSombra")
panelSombra.Tag = "panelSombra"
Private cd As ColorDrawable
cd.Initialize(Colors.ARGB(125, 98, 98, 98), 0)
panelSombra.Background = cd
Private panelX As Panel 'Panel de la pregunta.
panelX.Initialize("pMsg")
panelActual = panelX
Private lbl As Label 'Etiqueta de la pregunta.
lbl.Initialize("")
Private cs As CSBuilder
cs.Initialize
lbl.Text = cs.bold.color(Colors.red).append("¡¡ATENCION!!").pop.pop.bold.Append(CRLF & CRLF & "Recuerda enviar tu venta.").PopAll
lbl.TextSize = 18
lbl.Gravity = Gravity.CENTER_HORIZONTAL
lbl.Left = (vRoot.Width / 2) - (lbl.Width/2)
lbl.TextColor = Colors.Black
cd.Initialize2(Colors.white, 20, 1, Colors.Gray) 'Borde y esquinas redondeadas del panel de la pregunta.
panelX.Background = cd
panelSombra.AddView(panelX, 100, 20%y, 80%x, 120dip)
panelX.Left = (vRoot.Width / 2) - (panelX.Width / 2)
vRoot.AddView(panelSombra, 0, 0, 100%x, 100%y) 'add the panel to the layout
panelX.AddView(lbl, 20dip, 20dip, (panelX.Width * 0.9), 40dip) 'Agregamos la etiqueta al panel.
lbl.Height = panelX.Height - 5
panelSombra.Width = vRoot.Width
panelSombra.Height = vRoot.Height
panelSombra.Elevation = 100
panelSombra.BringToFront
Catch
Log(LastException)
End Try
End Sub
'Oculta el panel de la pregunta.
Sub ocultPanelRecordatorio
If panelSombra.IsInitialized Then panelSombra.RemoveView
End Sub
Sub panelSombra_Click
If panelSombra.IsInitialized Then panelSombra.RemoveView
End Sub

View File

@@ -57,6 +57,7 @@ End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub B4XPage_Appear
B4xPages.mainpage.pantallaActual = Root
nombre_boton = "NOVENTA"
c=Starter.skmt.ExecQuery("select PC_CLIENTE,PC_MONTO,PC_NOART,(select CAT_CL_NOMBRE from kmt_info where cat_cl_codigo = pc_cliente ) as NOMBRE FROM PEDIDO_CLIENTE ORDER BY PC_FECHA asc")
ListView1.Clear

Binary file not shown.

Binary file not shown.

View File

@@ -121,6 +121,7 @@ Sub Activity_Create(FirstTime As Boolean)
End Sub
Sub Activity_Resume
' B4xPages.mainpage.pantallaActual = Root
Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then

View File

@@ -168,20 +168,22 @@ Module11=C_Pedidos
Module12=C_Principal
Module13=C_Productos
Module14=C_Promos
Module15=C_RespaldoDiario
Module16=C_Subs
Module17=C_TicketsDia
Module18=C_UpdateAvailable
Module19=CameraExClass2
Module15=C_Recordatorio
Module16=C_RespaldoDiario
Module17=C_Subs
Module18=C_TicketsDia
Module19=C_UpdateAvailable
Module2=B4XMainPage
Module20=DBRequestManager
Module21=FileHandler
Module22=ManageExternalStorage
Module23=MAPA_RUTAS
Module24=NotificationService
Module25=Starter
Module26=Subs
Module27=Tracker
Module20=CameraExClass2
Module21=DBRequestManager
Module22=FileHandler
Module23=ManageExternalStorage
Module24=MAPA_RUTAS
Module25=Notas
Module26=NotificationService
Module27=Starter
Module28=Subs
Module29=Tracker
Module3=BatteryUtilities
Module4=C_Cliente
Module5=C_Clientes
@@ -191,13 +193,13 @@ Module8=C_Nota
Module9=C_NoVenta
NumberOfFiles=63
NumberOfLibraries=35
NumberOfModules=27
NumberOfModules=29
Version=12.8
@EndOfDesignText@
#Region Project Attributes
#ApplicationLabel: Mariana
#VersionCode: 1
#VersionName: 5.06.08
#VersionName: 5.06.24
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False

View File

@@ -19,6 +19,8 @@ ModuleBookmarks24=
ModuleBookmarks25=
ModuleBookmarks26=
ModuleBookmarks27=
ModuleBookmarks28=
ModuleBookmarks29=
ModuleBookmarks3=
ModuleBookmarks4=
ModuleBookmarks5=
@@ -47,6 +49,8 @@ ModuleBreakpoints24=
ModuleBreakpoints25=
ModuleBreakpoints26=
ModuleBreakpoints27=
ModuleBreakpoints28=
ModuleBreakpoints29=
ModuleBreakpoints3=
ModuleBreakpoints4=
ModuleBreakpoints5=
@@ -59,8 +63,8 @@ ModuleClosedNodes1=
ModuleClosedNodes10=
ModuleClosedNodes11=
ModuleClosedNodes12=
ModuleClosedNodes13=
ModuleClosedNodes14=
ModuleClosedNodes13=1
ModuleClosedNodes14=2
ModuleClosedNodes15=
ModuleClosedNodes16=
ModuleClosedNodes17=
@@ -74,14 +78,16 @@ ModuleClosedNodes23=
ModuleClosedNodes24=
ModuleClosedNodes25=
ModuleClosedNodes26=
ModuleClosedNodes27=
ModuleClosedNodes27=9,10,11,12,13,14
ModuleClosedNodes28=
ModuleClosedNodes29=9,10,11,12
ModuleClosedNodes3=
ModuleClosedNodes4=
ModuleClosedNodes4=4,10
ModuleClosedNodes5=
ModuleClosedNodes6=
ModuleClosedNodes7=
ModuleClosedNodes8=
ModuleClosedNodes9=
NavigationStack=C_Cliente,b_venta_Click,403,0,C_Cliente,StartPrinter,689,0,Diseñador Visual,cliente.bal,-100,6,C_Cliente,B_GUARDA_C_Click,738,0,Diseñador Visual,clientes.bal,-100,5,C_Clientes,B4XPage_Appear,94,6,Subs,CreateBitmapWithNumber,1391,0,Subs,capitalizar,1376,0,MAPA_RUTAS,Globals,20,0,MAPA_RUTAS,MapFragment1_Ready,174,0,Starter,Process_Globals,17,0
NavigationStack=C_Principal,connecta_LongClick,1832,2,Starter,Process_Globals,32,5,B4XMainPage,B4XPage_Created,111,0,Diseñador Visual,login.bal,-100,4,B4XMainPage,p_transparente_Click,884,0,B4XMainPage,b_passGeocerca_Click,885,6,B4XMainPage,JobDone,577,6,Starter,ENVIA_ULTIMA_GPS,90,0,Starter,timerRecordatorio_Tick,180,6,Starter,Service_Start,57,0,Starter,IsConnectedToInternet,158,0
SelectedBuild=0
VisibleModules=25,2,12,4,5,6,26,16,13,9,23
VisibleModules=27,2,12,4,28,15,5,8,14,18

14
B4A/Notas.bas Normal file
View File

@@ -0,0 +1,14 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=StaticCode
Version=12.8
@EndOfDesignText@
'Code module
Sub Process_Globals
' Geocerca a 50 mts.
' Los pedidos solo se pueden meter en la tienda (dentro de 50 mts), o en el almacen (con geocerca deshabilitada con contraseña de supervisor de uso unico).
' La geocerca se deshabilita entrando al engrane.
' A los pedidos se les puede agregar producto (entrando por "Tickets dia") sin estar dentro de la geocerca, obviamente tiene que YA haber pedido.
' Al hacer FIN DIA se regresa la geocerca a ACTIVA.
End Sub

View File

@@ -35,6 +35,8 @@ Sub Process_Globals
Dim marcaCel As String = ph.manufacturer
Public rp As RuntimePermissions
Dim muestraProgreso As String = 0
Dim timerRecordatorio As Timer
Dim ultimoRecordatorio As String = ""
End Sub
Sub Service_Create
@@ -59,6 +61,8 @@ Sub Service_Start (StartingIntent As Intent)
If s.traeDBReqServerDeBD(skmt) <> "N/A" Then DBReqServer = s.traeDBReqServerDeBD(skmt)
reqManager.Initialize(Me, DBReqServer)
' StartService(NotificationService)
timerRecordatorio.Initialize("timerRecordatorio", 50 * 1000)
timerRecordatorio.Enabled = True
End Sub
Private Sub Timer1_Tick
@@ -157,4 +161,30 @@ Sub IsConnectedToInternet As Boolean 'ignore
Return r.RunMethod("isConnectedOrConnecting")
End If
Return False
End Sub
Private Sub timerRecordatorio_Tick
'10:30, 13:00 y 15:30
Log("Revisando la hora - UltimoRecordatorio: " & ultimoRecordatorio)
If ultimoRecordatorio <> DateTime.GetHour(DateTime.now) & DateTime.GetMinute(DateTime.now) Then
If (DateTime.GetHour(DateTime.now) = 10 And DateTime.GetMinute(DateTime.now) = 20) _ 'Recordatorio de las 10:20
Or (DateTime.GetHour(DateTime.now) = 10 And DateTime.GetMinute(DateTime.now) = 25) _ 'Recordatorio de las 10:25
Or (DateTime.GetHour(DateTime.now) = 10 And DateTime.GetMinute(DateTime.now) = 29) _ 'Recordatorio de las 10:29
Or (DateTime.GetHour(DateTime.now) = 10 And DateTime.GetMinute(DateTime.now) = 30) _ 'Recordatorio de las 10:30
Or (DateTime.GetHour(DateTime.now) = 12 And DateTime.GetMinute(DateTime.now) = 50) _ 'Recordatorio de las 12:50
Or (DateTime.GetHour(DateTime.now) = 12 And DateTime.GetMinute(DateTime.now) = 55) _ 'Recordatorio de las 12:55
Or (DateTime.GetHour(DateTime.now) = 12 And DateTime.GetMinute(DateTime.now) = 59) _ 'Recordatorio de las 12:59
Or (DateTime.GetHour(DateTime.now) = 13 And DateTime.GetMinute(DateTime.now) = 0) _ 'Recordatorio de las 13:00
Or (DateTime.GetHour(DateTime.now) = 15 And DateTime.GetMinute(DateTime.now) = 20) _ 'Recordatorio de las 15:20
Or (DateTime.GetHour(DateTime.now) = 15 And DateTime.GetMinute(DateTime.now) = 25) _ 'Recordatorio de las 15:25
Or (DateTime.GetHour(DateTime.now) = 15 And DateTime.GetMinute(DateTime.now) = 29) _ 'Recordatorio de las 15:29
Or (DateTime.GetHour(DateTime.now) = 15 And DateTime.GetMinute(DateTime.now) = 30) _ 'Recordatorio de las 15:30
Or (DateTime.GetHour(DateTime.now) = 17 And DateTime.GetMinute(DateTime.now) = 70) Then ' HORARIO DE PRUEBA
If Not(B4XPages.GetManager.IsForeground) Then Subs.notiHigh("¡¡ATENCION!!", "Recuerda enviar tu venta.", Main)
If B4XPages.MainPage.IsInitialized And B4XPages.MainPage.pantallaActual.IsInitialized Then
B4XPages.MainPage.recordatorio.agregaPanelRecordatorio(B4XPages.MainPage.pantallaActual)
End If
ultimoRecordatorio = DateTime.GetHour(DateTime.now) & DateTime.GetMinute(DateTime.now)
End If
End If
End Sub

View File

@@ -848,7 +848,7 @@ Sub traePromo(promo As String, cliente As String) As Map
promoMap = CreateMap("id":promo, "maxXcliente":(ps2.GetString("HCCP_CANT")-ps2.GetString("HCCP_CANT_VENDIDA")), "maxRecurrente":ps2.GetString("HCCP_CANT"), "maxPromos":ps2.GetString("HCCP_CANT")) 'Si es segmentada SOLO le aparece a ciertos clientes.
End If
End If
If thisLog Then Log(promoMap)
If thisLog Then Log("MAX PROMOS: " & promoMap)
' ########## TERMINA PROMOS SEGMENTADAS ##########
c = Starter.skmt.ExecQuery("Select count(*) as hist from HIST_PROMOS where HP_CLIENTE = '"& cliente & "' and HP_CODIGO_PROMOCION = '" & promo & "'") 'Revisamos si hay historico de la promoción.
c.Position = 0
@@ -963,7 +963,7 @@ End Sub
'Revisa si tenemos los productos variables requeridos para la promoción (mapa).
'Hay que darle como parametro un mapa (traePromo(promo)) con toda la informacion de la promocion.
Sub alcanzanLosVariablesParaPromo(promoMap As Map, inventarioSinFijos As Map) As Boolean 'ignore
Private thisLog As Boolean = False 'Si es verdadero, muestra los logs de este sub.
Private thisLog As Boolean = True 'Si es verdadero, muestra los logs de este sub.
If thisLog Then LogColor("Inventario inicial: "&inventarioSinFijos, Colors.Gray) 'Inventario inicial.
Private totalProdsVariables As Int = 0
' Private prodsmap As Map = promoMap.Get("productos") 'Obtenemos un mapa con todos los productos de la promoción.
@@ -989,7 +989,7 @@ Sub traeMaxPromos(pm As Map) As Int
Private vendidas As Int = 0
maxPromos.Initialize
' If Starter.promosLog Then Log("==== HISTORICO:"&pm.Get("historico"))
If thisLog Then Log(pm)
' If thisLog Then Log(pm)
Private maxXruta As String = traeMaxPromosXruta(pm.Get("id"))
@@ -1000,7 +1000,7 @@ Sub traeMaxPromos(pm As Map) As Int
maxPromos.Add(pm.Get("maxXcliente").As(Int)) 'Agregamos maxXcliente
If maxXruta <> "" Then maxPromos.Add(maxXruta.As(Int)) 'Agregamos maxXruta
maxPromos.Sort(True)
Log(maxPromos)
' Log("MaxPromos: " & maxPromos)
' Log($"|${pm.Get("id").As(String).trim}|${traeCliente.Trim}|"$)
Private c As Cursor = Starter.skmt.ExecQuery2("select sum(PE_CANT) as vendidas from PEDIDO where PE_PROID = ? and PE_CLIENTE = ? ", Array As String(pm.Get("id").As(String).trim, traeCliente.Trim))
@@ -1028,11 +1028,11 @@ Sub traeMaxPromosXruta(idPromo As String) As String
End If
'Revisamos las promos que ya se hayan vendido y las restamos del máximo.
Private cp As Cursor = Starter.skmt.ExecQuery($"select count(PE_CANT) as cuantos from PEDIDO where PE_PROID = '${idPromo}'"$)
Log(cp.RowCount)
' Log(cp.RowCount)
If cp.RowCount > 0 Then
Private pa As Int = 0
cp.Position = 0
Log(cp.GetInt("cuantos"))
' Log(cp.GetInt("cuantos"))
If IsNumber(cp.GetInt("cuantos")) Then pa = cp.GetInt("cuantos")
If maxXruta <> "" Then maxXruta = maxXruta - pa
End If
@@ -1054,7 +1054,7 @@ End Sub
Sub procesaPromocion(idPromo As String, cliente As String) As Map 'ignore
Private thisLog As Boolean = True 'Si es verdadero, muestra los logs de este sub.
Private inicioContador As String = DateTime.Now
If thisLog Then LogColor($"********* Iniciamos revision de Promo ${idPromo} *********"$, Colors.Magenta)
If thisLog Then LogColor($"********* Procesamos Promo ${idPromo} *********"$, Colors.Magenta)
'Obtenemos el mapa con toda la info de la promoción.
Private pm As Map = traePromo(idPromo, cliente)
If thisLog Then LogColor(pm, Colors.Blue)
@@ -1068,6 +1068,7 @@ Sub procesaPromocion(idPromo As String, cliente As String) As Map 'ignore
End If
'Restamos del inventario (mapa) las piezas necesarias para los productos fijos.
Private inventarioSinFijos As Map = restaFijosPromo(pm)
Log(idPromo)
If thisLog Then LogColor("inventariosfijos="&inventarioSinFijos, Colors.Green)
If inventarioSinFijos.Get("resultado") = "ok" Then
@@ -1394,4 +1395,41 @@ Sub CreateBitmapWithNumber(OriginalBitmap As Bitmap, Number As Int) As Bitmap 'i
' Dibujar el número en el centro del Bitmap y configurar el estilo del texto
Canvas.DrawText(Number, (OriginalBitmap.Width / 2), (OriginalBitmap.Height / 2.4), Typeface.DEFAULT, 15, Colors.White, "CENTER")
Return NewBitmap
End Sub
'Regresa verdadero si la geocerca esta activa en CAT_VARIABLES, default true.
Sub geocercaHabilitada As Boolean
Dim activa As Boolean = True
Dim c As Cursor = Starter.skmt.ExecQuery("select cat_va_valor from cat_variables where cat_va_descripcion = 'GEOCERCA_ACTIVA'")
If c.RowCount > 0 Then
c.Position = 0
If c.Getstring("CAT_VA_VALOR") = 0 Then activa = False
End If
' Log("Geocerca habilitada: " & activa)
Return activa
End Sub
Sub estamosEnAlmacen(rango As Int) As Boolean
Dim l1, l2 As Location
Dim res As Boolean = False
Dim latAlmacen As String
Dim lonAlmacen As String
Try
l1.Initialize2(B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps)
Private x As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'COORDS_ALMACEN'"$)
If x.RowCount > 0 Then
x.Position = 0
Dim coords() As String = Regex.Split(",", x.GetString("CAT_VA_VALOR"))
latAlmacen = coords(0)
lonAlmacen = coords(1)
End If
' Log($"Coordenadas del almacen - lat:${latAlmacen}, lon:${lonAlmacen}"$)
l2.Initialize2(latAlmacen, lonAlmacen)
Dim distance As Long = l1.DistanceTo(l2) 'the result is in meters
If distance <= rango Then res = True
' Log("Dentro del almacen: " & res)
Catch
Log(LastException)
End Try
Return res
End Sub

View File

@@ -192,6 +192,7 @@ Sub flp_LocationChanged (Location1 As Location)
End If
CallSub2(Starter, "GPS_LocationChanged", Location1)
CallSub2(B4XPages.MainPage, "GPS_LocationChanged", Location1)
' CallSub2(gestion, "GPS_LocationChanged", Location1)
' CallSub2(B4XPages.GetPage("Cliente"), "GPS_LocationChanged", Location1)
' CallSub2(nuevocliente, "GPS_LocationChanged", Location1)
@@ -294,4 +295,4 @@ Sub revisaUUG 'ignore
Catch
LogColor("If FLP.IsInitialized --> "&LastException, Colors.Red)
End Try
End Sub
End Sub