Commit inicial.
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
**/Objects
|
||||
**/AutoBackups
|
||||
*.meta
|
||||
3
.ttxfolder
Normal file
@@ -0,0 +1,3 @@
|
||||
#Folder properties -- MetaCtrl
|
||||
#Fri Jul 08 00:22:52 CDT 2022
|
||||
folderid=181dc42c795
|
||||
24
B4A/B4XCliente.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
24
B4A/B4XClientes.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
659
B4A/B4XMainPage.bas
Normal file
@@ -0,0 +1,659 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=9.85
|
||||
@EndOfDesignText@
|
||||
#Region Shared Files
|
||||
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
|
||||
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
|
||||
'Ctrl + click to sync files con Github Desktop ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=github&Args=..\..\
|
||||
#End Region
|
||||
|
||||
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
|
||||
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView
|
||||
Private xui As XUI
|
||||
Public login As B4XMainPage
|
||||
Public principal As C_Principal
|
||||
Public clientes As C_Clientes
|
||||
Public cliente As C_Cliente
|
||||
Public productos As C_Productos
|
||||
Public updateAvailable As C_UpdateAvailable
|
||||
Public mapas As C_Mapas
|
||||
Public nuevoCliente As C_NuevoCliente
|
||||
Public ticketsDia As C_TicketsDia
|
||||
Public noVenta As C_NoVenta
|
||||
Public nota As C_Nota
|
||||
Public pedidos As C_Pedidos
|
||||
Public promos As C_Promos
|
||||
Public historico As C_Historico
|
||||
Public Provider As FileProvider
|
||||
|
||||
'nuevocliente -> NuevoCliente
|
||||
'buscar -> ticketsDia
|
||||
'colonia -> clientes
|
||||
'nopago -> noVenta
|
||||
'tarjeta -> Nota
|
||||
'fila -> Cliente
|
||||
'colonia2 -> Productos
|
||||
|
||||
'xxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
Dim reqManager As DBRequestManager
|
||||
Dim v As String = Application.VersionName
|
||||
Dim ruta As String
|
||||
Dim tgl As Toggle
|
||||
Dim lat_gps, lon_gps As String
|
||||
Dim usuario As String
|
||||
Dim batt As Int
|
||||
Dim skmt As SQL
|
||||
Dim montoActual, clientesTotal, clientesVenta, clientesVisitados,almacen, rutaPreventa As String
|
||||
Dim server, fechaRuta As String
|
||||
Dim Logger As Boolean
|
||||
Dim mac_impresora As String
|
||||
Dim Phn As PhoneId
|
||||
|
||||
Dim user As EditText
|
||||
Dim pass As EditText
|
||||
Dim c As Cursor
|
||||
Dim existe As String
|
||||
Dim paso1 As String
|
||||
Private IMEN As Label
|
||||
Dim IMEI As String = ""
|
||||
Dim alterno As String
|
||||
Private b_menu As Button
|
||||
Dim PopupMenu As RSPopupMenu
|
||||
Dim cmd As DBCommand
|
||||
Private PDF As Button
|
||||
Private bpv1 As BatteryProgressView
|
||||
Dim batterystatus(11) As Int
|
||||
Private bu As BatteryUtilities
|
||||
Private b_apk As Button
|
||||
Private i_engrane As ImageView
|
||||
Private p_Main As Panel
|
||||
Private p_appUpdate As Panel
|
||||
Private b_regesar As Button
|
||||
Private l_version As Label
|
||||
Private ImageView1 As ImageView
|
||||
Private Label2 As Label
|
||||
Private Entrar As Button
|
||||
Dim tipo_venta As String
|
||||
Dim bTerminarClicked As Boolean = False
|
||||
Private lv_server As ListView
|
||||
Private l_server As Label
|
||||
Private b_enviarbd As Button
|
||||
Private b_importarBD As Button
|
||||
Dim ime As IME
|
||||
End Sub
|
||||
|
||||
Public Sub Initialize
|
||||
' B4XPages.GetManager.LogEvents = True
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
B4XPages.GetManager.LogEvents = True
|
||||
Root = Root1
|
||||
Root.LoadLayout("login")
|
||||
B4XPages.SetTitle(Me, "Intmex Preventa")
|
||||
login.Initialize
|
||||
B4XPages.AddPage("Login", login)
|
||||
principal.Initialize
|
||||
B4XPages.AddPage("Principal", principal)
|
||||
clientes.Initialize
|
||||
B4XPages.AddPage("Clientes", clientes)
|
||||
cliente.Initialize
|
||||
B4XPages.AddPage("Cliente", cliente)
|
||||
productos.Initialize
|
||||
B4XPages.AddPage("Productos", productos)
|
||||
updateAvailable.Initialize
|
||||
B4XPages.AddPage("updateAvailable", updateAvailable)
|
||||
mapas.Initialize
|
||||
B4XPages.AddPage("Mapas", mapas)
|
||||
nuevoCliente.Initialize
|
||||
B4XPages.AddPage("NuevoCliente", nuevoCliente)
|
||||
ticketsDia.Initialize
|
||||
B4XPages.AddPage("TicketsDia", ticketsDia)
|
||||
noVenta.Initialize
|
||||
B4XPages.AddPage("NoVenta", noVenta)
|
||||
nota.Initialize
|
||||
B4XPages.AddPage("Nota", nota)
|
||||
pedidos.Initialize
|
||||
B4XPages.AddPage("Pedidos", pedidos)
|
||||
promos.Initialize
|
||||
B4XPages.AddPage("Promos", promos)
|
||||
historico.Initialize
|
||||
B4XPages.AddPage("Historico", historico)
|
||||
ruta = Starter.ruta
|
||||
Provider.Initialize
|
||||
Subs.borraArribaDe100Errores ' Para Websockets
|
||||
Subs.borraArribaDe600RenglonesBitacora ' Para Websockets
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
LogColor("copiamos kmt.db de "&File.DirAssets & " a " & ruta,Colors.Green)
|
||||
End If
|
||||
|
||||
Log(ruta)
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_CUOTAS (HC_META6 TEXT, HC_META5 TEXT, HC_META4 TEXT, HC_META3 TEXT, HC_META2 TEXT, HC_META1 TEXT, HC_RUTA TEXT, HC_CUOTA1 TEXT, HC_CUOTA2 TEXT, HC_CUOTA3 TEXT, HC_CUOTA4 TEXT, HC_CUOTA5 TEXT, HC_CUOTA6 TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_GPS (HGDATE TEXT, HGLAT TEXT, HGLON TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_STAY_STORE (HSS_CODIGO TEXT, HSS_IN TEXT, HSS_OUT TEXT, HSS_TOT TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_STAY_OUT (HSO_INI TEXT, HSO_FIN TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS INVENT_X_ENVIAR (ALMACEN TEXT, PROID TEXT, CANTIDAD TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_RESUM_APK (HIST_RA_OBJMES TEXT, HIST_RA_VENTA TEXT, HIST_RA_TENDENCIA TEXT, HIST_RA_ALCANCE TEXT, HISR_RA_DRAOBJ TEXT, HIST_RA_DRAVTA TEXT, HIST_RA_DSOBJ TEXT, HIST_RA_DSVTA TEXT, HIST_RA_VPOOBJ TEXT, HIST_RA_VPOVTA TEXT, HIST_RA_COBCCC TEXT, HIST_RA_CTES TEXT, HIST_RA_ECO TEXT, HIST_RA_VISITPLAN TEXT, HIST_RA_VISIREAL TEXT, HIST_RA_COBVISIT TEXT, HIST_RA_FRECCOMPOBJ TEXT, HIST_RA_FRECCOMREAL TEXT, HIST_RA_VENTAMES1 TEXT, HIST_RA_VENTAMES2 TEXT, HIST_RA_VENTAMES3 TEXT, HIST_RA_VENTAMES4 TEXT, HIST_RA_RECHAZO TEXT, HIST_RA_RECHAZOPORCEN TEXT, HIST_RA_SEMANA1 TEXT, HIST_RA_SEMANA1_DIAS TEXT, HIST_RA_SEMANA1_DRA TEXT, HIST_RA_SEMANA2 TEXT, HIST_RA_SEMANA2_DIAS TEXT, HIST_RA_SEMANA2_DRA TEXT, HIST_RA_SEMANA3 TEXT, HIST_RA_SEMANA3_DIAS TEXT, HIST_RA_SEMANA4 TEXT, HIST_RA_SEMANA3_DRA TEXT, HIST_RA_SEMANA4_DIAS TEXT, HIST_RA_SEMANA4_DRA TEXT, HIST_RA_SEMANA5 TEXT, HIST_RA_SEMANA5_DIAS TEXT, HIST_RA_SEMANA5_DRA TEXT, HIST_RA_SEMANA1_LPT TEXT, HIST_RA_SEMANA2_LPT TEXT, HIST_RA_SEMANA3_LPT TEXT, HIST_RA_SEMANA4_LPT TEXT, HIST_RA_SEMANA5_LPT TEXT, HIST_RA_RUTA TEXT, HIST_RA_IDALMACEN TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_COMISIONES_MOVIL (HCM_IDALMACEN TEXT, HCM_RUTA TEXT, HCM_TOTAL_V TEXT, HCM_TOTAL_VIVE TEXT, HCM_TOTAL_GUNA TEXT, HCM_TOTAL_BEB TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_GEOCERCA (HGCLIENTE TEXT, HGDATE TEXT, HGLAT TEXT, HGLON TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_FACE (HFCLIENTE TEXT, HFALIAS TEXT, HFRUTA TEXT, HFALMACEN TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS RUTA_GPS(FECHA INTEGER, LAT TEXT, LON TEXT)")
|
||||
skmt.ExecNonQuery("CREATE VIEW IF NOT EXISTS CATALOGO AS Select CAT_GP_CLASIF, CAT_GP_ID FROM CAT_GUNAPROD UNION Select CAT_GP_CLASIF, CAT_GP_ID FROM CAT_GUNAPROD GROUP BY CAT_GP_CLASIF, CAT_GP_ID")
|
||||
skmt.ExecNonQuery("CREATE VIEW IF NOT EXISTS total_marcas AS Select cat_gp_clasif, sum(pe_costo_tot) As total from CATALOGO, pedido where pe_proid = cat_gp_id And pe_cliente <> 0 group by cat_gp_clasif")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_MARCAS_CUOTAS ( HMC_MARCA TEXT, HMC_TOTAL TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS HIST_CODIGO_BARRAS(CODIGOKMTS TEXT, CODIGOB TEXT, LAT TEXT, LON TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS ABONOS (a_usuario TEXT, a_ruta TEXT, a_cliente TEXT, a_abono TEXT, a_fecha TEXT, a_enviado TEXT)")
|
||||
skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS COORDENADAS_GPS (tienda_id TEXT, ruta TEXT, almacen TEXT, latitud TEXT, longitud TEXT, fecha TEXT)")
|
||||
c=skmt.ExecQuery("select COUNT(*) AS CUANTOS from HIST_STAY_OUT ")
|
||||
C.Position = 0
|
||||
If c.GetString("CUANTOS") = 0 Then
|
||||
skmt.ExecNonQuery("INSERT INTO HIST_STAY_OUT(HSO_INI, HSO_FIN) VALUES (0,0)")
|
||||
End If
|
||||
C.Close
|
||||
' server = "http://keymon.com.mx:1782"
|
||||
'server = "http://201.99.139.28:1783"
|
||||
' reqManager.Initialize(Me, server)
|
||||
l_version.Text = Application.VersionName
|
||||
'este codigo es para lo del menu
|
||||
PopupMenu.Initialize("PopupMenu", b_menu)
|
||||
PopupMenu.AddMenuItem(0, 0, "View")
|
||||
PopupMenu.AddMenuItem(1, 1, "Edit")
|
||||
PopupMenu.AddMenuItem(2, 2, "Details")
|
||||
PopupMenu.AddMenuItem(3, 3, "Remove")
|
||||
' menu fin
|
||||
montoActual = 0
|
||||
clientesTotal = 0
|
||||
clientesVenta = 0
|
||||
clientesVisitados = 0
|
||||
almacen = 0
|
||||
rutaPreventa = 0
|
||||
p_appUpdate.Visible = False
|
||||
|
||||
LogColor("Revisa permisos Phone_State", Colors.Green)
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
If Result Then
|
||||
Log("Con permisos de ubicacion")
|
||||
Else
|
||||
Log("SIN permisos de ubicacion")
|
||||
End If
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_COARSE_LOCATION)
|
||||
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
If Result Then
|
||||
Log("Con permisos de ubicacion")
|
||||
Else
|
||||
Log("SIN permisos de ubicacion")
|
||||
End If
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_PHONE_STATE)
|
||||
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
If Result Then
|
||||
' IMEN.Text = Phn.GetDeviceId
|
||||
' IMEI = Phn.GetDeviceId
|
||||
' LogColor($"////////////////// IMEI: ${IMEI} ////////////////// "$, Colors.Blue)
|
||||
' IMEI="" 'Pruebas
|
||||
End If
|
||||
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
' If Result Then
|
||||
' StartService(Tracker)
|
||||
'' Log("Start Tracker")
|
||||
' Else
|
||||
' ToastMessageShow("No permission", True)
|
||||
' End If
|
||||
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
If Starter.muestraProgreso = 1 Then
|
||||
muestraProgreso("Descargando actualización")
|
||||
Starter.muestraProgreso = 0
|
||||
End If
|
||||
Dim ph As Phone 'Get Id Device
|
||||
Dim DeviceID As String = ph.GetSettings("android_id").ToUpperCase
|
||||
LogColor($"////////////////// DeviceID: ${DeviceID} ////////////////// "$, Colors.Blue)
|
||||
server = Starter.server
|
||||
reqManager.Initialize(Me, Starter.server)
|
||||
tgl.Initialize()
|
||||
If Not(Starter.gps.GPSEnabled) Then
|
||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||
Sleep(500)
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
End If
|
||||
c=skmt.ExecQuery2("select count(*) as CUANTOS from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("FECHA"))
|
||||
c.Position = 0
|
||||
If c.GetString("CUANTOS") = 0 Then
|
||||
LogColor($"No hay fecha: ${c.GetString("CUANTOS")}"$, Colors.Red)
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_fecha"
|
||||
reqManager.ExecuteQuery(cmd , 0, "fecha")
|
||||
Msgbox("AJUSTAR FECHA","AVISO") 'Ignore
|
||||
B4XPage_Appear
|
||||
Else
|
||||
' LogColor($"Si hay fecha: ${c.GetString("CUANTOS")}"$, Colors.Green)
|
||||
c=skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("FECHA"))
|
||||
c.Position =0
|
||||
Dim sDate, sTime As String
|
||||
DateTime.DateFormat = "yyyyMMdd"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
' If sDate > "20220701" Then
|
||||
' Msgbox("INSTALAR NUEVO APK" ,"AVISO") 'Ignore
|
||||
' B4XPage_Appear
|
||||
' End If
|
||||
If c.GetString("CAT_VA_VALOR") > sDate Then
|
||||
Msgbox("AJUSTAR LA FECHA YA QUE ES MENOR AL SISTEMA" ,"AVISO") 'Ignore
|
||||
B4XPage_Appear
|
||||
End If
|
||||
End If
|
||||
bu.Initialize
|
||||
batterystatus = bu.BatteryInformation
|
||||
'Obtenemos el usuario registrado
|
||||
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
|
||||
dameUsuario
|
||||
End Sub
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub Entrar_Click
|
||||
Dim r As Reflector
|
||||
Dim Api As Int
|
||||
Dim PP As Phone
|
||||
Api = r.GetStaticField("android.os.Build$VERSION", "SDK_INT")
|
||||
If Api < 9 Then
|
||||
'Old device
|
||||
If File.Exists(File.DirInternal, "__id") Then
|
||||
IMEI = File.ReadString(File.DirInternal, "__id")
|
||||
Log(1&"-"&IMEI)
|
||||
Else
|
||||
Dim id As Int
|
||||
id = Rnd(0x10000000, 0x7FFFFFFF)
|
||||
File.WriteString(File.DirInternal, "__id", id)
|
||||
IMEI = id
|
||||
Log(2&"-"&IMEI)
|
||||
End If
|
||||
Else
|
||||
'New device
|
||||
IMEI = r.GetStaticField("android.os.Build", "SERIAL")
|
||||
' Log(3&"-"&IMEI)
|
||||
End If
|
||||
If IMEI.ToLowerCase = "unknown" Then
|
||||
IMEI = PP.GetSettings("android_id")
|
||||
End If
|
||||
' Log("IMEI = " & IMEI)
|
||||
|
||||
If user.Text = "ALTERNO" Then
|
||||
c=skmt.ExecQuery2("select CAT_CO_CONFIGURACION, CAT_CO_RESULTADO from CAT_CODIGOS where CAT_CO_PONDERACION =1 AND CAT_CO_ACCION = ?", Array As String("SERVER"))
|
||||
c.Position =0
|
||||
server = c.GetString("CAT_CO_CONFIGURACION")
|
||||
alterno = c.GetString("CAT_CO_RESULTADO")
|
||||
c.Close
|
||||
If alterno = 1 Then
|
||||
skmt.ExecNonQuery2("UPDATE CAT_CODIGOS SET CAT_CO_PONDERACION = 1 WHERE CAT_CO_ACCION = ? AND CAT_CO_RESULTADO = 2", Array As String ("SERVER"))
|
||||
skmt.ExecNonQuery2("UPDATE CAT_CODIGOS SET CAT_CO_PONDERACION = 0 WHERE CAT_CO_ACCION = ? AND CAT_CO_RESULTADO = 1", Array As String ("SERVER"))
|
||||
Else if alterno = 2 Then
|
||||
skmt.ExecNonQuery2("UPDATE CAT_CODIGOS SET CAT_CO_PONDERACION = 1 WHERE CAT_CO_ACCION = ? AND CAT_CO_RESULTADO = 1", Array As String ("SERVER"))
|
||||
skmt.ExecNonQuery2("UPDATE CAT_CODIGOS SET CAT_CO_PONDERACION = 0 WHERE CAT_CO_ACCION = ? AND CAT_CO_RESULTADO = 2", Array As String ("SERVER"))
|
||||
End If
|
||||
c=skmt.ExecQuery2("select CAT_CO_CONFIGURACION, CAT_CO_RESULTADO from CAT_CODIGOS where CAT_CO_PONDERACION =1 AND CAT_CO_ACCION = ?", Array As String("SERVER"))
|
||||
c.Position =0
|
||||
server = c.GetString("CAT_CO_CONFIGURACION")
|
||||
user.Text = server
|
||||
c.Close
|
||||
' reqManager.Initialize(Me, server)
|
||||
else if user.Text = "KMTS1" Then
|
||||
skmt.ExecNonQuery("delete from usuarioa")
|
||||
skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(user.Text, pass.Text))
|
||||
skmt.ExecNonQuery("delete from cat_almacen")
|
||||
skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (pass.Text))
|
||||
skmt.ExecNonQuery("delete from VERSION")
|
||||
skmt.ExecNonQuery2("INSERT INTO VERSION(NOVERSION) VALUES (?)", Array As Object ("2.1"))
|
||||
B4XPages.ShowPage("Clientes")
|
||||
else if user.Text = "BERNA1" Then
|
||||
skmt.ExecNonQuery("delete from usuarioa")
|
||||
skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(user.Text, "1"))
|
||||
skmt.ExecNonQuery("delete from cat_almacen")
|
||||
skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object ("1"))
|
||||
skmt.ExecNonQuery("delete from VERSION")
|
||||
skmt.ExecNonQuery2("INSERT INTO VERSION(NOVERSION) VALUES (?)", Array As Object ("2.1"))
|
||||
B4XPages.ShowPage("Clientes")
|
||||
else if user.Text = "IMEI" Then
|
||||
user.Text = IMEI
|
||||
End If
|
||||
|
||||
c=skmt.ExecQuery2("select count(*) as EXISTE1 from usuarioa where usuario = ?", Array As String(user.Text))
|
||||
c.Position=0
|
||||
existe = c.GetString("EXISTE1")
|
||||
If existe = 0 Then
|
||||
If IMEI = "" Then
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_usuario_INTMEX_10" 'Antes select_usuario_guna_GV2_1
|
||||
cmd.Parameters = Array As Object(user.Text.Trim, pass.Text.Trim)
|
||||
reqManager.ExecuteQuery(cmd , 0, "usuario_10") 'Antes usuario
|
||||
Else
|
||||
If IMEI = "" Then
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_usuario_INTMEX_10"
|
||||
cmd.Parameters = Array As Object(user.Text.Trim, pass.Text.Trim)
|
||||
reqManager.ExecuteQuery(cmd , 0, "usuario_10")
|
||||
Else
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_usuario_INTMEX_10" 'Antes select_usuario_guna_GV2
|
||||
cmd.Parameters = Array As Object(user.Text.Trim, pass.Text.trim)
|
||||
Log("Mandamos: "&user.Text&"|"& pass.Text)
|
||||
reqManager.ExecuteQuery(cmd , 0, "usuario_10") 'Antes usuario
|
||||
End If
|
||||
End If
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_version_INTMEX"
|
||||
reqManager.ExecuteQuery(cmd , 0, "version")
|
||||
Else
|
||||
usuario = user.Text
|
||||
B4XPages.ShowPage("Principal")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
Log(Job.Success)
|
||||
If Job.Success = False Then
|
||||
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Else
|
||||
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211027
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||
If result.Tag = "version" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
skmt.ExecNonQuery("delete from VERSION")
|
||||
Dim CAT_VE_VERSION As String = records(result.Columns.Get("CAT_VE_VERSION"))
|
||||
skmt.ExecNonQuery2("INSERT INTO VERSION(NOVERSION) VALUES (?)", Array As Object (CAT_VE_VERSION))
|
||||
Next
|
||||
End If
|
||||
|
||||
If result.Tag = "select_fechat" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
For Each k As String In result.Columns.Keys
|
||||
Log("select_fechat: " & k & ": " & records(result.Columns.Get(k)))
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||
If result.Tag = "agencia" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
Dim ID_ALMACEN As String = records(result.Columns.Get("ID_ALMACEN"))
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||
If result.Tag = "fecha" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
Dim FECHA_HOY As String = records(result.Columns.Get("FECHA"))
|
||||
skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("FECHA"))
|
||||
skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("FECHA",FECHA_HOY))
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||
If result.Tag = "usuario" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
Dim name As String = records(result.Columns.Get("USUARIO"))
|
||||
Dim ID_ALMACEN As String = records(result.Columns.Get("CAT_LO_AGENCIA"))
|
||||
Dim IMEI_BASE As String = records(result.Columns.Get("CAT_LO_IDTELEFONO"))
|
||||
Log(records(result.Columns.Get("CAT_LO_IDTELEFONO")) )
|
||||
Next
|
||||
paso1 = 1
|
||||
ToastMessageShow(name, False)
|
||||
Log("////////////////////////// "&name)
|
||||
End If
|
||||
End If
|
||||
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||
If result.Tag = "usuario_10" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
Dim name As String = records(result.Columns.Get("USUARIO"))
|
||||
Dim ID_ALMACEN As String = records(result.Columns.Get("CAT_LO_AGENCIA"))
|
||||
Dim IMEI_BASE As String = records(result.Columns.Get("CAT_LO_IDTELEFONO"))
|
||||
Next
|
||||
Log("|"&name&"|")
|
||||
paso1 = 1
|
||||
IMEI_BASE = ""
|
||||
IMEI = ""
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End If
|
||||
Log($"Paso1 = ${paso1} - Name: ${name} - IMEI: ${IMEI} - IMEI_BASE: ${IMEI_BASE}"$)
|
||||
If paso1 = 1 Then
|
||||
If IMEI = "" Then
|
||||
If user.Text = "KMTS1" Then name = "OKActivo"
|
||||
If name = "OKActivo" Then
|
||||
skmt.ExecNonQuery("delete from usuarioa")
|
||||
skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(user.Text.Trim, pass.Text.Trim))
|
||||
skmt.ExecNonQuery("delete from cat_almacen")
|
||||
skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (ID_ALMACEN))
|
||||
usuario = user.Text
|
||||
B4XPages.ShowPage("Principal")
|
||||
Else If name = "OKExpirado" Then
|
||||
Msgbox("Usuario Expirado llamar al administrador","") 'Ignore
|
||||
Else If name = "OKCancelado" Then
|
||||
Msgbox("Usuario Cancelado llamar al administrador","") 'Ignore
|
||||
Else
|
||||
Msgbox("Usuario o password No validos","") 'Ignore
|
||||
End If
|
||||
paso1 = 0
|
||||
Else
|
||||
If name = "OKActivo" & IMEI And IMEI = IMEI_BASE Then
|
||||
If name = "OKActivo" & IMEI Then
|
||||
skmt.ExecNonQuery("delete from usuarioa")
|
||||
skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(user.Text.Trim, pass.Text.Trim))
|
||||
skmt.ExecNonQuery("delete from cat_almacen")
|
||||
skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (ID_ALMACEN))
|
||||
usuario = user.Text
|
||||
B4XPages.ShowPage("Clientes")
|
||||
Else If name = "OKExpirado"& IMEI Then
|
||||
Msgbox("Usuario Expirado llamar al administrador","") 'ignore
|
||||
Else If name = "OKCancelado"& IMEI Then
|
||||
Msgbox("Usuario Cancelado llamar al administrador","") 'ignore
|
||||
Else
|
||||
Msgbox("Usuario o password No validos","") 'ignore
|
||||
End If
|
||||
paso1 = 0
|
||||
Else IF name = "OKActivo" Then
|
||||
Msgbox("Telefono no VALIDO!","") 'ignore
|
||||
Else
|
||||
Msgbox("Usuario o password No validos","") 'ignore
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
Log("closreq")
|
||||
Sleep(0)
|
||||
If p_appUpdate.IsInitialized And p_appUpdate.Visible Then
|
||||
p_appUpdate.Visible = False
|
||||
Return False
|
||||
End If
|
||||
If Not(p_appUpdate.Visible) Then
|
||||
Log("ExitApplication")
|
||||
ExitApplication
|
||||
End If
|
||||
Return True
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
If user.text = "GPS" Then
|
||||
user.Text=Location1.Latitude
|
||||
pass.text=Location1.Longitude
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub PopupMenu_Dismiss
|
||||
ToastMessageShow("PopupMenu dismissed", False)
|
||||
End Sub
|
||||
|
||||
Sub PopupMenu_MenuItemClick (ItemId As Int) As Boolean
|
||||
ToastMessageShow("Item " & ItemId & " clicked.", False)
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub b_menu_Click
|
||||
PopupMenu.Show
|
||||
End Sub
|
||||
|
||||
Sub PDF_Click
|
||||
|
||||
End Sub
|
||||
|
||||
'Private Sub GetAdvertisingId As ResumableSub
|
||||
' Dim jo As JavaObject = Me
|
||||
' jo.RunMethod("GetAdvertisingId", Null)
|
||||
' Wait For AdvertisingId_Ready (Success As Boolean, Id As String)
|
||||
' Return Id
|
||||
'End Sub
|
||||
|
||||
Sub dameUsuario
|
||||
c=skmt.ExecQuery2("select count(*) as EXISTE1 from usuarioa where usuario = ?", Array As String(user.Text))
|
||||
c.Position=0
|
||||
existe = c.GetString("EXISTE1")
|
||||
c.Close
|
||||
If existe > 0 Then
|
||||
c=skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
Else
|
||||
usuario = "SINUSUARIO"
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'#if Java
|
||||
'import java.util.concurrent.Callable;
|
||||
'import com.google.android.gms.ads.identifier.AdvertisingIdClient;
|
||||
'import com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;
|
||||
'
|
||||
'public static void GetAdvertisingId() {
|
||||
' BA.runAsync(processBA, mostCurrent, "advertisingid_ready", new Object[] {false, ""}
|
||||
' , new Callable<Object[]>() {
|
||||
' @Override
|
||||
' public Object[] call() throws Exception {
|
||||
' String id = AdvertisingIdClient.getAdvertisingIdInfo(mostCurrent).getId();
|
||||
' return new Object[] {true, id};
|
||||
' }
|
||||
' }); }
|
||||
'#End If
|
||||
|
||||
Sub copiaDB
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
|
||||
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
Dim theDir As String = ""
|
||||
If Result Then
|
||||
' Private x As String
|
||||
' If File.ExternalWritable Then
|
||||
' x = File.DirRootExternal
|
||||
' Else
|
||||
' x = File.DirInternal
|
||||
' End If
|
||||
Dim theDir As String
|
||||
Try
|
||||
File.MakeDir(File.DirRootExternal,"kmts")
|
||||
theDir = "/kmts"
|
||||
Catch
|
||||
theDir = ""
|
||||
End Try
|
||||
Try
|
||||
File.Copy(File.DirInternal,"kmt.db",File.DirRootExternal&theDir, "intmex_kmt.db")
|
||||
ToastMessageShow("Listo, copiado a " & File.DirRootExternal&theDir & "/intmex_kmt.db", False)
|
||||
Catch
|
||||
ToastMessageShow("No se pudo hacer la copia: "&LastException, True)
|
||||
End Try
|
||||
Else
|
||||
ToastMessageShow("Sin permisos", False)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub b_apk_Click
|
||||
StartService(appUpdater)
|
||||
End Sub
|
||||
|
||||
'appUpdater - Mostramos el anuncio de que se esta descargando el nuevo apk
|
||||
Sub muestraProgreso(mensaje As String)
|
||||
ProgressDialogShow(mensaje)
|
||||
End Sub
|
||||
|
||||
'appUpdater - Ocultamos el anuncio de que se esta descargando el nuevo apk
|
||||
Sub ocultaProgreso
|
||||
ProgressDialogHide
|
||||
End Sub
|
||||
|
||||
Sub i_engrane_Click
|
||||
lv_server.Clear
|
||||
ime.HideKeyboard
|
||||
lv_server.AddSingleLine("http://keymon.lat:1782")
|
||||
If user.Text = "KMTS1" Then lv_server.AddSingleLine("http://10.0.0.205:1782")
|
||||
l_server.Text = Starter.server
|
||||
Subs.panelVisible(p_appUpdate,0,0)
|
||||
If user.Text.trim = "KMTS1" Then b_importarBD.Visible = True Else b_importarBD.Visible = False
|
||||
End Sub
|
||||
|
||||
Sub b_regesar_Click
|
||||
Subs.panelVisible(p_Main,0,0)
|
||||
End Sub
|
||||
|
||||
Sub i_engrane_LongClick
|
||||
copiaDB
|
||||
End Sub
|
||||
|
||||
Sub Entrar_LongClick
|
||||
' dim a as int = "a"
|
||||
End Sub
|
||||
|
||||
Private Sub lv_server_ItemClick (Position As Int, Value As Object)
|
||||
Starter.server = Value
|
||||
l_server.Text = Value
|
||||
Starter.reqManager.Initialize(Me, Value)
|
||||
ToastMessageShow("Servidor modificado", False)
|
||||
End Sub
|
||||
|
||||
Private Sub b_enviarbd_Click
|
||||
' copiaDB
|
||||
' Sleep(1000)
|
||||
Dim FileName As String = "kmt.db"
|
||||
'copy the shared file to the shared folder
|
||||
Log("xxxxxx:"&Provider.SharedFolder)
|
||||
Sleep(1000)
|
||||
File.Copy(File.DirInternal, FileName, Provider.SharedFolder, FileName)
|
||||
Dim email As Email
|
||||
email.To.Add("soporte@keymonsoft.com")
|
||||
email.Subject = "Envio Base de datos INTMEX"
|
||||
email.Attachments.Add(Provider.GetFileUri(FileName))
|
||||
' email.Attachments.Add(Provider.GetFileUri(FileName)) 'second attachment
|
||||
Dim in As Intent = email.GetIntent
|
||||
in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
|
||||
StartActivity(in)
|
||||
End Sub
|
||||
|
||||
Private Sub b_importarBD_Click
|
||||
Private FH As FileHandler
|
||||
FH.Initialize
|
||||
Wait For (FH.Load) Complete (Result As LoadResult) 'Abre un fileManager para seleccionar la base de datos a importar.
|
||||
File.Copy(Result.Dir, Result.FileName, File.DirInternal, "kmt.db") 'Copia la base de datos seleccionada al directorio interno.
|
||||
B4XPages.MainPage.skmt.Initialize(Starter.ruta,"kmt.db", True) 'Reiniciliza la base de datos con la recien importada.
|
||||
ToastMessageShow("¡BD importada!", False)
|
||||
End Sub
|
||||
24
B4A/B4XMapaRutas.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
24
B4A/B4XMapas.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
24
B4A/B4XNoVenta.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
24
B4A/B4XNota.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
24
B4A/B4XNuevoCliente.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
2100
B4A/B4XPrincipal.bas
Normal file
24
B4A/B4XProductos.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
24
B4A/B4XTicketsDia.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
24
B4A/B4XUpdateAvailable.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
126
B4A/BatteryUtilities.bas
Normal file
@@ -0,0 +1,126 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=9.5
|
||||
@EndOfDesignText@
|
||||
'Class module
|
||||
Sub Class_Globals
|
||||
Private nativeMe As JavaObject
|
||||
|
||||
End Sub
|
||||
'Initializes the object.
|
||||
Public Sub Initialize
|
||||
nativeMe = Me
|
||||
End Sub
|
||||
'Return information about the battery status. It returns the following 11 values in an integer Array:
|
||||
'EXTRA_LEVEL = current battery level, from 0 To EXTRA_SCALE.
|
||||
'EXTRA_SCALE = the maximum battery level possible.
|
||||
'EXTRA_HEALTH = the current health constant.
|
||||
'EXTRA_ICON_SMALL = the resource ID of a small status bar icon indicating the current battery state.
|
||||
'EXTRA_PLUGGED = whether the device is plugged into a Power source; 0 means it is on battery, other constants are different types of Power sources.
|
||||
'EXTRA_STATUS = the current status constant.
|
||||
'EXTRA_TEMPERATURE = the current battery temperature.
|
||||
'EXTRA_VOLTAGE = the current battery voltage level.
|
||||
'A value indicating if the battery is being charged or fully charged (If neither it returns 0 Else it returns 1)
|
||||
'A value indicating if it is charging via USB (0 = Not USB, 2 = USB)
|
||||
'A value indicating if it is charging via AC (0 = Not AC, 1 = AC)
|
||||
Public Sub getBatteryInformation () As Int()
|
||||
|
||||
Dim batteryInfo(11) As Int
|
||||
batteryInfo = nativeMe.RunMethod("getBatteryInformation",Null)
|
||||
Return batteryInfo
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub getBatteryTechnolgy() As String
|
||||
|
||||
Dim batterytech As String
|
||||
batterytech = nativeMe.RunMethod("getBatteryTechnology",Null)
|
||||
Return batterytech
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
#If Java
|
||||
|
||||
import android.os.BatteryManager;
|
||||
import android.os.Bundle;
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
public int[] getBatteryInformation() {
|
||||
|
||||
int[] mybat = new int[11];
|
||||
|
||||
Intent batteryIntent = ba.context.getApplicationContext().registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
|
||||
int level = batteryIntent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
|
||||
mybat[0] = level;
|
||||
int scale = batteryIntent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
|
||||
mybat[1] = scale;
|
||||
int health = batteryIntent.getIntExtra(BatteryManager.EXTRA_HEALTH,-1);
|
||||
mybat[2] = health;
|
||||
int icon_small = batteryIntent.getIntExtra(BatteryManager.EXTRA_ICON_SMALL,-1);
|
||||
mybat[3] = icon_small;
|
||||
int plugged = batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED,-1);
|
||||
mybat[4] = plugged;
|
||||
// boolean present = batteryIntent.getExtras().getBoolean(BatteryManager.EXTRA_PRESENT);
|
||||
int status = batteryIntent.getIntExtra(BatteryManager.EXTRA_STATUS,-1);
|
||||
mybat[5] = status;
|
||||
// String technology = batteryIntent.getExtras().getString(BatteryManager.EXTRA_TECHNOLOGY);
|
||||
// BA.Log("Technology = " + technology);
|
||||
int temperature = batteryIntent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE,-1);
|
||||
mybat[6] = temperature;
|
||||
int voltage = batteryIntent.getIntExtra(BatteryManager.EXTRA_VOLTAGE,-1);
|
||||
mybat[7] = voltage;
|
||||
// int ac = batteryIntent.getIntExtra("plugged",BatteryManager.BATTERY_PLUGGED_AC);
|
||||
// mybat[8] = ac;
|
||||
// int usb = batteryIntent.getIntExtra("plugged",BatteryManager.BATTERY_PLUGGED_USB);
|
||||
// mybat[9] = usb;
|
||||
|
||||
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING ||
|
||||
status == BatteryManager.BATTERY_STATUS_FULL;
|
||||
mybat[8] = 0;
|
||||
if (isCharging == true) {
|
||||
mybat[8] = 1;
|
||||
}
|
||||
|
||||
// How are we charging?
|
||||
mybat[9] = 0;
|
||||
mybat[10] = 0;
|
||||
int chargePlug = batteryIntent.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1);
|
||||
boolean usbCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_USB;
|
||||
if (usbCharge == true) {
|
||||
mybat[9] = 2;
|
||||
}
|
||||
|
||||
boolean acCharge = chargePlug == BatteryManager.BATTERY_PLUGGED_AC;
|
||||
if (acCharge == true) {
|
||||
mybat[10] = 1;
|
||||
}
|
||||
|
||||
return mybat;
|
||||
}
|
||||
|
||||
|
||||
public String getBatteryTechnology() {
|
||||
|
||||
Intent batteryIntent = ba.context.getApplicationContext().registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
|
||||
|
||||
String technology = batteryIntent.getExtras().getString(BatteryManager.EXTRA_TECHNOLOGY);
|
||||
|
||||
return technology;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#End If
|
||||
1060
B4A/C_Cliente.bas
Normal file
317
B4A/C_Clientes.bas
Normal file
@@ -0,0 +1,317 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
|
||||
' Dim skmt As SQL
|
||||
Dim c As Cursor
|
||||
Dim c2 As Cursor
|
||||
Dim d As Cursor
|
||||
Dim s As Cursor
|
||||
Dim ListView1 As ListView
|
||||
Dim entro As String
|
||||
Dim gest As Button
|
||||
Dim lfila As Label
|
||||
Dim busca As EditText
|
||||
Dim colonia As String
|
||||
Private b_qr As Button
|
||||
Private qr As QRCode
|
||||
' Dim sc As Zxing_scanner
|
||||
Dim CODIGO As String
|
||||
Dim STIME As String
|
||||
|
||||
Dim ruta As String
|
||||
Dim q_buscar As String
|
||||
Private p_clientes As Panel
|
||||
Private CustomListView1 As CustomListView
|
||||
Private numerocliente As Label
|
||||
Private nombrecliente As Label
|
||||
Private direccion As Label
|
||||
Private cxc As Label
|
||||
Private p_datosclie As Panel
|
||||
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("clientes")
|
||||
'Dim ruta As String
|
||||
entro ="2"
|
||||
' valido donde escribo el archivo de la base de datos de kmt
|
||||
' If File.ExternalWritable Then
|
||||
' ruta = File.DirDefaultExternal
|
||||
' Else
|
||||
ruta = File.DirInternal
|
||||
' End If
|
||||
|
||||
' se crea o no el archivo de la base de ddatos de kmt
|
||||
'NOTAS SI SE MODIFICA LA ESTRUCTURA SE QUITA EL IF Y SE VA DIRECTO A LA SENTENCIA FILE.COPY PARA QUE
|
||||
'TOME LA NUEVA ESTRUCTURA ES MUY IMPORTANTE TENER EL IF DE LO CONTRARIO SOLO LO ESCRIBE UNA VEZ Y LO BORRA
|
||||
'SI SE REGRESA A ESTE ACTIVIDAD.
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
qr.initialize
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
busca.Text = ""
|
||||
entro ="2"
|
||||
colonia = 0
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_CODIGO from kmt_info where gestion = 0 ORDER BY CAT_CL_CODIGO")
|
||||
ListView1.Clear
|
||||
lfila.Text = "NOMBRE"
|
||||
|
||||
CustomListView1.Clear
|
||||
For i = 0 To c.RowCount - 1
|
||||
c.Position = i
|
||||
CustomListView1.Add(CreateListItem(c.GetString("CAT_CL_NOMBRE"),c.GetString("CAT_CL_CALLE"),c.GetString("CAT_CL_CODIGO")),i)
|
||||
d = B4XPages.MainPage.skmt.ExecQuery($"select CLIENTE FROM ABONOSP WHERE CLIENTE = '${c.GetString("CAT_CL_CODIGO")}'"$)
|
||||
If d.RowCount = 0 Then
|
||||
cxc.Visible = False
|
||||
Else
|
||||
cxc.Visible = True
|
||||
End If
|
||||
d.Close
|
||||
Next
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 13
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 13
|
||||
label2.TextColor = Colors.Black
|
||||
ListView1.AddTwoLines(c.GetString("CAT_CL_CODIGO"), c.GetString("CAT_CL_NOMBRE"))
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
entro = "4"
|
||||
End Sub
|
||||
|
||||
Sub CreateListItem(mostrar As String, mostrar1 As String, mostrar2 As String) As Panel
|
||||
Dim p As B4XView = xui.CreatePanel("")
|
||||
p.SetLayoutAnimated(0, 0, 0, 1, 220)
|
||||
p.LoadLayout("datoscliente")
|
||||
p.Height= 60dip
|
||||
' p.Width = clv_orden.GetBase.Width
|
||||
nombrecliente.Text = mostrar
|
||||
direccion.Text = mostrar1
|
||||
numerocliente.Text = mostrar2
|
||||
p_datosclie.Tag = mostrar2
|
||||
' cxc.Text = mostrar3
|
||||
' Log(p.Width)
|
||||
Return p
|
||||
End Sub
|
||||
|
||||
Sub ListView1_ItemClick (Position As Int, value As Object)
|
||||
If colonia = 0 Then
|
||||
colonia = value
|
||||
End If
|
||||
If entro = "2" Then
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery2("select CAT_CL_CALLE, CAT_CL_COLONIA, count(*) as cuantos from kmt_info where gestion = 0 and CAT_CL_COLONIA = ? GROUP BY CAT_CL_CALLE, CAT_CL_COLONIA order by CAT_CL_CALLE ", Array As String(value))
|
||||
ListView1.Clear
|
||||
lfila.text = "Calle"
|
||||
If c2.RowCount>0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
ListView1.AddTwoLines(c2.GetString("CAT_CL_CALLE"),c2.GetString("cuantos") )
|
||||
Next
|
||||
End If
|
||||
entro = "3"
|
||||
Else If entro = "3" Then
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery2("select CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_CODIGO from kmt_info where gestion = 0 and CAT_CL_CALLE = ? AND CAT_CL_COLONIA = ? order by CAT_CL_NOMBRE ", Array As String(value, colonia))
|
||||
ListView1.Clear
|
||||
lfila.text = "Nombre"
|
||||
If c2.RowCount>0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
ListView1.AddTwoLines(c2.GetString("CAT_CL_CODIGO"), c2.GetString("CAT_CL_NOMBRE"))
|
||||
Next
|
||||
End If
|
||||
entro = "4"
|
||||
Else If entro = "4" Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(value))
|
||||
DateTime.TimeFormat = "HHmmss"
|
||||
STIME=DateTime.Time(DateTime.Now)
|
||||
|
||||
s=B4XPages.MainPage.skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM HIST_STAY_STORE WHERE HSS_IN = ? AND HSS_CODIGO In (select cuenta from cuentaa)", Array As String("0"))
|
||||
s.Position = 0
|
||||
If s.GetString("CUANTOS") = 1 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_IN = ? where HSS_IN = 0 AND HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(STIME))
|
||||
Else
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_STAY_STORE(HSS_CODIGO, HSS_IN , HSS_OUT , HSS_TOT) VALUES (?,0,0,0)", Array As Object (value))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_IN = ? where HSS_IN = 0 AND HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(STIME))
|
||||
End If
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_OUT set HSO_INI = ? where HSO_INI = 0 ", Array As Object(STIME))
|
||||
DateTime.TimeFormat = "HH:mm:ss"
|
||||
|
||||
Subs.guardaClienteHoraInicio(value)
|
||||
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
'Return True to close, False to cancel
|
||||
' If key=KeyCodes.KEYCODE_BACK Then
|
||||
' StartActivity(seleccion)
|
||||
' Return False
|
||||
' End If
|
||||
Return True
|
||||
End Sub
|
||||
|
||||
Sub BUSCA_TextChanged (Old As String, New As String)
|
||||
q_buscar = "%" & busca.Text & "%"
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery2("select CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_CODIGO from kmt_info where (CAT_CL_NOMBRE like ? OR CAT_CL_CODIGO LIKE ? OR CAT_CL_CALLE LIKE ?)and gestion = 0 order by CAT_CL_NOMBRE ", Array As String(q_buscar,q_buscar,q_buscar))
|
||||
ListView1.Clear
|
||||
lfila.text = "Nombre y Calle"
|
||||
|
||||
CustomListView1.Clear
|
||||
For i = 0 To c2.RowCount - 1
|
||||
c2.Position = i
|
||||
CustomListView1.Add(CreateListItem(c2.GetString("CAT_CL_NOMBRE"),c2.GetString("CAT_CL_CALLE"),c2.GetString("CAT_CL_CODIGO")),i)
|
||||
d = B4XPages.MainPage.skmt.ExecQuery($"select CLIENTE FROM ABONOSP WHERE CLIENTE = '${c2.GetString("CAT_CL_CODIGO")}'"$)
|
||||
If d.RowCount = 0 Then
|
||||
cxc.Visible = False
|
||||
Else
|
||||
cxc.Visible = True
|
||||
End If
|
||||
d.Close
|
||||
Next
|
||||
|
||||
|
||||
If c2.RowCount>0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 9
|
||||
label1.TextColor = Colors.White
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 17
|
||||
label2.TextColor = Colors.White
|
||||
ListView1.AddTwoLines(c2.GetString("CAT_CL_CODIGO"), c2.GetString("CAT_CL_NOMBRE") &" CALLE: "& c2.GetString("CAT_CL_CALLE"))
|
||||
Next
|
||||
End If
|
||||
entro = "4"
|
||||
c2.Close
|
||||
End Sub
|
||||
|
||||
Sub b_qr_Click
|
||||
Dim scan_width As Int
|
||||
Dim scan_height As Int
|
||||
scan_width = 400
|
||||
scan_height = 400
|
||||
End Sub
|
||||
|
||||
Sub sc_result(atype As String,Values As String)
|
||||
CODIGO = Values
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery2("select COUNT(*) AS ENCONTRADO from kmt_info where CAT_CL_NUM_SERIEFISICO = ? order by CAT_CL_NOMBRE ", Array As String(CODIGO))
|
||||
c2.Position =0
|
||||
If c2.GetString("ENCONTRADO") > 0 Then
|
||||
s=B4XPages.MainPage.skmt.ExecQuery2("select CAT_CL_CODIGO from kmt_info where CAT_CL_NUM_SERIEFISICO = ? order by CAT_CL_NOMBRE ", Array As String(CODIGO))
|
||||
s.Position =0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(s.GetString("CAT_CL_CODIGO")))
|
||||
s.Close
|
||||
' b_qr.Visible = False
|
||||
B4XPages.ShowPage("clientes")
|
||||
Else
|
||||
Msgbox("CODIGO " & CODIGO & " NO ENCONTRADO","AVISO") 'ignore
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub sc_noScan
|
||||
Log("nothing returned from the scan !!!!!")
|
||||
End Sub
|
||||
|
||||
Sub calc_ean_checksum(number As String) As String 'this has now become redundant as I am only interested in QR Codes
|
||||
Dim i As Int
|
||||
Dim cO As Char
|
||||
Dim soma As Int
|
||||
Dim n As Int
|
||||
Dim digit As Float
|
||||
soma = 0
|
||||
For i=0 To number.Length - 1
|
||||
digit = number.SubString2(i,i+1)
|
||||
n= digit * ((i Mod 2) * 2 + 1)
|
||||
soma=soma+n
|
||||
Next
|
||||
Return number & ( ( 10 - ( soma Mod 10 )) Mod 10 )
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Private Sub p_clientes_Click
|
||||
'Nada aqui, solo esta para que los clics no se pasen hacia atras.
|
||||
End Sub
|
||||
|
||||
Private Sub p_datosclie_Click
|
||||
If colonia = 0 Then
|
||||
colonia = Sender.As(Panel).tag
|
||||
End If
|
||||
If entro = "2" Then
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery2("select CAT_CL_CALLE, CAT_CL_COLONIA, count(*) as cuantos from kmt_info where gestion = 0 and CAT_CL_COLONIA = ? GROUP BY CAT_CL_CALLE, CAT_CL_COLONIA order by CAT_CL_CALLE ", Array As String(Sender.As(Panel).tag))
|
||||
ListView1.Clear
|
||||
lfila.text = "Calle"
|
||||
If c2.RowCount>0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
ListView1.AddTwoLines(c2.GetString("CAT_CL_CALLE"),c2.GetString("cuantos") )
|
||||
Next
|
||||
End If
|
||||
entro = "3"
|
||||
Else If entro = "3" Then
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery2("select CAT_CL_NOMBRE, CAT_CL_CALLE, CAT_CL_CODIGO from kmt_info where gestion = 0 and CAT_CL_CALLE = ? AND CAT_CL_COLONIA = ? order by CAT_CL_NOMBRE ", Array As String(Sender.As(Panel).tag, colonia))
|
||||
ListView1.Clear
|
||||
lfila.text = "Nombre"
|
||||
If c2.RowCount>0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
ListView1.AddTwoLines(c2.GetString("CAT_CL_CODIGO"), c2.GetString("CAT_CL_NOMBRE"))
|
||||
Next
|
||||
End If
|
||||
entro = "4"
|
||||
Else If entro = "4" Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(Sender.As(Panel).tag))
|
||||
DateTime.TimeFormat = "HHmmss"
|
||||
STIME=DateTime.Time(DateTime.Now)
|
||||
|
||||
s=B4XPages.MainPage.skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM HIST_STAY_STORE WHERE HSS_IN = ? AND HSS_CODIGO In (select cuenta from cuentaa)", Array As String("0"))
|
||||
s.Position = 0
|
||||
If s.GetString("CUANTOS") = 1 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_IN = ? where HSS_IN = 0 AND HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(STIME))
|
||||
Else
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_STAY_STORE(HSS_CODIGO, HSS_IN , HSS_OUT , HSS_TOT) VALUES (?,0,0,0)", Array As Object (Sender.As(Panel).tag))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_IN = ? where HSS_IN = 0 AND HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(STIME))
|
||||
End If
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_OUT set HSO_INI = ? where HSO_INI = 0 ", Array As Object(STIME))
|
||||
DateTime.TimeFormat = "HH:mm:ss"
|
||||
|
||||
Subs.guardaClienteHoraInicio(Sender.As(Panel).tag)
|
||||
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End If
|
||||
|
||||
|
||||
' Log(Sender.As(Panel).tag)
|
||||
End Sub
|
||||
123
B4A/C_Historico.bas
Normal file
@@ -0,0 +1,123 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
|
||||
Dim g As GPS
|
||||
Dim clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
|
||||
Dim c As Cursor
|
||||
Dim ruta As String
|
||||
Dim Regresar As Button
|
||||
|
||||
|
||||
Dim ListView1 As ListView
|
||||
Dim L_CANT As Label
|
||||
Dim L_TOTAL As Label
|
||||
Dim borra As Button
|
||||
Dim Existe As String
|
||||
Dim result As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
|
||||
Private Titulo As Label
|
||||
Private b_desc As Button
|
||||
Private ListView2 As ListView
|
||||
Dim tgl As Toggle
|
||||
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
|
||||
ruta = File.DirInternal
|
||||
Root.LoadLayout("nota")
|
||||
borra.Visible = False
|
||||
Titulo.Text = "Acumulado"
|
||||
b_desc.Visible = False
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
' skmt.Initialize(ruta,"kmt.db", True)
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
If Not(Starter.gps.GPSEnabled) Then
|
||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
End If
|
||||
L_CANT.Text =""
|
||||
L_TOTAL.Text=""
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select count(*) as EXISTE from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
Existe = C.GetString("EXISTE")
|
||||
C.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_PRONOMBRE asc")
|
||||
ListView1.Clear
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("HVD_PRONOMBRE"),"Cantidad #"& c.GetString("HVD_CANT")& " SubTotal $"& c.GetString("HVD_COSTO_TOT"))
|
||||
Next
|
||||
End If
|
||||
If Existe <> 0 Then
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select SUM(HVD_CANT) AS PC_NOART, SUM(HVD_COSTO_TOT) AS PC_MONTO from HIST_VENTAS where HVD_CLIENTE in (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
L_CANT.Text = c.GetString("PC_NOART")
|
||||
L_TOTAL.Text = c.GetString("PC_MONTO")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
'lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
'lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
End Sub
|
||||
|
||||
Sub Regresar_Click
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
' Return True To close, False To cancel
|
||||
B4XPages.ShowPage("Principal")
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub ListView2_ItemClick (Position As Int, Value As Object)
|
||||
ListView2.Visible = False
|
||||
ListView1.Visible = True
|
||||
End Sub
|
||||
|
||||
Sub ListView1_ItemClick (Position As Int, Value As Object)
|
||||
ListView2.Visible = True
|
||||
ListView1.Visible = False
|
||||
Dim label1 As Label
|
||||
For i=0 To 20
|
||||
label1 = ListView2.SingleLineLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
ListView2.AddSingleLine(i)
|
||||
Next
|
||||
End Sub
|
||||
263
B4A/C_MapaRutas.bas
Normal file
@@ -0,0 +1,263 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
|
||||
Dim GPS As GPS
|
||||
Dim rp As RuntimePermissions
|
||||
Dim ruta As String
|
||||
Dim skmt As SQL
|
||||
Dim c As Cursor
|
||||
Dim c2 As Cursor
|
||||
Dim c22 As Cursor
|
||||
Dim c3 As Cursor
|
||||
|
||||
Private gmap As GoogleMap
|
||||
Private MapFragment1 As MapFragment
|
||||
Dim Latitud As Double = 0
|
||||
Dim Longitud As Double = 0
|
||||
Dim Lat2 As Double = 0
|
||||
Dim Lon2 As Double = 0
|
||||
Dim p1, p2 As Location
|
||||
Dim Distance As Float
|
||||
Dim boton1 As Button
|
||||
Dim HUE_BLUE As Float
|
||||
Dim HUE_RED As Float
|
||||
Dim HUE_GREEN As Float
|
||||
Private B_AZUL As Button
|
||||
Private B_ROJO As Button
|
||||
Private B_VERDE As Button
|
||||
Private B_TODOS As Button
|
||||
Dim Tienda As String
|
||||
Dim LatitudRu As Double
|
||||
Dim LongitudRU As Double
|
||||
Dim LIST_AZUL As List
|
||||
Dim LIST_ROJO As List
|
||||
Dim LIST_VERDE As List
|
||||
Dim MARK_AZUL As Marker
|
||||
Dim MARK_ROJO As Marker
|
||||
Dim MARK_VERDE As Marker
|
||||
Dim MARK_CEDIS As Marker
|
||||
Dim rojo As String
|
||||
Dim azul As String
|
||||
Dim verde As String
|
||||
Dim todos As String
|
||||
Dim NumSerie As Int
|
||||
Dim OnInfoWindowClickListener1 As OnInfoWindowClickListener
|
||||
Dim GoogleMapEXTRA As GoogleMapsExtras
|
||||
Dim CODIGO As String
|
||||
Private SEMANA As String
|
||||
Private p_mapaRutas As Panel
|
||||
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("mapaRutas")
|
||||
ruta = File.DirInternal
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
GPS.Initialize("GPS")
|
||||
If MapFragment1.IsGooglePlayServicesAvailable = False Then
|
||||
ToastMessageShow("Please install Google Play Services.", True)
|
||||
End If
|
||||
MARK_AZUL.IsInitialized
|
||||
MARK_ROJO.IsInitialized
|
||||
MARK_VERDE.IsInitialized
|
||||
LIST_AZUL.Initialize
|
||||
LIST_ROJO.Initialize
|
||||
LIST_VERDE.Initialize
|
||||
verde = 0
|
||||
azul = 0
|
||||
rojo = 0
|
||||
todos = 1
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("select count(*) AS CUANTOS from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SEMANA"))
|
||||
c.Position =0
|
||||
SEMANA = c.GetString("CUANTOS")
|
||||
c.Close
|
||||
If SEMANA > 0 Then
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SEMANA"))
|
||||
c.Position =0
|
||||
SEMANA = c.GetString("CAT_VA_VALOR")
|
||||
c.Close
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub MapFragment1_Ready
|
||||
Log("ENTRANDO")
|
||||
gmap = MapFragment1.GetMap
|
||||
gmap.IsInitialized
|
||||
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
gmap.MyLocationEnabled = Result
|
||||
Dim JavaMapsObject As JavaObject
|
||||
JavaMapsObject = gmap.GetUiSettings
|
||||
JavaMapsObject.RunMethod("setMapToolbarEnabled", Array As Object(True))
|
||||
'''''''----------------------------MARKER AZUL - POR VISITAR
|
||||
If azul = 1 Or todos = 1 Then
|
||||
c.IsInitialized
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_CODIGO,CAT_CL_NOMBRE,CAT_CL_LAT,CAT_CL_LONG from kmt_info where gestion = 0 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 and CAT_CL_LAT <> ' ' and CAT_CL_LONG <> ' ' ")
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
If c.RowCount > 0 Then
|
||||
For i = 0 To c.RowCount - 1
|
||||
c.Position = i
|
||||
' Log(i&"|"&c.GetString("CAT_CL_LAT")&"|")
|
||||
LatitudRu = 0
|
||||
If c.GetString("CAT_CL_LAT") <> "" Then LatitudRu = c.GetString("CAT_CL_LAT")
|
||||
LongitudRU = 0
|
||||
If c.GetString("CAT_CL_LONG") <> "" Then LongitudRU = c.GetString("CAT_CL_LONG")
|
||||
CODIGO=c.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c.GetString("CAT_CL_NOMBRE")
|
||||
MARK_AZUL = gmap.AddMarker2(LatitudRu,LongitudRU,CODIGO, gmap.HUE_BLUE)
|
||||
MARK_AZUL.Snippet = Tienda
|
||||
Next
|
||||
End If
|
||||
c .Close
|
||||
If MARK_AZUL.IsInitialized Then LIST_AZUL.Add(MARK_AZUL)
|
||||
End If
|
||||
'''''''----------------------------MARKER VERDE - VENTA
|
||||
If verde =1 Or todos = 1 Then
|
||||
c2.IsInitialized
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE,CAT_CL_LONG,CAT_CL_LAT from kmt_info where gestion = 2 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0")
|
||||
For i = 0 To c2.RowCount -1
|
||||
c2.Position = i
|
||||
LongitudRU = c2.GetString("CAT_CL_LONG")
|
||||
LatitudRu = c2.GetString("CAT_CL_LAT")
|
||||
CODIGO=c2.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c2.GetString("CAT_CL_NOMBRE")
|
||||
MARK_VERDE = gmap.AddMarker2(LatitudRu,LongitudRU,CODIGO,gmap.HUE_GREEN)
|
||||
MARK_VERDE.Snippet = Tienda
|
||||
Next
|
||||
Else
|
||||
If verde =1 Or todos = 1 Then
|
||||
c2.IsInitialized
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE,CAT_CL_LONG,CAT_CL_LAT from kmt_info where gestion = 2 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0")
|
||||
For i = 0 To c2.RowCount -1
|
||||
c2.Position = i
|
||||
LongitudRU = c2.GetString("CAT_CL_LONG")
|
||||
LatitudRu = c2.GetString("CAT_CL_LAT")
|
||||
CODIGO=c2.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c2.GetString("CAT_CL_NOMBRE")
|
||||
MARK_VERDE = gmap.AddMarker2(LatitudRu,LongitudRU,CODIGO,gmap.HUE_GREEN)
|
||||
MARK_VERDE.Snippet = Tienda
|
||||
Next
|
||||
c2 .Close
|
||||
If MARK_VERDE.IsInitialized Then LIST_VERDE.Add(MARK_VERDE)
|
||||
End If
|
||||
End If
|
||||
' '''''''----------------------------MARKER ROJO - NO VENTA
|
||||
If rojo =1 Or todos = 1 Then
|
||||
c3.IsInitialized
|
||||
c3=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE,CAT_CL_LONG,CAT_CL_LAT from kmt_info where gestion = 3 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0")
|
||||
For i = 0 To c3.RowCount -1
|
||||
c3.Position = i
|
||||
LongitudRU = c3.GetDouble("CAT_CL_LONG")
|
||||
LatitudRu = c3.GetDouble("CAT_CL_LAT")
|
||||
Tienda= c3.GetString("CAT_CL_NOMBRE")
|
||||
MARK_ROJO = gmap.AddMarker2(LatitudRu,LongitudRU,Tienda, gmap.HUE_RED)
|
||||
Next
|
||||
Else
|
||||
If rojo =1 Or todos = 1 Then
|
||||
c3.IsInitialized
|
||||
c3=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE,CAT_CL_LONG,CAT_CL_LAT from kmt_info where gestion = 3 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0")
|
||||
For i = 0 To c3.RowCount -1
|
||||
c3.Position = i
|
||||
LongitudRU = c3.GetDouble("CAT_CL_LONG")
|
||||
LatitudRu = c3.GetDouble("CAT_CL_LAT")
|
||||
Tienda= c3.GetString("CAT_CL_NOMBRE")
|
||||
MARK_ROJO = gmap.AddMarker2(LatitudRu,LongitudRU,Tienda, gmap.HUE_RED)
|
||||
Next
|
||||
If MARK_ROJO.IsInitialized Then LIST_ROJO.Add(MARK_ROJO)
|
||||
c3.Close
|
||||
End If
|
||||
End If
|
||||
''------------------------------
|
||||
Dim aa As CameraPosition
|
||||
aa.Initialize(LatitudRu,LongitudRU,15)''' RECOMENDABLE CAMBIAR A 10 PARA QUE SE VEAN MAS MARCADORES
|
||||
gmap.AnimateCamera(aa)
|
||||
|
||||
'''''---------------------- ESTO ES PARA LOS CLICK EN LAS VENTANAS D INFORMACION-----------
|
||||
Dim OnInfoWindowClickListener1 As OnInfoWindowClickListener
|
||||
OnInfoWindowClickListener1.Initialize("OnInfoWindowClickListener1")
|
||||
GoogleMapEXTRA.SetOnInfoWindowClickListener(gmap, OnInfoWindowClickListener1)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub OnInfoWindowClickListener1_click(Marker1 As Marker)
|
||||
Log("mapclicked")
|
||||
Log("borramos cuentaa")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
Log("insertamos cuentaa")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?) ", Array As Object(Marker1.Title))
|
||||
Log("vamos a cliente")
|
||||
B4XPages.ShowPage("Cliente")
|
||||
B4XPages.ClosePage("MapaRutas")
|
||||
B4XPages.GetManager.ClosePage(Me)
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Parametro As Location)
|
||||
MARK_CEDIS.IsInitialized
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
If GPS.GPSEnabled = False Then
|
||||
ToastMessageShow("Debe Activar el GPS del Equipo.", True)
|
||||
StartActivity(GPS.LocationSettingsIntent)
|
||||
Else
|
||||
GPS.Start(0, 0)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub B_TODOS_Click
|
||||
todos =1
|
||||
verde = 0
|
||||
azul = 0
|
||||
rojo = 0
|
||||
MapFragment1_Ready
|
||||
End Sub
|
||||
|
||||
Sub B_VERDE_Click
|
||||
verde = 1
|
||||
azul = 0
|
||||
rojo = 0
|
||||
todos = 0
|
||||
gmap.Clear
|
||||
MapFragment1_Ready
|
||||
End Sub
|
||||
|
||||
Sub B_ROJO_Click
|
||||
rojo = 1
|
||||
verde = 0
|
||||
azul = 0
|
||||
todos = 0
|
||||
gmap.Clear
|
||||
MapFragment1_Ready
|
||||
End Sub
|
||||
|
||||
Sub B_AZUL_Click
|
||||
azul = 1
|
||||
verde = 0
|
||||
rojo = 0
|
||||
todos = 0
|
||||
gmap.Clear
|
||||
MapFragment1_Ready
|
||||
End Sub
|
||||
|
||||
Private Sub p_mapaRutas_Click
|
||||
|
||||
End Sub
|
||||
24
B4A/C_Mapas.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
171
B4A/C_NoVenta.bas
Normal file
@@ -0,0 +1,171 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
|
||||
Dim g As GPS
|
||||
Dim ruta As String
|
||||
Dim skmt As SQL
|
||||
Dim c As Cursor
|
||||
|
||||
Dim CANCELA As Button
|
||||
Dim GUARDA As Button
|
||||
Dim r_1 As RadioButton
|
||||
Dim r_2 As RadioButton
|
||||
Dim r_3 As RadioButton
|
||||
Dim e_comm As EditText
|
||||
Dim motivo As String
|
||||
Dim cuenta As String
|
||||
Dim usuario As String
|
||||
Dim sDate,sTime As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
Dim tgl As Toggle
|
||||
Dim r_4 As RadioButton
|
||||
Dim reqManager As DBRequestManager
|
||||
Private stay_hh As String
|
||||
Private stay_mi As String
|
||||
Private stay_ss As String
|
||||
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("noventa")
|
||||
ruta = File.DirInternal
|
||||
' End If
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
reqManager.Initialize(Me, B4XPages.MainPage.SERVER)
|
||||
' skmt.Initialize(ruta,"kmt.db", True)
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
e_comm.Text=""
|
||||
tgl.Initialize
|
||||
If Not(Starter.gps.GPSEnabled) Then
|
||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
'lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
'lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
End Sub
|
||||
|
||||
Sub CANCELA_Click
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
Sub GUARDA_Click
|
||||
If r_1.Checked Then
|
||||
motivo = "CERRADO"
|
||||
Else If r_2.Checked Then
|
||||
motivo = "NO COMPRA"
|
||||
Else If r_3.Checked Then
|
||||
motivo = "CON PRODUCTO"
|
||||
Else
|
||||
motivo = "NO ESTA EL ENCARGADO"
|
||||
End If
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CUENTA from cuentaa")
|
||||
c.Position = 0
|
||||
cuenta = c.GetString("CUENTA")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select usuario from usuarioa")
|
||||
c.Position = 0
|
||||
usuario = c.GetString("USUARIO")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select PE_PROID,PE_CANT FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) ")
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?", Array As Object(c.GetString("PE_CANT"),c.GetString("PE_PROID")))
|
||||
Next
|
||||
End If
|
||||
|
||||
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido where pe_cliente in (Select CUENTA from cuentaa)")
|
||||
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO NOVENTA (NV_CLIENTE,NV_FECHA,NV_USER,NV_MOTIVO,NV_COMM,NV_LAT,NV_LON) VALUES(?,?,?,?,?,?,?) ", Array As Object (cuenta,sDate & sTime, usuario, motivo,e_comm.text, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 3 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
DateTime.TimeFormat = "HHmmss"
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_OUT = ? where HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(sTime))
|
||||
' B4XPages.MainPage.skmt.ExecNonQuery("UPDATE HIST_STAY_STORE set HSS_TOT = HSS_OUT - HSS_IN where HSS_CODIGO In (select cuenta from cuentaa)")
|
||||
|
||||
c=B4XPages.MainPage.skmt.ExecQuery(" Select (substr(HSS_OUT,1,2) - substr(HSS_IN,1,2)) - Case when (substr(HSS_OUT,3,2) - substr(HSS_IN,3,2)) < 0 Then 1 Else 0 end HORAS_TOTALES, " & _
|
||||
"Case when (substr(HSS_OUT,3,2) - substr(HSS_IN,3,2)) < 0 Then (substr(HSS_OUT,3,2) + 60 - substr(HSS_IN,3,2)) " & _
|
||||
" Else (substr(HSS_OUT,3,2) - substr(HSS_IN,3,2)) End - Case when (substr(HSS_OUT,5,2) - substr(HSS_IN,5,2)) < 0 Then 1 Else 0 end MINUTOS_TOTALES, " & _
|
||||
"Case when (substr(HSS_OUT,5,2) - substr(HSS_IN,5,2)) < 0 Then (substr(HSS_OUT,5,2) + 60 - substr(HSS_IN,5,2)) " & _
|
||||
" Else (substr(HSS_OUT,5,2) - substr(HSS_IN,5,2)) end SEGUNDOS_TOTALES " & _
|
||||
" from HIST_STAY_STORE where HSS_CODIGO In (Select cuenta from cuentaa) ")
|
||||
c.Position = 0
|
||||
stay_hh = c.GetString("HORAS_TOTALES") * 60 * 60
|
||||
stay_mi = c.GetString("MINUTOS_TOTALES") * 60
|
||||
stay_ss = c.GetString("SEGUNDOS_TOTALES")
|
||||
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_TOT = ? where HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(stay_hh + stay_mi + stay_ss))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_OUT set HSO_FIN = ? ", Array As Object(sTime))
|
||||
DateTime.TimeFormat = "HH:mm:ss"
|
||||
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update PEDIDO_INICIO_FINAL set PIF_HORA_FINAL = ? where PIF_CLIENTE = ? and PIF_HORA_FINAL = 0", Array As Object (DateTime.Now, cuenta))
|
||||
LogColor($"actualizamos "${cuenta}, hora_final=${DateTime.now}"$,Colors.Red)
|
||||
|
||||
mandaPendientesnoventa
|
||||
B4XPages.ShowPage("Principal")
|
||||
End Sub
|
||||
|
||||
Sub mandaPendientesnoventa
|
||||
'PEDIDO_CLIENTE (Pendientes)
|
||||
c=B4XPages.MainPage.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 where pc_envio_ok <> 1")
|
||||
Log($"Pedido_Cliente PENDIENTE: ${c.RowCount}"$)
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "insert_pedidos_INTMEX"
|
||||
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"), C.GetString("PC_ALMACEN"),C.GetString("PC_RUTA"), C.GetString("PC_COSTO_SIN"), C.GetString("PC_FACTURA"))
|
||||
reqManager.ExecuteCommand(cmd , $"ins_pedidosPendientes_head_${c.GetString("PC_CLIENTE")}"$)
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
Log(Job.Success)
|
||||
If Job.Success = False Then
|
||||
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Else
|
||||
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211027
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim resultado As DBResult = reqManager.HandleJob(Job)
|
||||
If resultado.Tag.As(String).IndexOf("ins_pedidosPendientes_head_") > -1 Then
|
||||
Private cliente As String= resultado.Tag
|
||||
cliente = cliente.SubString(cliente.IndexOf("_")+24)
|
||||
Log($"Cliente1:${cliente}"$)
|
||||
|
||||
For Each records() As Object In resultado.Rows
|
||||
For Each k As String In resultado.Columns.Keys
|
||||
Log(resultado.Tag & ": " & k & ": " & records(resultado.Columns.Get(k)))
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End If
|
||||
End Sub
|
||||
256
B4A/C_Nota.bas
Normal file
@@ -0,0 +1,256 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
|
||||
Dim skmt As SQL
|
||||
Dim g As GPS
|
||||
Dim clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
|
||||
Dim c As Cursor
|
||||
Dim ruta As String
|
||||
Dim Regresar As Button
|
||||
|
||||
Dim ListView1 As ListView
|
||||
Dim L_CANT As Label
|
||||
Dim L_TOTAL As Label
|
||||
Dim borra As Button
|
||||
Dim Existe As String
|
||||
Dim result As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
Dim DESC As String
|
||||
|
||||
Private Titulo As Label
|
||||
Private b_desc As Button
|
||||
Dim DESCUENTO As String
|
||||
Dim folio As String
|
||||
Dim tgl As Toggle
|
||||
Private almacen As String
|
||||
Private p_nota As Panel
|
||||
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
|
||||
ruta = File.DirInternal
|
||||
Root.LoadLayout("nota")
|
||||
borra.Visible = True
|
||||
Titulo.Text = "Pedido Actual"
|
||||
' If Existe <> 0 Then
|
||||
' c=B4XPages.MainPage.skmt.ExecQuery("select pc_noart, pc_monto from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||
' C.Position=0
|
||||
' L_CANT.Text = c.GetString("PC_NOART")
|
||||
' L_TOTAL.Text = c.GetString("PC_MONTO")
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
If Not(Starter.gps.GPSEnabled) Then
|
||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
End If
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
|
||||
C.Position =0
|
||||
almacen = C.GetString("ID_ALMACEN")
|
||||
C.Close
|
||||
L_CANT.Text =""
|
||||
L_TOTAL.Text=""
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select count(*) as EXISTE from pedido_cliente WHERE pc_cliente IN (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
Existe = C.GetString("EXISTE")
|
||||
C.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select PE_PRONOMBRE,PE_COSTO_TOT, PE_CANT, PE_FOLIO, PE_CEDIS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order by PE_CEDIS, PE_PRONOMBRE")
|
||||
ListView1.Clear
|
||||
Private cs As CSBuilder
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
cs.Initialize
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
label1.color = Colors.White
|
||||
Private textColor As Int = Colors.black
|
||||
' If c.GetString("PE_CEDIS").Contains("PRO") Then textColor = Colors.RGB(210,105,30) 'Si es promo, cambiamos el color del texto.
|
||||
If Not(IsNumber(c.GetString("PE_CEDIS"))) Then textColor = Colors.RGB(210,105,30) 'Si es promo, cambiamos el color del texto.
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(cs.Color(textColor).append(c.GetString("PE_PRONOMBRE")).pop,"Cantidad #"& c.GetString("PE_CANT")& " SubTotal $"& c.GetString("PE_COSTO_TOT")& " Folio "& c.GetString("PE_FOLIO"))
|
||||
folio = c.GetString("PE_FOLIO")
|
||||
Next
|
||||
End If
|
||||
Log($"EXISTE: ${Existe}"$)
|
||||
' If Existe <> 0 Then
|
||||
' c=B4XPages.MainPage.skmt.ExecQuery("select pc_noart, pc_monto from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||
c = B4XPages.MainPage.skmt.ExecQuery("select sum(PE_CANT) as PC_NOART, sum (PE_COSTO_TOT) as PC_MONTO from PEDIDO where PE_CLIENTE in (Select CUENTA from cuentaa) AND PE_PROID NOT IN (SELECT CAT_PA_ID FROM PROMOS_COMP ) ")
|
||||
If c.RowCount > 0 Then
|
||||
C.Position = 0
|
||||
Log($"registros: ${c.RowCount}, arts: ${c.GetString("PC_NOART")}, monto:${c.GetString("PC_MONTO")}"$)
|
||||
L_CANT.Text = c.GetString("PC_NOART")
|
||||
L_TOTAL.Text = c.GetString("PC_MONTO")
|
||||
If L_CANT.Text = Null Or L_CANT.Text = "null" Or L_CANT.Text = "" Then L_CANT.Text = "0"
|
||||
If L_TOTAL.Text = Null Or L_TOTAL.Text = "null" Or L_TOTAL.Text = "" Then L_TOTAL.Text = "0"
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select SUM(IFNULL(PE_DESC,0)) AS DESCUENTO FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
DESC = c.GetString("DESCUENTO")
|
||||
b_desc.Visible = False
|
||||
End If
|
||||
|
||||
' End If
|
||||
If Subs.pedidoGuardado Then borra.Enabled = False Else borra.Enabled = True
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
'lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
'lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
End Sub
|
||||
|
||||
Sub Regresar_Click
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
' Return True To close, False To cancel
|
||||
B4XPages.ShowPage("Cliente")
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub borra_Click
|
||||
' If folio <> "" Then
|
||||
result = Msgbox2("Seguro que desea borrar el pedido?","Cancelar pedido", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select PE_PROID,PE_CANT FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) ")
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?", Array As Object(c.GetString("PE_CANT"),c.GetString("PE_PROID")))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO INVENT_X_ENVIAR (ALMACEN , PROID , CANTIDAD ) VALUES(?,?,?) ", Array As Object (almacen,c.GetString("PE_PROID"),c.GetString("PE_CANT")* -1))
|
||||
Next
|
||||
End If
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido where pe_cliente in (Select CUENTA from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
B4XPage_Appear
|
||||
B4XPages.MainPage.productos.clv_prods_ll.Clear
|
||||
End If
|
||||
' Else
|
||||
' Msgbox("CLIENTE YA SE TRANSMITIO, FAVOR DE LLAMAR A SOPORTE PARA ASISTENCIA","AVISO") 'ignore
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
If Not(Subs.pedidoGuardado) Then
|
||||
result = Msgbox2("Seguro que desea borrar este articulo?","Borrar Articulo", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("select PE_PROID,PE_CANT FROM PEDIDO where pe_pronombre = ? and pe_cliente in (Select CUENTA from cuentaa) ", Array As String(Value))
|
||||
c.Position=0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?", Array As Object(c.GetString("PE_CANT"),c.GetString("PE_PROID")))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO INVENT_X_ENVIAR (ALMACEN , PROID , CANTIDAD ) VALUES(?,?,?) ", Array As Object (almacen,c.GetString("PE_PROID"),c.GetString("PE_CANT")* -1))
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("select count(*) AS CUANTOS from cat_gunaprod where CAT_GP_ID in (select pe_cedis from pedido where pe_pronombre = ? and pe_cliente in (Select CUENTA from cuentaa)) and CAT_GP_CLASIF = 'PROMOS' AND CAT_GP_TIPO = 'PROMOS' AND CAT_GP_SUBTIPO = 'PROMOS'", Array As String(Value))
|
||||
c.Position=0
|
||||
If c.GetString("CUANTOS") > 0 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("delete from pedido where pe_cedis in (select pe_cedis from pedido where pe_pronombre = ?) and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(Value))
|
||||
Else
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("delete from pedido where pe_pronombre = ? and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(Value))
|
||||
End If
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, count(*) as CUANTOS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
If c.GetString("CUANTOS") > 0 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT) VALUES (?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
Else
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
End If
|
||||
B4XPage_Appear
|
||||
End If
|
||||
Else
|
||||
ToastMessageShow("Pedido guardado, NO se puede editar.",false)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub b_desc_Click
|
||||
If DESCUENTO = "MENOS" Then
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
c.Close
|
||||
result = Msgbox2("Seguro que desea dar descuento del 5%?","Dar descuento", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE pedido SET PE_COSTO_TOT = PE_COSTO_TOT * .95, PE_DESC = 5 WHERE PE_CLIENTE In (select cuenta from cuentaa)")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, count(*) as CUANTOS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT) VALUES (?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps))
|
||||
c.Close
|
||||
B4XPage_Appear
|
||||
End If
|
||||
ELSE IF DESCUENTO = "MAS" Then
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
c.Close
|
||||
result = Msgbox2("Seguro que desea CANCELAR el descuento?","Cancelar descuento", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE pedido SET PE_COSTO_TOT = PE_COSTO_TOT / .95, PE_DESC = 0 WHERE PE_CLIENTE In (select cuenta from cuentaa)")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, count(*) as CUANTOS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT) VALUES (?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps))
|
||||
c.Close
|
||||
B4XPage_Appear
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub p_nota_Click
|
||||
|
||||
End Sub
|
||||
115
B4A/C_NuevoCliente.bas
Normal file
@@ -0,0 +1,115 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
|
||||
Dim g As GPS
|
||||
Dim ruta As String
|
||||
Dim c As Cursor
|
||||
|
||||
Dim CANCELA As Button
|
||||
Dim GUARDA As Button
|
||||
Dim cuenta As String
|
||||
Dim usuario As String
|
||||
Dim sDate,sTime As String
|
||||
Dim no_cliente As String
|
||||
Dim no_ruta As String
|
||||
|
||||
Dim r_4 As RadioButton
|
||||
Dim E_NOMBRE As EditText
|
||||
Dim tgl As Toggle
|
||||
Private l_sinUbicacion As Label
|
||||
Private p_nuevoCliente As Panel
|
||||
Private Label1 As Label
|
||||
Private p_botones As Panel
|
||||
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("nuevocliente")
|
||||
ruta = File.DirInternal
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
' skmt.Initialize(ruta,"kmt.db", True)
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
E_NOMBRE.Text = ""
|
||||
If Not(Starter.gps.GPSEnabled) Then
|
||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
End If
|
||||
GUARDA.Visible = False
|
||||
Subs.panelVisible(p_nuevoCliente, 0, 0)
|
||||
p_nuevoCliente.Height = Root.Height
|
||||
p_nuevoCliente.Width = Root.Width
|
||||
Subs.centraEtiqueta(Label1, Root.Width)
|
||||
Subs.centraEtiqueta(l_sinUbicacion, Root.Width)
|
||||
Subs.centraPanel(p_botones, Root.Width)
|
||||
E_NOMBRE.Left = Round(Root.Width/2)-(E_NOMBRE.Width/2)
|
||||
If B4XPages.MainPage.lat_gps <> "0.0" Then
|
||||
GUARDA.Visible = True 'Si hay ubicaccion, mostramos el boton de guardar.
|
||||
l_sinUbicacion.Visible = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
If B4XPages.MainPage.lat_gps <> "0.0" Then
|
||||
GUARDA.Visible = True 'Si hay ubicaccion, mostramos el boton de guardar.
|
||||
l_sinUbicacion.Visible = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub CANCELA_Click
|
||||
B4XPages.ShowPage("Principal")
|
||||
End Sub
|
||||
|
||||
Sub GUARDA_Click
|
||||
If E_NOMBRE.Text = "" Then
|
||||
ToastMessageShow("Se tiene que nombrar la tienda para continuar" , True)
|
||||
Else
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
DateTime.Timeformat = "HHmmss"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
Log($" //////////// Date: ${sDate} - Time: ${sTime} ////////////////"$)
|
||||
'Aqui creamos manualmete la hora con el separador de los 2 puntos porque en algunas versiones de android no respeta el formato "Timeformat = 'HH:mm:ss'"
|
||||
Private hora As String = sTime.SubString2(0,2)
|
||||
Private mins As String = sTime.SubString2(2,4)
|
||||
Private segs As String = sTime.SubString(4)
|
||||
sTime = hora&":"&mins&":"&segs
|
||||
Log("////////////// sTime: "&sTime&" ////////////////")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_RUTA FROM kmt_info")
|
||||
c.Position=0
|
||||
no_ruta= c.GetString("CAT_CL_RUTA")
|
||||
no_cliente= "N" & sTime & no_ruta
|
||||
Log("++ ++ no_cliente = "&no_cliente)
|
||||
c.Close
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO kmt_info(CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO, gestion) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,0) ",Array As Object (no_cliente,no_ruta, E_NOMBRE.Text,"null","null","null","null","null","null","null","null","null","null","null","null","null",B4XPages.MainPage.lon_gps,B4XPages.MainPage.lat_gps))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_STAY_STORE(HSS_CODIGO, HSS_IN , HSS_OUT , HSS_TOT) VALUES (?,0,0,0)", Array As Object (no_cliente))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(no_cliente))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CLIENTE_NUEVO(CN_ID_CLIENTE, CN_NOMBRE) VALUES (?,?)", Array As Object(no_cliente, E_NOMBRE.Text))
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub p_nuevoCliente_Click
|
||||
|
||||
End Sub
|
||||
584
B4A/C_Pedidos.bas
Normal file
@@ -0,0 +1,584 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
|
||||
Dim g As GPS
|
||||
Dim ruta As String
|
||||
Dim skmt As SQL
|
||||
Private t3 As Timer
|
||||
Dim p As Phone
|
||||
Dim sb As StringBuilder
|
||||
|
||||
Dim c As Cursor
|
||||
Dim e As Cursor
|
||||
Dim f As Cursor
|
||||
Dim h As Cursor
|
||||
Dim CC As Cursor
|
||||
Dim DD As Cursor
|
||||
Dim l_tipo As Label
|
||||
Dim l_sub As Label
|
||||
Dim l_marca As Label
|
||||
Dim l_desc As Label
|
||||
Dim l_precio As Label
|
||||
Dim l_bodega As Label
|
||||
Dim cantidad As EditText
|
||||
Dim guardar As Button
|
||||
Dim Terminar As Button
|
||||
Dim img_prod As ImageView
|
||||
Dim IMG_PASO() As Byte
|
||||
Dim L_PROID As Label
|
||||
Dim clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
Dim t_venta As Label
|
||||
Dim PROMO_C As String
|
||||
Dim i_fotol As ImageView
|
||||
Private DESC_PROMO As Button
|
||||
Private nopromo As Button
|
||||
Dim TOT_ART_PROMO As String
|
||||
Dim cambio As String
|
||||
Dim COSTO_TOT As String
|
||||
Dim ALMACEN As String
|
||||
Dim preciosin As String
|
||||
Dim cl_ruta As String
|
||||
Dim d As Cursor
|
||||
Dim TOT_ART_PROMOR As String
|
||||
Dim PROMO_CR As String
|
||||
Dim TOTAL_PROMO As String
|
||||
Dim HCCP_CANT As String
|
||||
Dim tgl As Toggle
|
||||
Dim precio_Cero As String
|
||||
Private BONSABOR As String
|
||||
Private BONSABOR2 As String
|
||||
Dim cmd As DBCommand
|
||||
Private p_pedido As Panel
|
||||
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("pedido")
|
||||
i_fotol.Visible = False
|
||||
' B4XPages.MainPage.reqManager.Initialize(Me, "http://177.244.63.54:1782")
|
||||
ruta = File.DirInternal
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
' skmt.Initialize(ruta,"kmt.db", True)
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
tgl.Initialize
|
||||
BONSABOR = 0
|
||||
BONSABOR2 = 0
|
||||
If Not(Starter.gps.GPSEnabled) Then
|
||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
End If
|
||||
cantidad.Text = ""
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select ID_ALMACEN from CAT_ALMACEN")
|
||||
C.Position =0
|
||||
ALMACEN = C.GetString("ID_ALMACEN")
|
||||
C.Close
|
||||
i_fotol.Visible = False
|
||||
sb.Initialize
|
||||
p.Shell("ping -c1 -W1 177.244.63.54",Null, sb,Null)
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CAT_GP_ID,CAT_GP_NOMBRE,CAT_GP_IMP1,CAT_GP_IMP2,CAT_GP_PRECIO,CAT_GP_CLASIF,CAT_GP_STS,CAT_GP_TIPO,CAT_GP_SUBTIPO,CAT_GP_IMG,CAT_GP_ALMACEN,CAT_GP_DEV from CAT_GUNAPROD where CAT_GP_NOMBRE In (Select PDESC from PROID)")
|
||||
c.Position=0
|
||||
L_PROID.Text = c.GetString("CAT_GP_ID")
|
||||
l_tipo.Text = c.GetString("CAT_GP_TIPO")
|
||||
l_sub.Text = c.GetString("CAT_GP_SUBTIPO")
|
||||
l_marca.Text = c.GetString("CAT_GP_CLASIF")
|
||||
l_desc.Text = c.GetString("CAT_GP_NOMBRE")
|
||||
l_precio.Text = c.GetDouble("CAT_GP_PRECIO")
|
||||
l_bodega.Text = c.GetString("CAT_GP_ALMACEN")
|
||||
IMG_PASO = c.GetBlob("CAT_GP_IMG")
|
||||
PROMO_C = c.GetString("CAT_GP_STS")
|
||||
cambio = c.GetString("CAT_GP_DEV")
|
||||
preciosin = c.GetString("CAT_GP_IMP2")
|
||||
PROMO_CR = c.GetString("CAT_GP_IMP1")
|
||||
cambio = "0"
|
||||
|
||||
e=B4XPages.MainPage.skmt.ExecQuery2("select count(*) as CUANTOS FROM pedido WHERE PE_CEDIS = ? AND PE_CLIENTE IN (Select cuenta from cuentaa) ", Array As String(c.GetString("CAT_GP_ID")))
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") = 0 Then
|
||||
If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" Then
|
||||
DESC_PROMO.Visible = True
|
||||
CC=B4XPages.MainPage.skmt.ExecQuery2("select count(*) as CUANTOS FROM PROMOS_COMP WHERE CAT_PA_ID = ?", Array As String(c.GetString("CAT_GP_ID")))
|
||||
CC.Position =0
|
||||
If CC.GetString("CUANTOS") = 0 Then
|
||||
l_bodega.Text = "0" ' se modifica a cero para evitar error en la promo especial de unilever mayo
|
||||
Else
|
||||
CC.Close
|
||||
CC=B4XPages.MainPage.skmt.ExecQuery2("select CAT_PA_MAXPROM, CAT_PA_MAXPROMREC, CAT_PA_MAXPROMCLIE FROM PROMOS_COMP WHERE CAT_PA_ID = ?", Array As String(c.GetString("CAT_GP_ID")))
|
||||
CC.Position =0
|
||||
' SE MODIFICA LA APLICACION PARA QUE VEA EL HISTORIAL DE VENTA DEL CLIENTE.
|
||||
DD=B4XPages.MainPage.skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM HIST_CLIENTE_CANT_PROMOS WHERE HCCP_CLIENTE IN (Select cuenta from cuentaa) AND HCCP_PROMO =?", Array As String(c.GetString("CAT_GP_ID")))
|
||||
DD.Position =0
|
||||
If DD.GetString("CUANTOS") = 0 Then
|
||||
HCCP_CANT = 0
|
||||
Else
|
||||
DD.Close
|
||||
DD=B4XPages.MainPage.skmt.ExecQuery2("SELECT HCCP_CANT FROM HIST_CLIENTE_CANT_PROMOS WHERE HCCP_CLIENTE IN (Select cuenta from cuentaa) AND HCCP_PROMO =?", Array As String(c.GetString("CAT_GP_ID")))
|
||||
DD.Position =0
|
||||
HCCP_CANT = DD.GetString("HCCP_CANT")
|
||||
DD.Close
|
||||
End If
|
||||
BONSABOR = HCCP_CANT
|
||||
DD=B4XPages.MainPage.skmt.ExecQuery2("SELECT COUNT(*) AS CUANTOS FROM HIST_VENTAS WHERE HVD_CLIENTE IN (Select cuenta from cuentaa) AND HVD_PRONOMBRE =?", Array As String(c.GetString("CAT_GP_NOMBRE")))
|
||||
DD.Position =0
|
||||
If DD.GetString("CUANTOS") = 0 Then
|
||||
HCCP_CANT = 0
|
||||
Else
|
||||
DD.Close
|
||||
DD=B4XPages.MainPage.skmt.ExecQuery2("SELECT SUM(HVD_CANT) AS HCCP_CANT FROM HIST_VENTAS WHERE HVD_CLIENTE IN (Select cuenta from cuentaa) AND HVD_PRONOMBRE =?", Array As String(c.GetString("CAT_GP_NOMBRE")))
|
||||
DD.Position =0
|
||||
HCCP_CANT = DD.GetString("HCCP_CANT")
|
||||
DD.Close
|
||||
End If
|
||||
DD=B4XPages.MainPage.skmt.ExecQuery2("Select COUNT(*) AS CUANTOS FROM PEDIDO WHERE PE_CLIENTE IN (Select cuenta from cuentaa) AND PE_PROID IN (select CAT_GP_ID from CAT_GUNAPROD where CAT_GP_CLASIF = ?) ",Array As String(c.GetString("CAT_GP_NOMBRE")))
|
||||
DD.Position =0
|
||||
BONSABOR2 = DD.GetString("CUANTOS")
|
||||
DD.Close
|
||||
TOTAL_PROMO = CC.GetString("CAT_PA_MAXPROMCLIE") - HCCP_CANT
|
||||
If HCCP_CANT = 0 Then
|
||||
l_bodega.Text = CC.GetString("CAT_PA_MAXPROM")
|
||||
Else IF TOTAL_PROMO > CC.GetString("CAT_PA_MAXPROMREC") Then
|
||||
l_bodega.Text = CC.GetString("CAT_PA_MAXPROMREC")
|
||||
Else
|
||||
l_bodega.Text = TOTAL_PROMO
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
DESC_PROMO.Visible = False
|
||||
End If
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CASE WHEN pe_costo_tot is null then 0 else sum( pe_costo_tot ) end as TOTAL_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
t_venta.Text = c.GetString("TOTAL_CLIE")
|
||||
c.Close
|
||||
Terminar.Visible = True
|
||||
guardar.Visible = True
|
||||
cantidad.Visible = True
|
||||
If cambio = "1" Then
|
||||
nopromo.Visible = True
|
||||
Else
|
||||
nopromo.Visible = False
|
||||
End If
|
||||
Dim out As OutputStream
|
||||
out = File.OpenOutput(ruta, "1.jpg", False)
|
||||
out.WriteBytes(IMG_PASO, 0, IMG_PASO.Length)
|
||||
out.Close
|
||||
img_prod.Bitmap = LoadBitmap(ruta,"1.jpg")
|
||||
TOT_ART_PROMO = "0"
|
||||
TOT_ART_PROMOR = "0"
|
||||
If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And l_bodega.Text = "0" Then
|
||||
Msgbox("ALERTA","EL CLIENTE NO PUEDE TENER ESTA PROMOCION") 'ignore
|
||||
B4XPages.ShowPage("Productos")
|
||||
ELSE IF l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And L_PROID.Text = "PROUNI1" And BONSABOR <> "1" And BONSABOR2 = 0 Then
|
||||
Msgbox("ALERTA","EL CLIENTE NO PUEDE TENER ESTA PROMOCION") 'ignore
|
||||
B4XPages.ShowPage("Productos")
|
||||
End If
|
||||
Else
|
||||
Msgbox("ALERTA","EL CLIENTE YA COMPRO ESTE PRODUCTO REVISAR NOTA") 'ignore
|
||||
B4XPages.ShowPage("Productos")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub guardar_Click
|
||||
If cantidad.Text = "" Then
|
||||
B4XPages.ShowPage("Productos")
|
||||
ELSE If cantidad.Text > l_bodega.Text Then
|
||||
Msgbox("Exede la existencia", "ADVERTENCIA") 'ignore
|
||||
Else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C > 0 And cantidad.Text > 0 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from PROIDID")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_TIPO = 1)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA") 'ignore
|
||||
Else
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 1)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMO = C.GetString("TOT_ART_PROMO")
|
||||
COSTO_TOT = C.GetString("COSTO_TOT")
|
||||
C.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND (CAT_DP_PRECIO = 0.01 or CAT_DP_PRECIO = 1 OR CAT_DP_PRECIO = 0) AND CAT_DP_TIPO = 1)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
TOT_ART_PROMOR = "0" 'Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA")
|
||||
Else
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND (CAT_DP_PRECIO = 0.01 or CAT_DP_PRECIO = 1 OR CAT_DP_PRECIO = 0) AND CAT_DP_TIPO = 1)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMOR = C.GetString("TOT_ART_PROMO")
|
||||
End If
|
||||
C.Close
|
||||
PROMO_C = PROMO_C * cantidad.Text
|
||||
PROMO_CR = PROMO_CR * cantidad.Text
|
||||
If TOT_ART_PROMO = PROMO_C And TOT_ART_PROMOR = PROMO_CR Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_CEDIS = (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(L_PROID.text))
|
||||
D=B4XPages.MainPage.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 1")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
D=B4XPages.MainPage.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND (CAT_DP_PRECIO = 0.01 or CAT_DP_PRECIO = 1 OR CAT_DP_PRECIO = 0) AND CAT_DP_TIPO = 1")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
e=B4XPages.MainPage.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 ")
|
||||
' SE LO QUITE DE CONDICION AND (CAT_DP_PRECIO = 0.01 or CAT_DP_PRECIO = 1 OR CAT_DP_PRECIO = 0)
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=B4XPages.MainPage.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS,CAT_DP_PRECIO FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 ") ' AND (CAT_DP_PRECIO = 0.01 or CAT_DP_PRECIO = 1 OR CAT_DP_PRECIO = 0)
|
||||
'meter el otro
|
||||
'si jala copiar para guna y el resto
|
||||
If f.RowCount>0 Then
|
||||
For i=0 To f.RowCount -1
|
||||
f.Position=i
|
||||
precio_Cero = f.GetString("CAT_DP_PRECIO")
|
||||
h=B4XPages.MainPage.skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
'0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA) VALUES(?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,precio_Cero * f.GetString("CAT_DP_PZAS") * cantidad.text, precio_Cero, f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta))
|
||||
h.Close
|
||||
Next
|
||||
End If
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA,PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,0 , 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta, b4xpages.MainPage.tipo_venta))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
Else
|
||||
Msgbox("Tiene " & TOT_ART_PROMO & " " & TOT_ART_PROMOR & " y necesita " & PROMO_C & " " & PROMO_CR & " Para la Promo. " , "ADVERTENCIA") 'ignore
|
||||
End If
|
||||
End If
|
||||
cantidad.Text = ""
|
||||
B4XPages.ShowPage("Productos")
|
||||
else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C = 0 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from PROIDID")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO) VALUES(?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario))
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=B4XPages.MainPage.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) ")
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=B4XPages.MainPage.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS, CAT_DP_PRECIO FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID)")
|
||||
For i =0 To f.RowCount -1
|
||||
F.Position =i
|
||||
h=B4XPages.MainPage.skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA,PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,f.GetString("CAT_DP_PRECIO") * cantidad.text * f.GetString("CAT_DP_PZAS"), f.GetString("CAT_DP_PRECIO"), f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta, B4XPages.MainPage.tipo_venta))
|
||||
h.Close
|
||||
Next
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
'0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA,PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,0, 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta, b4xpages.MainPage.tipo_venta))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
cantidad.Text = ""
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, SUM(PE_COSTO_SIN) AS TOTAL_CLIE_SIN FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT,PC_ALMACEN,PC_RUTA,PC_COSTO_SIN) VALUES (?,?,?,?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
B4XPages.ShowPage("Productos")
|
||||
Else
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA,PE_COSTO_SIN, PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (ALMACEN,cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta,preciosin, b4xpages.MainPage.tipo_venta))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, SUM(PE_COSTO_SIN) AS TOTAL_CLIE_SIN FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT,PC_ALMACEN,PC_RUTA,PC_COSTO_SIN) VALUES (?,?,?,?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO INVENT_X_ENVIAR (ALMACEN , PROID , CANTIDAD ) VALUES(?,?,?) ", Array As Object (ALMACEN,L_PROID.Text,cantidad.text))
|
||||
B4XPages.ShowPage("Productos")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
'lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
'lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
End Sub
|
||||
|
||||
Sub Terminar_Click
|
||||
If cantidad.Text = "" Then
|
||||
B4XPages.ShowPage("Cliente")
|
||||
ELSE If cantidad.Text > l_bodega.Text Then
|
||||
Msgbox("Exede la existencia", "ADVERTENCIA") 'ignore
|
||||
Else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C > 0 And cantidad.Text > 0 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from PROIDID")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_TIPO = 1)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA") 'ignore
|
||||
Else
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 1)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMO = C.GetString("TOT_ART_PROMO")
|
||||
COSTO_TOT = C.GetString("COSTO_TOT")
|
||||
C.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select count(*) as CUANTOSD from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND (CAT_DP_PRECIO = 0.01 or CAT_DP_PRECIO = 1 OR CAT_DP_PRECIO = 0) AND CAT_DP_TIPO = 1)")
|
||||
c.Position =0
|
||||
If c.GetString("CUANTOSD") = 0 Then
|
||||
TOT_ART_PROMOR = "0" 'Msgbox("No tiene venta el cliente para la promo", "ADVERTENCIA")
|
||||
Else
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select sum(pe_cant) As TOT_ART_PROMO, sum(PE_COSTO_TOT) as COSTO_TOT from pedido where PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID) AND (CAT_DP_PRECIO = 0.01 or CAT_DP_PRECIO = 1 OR CAT_DP_PRECIO = 0) AND CAT_DP_TIPO = 1)")
|
||||
C.Position =0
|
||||
TOT_ART_PROMOR = C.GetString("TOT_ART_PROMO")
|
||||
End If
|
||||
C.Close
|
||||
PROMO_C = PROMO_C * cantidad.Text
|
||||
PROMO_CR = PROMO_CR * cantidad.Text
|
||||
If TOT_ART_PROMO = PROMO_C And TOT_ART_PROMOR = PROMO_CR Then
|
||||
' anterior a 29/06/2015
|
||||
'B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(l_precio.text/(TOT_ART_PROMO/cantidad.Text),l_precio.text/(TOT_ART_PROMO/cantidad.Text)))
|
||||
'en pe_cedis meto el codigo de promocion para hacer esta validacion.
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_CEDIS = (?) WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and pe_proid In (Select cat_dp_idprod from CAT_DETALLES_PAQ WHERE CAT_DP_ID In (Select PROIDID from PROIDID))", Array As Object(L_PROID.text))
|
||||
D=B4XPages.MainPage.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND CAT_DP_PRECIO > 1")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
D=B4XPages.MainPage.skmt.ExecQuery("select CAT_DP_ID, CAT_DP_PRECIO, CAT_DP_PRECIO_SIMPTOS, CAT_DP_IDPROD FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) AND (CAT_DP_PRECIO = 0.01 or CAT_DP_PRECIO = 1 OR CAT_DP_PRECIO = 0) AND CAT_DP_TIPO = 1")
|
||||
If D.RowCount>0 Then
|
||||
For i=0 To D.RowCount -1
|
||||
D.Position=i
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE PEDIDO SET PE_COSTOU = (?), PE_COSTO_TOT = PE_CANT * (?) , PE_COSTO_SIN = (?) WHERE PE_PROID = (?) And PE_CEDIS In (Select PROIDID from PROIDID) AND PE_CLIENTE IN (Select CUENTA from cuentaa) ",Array As Object( D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO"), D.GetString("CAT_DP_PRECIO_SIMPTOS"),D.GetString("CAT_DP_IDPROD")))
|
||||
Next
|
||||
End If
|
||||
D.Close
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=B4XPages.MainPage.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 ")
|
||||
' SE LO QUITE DE CONDICION AND (CAT_DP_PRECIO = 0.01 or CAT_DP_PRECIO = 1 OR CAT_DP_PRECIO = 0)
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=B4XPages.MainPage.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS,CAT_DP_PRECIO FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) and CAT_DP_TIPO = 0 ") ' AND (CAT_DP_PRECIO = 0.01 or CAT_DP_PRECIO = 1 OR CAT_DP_PRECIO = 0)
|
||||
'meter el otro
|
||||
'si jala copiar para guna y el resto
|
||||
If f.RowCount>0 Then
|
||||
For i=0 To f.RowCount -1
|
||||
f.Position=i
|
||||
precio_Cero = f.GetString("CAT_DP_PRECIO")
|
||||
h=B4XPages.MainPage.skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
Log(111)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA,PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,precio_Cero * f.GetString("CAT_DP_PZAS") * cantidad.text, precio_Cero, f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta, B4XPages.MainPage.tipo_venta))
|
||||
h.Close
|
||||
Next
|
||||
End If
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
Log(222)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA,PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,0 , 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta, b4xpages.MainPage.tipo_venta))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
Else
|
||||
Msgbox("Tiene " & TOT_ART_PROMO & " " & TOT_ART_PROMOR & " y necesita " & PROMO_C & " " & PROMO_CR & " Para la Promo. " , "ADVERTENCIA") 'ignore
|
||||
End If
|
||||
End If
|
||||
cantidad.Text = ""
|
||||
B4XPages.ShowPage("Cliente")
|
||||
else If l_marca.text = "PROMOS" And l_tipo.Text ="PROMOS" And PROMO_C = 0 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from PROIDID")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
'para insertar la promo de ades el de regalo en 0
|
||||
e=B4XPages.MainPage.skmt.ExecQuery("select count(*) as CUANTOS FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID) ")
|
||||
e.Position =0
|
||||
If e.GetString("CUANTOS") > 0 Then
|
||||
F=B4XPages.MainPage.skmt.ExecQuery("select CAT_DP_IDPROD, CAT_DP_PZAS, CAT_DP_PRECIO FROM CAT_DETALLES_PAQ WHERE CAT_DP_ID IN (Select PROIDID from PROIDID)")
|
||||
For i =0 To f.RowCount -1
|
||||
F.Position =i
|
||||
h=B4XPages.MainPage.skmt.ExecQuery2("select CAT_GP_NOMBRE from CAT_GUNAPROD where CAT_GP_ID = ? ", Array As String(f.GetString("CAT_DP_IDPROD")))
|
||||
h.Position=0
|
||||
Log(333)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA,PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,f.GetString("CAT_DP_PRECIO") * cantidad.text * f.GetString("CAT_DP_PZAS"), f.GetString("CAT_DP_PRECIO"), f.GetString("CAT_DP_PZAS") * cantidad.text, h.GetString("CAT_GP_NOMBRE"), f.GetString("CAT_DP_IDPROD"),clie_id, sDate & sTime, usuario,cl_ruta, B4XPages.MainPage.tipo_venta))
|
||||
h.Close
|
||||
Next
|
||||
f.Close
|
||||
End If
|
||||
e.Close
|
||||
Log(444)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA,PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (L_PROID.text,0, 0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta, b4xpages.MainPage.tipo_venta))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
cantidad.Text = ""
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, SUM(PE_COSTO_SIN) AS TOTAL_CLIE_SIN FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT,PC_ALMACEN,PC_RUTA,PC_COSTO_SIN) VALUES (?,?,?,?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
B4XPages.ShowPage("Cliente")
|
||||
Else
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select CAT_CL_RUTA from kmt_info where CAT_CL_CODIGO In (Select cuenta from cuentaa)")
|
||||
c.Position=0
|
||||
cl_ruta = c.GetString("CAT_CL_RUTA")
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
Log(555)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_RUTA,PE_COSTO_SIN,PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?,?,?) ", Array As Object (ALMACEN,cantidad.Text * l_precio.Text, l_precio.text, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario,cl_ruta,preciosin, b4xpages.MainPage.tipo_venta))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, SUM(PE_COSTO_SIN) AS TOTAL_CLIE_SIN FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT,PC_ALMACEN,PC_RUTA,PC_COSTO_SIN) VALUES (?,?,?,?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps,ALMACEN,cl_ruta,c.GetString("TOTAL_CLIE_SIN")))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 2 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO INVENT_X_ENVIAR (ALMACEN , PROID , CANTIDAD ) VALUES(?,?,?) ", Array As Object (ALMACEN,L_PROID.Text,cantidad.text))
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
' Return True To close, False To cancel
|
||||
Msgbox("Presione Boton Terminar.","ADVERTENCIA") 'ignore
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub img_prod_Click
|
||||
i_fotol.Visible = True
|
||||
i_fotol.Bitmap = LoadBitmap(ruta,"1.jpg")
|
||||
|
||||
End Sub
|
||||
Sub i_fotol_Click
|
||||
i_fotol.Visible = False
|
||||
|
||||
End Sub
|
||||
|
||||
Sub DESC_PROMO_Click
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from PROIDID")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PROIDID VALUES (?)", Array As Object(L_PROID.text))
|
||||
B4XPages.ShowPage("detalle_promo")
|
||||
End Sub
|
||||
|
||||
Sub nopromo_Click
|
||||
If cantidad.Text = "" Then
|
||||
Msgbox("Cantidad no puede ser 0","Cantidad") 'ignore
|
||||
Else If cantidad.Text > l_bodega.Text Then
|
||||
Msgbox("Exede la existencia", "ADVERTENCIA") 'ignore
|
||||
Else
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PEDIDO (PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO,PE_FOLIO) VALUES(?,?,?,?,?,?,?,?,?,?) ", Array As Object ("COACALCO",0,0, cantidad.text, l_desc.text, L_PROID.Text,clie_id, sDate & sTime, usuario, b4xpages.MainPage.tipo_venta))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen - ? where cat_gp_id = ? ", Array As Object(cantidad.Text, L_PROID.Text))
|
||||
cantidad.Text = ""
|
||||
B4XPages.ShowPage("Productos")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub p_pedido_Click
|
||||
|
||||
End Sub
|
||||
2281
B4A/C_Principal.bas
Normal file
977
B4A/C_Productos.bas
Normal file
@@ -0,0 +1,977 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Dim ruta As String
|
||||
Dim q_buscar As String
|
||||
Dim forzarBusqueda As Boolean = False
|
||||
Dim skmt As SQL
|
||||
Dim c As Cursor
|
||||
Dim c2 As Cursor
|
||||
Dim C3 As Cursor
|
||||
Dim s As Cursor
|
||||
Dim lv_catalogos As ListView
|
||||
Dim lv_promos As ListView
|
||||
Dim entro As String
|
||||
Dim gest As Button
|
||||
Dim lfila As Label
|
||||
Dim marca As String
|
||||
Dim tipo As String
|
||||
Dim subtipo As String
|
||||
Private BUSCA As EditText
|
||||
Dim ya_entro As String
|
||||
Dim TIENE_PROMOS As String
|
||||
Dim RES As String
|
||||
Dim S1 As Cursor
|
||||
Dim bmp As Bitmap
|
||||
Dim ciclo As String
|
||||
Private b_qr As Button
|
||||
Private p_productos As Panel
|
||||
Dim clv_productos As CustomListView
|
||||
Private ImageView1 As ImageView
|
||||
Private Panel3 As Panel
|
||||
Private p_prods As Panel
|
||||
Private i_prod As ImageView
|
||||
Private l_prodX As Label
|
||||
Private b_prodMas As Button
|
||||
Private l_pCant As Label
|
||||
Private et_pCant As EditText
|
||||
Private b_prodMenos As Button
|
||||
Dim b_terminar1 As Button
|
||||
Dim b_continuar As Button
|
||||
Private l_total As Label
|
||||
Private l_totProds As Label
|
||||
Dim totalProds As Int = 0
|
||||
Dim totalCompra As Float = 0
|
||||
Dim etCantHasFocus As Boolean = False
|
||||
Dim prodsMap As Map
|
||||
Private l_Cargando As Label
|
||||
Private l_info As Label
|
||||
Private b_buscar As Button
|
||||
Private p_botonesVenta As Panel
|
||||
Private lv_tipo As ListView
|
||||
Private lv_subtipo As ListView
|
||||
Private p_vistaPreviaTrans As Panel
|
||||
Private lv_prodsPedido As ListView
|
||||
Private b_rechazar As Button
|
||||
Private b_aceptar As Button
|
||||
Private p_vistaPrevia As Panel
|
||||
Dim folio As String
|
||||
Dim result As String
|
||||
Private l_cant As Label
|
||||
Private l_total2 As Label
|
||||
Dim prodsPedidoActual As String
|
||||
Dim montoPedidoActual As String
|
||||
|
||||
Dim clv_prods_ll As CustomListView
|
||||
Private PCLV As PreoptimizedCLV
|
||||
Dim listaProds As List
|
||||
' Type AirportData (Name As String, AirportID As Int, IATA As String, ICAO As String, City As String, Latitude As Float, Longitude As Float, Altitude As String)
|
||||
Dim pedidoMap As Map
|
||||
Private p_botMasMen As Panel
|
||||
Dim reiniciarlistaProds As Boolean= False
|
||||
' Dim listaRenglones As List
|
||||
Dim listaTiempos As List
|
||||
Dim clienteId As String
|
||||
Dim rutaUsuario As String
|
||||
Dim hayPedido As Boolean
|
||||
Dim listaHints As List
|
||||
Dim r As Cursor
|
||||
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
|
||||
' Activity.RemoveAllViews
|
||||
Root.LoadLayout("productos")
|
||||
ruta = File.DirInternal
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
PCLV.Initialize(Me, "PCLV", clv_prods_ll)
|
||||
ciclo = 1
|
||||
l_info.Width = Root.Width * 0.8
|
||||
l_info.Left = (Root.Width/2) - (l_info.Width/2)
|
||||
c = B4XPages.MainPage.skmt.ExecQuery("select distinct CAT_GP_TIPO from cat_gunaprod where CAT_GP_TIPO <> 'PROMOS' order by CAT_GP_TIPO")
|
||||
If c.RowCount > 0 Then
|
||||
Dim label1 As Label
|
||||
label1 = lv_tipo.SingleLineLayout.Label
|
||||
label1.TextSize = 17
|
||||
label1.TextColor = Colors.Black
|
||||
lv_tipo.Clear
|
||||
For i=0 To c.RowCount-1
|
||||
c.Position=i
|
||||
lv_tipo.AddSingleLine(c.GetString("CAT_GP_TIPO"))
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
' llenaCatalogo(False)
|
||||
' listaRenglones.Initialize
|
||||
listaTiempos.Initialize
|
||||
listaProds.Initialize
|
||||
pedidoMap.Initialize
|
||||
listaHints.Initialize
|
||||
' Log("Llamamos LlenaProdsLL")
|
||||
' LlenaProdsLL(Null)
|
||||
clv_prods_ll.Clear
|
||||
prodsMap.Initialize
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
clienteId = Subs.traeCliente
|
||||
rutaUsuario = Subs.traeRuta
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("PRIORITARIO","1"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("ESTRATEGICO","2"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("COMPLEMENTARIO","3"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_TIPOPROD = (?) ",Array As Object("CATALOGO REGULAR","0"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_CLASIF = (?) ",Array As Object("PROMOS","PROMOS"))
|
||||
clv_prods_ll.GetBase.SetLayoutAnimated(0, 5dip, 130dip, Root.Width + 10, Root.Height * 0.74) '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 ajuste al nuevo tamaño.
|
||||
If B4XPages.MainPage.bTerminarClicked Then
|
||||
lv_catalogos.Visible = True
|
||||
lv_promos.Visible = False
|
||||
lv_tipo.Visible = False
|
||||
lv_subtipo.Visible = False
|
||||
clv_prods_ll.AsView.Visible = False
|
||||
B4XPages.MainPage.bTerminarClicked = False
|
||||
End If
|
||||
If ya_entro <> "1" Then
|
||||
If BUSCA.Text <> "" Then BUSCA.Text =""
|
||||
entro ="3"
|
||||
lv_catalogos.Clear
|
||||
Sleep(100)
|
||||
lfila.Text = "CATALOGOS"
|
||||
p_productos.Height = Root.Height
|
||||
clv_prods_ll.AsView.Visible = False
|
||||
lv_catalogos.Visible = True
|
||||
p_botonesVenta.Visible = False
|
||||
p_botonesVenta.Top = clv_prods_ll.AsView.top + clv_prods_ll.AsView.Height - 10
|
||||
lv_promos.Visible = False
|
||||
End If
|
||||
Dim label1 As Label
|
||||
label1 = lv_catalogos.SingleLineLayout.Label
|
||||
label1.TextSize = 17
|
||||
label1.TextColor = Colors.Black
|
||||
lv_catalogos.Clear
|
||||
lv_catalogos.AddSingleLine("CATALOGO")
|
||||
c = B4XPages.MainPage.skmt.ExecQuery("select count(*) as hayPromos from cat_gunaprod where CAT_GP_TIPOPROD = 'PROMOS'")
|
||||
c.Position = 0
|
||||
If c.GetInt("hayPromos") > 0 Then
|
||||
lv_catalogos.AddSingleLine("PROMOS")
|
||||
End If
|
||||
Sleep(100)
|
||||
l_total.Visible = False
|
||||
l_totProds.Visible = False
|
||||
l_total.Left = 5dip
|
||||
l_totProds.Width = Root.Width * 0.19
|
||||
l_total.Left = l_totProds.Width + 20
|
||||
l_total.Width = Root.Width * 0.25
|
||||
' Log(Subs.traeTotalesClienteActual)
|
||||
Dim m As Map = Subs.traeTotalesClienteActual
|
||||
prodsPedidoActual = m.Get("productos")
|
||||
montoPedidoActual = m.Get("monto")
|
||||
hayPedido = Subs.hayPedido
|
||||
' LogColor("Pedido ant? - "&hayPedido, Colors.Magenta)
|
||||
If reiniciarlistaProds Then
|
||||
' Log("Llamamos LlenaProdsLL")
|
||||
' LlenaProdsLL(Null)
|
||||
clv_prods_ll.Clear
|
||||
else If hayPedido Then
|
||||
' LogColor("HAY PEDIDO ANTERIOR", Colors.red)
|
||||
' Log("Llamamos LlenaProdsLL")
|
||||
' LlenaProdsLL(Null)
|
||||
clv_prods_ll.Clear
|
||||
End If
|
||||
If clv_prods_ll.Size = 0 Then LlenaProdsLL(Null)
|
||||
clv_prods_ll.JumpToItem(0) 'Vamos al primer artículo de la lista.
|
||||
PCLV.lblHint.SetTextSizeAnimated(0,13)
|
||||
PCLV.B4XSeekBar1.Color1=Colors.DarkGray
|
||||
PCLV.B4XSeekBar1.Color2=Colors.DarkGray
|
||||
PCLV.B4XSeekBar1.ThumbColor=Colors.red
|
||||
PCLV.B4XSeekBar1.mBase.Left=Root.Width *0.91
|
||||
' PCLV.B4XSeekBar1.mBase.Top=-50
|
||||
PCLV.B4XSeekBar1.mBase.Height=clv_prods_ll.AsView.Height
|
||||
PCLV.pnlOverlay.Height = clv_prods_ll.AsView.Height
|
||||
PCLV.B4XSeekBar1.Update
|
||||
End Sub
|
||||
|
||||
Sub PCLV_AddProds
|
||||
|
||||
End Sub
|
||||
|
||||
Sub lv_catalogos_ItemClick (Position As Int, Value As Object)
|
||||
If Value = "CATALOGO" Then
|
||||
' lfila.text = "TIPO"
|
||||
lfila.text = "PRODUCTOS"
|
||||
lv_catalogos.Visible = False
|
||||
' lv_tipo.Visible = True
|
||||
If clv_prods_ll.Size = 0 Then LlenaProdsLL(Null)
|
||||
clv_prods_ll.AsView.Visible = True
|
||||
If hayPedido Then p_botonesVenta.Visible = True 'Si ya hay pedido, entonces mostramos los botones.
|
||||
Else
|
||||
clv_prods_ll.AsView.Visible = False
|
||||
lv_promos.Visible = True
|
||||
lfila.text = "PROMOCIONES"
|
||||
lv_catalogos.Visible = False
|
||||
lv_promos.Clear
|
||||
Dim label1 As Label
|
||||
label1 = lv_promos.TwoLinesLayout.Label
|
||||
label1.TextSize = 12
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = lv_promos.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 12
|
||||
label2.TextColor = Colors.Black
|
||||
Dim label13 As Label
|
||||
label13 = lv_promos.TwoLinesAndBitmap.Label
|
||||
label13.TextSize = 12
|
||||
label13.TextColor = Colors.Black
|
||||
Dim label14 As Label
|
||||
label14 = lv_promos.TwoLinesAndBitmap.SecondLabel
|
||||
label14.TextSize = 12
|
||||
label14.TextColor = Colors.Black
|
||||
lfila.text = "PROMOS"
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery2("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_TIPOPROD = ? AND CAT_GP_TIPO = ? AND CAT_GP_SUBTIPO = ? AND CAT_GP_ID NOT IN (SELECT PE_PROID FROM PEDIDO WHERE PE_CLIENTE IN (Select cuenta from cuentaa) )", Array As String(Value, Value, Value))
|
||||
' Log($"res:${c2.RowCount}, ${Value}, ${marca}, ${tipo}"$)
|
||||
If c2.RowCount > 0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
Private tm As Map = Subs.procesaPromocion(c2.GetString("CAT_GP_ID"), clienteId)
|
||||
If tm.Get("status") = "ok" Then 'Solo muestrala si hay producto.
|
||||
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
|
||||
Else
|
||||
ToastMessageShow("No hay promociones disponibles.", False)
|
||||
End If
|
||||
c2.Close
|
||||
entro = "4"
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub lv_catalogos2_ItemClick (Position As Int, Value As Object)
|
||||
clv_prods_ll.AsView.Visible = False
|
||||
BUSCA.Text = ""
|
||||
Dim cliente As C_Cliente = B4XPages.GetPage("Cliente")
|
||||
Log($"value=${Value}"$)
|
||||
If Value = "PROMOS" And cliente.cuenta <> "N" Then
|
||||
entro = "3"
|
||||
marca = "PROMOS"
|
||||
tipo = "PROMOS"
|
||||
Else if Value = "PROMOS" And cliente.cuenta = "N" Then
|
||||
entro = "5"
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End If
|
||||
If Value = "PROMOS" Then
|
||||
LogColor("Promos", Colors.red)
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery2("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_TIPOPROD = ? AND CAT_GP_TIPO = ? AND CAT_GP_SUBTIPO = ? AND CAT_GP_ID NOT IN (SELECT PE_PROID FROM PEDIDO WHERE PE_CLIENTE IN (Select cuenta from cuentaa) )", Array As String(Value, marca, tipo))
|
||||
Else
|
||||
LogColor("Catalogo", Colors.red)
|
||||
c2=B4XPages.MainPage.skmt.ExecQuery("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG, CAT_GP_TIPOPROD, CAT_GP_INICIATIVA from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_TIPOPROD <> 'PROMOS' ")
|
||||
End If
|
||||
If Value = "CATALOGO" Then
|
||||
lv_catalogos.Visible = False
|
||||
lv_promos.Visible = False
|
||||
lfila.text = "CATALOGO"
|
||||
Log("PGS")
|
||||
ProgressDialogShow("Cargando catalogo ...")
|
||||
Sleep(100)
|
||||
Private inicioContador As String = DateTime.Now
|
||||
llenaCatalogo(False)
|
||||
clv_prods_ll.AsView.Visible = True
|
||||
Log("PGH")
|
||||
LogColor("TIEMPO DE PROCESO DEL CATALOGO: " & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
||||
ProgressDialogHide
|
||||
c2.Close
|
||||
Else
|
||||
clv_prods_ll.AsView.Visible = False
|
||||
lv_promos.Visible = True
|
||||
lv_catalogos.Visible = False
|
||||
lv_promos.Clear
|
||||
Dim label1 As Label
|
||||
label1 = lv_promos.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = lv_promos.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 15
|
||||
label2.TextColor = Colors.Black
|
||||
Dim label13 As Label
|
||||
label13 = lv_promos.TwoLinesAndBitmap.Label
|
||||
label13.TextSize = 15
|
||||
label13.TextColor = Colors.Black
|
||||
Dim label14 As Label
|
||||
label14 = lv_promos.TwoLinesAndBitmap.SecondLabel
|
||||
label14.TextSize = 15
|
||||
label14.TextColor = Colors.Black
|
||||
lfila.text = "PROMOS"
|
||||
If c2.RowCount > 0 Then
|
||||
For i=0 To c2.RowCount -1
|
||||
c2.Position=i
|
||||
Private tm As Map = Subs.procesaPromocion(c2.GetString("CAT_GP_ID"), clienteId)
|
||||
If tm.Get("status") = "ok" Then 'Solo muestrala si hay producto.
|
||||
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
|
||||
End If
|
||||
c2.Close
|
||||
End If
|
||||
entro = "4"
|
||||
End Sub
|
||||
|
||||
Sub lv_promos_ItemClick (Position As Int, Value As Object)
|
||||
clv_prods_ll.AsView.Visible = False
|
||||
Dim cliente As C_Cliente = B4XPages.GetPage("Cliente")
|
||||
' Log($"Entro=${entro}, value=${Value}, cuenta=${cliente.cuenta}"$)
|
||||
If Value = "PROMOS" And cliente.cuenta <> "N" Then
|
||||
entro = "3"
|
||||
marca = "PROMOS"
|
||||
tipo = "PROMOS"
|
||||
Else if Value = "PROMOS" And cliente.cuenta = "N" Then
|
||||
entro = "5"
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End If
|
||||
If entro = "3" Then
|
||||
'xxxxxxxxxxxxxxxxxxxxx
|
||||
Else If entro = "4" Then
|
||||
' Log("Entro = 4")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from PROID")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO PROID VALUES (?)", Array As Object(Value))
|
||||
Dim promos As C_Promos = B4XPages.GetPage("Promos")
|
||||
promos.laPromo = Subs.traeProdIdDeBD.Get("id")
|
||||
promos.elCliente = Subs.traeUsuarioDeBD
|
||||
B4XPages.ShowPage("Promos")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Generamos la lista de productos.
|
||||
Sub llenaCatalogo(subtipo1 As String)
|
||||
' Log("LlenaCatalogo")
|
||||
' Private c2 As Cursor
|
||||
' c2=B4XPages.MainPage.skmt.ExecQuery2("select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_PRECIO, CAT_GP_ALMACEN, CAT_GP_IMG, CAT_GP_TIPOPROD, CAT_GP_INICIATIVA from cat_gunaprod where CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_TIPOPROD <> 'PROMOS' and CAT_GP_SUBTIPO = ? ", Array As String(subtipo1))
|
||||
' Private bgColor, textColor As Int
|
||||
' If c2.RowCount > 0 And clv_productos.Size <> c2.RowCount Then
|
||||
' clv_productos.Clear : Log("limpiamos productos")
|
||||
' For i=0 To c2.RowCount -1
|
||||
' c2.Position=i
|
||||
' If c2.GetString("CAT_GP_TIPOPROD") = "PRIORITARIO" Then
|
||||
' bgColor = Colors.RGB(255, 212, 163) 'naranja
|
||||
' Else If c2.GetString("CAT_GP_TIPOPROD") = "COMPLEMENTARIO" Then
|
||||
' bgColor = Colors.RGB(177, 200, 249)'azul
|
||||
' else If c2.GetString("CAT_GP_TIPOPROD") = "CATALOGO REGULAR" Then
|
||||
' bgColor = Colors.White
|
||||
' else If c2.GetString("CAT_GP_TIPOPROD") = "ESTRATEGICO" Then
|
||||
' bgColor = Colors.RGB(241, 255, 163) 'amarillo
|
||||
' End If
|
||||
' textColor = Colors.Black
|
||||
' clv_productos.Add(CreateListItem(c2.GetString("CAT_GP_NOMBRE"), c2.GetString("CAT_GP_PRECIO"), c2.GetString("CAT_GP_ALMACEN"), clv_productos.AsView.Width, 60dip, bmp, c2.GetString("CAT_GP_ID"), bgColor, textColor), c2.GetString("CAT_GP_NOMBRE"))
|
||||
' Next
|
||||
' End If
|
||||
' c2.Close
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
' Return True To close, False To cancel
|
||||
If l_info.Visible Then
|
||||
l_info.Visible = False
|
||||
Return False
|
||||
else if p_vistaPreviaTrans.Visible Then
|
||||
p_vistaPreviaTrans.Visible = False
|
||||
Return False
|
||||
else if lv_promos.visible Then
|
||||
lv_promos.Visible = False
|
||||
lv_catalogos.Visible = True
|
||||
p_botonesVenta.Visible = False
|
||||
l_total.Visible = False
|
||||
l_totProds.Visible = False
|
||||
Return False
|
||||
else if clv_prods_ll.AsView.Visible Then
|
||||
lfila.text = "CATALOGO"
|
||||
clv_prods_ll.AsView.Visible = False
|
||||
lv_subtipo.Visible = False
|
||||
p_botonesVenta.Visible = False
|
||||
l_total.Visible = False
|
||||
l_totProds.Visible = False
|
||||
lv_catalogos.Visible = True
|
||||
Return False
|
||||
' else if lv_subtipo.Visible Then
|
||||
' lfila.text = "TIPO"
|
||||
' lv_subtipo.Visible = False
|
||||
' lv_tipo.Visible = False
|
||||
' Return False
|
||||
' else if lv_tipo.Visible Then
|
||||
' lfila.text = "CATALOGO"
|
||||
' lv_tipo.Visible = False
|
||||
' lv_catalogos.Visible = True
|
||||
' Return False
|
||||
else If entro = "4" Then
|
||||
entro = "3"
|
||||
B4XPage_Appear
|
||||
Return True
|
||||
Else If entro = "3" Then
|
||||
B4XPages.ShowPage("Cliente")
|
||||
Return False
|
||||
Else
|
||||
B4XPages.ShowPage("Cliente")
|
||||
Return False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Sub b_QR_Click
|
||||
If ciclo = 1 Then
|
||||
ciclo = 2
|
||||
ya_entro = "0"
|
||||
B4XPage_Appear
|
||||
else if ciclo = 2 Then
|
||||
ciclo = 3
|
||||
ya_entro = "0"
|
||||
B4XPage_Appear
|
||||
else if ciclo = 3 Then
|
||||
ciclo = 4
|
||||
ya_entro = "0"
|
||||
B4XPage_Appear
|
||||
else if ciclo = 4 Then
|
||||
ciclo = 5
|
||||
ya_entro = "0"
|
||||
B4XPage_Appear
|
||||
else if ciclo = 5 Then
|
||||
ciclo = 1
|
||||
ya_entro = "0"
|
||||
B4XPage_Appear
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'****************************************************************************
|
||||
'***************** PARA EL MAS/MENOS *************************************
|
||||
'****************************************************************************
|
||||
Sub CreateListItem(Text As String, precioU As String, inv As Int, Width As Int, Height As Int, img As Bitmap, prodId As String, bc As Int, tc As Int) As Panel
|
||||
' Dim p As B4XView = xui.CreatePanel("")
|
||||
' p.SetLayoutAnimated(0, 0, 0, Width, Height)
|
||||
' p.LoadLayout("prodItem")
|
||||
' p_prods.Color = bc
|
||||
' l_prodX.TextColor = tc
|
||||
' l_prodX.TextSize = 15
|
||||
' p_prods.Height = Height
|
||||
' l_prodX.Height = Height
|
||||
' l_prodX.Text = Text&CRLF&"# " & inv & " $ " & precioU
|
||||
' 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.BringToFront
|
||||
' Return p
|
||||
End Sub
|
||||
|
||||
Sub b_prodMenos_Click
|
||||
etCantHasFocus = False
|
||||
' LogColor("b_prodMenos_Click", Colors.Magenta)
|
||||
Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
||||
Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(2)
|
||||
' Log($"precio|stock:${laCant.tag}"$)
|
||||
If laCant.Text = "" Then laCant.Text = 0
|
||||
' Log("lacant.text="&laCant.text)
|
||||
laCant.Text = $"${NumberFormat2(laCant.Text-1,0,0,0,False)}"$
|
||||
If laCant.Text < 0 Then laCant.Text = 0
|
||||
Private tmpMap As Map = clv_prods_ll.GetValue(index).As(Map)
|
||||
Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio")
|
||||
Private id As String=clv_prods_ll.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)
|
||||
LogColor("prodsMap="&prodsMap, Colors.blue)
|
||||
' (Subs.traeAlmacen, p1.Get("precio"), p1.Get("cant"), pn, p, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, B4XPages.MainPage.tipo_venta)
|
||||
Log($"${Subs.traeAlmacen}, ${precio}, ${laCant.text}, ${Subs.traeProdNombre(id)}, ${id}, ${clienteId}"$)
|
||||
Subs.actualizaProducto(Subs.traeAlmacen, precio, laCant.text, Subs.traeProdNombre(id), id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, B4XPages.MainPage.tipo_venta)
|
||||
cuentaProds
|
||||
LogColor("prodsMap="&prodsMap, Colors.blue)
|
||||
Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
||||
End Sub
|
||||
|
||||
Sub b_prodMas_Click
|
||||
etCantHasFocus = False
|
||||
' LogColor("b_prodMas_Click", Colors.Magenta)
|
||||
Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
||||
Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(2)
|
||||
' Private tmpMap As Map = clv_prods_ll.GetValue(index).As(Map)
|
||||
Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio")
|
||||
Private inv As String=clv_prods_ll.GetValue(index).As(Map).Get("almacen")
|
||||
If laCant.Text = "" Then laCant.Text = 0
|
||||
If laCant.Text + 1 <= inv Then
|
||||
' Log(NumberFormat2(laCant.Text+1,0,0,0,False))
|
||||
laCant.Text = $"${NumberFormat2(laCant.Text+1,0,0,0,False)}"$
|
||||
' Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio")
|
||||
Private id As String=clv_prods_ll.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)
|
||||
' LogColor(prodsMap, Colors.blue)
|
||||
End If
|
||||
' Subs.actualizaProducto(Subs.traeAlmacen, laCant.text, id, clienteId)
|
||||
Subs.actualizaProducto(Subs.traeAlmacen, precio, laCant.text, Subs.traeProdNombre(id), id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, B4XPages.MainPage.tipo_venta)
|
||||
cuentaProds
|
||||
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
||||
End Sub
|
||||
|
||||
Private Sub et_pCant_TextChanged (Old As String, New As String)
|
||||
If etCantHasFocus = True Then
|
||||
' LogColor($"txt changed: ${Old}|${New}, hasfocus=${etCantHasFocus}"$,Colors.Magenta)
|
||||
Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
||||
Dim pnl0 As B4XView = clv_prods_ll.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(2)
|
||||
Private id As String=clv_prods_ll.GetValue(index).As(Map).Get("id")
|
||||
Private precio As String=clv_prods_ll.GetValue(index).As(Map).Get("precio")
|
||||
Private inv As String=clv_prods_ll.GetValue(index).As(Map).Get("almacen")
|
||||
Private inv As String=clv_prods_ll.GetValue(index).As(Map).Get("almacen")
|
||||
If(New = "" Or New = Null) Then New = 0
|
||||
If(New > inv) Then
|
||||
Sender.As(EditText).text = inv
|
||||
End If
|
||||
' Log($"inventario=${inv}"$)
|
||||
If Not(Old = "0" And New = "") And laCant.Text <> Null And laCant.Text <> 0 And laCant.Text <> "" And etCantHasFocus Then
|
||||
Subs.actualizaProducto(Subs.traeAlmacen, precio, laCant.text, Subs.traeProdNombre(id), id, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, B4XPages.MainPage.tipo_venta)
|
||||
cuentaProds
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub cuentaProds
|
||||
' LogColor($"Productos de la orden: ${c_prods.GetString("cantProds")}, Total: ${c_prodsX.GetString("costoTotal")}"$, Colors.red)
|
||||
Log("===========================")
|
||||
Private c As Cursor = B4XPages.MainPage.skmt.ExecQuery($"select sum(PE_COSTO_TOT) as total, sum(PE_CANT) as cant from PEDIDO where PE_CLIENTE = '${clienteId}'"$)
|
||||
' LogColor("TIEMPO cuentaProds =" & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
||||
' LogColor(prodsMap, Colors.Magenta)
|
||||
p_botonesVenta.Visible = True
|
||||
p_botonesVenta.BringToFront
|
||||
c.Position=0
|
||||
Log($"Total Prods: ${c.GetString("cant")}, Total Compra: $$1.2{c.GetString("total")}"$)
|
||||
c.Close
|
||||
' Log($"HAY PEDIDO: ${hayPedido}"$)
|
||||
End Sub
|
||||
|
||||
Private Sub et_pCant_FocusChanged (HasFocus As Boolean)
|
||||
LogColor($"focus changed=${HasFocus}"$, Colors.Magenta)
|
||||
etCantHasFocus = HasFocus
|
||||
cuentaProds
|
||||
End Sub
|
||||
|
||||
|
||||
Sub b_terminar1_Click
|
||||
' Log("b_terminar1_Click")
|
||||
' ya_entro = "0" : Log("ya_entro=1")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("delete from PEDIDO WHERE PE_PRONOMBRE = ? ", Array As Object("N/A") )
|
||||
|
||||
lv_promos.Visible = False
|
||||
clv_prods_ll.AsView.Visible = False
|
||||
lv_catalogos.Visible = True
|
||||
lv_prodsPedido.Clear
|
||||
lv_prodsPedido.TwoLinesLayout.Label.Height = 35dip
|
||||
lv_prodsPedido.TwoLinesLayout.SecondLabel.Height = 25dip
|
||||
Private c_prods As Cursor=B4XPages.MainPage.skmt.ExecQuery("select PE_PRONOMBRE,PE_COSTO_TOT, PE_CANT, PE_FOLIO, PE_CEDIS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) order by PE_CEDIS, PE_PRONOMBRE")
|
||||
If c_prods.RowCount > 0 Then
|
||||
Private cs As CSBuilder
|
||||
For i=0 To c_prods.RowCount -1
|
||||
cs.Initialize
|
||||
c_prods.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = lv_prodsPedido.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
label1.color = Colors.White
|
||||
Private textColor As Int = Colors.black
|
||||
If Not(IsNumber(c_prods.GetString("PE_CEDIS"))) Then textColor = Colors.RGB(210,105,30) 'Si es promo, cambiamos el color del texto.
|
||||
|
||||
Dim label2 As Label
|
||||
label2 = lv_prodsPedido.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
lv_prodsPedido.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"))
|
||||
folio = c_prods.GetString("PE_FOLIO")
|
||||
Next
|
||||
' c=B4XPages.MainPage.skmt.ExecQuery("select pc_noart, pc_monto from pedido_cliente where pc_cliente in (Select CUENTA from cuentaa)")
|
||||
' c = B4XPages.MainPage.skmt.ExecQuery("SELECT SUM (PE_CANT) AS CANTIDAD FROM PEDIDO WHERE PE_PROID not like 'PRO%' and PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c = B4XPages.MainPage.skmt.ExecQuery("select sum(PE_CANT) as PC_NOART, sum (PE_COSTO_TOT) as PC_MONTO from PEDIDO where PE_CLIENTE in (Select CUENTA from cuentaa) AND PE_PROID NOT IN (SELECT CAT_PA_ID FROM PROMOS_COMP )")
|
||||
' r = B4XPages.MainPage.skmt.ExecQuery("SELECT SUM (PE_COSTO_TOT) AS MONTO FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
' r.Position = 0
|
||||
l_cant.Text = c.GetString("PC_NOART")
|
||||
l_total2.Text = c.GetString("PC_MONTO")
|
||||
c.Close
|
||||
' r.Close
|
||||
End If
|
||||
c_prods.Close
|
||||
p_vistaPreviaTrans.Width = Root.Width
|
||||
Subs.centraPanel(p_vistaPrevia, Root.Width)
|
||||
If Subs.pedidoGuardado Then b_rechazar.Enabled = False Else b_rechazar.Enabled = True
|
||||
p_vistaPrevia.Visible=True
|
||||
p_vistaPreviaTrans.Visible=True
|
||||
End Sub
|
||||
|
||||
Private Sub b_continuar_Click
|
||||
Log("b_continuar_Click")
|
||||
cuentaProds
|
||||
Private p1 As Map
|
||||
Log($"prodsMap=${prodsMap}"$)
|
||||
For Each p As String In prodsMap.Keys
|
||||
p1 = prodsMap.Get(p)
|
||||
Log(p & "|" & p1)
|
||||
Private pn As String = Subs.traeProdNombre(p)
|
||||
Subs.guardaProductoSinGestion(Subs.traeAlmacen, p1.Get("precio"), p1.Get("cant"), pn, p, clienteId, Subs.traeFecha, Subs.traeUsuarioDeBD, rutaUsuario, 0, B4XPages.MainPage.tipo_venta)
|
||||
Next
|
||||
Log("promos-inv, prods-inv, cat-vis")
|
||||
lv_promos.Visible = False
|
||||
clv_prods_ll.AsView.Visible = False
|
||||
lv_subtipo.Visible = False
|
||||
lv_tipo.Visible = False
|
||||
lv_catalogos.Visible = True
|
||||
Log("Continuar")
|
||||
Dim m As Map = Subs.traeTotalesClienteActual
|
||||
prodsPedidoActual = m.Get("productos")
|
||||
montoPedidoActual = m.Get("monto")
|
||||
End Sub
|
||||
|
||||
Private Sub l_prodX_LongClick
|
||||
Log("longclic = "&Sender.as(Label).tag)
|
||||
l_info.Text = Sender.as(Label).tag
|
||||
l_info.Visible = True
|
||||
End Sub
|
||||
|
||||
Private Sub l_info_Click
|
||||
l_info.Visible = False
|
||||
End Sub
|
||||
|
||||
Private Sub lv_promos_ItemLongClick (Position As Int, Value As Object)
|
||||
Log("Promo longclic = "&Value)
|
||||
Private id As String = ""
|
||||
Dim c As Cursor = B4XPages.MainPage.skmt.ExecQuery($"select CAT_GP_ID from cat_gunaprod where CAT_GP_TIPO = 'PROMOS' and CAT_GP_NOMBRE = '${Value}'"$)
|
||||
If c.RowCount > 0 Then
|
||||
c.Position = 0
|
||||
id = c.GetString("CAT_GP_ID")
|
||||
End If
|
||||
l_info.Text = $"ID: ${id}${CRLF}${Value}"$
|
||||
l_info.Visible = True
|
||||
End Sub
|
||||
|
||||
Private Sub b_buscar_Click
|
||||
forzarBusqueda = True
|
||||
Busca_TextChanged("",BUSCA.Text)
|
||||
End Sub
|
||||
|
||||
Private Sub lv_tipo_ItemClick (Position As Int, Value As Object)
|
||||
' lfila.text = "SUB TIPO"
|
||||
' lv_tipo.Visible = False
|
||||
' lv_subtipo.Height = Root.Height * 0.7
|
||||
' lv_subtipo.Visible = True
|
||||
' Private c As Cursor = B4XPages.MainPage.skmt.ExecQuery2("select distinct CAT_GP_SUBTIPO from cat_gunaprod where CAT_GP_TIPO = ? order by CAT_GP_SUBTIPO", Array As String(Value))
|
||||
' If c.RowCount > 0 Then
|
||||
' Dim label1 As Label
|
||||
' label1 = lv_subtipo.SingleLineLayout.Label
|
||||
' label1.TextSize = 17
|
||||
' label1.TextColor = Colors.Black
|
||||
' lv_subtipo.Clear
|
||||
' For i=0 To c.RowCount-1
|
||||
' c.Position=i
|
||||
' lv_subtipo.AddSingleLine(c.GetString("CAT_GP_SUBTIPO"))
|
||||
' Next
|
||||
' End If
|
||||
' c.Close
|
||||
End Sub
|
||||
|
||||
Private Sub lv_subtipo_ItemClick (Position As Int, Value As Object)
|
||||
' lfila.text = "SUB TIPO"
|
||||
' LogColor("Catalogo", Colors.red)
|
||||
' lv_catalogos.Visible = False
|
||||
' lv_subtipo.Visible = False
|
||||
' lv_promos.Visible = False
|
||||
' lfila.text = "CATALOGO"
|
||||
' ProgressDialogShow("Cargando catalogo ...")
|
||||
' Sleep(100)
|
||||
' Private inicioContador As String = DateTime.Now
|
||||
' llenaCatalogo(Value)
|
||||
' clv_prods_ll.AsView.Visible = True
|
||||
' LogColor("TIEMPO DE PROCESO DEL CATALOGO: " & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
||||
' ProgressDialogHide
|
||||
End Sub
|
||||
|
||||
Private Sub p_vistaPreviaTrans_Click
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub b_rechazar_Click
|
||||
' If folio <> "" Then
|
||||
result = Msgbox2($"Seguro que desea borrar el pedido completo?${CRLF}Haciendo clic largo sobre un producto se pueden borrar articulos independientes."$,"Rechazar Pedido", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then
|
||||
Subs.borraPedidoClienteActual
|
||||
prodsMap.Initialize
|
||||
B4XPages.MainPage.promos.promosMap.Initialize
|
||||
' Log("Llamamos LlenaProdsLL")
|
||||
' LlenaProdsLL(Null)
|
||||
clv_prods_ll.Clear
|
||||
Log("Positivo")
|
||||
B4XPages.ShowPage("Cliente")
|
||||
Else
|
||||
Log("NO Positivo")
|
||||
p_vistaPreviaTrans.Visible = False
|
||||
End If
|
||||
' Else
|
||||
' Msgbox("CLIENTE YA SE TRANSMITIO, FAVOR DE LLAMAR A SOPORTE PARA ASISTENCIA","AVISO") 'ignore
|
||||
' End If
|
||||
p_vistaPreviaTrans.Visible=False
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
|
||||
Private Sub b_aceptar_Click
|
||||
p_vistaPreviaTrans.Visible=False
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
|
||||
Private Sub lv_prodsPedido_ItemLongClick (Position As Int, Value As Object)
|
||||
Private sDate,sTime, clie_id, usuario As String
|
||||
If Not(Subs.pedidoGuardado) Then
|
||||
result = Msgbox2("Seguro que desea borrar este articulo?","Borrar Articulo", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("select PE_PROID,PE_CANT FROM PEDIDO where pe_pronombre = ? and pe_cliente in (Select CUENTA from cuentaa) ", Array As String(Value))
|
||||
c.Position=0
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("update cat_gunaprod set cat_gp_almacen = cat_gp_almacen + ? where cat_gp_id = ?", Array As Object(c.GetString("PE_CANT"),c.GetString("PE_PROID")))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO INVENT_X_ENVIAR (ALMACEN , PROID , CANTIDAD ) VALUES(?,?,?) ", Array As Object (Subs.traeAlmacen,c.GetString("PE_PROID"),c.GetString("PE_CANT")* -1))
|
||||
c.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("select count(*) AS CUANTOS from cat_gunaprod where CAT_GP_ID in (select pe_cedis from pedido where pe_pronombre = ? and pe_cliente in (Select CUENTA from cuentaa)) and CAT_GP_CLASIF = 'PROMOS' AND CAT_GP_TIPO = 'PROMOS' AND CAT_GP_SUBTIPO = 'PROMOS'", Array As String(Value))
|
||||
c.Position=0
|
||||
If c.GetString("CUANTOS") > 0 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("delete from pedido where pe_cedis in (select pe_cedis from pedido where pe_pronombre = ?) and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(Value))
|
||||
Else
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("delete from pedido where pe_pronombre = ? and pe_cliente in (Select CUENTA from cuentaa)", Array As Object(Value))
|
||||
End If
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
clie_id = c.GetString("CUENTA")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select USUARIO from usuarioa")
|
||||
c.Position=0
|
||||
usuario = c.GetString("USUARIO")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select sum(pe_costo_tot) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, count(*) as CUANTOS FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
c.Position=0
|
||||
If c.GetString("CUANTOS") > 0 Then
|
||||
Log("aqui5")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("insert into pedido_cliente(PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT) VALUES (?,?,?,?,?,?,?)", Array As Object(clie_id, sDate & sTime, usuario, c.GetString("CANT_CLIE"),c.GetString("TOTAL_CLIE"), B4XPages.MainPage.lon_gps, B4XPages.MainPage.lat_gps))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
Private h As Cursor = B4XPages.MainPage.skmt.ExecQuery("select sum(PE_CANT) as PC_NOART, sum (PE_COSTO_TOT) as PC_MONTO from PEDIDO where PE_CLIENTE in (Select CUENTA from cuentaa) AND PE_PROID NOT IN (SELECT CAT_PA_ID FROM PROMOS_COMP )")
|
||||
h.Position=0
|
||||
l_cant.Text = h.GetString("PC_NOART")
|
||||
l_total2.Text = h.GetString("PC_MONTO")
|
||||
h.Close
|
||||
Else
|
||||
Log("aqui6")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from pedido_cliente where PC_CLIENTE In (select cuenta from cuentaa)")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("UPDATE kmt_info set gestion = 0 where CAT_CL_CODIGO In (select cuenta from cuentaa)")
|
||||
Private h As Cursor = B4XPages.MainPage.skmt.ExecQuery("select sum(PE_CANT) as PC_NOART, sum (PE_COSTO_TOT) as PC_MONTO from PEDIDO where PE_CLIENTE in (Select CUENTA from cuentaa) AND PE_PROID NOT IN (SELECT CAT_PA_ID FROM PROMOS_COMP )")
|
||||
h.Position=0
|
||||
l_cant.Text = 0
|
||||
l_total2.Text = 0
|
||||
h.Close
|
||||
End If
|
||||
b_terminar1_Click
|
||||
End If
|
||||
Else
|
||||
ToastMessageShow("Esta venta ya esta guardada, no se puede editar ni borrar.", False)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub clv_prods_ll_ItemClick (Index As Int, Value As Object)
|
||||
|
||||
End Sub
|
||||
|
||||
Sub l_prodx_click
|
||||
Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
||||
Private p0 As B4XView = clv_prods_ll.GetPanel(index)
|
||||
Private p As B4XView = p0.GetView(0)
|
||||
Private cant1 As B4XView = p.GetView(2).GetView(2)
|
||||
Dim index As Int = clv_prods_ll.GetItemFromView(Sender)
|
||||
' Log(clv_prods_ll.GetValue(index))
|
||||
Log(cant1.Text)
|
||||
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 = 15 '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)
|
||||
If Pnl.NumberOfViews = 0 Then 'Add each item/layout to the list/main layout
|
||||
Pnl.LoadLayout("proditem")
|
||||
p_prods.Width = Root.Width * 0.92
|
||||
p_botMasMen.Left = p_prods.Width - (p_botMasMen.Width + 5)
|
||||
p_prods.Height = 62dip
|
||||
b_prodMenos.Height = 60dip
|
||||
b_prodMas.Height = 60dip
|
||||
et_pCant.Height = 51dip
|
||||
l_pCant.Height = 44dip
|
||||
l_pCant.Top = l_pCant.Top + 8
|
||||
Pnl.Height = p_prods.Height
|
||||
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
|
||||
If Subs.pedidoGuardado Then
|
||||
Log("YA SE GUARDO")
|
||||
et_pCant.Enabled = False
|
||||
' b_prodMas.Enabled = False
|
||||
b_prodMenos.Enabled = False
|
||||
End If
|
||||
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).Append("Existencias: " & clv_prods_ll.GetValue(i).As(Map).Get("almacen")).Color(0xFF017F01).Append($" $${precio}"$).Popall
|
||||
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 Busca_TextChanged (Old As String, New As String)
|
||||
' Private inicioContador As String = DateTime.Now
|
||||
If Not(clv_prods_ll.AsView.Visible) Then clv_prods_ll.AsView.Visible = True
|
||||
If (New.Length = 1 Or New.Length = 2) And Not(forzarBusqueda) Then Return
|
||||
forzarBusqueda = False
|
||||
clv_prods_ll.Clear
|
||||
listaProds.Initialize
|
||||
listaHints.Initialize
|
||||
Sleep(0)
|
||||
Dim p As ResultSet = B4XPages.MainPage.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPOPROD from CAT_GUNAPROD where CAT_GP_NOMBRE like '%${New}%' and CAT_GP_PRECIO > 0 AND CAT_GP_ALMACEN > 0 and CAT_GP_CLASIF <> 'PROMOS' order by CAT_GP_NOMBRE"$)
|
||||
Log("Llamamos LlenaProdsLL")
|
||||
LlenaProdsLL(p)
|
||||
' Do While p.NextRow
|
||||
' 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"))
|
||||
' listaProds.Add(tempMap)
|
||||
' listaHints.Add(p.GetString("CAT_GP_NOMBRE"))
|
||||
' Dim Pnl As B4XView = xui.CreatePanel("")
|
||||
' Pnl.SetLayoutAnimated(0, 0, 0, clv_prods_ll.AsView.Width, 50dip) 'Panel height + 4 for drop shadow
|
||||
' clv_prods_ll.Add(Pnl, tempMap)
|
||||
' Loop
|
||||
' LogColor(clv_prods_ll.Size, Colors.red)
|
||||
'' Log(listaProds)
|
||||
' p.Close
|
||||
' PCLV.B4XSeekBar1.MaxValue = clv_prods_ll.Size
|
||||
' PCLV.B4XSeekBar1.MinValue = 0
|
||||
' PCLV.B4XSeekBar1.Interval = clv_prods_ll.Size/10
|
||||
' PCLV.B4XSeekBar1.Value = clv_prods_ll.Size
|
||||
' PCLV.B4XSeekBar1.Update
|
||||
' Log($"Min:0, max:${clv_prods_ll.Size}, Interval:${clv_prods_ll.Size/10}"$)
|
||||
' LogColor("TIEMPO DE PROCESO DEL TEXTCHANGED: " & ((DateTime.Now-inicioContador)/1000), Colors.Red)
|
||||
End Sub
|
||||
|
||||
Sub LlenaProdsLL(p As ResultSet)
|
||||
' Log("Iniciamos LlenaProdsLL")
|
||||
listaProds.Initialize
|
||||
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 = B4XPages.MainPage.skmt.ExecQuery($"select PE_PROID, PE_CANT from PEDIDO where PE_CLIENTE = '${clienteId}' and PE_CEDIS = '${Subs.traeAlmacen}'"$)
|
||||
' 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
|
||||
pe.Close
|
||||
End If
|
||||
' Log(p.IsInitialized)
|
||||
If p.IsInitialized Then
|
||||
' Log("YA HAY RESULSET")
|
||||
Else
|
||||
' Log("NO HAY RESULSET")
|
||||
Dim p As ResultSet = B4XPages.MainPage.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPOPROD from CAT_GUNAPROD where CAT_GP_PRECIO > 0 And CAT_GP_ALMACEN > 0 And CAT_GP_CLASIF <> 'PROMOS' order by CAT_GP_NOMBRE"$)
|
||||
End If
|
||||
|
||||
Do While p.NextRow
|
||||
Private cant As Int = 0
|
||||
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)
|
||||
listaProds.Add(tempMap)
|
||||
Loop
|
||||
p.Close
|
||||
' Log(listaProds)
|
||||
PCLV.Commit
|
||||
clv_prods_ll.Clear
|
||||
Private listaProdsConCant, listaProdsConCantIndex As List
|
||||
listaProdsConCant.Initialize
|
||||
listaProdsConCantIndex.Initialize
|
||||
listaHints.Initialize
|
||||
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("cant"))
|
||||
listaProdsConCant.Add(listaProds.Get(q))
|
||||
listaProdsConCantIndex.Add(q)
|
||||
End If
|
||||
Next
|
||||
' 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, 63dip)
|
||||
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("")
|
||||
Pnl.SetLayoutAnimated(0, 0, 0, clv_prods_ll.AsView.Width, 63dip)
|
||||
clv_prods_ll.Add(Pnl, listaProds.Get(pr))
|
||||
listaHints.Add(listaProds.get(pr).As(Map).Get("prod"))
|
||||
cont = cont + 1
|
||||
End If
|
||||
Next
|
||||
' LogColor(clv_prods_ll.Size, Colors.red)
|
||||
' PCLV.Commit
|
||||
' Log("CONT=" & cont)
|
||||
' Log("CLV_PRODSLL="&clv_prods_ll.Size)
|
||||
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
|
||||
|
||||
'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
|
||||
607
B4A/C_Promos.bas
Normal file
@@ -0,0 +1,607 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI
|
||||
Private l_promoDesc As Label
|
||||
Private lv_prodsFijos As ListView
|
||||
Private clv_prodsVariabes, clv_prodsVariabes2 As CustomListView
|
||||
Private l_prodsFijos As Label
|
||||
Private l_prodsVariables, l_prodsVariables2 As Label
|
||||
Private i_prod As ImageView
|
||||
Private l_prodX As Label
|
||||
Private p_prods As Panel
|
||||
Private b_prodMenos, b_prodMenos2 As Button
|
||||
Private et_pCant As EditText
|
||||
Private b_prodMas, b_prodMas2 As Button
|
||||
Private l_pCant As Label
|
||||
Dim totalProds As Int = 0
|
||||
Dim prodsVar1 As Int = 0
|
||||
Dim prodsVar2 As Int = 0
|
||||
Dim prodsVarReq As Int = 0
|
||||
Dim prodsVarReq_ As Int = 0
|
||||
Dim prodsVarReq2 As Int = 0
|
||||
Dim prodsVarReq2_ As Int = 0
|
||||
Dim totalCompra As Float = 0
|
||||
Dim prodsFijosTot As Float = 0
|
||||
Dim tpf As Int = 0
|
||||
Dim tpf2 As Int = 0
|
||||
Dim maxCantPromos As Int = 1
|
||||
Private l_totProds As Label
|
||||
Private l_total As Label
|
||||
Private b_terminar1 As Button
|
||||
Private p_promociones As Panel
|
||||
Dim prodsIds, prodsCants, prodsPrecios, prodsIds2, prodsCants2, prodsPrecios2 As List
|
||||
Dim estaPromo, esteCliente As String
|
||||
Private b_promoMas As Button
|
||||
Private b_promoMenos As Button
|
||||
Private et_promoCant As EditText
|
||||
Private l_promosCant As Label
|
||||
Private b_continuar As Button
|
||||
Private p_prodsVariables, p_prodsVariables2 As Panel
|
||||
Dim laPromo = "", elCliente = "" As String
|
||||
Dim prodsPedidoActual As String
|
||||
Dim montoPedidoActual As String
|
||||
Dim promosMap As Map
|
||||
Dim su As StringUtils
|
||||
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("promociones")
|
||||
|
||||
p_promociones.Height= Root.Height
|
||||
p_promociones.Width= Root.Width
|
||||
|
||||
promosMap.Initialize
|
||||
p_promociones.Top=0
|
||||
p_promociones.Left=0
|
||||
b_terminar1.Left = Root.Width - (b_terminar1.Width + 10)
|
||||
b_continuar.Left = Root.Width - b_terminar1.Width - (b_continuar.Width + 20)
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
' LogColor(B4XPages.MainPage.productos.prodsMap, Colors.blue)
|
||||
prodsIds.Initialize
|
||||
prodsCants.Initialize
|
||||
prodsPrecios.Initialize
|
||||
prodsIds2.Initialize
|
||||
prodsCants2.Initialize
|
||||
prodsPrecios2.Initialize
|
||||
Dim m As Map = Subs.traeTotalesClienteActual
|
||||
prodsPedidoActual = m.Get("productos")
|
||||
montoPedidoActual = m.Get("monto")
|
||||
' Log($"laPromo=${laPromo}, el cliente=${elCliente}"$)
|
||||
If laPromo <> "" Then muestraPromo(laPromo, elCliente)
|
||||
End Sub
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub muestraPromo(promo As String, cliente As String)
|
||||
Private thisLog As Boolean = False
|
||||
' If thisLog Then Log(promo)
|
||||
estaPromo = promo
|
||||
esteCliente = cliente
|
||||
Private mp As Map = Subs.traePromo(promo, cliente)
|
||||
Private prodsPromo As Map = mp.Get("productos") 'Los productos de la promoción.
|
||||
Private invDispPromo As Map = Subs.traemosInventarioDisponibleParaPromo(promo)
|
||||
' If thisLog Then Log($"invDispPromo=${invDispPromo}"$)
|
||||
If thisLog Then Log("Max promos por inv de prods FIJOS: " & Subs.revisaMaxPromosProdsFijosPorInventario(mp))
|
||||
If thisLog Then Log("Max promos por inv de prods VARIABLES: " & Subs.revisaMaxPromosProdsVariablesPorInventario(mp))
|
||||
maxCantPromos = Subs.revisaMaxPromosProdsVariablesPorInventario(mp)
|
||||
et_promoCant.Text = 1
|
||||
l_promosCant.text = "Max promos: " & maxCantPromos
|
||||
Private cs As CSBuilder
|
||||
cs.Initialize
|
||||
If thisLog Then Log(mp)
|
||||
If thisLog Then Log(prodsPromo)
|
||||
Private listaPV As List = mp.Get("prodsVariables")
|
||||
Private listaPreciosPV As List = mp.Get("prodsVariablesPrecios")
|
||||
Private listaPV2 As List = mp.Get("prodsVariables2")
|
||||
Private listaPreciosPV2 As List = mp.Get("prodsVariablesPrecios2")
|
||||
' Log("============ " & CRLF & listaPV)
|
||||
'Ponemos la promo y descripción.
|
||||
' Dim desc As String = $"Promoción: ${promo}${CRLF}${mp.Get("descripcion")}"$
|
||||
' Dim desc As String = cs.append("Promocion: ").Color(Colors.RGB(100,149,237)).Append(promo).pop.append(CRLF).Append(mp.Get("descripcion")).Popall
|
||||
l_promoDesc.Text = cs.Color(Colors.RGB(100,149,237)).append("Promocion: ").pop.append(CRLF).Append(promo).append(CRLF).Append(mp.Get("descripcion")).Popall
|
||||
prodsFijosTot = 0
|
||||
'Ponemos el texto en las etiquetas de la cantidad de productos.
|
||||
' Dim pf As List = mp.Get("prodsFijos")
|
||||
Dim pv As List = mp.Get("prodsVariables")
|
||||
Dim pv2 As List = mp.Get("prodsVariables2")
|
||||
If thisLog Then Log(mp)
|
||||
tpf = 0
|
||||
For Each pfp As Int In mp.Get("prodsFijosPiezas").As(List)
|
||||
tpf = tpf + pfp
|
||||
Next
|
||||
tpf2 = tpf
|
||||
' tpf = tpf * maxCantPromos
|
||||
l_prodsFijos.Text = $"Productos fijos (${tpf})"$
|
||||
prodsVarReq = mp.Get("prodsVariablesRequeridos")
|
||||
prodsVarReq_ = prodsVarReq
|
||||
prodsVarReq2 = mp.Get("prodsVariables2Requeridos")
|
||||
prodsVarReq2_ = prodsVarReq2
|
||||
' Log("========= " & prodsVarReq2)
|
||||
l_prodsVariables.Text = $"Productos variables requeridos: ${prodsVarReq}"$
|
||||
l_prodsVariables2.Text = $"Productos variables2 requeridos: ${prodsVarReq2}"$
|
||||
If prodsVarReq = 0 Then
|
||||
p_prodsVariables.Visible = False
|
||||
Else
|
||||
p_prodsVariables.Visible = True
|
||||
End If
|
||||
'Llenamos el listview con los productos fijos.
|
||||
Dim label1 As Label
|
||||
label1 = lv_prodsFijos.SingleLineLayout.Label
|
||||
label1.TextSize = 13
|
||||
label1.TextColor = Colors.black
|
||||
lv_prodsFijos.SingleLineLayout.ItemHeight = 30dip
|
||||
lv_prodsFijos.Clear
|
||||
' If pf.Size < 1 Then pf.Add("Sin productos fijos.")
|
||||
lv_prodsFijos.Clear
|
||||
agregaFijosALista(mp, True)
|
||||
If thisLog Then Log("Total prods fijos = " & prodsFijosTot)
|
||||
' If thisLog Then Log("======="&prodsMap)
|
||||
l_totProds.text = $"Productos: ${tpf}"$
|
||||
l_total.Text = $"Total: $$1.2{prodsFijosTot}"$
|
||||
' Dim ins As InputStream
|
||||
' Dim bmp As Bitmap
|
||||
' Dim jpeg() As Byte
|
||||
|
||||
'Llenamos el listview con los productos variables.
|
||||
If thisLog Then Log($"PV1: ${pv.Size}, ${pv}"$)
|
||||
If thisLog Then Log($"PV2: ${pv2.Size}, ${pv2}"$)
|
||||
If thisLog Then Log("invDisp=" & invDispPromo)
|
||||
clv_prodsVariabes.Clear
|
||||
clv_prodsVariabes2.Clear
|
||||
For Each p As String In pv
|
||||
If invDispPromo.ContainsKey(p) Then 'Si no esta en la lista de productos con inventario no lo mostramos.
|
||||
Private indicePV = listaPV.IndexOf(p)
|
||||
' Log(p & "|" & indicePV & "|" & listaPreciosPV.Get(indicePV))
|
||||
Private estePrecio = listaPreciosPV.Get(indicePV)
|
||||
' c2.Position=i
|
||||
' jpeg = c2.GetBlob("CAT_GP_IMG")
|
||||
' ins.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
|
||||
' bmp.Initialize2(ins)
|
||||
Private thisProd As Map = prodsPromo.Get(p)
|
||||
If thisLog Then Log(thisProd)
|
||||
clv_prodsVariabes.Add(CreateListItem(Subs.traeProdNombre(p)&CRLF&"Hay " & invDispPromo.Get(p) & " $" & estePrecio, estePrecio, invDispPromo.Get(p), clv_prodsVariabes.AsView.Width, 50dip, Null, p), p)
|
||||
End If
|
||||
Next
|
||||
For Each p As String In pv2
|
||||
If invDispPromo.ContainsKey(p) Then 'Si no esta en la lista de productos con inventario no lo mostramos.
|
||||
' Log(p)
|
||||
' Log($"${invDispPromo}$"$)
|
||||
' Log($"${listaPV2}"$)
|
||||
' Log("listaPrecios:"&listaPreciosPV2)
|
||||
Private indicePV2 = listaPV2.IndexOf(p)
|
||||
' Log($"${indicePV2}"$)
|
||||
' Log(p & "|" & indicePV & "|" & listaPreciosPV2.Get(indicePV2))
|
||||
Private estePrecio = listaPreciosPV2.Get(indicePV2)
|
||||
' c2.Position=i
|
||||
' jpeg = c2.GetBlob("CAT_GP_IMG")
|
||||
' ins.InitializeFromBytesArray(jpeg, 0, jpeg.Length)
|
||||
' bmp.Initialize2(ins)
|
||||
Private thisProd As Map = prodsPromo.Get(p)
|
||||
If thisLog Then Log(thisProd)
|
||||
clv_prodsVariabes2.Add(CreateListItem2(Subs.traeProdNombre(p)&CRLF&"Hay " & invDispPromo.Get(p) & " $" & estePrecio, estePrecio, invDispPromo.Get(p), clv_prodsVariabes2.AsView.Width, 50dip, Null, p), p)
|
||||
End If
|
||||
Next
|
||||
If pv2.Size = 0 Then
|
||||
' Log("PV2 = 0")
|
||||
l_prodsVariables2.Visible = False
|
||||
p_prodsVariables2.Visible = False
|
||||
|
||||
p_prodsVariables.Height = 410dip
|
||||
clv_prodsVariabes.GetBase.Height = p_prodsVariables.Height - 20
|
||||
' p_prodsVariables.Height = 380dip
|
||||
' clv_prodsVariabes.GetBase.Height = 380dip 'Cambiamos el tamaño y posición de la lista de productos
|
||||
'' clv_prodsVariabes.GetBase.Width =
|
||||
clv_prodsVariabes.Base_Resize(clv_prodsVariabes.GetBase.Width, p_prodsVariables.Height - 20) 'Cambiamos el tamaño del panel interno de la lista para que ajuste al nuevo tamaño.
|
||||
Else
|
||||
l_prodsVariables2.Visible = True
|
||||
p_prodsVariables2.Visible = True
|
||||
p_prodsVariables.Height = 210dip
|
||||
clv_prodsVariabes.GetBase.Height = p_prodsVariables.Height - 20
|
||||
End If
|
||||
b_terminar1.Visible = False
|
||||
b_continuar.Visible = False
|
||||
cuentaProds
|
||||
End Sub
|
||||
|
||||
'Agregamos los productos fijos a una lista para despues meterlos en el pedido.
|
||||
Sub agregaFijosALista(mp As Map, addListItem As Boolean)
|
||||
Private thisLog As Boolean = False
|
||||
Private cont As Int = 0
|
||||
prodsFijosTot = 0
|
||||
Dim pf As List = mp.Get("prodsFijos")
|
||||
If pf.Size < 1 Then pf.Add("Sin productos fijos.")
|
||||
' Private m As Map
|
||||
' prodsMap.Put(estaPromo, CreateMap("cant":1, "precio":0))
|
||||
' prodsIds.Add(estaPromo)
|
||||
prodsIds.clear
|
||||
prodsCants.clear
|
||||
prodsPrecios.clear
|
||||
prodsIds.Add(estaPromo)
|
||||
prodsCants.Add(et_promoCant.text.As(Int))
|
||||
prodsPrecios.Add(0)
|
||||
For Each p As String In pf
|
||||
' Log($"cont=${cont}, mp=${mp}"$)
|
||||
If mp.Get("prodsFijosPiezas").As(List).Size > 0 Then
|
||||
Private tpi As String = mp.Get("prodsFijosPiezas").As(List).Get(cont)
|
||||
Else
|
||||
Private tpi As String = 0
|
||||
End If
|
||||
If mp.Get("prodsFijosPrecios").As(List).Size > 0 Then
|
||||
Private tpr As String = mp.Get("prodsFijosPrecios").As(List).Get(cont)
|
||||
Else
|
||||
Private tpr As String = 0
|
||||
End If
|
||||
prodsFijosTot = prodsFijosTot + (tpi * tpr)
|
||||
If thisLog Then Log("|"&tpi&"|"&p)
|
||||
Private ntpi As Int = tpi * et_promoCant.text
|
||||
If addListItem And tpi > 0 Then lv_prodsFijos.AddSingleLine(ntpi & " " & Subs.traeProdNombre(p) & " - $" & tpr)
|
||||
cont = cont+1
|
||||
' m=CreateMap("cant":tpi, "precio":tpr)
|
||||
' prodsMap.Put(p, m)
|
||||
prodsIds.Add(p)
|
||||
prodsCants.Add(tpi.As(Int)*et_promoCant.text.As(Int))
|
||||
prodsPrecios.Add(tpr) '*et_promoCant.text.As(Int)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Sub CreateListItem(Text As String, 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("")
|
||||
p.SetLayoutAnimated(0, 0, 0, Width, Height)
|
||||
p.LoadLayout("prodItem")
|
||||
l_prodX.TextSize = 15
|
||||
l_prodX.Text = Text
|
||||
l_prodX.TextSize = 15
|
||||
' p_prods.Height = Height + 70
|
||||
' l_prodX.Height = Height
|
||||
p_prods.height = su.MeasureMultilineTextHeight(l_prodX, l_prodX.Text) + 20 'Calculamos la altura del panel de acuerdo al texto contenido.
|
||||
If p_prods.Height < Height Then p_prods.Height = Height
|
||||
l_prodX.Height = p_prods.Height
|
||||
l_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
||||
et_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
||||
et_pCant.BringToFront
|
||||
' i_prod.Bitmap = img
|
||||
p.Height = p_prods.Height
|
||||
Return p
|
||||
End Sub
|
||||
|
||||
Sub CreateListItem2(Text As String, 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("")
|
||||
p.SetLayoutAnimated(0, 0, 0, Width, Height)
|
||||
p.LoadLayout("prodItem2")
|
||||
l_prodX.TextSize = 15
|
||||
l_prodX.Text = Text
|
||||
l_prodX.TextSize = 15
|
||||
' p_prods.Height = Height
|
||||
' l_prodX.Height = Height
|
||||
p_prods.height = su.MeasureMultilineTextHeight(l_prodX, l_prodX.Text) + 20 'Calculamos la altura del panel de acuerdo al texto contenido.
|
||||
If p_prods.Height < Height Then p_prods.Height = Height
|
||||
l_prodX.Height = p_prods.Height
|
||||
' l_pCant.Text = 0
|
||||
l_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
||||
et_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
||||
et_pCant.BringToFront
|
||||
' i_prod.Bitmap = img
|
||||
p.Height = p_prods.Height
|
||||
Return p
|
||||
End Sub
|
||||
|
||||
Sub b_prodMenos_Click
|
||||
Dim index As Int = clv_prodsVariabes.GetItemFromView(Sender)
|
||||
Dim pnl0 As B4XView = clv_prodsVariabes.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
' Dim laCant As B4XView = pnl.GetView(5)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(4)
|
||||
' Log($"precio|stock:${laCant.tag}"$)
|
||||
laCant.Text = $"$1.0{laCant.Text-1}"$
|
||||
If laCant.Text < 0 Then laCant.Text = 0
|
||||
|
||||
' Log(Regex.Split("\|", laCant.tag)(0))
|
||||
Private precio As String = Regex.Split("\|", laCant.tag)(0)
|
||||
' Private inv As String = Regex.Split("\|", laCant.tag)(1)
|
||||
Private prodId As String = Regex.Split("\|", laCant.tag)(2)
|
||||
Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":estaPromo)
|
||||
' Log(tmpMap)
|
||||
promosMap.Put(prodId, tmpMap)
|
||||
If laCant.Text = 0 Then promosMap.Remove(prodId)
|
||||
' LogColor(promosMap, Colors.Magenta)
|
||||
cuentaProds
|
||||
' l_total.Text = $"Total Compra: $$1.2{totalCompra}"$
|
||||
' l_totProds.text = $"Total Productos: ${totalProds}"$
|
||||
End Sub
|
||||
|
||||
Sub b_prodMas_Click
|
||||
If prodsVar1 < prodsVarReq Then
|
||||
Dim index As Int = clv_prodsVariabes.GetItemFromView(Sender)
|
||||
Dim pnl0 As B4XView = clv_prodsVariabes.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
' Dim laCant As B4XView = pnl.GetView(5)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(4)
|
||||
' Log($"precio|stock:${laCant.tag}"$)
|
||||
' Log($"Indice: ${index}, cant:${laCant.Text+1}, precioU: ${laCant.tag}"$)
|
||||
Dim esteTag As List = Regex.Split("\|", laCant.Tag)
|
||||
' Log(esteTag)
|
||||
If laCant.Text + 1 <= esteTag.get(1) Then
|
||||
laCant.Text = $"$1.0{laCant.Text+1}"$
|
||||
cuentaProds
|
||||
End If
|
||||
|
||||
' Log(Regex.Split("\|", laCant.tag)(0))
|
||||
Private precio As String = Regex.Split("\|", laCant.tag)(0)
|
||||
' Private inv As String = Regex.Split("\|", laCant.tag)(1)
|
||||
Private prodId As String = Regex.Split("\|", laCant.tag)(2)
|
||||
Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":estaPromo)
|
||||
' Log(tmpMap)
|
||||
promosMap.Put(prodId, tmpMap)
|
||||
' LogColor(promosMap, Colors.Magenta)
|
||||
End If
|
||||
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
||||
' l_total.Text = $"Total Compra: $$1.2{totalCompra}"$
|
||||
' l_totProds.text = $"Total Productos: ${totalProds}"$
|
||||
End Sub
|
||||
|
||||
|
||||
Sub b_prodMenos2_Click
|
||||
Dim index As Int = clv_prodsVariabes2.GetItemFromView(Sender)
|
||||
Dim pnl0 As B4XView = clv_prodsVariabes2.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
' Dim laCant As B4XView = pnl.GetView(5)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(4)
|
||||
' Log($"precio|stock:${laCant.tag}"$)
|
||||
laCant.Text = $"$1.0{laCant.Text-1}"$
|
||||
If laCant.Text < 0 Then laCant.Text = 0
|
||||
|
||||
' Log(Regex.Split("\|", laCant.tag)(0))
|
||||
Private precio As String = Regex.Split("\|", laCant.tag)(0)
|
||||
' Private inv As String = Regex.Split("\|", laCant.tag)(1)
|
||||
Private prodId As String = Regex.Split("\|", laCant.tag)(2)
|
||||
Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":estaPromo)
|
||||
' Log(tmpMap)
|
||||
promosMap.Put(prodId, tmpMap)
|
||||
If laCant.Text = 0 Then promosMap.Remove(prodId)
|
||||
' LogColor(promosMap, Colors.Magenta)
|
||||
cuentaProds
|
||||
' l_total.Text = $"Total Compra: $$1.2{totalCompra}"$
|
||||
' l_totProds.text = $"Total Productos: ${totalProds}"$
|
||||
End Sub
|
||||
|
||||
Sub b_prodMas2_Click
|
||||
' Log(prodsVarReq & "|" & prodsVarReq2 & "|" & tpf & "|" & prodsVar2)
|
||||
If prodsVar2 < prodsVarReq2 Then
|
||||
Dim index As Int = clv_prodsVariabes2.GetItemFromView(Sender)
|
||||
Dim pnl0 As B4XView = clv_prodsVariabes2.GetPanel(index)
|
||||
Dim pnl As B4XView = pnl0.GetView(0)
|
||||
' Dim laCant As B4XView = pnl.GetView(5)
|
||||
Dim laCant As B4XView = pnl.GetView(2).GetView(4)
|
||||
' Log($"precio|stock:${laCant.tag}"$)
|
||||
' Log($"Indice: ${index}, cant:${laCant.Text+1}, precioU: ${laCant.tag}"$)
|
||||
Dim esteTag As List = Regex.Split("\|", laCant.Tag)
|
||||
' Log(esteTag)
|
||||
If laCant.Text + 1 <= esteTag.get(1) Then
|
||||
laCant.Text = $"$1.0{laCant.Text+1}"$
|
||||
cuentaProds
|
||||
End If
|
||||
|
||||
' Log(Regex.Split("\|", laCant.tag)(0))
|
||||
Private precio As String = Regex.Split("\|", laCant.tag)(0)
|
||||
' Private inv As String = Regex.Split("\|", laCant.tag)(1)
|
||||
Private prodId As String = Regex.Split("\|", laCant.tag)(2)
|
||||
Private tmpMap As Map = CreateMap("precio":precio, "cant":laCant.Text, "almacen":estaPromo)
|
||||
' Log(tmpMap)
|
||||
promosMap.Put(prodId, tmpMap)
|
||||
' LogColor(promosMap, Colors.Magenta)
|
||||
End If
|
||||
' Log($"Total Prods: ${totalProds}, Total Compra: $$1.2{totalCompra}"$)
|
||||
' l_total.Text = $"Total Compra: $$1.2{totalCompra}"$
|
||||
' l_totProds.text = $"Total Productos: ${totalProds}"$
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub et_pCant_TextChanged (Old As String, New As String)
|
||||
' LogColor("txt changed",Colors.Magenta)
|
||||
cuentaProds
|
||||
End Sub
|
||||
|
||||
Sub cuentaProds
|
||||
' Log("=====================================================")
|
||||
' Log("Inicia cuentaProds")
|
||||
Private thisLog As Boolean = False
|
||||
' LogColor($"ProdsFijos=${tpf}, totalProds=${totalProds}, totalCompra=${totalCompra}"$, Colors.Red)
|
||||
prodsIds2.Clear
|
||||
prodsCants2.Clear
|
||||
prodsPrecios2.Clear
|
||||
lv_prodsFijos.Clear
|
||||
prodsVar1 = 0
|
||||
prodsVar2 = 0
|
||||
agregaFijosALista(Subs.traePromo(estaPromo, esteCliente), True)
|
||||
' Log(prodsIds)
|
||||
Private tcpf As Float = 0 'Total de compra de productos fijos.
|
||||
For pf = 0 To prodsIds.Size - 1
|
||||
If thisLog Then Log($"${tcpf} + ${prodsCants.Get(pf)} * ${prodsPrecios.Get(pf)} = ${(prodsPrecios.Get(pf) * prodsCants.Get(pf))}"$)
|
||||
tcpf = tcpf + (prodsPrecios.Get(pf) * prodsCants.Get(pf))
|
||||
Next
|
||||
' Log("Total compra prodsFijos = " & tcpf)
|
||||
totalCompra = tcpf
|
||||
totalProds = tpf 'Cantidad total de productos fijos.
|
||||
'Variables1
|
||||
For i = 0 To clv_prodsVariabes.GetSize - 1
|
||||
Private p0 As B4XView = clv_prodsVariabes.GetPanel(i)
|
||||
Private p As B4XView = p0.GetView(0)
|
||||
Private cant1 As B4XView = p.GetView(2).GetView(4)
|
||||
' If cant1.Text = "" Then cant1.Text = 0
|
||||
totalProds = totalProds + cant1.Text
|
||||
prodsVar1 = prodsVar1 + cant1.Text
|
||||
Private esteTag As List = Regex.Split("\|", cant1.Tag)
|
||||
If cant1.Text > esteTag.Get(1) Then cant1.Text = esteTag.Get(1)
|
||||
If cant1.Text > 0 Then
|
||||
' Log(esteTag.Get(2) & "|" & cant1.Text)
|
||||
totalCompra = totalCompra + (esteTag.get(0) * cant1.text)
|
||||
If thisLog Then Log($"Cant: ${cant1.Text}, Suma: ${totalCompra}"$)
|
||||
prodsIds2.Add(esteTag.Get(2))
|
||||
prodsCants2.Add(cant1.Text)
|
||||
prodsPrecios2.Add(esteTag.get(0))
|
||||
End If
|
||||
l_total.Text = $"Total: $$1.2{totalCompra}"$
|
||||
l_totProds.text = $"Productos: ${totalProds}"$
|
||||
Next
|
||||
'Variables2
|
||||
For i = 0 To clv_prodsVariabes2.GetSize - 1
|
||||
Private p0 As B4XView = clv_prodsVariabes2.GetPanel(i)
|
||||
Private p As B4XView = p0.GetView(0)
|
||||
Private cant2 As B4XView = p.GetView(2).GetView(4)
|
||||
totalProds = totalProds + cant2.Text
|
||||
prodsVar2 = prodsVar2 + cant2.Text
|
||||
Private esteTag As List = Regex.Split("\|", cant2.Tag)
|
||||
If cant2.Text > esteTag.Get(1) Then cant2.Text = esteTag.Get(1)
|
||||
If cant2.Text > 0 Then
|
||||
' Log(esteTag.Get(2) & "|" & cant2.Text)
|
||||
totalCompra = totalCompra + (esteTag.get(0) * cant2.text)
|
||||
If thisLog Then Log($"Cant: ${cant2.Text}, Suma: ${totalCompra}"$)
|
||||
prodsIds2.Add(esteTag.Get(2))
|
||||
prodsCants2.Add(cant2.Text)
|
||||
prodsPrecios2.Add(esteTag.get(0))
|
||||
End If
|
||||
l_total.Text = $"Total: $$1.2{totalCompra}"$
|
||||
l_totProds.text = $"Productos: ${totalProds}"$
|
||||
Next
|
||||
|
||||
If thisLog Then Log($"Total Prods: ${totalProds}, Total: $$1.2{totalCompra}"$)
|
||||
l_total.Text = $"Total: $$1.2{totalCompra}"$
|
||||
l_totProds.text = $"Productos: ${totalProds}"$
|
||||
If totalProds < prodsVarReq + prodsVarReq2 + tpf Or totalProds > prodsVarReq + prodsVarReq2 + tpf Then
|
||||
' Log("INCOMPLETA")
|
||||
b_terminar1.Visible = False
|
||||
b_continuar.Visible = False
|
||||
Else
|
||||
' Log("COMPLETA")
|
||||
b_terminar1.Visible = True
|
||||
b_continuar.Visible = True
|
||||
End If
|
||||
If thisLog Then LogColor($"${prodsIds}${CRLF}${prodsCants}${CRLF}${prodsPrecios}"$, Colors.blue)
|
||||
If thisLog Then LogColor($"${prodsIds2}${CRLF}${prodsCants2}${CRLF}${prodsPrecios2}"$, Colors.Magenta)
|
||||
' LogColor($"Total Prods: ${totalProds}, Total: $$1.2{totalCompra}"$, Colors.Blue)
|
||||
End Sub
|
||||
|
||||
Private Sub et_pCant_FocusChanged (HasFocus As Boolean)
|
||||
LogColor("focus changed", Colors.Magenta)
|
||||
cuentaProds
|
||||
End Sub
|
||||
|
||||
Private Sub b_promoMenos_Click
|
||||
If et_promoCant.Text > 1 Then
|
||||
et_promoCant.Text = et_promoCant.Text.As(Int) - 1
|
||||
End If
|
||||
l_prodsFijos.Text = $"Productos fijos (${tpf2 * et_promoCant.Text.As(Int)})"$
|
||||
l_prodsVariables.Text = $"Productos variables requeridos: ${prodsVarReq_ * et_promoCant.Text.As(Int)}"$
|
||||
l_prodsVariables2.Text = $"Productos variables2 requeridos: ${prodsVarReq2_ * et_promoCant.Text.As(Int)}"$
|
||||
tpf = tpf2 * et_promoCant.Text.As(Int)
|
||||
prodsVarReq = prodsVarReq_ * et_promoCant.Text.As(Int)
|
||||
prodsVarReq2 = prodsVarReq2_ * et_promoCant.Text.As(Int)
|
||||
Log($"Max promos=${et_promoCant.Text.As(Int)}, Prods fijos=${tpf}, "$)
|
||||
cuentaProds
|
||||
End Sub
|
||||
|
||||
Private Sub b_promoMas_Click
|
||||
If et_promoCant.Text < maxCantPromos Then
|
||||
et_promoCant.Text = et_promoCant.Text.As(Int) + 1
|
||||
l_prodsFijos.Text = $"Productos fijos (${tpf2 * et_promoCant.Text.As(Int)})"$
|
||||
l_prodsVariables.Text = $"Productos variables requeridos: ${prodsVarReq_ * et_promoCant.Text.As(Int)}"$
|
||||
l_prodsVariables2.Text = $"Productos variables2 requeridos: ${prodsVarReq2_ * et_promoCant.Text.As(Int)}"$
|
||||
tpf = tpf2 * et_promoCant.Text.As(Int)
|
||||
prodsVarReq = prodsVarReq_ * et_promoCant.Text.As(Int)
|
||||
prodsVarReq2 = prodsVarReq2_ * et_promoCant.Text.As(Int)
|
||||
Log($"Max promos=${et_promoCant.Text.As(Int)}, Prods fijos=${tpf}, "$)
|
||||
End If
|
||||
If et_promoCant.text > maxCantPromos Then et_promoCant.Text = maxCantPromos
|
||||
cuentaProds
|
||||
End Sub
|
||||
|
||||
Private Sub b_terminar1_Click
|
||||
cuentaProds
|
||||
Log("====================================================================")
|
||||
For t = 0 To prodsIds.Size - 1 'Guardamos los productos fijos de la promocion en pedido.
|
||||
Private pn As String = Subs.traeProdNombre(prodsIds.Get(t))
|
||||
If prodsCants.Get(t) > 0 Then Subs.guardaProductoSinGestion(estaPromo, prodsPrecios.Get(t), prodsCants.Get(t), pn, prodsIds.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
||||
Next
|
||||
For t = 0 To prodsIds2.Size - 1 'Guardamos los productos variables de la promocion en pedido.
|
||||
Private pn As String = Subs.traeProdNombre(prodsIds2.Get(t))
|
||||
Subs.guardaProductoSinGestion(estaPromo, prodsPrecios2.Get(t), prodsCants2.Get(t), pn, prodsIds2.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
||||
Next
|
||||
' Log(B4XPages.MainPage.productos.prodsMap)
|
||||
' For o=0 To prodsIds.Size - 1 'Ponemos los productos fijos en el mapa de la compra.
|
||||
' Private tmpMap As Map = CreateMap("precio":prodsPrecios.Get(o), "cant":prodsCants.Get(o), "almacen":estaPromo)
|
||||
'' Log(tmpMap)
|
||||
' If prodsCants.Get(o) > 0 Then B4XPages.MainPage.productos.prodsMap.Put(estaPromo&"|"&prodsIds.Get(o), tmpMap)
|
||||
' Next
|
||||
' For o=0 To prodsIds2.Size - 1 'Ponemos los productos variables en el mapa de la compra.
|
||||
' Private tmpMap As Map = CreateMap("precio":prodsPrecios2.Get(o), "cant":prodsCants2.Get(o), "almacen":estaPromo)
|
||||
'' Log(tmpMap)
|
||||
' B4XPages.MainPage.productos.prodsMap.Put(estaPromo&"|"&prodsIds2.Get(o), tmpMap)
|
||||
' Next
|
||||
' LogColor(B4XPages.MainPage.productos.prodsMap, Colors.red)
|
||||
lv_prodsFijos.Clear
|
||||
B4XPages.MainPage.bTerminarClicked = True
|
||||
B4XPages.ShowPage("productos")
|
||||
B4XPages.MainPage.productos.b_terminar1_Click
|
||||
End Sub
|
||||
|
||||
Private Sub b_continuar_Click
|
||||
cuentaProds
|
||||
Log("====================================================================")
|
||||
For t = 0 To prodsIds.Size - 1 'Guardamos los productos fijos de la promocion en pedido.
|
||||
Private pn As String = Subs.traeProdNombre(prodsIds.Get(t))
|
||||
Subs.guardaProductoSinGestion(estaPromo, prodsPrecios.Get(t), prodsCants.Get(t), pn, prodsIds.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
||||
Next
|
||||
For t = 0 To prodsIds2.Size - 1 'Guardamos los productos variables de la promocion en pedido.
|
||||
Private pn As String = Subs.traeProdNombre(prodsIds2.Get(t))
|
||||
Subs.guardaProductoSinGestion(estaPromo, prodsPrecios2.Get(t), prodsCants2.Get(t), pn, prodsIds2.Get(t), Subs.traeCliente, Subs.traeFecha, Subs.traeUsuarioDeBD, Subs.traeRuta, 0, B4XPages.MainPage.tipo_venta)
|
||||
Next
|
||||
' Log(B4XPages.MainPage.productos.prodsMap)
|
||||
' For o=0 To prodsIds.Size - 1 'Ponemos los productos fijos en el mapa de la compra.
|
||||
' Private tmpMap As Map = CreateMap("precio":prodsPrecios.Get(o), "cant":prodsCants.Get(o), "almacen":estaPromo)
|
||||
'' Log(tmpMap)
|
||||
' If prodsCants.Get(o) > 0 Then B4XPages.MainPage.productos.prodsMap.Put(estaPromo&"|"&prodsIds.Get(o), tmpMap)
|
||||
' Next
|
||||
' For o=0 To prodsIds2.Size - 1 'Ponemos los productos variables en el mapa de la compra.
|
||||
' Private tmpMap As Map = CreateMap("precio":prodsPrecios2.Get(o), "cant":prodsCants2.Get(o), "almacen":estaPromo)
|
||||
'' Log(tmpMap)
|
||||
' B4XPages.MainPage.productos.prodsMap.Put(estaPromo&"|"&prodsIds2.Get(o), tmpMap)
|
||||
' Next
|
||||
' LogColor(B4XPages.MainPage.productos.prodsMap, Colors.red)
|
||||
lv_prodsFijos.Clear
|
||||
' Activity_KeyPress(KeyCodes.KEYCODE_BACK)
|
||||
' CallSubDelayed2(productos, "Activity_KeyPress", KeyCodes.KEYCODE_BACK)
|
||||
Private prodspage As C_Productos
|
||||
If prodspage.IsInitialized Then
|
||||
prodspage.lv_catalogos.Visible = True
|
||||
prodspage.lv_promos.Visible = False
|
||||
prodspage.clv_productos.AsView.Visible = False
|
||||
End If
|
||||
B4XPages.MainPage.bTerminarClicked = True
|
||||
B4XPages.ShowPage("productos")
|
||||
End Sub
|
||||
|
||||
'Sub Activity_KeyPress (key As Int) As Boolean 'ignore
|
||||
' ' BACK key pressed
|
||||
' Log("Keypress")
|
||||
' If key=KeyCodes.KEYCODE_BACK Then
|
||||
' Log("BACK")
|
||||
' Return False
|
||||
' End If
|
||||
' Return False
|
||||
' ' Returning False signals the system to handle the key
|
||||
'End Sub
|
||||
164
B4A/C_TicketsDia.bas
Normal file
@@ -0,0 +1,164 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
Private p_ticketsdia As Panel
|
||||
|
||||
Dim c As Cursor
|
||||
Dim S As Cursor
|
||||
Dim ruta As String
|
||||
Dim ListView1 As ListView
|
||||
Dim b_noventa As Button
|
||||
Dim nombre_boton As String
|
||||
Dim STIME As String
|
||||
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
|
||||
ruta = File.DirInternal
|
||||
Root.LoadLayout("ticketsdia")
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
c = B4XPages.MainPage.skmt.ExecQuery("select PC_CLIENTE,PC_MONTO,PC_NOART FROM PEDIDO_CLIENTE ORDER BY PC_FECHA asc")
|
||||
|
||||
|
||||
ListView1.Clear
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 13
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),"Cantidad #"& c.GetString("PC_NOART")& " SubTotal $"& c.GetString("PC_MONTO"))
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
nombre_boton = "NOVENTA"
|
||||
c=B4XPages.MainPage.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")
|
||||
Dim noArticulos As Int = 0
|
||||
|
||||
ListView1.Clear
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim x As Cursor = B4XPages.MainPage.skmt.ExecQuery($"select sum(PE_CANT) as PC_NOART from PEDIDO where PE_CLIENTE = '${c.GetString("PC_CLIENTE")}' AND PE_PROID NOT IN (SELECT CAT_PA_ID FROM PROMOS_COMP)"$)
|
||||
If x.RowCount > 0 Then
|
||||
x.Position = 0
|
||||
Log(x.GetString("PC_NOART"))
|
||||
noArticulos = x.GetString("PC_NOART")
|
||||
End If
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 10
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 13
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& noArticulos & " SubTotal $"& c.GetString("PC_MONTO"))
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
End Sub
|
||||
|
||||
Sub Regresar_Click
|
||||
B4XPages.ShowPage("cliente")
|
||||
End Sub
|
||||
Sub Activity_KeyPress (key As Int) As Boolean
|
||||
' BACK key pressed
|
||||
If key=KeyCodes.KEYCODE_BACK Then
|
||||
' I want to capture the key here so I return True
|
||||
B4XPages.ShowPage("principal")
|
||||
'Return True
|
||||
End If
|
||||
' Returning False signals the system to handle the key
|
||||
Return False
|
||||
End Sub
|
||||
Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(Value))
|
||||
DateTime.TimeFormat = "HHmmss"
|
||||
STIME=DateTime.Time(DateTime.Now)
|
||||
s=B4XPages.MainPage.skmt.ExecQuery("SELECT COUNT(*) AS CUANTOS FROM HIST_STAY_STORE WHERE HSS_IN = 0 AND HSS_CODIGO In (select cuenta from cuentaa)")
|
||||
s.Position = 0
|
||||
If s.GetString("CUANTOS") = 1 Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_IN = ? where HSS_IN = 0 AND HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(STIME))
|
||||
Else
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_STAY_STORE(HSS_CODIGO, HSS_IN , HSS_OUT , HSS_TOT) VALUES (?,0,0,0)", Array As Object (Value))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE HIST_STAY_STORE set HSS_IN = ? where HSS_IN = 0 AND HSS_CODIGO In (select cuenta from cuentaa)", Array As Object(STIME))
|
||||
End If
|
||||
DateTime.TimeFormat = "HH:mm:ss"
|
||||
Subs.guardaClienteHoraInicio(Value)
|
||||
B4XPages.MainPage.cliente.venimosDeTicketsDia = True
|
||||
B4XPages.ShowPage("cliente")
|
||||
End Sub
|
||||
|
||||
Sub b_noventa_Click
|
||||
If nombre_boton = "NOVENTA" Then
|
||||
nombre_boton = "VENTA"
|
||||
b_noventa.Text ="VENTA"
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select NV_CLIENTE,NV_MOTIVO,NV_COMM, (select CAT_CL_NOMBRE from kmt_info where cat_cl_codigo = NV_CLIENTE ) as NOMBRE FROM NOVENTA ORDER BY NV_CLIENTE asc")
|
||||
ListView1.Clear
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("NV_CLIENTE"),c.GetString("NOMBRE") &" Motivo #"& c.GetString("NV_MOTIVO")& " Comentario $"& c.GetString("NV_COMM"))
|
||||
Next
|
||||
End If
|
||||
Else
|
||||
nombre_boton = "NOVENTA"
|
||||
b_noventa.Text ="NO VENTA"
|
||||
c=B4XPages.MainPage.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
|
||||
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& c.GetString("PC_NOART")& " SubTotal $"& c.GetString("PC_MONTO"))
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub p_ticketsdia_Click
|
||||
|
||||
End Sub
|
||||
73
B4A/C_UpdateAvailable.bas
Normal file
@@ -0,0 +1,73 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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.Color = Colors.Transparent
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
Try
|
||||
Do While Not(CanRequestPackageInstalls)
|
||||
MsgboxAsync($"Por favor permita que ${Application.PackageName} instale actualizaciones"$, "Instalar actualización")
|
||||
Wait For Msgbox_Result(Result As Int)
|
||||
Dim in As Intent
|
||||
in.Initialize("android.settings.MANAGE_UNKNOWN_APP_SOURCES", "package:" & Application.PackageName)
|
||||
StartActivity(in)
|
||||
Loop
|
||||
Catch
|
||||
Log("updateAvailable() Error - " & LastException.Message)
|
||||
End Try
|
||||
If appUpdater.newApp.update Then
|
||||
ofreceActualizacion
|
||||
Else
|
||||
sinActualizacion
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'////////////////////////////////////////////////////////////////////////////////////////////
|
||||
'//// Esta es una actividad usada por el servicio appUpdater para mostrar notificaciones
|
||||
'//// cuando hay alguna actualizacion de apk.
|
||||
'////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Sub CanRequestPackageInstalls As Boolean
|
||||
' // https://www.b4x.com/android/forum/threads/version-safe-apk-installation.87667/#content
|
||||
Dim ctxt As JavaObject
|
||||
ctxt.InitializeContext
|
||||
Dim PackageManager As JavaObject = ctxt.RunMethod("getPackageManager", Null)
|
||||
Return PackageManager.RunMethod("canRequestPackageInstalls", Null)
|
||||
End Sub
|
||||
|
||||
Sub ofreceActualizacion
|
||||
If Msgbox2(appUpdater.newApp.newMsg,"Actualización disponible","Si","","No",Null) = DialogResponse.Positive Then 'ignore
|
||||
' StartService(DownloadService)
|
||||
CallSubDelayed(appUpdater, "download_newApk")
|
||||
End If
|
||||
B4XPages.MainPage.ocultaProgreso
|
||||
StartActivity(Main)
|
||||
' Activity.Finish
|
||||
B4XPages.ShowPage("Login")
|
||||
End Sub
|
||||
|
||||
Sub sinActualizacion
|
||||
Msgbox(appUpdater.newApp.okMsg, "Aplicación al corriente") 'ignore
|
||||
' StartActivity(Main)
|
||||
B4XPages.MainPage.ocultaProgreso
|
||||
B4XPages.ShowPage("Login")
|
||||
End Sub
|
||||
275
B4A/DBRequestManager.bas
Normal file
@@ -0,0 +1,275 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=6.8
|
||||
@EndOfDesignText@
|
||||
'Necesita la libreria RandomAccessFile
|
||||
|
||||
'Class module
|
||||
Sub Class_Globals
|
||||
Private mTarget As Object
|
||||
Type DBResult (Tag As Object, Columns As Map, Rows As List)
|
||||
Type DBCommand (Name As String, Parameters() As Object)
|
||||
Private link As String
|
||||
Private bc As ByteConverter
|
||||
Private T_NULL = 0, T_STRING = 1, T_SHORT = 2, T_INT = 3, T_LONG = 4, T_FLOAT = 5 _
|
||||
,T_DOUBLE = 6, T_BOOLEAN = 7, T_BLOB = 8 As Byte
|
||||
Private VERSION As Float = 0.9
|
||||
Private tempArray(1) As Object
|
||||
Dim jobTagAnterior As String = "" 'Mod por CHV - 211027
|
||||
End Sub
|
||||
|
||||
'Target - The module that handles JobDone (usually Me).
|
||||
'ConnectorLink - URL of the Java server.
|
||||
Public Sub Initialize (Target As Object, ConnectorLink As String)
|
||||
mTarget = Target
|
||||
link = ConnectorLink
|
||||
End Sub
|
||||
|
||||
'Sends a query request.
|
||||
'Command - Query name and parameters.
|
||||
'Limit - Maximum rows to return or 0 for no limit.
|
||||
'Tag - An object that will be returned in the result.
|
||||
Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object)
|
||||
Dim j As HttpJob
|
||||
Dim ms As OutputStream
|
||||
Dim out2 As OutputStream = StartJob(j,ms, Tag)
|
||||
|
||||
WriteObject(Command.Name, out2)
|
||||
WriteInt(Limit, out2)
|
||||
WriteList(Command.Parameters, out2)
|
||||
out2.Close
|
||||
j.PostBytes(link & "?method=query", ms.ToBytesArray)
|
||||
End Sub
|
||||
|
||||
'Executes a batch of (non-select) commands.
|
||||
'ListOfCommands - List of the commands that will be executes.
|
||||
'Tag - An object that will be returned in the result.
|
||||
Public Sub ExecuteBatch(ListOfCommands As List, Tag As Object)
|
||||
Dim j As HttpJob
|
||||
Dim ms As OutputStream
|
||||
Dim out2 As OutputStream = StartJob(j,ms, Tag)
|
||||
WriteInt(ListOfCommands.Size, out2)
|
||||
For Each Command As DBCommand In ListOfCommands
|
||||
WriteObject(Command.Name, out2)
|
||||
WriteList(Command.Parameters, out2)
|
||||
Next
|
||||
out2.Close
|
||||
j.PostBytes(link & "?method=batch", ms.ToBytesArray)
|
||||
End Sub
|
||||
|
||||
'Similar to ExecuteBatch. Sends a single command.
|
||||
Public Sub ExecuteCommand(Command As DBCommand, Tag As Object)
|
||||
ExecuteBatch(Array As DBCommand(Command), Tag)
|
||||
End Sub
|
||||
|
||||
Private Sub StartJob(j As HttpJob, MemoryStream As OutputStream, Tag As Object) As OutputStream
|
||||
j.Initialize("DBRequest", mTarget)
|
||||
j.Tag = Tag
|
||||
MemoryStream.InitializeToBytesArray(0)
|
||||
Dim compress As CompressedStreams
|
||||
Dim out As OutputStream = compress.WrapOutputStream(MemoryStream, "gzip")
|
||||
WriteObject(VERSION, out)
|
||||
Return out
|
||||
End Sub
|
||||
|
||||
Private Sub WriteList(Parameters As List, out As OutputStream)
|
||||
Dim data() As Byte
|
||||
If Parameters = Null Or Parameters.IsInitialized = False Then
|
||||
Dim Parameters As List
|
||||
Parameters.Initialize
|
||||
End If
|
||||
data = bc.IntsToBytes(Array As Int(Parameters.Size))
|
||||
out.WriteBytes(data, 0, data.Length)
|
||||
For Each o As Object In Parameters
|
||||
WriteObject(o, out)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub WriteObject(o As Object, out As OutputStream)
|
||||
Dim data() As Byte
|
||||
tempArray(0) = o
|
||||
If tempArray(0) = Null Then
|
||||
out.WriteBytes(Array As Byte(T_NULL), 0, 1)
|
||||
Else If tempArray(0) Is Short Then
|
||||
out.WriteBytes(Array As Byte(T_SHORT), 0, 1)
|
||||
data = bc.ShortsToBytes(Array As Short(o))
|
||||
Else If tempArray(0) Is Int Then
|
||||
out.WriteBytes(Array As Byte(T_INT), 0, 1)
|
||||
data = bc.IntsToBytes(Array As Int(o))
|
||||
Else If tempArray(0) Is Float Then
|
||||
out.WriteBytes(Array As Byte(T_FLOAT), 0, 1)
|
||||
data = bc.FloatsToBytes(Array As Float(o))
|
||||
Else If tempArray(0) Is Double Then
|
||||
out.WriteBytes(Array As Byte(T_DOUBLE), 0, 1)
|
||||
data = bc.DoublesToBytes(Array As Double(o))
|
||||
Else If tempArray(0) Is Long Then
|
||||
out.WriteBytes(Array As Byte(T_LONG), 0, 1)
|
||||
data = bc.LongsToBytes(Array As Long(o))
|
||||
Else If tempArray(0) Is Boolean Then
|
||||
out.WriteBytes(Array As Byte(T_BOOLEAN), 0, 1)
|
||||
Dim b As Boolean = 0
|
||||
Dim data(1) As Byte
|
||||
If b Then data(0) = 1 Else data(0) = 0
|
||||
Else If GetType(tempArray(0)) = "[B" Then
|
||||
data = o
|
||||
out.WriteBytes(Array As Byte(T_BLOB), 0, 1)
|
||||
WriteInt(data.Length, out)
|
||||
Else 'If o Is String Then (treat all other values as string)
|
||||
out.WriteBytes(Array As Byte(T_STRING), 0, 1)
|
||||
data = bc.StringToBytes(o, "UTF8")
|
||||
WriteInt(data.Length, out)
|
||||
End If
|
||||
If data.Length > 0 Then out.WriteBytes(data, 0, data.Length)
|
||||
End Sub
|
||||
|
||||
Private Sub ReadObject(In As InputStream) As Object
|
||||
Dim data(1) As Byte
|
||||
In.ReadBytes(data, 0, 1)
|
||||
Select data(0)
|
||||
Case T_NULL
|
||||
Return Null
|
||||
Case T_SHORT
|
||||
Dim data(2) As Byte
|
||||
Return bc.ShortsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_INT
|
||||
Dim data(4) As Byte
|
||||
Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_LONG
|
||||
Dim data(8) As Byte
|
||||
Return bc.LongsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_FLOAT
|
||||
Dim data(4) As Byte
|
||||
Return bc.FloatsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_DOUBLE
|
||||
Dim data(8) As Byte
|
||||
Return bc.DoublesFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_BOOLEAN
|
||||
Dim b As Byte = ReadByte(In)
|
||||
Return b = 1
|
||||
Case T_BLOB
|
||||
Dim len As Int = ReadInt(In)
|
||||
Dim data(len) As Byte
|
||||
Return ReadBytesFully(In, data, data.Length)
|
||||
Case Else
|
||||
Dim len As Int = ReadInt(In)
|
||||
Dim data(len) As Byte
|
||||
ReadBytesFully(In, data, data.Length)
|
||||
Return BytesToString(data, 0, data.Length, "UTF8")
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub ReadBytesFully(In As InputStream, Data() As Byte, Len As Int) As Byte()
|
||||
Dim count = 0, read As Int
|
||||
Do While count < Len And read > -1
|
||||
read = In.ReadBytes(Data, count, Len - count)
|
||||
count = count + read
|
||||
Loop
|
||||
Return Data
|
||||
End Sub
|
||||
|
||||
Private Sub WriteInt(i As Int, out As OutputStream)
|
||||
Dim data() As Byte
|
||||
data = bc.IntsToBytes(Array As Int(i))
|
||||
out.WriteBytes(data, 0, data.Length)
|
||||
End Sub
|
||||
|
||||
Private Sub ReadInt(In As InputStream) As Int
|
||||
Dim data(4) As Byte
|
||||
Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
End Sub
|
||||
|
||||
Private Sub ReadByte(In As InputStream) As Byte
|
||||
Dim data(1) As Byte
|
||||
In.ReadBytes(data, 0, 1)
|
||||
Return data(0)
|
||||
End Sub
|
||||
|
||||
'Handles the Job result and returns a DBResult.
|
||||
Public Sub HandleJob(Job As HttpJob) As DBResult
|
||||
Dim start As Long = DateTime.Now
|
||||
Dim In As InputStream = Job.GetInputStream
|
||||
Dim cs As CompressedStreams
|
||||
In = cs.WrapInputStream(In, "gzip")
|
||||
Dim serverVersion As Float = ReadObject(In) 'ignore
|
||||
Dim method As String = ReadObject(In)
|
||||
Dim table As DBResult
|
||||
table.Initialize
|
||||
table.Columns.Initialize
|
||||
table.rows.Initialize
|
||||
table.Tag = Job.Tag
|
||||
If jobTagAnterior <> Job.Tag Then LogColor("HandleJob: '"&Job.Tag&"'", Colors.Blue) 'Mod por CHV - 211023
|
||||
jobTagAnterior = Job.Tag 'Mod por CHV - 211023
|
||||
If method = "query" Then
|
||||
Dim numberOfColumns As Int = ReadInt(In)
|
||||
For i = 0 To numberOfColumns - 1
|
||||
table.Columns.Put(ReadObject(In), i)
|
||||
Next
|
||||
Do While ReadByte(In) = 1
|
||||
Dim rowObjects(numberOfColumns) As Object
|
||||
table.rows.Add(rowObjects)
|
||||
For col = 0 To numberOfColumns - 1
|
||||
Dim o As Object = ReadObject(In)
|
||||
rowObjects(col) = o
|
||||
Next
|
||||
Loop
|
||||
Else If method = "batch" Then
|
||||
table.Columns.Put("AffectedRows", 0)
|
||||
Dim rows As Int = ReadInt(In)
|
||||
For i = 0 To rows - 1
|
||||
table.rows.Add(Array As Object(ReadInt(In)))
|
||||
Next
|
||||
End If
|
||||
In.Close
|
||||
' Log("HandleJob: " & (DateTime.Now - start))
|
||||
Return table
|
||||
End Sub
|
||||
'Reads a file and returns the file as a bytes array.
|
||||
Public Sub FileToBytes(Dir As String, FileName As String) As Byte()
|
||||
Dim out As OutputStream
|
||||
out.InitializeToBytesArray(0)
|
||||
Dim In As InputStream = File.OpenInput(Dir, FileName)
|
||||
File.Copy2(In, out)
|
||||
out.Close
|
||||
Return out.ToBytesArray
|
||||
End Sub
|
||||
|
||||
'Converts an image to a bytes array (for BLOB fields).
|
||||
Public Sub ImageToBytes(Image As Bitmap) As Byte()
|
||||
Dim out As OutputStream
|
||||
out.InitializeToBytesArray(0)
|
||||
Image.WriteToStream(out, 100, "JPEG")
|
||||
out.Close
|
||||
Return out.ToBytesArray
|
||||
End Sub
|
||||
|
||||
'Converts a bytes array to an image (for BLOB fields).
|
||||
Public Sub BytesToImage(bytes() As Byte) As Bitmap
|
||||
Dim In As InputStream
|
||||
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
|
||||
Dim bmp As Bitmap
|
||||
bmp.Initialize2(In)
|
||||
Return bmp
|
||||
End Sub
|
||||
|
||||
'Prints the table to the logs.
|
||||
Public Sub PrintTable(Table As DBResult)
|
||||
Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size)
|
||||
Dim sb As StringBuilder
|
||||
sb.Initialize
|
||||
For Each col In Table.Columns.Keys
|
||||
sb.Append(col).Append(TAB)
|
||||
Next
|
||||
Log(sb.ToString)
|
||||
For Each row() As Object In Table.Rows
|
||||
Dim sb As StringBuilder
|
||||
sb.Initialize
|
||||
For Each record As Object In row
|
||||
sb.Append(record).Append(TAB)
|
||||
Next
|
||||
ToastMessageShow(sb.ToString, True)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
164
B4A/FileHandler.bas
Normal file
@@ -0,0 +1,164 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11
|
||||
@EndOfDesignText@
|
||||
'Requiere la librería "ContentResolver"
|
||||
'
|
||||
'Copiar este codigo al boton_Click que se quiere que importe la base de datos.
|
||||
'
|
||||
' Private Sub b_importarBD_Click
|
||||
' Private FH As FileHandler
|
||||
' FH.Initialize
|
||||
' Wait For (FH.Load) Complete (Result As LoadResult) 'Abre un fileManager para seleccionar la base de datos a importar.
|
||||
' File.Copy(Result.Dir, Result.FileName, File.DirInternal, "kmt.db") 'Copia la base de datos seleccionada al directorio interno.
|
||||
' Starter.skmt.Initialize(Starter.ruta,"kmt.db", True) 'Reiniciliza la base de datos con la recien importada.
|
||||
' ToastMessageShow("¡BD importada!", False)
|
||||
' End Sub
|
||||
|
||||
|
||||
Sub Class_Globals
|
||||
#if B4A
|
||||
Private ion As Object
|
||||
Private OldIntent As Intent
|
||||
#end if
|
||||
Type LoadResult (Success As Boolean, Dir As String, FileName As String, RealName As String, Size As Long, Modified As Long, MimeType As String)
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub Initialize
|
||||
|
||||
End Sub
|
||||
|
||||
#if B4A
|
||||
Public Sub SaveAs (Source As InputStream, MimeType As String, Title As String) As ResumableSub
|
||||
Dim intent As Intent
|
||||
intent.Initialize("android.intent.action.CREATE_DOCUMENT", "")
|
||||
intent.AddCategory("android.intent.category.OPENABLE")
|
||||
intent.PutExtra("android.intent.extra.TITLE", Title)
|
||||
intent.SetType(MimeType)
|
||||
StartActivityForResult(intent)
|
||||
Wait For ion_Event (MethodName As String, Args() As Object)
|
||||
If -1 = Args(0) Then 'resultCode = RESULT_OK
|
||||
Dim result As Intent = Args(1)
|
||||
Dim jo As JavaObject = result
|
||||
Dim ctxt As JavaObject
|
||||
Dim out As OutputStream = ctxt.InitializeContext.RunMethodJO("getContentResolver", Null).RunMethod("openOutputStream", Array(jo.RunMethod("getData", Null)))
|
||||
File.Copy2(Source, out)
|
||||
out.Close
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Public Sub Load As ResumableSub
|
||||
Dim cc As ContentChooser
|
||||
cc.Initialize("cc")
|
||||
cc.Show("application/octet-stream", "Choose text file")
|
||||
Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
|
||||
Log($"***************************${CRLF}${Dir}${CRLF} ${FileName}"$)
|
||||
Dim res As LoadResult = CreateLoadResult(Success, Dir, FileName)
|
||||
Log($"***************************${CRLF}${res.FileName}${CRLF} ${res}"$)
|
||||
If res.Success Then ExtractInformationFromURI(res.FileName, res)
|
||||
Return res
|
||||
End Sub
|
||||
|
||||
Private Sub StartActivityForResult(i As Intent)
|
||||
Dim jo As JavaObject = GetBA
|
||||
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
|
||||
jo.RunMethod("startActivityForResult", Array(ion, i))
|
||||
End Sub
|
||||
|
||||
Private Sub GetBA As Object
|
||||
Return Me.As(JavaObject).RunMethod("getBA", Null)
|
||||
End Sub
|
||||
|
||||
Private Sub ExtractInformationFromURI (Uri As String, res As LoadResult)
|
||||
Try
|
||||
|
||||
Dim resolver As ContentResolver
|
||||
resolver.Initialize("")
|
||||
Dim u As Uri
|
||||
u.Parse(Uri)
|
||||
Dim rs As ResultSet = resolver.Query(u, Null, "", Null, "")
|
||||
If rs.NextRow Then
|
||||
Dim columns As B4XSet = B4XCollections.CreateSet
|
||||
For i = 0 To rs.ColumnCount - 1
|
||||
columns.Add(rs.GetColumnName(i))
|
||||
Next
|
||||
If columns.Contains("_display_name") Then res.RealName = rs.GetString("_display_name")
|
||||
If columns.Contains("_size") Then res.Size = rs.GetLong("_size")
|
||||
If columns.Contains("last_modified") Then res.Modified = rs.GetLong("last_modified")
|
||||
If columns.Contains("mime_type") Then res.MimeType = rs.GetString("mime_type")
|
||||
End If
|
||||
rs.Close
|
||||
|
||||
Catch
|
||||
Log("error extracting information from file provider")
|
||||
Log(LastException)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Sub CheckForReceivedFiles As LoadResult
|
||||
Dim Activity As Activity = B4XPages.GetNativeParent(B4XPages.MainPage)
|
||||
If IsRelevantIntent(Activity.GetStartingIntent) Then
|
||||
Dim in As Intent = Activity.GetStartingIntent
|
||||
Dim uri As String
|
||||
If in.HasExtra("android.intent.extra.STREAM") Then
|
||||
uri = in.As(JavaObject).RunMethod("getParcelableExtra", Array("android.intent.extra.STREAM"))
|
||||
Else
|
||||
uri = in.GetData
|
||||
End If
|
||||
Dim res As LoadResult = CreateLoadResult(True, "ContentDir", uri)
|
||||
ExtractInformationFromURI(res.FileName, res)
|
||||
Return res
|
||||
End If
|
||||
Return CreateLoadResult(False, "", "")
|
||||
End Sub
|
||||
|
||||
Private Sub IsRelevantIntent(in As Intent) As Boolean
|
||||
If in.IsInitialized And in <> OldIntent And in.Action = in.ACTION_VIEW Then
|
||||
OldIntent = in
|
||||
Return True
|
||||
End If
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
#else if B4i
|
||||
Public Sub SaveAs(ParentPage As Object, AnchorView As Object, Text As String) As ResumableSub
|
||||
Dim avc As ActivityViewController
|
||||
avc.Initialize("avc", Array(Text))
|
||||
avc.Show(B4XPages.GetNativeParent(ParentPage), AnchorView)
|
||||
Wait For avc_Complete (Success As Boolean, ActivityType As String)
|
||||
Return Success
|
||||
End Sub
|
||||
|
||||
Public Sub Load (ParentPage As Object, AnchorView As Object) As ResumableSub
|
||||
Dim DocumentPicker As DocumentPickerViewController
|
||||
DocumentPicker.InitializeImport("picker", Array("public.text"))
|
||||
DocumentPicker.Show(B4XPages.GetNativeParent(ParentPage), AnchorView)
|
||||
Wait For Picker_Complete (Success As Boolean, URLs As List)
|
||||
If Success And URLs.Size > 0 Then
|
||||
Return UrlToLoadResult(URLs.Get(0))
|
||||
End If
|
||||
Return CreateLoadResult(False, "", "")
|
||||
End Sub
|
||||
|
||||
Public Sub UrlToLoadResult(url As String) As LoadResult
|
||||
Dim res As LoadResult = CreateLoadResult(IIf(File.Exists(url, ""), True, False), url, "")
|
||||
res.RealName = res.Dir.SubString(res.Dir.LastIndexOf("/") + 1)
|
||||
res.Size = File.Size(res.Dir, "")
|
||||
Return res
|
||||
End Sub
|
||||
#end if
|
||||
|
||||
Private Sub CreateLoadResult (Success As Boolean, Dir As String, FileName As String) As LoadResult
|
||||
Dim t1 As LoadResult
|
||||
t1.Initialize
|
||||
t1.Success = Success
|
||||
t1.Dir = Dir
|
||||
t1.FileName = FileName
|
||||
Return t1
|
||||
End Sub
|
||||
|
||||
BIN
B4A/Files/alert2.png
Normal file
|
After Width: | Height: | Size: 632 B |
BIN
B4A/Files/alerta_amarilla.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
B4A/Files/anterior.jpg
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
B4A/Files/carrito.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
B4A/Files/celltitle.bal
Normal file
BIN
B4A/Files/cliente.bal
Normal file
BIN
B4A/Files/clientes.bal
Normal file
BIN
B4A/Files/datoscliente.bal
Normal file
BIN
B4A/Files/durakelo.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
B4A/Files/engrane.jpg
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
B4A/Files/engrane_gris.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
B4A/Files/folioabono.bal
Normal file
BIN
B4A/Files/fondo_kmt.jpg
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
B4A/Files/hacer pedido.jpg
Normal file
|
After Width: | Height: | Size: 595 KiB |
BIN
B4A/Files/intmex_logo_192x192.jpg
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
B4A/Files/itembuttonblue.png
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
B4A/Files/kmt.db
Normal file
BIN
B4A/Files/login.bal
Normal file
BIN
B4A/Files/logo_192x192.jpg
Normal file
|
After Width: | Height: | Size: 4.1 KiB |
BIN
B4A/Files/mainpage.bal
Normal file
BIN
B4A/Files/malo.jpg
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
B4A/Files/mapa_rutas.bal
Normal file
BIN
B4A/Files/nota.bal
Normal file
BIN
B4A/Files/noventa.bal
Normal file
BIN
B4A/Files/nuevocliente.bal
Normal file
BIN
B4A/Files/nvo cliente.jpg
Normal file
|
After Width: | Height: | Size: 579 KiB |
BIN
B4A/Files/palomita_verde.png
Normal file
|
After Width: | Height: | Size: 156 KiB |
BIN
B4A/Files/pedido.bal
Normal file
BIN
B4A/Files/planfia_logo.png
Normal file
|
After Width: | Height: | Size: 220 KiB |
BIN
B4A/Files/principal.bal
Normal file
BIN
B4A/Files/proditem.bal
Normal file
BIN
B4A/Files/proditem2.bal
Normal file
BIN
B4A/Files/productos.bal
Normal file
BIN
B4A/Files/promociones.bal
Normal file
BIN
B4A/Files/resdia.bal
Normal file
BIN
B4A/Files/resdia.jpg
Normal file
|
After Width: | Height: | Size: 596 KiB |
BIN
B4A/Files/salma.jpg
Normal file
|
After Width: | Height: | Size: 7.7 KiB |
BIN
B4A/Files/salma.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
B4A/Files/scrollpromos.bal
Normal file
BIN
B4A/Files/senial.jpg
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
B4A/Files/sync.png
Normal file
|
After Width: | Height: | Size: 763 B |
BIN
B4A/Files/tache_rojo.png
Normal file
|
After Width: | Height: | Size: 249 KiB |
BIN
B4A/Files/ticket dia.jpg
Normal file
|
After Width: | Height: | Size: 575 KiB |
BIN
B4A/Files/ticketsdia.bal
Normal file
BIN
B4A/Files/tiendita.jpg
Normal file
|
After Width: | Height: | Size: 8.8 KiB |
BIN
B4A/Files/verde.png
Normal file
|
After Width: | Height: | Size: 7.5 KiB |
226
B4A/FirebaseMessaging.bas
Normal file
@@ -0,0 +1,226 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=10.2
|
||||
@EndOfDesignText@
|
||||
'///////////////////////////////////////////////////////////////////////////////////////
|
||||
'/// Agregar estas lineas al editor de manifiestos
|
||||
'
|
||||
' CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
|
||||
' CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
|
||||
' CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
|
||||
' CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
|
||||
'
|
||||
'/// Agregar modulo de servicio nuevo FirebaseMessaging y copiar este modulo
|
||||
'
|
||||
'/// Bajar el archivo google-services.json de la consola de Firebase (https://console.firebase.google.com/)
|
||||
'/// El nombre de la app en el archivo json tiene que ser el mismo que el nombre del paquete (Proyecto/Conf de Compilacion/Paquete)
|
||||
'
|
||||
'/// En Starter agregar esta linea
|
||||
'
|
||||
' Sub Service_Create
|
||||
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
|
||||
' End Sub
|
||||
'
|
||||
'/// En Main en Sub Process_Globals agregar esta linea
|
||||
'
|
||||
' Private const API_KEY As String = "AAAAv__xxxxxxxxxxxxx-xxxxxxxxxxxxxx-xxxxxxxxxxxx"
|
||||
'
|
||||
'/// Esta llave se consigue igualmente en la consola de Firebase, configuracion de proyecto, Cloud Messaging,
|
||||
'/// es la clave de servidor.
|
||||
'///
|
||||
'/// Se necesitan agregar las librerías: FirebaseAnalitics, FirebaseNotifications, JSON y OkHttpUtils2
|
||||
'/// ... JSON es necesario si se van a enviar mensajes, si solo se van a recibir, no es necesario.
|
||||
'
|
||||
'///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Sub Process_Globals
|
||||
' Private fm As FirebaseMessaging
|
||||
Private const API_KEY As String = "AAAAv1qt3Lk:APA91bECIR-pHn6ul53eYyoVlpPuOo85RO-0zcAgEXwE7vqw8DFSbBtCaCINiqWQAkBBZXxHtQMdpU6B-jHIqgFKVL196UgwHv0Gw6_IgmipfV_NiItjzlH9d2QNpGLp9y_JUKVjUEhP" 'Api_Key cheveguerra@gmail.com/Pusher
|
||||
Dim locRequest As String
|
||||
' Dim phn As Phone
|
||||
Dim pe As PhoneEvents
|
||||
Dim c As Cursor
|
||||
Public GZip As GZipStrings
|
||||
Dim Sprvsr As String = "Sprv-Cedex" ' El topico al que se mandan los mensajes push
|
||||
Dim Subscrito As String
|
||||
Dim au As String 'ignore
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
' fm.Initialize("fm") 'Inicializamos FirebaseMessaging
|
||||
pe.Initialize("pe") 'Para obtener la bateria
|
||||
End Sub
|
||||
|
||||
Public Sub SubscribeToTopics
|
||||
' fm.SubscribeToTopic("Trckr") 'Topico general Keymon
|
||||
fm.SubscribeToTopic("Trckr") 'Tracker Global
|
||||
' Log("Suscrito al tracker global")
|
||||
fm.SubscribeToTopic("Trckr-Cedex") 'Topico de Guna
|
||||
If "Cdx_"&B4XPages.MainPage.usuario <> Subscrito Then
|
||||
fm.SubscribeToTopic("Cdx_"&B4XPages.MainPage.usuario) 'Propio (you can subscribe to more topics)
|
||||
fm.UnsubscribeFromTopic(Subscrito) 'Unsubscribe from topic
|
||||
End If
|
||||
' Log("Subscrito a "&"Cdx_"&B4XPages.MainPage.usuario)
|
||||
Subscrito = "Cdx_"&B4XPages.MainPage.usuario
|
||||
' Log(fm.token)
|
||||
' fm.UnsubscribeFromTopic("Sprvsr") 'Unsubscribe from topic
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
|
||||
Sleep(0)
|
||||
Service.StopAutomaticForeground 'remove if not using B4A v8+.
|
||||
StartServiceAt(Me, DateTime.Now + 15 * DateTime.TicksPerMinute, True) 'Iniciamos servicio cada XX minutos
|
||||
End Sub
|
||||
|
||||
Sub fm_MessageArrived (Message As RemoteMessage)
|
||||
Log("Message arrived")
|
||||
Log($"Message data: ${Message.GetData}"$)
|
||||
' getPhnId
|
||||
If Message.GetData.ContainsKey("t") Then
|
||||
Dim tipos As List = Regex.Split(",",Message.GetData.Get("t"))
|
||||
If tipos.IndexOf("pu") <> -1 Or tipos.IndexOf("au") <> -1 Then 'Si es una peticion de ubicacion
|
||||
Log("Es una peticion de ubicacion")
|
||||
locRequest="Activa"
|
||||
Log("Llamamos StartFLPSmall")
|
||||
CallSubDelayed(Tracker, "StartFLPSmall")
|
||||
CallSubDelayed(Tracker, "StartFLP")
|
||||
End If
|
||||
If tipos.IndexOf("au") <> -1 Then 'Si es una actualizacion de ubicacion
|
||||
au = 1
|
||||
End If
|
||||
If tipos.IndexOf("ping") <> -1 Then 'Si es un ping
|
||||
Log("Es un ping")
|
||||
Log("Mandamos pong")
|
||||
Dim params As Map = CreateMap("topic":Sprvsr,"title":"pong", "body":B4XPages.MainPage.usuario&" - Recibi mensaje "&Message.GetData.Get("title"), "t":"pong")
|
||||
SendMessage(params)
|
||||
End If
|
||||
If tipos.IndexOf("bgps") <> -1 Then 'Si es una instruccion de borrar archivo gps
|
||||
Log("Es una instruccion de borrar archivo gps")
|
||||
Log("Borramos archivo gps")
|
||||
borramosArchivoGPS
|
||||
End If
|
||||
If tipos.IndexOf("dr") <> -1 Then 'Si es una peticion de ruta gps
|
||||
Log("Es una peticion de Ruta GPS")
|
||||
Dim rutaGpsCmp As String = dameRuta
|
||||
Dim params As Map = CreateMap("topic":Sprvsr,"title":"ruta", "body":B4XPages.MainPage.usuario&" - Recibi mensaje "&Message.GetData.Get("title"), "t":"ruta", "r":rutaGpsCmp)
|
||||
SendMessage(params)
|
||||
End If
|
||||
If tipos.IndexOf("bgps2") <> -1 Then 'Si es una instruccion de borrar DB gps
|
||||
Log("Es una instruccion de borrar BD gps")
|
||||
Log("Borramos BD gps")
|
||||
borraGPSHist
|
||||
End If
|
||||
If tipos.IndexOf("pu") = -1 And tipos.IndexOf("au") = -1 And tipos.IndexOf("ping") = -1 And tipos.IndexOf("dr") = -1 Then
|
||||
Log("No es ping ni solicitud de ubicacion o ruta, entonces no hacemos nada")
|
||||
End If
|
||||
End If
|
||||
' Dim n As Notification
|
||||
' n.Initialize
|
||||
' n.Icon = "icon"
|
||||
' n.SetInfo("Guna", "Guna", Main)
|
||||
' n.Notify(1)
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
|
||||
End Sub
|
||||
|
||||
Sub SendMessage(params As Map)
|
||||
Dim topic As String= params.Get("topic")
|
||||
Dim title As String= params.Get("title")
|
||||
Dim body As String= params.Get("body")
|
||||
Dim tipo As String= params.Get("t")
|
||||
If params.ContainsKey("r") Then
|
||||
Log("Con ruta")
|
||||
Dim rutaGpsCmp As String= params.Get("r")
|
||||
Else
|
||||
Log("Sin ruta")
|
||||
Dim rutaGpsCmp As String = ""
|
||||
End If
|
||||
Dim Job As HttpJob
|
||||
Job.Initialize("fcm", Me)
|
||||
Dim m As Map = CreateMap("to": $"/topics/${topic}"$)
|
||||
Dim data As Map = CreateMap("title":title, "body":body, "d":B4XPages.MainPage.usuario, "t":tipo, "b":B4XPages.MainPage.batt, "mt":B4XPages.MainPage.montoActual, "r":rutaGpsCmp, "v":B4XPages.MainPage.v)
|
||||
m.Put("data", data)
|
||||
Dim jg As JSONGenerator
|
||||
jg.Initialize(m)
|
||||
Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
|
||||
Job.GetRequest.SetContentType("application/json;charset=UTF-8")
|
||||
Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
|
||||
Log(m) 'ignore
|
||||
End Sub
|
||||
|
||||
Sub mandamosLoc(coords As String)
|
||||
' Log("Iniciamos mandamosLoc "&coords)
|
||||
' Log("locRequest="&locRequest)
|
||||
If locRequest="Activa" Then 'Si hay solicitud de ubicacion, entonces la mandamos ...
|
||||
Dim params As Map = CreateMap("topic":Sprvsr,"title":"ubicacionRecibida", "body":coords, "t":"u")
|
||||
SendMessage(params)
|
||||
locRequest="Enviada"
|
||||
CallSubDelayed(Tracker,"CreateLocationRequest")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub guardaInfoEnArchivo(coords As String) 'ignore 'Escribimos coordenadas y fecha a un archivo de texto
|
||||
Log("Guardamos ubicacion en BD")
|
||||
Dim latlon() As String = Regex.Split(",", coords)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO RUTA_GPS(FECHA, LAT, LON) VALUES (?,?,?)", Array As Object (latlon(2),latlon(0),latlon(1)))
|
||||
End Sub
|
||||
|
||||
Sub borramosArchivoGPS
|
||||
Dim out As OutputStream = File.OpenOutput(File.DirRootExternal, "gps.txt", False)
|
||||
Dim s As String = ""
|
||||
Dim t() As Byte = s.GetBytes("UTF-8")
|
||||
out.WriteBytes(t, 0, t.Length)
|
||||
out.Close
|
||||
End Sub
|
||||
|
||||
Sub pe_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent)
|
||||
B4XPages.MainPage.batt=Level
|
||||
End Sub
|
||||
|
||||
Sub compress(str As String) As String
|
||||
' Compression
|
||||
Private su As StringUtils
|
||||
Dim compressed() As Byte = GZip.compress(str)
|
||||
Log($"CompressedBytesLength: ${compressed.Length}"$)
|
||||
Dim base64 As String = su.EncodeBase64(compressed)
|
||||
Log($"CompressedBytes converted to base64 Length: ${base64.Length}"$)
|
||||
Log($"CompressedBytes converted to base64: ${base64}"$)
|
||||
Return base64
|
||||
End Sub
|
||||
|
||||
Sub decompress(base64 As String) As String 'ignore
|
||||
' Decompression
|
||||
Private su As StringUtils
|
||||
Dim decompressedbytes() As Byte = su.DecodeBase64(base64)
|
||||
Log($"decompressedbytesLength: ${decompressedbytes.Length}"$)
|
||||
Dim bc As ByteConverter
|
||||
Dim uncompressed As String = bc.StringFromBytes(decompressedbytes,"UTF8")
|
||||
Log($"uncompressedLength: ${uncompressed.Length}"$) ' 6163 Bytes
|
||||
Log($"Decompressed String = ${uncompressed}"$)
|
||||
Return uncompressed
|
||||
End Sub
|
||||
|
||||
Sub dameRuta As String
|
||||
Log("dameRuta")
|
||||
Dim c As Cursor
|
||||
c = B4XPages.MainPage.skmt.ExecQuery("select LAT, LON from RUTA_GPS order by FECHA desc limit 390")
|
||||
c.Position = 0
|
||||
Dim ruta2 As String = ""
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
ruta2=ruta2&CRLF&c.GetString("LAT")&","&c.GetString("LON")
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
Return compress(ruta2)
|
||||
End Sub
|
||||
|
||||
Sub borraGPSHist
|
||||
c = B4XPages.MainPage.skmt.ExecQuery("delete FROM RUTA_GPS")
|
||||
End Sub
|
||||
224
B4A/INTMEX_LL.b4a
Normal file
347
B4A/MAPA_RUTAS.bas
Normal file
@@ -0,0 +1,347 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Activity
|
||||
Version=9.3
|
||||
@EndOfDesignText@
|
||||
#Region Activity Attributes
|
||||
#FullScreen: False
|
||||
#IncludeTitle: False
|
||||
#End Region
|
||||
|
||||
'Activity module
|
||||
Sub Process_Globals
|
||||
Dim GPS As GPS
|
||||
Dim rp As RuntimePermissions
|
||||
Dim ruta As String
|
||||
Dim skmt As SQL
|
||||
Dim c As Cursor
|
||||
Dim c2 As Cursor
|
||||
Dim c22 As Cursor
|
||||
Dim c3 As Cursor
|
||||
End Sub
|
||||
|
||||
Sub Globals
|
||||
Private gmap As GoogleMap
|
||||
Private MapFragment1 As MapFragment
|
||||
Dim Latitud As Double = 0
|
||||
Dim Longitud As Double = 0
|
||||
Dim Lat2 As Double = 0
|
||||
Dim Lon2 As Double = 0
|
||||
Dim p1, p2 As Location
|
||||
Dim Distance As Float
|
||||
Dim boton1 As Button
|
||||
Dim HUE_BLUE As Float
|
||||
Dim HUE_RED As Float
|
||||
Dim HUE_GREEN As Float
|
||||
Private B_AZUL As Button
|
||||
Private B_ROJO As Button
|
||||
Private B_VERDE As Button
|
||||
Private B_TODOS As Button
|
||||
Dim Tienda As String
|
||||
Dim LatitudRu As Double
|
||||
Dim LongitudRU As Double
|
||||
Dim LIST_AZUL As List
|
||||
Dim LIST_ROJO As List
|
||||
Dim LIST_VERDE As List
|
||||
Dim MARK_AZUL As Marker
|
||||
Dim MARK_ROJO As Marker
|
||||
Dim MARK_VERDE As Marker
|
||||
Dim MARK_CEDIS As Marker
|
||||
Dim rojo As String
|
||||
Dim azul As String
|
||||
Dim verde As String
|
||||
Dim todos As String
|
||||
Dim NumSerie As Int
|
||||
Dim OnInfoWindowClickListener1 As OnInfoWindowClickListener
|
||||
Dim GoogleMapEXTRA As GoogleMapsExtras
|
||||
Dim CODIGO As String
|
||||
Private SEMANA As String
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
Activity.LoadLayout("MAPA_RUTAS")
|
||||
' If File.ExternalWritable Then
|
||||
' ruta = File.DirDefaultExternal
|
||||
' Else
|
||||
ruta = File.DirInternal
|
||||
' End If
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
skmt.Initialize(ruta,"kmt.db", True)
|
||||
'GPS
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
If Result Then
|
||||
StartService(Tracker)
|
||||
Log("Start Tracker")
|
||||
If MapFragment1.IsGooglePlayServicesAvailable = False Then
|
||||
ToastMessageShow("Please install Google Play Services.", True)
|
||||
End If
|
||||
Else
|
||||
ToastMessageShow("No permission", True)
|
||||
B4XPages.ShowPage("Principal")
|
||||
End If
|
||||
' If(FirstTime) Then
|
||||
' Starter.GPS.Initialize("GPS")
|
||||
' End If
|
||||
|
||||
|
||||
'Boton velocidad'
|
||||
' boton1.Initialize(0)
|
||||
' boton1.Text = 0 &" "&"km/h"
|
||||
' boton1.TextColor = Colors.Red
|
||||
' boton1.TextSize = 15
|
||||
' Activity.AddView(boton1, 40%x, 5dip, 25%x, 40dip)
|
||||
'Fin Boton velocidad'
|
||||
'MARK_CEDIS.IsInitialized
|
||||
MARK_AZUL.IsInitialized
|
||||
MARK_ROJO.IsInitialized
|
||||
MARK_VERDE.IsInitialized
|
||||
LIST_AZUL.Initialize
|
||||
LIST_ROJO.Initialize
|
||||
LIST_VERDE.Initialize
|
||||
verde = 0
|
||||
azul = 0
|
||||
rojo = 0
|
||||
todos = 1
|
||||
c=skmt.ExecQuery2("select count(*) AS CUANTOS from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SEMANA"))
|
||||
c.Position =0
|
||||
SEMANA = c.GetString("CUANTOS")
|
||||
c.Close
|
||||
|
||||
If SEMANA > 0 Then
|
||||
c=skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("SEMANA"))
|
||||
c.Position =0
|
||||
SEMANA = c.GetString("CAT_VA_VALOR")
|
||||
c.Close
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
If Result Then
|
||||
If Starter.GPS.GPSEnabled = False Then
|
||||
ToastMessageShow("Debe Activar el GPS del Equipo.", True)
|
||||
StartActivity(Starter.GPS.LocationSettingsIntent)
|
||||
Else
|
||||
Starter.GPS.Start(0, 0)
|
||||
End If
|
||||
End If
|
||||
LIST_AZUL.Initialize
|
||||
LIST_ROJO.Initialize
|
||||
LIST_VERDE.Initialize
|
||||
verde = 0
|
||||
azul = 1
|
||||
rojo = 0
|
||||
todos = 0
|
||||
End Sub
|
||||
|
||||
Sub MapFragment1_Ready
|
||||
Log("ENTRANDO MapFragment1_Ready")
|
||||
gmap = MapFragment1.GetMap
|
||||
gmap.IsInitialized
|
||||
'todos= 1
|
||||
'permisos
|
||||
|
||||
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
gmap.MyLocationEnabled = Result
|
||||
|
||||
Dim JavaMapsObject As JavaObject
|
||||
JavaMapsObject = gmap.GetUiSettings
|
||||
JavaMapsObject.RunMethod("setMapToolbarEnabled", Array As Object(True))
|
||||
'''''''----------------------------MARKER AZUL - POR VISITAR
|
||||
If azul = 1 Or todos = 1 Then
|
||||
c.IsInitialized
|
||||
c=skmt.ExecQuery("select CAT_CL_CODIGO,CAT_CL_NOMBRE,CAT_CL_LAT,CAT_CL_LONG from kmt_info where gestion = 0 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0 and CAT_CL_LAT <> ' ' and CAT_CL_LONG <> ' ' ")
|
||||
' skmt.Initialize(ruta,"kmt.db", True)
|
||||
Log($"============== Resultados = ${c.RowCount}"$)
|
||||
If c.RowCount > 0 Then
|
||||
For i = 0 To c.RowCount - 1
|
||||
c.Position = i
|
||||
' Log($"|${c.GetString("CAT_CL_LONG")}|${c.GetString("CAT_CL_LAT")}|"$)
|
||||
' Log(i&"|"&c.GetString("CAT_CL_LAT")&"|")
|
||||
LatitudRu = 0
|
||||
If c.GetString("CAT_CL_LAT") <> "" Then LatitudRu = c.GetString("CAT_CL_LAT")
|
||||
LongitudRU = 0
|
||||
If c.GetString("CAT_CL_LONG") <> "" Then LongitudRU = c.GetString("CAT_CL_LONG")
|
||||
CODIGO=c.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c.GetString("CAT_CL_NOMBRE")
|
||||
MARK_AZUL = gmap.AddMarker2(LatitudRu, LongitudRU, CODIGO, gmap.HUE_BLUE)
|
||||
MARK_AZUL.Snippet = Tienda
|
||||
Next
|
||||
End If
|
||||
c .Close
|
||||
' Log("4")
|
||||
|
||||
If MARK_AZUL.IsInitialized Then LIST_AZUL.Add(MARK_AZUL)
|
||||
End If
|
||||
'''''''----------------------------MARKER VERDE - VENTA
|
||||
If verde = 1 Or todos = 1 Then
|
||||
c2.IsInitialized
|
||||
c2=skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE,CAT_CL_LONG,CAT_CL_LAT from kmt_info where gestion = 2 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0")
|
||||
Log($"============== Resultados = ${c2.RowCount}"$)
|
||||
For i = 0 To c2.RowCount -1
|
||||
c2.Position = i
|
||||
' Log($"|${c2.GetString("CAT_CL_LONG")}|${c2.GetString("CAT_CL_LAT")}|"$)
|
||||
If IsNumber(c2.GetString("CAT_CL_LONG")) Then
|
||||
LongitudRU = c2.GetString("CAT_CL_LONG")
|
||||
LatitudRu = c2.GetString("CAT_CL_LAT")
|
||||
CODIGO=c2.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c2.GetString("CAT_CL_NOMBRE")
|
||||
MARK_VERDE = gmap.AddMarker2(LatitudRu, LongitudRU, CODIGO,gmap.HUE_GREEN)
|
||||
MARK_VERDE.Snippet = Tienda
|
||||
End If
|
||||
Next
|
||||
Else
|
||||
If verde = 1 Or todos = 1 Then
|
||||
c2.IsInitialized
|
||||
c2=skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE,CAT_CL_LONG,CAT_CL_LAT from kmt_info where gestion = 2 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0")
|
||||
Log($"============== Resultados = ${c2.RowCount}"$)
|
||||
For i = 0 To c2.RowCount -1
|
||||
c2.Position = i
|
||||
' Log($"|${c2.GetString("CAT_CL_LONG")}|${c2.GetString("CAT_CL_LAT")}|"$)
|
||||
LongitudRU = c2.GetString("CAT_CL_LONG")
|
||||
LatitudRu = c2.GetString("CAT_CL_LAT")
|
||||
CODIGO=c2.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c2.GetString("CAT_CL_NOMBRE")
|
||||
MARK_VERDE = gmap.AddMarker2(LatitudRu, LongitudRU, CODIGO,gmap.HUE_GREEN)
|
||||
MARK_VERDE.Snippet = Tienda
|
||||
Next
|
||||
c2 .Close
|
||||
If MARK_VERDE.IsInitialized Then LIST_VERDE.Add(MARK_VERDE)
|
||||
End If
|
||||
End If
|
||||
' '''''''----------------------------MARKER ROJO - NO VENTA
|
||||
|
||||
If rojo = 1 Or todos = 1 Then
|
||||
c3.IsInitialized
|
||||
c3=skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE,CAT_CL_LONG,CAT_CL_LAT from kmt_info where gestion = 3 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0")
|
||||
Log($"============== Resultados = ${c3.RowCount}"$)
|
||||
For i = 0 To c3.RowCount -1
|
||||
c3.Position = i
|
||||
' Log($"|${c3.GetString("CAT_CL_LONG")}|${c3.GetString("CAT_CL_LAT")}|"$)
|
||||
LongitudRU = c3.GetDouble("CAT_CL_LONG")
|
||||
LatitudRu = c3.GetDouble("CAT_CL_LAT")
|
||||
CODIGO = c3.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c3.GetString("CAT_CL_NOMBRE")
|
||||
MARK_ROJO = gmap.AddMarker2(LatitudRu, LongitudRU, CODIGO, gmap.HUE_RED)
|
||||
MARK_ROJO.Snippet = Tienda
|
||||
Next
|
||||
Else
|
||||
If rojo = 1 Or todos = 1 Then
|
||||
c3.IsInitialized
|
||||
c3=skmt.ExecQuery("select CAT_CL_CODIGO, CAT_CL_NOMBRE,CAT_CL_LONG,CAT_CL_LAT from kmt_info where gestion = 3 and CAT_CL_LAT is not null and CAT_CL_LONG is not null and CAT_CL_LAT <> 0 and CAT_CL_LONG <> 0")
|
||||
Log($"============== Resultados = ${c3.RowCount}"$)
|
||||
For i = 0 To c3.RowCount -1
|
||||
c3.Position = i
|
||||
' Log($"|${c3.GetString("CAT_CL_LONG")}|${c3.GetString("CAT_CL_LAT")}|"$)
|
||||
LongitudRU = c3.GetDouble("CAT_CL_LONG")
|
||||
LatitudRu = c3.GetDouble("CAT_CL_LAT")
|
||||
CODIGO = c3.GetString("CAT_CL_CODIGO")
|
||||
Tienda= c3.GetString("CAT_CL_NOMBRE")
|
||||
MARK_ROJO = gmap.AddMarker2(LatitudRu, LongitudRU, CODIGO, gmap.HUE_RED)
|
||||
MARK_ROJO.Snippet = Tienda
|
||||
Next
|
||||
If MARK_ROJO.IsInitialized Then LIST_ROJO.Add(MARK_ROJO)
|
||||
c3.Close
|
||||
End If
|
||||
End If
|
||||
''------------------------------
|
||||
|
||||
' MARK_CEDIS = gmap.AddMarker3("19.3961802","-99.0784293","CEDIS", LoadBitmap(File.DirAssets, "marker-azul-0.png"))
|
||||
' If MARK_VERDE.Visible Or MARK_ROJO.Visible Then
|
||||
' MARK_CEDIS.Remove
|
||||
' End If
|
||||
Dim aa As CameraPosition
|
||||
aa.Initialize(LatitudRu,LongitudRU,15)''' RECOMENDABLE CAMBIAR A 10 PARA QUE SE VEAN MAS MARCADORES
|
||||
gmap.AnimateCamera(aa)
|
||||
|
||||
'''''---------------------- ESTO ES PARA LOS CLICK EN LAS VENTANAS D INFORMACION-----------
|
||||
Dim OnInfoWindowClickListener1 As OnInfoWindowClickListener
|
||||
OnInfoWindowClickListener1.Initialize("OnInfoWindowClickListener1")
|
||||
GoogleMapEXTRA.SetOnInfoWindowClickListener(gmap, OnInfoWindowClickListener1)
|
||||
|
||||
End Sub
|
||||
'
|
||||
''''-------------------------- PRUEBA CON MARKER _CLICK
|
||||
|
||||
|
||||
Sub OnInfoWindowClickListener1_click(Marker1 As Marker)
|
||||
skmt.ExecNonQuery("delete from CUENTAA")
|
||||
skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?) ", Array As Object(Marker1.Title))
|
||||
Activity.Finish
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
|
||||
|
||||
Sub GPS_LocationChanged (Parametro As Location)
|
||||
MARK_CEDIS.IsInitialized
|
||||
' Dim sp As Int
|
||||
' sp = Ceil(Parametro.Speed * 3.6)
|
||||
' boton1.Text = sp &" "&"km/h"
|
||||
' Latitud = Parametro.Latitude
|
||||
' Longitud = Parametro.Longitude
|
||||
' p2.Initialize2(Latitud,Longitud)
|
||||
' p1.Initialize2(Lat2, Lon2)
|
||||
' Distance = p1.DistanceTo(p2)
|
||||
' If Latitud <> 0 And Longitud <> 0 Then
|
||||
' If Distance > 10 Then
|
||||
' Lat2 = Latitud
|
||||
' Lon2 = Longitud
|
||||
' Dim cp As CameraPosition
|
||||
' cp.Initialize2(Parametro.Latitude, Parametro.Longitude, gmap.CameraPosition.Zoom, Parametro.Bearing, 0)
|
||||
' gmap.AnimateCamera(cp)
|
||||
' End If
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
GPS.Stop
|
||||
End Sub
|
||||
|
||||
|
||||
Sub B_TODOS_Click
|
||||
todos =1
|
||||
verde = 0
|
||||
azul = 0
|
||||
rojo = 0
|
||||
|
||||
MapFragment1_Ready
|
||||
|
||||
End Sub
|
||||
|
||||
Sub B_VERDE_Click
|
||||
verde = 1
|
||||
azul = 0
|
||||
rojo = 0
|
||||
todos = 0
|
||||
gmap.Clear
|
||||
MapFragment1_Ready
|
||||
|
||||
End Sub
|
||||
|
||||
Sub B_ROJO_Click
|
||||
rojo = 1
|
||||
verde = 0
|
||||
azul = 0
|
||||
todos = 0
|
||||
gmap.Clear
|
||||
|
||||
MapFragment1_Ready
|
||||
|
||||
End Sub
|
||||
|
||||
Sub B_AZUL_Click
|
||||
azul = 1
|
||||
verde = 0
|
||||
rojo = 0
|
||||
todos = 0
|
||||
gmap.Clear
|
||||
|
||||
MapFragment1_Ready
|
||||
|
||||
End Sub
|
||||
116
B4A/Starter.bas
Normal file
@@ -0,0 +1,116 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=9.85
|
||||
@EndOfDesignText@
|
||||
#Region Service Attributes
|
||||
#StartAtBoot: False
|
||||
#ExcludeFromLibrary: True
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
'These global variables will be declared once when the application starts.
|
||||
'These variables can be accessed from all modules.
|
||||
Public gps As GPS
|
||||
Dim ph As Phone
|
||||
Public rp As RuntimePermissions
|
||||
Public FLP As FusedLocationProvider
|
||||
' Private flpStarted As Boolean
|
||||
Dim reqManager As DBRequestManager
|
||||
Dim server As String = "http://187.189.244.154:1782"
|
||||
' Dim server As String = "http://187.189.244.154:1783"
|
||||
' Dim server As String = "http://10.0.0.205:1783"
|
||||
' Dim server As String = "http://11.0.0.15:1782"
|
||||
Dim Timer1 As Timer
|
||||
Dim Interval As Int = 10
|
||||
Dim ruta As String = File.DirInternal
|
||||
'Para los Logs
|
||||
Private logs As StringBuilder
|
||||
Private logcat As LogCat
|
||||
Dim muestraProgreso = 0
|
||||
Dim logger As Boolean = False
|
||||
Dim marcaCel As String = ph.manufacturer
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
'This is the program entry point.
|
||||
'This is a good place to load resources that are not specific to a single activity.
|
||||
gps.Initialize("GPS")
|
||||
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics") 'Para Push FirebaseMessaging
|
||||
Timer1.Initialize("Timer1", Interval * 1000)
|
||||
Timer1.Enabled = True
|
||||
' 'Para los Logs
|
||||
#if RELEASE
|
||||
logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
|
||||
#end if
|
||||
logs.Initialize
|
||||
' CallSubDelayed(FirebaseMessaging, "SubscribeToTopics") 'Para Push FirebaseMessaging
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
||||
Subs.revisaBD
|
||||
' Log(marcaCel)
|
||||
reqManager.Initialize(Me, server)
|
||||
End Sub
|
||||
|
||||
Private Sub Timer1_Tick
|
||||
' Log("Next run " & DateTime.Time(DateTime.Now + Interval * 1000))
|
||||
ENVIA_ULTIMA_GPS
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
' CallSub2(Main, "GPS_LocationChanged", Location1)
|
||||
End Sub
|
||||
|
||||
Sub Service_TaskRemoved
|
||||
'This event will be raised when the user removes the app from the recent apps list.
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
|
||||
End Sub
|
||||
|
||||
Sub ENVIA_ULTIMA_GPS
|
||||
Dim logger As Boolean = False
|
||||
If logger Then LogColor("Iniciamos ENVIA_ULTIMA_GPS", Colors.Magenta)
|
||||
Dim skmt As SQL
|
||||
Dim cmd As DBCommand
|
||||
skmt.Initialize(ruta,"kmt.db", False)
|
||||
' cmd.Initialize
|
||||
' cmd.Name = "select_fechat"
|
||||
' B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "fechat")
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "UPDATE_INTMEX_ACTUAL2_GPS"
|
||||
If B4XPages.MainPage.lat_gps.Length < 15 Then B4XPages.MainPage.lat_gps = B4XPages.MainPage.lat_gps&"0"
|
||||
cmd.Parameters = Array As Object(B4XPages.MainPage.montoActual, B4XPages.MainPage.clientestotal, B4XPages.MainPage.clientesventa,B4XPages.MainPage.clientesvisitados,B4XPages.MainPage.lat_gps,B4XPages.MainPage.lon_gps,B4XPages.MainPage.batt,0, 0, 0,B4XPages.MainPage.ALMACEN,B4XPages.MainPage.rutapreventa)
|
||||
If logger Then Log($"montoActual: ${B4XPages.MainPage.montoActual}, cTotal: ${B4XPages.MainPage.clientestotal}, cVenta: ${B4XPages.MainPage.clientesventa}, cVisitados: ${B4XPages.MainPage.clientesvisitados}, ${B4XPages.MainPage.lat_gps}, ${B4XPages.MainPage.lon_gps}, Batt: ${B4XPages.MainPage.batt}, 0, 0, 0, Almacen: ${B4XPages.MainPage.ALMACEN}, Ruta: ${B4XPages.MainPage.rutapreventa}"$)
|
||||
reqManager.ExecuteCommand(cmd, "inst_visitas")
|
||||
skmt.ExecNonQuery2("Update cat_variables set CAT_VA_VALOR = ? WHERE CAT_VA_DESCRIPCION = ?" , Array As String(DateTime.Time(DateTime.Now),"HoraIngreso"))
|
||||
'Reiniciamos el timer para cuando llamamos el Sub desde "seleccion"
|
||||
Timer1.Enabled = False
|
||||
Timer1.Interval = Interval * 1000
|
||||
Timer1.Enabled = True
|
||||
End Sub
|
||||
|
||||
'Para los Logs
|
||||
Private Sub logcat_LogCatData (Buffer() As Byte, Length As Int)
|
||||
logs.Append(BytesToString(Buffer, 0, Length, "utf8"))
|
||||
If logs.Length > 4000 Then
|
||||
logs.Remove(0, logs.Length - 2000) 'Obtenemos log de 2000 ~ 4000 chars
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Return true to allow the OS default exceptions handler to handle the uncaught exception. 'Para los Logs
|
||||
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
|
||||
'wait for 500ms to allow the logs to be updated.
|
||||
Dim jo As JavaObject
|
||||
Dim l As Long = 500: jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l)) 'Sleep 500ms
|
||||
logcat.LogCatStop
|
||||
logs.Append(StackTrace)
|
||||
Subs.revisaBD
|
||||
Subs.errorLog.ExecNonQuery2("INSERT INTO errores(fecha, error) VALUES (?,?)", Array As Object (Subs.fechaKMT(DateTime.now), logs))
|
||||
Return True
|
||||
End Sub
|
||||
1320
B4A/Subs.bas
Normal file
297
B4A/Tracker.bas
Normal file
@@ -0,0 +1,297 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=10.2
|
||||
@EndOfDesignText@
|
||||
#Region Service Attributes
|
||||
#StartAtBoot: True
|
||||
#End Region
|
||||
'******************************************************************************
|
||||
'No olvidar agregar esta linea al editor de manifiesto:
|
||||
' SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
|
||||
'
|
||||
'En Starter agregar estas lineas en Process_Globals
|
||||
' Public rp As RuntimePermissions
|
||||
' Public FLP As FusedLocationProvider
|
||||
' Private flpStarted As Boolean
|
||||
'
|
||||
'En Main agregar estas lineas a Activity_Resume
|
||||
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
' If Result Then
|
||||
' StartService(Tracker)
|
||||
' Log("Start Tracker")
|
||||
' Else
|
||||
' ToastMessageShow("No permission", True)
|
||||
' End If
|
||||
'
|
||||
'Se necesitan las librerias FusedLocationProvider, GPS, Phone y RunTimePermissions
|
||||
'
|
||||
'Y en Main agregar estas dos lineas:
|
||||
'#AdditionalJar: com.android.support:support-v4
|
||||
'#AdditionalJar: com.google.android.gms:play-services-location
|
||||
|
||||
Sub Process_Globals
|
||||
Private nid As Int = 51042
|
||||
Private Tracking As Boolean
|
||||
Private lock As PhoneWakeState
|
||||
'Para FusedLocationProvider (2 lineas)
|
||||
Public FLP As FusedLocationProvider
|
||||
Dim actualLR As LocationRequest
|
||||
Private flpStarted As Boolean
|
||||
' Dim locRequest As String
|
||||
Dim UUGCoords As Location 'Ultima Ubicacion Guardada
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
|
||||
'Para FusedLocationProvider (2 lineas)
|
||||
FLP.Initialize("flp")
|
||||
FLP.Connect
|
||||
lock.PartialLock
|
||||
StartFLP
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuccess
|
||||
' Log("Connected to location provider")
|
||||
'FLP.GetLastKnownLocation
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionFailed(ConnectionResult1 As Int)
|
||||
Log("Failed to connect to location provider")
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
'Para FusedLocationProvider (1 linea)
|
||||
Service.StopAutomaticForeground
|
||||
Service.StartForeground(nid, CreateNotification("..."))
|
||||
Track
|
||||
StartServiceAt(Me, DateTime.Now + 5 * DateTime.TicksPerMinute, True)
|
||||
FLP.GetLastKnownLocation.Initialize
|
||||
End Sub
|
||||
|
||||
Public Sub Track
|
||||
' Log("Inicia Track - Tracking : "&Tracking)
|
||||
If Not(FLP.IsInitialized) Then FLP.Initialize("flp")
|
||||
If Not(FLP.IsConnected) Then FLP.Connect
|
||||
If Tracking And actualLR.IsInitialized Then
|
||||
' Log(actualLR.GetSmallestDisplacement)
|
||||
Return 'Si ya estamos "rastreando" no hacemos nada (return)
|
||||
End If
|
||||
If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
|
||||
Log("No permission")
|
||||
Return
|
||||
End If
|
||||
StartFLP 'Iniciamos FusedLocationProvider
|
||||
Tracking = True
|
||||
End Sub
|
||||
|
||||
Public Sub StartFLP
|
||||
' Log("StartFLP - flpStarted="&flpStarted)
|
||||
Do While FLP.IsConnected = False
|
||||
Sleep(500)
|
||||
' Log("sleeping")
|
||||
Loop
|
||||
' If flpStarted = False Then
|
||||
' Log("RequestLocationUpdates")
|
||||
FLP.RequestLocationUpdates(CreateLocationRequest) 'Buscamos ubicacion
|
||||
' Log("Buscamos ubicacion")
|
||||
' Log(actualLR.GetSmallestDisplacement)
|
||||
flpStarted = True
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Public Sub StartFLPSmall
|
||||
' Log("StartFLPSmall - flpStarted="&flpStarted)
|
||||
Do While FLP.IsConnected = False
|
||||
Sleep(500)
|
||||
Log("sleeping")
|
||||
Loop
|
||||
dameUltimaUbicacionConocida 'Regresamos ultima ubicacion conocida
|
||||
FLP.RequestLocationUpdates(CreateLocationRequestSmallD) 'Buscamos ubicacion 2 peticiones
|
||||
' Log("Buscamos ubicacion Small displacement")
|
||||
' Log("GPSSmallestDisplacement = " & actualLR.GetSmallestDisplacement)
|
||||
End Sub
|
||||
|
||||
Private Sub CreateLocationRequest As LocationRequest
|
||||
' Log("CreateLocationRequest")
|
||||
Dim lr As LocationRequest
|
||||
lr.Initialize
|
||||
lr.SetInterval(10000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
lr.SetFastestInterval(lr.GetInterval / 2) 'Intervalo minimo para actualizaciones de ubicacion
|
||||
lr.SetSmallestDisplacement(50) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||
lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
|
||||
actualLR=lr
|
||||
Return lr
|
||||
End Sub
|
||||
|
||||
Private Sub CreateLocationRequestSmallD As LocationRequest
|
||||
' Log("Iniciamos CreateLocationRequestSmallD")
|
||||
Dim lr As LocationRequest
|
||||
lr.Initialize
|
||||
lr.SetInterval(2000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
lr.SetFastestInterval(lr.GetInterval / 2) 'Intervalo minimo para actualizaciones de ubicacion
|
||||
lr.setNumUpdates(2) 'Solicitamos solo 2 actualizaciones con estos parametros
|
||||
lr.SetSmallestDisplacement(1) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||
lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
|
||||
actualLR=lr
|
||||
Return lr
|
||||
End Sub
|
||||
|
||||
Sub dameUltimaUbicacionConocida
|
||||
If FLP.GetLastKnownLocation.IsInitialized Then 'Mandamos ultima ubicacion guardada
|
||||
' If Main.logger Then Log("Mandamos UUC : "&formatoFecha(FLP.GetLastKnownLocation.Time))
|
||||
If Starter.Logger Then LogColor($"Mandamos UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|Acc:$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|Spd:$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
|
||||
Dim coords As String = FLP.GetLastKnownLocation.Latitude&","&FLP.GetLastKnownLocation.Longitude&","&formatoFecha(FLP.GetLastKnownLocation.Time)
|
||||
' CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
|
||||
' Subs.mandamosLoc(coords)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub StopFLP
|
||||
'Log("StopFLP")
|
||||
If flpStarted Then
|
||||
FLP.RemoveLocationUpdates 'Eliminamos todas las solicitudes de ubicacion
|
||||
flpStarted = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub flp_LocationChanged (Location1 As Location)
|
||||
' ToastMessageShow("Loc changed", False)
|
||||
' Log($"Loc changed:${Location1.Longitude},${Location1.Latitude}"$)
|
||||
B4XPages.MainPage.lat_gps = Location1.Latitude
|
||||
B4XPages.MainPage.lon_gps = Location1.Longitude
|
||||
UUGCoords = Location1
|
||||
' Log("SmallestDisplacement="&actualLR.GetSmallestDisplacement)
|
||||
' If DateTime.Now > LastUpdateTime + 10 * DateTime.TicksPerSecond Then
|
||||
' Dim n As Notification = CreateNotification($"$2.5{Location1.Latitude} / $2.5{Location1.Longitude}"$)
|
||||
' n.Notify(nid)
|
||||
' LastUpdateTime = DateTime.Now
|
||||
' End If
|
||||
'/////// para la ultima localización FL
|
||||
Dim sDate,sTime As String
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
If Not(B4XPages.MainPage.skmt.IsInitialized) Then B4XPages.MainPage.skmt.Initialize(Starter.ruta,"kmt.db", True)
|
||||
Try
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
|
||||
Catch
|
||||
LogColor(LastException, Colors.Red)
|
||||
End Try
|
||||
'///////
|
||||
Dim coords As String = Location1.Latitude&","&Location1.Longitude&","&formatoFecha(Location1.Time)
|
||||
' Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude&"|"&B4XPages.MainPage.usuario&"|")
|
||||
' Log("Mandamos Ubicacion")
|
||||
' Log(FirebaseMessaging.locRequest)
|
||||
' Solo mandamos la ubicacion si la precision es menor a XX mts
|
||||
If Location1.Accuracy < 100 Then
|
||||
' CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
|
||||
End If
|
||||
|
||||
CallSub2(Starter, "GPS_LocationChanged", Location1)
|
||||
' CallSub2(gestion, "GPS_LocationChanged", Location1)
|
||||
' CallSub2(B4XPages.GetPage("Cliente"), "GPS_LocationChanged", Location1)
|
||||
' CallSub2(nuevocliente, "GPS_LocationChanged", Location1)
|
||||
End Sub
|
||||
|
||||
Sub CreateNotification (Body As String) As Notification
|
||||
Dim notification As Notification
|
||||
notification.Initialize2(notification.IMPORTANCE_LOW)
|
||||
notification.Icon = "icon"
|
||||
notification.SetInfo("INTMEX", Body, Main)
|
||||
Return notification
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
If Tracking Then
|
||||
StopFLP
|
||||
End If
|
||||
Tracking = False
|
||||
lock.ReleasePartialLock
|
||||
End Sub
|
||||
|
||||
Sub formatoFecha(fecha As String) As String 'Convierte una fecha al formato yyMMddHHmmss
|
||||
' Log(fecha)
|
||||
Dim OrigFormat As String = DateTime.DateFormat 'save orig date format
|
||||
DateTime.DateFormat="yyMMddHHmmss"
|
||||
Dim lastUpdate As String=DateTime.Date(fecha)
|
||||
DateTime.DateFormat=OrigFormat 'return to orig date format
|
||||
' Log(lastUpdate)
|
||||
Return lastUpdate
|
||||
End Sub
|
||||
|
||||
'Revisamos que el FLP (FusedLocationProvider) este inicializado y activo
|
||||
Sub revisaFLP 'ignore
|
||||
LogColor("**** **** Revisamos FLP **** ****", Colors.RGB(78,0,227))
|
||||
Private todoBienFLP As Boolean = True
|
||||
Try
|
||||
If Not(FLP.IsInitialized) Then
|
||||
Subs.log2DB("revisaFLP: No esta inicializado ... 'Reinicializando FLP'")
|
||||
FLP.Initialize("flp")
|
||||
todoBienFLP = False
|
||||
End If
|
||||
Catch
|
||||
LogColor("If Not(Tracker.FLP.IsInitialized) --> "&LastException, Colors.Red)
|
||||
End Try
|
||||
Try
|
||||
If FLP.IsInitialized Then
|
||||
Try
|
||||
If Not(FLP.IsConnected) Then
|
||||
Subs.log2DB("revisaFLP: No esta conectado ... 'Reconectando FLP'")
|
||||
' Tracker.FLP.Connect
|
||||
StartFLP
|
||||
todoBienFLP = False
|
||||
End If
|
||||
Catch
|
||||
LogColor("If Not(Tracker.FLP.IsConnected) --> "&LastException, Colors.Red)
|
||||
End Try
|
||||
Try
|
||||
If FLP.IsConnected And _
|
||||
FLP.GetLastKnownLocation.IsInitialized And _
|
||||
FLP.GetLastKnownLocation.DistanceTo(UUGCoords) > 500 Then
|
||||
Subs.log2DB("revisaFLP: 'No se esta actualizando, lo reiniciamos ...'")
|
||||
StartService(Me)
|
||||
todoBienFLP = False
|
||||
End If
|
||||
Catch
|
||||
LogColor("If FLP.IsConnectctd and FLP.getLKL.IsInitialized --> "&LastException, Colors.Red)
|
||||
End Try
|
||||
End If
|
||||
If todoBienFLP Then LogColor(" +++ +++ Sin errores en FLP", Colors.Green)
|
||||
Catch
|
||||
LogColor("If Tracker.FLP.IsInitialized --> "&LastException, Colors.Red)
|
||||
End Try
|
||||
' revisar hora de lastKnownlocation y si es mayor de 10 minutos llamar StartFLP
|
||||
End Sub
|
||||
|
||||
'Compara la UUG (Ultima Ubicacion Guardada) con FLP.LastKnowLocation y si
|
||||
'cumple con los requisitos de distancia y precision la guardamos en la BD.
|
||||
Sub revisaUUG 'ignore
|
||||
Try
|
||||
' revisaFLP
|
||||
If FLP.IsInitialized And FLP.IsConnected Then
|
||||
Try
|
||||
If FLP.GetLastKnownLocation.IsInitialized Then
|
||||
' Dim x As Location = FLP.GetLastKnownLocation
|
||||
Dim daa As Int = UUGCoords.DistanceTo(FLP.GetLastKnownLocation) 'Distancia de la UUG a la actual de Tracker.FLP.GetLastKnownLocation
|
||||
If Starter.Logger Then LogColor($"**** UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
|
||||
If daa > 40 And FLP.GetLastKnownLocation.Accuracy < 35 Then 'Si la distancia de la ubicacion anterior es mayor de XX y la precision es menor de XX, la guardamos ...
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO RUTA_GPS(fecha, lat, lon) VALUES (?,?,?)", Array As Object (Subs.fechaKMT(FLP.GetLastKnownLocation.Time),FLP.GetLastKnownLocation.Latitude,FLP.GetLastKnownLocation.Longitude))
|
||||
If Starter.Logger Then Log("++++ Distancia a anterior="&daa&"|"&"Precision="&FLP.GetLastKnownLocation.Accuracy)
|
||||
End If
|
||||
UUGCoords = FLP.GetLastKnownLocation
|
||||
End If
|
||||
Catch
|
||||
LogColor("FLP.GetLastKnownLocation.IsInitialized --> "&LastException, Colors.Red)
|
||||
End Try
|
||||
Else
|
||||
Log("StartFLP")
|
||||
StartFLP
|
||||
End If
|
||||
Catch
|
||||
LogColor("If FLP.IsInitialized --> "&LastException, Colors.Red)
|
||||
End Try
|
||||
End Sub
|
||||
286
B4A/appUpdater.bas
Normal file
@@ -0,0 +1,286 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=10.2
|
||||
@EndOfDesignText@
|
||||
#Region Service Attributes
|
||||
#StartAtBoot: False
|
||||
#End Region
|
||||
|
||||
'////////////////////////////////////////////////////////////////////////////////////////////
|
||||
'//// Servicio para revisar si hay actualizacion de aplicación, usa la
|
||||
'//// actividad "updateAvailable" para mostrar mensajes.
|
||||
'////
|
||||
'//// https://www.b4x.com/android/forum/threads/update-your-app-without-using-the-gplaystore.109720/#content
|
||||
'////
|
||||
'//// En la actividad del la cual se va a llamar la revision de actualizacion
|
||||
'//// hay que agregar los siguientes Subs:
|
||||
'////
|
||||
' Sub boton_que_llama_revision_Click
|
||||
' StartService(appUpdater)
|
||||
' End Sub
|
||||
'
|
||||
' appUpdater - Mostramos el anuncio de que se esta descargando el nuevo apk
|
||||
' Sub muestraProgreso
|
||||
' ProgressDialogShow("Descargando actualización")
|
||||
' End Sub
|
||||
'
|
||||
' appUpdater - Ocultamos el anuncio de que se esta descargando el nuevo apk
|
||||
' Sub ocultaProgreso
|
||||
' ProgressDialogHide
|
||||
' End Sub
|
||||
'////
|
||||
'//// Requiere las siguientes librerias:
|
||||
'////
|
||||
'//// * JavaObject
|
||||
'//// * OkHttpUtils2
|
||||
'//// * Phone
|
||||
'//// * RuntimePermissions
|
||||
'//// * appUpdating
|
||||
'////
|
||||
'//// Requiere las siguientes lineas en el manifiesto:
|
||||
'////
|
||||
' AddManifestText(<uses-permission
|
||||
' android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
' android:maxSdkVersion="18" />
|
||||
' )
|
||||
' AddApplicationText(
|
||||
' <provider
|
||||
' android:name="android.support.v4.content.FileProvider"
|
||||
' android:authorities="$PACKAGE$.provider"
|
||||
' android:exported="false"
|
||||
' android:grantUriPermissions="true">
|
||||
' <meta-data
|
||||
' android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
' android:resource="@xml/provider_paths"/>
|
||||
' </provider>
|
||||
' )
|
||||
' CreateResource(xml, provider_paths,
|
||||
' <paths>
|
||||
' <external-files-path name="name" path="" />
|
||||
' <files-path name="name" path="" />
|
||||
' <files-path name="name" path="shared" />
|
||||
' </paths>
|
||||
' )
|
||||
' AddPermission(android.permission.REQUEST_INSTALL_PACKAGES)
|
||||
' AddPermission(android.permission.INTERNET)
|
||||
' AddPermission(android.permission.INSTALL_PACKAGES)
|
||||
' AddPermission(android.permission.READ_EXTERNAL_STORAGE)
|
||||
' AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
|
||||
' AddPermission(android.permission.READ_PHONE_STATE)
|
||||
' AddPermission(android.permission.WAKE_LOCK)
|
||||
'////
|
||||
'////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Sub Process_Globals
|
||||
'These global variables will be declared once when the application starts.
|
||||
'These variables can be accessed from all modules.
|
||||
|
||||
'Aqui va la liga al archivo .ver en el servidor que contiene la información de la aplicacion
|
||||
Public lnk As String = "https://keymon.lat/movil/Intmex/intmex.ver"
|
||||
' Public lnk As String = "https://10.0.0.205/Movil/Guna/cedex.ver"
|
||||
'##########################################
|
||||
'## La ruta en el servidor es: ##
|
||||
'## \\10.0.0.205\e$\Cargas\Movil\Guna ##
|
||||
'##########################################
|
||||
'/// En el servidor se necesita un archivo de texto (.ver) que tenga los siguientes
|
||||
'/// datos separados por un tabulador
|
||||
'/// contents of ver file, each field is seperated by a tab
|
||||
' Field 0 = 2.226.19.09.19.01a <-- Esta es la version de la aplicación disponible
|
||||
' Field 1 = A new version of the MyAPP is available, Download and update now ? <-- Mensaje para cuando hay actualización
|
||||
' Field 2 = MyApp is up to date <--- Mensaje para cuando no hay actualización
|
||||
' Field 3 = http://www.mydomain.com/Public/myapp.apk <--- Liga al apk de la actualización
|
||||
|
||||
Public nNewApp As Notification
|
||||
Public nNewAppnID As Int = 16
|
||||
'Para Download
|
||||
Dim nativeMe As JavaObject
|
||||
Dim n2 As Notification
|
||||
Dim n2ID As Int = 16
|
||||
'Para fileProvider
|
||||
Public SharedFolder As String
|
||||
Public UseFileProvider As Boolean
|
||||
Private rp As RuntimePermissions
|
||||
|
||||
Type mNewVersion(update As Boolean, nonewAPP As Boolean, notifyUser As Boolean, _
|
||||
version As String, newMsg As String, okMsg As String, appLink As String)
|
||||
Public newApp As mNewVersion
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
Log("appUpdater(), Service_Create")
|
||||
newApp.Initialize
|
||||
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
|
||||
n2.Initialize
|
||||
nativeMe.InitializeContext
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
Log("appUpdater(), Service_Start")
|
||||
' CallSubDelayed2(Main, "muestraProgreso", "Buscando actualización")
|
||||
B4XPages.MainPage.muestraProgreso("Buscando actualización")
|
||||
Log("Buscando actualización")
|
||||
fileProvider_init
|
||||
Wait For (Download(Me, lnk)) JobDone (j As HttpJob)
|
||||
If j.Success Then
|
||||
Try
|
||||
Dim app() As String = Regex.Split(Chr(9),j.GetString)
|
||||
' // Set the data
|
||||
newApp.appLink = app(3) 'Liga a nueva app
|
||||
newApp.newMsg = app(1) 'Texto de que hay actualizacion
|
||||
newApp.okMsg = app(2) 'Texto de app al corriente
|
||||
newApp.version = app(0) 'Version actual
|
||||
|
||||
Log($"Application.VersionName=${Application.VersionName}, newApp=${newApp}"$)
|
||||
|
||||
' // App version check
|
||||
If newApp.version = Application.VersionName Then
|
||||
newApp.update = False
|
||||
Log("No new app")
|
||||
B4XPages.ShowPage("updateAvailable")
|
||||
'Se puede mandar tambien una notificacion avisando que NO hay actualizaciones
|
||||
CreateNotification2("Aplicacion al corriente","No hay actualizaciones disponibles","ic_file_download_white_24dp",Main,True,True,nNewApp,nNewAppnID)
|
||||
End If
|
||||
If newApp.version <> Application.VersionName Then
|
||||
newApp.update = True
|
||||
Log("New app true")
|
||||
B4XPages.ShowPage("updateAvailable")
|
||||
'Se puede mandar tambien una notificacion avisando que hay actualizacion disponible
|
||||
' CreateNotification2("Nueva aplicación disponible","Haga clic para descargar.","ic_file_download_white_24dp",C_UpdateAvailable,True,True,nNewApp,nNewAppnID)
|
||||
End If
|
||||
Catch
|
||||
Log("appUpdater(), Job Failed, error " & LastException.Message)
|
||||
End Try
|
||||
Else
|
||||
Log("appUpdater(), Job Failed " & lnk)
|
||||
End If
|
||||
j.Release
|
||||
' StopService(Me)
|
||||
End Sub
|
||||
|
||||
Sub download_Start (StartingIntent As Intent)
|
||||
download_newApk
|
||||
End Sub
|
||||
|
||||
Sub download_newApk
|
||||
' CreateNotification("Descargando actualización", "Descargando apk", "ic_file_download_white_24dp", Main, False, True)
|
||||
' CallSubDelayed2(Main, "muestraProgreso", "Descargando actualización")
|
||||
Log("Descargando actualización")
|
||||
B4XPages.ShowPage("login")
|
||||
Starter.muestraProgreso = 1
|
||||
Dim job_newAPP As HttpJob
|
||||
job_newAPP.Initialize("job_newAPP",Me)
|
||||
job_newAPP.Download(newApp.appLink)
|
||||
Wait for (job_newAPP) JobDone (job_newAPP As HttpJob)
|
||||
If job_newAPP.Success = True Then
|
||||
' // Delete existing file
|
||||
If File.Exists(SharedFolder,"newapp.apk") Then
|
||||
File.Delete(SharedFolder,"newapp.apk")
|
||||
End If
|
||||
' // Save new file
|
||||
Dim outNewAPK As OutputStream = File.OpenOutput(SharedFolder,"newapp.apk", False)
|
||||
File.Copy2(job_newAPP.GetInputStream, outNewAPK)
|
||||
outNewAPK.Close
|
||||
If Starter.Logger Then Log("APK dir: "&SharedFolder)
|
||||
End If
|
||||
job_newAPP.Release
|
||||
' // Install the app
|
||||
Dim in As Intent
|
||||
in.Initialize(in.ACTION_VIEW,"" )
|
||||
SetFileUriAsIntentData(in, "newapp.apk")
|
||||
' // Type must be set after calling SetFileUriAsIntentData
|
||||
in.SetType("application/vnd.android.package-archive")
|
||||
StartActivity(in)
|
||||
n2.Cancel(nNewAppnID)
|
||||
B4XPages.MainPage.ocultaProgreso
|
||||
' Service.StopForeground(nNewAppnID)
|
||||
StopService(Me)
|
||||
' CallSubDelayed(Main,"ocultaProgreso")
|
||||
End Sub
|
||||
|
||||
Sub download_Destroy
|
||||
n2.Cancel(n2ID)
|
||||
Service.StopForeground(n2ID)
|
||||
End Sub
|
||||
|
||||
Sub Download (Callback As Object, link As String) As HttpJob
|
||||
Dim j As HttpJob
|
||||
j.Initialize("", Callback)
|
||||
j.Download(link)
|
||||
Return j
|
||||
End Sub
|
||||
|
||||
Private Sub CreateNotification2(Title As String, Content As String, _ 'ignore
|
||||
Icon As String, TargetActivity As Object, Sound As Boolean, _
|
||||
Vibrate As Boolean, pN As Notification,pNID As Int) As Notification
|
||||
pN.Initialize2(pN.IMPORTANCE_HIGH)
|
||||
' pN.Number = pNID
|
||||
' pN.Light = False
|
||||
pN.Vibrate = Vibrate
|
||||
pN.Sound = Sound
|
||||
' pN.OnGoingEvent = False
|
||||
pN.Icon = Icon
|
||||
pN.AutoCancel = True
|
||||
pN.SetInfo(Title, Content, TargetActivity)
|
||||
pN.Notify(pNID)
|
||||
Return pN
|
||||
End Sub
|
||||
|
||||
Private Sub CreateNotification(Title As String, Content As String, Icon As String, TargetActivity As Object, Sound As Boolean, Vibrate As Boolean) As Notification 'ignore
|
||||
n2.Initialize
|
||||
n2.Light = False
|
||||
n2.Vibrate = Vibrate
|
||||
n2.Sound = Sound
|
||||
n2.OnGoingEvent = True
|
||||
n2.Icon = Icon
|
||||
n2.SetInfo(Title, Content, TargetActivity)
|
||||
n2.Notify(nNewAppnID)
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
Log("appUpdater(), Service_Destroy")
|
||||
End Sub
|
||||
|
||||
Sub fileProvider_init
|
||||
Dim p As Phone
|
||||
If p.SdkVersion >= 24 Or File.ExternalWritable = False Then
|
||||
UseFileProvider = True
|
||||
SharedFolder = File.Combine(File.DirInternal, "shared")
|
||||
If Not(File.IsDirectory(File.DirInternal,"shared")) Then
|
||||
File.MakeDir("", SharedFolder)
|
||||
End If
|
||||
Else
|
||||
UseFileProvider = False
|
||||
SharedFolder = rp.GetSafeDirDefaultExternal("shared")
|
||||
End If
|
||||
Log($"Using FileProvider? ${UseFileProvider}"$)
|
||||
End Sub
|
||||
|
||||
'Returns the file uri.
|
||||
Sub GetFileUri (FileName As String) As Object
|
||||
Try
|
||||
If Not(UseFileProvider) Then
|
||||
Dim uri As JavaObject
|
||||
Return uri.InitializeStatic("android.net.Uri").RunMethod("parse", Array("file://" & File.Combine(SharedFolder, FileName)))
|
||||
End If
|
||||
Dim f As JavaObject
|
||||
f.InitializeNewInstance("java.io.File", Array(SharedFolder, FileName))
|
||||
Dim fp As JavaObject
|
||||
Dim context As JavaObject
|
||||
context.InitializeContext
|
||||
fp.InitializeStatic("android.support.v4.content.FileProvider")
|
||||
Return fp.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
|
||||
Catch
|
||||
Log("FileProvider::GetFileUri - error - " & LastException.Message)
|
||||
Return ""
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Replaces the intent Data field with the file uri.
|
||||
'Resets the type field. Make sure to call Intent.SetType after calling this method
|
||||
Sub SetFileUriAsIntentData (Intent As Intent, FileName As String)
|
||||
Dim jo As JavaObject = Intent
|
||||
jo.RunMethod("setData", Array(GetFileUri(FileName)))
|
||||
Intent.Flags = Bit.Or(Intent.Flags, 1) 'FLAG_GRANT_READ_URI_PERMISSION
|
||||
End Sub
|
||||
126
B4A/google-services.json
Normal file
@@ -0,0 +1,126 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "821860097209",
|
||||
"project_id": "pusher-4c091",
|
||||
"storage_bucket": "pusher-4c091.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:4a9c1af4c93ba100f24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "flp2.chv.com"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:7b6620b2a870f23cf24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "gunav2.keymon.com.mx"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:7780f81ae43bf0f3f24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "pusher.chv.com"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:821860097209:android:7c55bc95da6d952df24f68",
|
||||
"android_client_info": {
|
||||
"package_name": "ths.keymon.com.mx"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDS-_5lpLX5IiKYrG-0Et-KCKx1bwlY7R0"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "821860097209-ef17t5620111ghub7l0tple62otbb56v.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
66
B4A/test.bas
Normal file
@@ -0,0 +1,66 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
#Region Service Attributes
|
||||
#StartAtBoot: False
|
||||
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
'These global variables will be declared once when the application starts.
|
||||
'These variables can be accessed from all modules.
|
||||
Dim timer As Timer
|
||||
' Dim reqManager As DBRequestManager
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
|
||||
timer.Initialize("Timer", 5000)
|
||||
timer.Enabled = True
|
||||
Starter.reqManager.Initialize(Me, Starter.server)
|
||||
End Sub
|
||||
|
||||
Private Sub Timer_Tick
|
||||
' ToastMessageShow("Timer",False)
|
||||
' Log("Next run " & DateTime.Time(DateTime.Now + Interval * 1000))
|
||||
testJobdone
|
||||
End Sub
|
||||
|
||||
Sub testJobdone
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_fechat"
|
||||
Starter.reqManager.ExecuteQuery(cmd , 0, "fechat")
|
||||
Log("sent......")
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
If Job.Success = False Then
|
||||
' ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Log("Success NOT")
|
||||
Else
|
||||
LogColor("JobDone: '" & Starter.reqManager.HandleJob(Job).tag & "' - Registros: " & Starter.reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211110
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result As DBResult = Starter.reqManager.HandleJob(Job)
|
||||
If result.Tag = "select_fechat" Then 'query tag
|
||||
For Each records() As Object In result.Rows
|
||||
For Each k As String In result.Columns.Keys
|
||||
Log("select_fechat: " & k & ": " & records(result.Columns.Get(k)))
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
|
||||
End Sub
|
||||
24
B4A/updateAvailable.bas
Normal file
@@ -0,0 +1,24 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
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
|
||||
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
53
B4J/Guna CEDEX.b4j
Normal file
@@ -0,0 +1,53 @@
|
||||
AppType=JavaFX
|
||||
Build1=Default,b4j.example
|
||||
File1=MainPage.bjl
|
||||
FileGroup1=New Group
|
||||
Group=Default Group
|
||||
Library1=jcore
|
||||
Library2=jfx
|
||||
Library3=b4xpages
|
||||
Module1=|relative|..\B4XMainPage
|
||||
NumberOfFiles=1
|
||||
NumberOfLibraries=3
|
||||
NumberOfModules=1
|
||||
Version=8.31
|
||||
@EndOfDesignText@
|
||||
#Region Project Attributes
|
||||
#MainFormWidth: 600
|
||||
#MainFormHeight: 600
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
Private fx As JFX
|
||||
Private MainForm As Form
|
||||
End Sub
|
||||
|
||||
Sub AppStart (Form1 As Form, Args() As String)
|
||||
MainForm = Form1
|
||||
MainForm.Show
|
||||
Dim PagesManager As B4XPagesManager
|
||||
PagesManager.Initialize(MainForm)
|
||||
End Sub
|
||||
|
||||
'Template version: B4J-1.0
|
||||
#Region Delegates
|
||||
Sub MainForm_FocusChanged (HasFocus As Boolean)
|
||||
B4XPages.Delegate.MainForm_FocusChanged(HasFocus)
|
||||
End Sub
|
||||
|
||||
Sub MainForm_Resize (Width As Double, Height As Double)
|
||||
B4XPages.Delegate.MainForm_Resize(Width, Height)
|
||||
End Sub
|
||||
|
||||
Sub MainForm_Closed
|
||||
B4XPages.Delegate.MainForm_Closed
|
||||
End Sub
|
||||
|
||||
Sub MainForm_CloseRequest (EventData As Event)
|
||||
B4XPages.Delegate.MainForm_CloseRequest(EventData)
|
||||
End Sub
|
||||
|
||||
Public Sub MainForm_IconifiedChanged (Iconified As Boolean)
|
||||
B4XPages.Delegate.MainForm_IconifiedChanged(Iconified)
|
||||
End Sub
|
||||
#End Region
|
||||
46
B4i/Guna CEDEX.b4i
Normal file
@@ -0,0 +1,46 @@
|
||||
Build1=Default,b4i.example
|
||||
File1=MainPage.bil
|
||||
FileGroup1=Default Group
|
||||
Group=Default Group
|
||||
Library1=icore
|
||||
Library2=b4xpages
|
||||
Module1=|relative|..\B4XMainPage
|
||||
NumberOfFiles=1
|
||||
NumberOfLibraries=2
|
||||
NumberOfModules=1
|
||||
Version=6.5
|
||||
@EndOfDesignText@
|
||||
'Code module
|
||||
#Region Project Attributes
|
||||
#ApplicationLabel: B4i Example
|
||||
#Version: 1.0.0
|
||||
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
|
||||
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
|
||||
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
|
||||
#Target: iPhone, iPad
|
||||
#ATSEnabled: True
|
||||
#MinVersion: 8
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
Public App As Application
|
||||
Public NavControl As NavigationController
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Application_Start (Nav As NavigationController)
|
||||
NavControl = Nav
|
||||
Dim PagesManager As B4XPagesManager
|
||||
PagesManager.Initialize(NavControl)
|
||||
End Sub
|
||||
|
||||
'Template version: B4i-1.0
|
||||
#Region Delegates
|
||||
Private Sub Application_Background
|
||||
B4XPages.Delegate.Activity_Pause
|
||||
End Sub
|
||||
|
||||
Private Sub Application_Foreground
|
||||
B4XPages.Delegate.Activity_Resume
|
||||
End Sub
|
||||
#End Region
|
||||