mirror of
https://github.com/KeymonSoft/Intmex_Multiventa.git
synced 2026-04-17 21:06:08 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 88fb12a277 | |||
| 028d200cc2 | |||
| fbb76fed9b | |||
| 5426e434ca | |||
| 57ac2ff737 | |||
| 004199111e | |||
| a2d5315d02 | |||
| 86d54dff58 | |||
| b4457da9cc | |||
|
|
622efa501c | ||
| 5dd5814658 | |||
| 5f23ece03f | |||
|
|
be8647261e | ||
| e40988de1c | |||
| 0a4483d93c |
@@ -12,16 +12,20 @@ Version=9.85
|
|||||||
'###################### PULL #############################################################
|
'###################### PULL #############################################################
|
||||||
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull
|
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull
|
||||||
'###########################################################################################################
|
'###########################################################################################################
|
||||||
|
'###################### PULL FORZADO #############################################################
|
||||||
|
'Ctrl + click Respaldar y Pull: ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=start&Args=powershell.exe&Args=-ExecutionPolicy&Args=Bypass&Args=-File&Args=..\..\_sync_project.ps1
|
||||||
|
'###########################################################################################################
|
||||||
'###################### PUSH #############################################################
|
'###################### PUSH #############################################################
|
||||||
'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=github&Args=..\..\
|
'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=github&Args=..\..\
|
||||||
'###########################################################################################################
|
'###########################################################################################################
|
||||||
'###################### PUSH TORTOISE GIT #########################################################
|
'###################### PUSH TORTOISE GIT #########################################################
|
||||||
'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=TortoiseGitProc&Args=/command:commit&Args=/path:"./../../"&Args=/closeonend:2
|
'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=TortoiseGitProc&Args=/command:commit&Args=/path:"./../../"&Args=/closeonend:2
|
||||||
'###########################################################################################################
|
'###########################################################################################################
|
||||||
|
'###################### PUSH TORTOISE GIT CON TAG ##################################################
|
||||||
|
'Ctrl + clic para Git: ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=-ExecutionPolicy&Args=Bypass&Args=-File&Args=..\_git_tag.ps1&Args=%22%PROJECT%%22&Args=%22%PROJECT_NAME%%22
|
||||||
|
'###########################################################################################################
|
||||||
#End Region
|
#End Region
|
||||||
|
|
||||||
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=github&Args=..\..\
|
|
||||||
|
|
||||||
Sub Class_Globals
|
Sub Class_Globals
|
||||||
Private Root As B4XView
|
Private Root As B4XView
|
||||||
Private xui As XUI
|
Private xui As XUI
|
||||||
@@ -197,6 +201,11 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
Subs.agregaColumna("CAT_GUNAPROD", "CAT_GP_PRECIO10", "TEXT DEFAULT '0'")
|
Subs.agregaColumna("CAT_GUNAPROD", "CAT_GP_PRECIO10", "TEXT DEFAULT '0'")
|
||||||
Subs.agregaColumna("PEDIDO_CLIENTE", "PC_GUARDADO", "TEXT DEFAULT '0'")
|
Subs.agregaColumna("PEDIDO_CLIENTE", "PC_GUARDADO", "TEXT DEFAULT '0'")
|
||||||
Subs.agregaColumna("CAT_GUNAPROD2", "CAT_GP_VARREQ3", "TEXT DEFAULT '0'")
|
Subs.agregaColumna("CAT_GUNAPROD2", "CAT_GP_VARREQ3", "TEXT DEFAULT '0'")
|
||||||
|
Subs.agregaColumna("HIST_VENTAS", "HVD_USUARIO", "TEXT")
|
||||||
|
Subs.agregaColumna("CAT_GUNAPROD2", "MARCA", "TEXT")
|
||||||
|
Subs.agregaColumna("CAT_GUNAPROD", "MARCA", "TEXT")
|
||||||
|
Subs.agregaColumna("PEDIDO", "PE_ARCH", "TEXT")
|
||||||
|
Subs.agregaColumna("PEDIDO_CLIENTE", "PC_ARCH", "TEXT")
|
||||||
|
|
||||||
c=skmt.ExecQuery("select COUNT(*) AS CUANTOS from HIST_STAY_OUT ")
|
c=skmt.ExecQuery("select COUNT(*) AS CUANTOS from HIST_STAY_OUT ")
|
||||||
C.Position = 0
|
C.Position = 0
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ Sub Class_Globals
|
|||||||
Dim reqManager As DBRequestManager
|
Dim reqManager As DBRequestManager
|
||||||
Dim cmd As DBCommand
|
Dim cmd As DBCommand
|
||||||
Dim ime As IME
|
Dim ime As IME
|
||||||
|
|
||||||
Dim g As GPS
|
Dim g As GPS
|
||||||
Dim ruta As String
|
Dim ruta As String
|
||||||
Dim skmt As SQL
|
Dim skmt As SQL
|
||||||
@@ -34,8 +33,6 @@ Sub Class_Globals
|
|||||||
Dim BLANCO As String
|
Dim BLANCO As String
|
||||||
Dim cuenta As String
|
Dim cuenta As String
|
||||||
Dim tipo_venta As String = "PREVENTA"
|
Dim tipo_venta As String = "PREVENTA"
|
||||||
|
|
||||||
|
|
||||||
Dim c As Cursor
|
Dim c As Cursor
|
||||||
Dim s As Cursor
|
Dim s As Cursor
|
||||||
Dim DD As Cursor
|
Dim DD As Cursor
|
||||||
@@ -54,13 +51,10 @@ Sub Class_Globals
|
|||||||
Dim gest As Button
|
Dim gest As Button
|
||||||
Dim la_saldotot As Label
|
Dim la_saldotot As Label
|
||||||
Dim la_saldooper As Label
|
Dim la_saldooper As Label
|
||||||
|
|
||||||
Dim Tels As Button
|
Dim Tels As Button
|
||||||
Dim Label10 As Label
|
Dim Label10 As Label
|
||||||
Dim Label11 As Label
|
Dim Label11 As Label
|
||||||
|
|
||||||
Dim Tar As Button
|
Dim Tar As Button
|
||||||
|
|
||||||
Dim la_comm As Label
|
Dim la_comm As Label
|
||||||
Dim la_actdte As Label
|
Dim la_actdte As Label
|
||||||
Dim la_usuario As Label
|
Dim la_usuario As Label
|
||||||
@@ -72,8 +66,7 @@ Sub Class_Globals
|
|||||||
Dim DATOS As Button
|
Dim DATOS As Button
|
||||||
Dim Guardar As Button
|
Dim Guardar As Button
|
||||||
Dim NUEVO As Button
|
Dim NUEVO As Button
|
||||||
' Dim lat_gps, lon_gps As String
|
' Dim lat_gps, lon_gps As String
|
||||||
|
|
||||||
Dim l_total As Label
|
Dim l_total As Label
|
||||||
Dim c2 As Cursor
|
Dim c2 As Cursor
|
||||||
Dim S2 As Cursor
|
Dim S2 As Cursor
|
||||||
@@ -88,7 +81,6 @@ Sub Class_Globals
|
|||||||
Private BT_QR As Button
|
Private BT_QR As Button
|
||||||
'Private qr As QRCode
|
'Private qr As QRCode
|
||||||
Dim CODIGO As String
|
Dim CODIGO As String
|
||||||
|
|
||||||
Private b_mapa As Button
|
Private b_mapa As Button
|
||||||
Dim CUANTOS As String
|
Dim CUANTOS As String
|
||||||
Private B_IMP As Button
|
Private B_IMP As Button
|
||||||
@@ -110,22 +102,18 @@ Sub Class_Globals
|
|||||||
Private HR_RES3 As String
|
Private HR_RES3 As String
|
||||||
Private EXISTE As String
|
Private EXISTE As String
|
||||||
Private TELEFONO As String
|
Private TELEFONO As String
|
||||||
|
|
||||||
Private RB1 As RadioButton
|
Private RB1 As RadioButton
|
||||||
Private RB2 As RadioButton
|
Private RB2 As RadioButton
|
||||||
Private RB3 As RadioButton
|
Private RB3 As RadioButton
|
||||||
Private RB4 As RadioButton
|
Private RB4 As RadioButton
|
||||||
Private RB5 As RadioButton
|
Private RB5 As RadioButton
|
||||||
|
|
||||||
Private stay_hh As String
|
Private stay_hh As String
|
||||||
Private stay_mi As String
|
Private stay_mi As String
|
||||||
Private stay_ss As String
|
Private stay_ss As String
|
||||||
|
|
||||||
Private LA_GEO As Label
|
Private LA_GEO As Label
|
||||||
Dim result As Int
|
Dim result As Int
|
||||||
Private cercavalor As String
|
Private cercavalor As String
|
||||||
Private LA_RUTA As String
|
Private LA_RUTA As String
|
||||||
|
|
||||||
Private b_like As Button
|
Private b_like As Button
|
||||||
Private B_GPS As Button
|
Private B_GPS As Button
|
||||||
' Dim sc As JhsIceZxing1
|
' Dim sc As JhsIceZxing1
|
||||||
@@ -152,7 +140,6 @@ Sub Class_Globals
|
|||||||
Dim cuest As C_Cuestionario
|
Dim cuest As C_Cuestionario
|
||||||
Private b_ventaabordo As Button
|
Private b_ventaabordo As Button
|
||||||
Private l_factura As Label
|
Private l_factura As Label
|
||||||
|
|
||||||
Dim Printer1 As EscPosPrinter
|
Dim Printer1 As EscPosPrinter
|
||||||
Dim impresoraConectada As Boolean = False
|
Dim impresoraConectada As Boolean = False
|
||||||
Dim MAC_IMPRESORA As String
|
Dim MAC_IMPRESORA As String
|
||||||
@@ -168,6 +155,7 @@ Sub Class_Globals
|
|||||||
Private et_telefono As EditText
|
Private et_telefono As EditText
|
||||||
Private b_canceltelefono As Button
|
Private b_canceltelefono As Button
|
||||||
Private b_aceptelefono As Button
|
Private b_aceptelefono As Button
|
||||||
|
Private l_version As Label
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'You can add more parameters here.
|
'You can add more parameters here.
|
||||||
@@ -197,7 +185,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
Else
|
Else
|
||||||
b_cxc.Visible = True
|
b_cxc.Visible = True
|
||||||
End If
|
End If
|
||||||
|
p_telefono.Top = 0 : p_telefono.Left = 0
|
||||||
s.Position=0
|
s.Position=0
|
||||||
If c.RowCount>0 Then
|
If c.RowCount>0 Then
|
||||||
c.Position=0
|
c.Position=0
|
||||||
@@ -247,11 +235,14 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
b_cerrar.Left = (p_pedidoExistente.Width / 2) - (b_cerrar.Width / 2)
|
b_cerrar.Left = (p_pedidoExistente.Width / 2) - (b_cerrar.Width / 2)
|
||||||
Subs.centraPanel(p_pedidoExistente, Root.Width)
|
Subs.centraPanel(p_pedidoExistente, Root.Width)
|
||||||
Subs.centraEtiqueta(l_pedidoExistente, Root.Width)
|
Subs.centraEtiqueta(l_pedidoExistente, Root.Width)
|
||||||
|
l_version.Text = Application.VersionName
|
||||||
|
l_version.Left = Root.Width - l_version.Width - 5dip
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||||
|
|
||||||
Sub B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
CallSubDelayed(Tracker, "StartFLPSmall")
|
||||||
p_pedidoExistente.Visible = False
|
p_pedidoExistente.Visible = False
|
||||||
reqManager.Initialize(Me, Starter.DBReqServer)
|
reqManager.Initialize(Me, Starter.DBReqServer)
|
||||||
b_pedidoExistente.Visible = False
|
b_pedidoExistente.Visible = False
|
||||||
@@ -304,16 +295,16 @@ Sub B4XPage_Appear
|
|||||||
If m_lon.Length < 5 Then m_lon = "0"
|
If m_lon.Length < 5 Then m_lon = "0"
|
||||||
LA_RUTA = c.GetString("CAT_CL_RUTA")
|
LA_RUTA = c.GetString("CAT_CL_RUTA")
|
||||||
' ESTO ES PARA FORZAR A PEDIR LA FOTO Y EL GPS
|
' ESTO ES PARA FORZAR A PEDIR LA FOTO Y EL GPS
|
||||||
If c.GetString("CAT_CL_NUM_SERIEFISICO") = "0" Then
|
' If c.GetString("CAT_CL_NUM_SERIEFISICO") = "0" Then
|
||||||
L_QR.TEXT = "SIN CODIGO"
|
' L_QR.TEXT = "SIN CODIGO"
|
||||||
L_QR.TextColor = Colors.Red
|
' L_QR.TextColor = Colors.Red
|
||||||
gest.VISIBLE = False
|
' gest.VISIBLE = False
|
||||||
BT_QR.Visible = True
|
' BT_QR.Visible = True
|
||||||
Else
|
' Else
|
||||||
L_QR.TEXT = c.GetString("CAT_CL_NUM_SERIEFISICO")
|
' L_QR.TEXT = c.GetString("CAT_CL_NUM_SERIEFISICO")
|
||||||
L_QR.TextColor = Colors.Blue
|
' L_QR.TextColor = Colors.Blue
|
||||||
BT_QR.Visible = False
|
' BT_QR.Visible = False
|
||||||
End If
|
' End If
|
||||||
End If
|
End If
|
||||||
c.Close
|
c.Close
|
||||||
s.Close
|
s.Close
|
||||||
@@ -346,9 +337,7 @@ Sub B4XPage_Appear
|
|||||||
End If
|
End If
|
||||||
c.Close
|
c.Close
|
||||||
If ALMACEN = "1" Then
|
If ALMACEN = "1" Then
|
||||||
Tels.Visible = False
|
ocultamosBotonesPorGeocerca
|
||||||
gest.Visible = False
|
|
||||||
' B_GPS.Visible = False
|
|
||||||
End If
|
End If
|
||||||
If ALMACEN = "4" Then
|
If ALMACEN = "4" Then
|
||||||
' b_like.Visible = True
|
' b_like.Visible = True
|
||||||
@@ -370,20 +359,22 @@ Sub B4XPage_Appear
|
|||||||
Else
|
Else
|
||||||
' b_like.Visible = False
|
' b_like.Visible = False
|
||||||
End If
|
End If
|
||||||
If ALMACEN = "16" Or ALMACEN = "13" Then
|
If Not(Subs.geocercaActiva) And ALMACEN = "16" Or ALMACEN = "13" Then
|
||||||
|
Log("Mostramos botones venta")
|
||||||
Tels.Visible = True
|
Tels.Visible = True
|
||||||
gest.Visible = True
|
gest.Visible = True
|
||||||
|
b_ventaabordo.Visible = True
|
||||||
End If
|
End If
|
||||||
CallSubDelayed(Tracker, "Track")
|
|
||||||
CallSubDelayed(Tracker, "StartFLPSmall")
|
If Not(Subs.geocercaActiva) Then
|
||||||
If Tracker.FLP.IsInitialized And Tracker.FLP.GetLastKnownLocation.IsInitialized Then 'Si tenemos "UltimaUbicaccionConocida" la usamos.
|
Log("Mostramos botones venta")
|
||||||
B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
|
|
||||||
B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
|
|
||||||
' Log($"Tenemos UUC: ${Tracker.FLP.GetLastKnownLocation.Latitude},${Tracker.FLP.GetLastKnownLocation.Longitude}"$)
|
|
||||||
GPS_LocationChanged(Tracker.FLP.GetLastKnownLocation)
|
|
||||||
End If
|
|
||||||
Tels.Visible = True
|
Tels.Visible = True
|
||||||
gest.Visible = True
|
gest.Visible = True
|
||||||
|
b_ventaabordo.Visible = True
|
||||||
|
Else
|
||||||
|
Log("Ocultamos botones venta")
|
||||||
|
ocultamosBotonesPorGeocerca
|
||||||
|
End If
|
||||||
|
|
||||||
' h = B4XPages.MainPage.skmt.ExecQuery("SELECT CUENTA from CUENTAA")
|
' h = B4XPages.MainPage.skmt.ExecQuery("SELECT CUENTA from CUENTAA")
|
||||||
' h.Position = 0
|
' h.Position = 0
|
||||||
@@ -399,33 +390,20 @@ Sub B4XPage_Appear
|
|||||||
' h.Close
|
' h.Close
|
||||||
' j.Close
|
' j.Close
|
||||||
|
|
||||||
If la_cuenta.Text = "0" Then
|
|
||||||
p_cbFactura.Visible = False
|
|
||||||
l_factura.Visible = False
|
|
||||||
b_ventaabordo.Visible = False
|
|
||||||
Else
|
|
||||||
p_cbFactura.Visible = True
|
|
||||||
l_factura.Visible = True
|
|
||||||
b_ventaabordo.Visible = True
|
|
||||||
End If
|
|
||||||
c = skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("MACIMP"))
|
c = skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("MACIMP"))
|
||||||
If c.RowCount > 0 Then
|
If c.RowCount > 0 Then
|
||||||
c.Position = 0
|
c.Position = 0
|
||||||
Starter.MAC_IMPRESORA = c.GetString("CAT_VA_VALOR")
|
Starter.MAC_IMPRESORA = c.GetString("CAT_VA_VALOR")
|
||||||
End If
|
End If
|
||||||
If Starter.MAC_IMPRESORA = "" Then Starter.MAC_IMPRESORA = "0"
|
If Starter.MAC_IMPRESORA = "" Then Starter.MAC_IMPRESORA = "0"
|
||||||
' Log("|" & Starter.MAC_IMPRESORA & "|")
|
|
||||||
Printer1.Initialize(Me, "Printer1")
|
Printer1.Initialize(Me, "Printer1")
|
||||||
If Printer1.IsConnected = False Then
|
If Printer1.IsConnected = False Then
|
||||||
' Printer1.Connect
|
' Printer1.Connect
|
||||||
' Log("1")
|
|
||||||
Else
|
Else
|
||||||
Printer1.DisConnect
|
Printer1.DisConnect
|
||||||
Printer1.Connect
|
Printer1.Connect
|
||||||
Log("2")
|
|
||||||
End If
|
End If
|
||||||
If Subs.hayPedido And Starter.utimaPagina <> "Productos" And Starter.utimaPagina <> "Cliente" Then
|
If Subs.hayPedido And Starter.utimaPagina <> "Productos" And Starter.utimaPagina <> "Cliente" Then
|
||||||
' Log()
|
|
||||||
Private p As ResultSet = Starter.skmt.ExecQuery($"select * from pedido where pe_cliente = '${Subs.traeCliente}'"$)
|
Private p As ResultSet = Starter.skmt.ExecQuery($"select * from pedido where pe_cliente = '${Subs.traeCliente}'"$)
|
||||||
lv_pedidoExistente.Clear
|
lv_pedidoExistente.Clear
|
||||||
Private label1 As Label = lv_pedidoExistente.TwoLinesLayout.Label
|
Private label1 As Label = lv_pedidoExistente.TwoLinesLayout.Label
|
||||||
@@ -448,6 +426,26 @@ Sub B4XPage_Appear
|
|||||||
p_pedidoExistente.BringToFront
|
p_pedidoExistente.BringToFront
|
||||||
b_pedidoExistente.Visible = True
|
b_pedidoExistente.Visible = True
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
If la_cuenta.Text = "0" Then
|
||||||
|
p_cbFactura.Visible = False
|
||||||
|
l_factura.Visible = False
|
||||||
|
b_ventaabordo.Visible = False
|
||||||
|
Else
|
||||||
|
p_cbFactura.Visible = True
|
||||||
|
l_factura.Visible = True
|
||||||
|
b_ventaabordo.Visible = True
|
||||||
|
End If
|
||||||
|
|
||||||
|
'Revisamos si la geocerca debe de activarse y de ser necesario, ocultamos los botones de venta y no venta.
|
||||||
|
If Subs.traeGeocerca Then ocultamosBotonesPorGeocerca
|
||||||
|
|
||||||
|
If Tracker.FLP.IsInitialized And Tracker.FLP.GetLastKnownLocation.IsInitialized Then 'Si tenemos "UltimaUbicaccionConocida" la usamos.
|
||||||
|
Log($"Tenemos UUC: ${Tracker.FLP.GetLastKnownLocation.Latitude},${Tracker.FLP.GetLastKnownLocation.Longitude}"$)
|
||||||
|
B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
|
||||||
|
B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
|
||||||
|
GPS_LocationChanged(Tracker.FLP.GetLastKnownLocation)
|
||||||
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub B4XPage_disappear
|
Sub B4XPage_disappear
|
||||||
@@ -456,7 +454,7 @@ Sub B4XPage_disappear
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub GPS_LocationChanged (Location1 As Location)
|
Sub GPS_LocationChanged (Location1 As Location)
|
||||||
' LogColor($"Entrando a Cliente.GPS_LocationChanged"$, Colors.red)
|
LogColor($"Entrando a Cliente.GPS_LocationChanged"$, Colors.red)
|
||||||
If Tracker.FLP.GetLastKnownLocation.IsInitialized And Tracker.FLP.GetLastKnownLocation.Latitude <> 0 Then
|
If Tracker.FLP.GetLastKnownLocation.IsInitialized And Tracker.FLP.GetLastKnownLocation.Latitude <> 0 Then
|
||||||
B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
|
B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
|
||||||
B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
|
B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
|
||||||
@@ -471,17 +469,22 @@ Sub GPS_LocationChanged (Location1 As Location)
|
|||||||
BT_QR.Enabled = True
|
BT_QR.Enabled = True
|
||||||
LA_GPS.TextColor = Colors.Blue
|
LA_GPS.TextColor = Colors.Blue
|
||||||
LA_GPS.Text = "CON UBICACION GPS"
|
LA_GPS.Text = "CON UBICACION GPS"
|
||||||
|
Log("CON UBICACION GPS")
|
||||||
' B_GPS.Enabled = True
|
' B_GPS.Enabled = True
|
||||||
'now we need the distance between our location and the target location
|
'now we need the distance between our location and the target location
|
||||||
distance = l1.DistanceTo(l2) 'the result is in meter
|
distance = l1.DistanceTo(l2) 'the result is in meter
|
||||||
gest.Visible = True
|
Log(distance)
|
||||||
' If distance < 100 Then
|
Log((Subs.geocercaActiva And distance < 100))
|
||||||
|
Log(Not(Subs.geocercaActiva))
|
||||||
|
If (Subs.geocercaActiva And distance < 100) Or (Not(Subs.geocercaActiva)) Then
|
||||||
|
Log("Mostramos botones venta")
|
||||||
LA_GEO.TextColor = Colors.Blue
|
LA_GEO.TextColor = Colors.Blue
|
||||||
Tels.Visible = True
|
Tels.Visible = True
|
||||||
gest.Visible = True
|
gest.Visible = True
|
||||||
' Else
|
b_ventaabordo.Visible = True
|
||||||
|
Else
|
||||||
' LA_GEO.TextColor = Colors.Red
|
' LA_GEO.TextColor = Colors.Red
|
||||||
' End If
|
End If
|
||||||
LA_GEO.Text= $"$1.2{distance/1000} kms"$
|
LA_GEO.Text= $"$1.2{distance/1000} kms"$
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
|
B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
|
||||||
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.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
|
||||||
@@ -510,7 +513,6 @@ Sub gest_Click
|
|||||||
' Return False
|
' Return False
|
||||||
' End If
|
' End If
|
||||||
Private x As Cursor = B4XPages.MainPage.skmt.ExecQuery($"select tienda_id from COORDENADAS_GPS where tienda_id = '${la_cuenta.text}'"$)
|
Private x As Cursor = B4XPages.MainPage.skmt.ExecQuery($"select tienda_id from COORDENADAS_GPS where tienda_id = '${la_cuenta.text}'"$)
|
||||||
' Log("+++++++++++++ " & x.RowCount)
|
|
||||||
If la_cuenta.Text<> "0" And distance > 50 And x.RowCount = 0 Then
|
If la_cuenta.Text<> "0" And distance > 50 And x.RowCount = 0 Then
|
||||||
Private res As String = Msgbox2("¿Estas en la tienda, para guardar la nueva ubicación?", "AVISO", "Si","" ,"No", Null) 'ignore
|
Private res As String = Msgbox2("¿Estas en la tienda, para guardar la nueva ubicación?", "AVISO", "Si","" ,"No", Null) 'ignore
|
||||||
If res = DialogResponse.POSITIVE Then
|
If res = DialogResponse.POSITIVE Then
|
||||||
@@ -527,8 +529,6 @@ Sub gest_Click
|
|||||||
reqManager.ExecuteCommand(cmd , "ins_coords_nuevas")
|
reqManager.ExecuteCommand(cmd , "ins_coords_nuevas")
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
'Si hay mapa de productos es que hay venta en proceso, entonces borramos la actual para meter la nueva.
|
|
||||||
' If B4XPages.MainPage.productos.prodsMap.IsInitialized And B4XPages.MainPage.productos.prodsMap.Size > 0 Then Subs.borraPedidoClienteActual
|
|
||||||
B4XPages.ShowPage("productos")
|
B4XPages.ShowPage("productos")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
@@ -539,7 +539,6 @@ End Sub
|
|||||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||||
' BACK key pressed
|
' BACK key pressed
|
||||||
' Return True To close, False To cancel
|
' Return True To close, False To cancel
|
||||||
' Log($"venimosDeTicketsDia=${venimosDeTicketsDia}"$)
|
|
||||||
If la_cuenta.Text <> "0" Then
|
If la_cuenta.Text <> "0" Then
|
||||||
cuest.encuestaIniciada = False
|
cuest.encuestaIniciada = False
|
||||||
cuest.ocultPanelPregunta
|
cuest.ocultPanelPregunta
|
||||||
@@ -570,10 +569,6 @@ Sub Tar_Click
|
|||||||
B4XPages.ShowPage("Nota")
|
B4XPages.ShowPage("Nota")
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'Sub Tar_LongClick
|
|
||||||
' p_abono.Visible = True
|
|
||||||
'End Sub
|
|
||||||
|
|
||||||
Sub DATOS_Click
|
Sub DATOS_Click
|
||||||
B4XPages.ShowPage("telefonos")
|
B4XPages.ShowPage("telefonos")
|
||||||
End Sub
|
End Sub
|
||||||
@@ -592,7 +587,6 @@ Sub Guardar_Click
|
|||||||
c.Close
|
c.Close
|
||||||
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=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
|
c.Position=0
|
||||||
' Log("xxxxxxxxxxxxxxx " & c.GetString("CUANTOS"))
|
|
||||||
If c.GetString("CUANTOS") > 0 Then ' Si hay pedido, entonces ...
|
If c.GetString("CUANTOS") > 0 Then ' Si hay pedido, entonces ...
|
||||||
Log("HAY PEDIDO")
|
Log("HAY PEDIDO")
|
||||||
Private cbFactura As Int = 0
|
Private cbFactura As Int = 0
|
||||||
@@ -604,7 +598,7 @@ Sub Guardar_Click
|
|||||||
Log(">>>>> PONEMOS SIG TICKET")
|
Log(">>>>> PONEMOS SIG TICKET")
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery($"update pedido set PE_TICKET = ${Subs.traeTicketConsecutivo(Subs.traeCliente)}, PE_GUARDADO = 1 where PE_CLIENTE IN (Select CUENTA from cuentaa) and PE_TICKET is Null"$)
|
B4XPages.MainPage.skmt.ExecNonQuery($"update pedido set PE_TICKET = ${Subs.traeTicketConsecutivo(Subs.traeCliente)}, PE_GUARDADO = 1 where PE_CLIENTE IN (Select CUENTA from cuentaa) and PE_TICKET is Null"$)
|
||||||
End If
|
End If
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery($"update pedido set PE_GUARDADO = 1, PE_ENVIO_OK = 1 where PE_CLIENTE IN (Select CUENTA from cuentaa)"$)
|
B4XPages.MainPage.skmt.ExecNonQuery($"update pedido set PE_GUARDADO = 1, PE_ENVIO_OK = 0 where PE_CLIENTE IN (Select CUENTA from cuentaa)"$)
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery($"update pedido_cliente set PC_GUARDADO = 1 where PC_CLIENTE IN (Select CUENTA from cuentaa)"$)
|
B4XPages.MainPage.skmt.ExecNonQuery($"update pedido_cliente set PC_GUARDADO = 1 where PC_CLIENTE IN (Select CUENTA from cuentaa)"$)
|
||||||
c.Close
|
c.Close
|
||||||
DateTime.TimeFormat = "HHmmss"
|
DateTime.TimeFormat = "HHmmss"
|
||||||
@@ -632,7 +626,13 @@ Sub Guardar_Click
|
|||||||
' LogColor($"actualizamos "${la_cuenta.text}, hora_final=${DateTime.now}"$,Colors.Red)
|
' LogColor($"actualizamos "${la_cuenta.text}, hora_final=${DateTime.now}"$,Colors.Red)
|
||||||
Subs.actualizaTET(la_cuenta.text)
|
Subs.actualizaTET(la_cuenta.text)
|
||||||
DateTime.TimeFormat = "HH:mm:ss"
|
DateTime.TimeFormat = "HH:mm:ss"
|
||||||
mandaPendientes 'LO COMENTAMOS PARA PRUEBAS, ACTIVAR AL FINAL!!! solo envia clientes nuenos, no comentar lo que yo descomente --- javier (por que Guerra lo comento)
|
|
||||||
|
|
||||||
|
' B4XPages.MainPage.principal.enviaPedidoBatch(Subs.traeCliente)
|
||||||
|
' Sleep(2000)
|
||||||
|
|
||||||
|
|
||||||
|
mandaPendientes 'LO COMENTAMOS PARA PRUEBAS, ACTIVAR AL FINAL!!! - Solo envia clientes nuevos, no comentar lo que yo descomente --- javier (por que Guerra lo comento) ... ¿Que descomentaste?? --- Guerra
|
||||||
mandapiezas
|
mandapiezas
|
||||||
B4XPages.MainPage.productos.reiniciarlistaProds = True
|
B4XPages.MainPage.productos.reiniciarlistaProds = True
|
||||||
B4XPages.MainPage.productos.prodsMap.Initialize
|
B4XPages.MainPage.productos.prodsMap.Initialize
|
||||||
@@ -1061,6 +1061,7 @@ Sub B_GUARDA_C_Click
|
|||||||
Tar.Visible = True
|
Tar.Visible = True
|
||||||
Tels.Visible = True
|
Tels.Visible = True
|
||||||
gest.Visible = True
|
gest.Visible = True
|
||||||
|
b_ventaabordo.Visible = True
|
||||||
' b_like.Visible = False
|
' b_like.Visible = False
|
||||||
Guardar.Visible = True
|
Guardar.Visible = True
|
||||||
End Sub
|
End Sub
|
||||||
@@ -1458,6 +1459,14 @@ Sub JobDone(Job As HttpJob)
|
|||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
'Guarda coords nuevas
|
||||||
|
If Job.JobName = "DBRequest" Then
|
||||||
|
Dim resultado As DBResult = reqManager.HandleJob(Job)
|
||||||
|
If resultado.Tag = "insCoordsNuevas" Then
|
||||||
|
ToastMessageShow("Coordenadas actualizadas", False)
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
'CUESTIONARIO
|
'CUESTIONARIO
|
||||||
If Job.JobName = "DBRequest" Then
|
If Job.JobName = "DBRequest" Then
|
||||||
Dim resultado As DBResult = reqManager.HandleJob(Job)
|
Dim resultado As DBResult = reqManager.HandleJob(Job)
|
||||||
@@ -1744,3 +1753,33 @@ Private Sub Label16_LongClick
|
|||||||
p_telefono.Width = Root.Width
|
p_telefono.Width = Root.Width
|
||||||
p_telefono.Visible = True
|
p_telefono.Visible = True
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
' Ocultamos por geocerca (Venta, Preventa y No venta)
|
||||||
|
Sub ocultamosBotonesPorGeocerca
|
||||||
|
gest.Visible = False
|
||||||
|
b_ventaabordo.Visible = False
|
||||||
|
Tels.Visible = False
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub la_nombre_Click
|
||||||
|
Log("Clicked")
|
||||||
|
If Not(Subs.geocercaActiva) Then
|
||||||
|
Log("Enviando coords")
|
||||||
|
DateTime.DateFormat = "MM/dd/yyyy"
|
||||||
|
sDate=DateTime.Date(DateTime.Now)
|
||||||
|
sTime=DateTime.Time(DateTime.Now)
|
||||||
|
B4XPages.MainPage.skmt.ExecNonQuery($"update kmt_info set cat_cl_lat = '${B4XPages.MainPage.lat_gps}', cat_cl_long = '${B4XPages.MainPage.lon_gps}' where cat_cl_codigo = '${la_cuenta.text}'"$)
|
||||||
|
|
||||||
|
Dim cmd As DBCommand
|
||||||
|
cmd.Initialize
|
||||||
|
cmd.Name = "insert_coordsNuevas_INTMEX"
|
||||||
|
cmd.Parameters = Array As Object(B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps, Subs.traeAlmacen, Subs.traeRuta, la_cuenta.text)
|
||||||
|
' cmd.Parameters = Array As Object("1", "1", "5", "6", "CLN13478")
|
||||||
|
Log($"${Subs.traeAlmacen}, ${Subs.traeRuta},${la_cuenta.text},${B4XPages.MainPage.lat_gps},${B4XPages.MainPage.lon_gps}"$)
|
||||||
|
reqManager.ExecuteCommand(cmd , "insCoordsNuevas")
|
||||||
|
ToastMessageShow("Coordenadas actualizadas", False)
|
||||||
|
B4XPage_Appear
|
||||||
|
Else
|
||||||
|
ToastMessageShow("Geocerca activada", False)
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
@@ -55,6 +55,7 @@ End Sub
|
|||||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||||
|
|
||||||
Sub B4XPage_Appear
|
Sub B4XPage_Appear
|
||||||
|
ListView1.Height = Root.Height * 0.8
|
||||||
If Not(Starter.gps.GPSEnabled) Then
|
If Not(Starter.gps.GPSEnabled) Then
|
||||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||||
@@ -65,8 +66,9 @@ Sub B4XPage_Appear
|
|||||||
C.Position=0
|
C.Position=0
|
||||||
Existe = C.GetString("EXISTE")
|
Existe = C.GetString("EXISTE")
|
||||||
C.Close
|
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")
|
c=B4XPages.MainPage.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT,HVD_USUARIO from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_PRONOMBRE asc")
|
||||||
ListView1.Clear
|
ListView1.Clear
|
||||||
|
ListView1.TwoLinesLayout.ItemHeight = 70dip
|
||||||
If c.RowCount>0 Then
|
If c.RowCount>0 Then
|
||||||
For i=0 To c.RowCount -1
|
For i=0 To c.RowCount -1
|
||||||
c.Position=i
|
c.Position=i
|
||||||
@@ -78,7 +80,7 @@ Sub B4XPage_Appear
|
|||||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||||
label2.TextSize = 10
|
label2.TextSize = 10
|
||||||
label2.TextColor = Colors.Blue
|
label2.TextColor = Colors.Blue
|
||||||
ListView1.AddTwoLines(c.GetString("HVD_PRONOMBRE"),"Cantidad #"& c.GetString("HVD_CANT")& " SubTotal $"& c.GetString("HVD_COSTO_TOT"))
|
ListView1.AddTwoLines(c.GetString("HVD_PRONOMBRE"),"Cantidad #"& c.GetString("HVD_CANT")& " SubTotal $"& c.GetString("HVD_COSTO_TOT") & CRLF & "Usuario: " & c.GetString("HVD_USUARIO"))
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
If Existe <> 0 Then
|
If Existe <> 0 Then
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
' L_CANT.Text = c.GetString("PC_NOART")
|
' L_CANT.Text = c.GetString("PC_NOART")
|
||||||
' L_TOTAL.Text = c.GetString("PC_MONTO")
|
' L_TOTAL.Text = c.GetString("PC_MONTO")
|
||||||
' End If
|
' End If
|
||||||
|
p_nota.Height = Root.Height : p_nota.Width = Root.Width
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||||
|
|||||||
@@ -162,6 +162,7 @@ Sub Class_Globals
|
|||||||
Private p_transparenteCN As Panel
|
Private p_transparenteCN As Panel
|
||||||
Private p_clientesNuevos As Panel
|
Private p_clientesNuevos As Panel
|
||||||
Private b_clienteNuevo As Button
|
Private b_clienteNuevo As Button
|
||||||
|
Private l_textoCN As Label
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'You can add more parameters here.
|
'You can add more parameters here.
|
||||||
@@ -260,14 +261,16 @@ Sub B4XPage_Appear
|
|||||||
c.Close
|
c.Close
|
||||||
Log($"Permitidos: ${permitidos}, Actuales: ${cuantosNuevos}"$)
|
Log($"Permitidos: ${permitidos}, Actuales: ${cuantosNuevos}"$)
|
||||||
Log((permitidos > 0) & "|" & (permitidos > cuantosNuevos))
|
Log((permitidos > 0) & "|" & (permitidos > cuantosNuevos))
|
||||||
If permitidos <> 0 Then ' Si permitidos es CERO entonces SIN LIMITE de clientes nuevos.
|
' If permitidos <> 0 Then ' Si permitidos es CERO entonces SIN LIMITE de clientes nuevos.
|
||||||
|
l_textoCN.Text = "Llegó al límite de clientes nuevos, ya no es posible agregar mas clientes."
|
||||||
|
If permitidos = 0 Then l_textoCN.Text = "No tienes permitido dar de alta clientes nuevos."
|
||||||
If permitidos > cuantosNuevos Then
|
If permitidos > cuantosNuevos Then
|
||||||
p_transparenteCN.Visible = False
|
p_transparenteCN.Visible = False
|
||||||
Else
|
Else
|
||||||
p_transparenteCN.BringToFront
|
p_transparenteCN.BringToFront
|
||||||
p_transparenteCN.Visible = True
|
p_transparenteCN.Visible = True
|
||||||
End If
|
End If
|
||||||
End If
|
' End If
|
||||||
|
|
||||||
CallSubDelayed(Tracker, "Track")
|
CallSubDelayed(Tracker, "Track")
|
||||||
CallSubDelayed(Tracker, "StartFLPSmall")
|
CallSubDelayed(Tracker, "StartFLPSmall")
|
||||||
|
|||||||
@@ -315,6 +315,8 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
|||||||
p_muestraPendientes.Left = Root.Width - p_muestraPendientes.Width - 5dip
|
p_muestraPendientes.Left = Root.Width - p_muestraPendientes.Width - 5dip
|
||||||
' p_conexion.Top = 1 : p_conexion.left = Root.width - p_conexion.width
|
' p_conexion.Top = 1 : p_conexion.left = Root.width - p_conexion.width
|
||||||
l_conexion.Top = 0 : l_conexion.left = Root.width - l_conexion.width -2
|
l_conexion.Top = 0 : l_conexion.left = Root.width - l_conexion.width -2
|
||||||
|
p_prod.Left = 0 : p_prod.Top = 0
|
||||||
|
p_mandaInfo.Top = 0 : p_mandaInfo.left = 0
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub chkIfTableExists(db As SQL, table As String) As Boolean 'ignore
|
Sub chkIfTableExists(db As SQL, table As String) As Boolean 'ignore
|
||||||
@@ -975,8 +977,9 @@ Sub cargar_Click
|
|||||||
reqManager.ExecuteQuery(cmd , 0, "detallepaq")
|
reqManager.ExecuteQuery(cmd , 0, "detallepaq")
|
||||||
|
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
cmd.Name = "select_cat_clientes2_INTMEX"
|
cmd.Name = "select_cat_clientes3_INTMEX"
|
||||||
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
|
cmd.Parameters = Array As Object(e_ruta.text,e_ruta.text, ALMACEN,e_ruta.text,e_ruta.text)
|
||||||
|
Log("select_cat_clientes3_INTMEX: " & e_ruta.text & "|" & ALMACEN)
|
||||||
reqManager.ExecuteQuery(cmd , 0, "kmt_datos")
|
reqManager.ExecuteQuery(cmd , 0, "kmt_datos")
|
||||||
|
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
@@ -995,8 +998,9 @@ Sub cargar_Click
|
|||||||
reqManager.ExecuteQuery(cmd , 0, "kmt_datos_todos")
|
reqManager.ExecuteQuery(cmd , 0, "kmt_datos_todos")
|
||||||
|
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
cmd.Name = "select_hist_datos_INTMEX_2"
|
cmd.Name = "select_hist_datos_INTMEX_3"
|
||||||
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
|
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
|
||||||
|
Log($"===> ${e_ruta.text}, ${ALMACEN}"$)
|
||||||
reqManager.ExecuteQuery(cmd , 0, "hist_datos")
|
reqManager.ExecuteQuery(cmd , 0, "hist_datos")
|
||||||
|
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
@@ -1026,23 +1030,25 @@ Sub cargar_Click
|
|||||||
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
|
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
|
||||||
reqManager.ExecuteQuery(cmd , 0, "tipoRuta")
|
reqManager.ExecuteQuery(cmd , 0, "tipoRuta")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
' cmd.Initialize
|
' cmd.Initialize
|
||||||
' cmd.Name = "select_HIST_MARCAS_CUOTAS_INTMEX"
|
' cmd.Name = "select_HIST_MARCAS_CUOTAS_INTMEX"
|
||||||
' cmd.Parameters = Array As Object( ALMACEN, e_ruta.text)
|
' cmd.Parameters = Array As Object( ALMACEN, e_ruta.text)
|
||||||
' reqManager.ExecuteQuery(cmd , 0, "HIST_MARCAS_CUOTAS")
|
' reqManager.ExecuteQuery(cmd , 0, "HIST_MARCAS_CUOTAS")
|
||||||
|
|
||||||
If E_RUTA2.text <> "" Then
|
cmd.Name = "select_geocerca_intmex"
|
||||||
|
cmd.Parameters = Array As Object(ALMACEN, e_ruta.text)
|
||||||
|
Log($"traeGeocerca: almacen: ${ALMACEN}, ruta: ${e_ruta.text}"$)
|
||||||
|
reqManager.ExecuteQuery(cmd , 0, "traeGeocerca")
|
||||||
|
|
||||||
|
If E_RUTA2.text <> "" Then
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO RUTA_SUPLENCIA(RS_RUTA) VALUES(?)",Array As String(E_RUTA2.Text))
|
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO RUTA_SUPLENCIA(RS_RUTA) VALUES(?)",Array As String(E_RUTA2.Text))
|
||||||
|
|
||||||
E_RUTA2.Visible = False
|
E_RUTA2.Visible = False
|
||||||
ImageView9.Visible = False
|
ImageView9.Visible = False
|
||||||
|
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
cmd.Name = "select_cat_clientes2_INTMEX"
|
cmd.Name = "select_cat_clientes3_INTMEX"
|
||||||
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN)
|
cmd.Parameters = Array As Object(E_RUTA2.text,E_RUTA2.text, ALMACEN,E_RUTA2.text,E_RUTA2.text)
|
||||||
reqManager.ExecuteQuery(cmd , 0, "kmt_datos")
|
reqManager.ExecuteQuery(cmd , 0, "kmt_datos")
|
||||||
|
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
@@ -1051,7 +1057,7 @@ Sub cargar_Click
|
|||||||
reqManager.ExecuteQuery(cmd , 0, "kmt_datos_todos")
|
reqManager.ExecuteQuery(cmd , 0, "kmt_datos_todos")
|
||||||
|
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
cmd.Name = "select_hist_datos_INTMEX"
|
cmd.Name = "select_hist_datos_INTMEX_3"
|
||||||
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN)
|
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN)
|
||||||
reqManager.ExecuteQuery(cmd , 0, "hist_datos")
|
reqManager.ExecuteQuery(cmd , 0, "hist_datos")
|
||||||
|
|
||||||
@@ -1096,11 +1102,16 @@ Sub cargar_Click
|
|||||||
cmd.Parameters = Array As Object( ALMACEN, e_ruta.text)
|
cmd.Parameters = Array As Object( ALMACEN, e_ruta.text)
|
||||||
reqManager.ExecuteQuery(cmd , 0, "marcas_rutas")
|
reqManager.ExecuteQuery(cmd , 0, "marcas_rutas")
|
||||||
|
|
||||||
|
cmd.Initialize
|
||||||
|
cmd.Name = "select_marcas_Intmex"
|
||||||
|
cmd.Parameters = Array As Object(usuario)
|
||||||
|
reqManager.ExecuteQuery(cmd , 0, "marcas")
|
||||||
|
|
||||||
' cmd.Initialize
|
' cmd.Initialize
|
||||||
' cmd.Name = "select_CUEST_INTMEX"
|
' cmd.Name = "select_CUEST_INTMEX"
|
||||||
' cmd.Parameters = Array As Object(ALMACEN)
|
' cmd.Parameters = Array As Object(ALMACEN)
|
||||||
' reqManager.ExecuteQuery(cmd , 0, "CUESTIONARIO")
|
' reqManager.ExecuteQuery(cmd , 0, "CUESTIONARIO")
|
||||||
|
'
|
||||||
' cmd.Initialize
|
' cmd.Initialize
|
||||||
' cmd.Name = "select_HIST_CUOTAS_INTMEX"
|
' cmd.Name = "select_HIST_CUOTAS_INTMEX"
|
||||||
' cmd.Parameters = Array As Object( ALMACEN,e_ruta.text )
|
' cmd.Parameters = Array As Object( ALMACEN,e_ruta.text )
|
||||||
@@ -1108,7 +1119,7 @@ Sub cargar_Click
|
|||||||
|
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
cmd.Name = "select_comis_cedex_INTMEX"
|
cmd.Name = "select_comis_cedex_INTMEX"
|
||||||
cmd.Parameters = Array As Object( ALMACEN, e_ruta.text )
|
cmd.Parameters = Array As Object(ALMACEN, e_ruta.text)
|
||||||
reqManager.ExecuteQuery(cmd , 0, "COMISIONES")
|
reqManager.ExecuteQuery(cmd , 0, "COMISIONES")
|
||||||
|
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
@@ -1141,7 +1152,6 @@ Sub JobDone(Job As HttpJob)
|
|||||||
LogColor("###### JobError: " & Job.Tag & CRLF & Job.ErrorMessage, Colors.red)
|
LogColor("###### JobError: " & Job.Tag & CRLF & Job.ErrorMessage, Colors.red)
|
||||||
LogColor("############################################", Colors.red)
|
LogColor("############################################", Colors.red)
|
||||||
Else 'If Job Success then ...
|
Else 'If Job Success then ...
|
||||||
Log(3)
|
|
||||||
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.RGB(0,160,0)) 'Mod por CHV - 211027
|
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.RGB(0,160,0)) 'Mod por CHV - 211027
|
||||||
'Verificamos que el usuario guardado en BD sea VALIDO.
|
'Verificamos que el usuario guardado en BD sea VALIDO.
|
||||||
If Job.JobName = "DBRequest" Then
|
If Job.JobName = "DBRequest" Then
|
||||||
@@ -1196,7 +1206,7 @@ Sub JobDone(Job As HttpJob)
|
|||||||
If n = "OKActivo" Then
|
If n = "OKActivo" Then
|
||||||
Dim cmd As DBCommand
|
Dim cmd As DBCommand
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
cmd.Name = "select_ruta_INTMEX_7"
|
cmd.Name = "select_ruta_INTMEX_8"
|
||||||
cmd.Parameters = Array As Object(ALMACEN,e_ruta.text)
|
cmd.Parameters = Array As Object(ALMACEN,e_ruta.text)
|
||||||
Log($"${ALMACEN},${e_ruta.text},${imei}"$)
|
Log($"${ALMACEN},${e_ruta.text},${imei}"$)
|
||||||
reqManager.ExecuteQuery(cmd , 0, "ruta")
|
reqManager.ExecuteQuery(cmd , 0, "ruta")
|
||||||
@@ -1455,6 +1465,26 @@ Sub JobDone(Job As HttpJob)
|
|||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
' If Job.JobName = "DBRequest" Then
|
||||||
|
' Dim RESULT As DBResult = reqManager.HandleJob(Job)
|
||||||
|
' If RESULT.Tag.As(String).Contains("pedido_completo") Then 'query tag
|
||||||
|
' Subs.logJobDoneResultados(RESULT)
|
||||||
|
' For Each records() As Object In resultado.Rows
|
||||||
|
' If records(resultado.Columns.Get("AffectedRows")).As(Int) > 0 Then
|
||||||
|
' Private pars() As String = Regex.Split("_", RESULT.tag)
|
||||||
|
' B4XPages.MainPage.skmt.ExecNonQuery($"update PEDIDO set PE_ENVIO_OK = 1, PE_GUARDADO = 1 where PE_CLIENTE = '${pars(2)}'"$)
|
||||||
|
' Log($"update PEDIDO set PE_ENVIO_OK = 1, PE_GUARDADO = 1 where PE_CLIENTE = '${pars(2)}'"$)
|
||||||
|
' B4XPages.MainPage.skmt.ExecNonQuery($"update PEDIDO_CLIENTE set PC_ENVIO_OK = 1, PC_GUARDADO = 1 where PC_CLIENTE = '${pars(2)}'"$)
|
||||||
|
' Log($"update PEDIDO_CLIENTE set PC_ENVIO_OK = 1, PC_GUARDADO = 1 where PC_CLIENTE = '${pars(2)}'"$)
|
||||||
|
'
|
||||||
|
' ($"update PEDIDO_CLIENTE set PC_ENVIO_OK = 1 where PC_CLIENTE = '${pars(3)}'"$)
|
||||||
|
'
|
||||||
|
' End If
|
||||||
|
' Next
|
||||||
|
'' validador.iniciaValidacion
|
||||||
|
' End If
|
||||||
|
' End If
|
||||||
|
|
||||||
If Job.JobName = "DBRequest" Then
|
If Job.JobName = "DBRequest" Then
|
||||||
Dim RESULT As DBResult = reqManager.HandleJob(Job)
|
Dim RESULT As DBResult = reqManager.HandleJob(Job)
|
||||||
If RESULT.Tag = "HIST_MARCAS_CUOTAS" Then 'query tag
|
If RESULT.Tag = "HIST_MARCAS_CUOTAS" Then 'query tag
|
||||||
@@ -1506,6 +1536,7 @@ Sub JobDone(Job As HttpJob)
|
|||||||
If RESULT.Tag = "cn" Then 'query tag
|
If RESULT.Tag = "cn" Then 'query tag
|
||||||
For Each records() As Object In RESULT.Rows
|
For Each records() As Object In RESULT.Rows
|
||||||
Dim CAT_RU_CN As String = records(RESULT.Columns.Get("CAT_RU_CN"))
|
Dim CAT_RU_CN As String = records(RESULT.Columns.Get("CAT_RU_CN"))
|
||||||
|
B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM CN")
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CN(ACTIVO) VALUES (?)", Array As Object (CAT_RU_CN))
|
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CN(ACTIVO) VALUES (?)", Array As Object (CAT_RU_CN))
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
@@ -1520,6 +1551,15 @@ Sub JobDone(Job As HttpJob)
|
|||||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO MARCAS_RUTAS(HVD_MARCA, CLIENTES) VALUES (?,?)", Array As Object (HVD_MARCA, CLIENTES))
|
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO MARCAS_RUTAS(HVD_MARCA, CLIENTES) VALUES (?,?)", Array As Object (HVD_MARCA, CLIENTES))
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
' Marcas
|
||||||
|
If RESULT.Tag = "marcas" Then 'query tag
|
||||||
|
For Each records() As Object In RESULT.Rows
|
||||||
|
Dim MARCAS As String = records(RESULT.Columns.Get("MARCAS"))
|
||||||
|
Starter.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("MARCAS"))
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("MARCAS",MARCAS))
|
||||||
|
Next
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
'CUOTAS
|
'CUOTAS
|
||||||
@@ -1669,13 +1709,14 @@ Sub JobDone(Job As HttpJob)
|
|||||||
Dim CAT_GP_ALMACEN As Int = records(RESULT.Columns.Get("CAT_GP_ALMACEN"))
|
Dim CAT_GP_ALMACEN As Int = records(RESULT.Columns.Get("CAT_GP_ALMACEN"))
|
||||||
Dim CAT_GP_TIPOPROD As Int = records(RESULT.Columns.Get("CAT_GP_TIPOPROD"))
|
Dim CAT_GP_TIPOPROD As Int = records(RESULT.Columns.Get("CAT_GP_TIPOPROD"))
|
||||||
Dim CAT_GP_VARREQ3 As Int = records(RESULT.Columns.Get("CAT_GP_VARREQ3"))
|
Dim CAT_GP_VARREQ3 As Int = records(RESULT.Columns.Get("CAT_GP_VARREQ3"))
|
||||||
|
Dim MARCA As String = records(RESULT.Columns.Get("MARCA"))
|
||||||
CAT_GP_TIPOPROD = "5"
|
CAT_GP_TIPOPROD = "5"
|
||||||
If CAT_GP_ID = "PAQUNI003" Then
|
If CAT_GP_ID = "PAQUNI003" Then
|
||||||
CAT_GP_ALMACEN = 60
|
CAT_GP_ALMACEN = 60
|
||||||
End If
|
End If
|
||||||
' Log("XXXXXXX gunaprodp XXXXXXXXX " & CAT_GP_ID & "|" & CAT_GP_IMP1 & "|" & CAT_GP_IMP2)
|
' Log("XXXXXXX gunaprodp XXXXXXXXX " & CAT_GP_ID & "|" & CAT_GP_IMP1 & "|" & CAT_GP_IMP2)
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CAT_GUNAPROD(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_TIPOPROD) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)", Array As Object (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_TIPOPROD))
|
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CAT_GUNAPROD(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_TIPOPROD,MARCA) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", Array As Object (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_TIPOPROD,MARCA))
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CAT_GUNAPROD2(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_TIPOPROD, CAT_GP_VARREQ3) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", Array As Object (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_TIPOPROD, CAT_GP_VARREQ3))
|
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CAT_GUNAPROD2(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_TIPOPROD, CAT_GP_VARREQ3,MARCA) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)", Array As Object (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_TIPOPROD, CAT_GP_VARREQ3,MARCA))
|
||||||
Next
|
Next
|
||||||
If PB2.Progress = 0 Then
|
If PB2.Progress = 0 Then
|
||||||
PB2.Progress = 30
|
PB2.Progress = 30
|
||||||
@@ -1795,7 +1836,9 @@ Sub JobDone(Job As HttpJob)
|
|||||||
Dim HVD_PRONOMBRE As String = records(RESULT.Columns.Get("HVD_PRONOMBRE"))
|
Dim HVD_PRONOMBRE As String = records(RESULT.Columns.Get("HVD_PRONOMBRE"))
|
||||||
Dim HVD_CANT As String = records(RESULT.Columns.Get("HVD_CANT"))
|
Dim HVD_CANT As String = records(RESULT.Columns.Get("HVD_CANT"))
|
||||||
Dim HVD_COSTO_TOT As String = records(RESULT.Columns.Get("HVD_COSTO_TOT"))
|
Dim HVD_COSTO_TOT As String = records(RESULT.Columns.Get("HVD_COSTO_TOT"))
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_VENTAS(HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT) VALUES (?,?,?,?)", Array As Object (HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT))
|
Dim HVD_USUARIO As String = records(RESULT.Columns.Get("USUARIO"))
|
||||||
|
Log(HVD_USUARIO)
|
||||||
|
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_VENTAS(HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT,HVD_USUARIO) VALUES (?,?,?,?,?)", Array As Object (HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT,HVD_USUARIO))
|
||||||
Next
|
Next
|
||||||
Listo3 =1
|
Listo3 =1
|
||||||
If PB1.Progress = 0 Then
|
If PB1.Progress = 0 Then
|
||||||
@@ -1985,11 +2028,11 @@ Sub JobDone(Job As HttpJob)
|
|||||||
Dim RESULT As DBResult = reqManager.HandleJob(Job)
|
Dim RESULT As DBResult = reqManager.HandleJob(Job)
|
||||||
If RESULT.Tag = "hist_avance" Then 'query tag
|
If RESULT.Tag = "hist_avance" Then 'query tag
|
||||||
For Each records() As Object In RESULT.Rows
|
For Each records() As Object In RESULT.Rows
|
||||||
Dim marca As String = records(RESULT.Columns.Get("HIST_AM_MARCA"))
|
Dim marca2 As String = records(RESULT.Columns.Get("HIST_AM_MARCA"))
|
||||||
Dim avance As String = records(RESULT.Columns.Get("HIST_AM_AVANCE"))
|
Dim avance As String = records(RESULT.Columns.Get("HIST_AM_AVANCE"))
|
||||||
Dim objetivo As String = records(RESULT.Columns.Get("HIST_AM_OBJETIVO"))
|
Dim objetivo As String = records(RESULT.Columns.Get("HIST_AM_OBJETIVO"))
|
||||||
Dim porcentaje1 As String = records(RESULT.Columns.Get("HIST_AM_PORCENTAJE"))
|
Dim porcentaje1 As String = records(RESULT.Columns.Get("HIST_AM_PORCENTAJE"))
|
||||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_AVANCE(HA_MARCA, HA_AVANCE, HA_OBJETIVO, HA_PORCENTAJE) VALUES (?,?,?,?)", Array As Object (marca, avance, objetivo, porcentaje1))
|
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_AVANCE(HA_MARCA, HA_AVANCE, HA_OBJETIVO, HA_PORCENTAJE) VALUES (?,?,?,?)", Array As Object (marca2, avance, objetivo, porcentaje1))
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
@@ -2052,6 +2095,16 @@ Sub JobDone(Job As HttpJob)
|
|||||||
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_CUESTIONARIO(HC_CLIENTE) VALUES (?)", Array As Object (idCliente))
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_CUESTIONARIO(HC_CLIENTE) VALUES (?)", Array As Object (idCliente))
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
If RESULT.Tag = "traeGeocerca" Then
|
||||||
|
For Each records() As Object In RESULT.Rows
|
||||||
|
Dim geocerca As String = records(RESULT.Columns.Get("CAT_RU_GEOCERCA"))
|
||||||
|
Log("-- geo: " & geocerca)
|
||||||
|
B4XPages.MainPage.skmt.ExecNonQuery2("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = ?", Array As Object ("GEOCERCA"))
|
||||||
|
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CAT_VARIABLES(CAT_VA_DESCRIPCION, CAT_VA_VALOR) VALUES (?,?)", Array As Object ("GEOCERCA", geocerca))
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
Job.Release
|
Job.Release
|
||||||
@@ -2111,7 +2164,7 @@ Sub connecta_Click
|
|||||||
Log(usrT)
|
Log(usrT)
|
||||||
Log(passT)
|
Log(passT)
|
||||||
cmd.Initialize
|
cmd.Initialize
|
||||||
cmd.Name = "select_usuario_INTMEX_10"
|
cmd.Name = "select_usuario_INTMEX_11"
|
||||||
cmd.Parameters = Array As Object(usrT, passT)
|
cmd.Parameters = Array As Object(usrT, passT)
|
||||||
reqManager.ExecuteQuery(cmd , 0, "usuarioA")
|
reqManager.ExecuteQuery(cmd , 0, "usuarioA")
|
||||||
End If
|
End If
|
||||||
@@ -2572,7 +2625,18 @@ Sub resdia_Click
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub hacer_ped_Click
|
Sub hacer_ped_Click
|
||||||
|
c = Starter.skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("MARCAS"))
|
||||||
|
c.Position = 0
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
Private MARCASQ As String = c.GetString("CAT_VA_VALOR")
|
||||||
|
c.Close
|
||||||
|
Starter.skmt.ExecNonQuery("delete from CAT_GUNAPROD WHERE CAT_GP_CLASIF NOT IN (" & MARCASQ &", 'PROMOS')" )
|
||||||
|
Starter.skmt.ExecNonQuery("delete from CAT_GUNAPROD WHERE CAT_GP_CLASIF IN ('PROMOS') AND MARCA NOT IN (" & MARCASQ &")" )
|
||||||
|
' Starter.skmt.ExecNonQuery("delete from CAT_GUNAPROD WHERE CAT_GP_ID NOT IN (SELECT CAT_DP_ID FROM CAT_DETALLES_PAQ WHERE CAT_DP_IDPROD NOT IN (SELECT CAT_GP_ID FROM CAT_GUNAPROD))")
|
||||||
B4XPages.ShowPage("Clientes")
|
B4XPages.ShowPage("Clientes")
|
||||||
|
Else
|
||||||
|
If Starter.marcaCel <> "LGE" Then ToastMessageShow("No hay marcas en la base de datos ... ya se cargo ruta??", True)
|
||||||
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub nvo_cliente_Click
|
Sub nvo_cliente_Click
|
||||||
@@ -2588,11 +2652,24 @@ Sub GPS_LocationChanged (Location1 As Location)
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Sub Btn_Ubicar_Click
|
Sub Btn_Ubicar_Click
|
||||||
|
c = Starter.skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("MARCAS"))
|
||||||
|
c.Position = 0
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
Private MARCASQ As String = c.GetString("CAT_VA_VALOR")
|
||||||
|
c.Close
|
||||||
|
Starter.skmt.ExecNonQuery("delete from CAT_GUNAPROD WHERE CAT_GP_CLASIF NOT IN (" & MARCASQ &", 'PROMOS')" )
|
||||||
|
Starter.skmt.ExecNonQuery("delete from CAT_GUNAPROD WHERE CAT_GP_CLASIF IN ('PROMOS') AND MARCA NOT IN (" & MARCASQ &")" )
|
||||||
|
' Starter.skmt.ExecNonQuery("delete from CAT_GUNAPROD WHERE CAT_GP_ID NOT IN (SELECT CAT_DP_ID FROM CAT_DETALLES_PAQ WHERE CAT_DP_IDPROD NOT IN (SELECT CAT_GP_ID FROM CAT_GUNAPROD))")
|
||||||
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
|
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||||
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||||
If Result Then
|
If Result Then
|
||||||
StartActivity(MAPA_RUTAS)
|
StartActivity(MAPA_RUTAS)
|
||||||
End If
|
End If
|
||||||
|
Else
|
||||||
|
If Starter.marcaCel <> "LGE" Then ToastMessageShow("No hay marcas en la base de datos ... ya se cargo ruta??", True)
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'''''''''''''''''''''''''''''''''''' VALIDAR CARACTERES
|
'''''''''''''''''''''''''''''''''''' VALIDAR CARACTERES
|
||||||
@@ -2947,3 +3024,126 @@ Private Sub B_PROM_Click
|
|||||||
End If
|
End If
|
||||||
c.Close
|
c.Close
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub l_conexion_LongClick
|
||||||
|
' enviaPedidoBatch_PRUEBA("todos")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
' 1. Recopila encabezados y detalles de pedidos locales (todos o solo los pendientes).
|
||||||
|
' 2. Genera un ID único (Arch) para vincular exactamente cada venta con sus productos.
|
||||||
|
' 3. Empaqueta todo en una lista de comandos (Batch) para enviarlo al servidor en una sola transacción.
|
||||||
|
Sub enviaPedidoBatch_PRUEBA(filtro As String)
|
||||||
|
' Creamos una lista llamada BatchCommands. Aquí vamos a guardar todas las instrucciones
|
||||||
|
' de base de datos que queremos mandar al servidor de un solo golpe (en lote o "batch").
|
||||||
|
Dim BatchCommands As List
|
||||||
|
BatchCommands.Initialize
|
||||||
|
LogColor("##############################################", Colors.Red)
|
||||||
|
LogColor($"### enviaPedidoBatch(${filtro})"$, Colors.red)
|
||||||
|
LogColor("##############################################", Colors.Red)
|
||||||
|
|
||||||
|
DateTime.TimeFormat = "HHmmss"
|
||||||
|
Private elFolio As String = DateTime.Time(DateTime.Now)
|
||||||
|
|
||||||
|
' Preparamos una variable para filtrar la consulta a la base de datos.
|
||||||
|
' Si el filtro no dice "Todos", armamos la condición para traer solo los pedidos que no se han enviado (PC_ENVIO_OK = 0).
|
||||||
|
Private condicion As String = ""
|
||||||
|
If filtro.ToUpperCase <> "TODOS" Then condicion = "where PC_ENVIO_OK = 0"
|
||||||
|
|
||||||
|
' Ejecutamos una consulta (Query) a la base de datos local de SQLite (skmt).
|
||||||
|
' Buscamos los ENCABEZADOS de los pedidos en la tabla PEDIDO_CLIENTE usando la condición que armamos arriba.
|
||||||
|
' El resultado se guarda en un Cursor llamado 'cx', que es como una tabla en memoria por la que podemos navegar.
|
||||||
|
Private cx As Cursor = Starter.skmt.ExecQuery($"SELECT PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT, PC_COSTO_SIN, PC_RUTA, PC_ALMACEN, PC_FACTURA, PC_ENVIO_OK FROM PEDIDO_CLIENTE ${condicion}"$)
|
||||||
|
Log($"SELECT PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT, PC_COSTO_SIN, PC_RUTA, PC_ALMACEN, PC_ENVIO_OK FROM PEDIDO_CLIENTE ${condicion}"$)
|
||||||
|
Log("pedido_cliente: " & cx.RowCount)
|
||||||
|
|
||||||
|
' Reiniciamos la variable de condición para usarla ahora en el DETALLE de los pedidos.
|
||||||
|
Private condicion As String = ""
|
||||||
|
If filtro.ToUpperCase <> "TODOS" Then condicion = "where PE_ENVIO_OK = 0"
|
||||||
|
|
||||||
|
' ' Verificamos si en la tabla de envíos históricos (HIST_ENVIOS) hay registros del tipo "ABORDO" (Ventas en ruta directa).
|
||||||
|
' c = Starter.skmt.ExecQuery2("SELECT COUNT(*) as CANTIDAD FROM HIST_ENVIOS WHERE HE_TIPO = ?",Array As String("ABORDO") )
|
||||||
|
' c.Position = 0
|
||||||
|
'
|
||||||
|
' ' Si encontramos que sí hay ventas a bordo...
|
||||||
|
' If c.GetString("CANTIDAD") > 0 Then
|
||||||
|
' Log($"pe_cedis_0"$)
|
||||||
|
' ' Actualizamos la tabla PEDIDO para que los artículos del cliente "0" (que suele ser el inventario a bordo)
|
||||||
|
' ' y que no tengan un número de folio, se marquen con el almacén/cedis "RECARGA".
|
||||||
|
' Starter.skmt.ExecNonQuery2("update PEDIDO set PE_CEDIS = ? where PE_CLIENTE =? AND PE_FOLIO IS NULL ", Array As Object("RECARGA", "0"))
|
||||||
|
' End If
|
||||||
|
|
||||||
|
' Hacemos una actualización rápida a los registros de PEDIDO que no tengan folio (folio 0 o 1).
|
||||||
|
' Les asignamos temporalmente el 'rowid' (el número de fila interno de SQLite) como folio para identificarlos.
|
||||||
|
Starter.skmt.ExecNonQuery("UPDATE PEDIDO SET PE_FOLIO = rowid where PE_FOLIO = 0 or PE_FOLIO = 1")
|
||||||
|
|
||||||
|
' Revisamos si nuestro cursor 'cx' (los encabezados de pedido) trajo algún resultado.
|
||||||
|
If cx.RowCount > 0 Then ' Si hay pedido entonces lo enviamos.
|
||||||
|
|
||||||
|
' Iniciamos un bucle (For) para recorrer cada uno de los encabezados de pedido encontrados.
|
||||||
|
For j = 0 To cx.RowCount - 1
|
||||||
|
Log("===== ENVIAMOS PRODUCTOS DE PEDIDO =====")
|
||||||
|
' Movemos el cursor 'cx' a la posición 'j' actual del bucle.
|
||||||
|
cx.Position = j
|
||||||
|
|
||||||
|
' Generamos un identificador único (Arch) concatenando el almacén, la ruta, el cliente y la fecha/hora actual.
|
||||||
|
' Esto sirve para agrupar en el servidor el encabezado con sus respectivos detalles.
|
||||||
|
Dim Arch As String = Subs.traeAlmacen & "_" & Subs.traeRuta & "_" & cx.GetString("PC_CLIENTE") & "_" & DateTime.Now
|
||||||
|
|
||||||
|
' Preparamos un comando de base de datos (DBCommand) para mandar al servidor.
|
||||||
|
Dim cmdHeader As DBCommand
|
||||||
|
cmdHeader.Initialize
|
||||||
|
' Asignamos el nombre del procedimiento almacenado o query que está en el servidor (jRDC2).
|
||||||
|
cmdHeader.Name = "insert_pedidos_INTMEX_arch"
|
||||||
|
' Pasamos los parámetros leyendo los datos del cursor 'cx' (encabezado) y le pasamos el ID único 'Arch'.
|
||||||
|
cmdHeader.Parameters = Array As Object(cx.GetString("PC_CLIENTE"),cx.GetString("PC_FECHA"),cx.GetString("PC_USER"),cx.GetString("PC_NOART"),cx.GetString("PC_MONTO"),cx.GetString("PC_LON"),cx.GetString("PC_LAT"),ALMACEN,l_ruta.text,cx.GetString("PC_COSTO_SIN"), cx.GetString("PC_FACTURA"), $"${Application.VersionName}|${elFolio}"$, Arch)
|
||||||
|
Log($"${cx.GetString("PC_CLIENTE")},${cx.GetString("PC_FECHA")},${cx.GetString("PC_USER")},${cx.GetString("PC_NOART")},${cx.GetString("PC_MONTO")},${cx.GetString("PC_LON")},${cx.GetString("PC_LAT")},${ALMACEN},${l_ruta.text},${cx.GetString("PC_COSTO_SIN")}, ${cx.GetString("PC_FACTURA")}, ${Application.VersionName}|${elFolio}, ${Arch}"$)
|
||||||
|
' cmd.Name = "insert_pedidos5_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"), ALMACEN, l_ruta.text, c.GetString("PC_COSTO_SIN"), c.GetString("PC_FACTURA"), $"${Application.VersionName}|${elFolio}"$)
|
||||||
|
|
||||||
|
' Añadimos este comando a nuestra lista del lote (Batch).
|
||||||
|
BatchCommands.Add(cmdHeader)
|
||||||
|
|
||||||
|
' Ahora hacemos una consulta para buscar el DETALLE de este pedido (los productos individuales).
|
||||||
|
' Filtramos por la condición (si se envió o no) y lo amarramos al cliente actual del bucle (PC_CLIENTE).
|
||||||
|
Private cPed As Cursor = Starter.skmt.ExecQuery($"SELECT (Select PC_NOART from pedido_cliente where pe_cliente = pc_cliente) As PCNoArts, (Select PC_MONTO from pedido_cliente where pe_cliente = pc_cliente) As PCMonto, * FROM PEDIDO ${condicion} ${(IIf(condicion = "","where", "and"))} pe_cliente = '${cx.GetString("PC_CLIENTE")}' "$)
|
||||||
|
Log($"SELECT (Select PC_NOART from pedido_cliente where pe_cliente = pc_cliente) As PCNoArts, (Select PC_MONTO from pedido_cliente where pe_cliente = pc_cliente) As PCMonto, * FROM PEDIDO ${condicion} ${(IIf(condicion = "","where", "and"))} pe_cliente = '${cx.GetString("PC_CLIENTE")}' "$)
|
||||||
|
Log("Productos sin enviar: " & cPed.RowCount)
|
||||||
|
' Si hay detalles para este encabezado...
|
||||||
|
If cPed.RowCount > 0 Then
|
||||||
|
|
||||||
|
' Iniciamos un bucle interno para recorrer cada producto de este pedido.
|
||||||
|
For i = 0 To cPed.RowCount - 1
|
||||||
|
Log("==== ENVIAMOS PRODS ====")
|
||||||
|
' Movemos el cursor de detalles a la posición actual.
|
||||||
|
cPed.Position = i
|
||||||
|
|
||||||
|
' Preparamos el comando para enviar este producto al servidor.
|
||||||
|
Dim cmdDetail As DBCommand
|
||||||
|
cmdDetail.Initialize
|
||||||
|
|
||||||
|
' Si es un vendedor normal, usa el comando estándar para insertar el detalle
|
||||||
|
' y le pasa la misma variable 'Arch' para que en el servidor sepa de qué encabezado es.
|
||||||
|
cmdDetail.Name = "insert_pedido_INTMEX_arch"
|
||||||
|
cmdDetail.Parameters = Array As Object(cPed.GetString("PE_CEDIS"),ALMACEN,cPed.GetString("PE_COSTO_TOT"),cPed.GetString("PE_COSTOU"),cPed.GetString("PE_CANT"),cPed.GetString("PE_PRONOMBRE"),cPed.GetString("PE_PROID"),cPed.GetString("PE_CLIENTE"),cPed.GetString("PE_FECHA"),cPed.GetString("PE_USUARIO"),cPed.GetString("PE_RUTA"), cPed.GetString("PE_COSTO_SIN"),cPed.GetString("PE_DESC"),cPed.GetString("PE_FOLIO"), cPed.GetString("PCNoArts"), cPed.GetString("PCMonto"), cPed.GetString("PE_TICKET"), elFolio, Arch)
|
||||||
|
Log($"ProdsPedido ==> (${cPed.GetString("PE_CEDIS")}, ${ALMACEN}, ${cPed.GetString("PE_COSTO_TOT")}, ${cPed.GetString("PE_COSTOU")}, $cPed.GetString("PE_CANT")}, ${cPed.GetString("PE_PRONOMBRE")}, ${cPed.GetString("PE_PROID")}, ${cPed.GetString("PE_CLIENTE")}, ${cPed.GetString("PE_FECHA")}, ${cPed.GetString("PE_USUARIO")}, ${cPed.GetString("PE_RUTA")}, ${cPed.GetString("PE_COSTO_SIN")}, ${cPed.GetString("PE_DESC")}, ${cPed.GetString("PE_FOLIO")}, ${cPed.GetString("PCNoArts")}, ${cPed.GetString("PCMonto")}, ${cPed.GetString("PE_TICKET")}, ${elFolio}, ${Arch}"$)
|
||||||
|
|
||||||
|
' cmd.Name = "insert_pedido5_INTMEX" 'CON TOTALES INCLUIDOS
|
||||||
|
' cmd.Parameters = Array As Object(C.GetString("PE_CEDIS"),ALMACEN,C.GetString("PE_COSTO_TOT"),C.GetString("PE_COSTOU"),C.GetString("PE_CANT"),C.GetString("PE_PRONOMBRE"),C.GetString("PE_PROID"),C.GetString("PE_CLIENTE"),C.GetString("PE_FECHA"),C.GetString("PE_USUARIO"),C.GetString("PE_RUTA"), C.GetString("PE_COSTO_SIN"),C.GetString("PE_DESC"),c.GetString("PE_FOLIO"), c.GetString("PCNoArts"), c.GetString("PCMonto"), c.GetString("PE_TICKET"), elFolio)
|
||||||
|
|
||||||
|
' Añadimos la instrucción del producto al lote de envío.
|
||||||
|
BatchCommands.Add(cmdDetail)
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
|
||||||
|
' Al terminar de empaquetar, enviamos toda la lista de instrucciones (BatchCommands) al servidor de un solo golpe.
|
||||||
|
' Se le asigna un nombre de etiqueta (Tag) para saber qué responderá el JobDone ("pedido_completo_" + id de cliente).
|
||||||
|
' (Ojo visual para el programador: Esta línea está dentro del 'If' general, pero también después de armar los batches en el bucle 'For'. Al procesar el último item del bucle cx, tomará el ID del último cliente para el Tag).
|
||||||
|
reqManager.ExecuteBatch(BatchCommands, "pedido_completo_" & cx.GetString("PC_CLIENTE"))
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Por buena práctica y para evitar fugas de memoria (memory leaks),
|
||||||
|
' cerramos siempre los cursores que abrimos hacia la base de datos local.
|
||||||
|
c.Close
|
||||||
|
cx.Close
|
||||||
|
End Sub
|
||||||
|
|||||||
@@ -820,7 +820,7 @@ Sub b_terminar1_Click
|
|||||||
|
|
||||||
' ListView1.AddSingleLine(cs.Color(textColor).Size(12).append(c.GetString("PE_PRONOMBRE") & " ").pop.Append(CRLF).Size(8).Color(Colors.Blue).Append("Cantidad #"& c.GetString("PE_CANT")).Append(" SubTotal $"& c.GetString("PE_COSTO_TOT")).Append(" " & c.GetString("PE_FOLIO")& " " &c.GetString("PE_CEDIS")).PopAll)
|
' ListView1.AddSingleLine(cs.Color(textColor).Size(12).append(c.GetString("PE_PRONOMBRE") & " ").pop.Append(CRLF).Size(8).Color(Colors.Blue).Append("Cantidad #"& c.GetString("PE_CANT")).Append(" SubTotal $"& c.GetString("PE_COSTO_TOT")).Append(" " & c.GetString("PE_FOLIO")& " " &c.GetString("PE_CEDIS")).PopAll)
|
||||||
lv_prodsPedido.AddSingleLine(cs.Color(textColor).Size(12).append(c_prods.GetString("PE_PRONOMBRE") & " ").pop.Append(CRLF).Size(8).Color(Colors.Blue).Append("Cantidad #"& c_prods.GetString("PE_CANT")).Append(" SubTotal $"& c_prods.GetString("PE_COSTO_TOT")).Append(" " & c_prods.GetString("PE_FOLIO")& " " &c_prods.GetString("PE_CEDIS")).PopAll)
|
lv_prodsPedido.AddSingleLine(cs.Color(textColor).Size(12).append(c_prods.GetString("PE_PRONOMBRE") & " ").pop.Append(CRLF).Size(8).Color(Colors.Blue).Append("Cantidad #"& c_prods.GetString("PE_CANT")).Append(" SubTotal $"& c_prods.GetString("PE_COSTO_TOT")).Append(" " & c_prods.GetString("PE_FOLIO")& " " &c_prods.GetString("PE_CEDIS")).PopAll)
|
||||||
Log(c_prods.GetString("PE_PRONOMBRE"))
|
' Log(c_prods.GetString("PE_PRONOMBRE"))
|
||||||
vamoaver.Add(c_prods.GetString("PE_FOLIO"))
|
vamoaver.Add(c_prods.GetString("PE_FOLIO"))
|
||||||
folio = c_prods.GetString("PE_FOLIO")
|
folio = c_prods.GetString("PE_FOLIO")
|
||||||
Next
|
Next
|
||||||
@@ -1115,7 +1115,7 @@ Private Sub clv_prods_ll_VisibleRangeChanged (FirstIndex As Int, LastIndex As In
|
|||||||
b_prodMenos.Enabled = False
|
b_prodMenos.Enabled = False
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
' Log(clv_prods_ll.GetValue(i))
|
' Log("|"&clv_prods_ll.GetValue(i)&"|")
|
||||||
Private precio As String=NumberFormat2(clv_prods_ll.GetValue(i).As(Map).Get("precio").As(Double),1,2,2,False)
|
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")
|
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
|
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
|
||||||
@@ -1133,8 +1133,6 @@ Private Sub clv_prods_ll_VisibleRangeChanged (FirstIndex As Int, LastIndex As In
|
|||||||
Next
|
Next
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Sub Busca_TextChanged (Old As String, New As String)
|
Sub Busca_TextChanged (Old As String, New As String)
|
||||||
' Private inicioContador As String = DateTime.Now
|
' Private inicioContador As String = DateTime.Now
|
||||||
|
|
||||||
@@ -1269,7 +1267,12 @@ Sub LlenaProdsLL(p As ResultSet)
|
|||||||
If tipoRuta = "MAYOREO" Then
|
If tipoRuta = "MAYOREO" Then
|
||||||
LogColor("####### RUTA MAYOREO ###########", Colors.red)
|
LogColor("####### RUTA MAYOREO ###########", Colors.red)
|
||||||
' Log($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO10 as CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Starter.tabla} where CAT_GP_PRECIO10 > 0 And CAT_GP_ALMACEN > 0 And CAT_GP_CLASIF <> 'PROMOS' union all select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO10 as CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Starter.tabla} where CAT_GP_PRECIO10 > 0 And CAT_GP_ALMACEN = 0 And CAT_GP_CLASIF <> 'PROMOS' and cat_gp_id in (select pe_proid from pedido where pe_cliente in (select cuenta from cuentaa)) order by 2"$)
|
' Log($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO10 as CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Starter.tabla} where CAT_GP_PRECIO10 > 0 And CAT_GP_ALMACEN > 0 And CAT_GP_CLASIF <> 'PROMOS' union all select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO10 as CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Starter.tabla} where CAT_GP_PRECIO10 > 0 And CAT_GP_ALMACEN = 0 And CAT_GP_CLASIF <> 'PROMOS' and cat_gp_id in (select pe_proid from pedido where pe_cliente in (select cuenta from cuentaa)) order by 2"$)
|
||||||
Dim p As ResultSet = B4XPages.MainPage.skmt.ExecQuery($"select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO10 as CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Starter.tabla} where CAT_GP_PRECIO10 > 0 And CAT_GP_ALMACEN > 0 And CAT_GP_CLASIF <> 'PROMOS' union all select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO10 as CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Starter.tabla} where CAT_GP_PRECIO10 > 0 And CAT_GP_ALMACEN = 0 And CAT_GP_CLASIF <> 'PROMOS' and cat_gp_id in (select pe_proid from pedido where pe_cliente in (select cuenta from cuentaa)) order by 2"$)
|
Dim p As ResultSet = B4XPages.MainPage.skmt.ExecQuery($"
|
||||||
|
select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO10 as CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Starter.tabla}
|
||||||
|
where CAT_GP_PRECIO10 > 0 And CAT_GP_ALMACEN > 0 And CAT_GP_CLASIF <> 'PROMOS'
|
||||||
|
union all
|
||||||
|
select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO10 as CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Starter.tabla}
|
||||||
|
where CAT_GP_PRECIO10 > 0 And CAT_GP_ALMACEN = 0 And CAT_GP_CLASIF <> 'PROMOS' and cat_gp_id in (select pe_proid from pedido where pe_cliente in (select cuenta from cuentaa)) order by 2"$)
|
||||||
Else
|
Else
|
||||||
LogColor("####### RUTA TRADICIONAL ###########", Colors.red)
|
LogColor("####### RUTA TRADICIONAL ###########", Colors.red)
|
||||||
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 ${Starter.tabla} where CAT_GP_PRECIO > 0 And CAT_GP_ALMACEN > 0 And CAT_GP_CLASIF <> 'PROMOS' union all select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Starter.tabla} where CAT_GP_PRECIO > 0 And CAT_GP_ALMACEN = 0 And CAT_GP_CLASIF <> 'PROMOS' and cat_gp_id in (select pe_proid from pedido where pe_cliente in (select cuenta from cuentaa)) order by 2"$)
|
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 ${Starter.tabla} where CAT_GP_PRECIO > 0 And CAT_GP_ALMACEN > 0 And CAT_GP_CLASIF <> 'PROMOS' union all select CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_ALMACEN, CAT_GP_PRECIO, CAT_GP_TIPOPROD from ${Starter.tabla} where CAT_GP_PRECIO > 0 And CAT_GP_ALMACEN = 0 And CAT_GP_CLASIF <> 'PROMOS' and cat_gp_id in (select pe_proid from pedido where pe_cliente in (select cuenta from cuentaa)) order by 2"$)
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ Public Sub Initialize As Object
|
|||||||
rkmt.ExecNonQuery($"create table if not exists paquetes (cat_dp_precio_simptos TEXT, cat_dp_precio TEXT, cat_dp_almacen TEXT, cat_dp_id TEXT, cat_dp_idprod TEXT, cat_dp_tipo TEXT, cat_dp_pzas TEXT, cat_dp_usuario TEXT, cat_dp_fecha TEXT, cat_dp_regalo TEXT, cat_dp_clasif TEXT, fecha TEXT)"$)
|
rkmt.ExecNonQuery($"create table if not exists paquetes (cat_dp_precio_simptos TEXT, cat_dp_precio TEXT, cat_dp_almacen TEXT, cat_dp_id TEXT, cat_dp_idprod TEXT, cat_dp_tipo TEXT, cat_dp_pzas TEXT, cat_dp_usuario TEXT, cat_dp_fecha TEXT, cat_dp_regalo TEXT, cat_dp_clasif TEXT, fecha TEXT)"$)
|
||||||
agregaColumna("pedidos", "pe_ticket", "INT")
|
agregaColumna("pedidos", "pe_ticket", "INT")
|
||||||
agregaColumna("pedidos", "pe_guardado", "TEXT")
|
agregaColumna("pedidos", "pe_guardado", "TEXT")
|
||||||
|
agregaColumna("pedidos", "pe_arch", "TEXT")
|
||||||
DateTime.DateFormat = "MM/dd/yyyy"
|
DateTime.DateFormat = "MM/dd/yyyy"
|
||||||
fechaHoy = DateTime.Date(DateTime.Now)
|
fechaHoy = DateTime.Date(DateTime.Now)
|
||||||
revisaSkmtAttached
|
revisaSkmtAttached
|
||||||
@@ -87,7 +88,7 @@ Sub respaldaPedido
|
|||||||
Log("copiando pedidos ...")
|
Log("copiando pedidos ...")
|
||||||
rkmt.BeginTransaction
|
rkmt.BeginTransaction
|
||||||
rkmt.ExecNonQuery($"delete from pedidos where substr(pe_fecha, 1, 10) = '${fechaHoy}'"$)
|
rkmt.ExecNonQuery($"delete from pedidos where substr(pe_fecha, 1, 10) = '${fechaHoy}'"$)
|
||||||
rkmt.ExecNonQuery($"insert into pedidos (pe_folio, pe_desc, pe_costo_sin, pe_ruta, pe_cedis, pe_costo_tot, pe_costou, pe_cant, pe_pronombre, pe_proid, pe_cliente, pe_fecha, pe_usuario, pe_envio_ok, pe_ticket, pe_guardado) select * from skmt1.pedido where substr(pe_fecha, 1, 10) = '${fechaHoy}'"$)
|
rkmt.ExecNonQuery($"insert into pedidos (pe_folio, pe_desc, pe_costo_sin, pe_ruta, pe_cedis, pe_costo_tot, pe_costou, pe_cant, pe_pronombre, pe_proid, pe_cliente, pe_fecha, pe_usuario, pe_envio_ok, pe_ticket, pe_guardado, pe_arch) select * from skmt1.pedido where substr(pe_fecha, 1, 10) = '${fechaHoy}'"$)
|
||||||
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
rkmt.TransactionSuccessful 'Si no se pone TransactionSuccessful no se escribe NADA!!
|
||||||
rkmt.EndTransaction
|
rkmt.EndTransaction
|
||||||
' Log(((DateTime.Now - inicio)/1000) & " segs")
|
' Log(((DateTime.Now - inicio)/1000) & " segs")
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ End Sub
|
|||||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||||
|
|
||||||
Sub iniciaValidacion
|
Sub iniciaValidacion
|
||||||
Log("INICIAMOS VALIDACIONES DE PEDIDOS")
|
LogColor("##############################################", Colors.Red)
|
||||||
|
LogColor("##### INICIAMOS VALIDACIONES DE PEDIDOS", Colors.Red)
|
||||||
|
LogColor("##############################################", Colors.Red)
|
||||||
|
Sleep(2000)
|
||||||
mandaGuardados
|
mandaGuardados
|
||||||
Sleep(5000)
|
Sleep(5000)
|
||||||
revisaGuardados
|
revisaGuardados
|
||||||
@@ -74,8 +77,10 @@ Sub buscaSinEnviar As Int
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
'Manda a web los pedidos GUARDADOS con ENVIO_OK = 0 y los pone en 1.
|
'Manda a web los pedidos GUARDADOS con ENVIO_OK = 0 y los pone en 1.
|
||||||
Sub mandaGuardados
|
Sub mandaGuardados0
|
||||||
Log(">>>>>>> MANDA GUARDADOS")
|
LogColor("##############################################", Colors.Red)
|
||||||
|
LogColor("#### MANDA GUARDADOS", Colors.red)
|
||||||
|
LogColor("##############################################", Colors.Red)
|
||||||
' PEDIDO_CLIENTE (Pendientes)
|
' PEDIDO_CLIENTE (Pendientes)
|
||||||
' Dim PCNoArts As String
|
' Dim PCNoArts As String
|
||||||
' Dim PCMonto As String
|
' Dim PCMonto As String
|
||||||
@@ -117,9 +122,112 @@ Sub mandaGuardados
|
|||||||
c.Close
|
c.Close
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
'Manda a web los pedidos GUARDADOS con ENVIO_OK = 0 y los pone en 1 (BATCH)
|
||||||
|
Sub mandaGuardados
|
||||||
|
' Creamos una lista llamada BatchCommands. Aquí vamos a guardar todas las instrucciones
|
||||||
|
' de base de datos que queremos mandar al servidor de un solo golpe (en lote o "batch").
|
||||||
|
Dim BatchCommands As List
|
||||||
|
BatchCommands.Initialize
|
||||||
|
LogColor("##############################################", Colors.Red)
|
||||||
|
LogColor($"### enviaPedidoBatch"$, Colors.red)
|
||||||
|
LogColor("##############################################", Colors.Red)
|
||||||
|
|
||||||
|
DateTime.TimeFormat = "HHmmss"
|
||||||
|
Private elFolio As String = DateTime.Time(DateTime.Now)
|
||||||
|
Private almacen As String = Subs.traeAlmacen
|
||||||
|
|
||||||
|
' Preparamos una variable para filtrar la consulta a la base de datos.
|
||||||
|
' Si el filtro no dice "Todos", armamos la condición para traer solo los pedidos que no se han enviado (PC_ENVIO_OK = 0).
|
||||||
|
' Private condicion As String = ""
|
||||||
|
' If filtro.ToUpperCase <> "TODOS" Then condicion = "where PC_ENVIO_OK = 0"
|
||||||
|
|
||||||
|
' Ejecutamos una consulta (Query) a la base de datos local de SQLite (skmt).
|
||||||
|
' Buscamos los ENCABEZADOS de los pedidos en la tabla PEDIDO_CLIENTE.
|
||||||
|
' Private cx As Cursor = Starter.skmt.ExecQuery($"SELECT PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT, PC_COSTO_SIN, PC_RUTA, PC_ALMACEN, PC_FACTURA, PC_ENVIO_OK FROM PEDIDO_CLIENTE ${condicion}"$)
|
||||||
|
Private cx As Cursor = Starter.skmt.ExecQuery("SELECT * FROM PEDIDO_CLIENTE where PC_ENVIO_OK < 2 and PC_GUARDADO = 1")
|
||||||
|
' Log($"SELECT PC_CLIENTE, PC_FECHA, PC_USER, PC_NOART, PC_MONTO,PC_LON, PC_LAT, PC_COSTO_SIN, PC_RUTA, PC_ALMACEN, PC_ENVIO_OK FROM PEDIDO_CLIENTE ${condicion}"$)
|
||||||
|
Log("SELECT * FROM PEDIDO_CLIENTE where PC_ENVIO_OK < 2 and PC_GUARDADO = 1")
|
||||||
|
Log("pedido_cliente: " & cx.RowCount)
|
||||||
|
|
||||||
|
' Reiniciamos la variable de condición para usarla ahora en el DETALLE de los pedidos.
|
||||||
|
' Private condicion As String = ""
|
||||||
|
' If filtro.ToUpperCase <> "TODOS" Then condicion = "where PE_ENVIO_OK = 0"
|
||||||
|
|
||||||
|
' Revisamos si nuestro cursor 'cx' (los encabezados de pedido) trajo algún resultado.
|
||||||
|
If cx.RowCount > 0 Then ' Si hay pedido entonces lo enviamos.
|
||||||
|
|
||||||
|
' Iniciamos un bucle (For) para recorrer cada uno de los encabezados de pedido encontrados.
|
||||||
|
For j = 0 To cx.RowCount - 1
|
||||||
|
Log("===== ENVIAMOS PRODUCTOS DE PEDIDO =====")
|
||||||
|
' Movemos el cursor 'cx' a la posición 'j' actual del bucle.
|
||||||
|
cx.Position = j
|
||||||
|
|
||||||
|
' Generamos un identificador único (Arch) concatenando el almacén, la ruta, el cliente y la fecha/hora actual.
|
||||||
|
' Esto sirve para agrupar en el servidor el encabezado con sus respectivos detalles.
|
||||||
|
Dim Arch As String = Subs.traeAlmacen & "_" & Subs.traeRuta & "_" & cx.GetString("PC_CLIENTE") & "_" & DateTime.Now
|
||||||
|
|
||||||
|
' Preparamos un comando de base de datos (DBCommand) para mandar al servidor.
|
||||||
|
Dim cmdHeader As DBCommand
|
||||||
|
cmdHeader.Initialize
|
||||||
|
' Asignamos el nombre del procedimiento almacenado o query que está en el servidor (jRDC2).
|
||||||
|
cmdHeader.Name = "insert_pedidos_INTMEX_arch"
|
||||||
|
' Pasamos los parámetros leyendo los datos del cursor 'cx' (encabezado) y le pasamos el ID único 'Arch'.
|
||||||
|
cmdHeader.Parameters = Array As Object(cx.GetString("PC_CLIENTE"),cx.GetString("PC_FECHA"),cx.GetString("PC_USER"),cx.GetString("PC_NOART"),cx.GetString("PC_MONTO"),cx.GetString("PC_LON"),cx.GetString("PC_LAT"),almacen,B4XPages.MainPage.principal.l_ruta.text,cx.GetString("PC_COSTO_SIN"), cx.GetString("PC_FACTURA"), $"${Application.VersionName}|${elFolio}"$, Arch)
|
||||||
|
Log($"${cx.GetString("PC_CLIENTE")},${cx.GetString("PC_FECHA")},${cx.GetString("PC_USER")},${cx.GetString("PC_NOART")},${cx.GetString("PC_MONTO")},${cx.GetString("PC_LON")},${cx.GetString("PC_LAT")},${almacen},${B4XPages.MainPage.principal.l_ruta.text},${cx.GetString("PC_COSTO_SIN")}, ${cx.GetString("PC_FACTURA")}, ${Application.VersionName}|${elFolio}, ${Arch}"$)
|
||||||
|
' cmd.Name = "insert_pedidos5_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"), ALMACEN, l_ruta.text, c.GetString("PC_COSTO_SIN"), c.GetString("PC_FACTURA"), $"${Application.VersionName}|${elFolio}"$)
|
||||||
|
|
||||||
|
' Añadimos este comando a nuestra lista del lote (Batch).
|
||||||
|
BatchCommands.Add(cmdHeader)
|
||||||
|
|
||||||
|
' Ahora hacemos una consulta para buscar el DETALLE de este pedido (los productos individuales).
|
||||||
|
' Private cPed As Cursor = Starter.skmt.ExecQuery($"SELECT (Select PC_NOART from pedido_cliente where pe_cliente = pc_cliente) As PCNoArts, (Select PC_MONTO from pedido_cliente where pe_cliente = pc_cliente) As PCMonto, * FROM PEDIDO where pe_cliente = '${cx.GetString("PC_CLIENTE")}' "$)
|
||||||
|
Private cPed As Cursor = Starter.skmt.ExecQuery($"Select (Select PC_NOART from pedido_cliente where pe_cliente = pc_cliente) As PCNoArts, (Select PC_MONTO from pedido_cliente where pe_cliente = pc_cliente) As PCMonto, * FROM PEDIDO where PE_ENVIO_OK < 2 And PE_GUARDADO = 1 and pe_cliente = '${cx.GetString("PC_CLIENTE")}'"$)
|
||||||
|
|
||||||
|
Log($"Select (Select PC_NOART from pedido_cliente where pe_cliente = pc_cliente) As PCNoArts, (Select PC_MONTO from pedido_cliente where pe_cliente = pc_cliente) As PCMonto, * FROM PEDIDO where PE_ENVIO_OK < 2 And PE_GUARDADO = 1 and pe_cliente = '${cx.GetString("PC_CLIENTE")}'"$)
|
||||||
|
Log("Productos sin enviar: " & cPed.RowCount)
|
||||||
|
' Si hay detalles para este encabezado...
|
||||||
|
If cPed.RowCount > 0 Then
|
||||||
|
|
||||||
|
' Iniciamos un bucle interno para recorrer cada producto de este pedido.
|
||||||
|
For i = 0 To cPed.RowCount - 1
|
||||||
|
Log("==== ENVIAMOS PRODS ====")
|
||||||
|
' Movemos el cursor de detalles a la posición actual.
|
||||||
|
cPed.Position = i
|
||||||
|
|
||||||
|
' Preparamos el comando para enviar este producto al servidor.
|
||||||
|
Dim cmdDetail As DBCommand
|
||||||
|
cmdDetail.Initialize
|
||||||
|
|
||||||
|
' Si es un vendedor normal, usa el comando estándar para insertar el detalle
|
||||||
|
' y le pasa la misma variable 'Arch' para que en el servidor sepa de qué encabezado es.
|
||||||
|
cmdDetail.Name = "insert_pedido_INTMEX_arch"
|
||||||
|
cmdDetail.Parameters = Array As Object(cPed.GetString("PE_CEDIS"),almacen,cPed.GetString("PE_COSTO_TOT"),cPed.GetString("PE_COSTOU"),cPed.GetString("PE_CANT"),cPed.GetString("PE_PRONOMBRE"),cPed.GetString("PE_PROID"),cPed.GetString("PE_CLIENTE"),cPed.GetString("PE_FECHA"),cPed.GetString("PE_USUARIO"),cPed.GetString("PE_RUTA"), cPed.GetString("PE_COSTO_SIN"),cPed.GetString("PE_DESC"),cPed.GetString("PE_FOLIO"), cPed.GetString("PCNoArts"), cPed.GetString("PCMonto"), cPed.GetString("PE_TICKET"), elFolio, Arch)
|
||||||
|
Log($"ProdsPedido ==> (${cPed.GetString("PE_CEDIS")}, ${almacen}, ${cPed.GetString("PE_COSTO_TOT")}, ${cPed.GetString("PE_COSTOU")}, $cPed.GetString("PE_CANT")}, ${cPed.GetString("PE_PRONOMBRE")}, ${cPed.GetString("PE_PROID")}, ${cPed.GetString("PE_CLIENTE")}, ${cPed.GetString("PE_FECHA")}, ${cPed.GetString("PE_USUARIO")}, ${cPed.GetString("PE_RUTA")}, ${cPed.GetString("PE_COSTO_SIN")}, ${cPed.GetString("PE_DESC")}, ${cPed.GetString("PE_FOLIO")}, ${cPed.GetString("PCNoArts")}, ${cPed.GetString("PCMonto")}, ${cPed.GetString("PE_TICKET")}, ${elFolio}, ${Arch}"$)
|
||||||
|
|
||||||
|
' Añadimos la instrucción del producto al lote de envío.
|
||||||
|
BatchCommands.Add(cmdDetail)
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Al terminar de empaquetar, enviamos toda la lista de instrucciones (BatchCommands) al servidor de un solo golpe.
|
||||||
|
' Se le asigna un nombre de etiqueta (Tag) para saber qué responderá el JobDone ("pedido_completo_" + id de cliente).
|
||||||
|
' (Ojo visual para el programador: Esta línea está dentro del 'If' general, pero también después de armar los batches en el bucle 'For'. Al procesar el último item del bucle cx, tomará el ID del último cliente para el Tag).
|
||||||
|
reqManager.ExecuteBatch(BatchCommands, "pedido_completo_" & cx.GetString("PC_CLIENTE"))
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Por buena práctica y para evitar fugas de memoria (memory leaks),
|
||||||
|
' cerramos siempre los cursores que abrimos hacia la base de datos local.
|
||||||
|
' c.Close
|
||||||
|
cx.Close
|
||||||
|
End Sub
|
||||||
|
|
||||||
'Revisa que los pedidos con envio_ok < 2 esten completos en web y los pone en 2.
|
'Revisa que los pedidos con envio_ok < 2 esten completos en web y los pone en 2.
|
||||||
Sub revisaGuardados
|
Sub revisaGuardados
|
||||||
Log(">>>>>>> VALIDA GUARDADOS")
|
LogColor("##############################################", Colors.Red)
|
||||||
|
LogColor("##### VALIDA GUARDADOS", Colors.red)
|
||||||
|
LogColor("##############################################", Colors.Red)
|
||||||
'' Dim PCNoArts As String
|
'' Dim PCNoArts As String
|
||||||
'' Dim PCMonto As String
|
'' Dim PCMonto As String
|
||||||
Private almacen As String = Subs.traeAlmacen
|
Private almacen As String = Subs.traeAlmacen
|
||||||
@@ -180,7 +288,9 @@ End Sub
|
|||||||
'Revisa que coincidan las cantidades y montos totales de los pedidos en web y locales, y si coinciden, pone PC_ENVIO_OK en 3 (en JobDone).
|
'Revisa que coincidan las cantidades y montos totales de los pedidos en web y locales, y si coinciden, pone PC_ENVIO_OK en 3 (en JobDone).
|
||||||
'Si No coinciden, pone en CERO PC_ENVIO_OK y PE_ENVIO_OK y reinicia el proceso de validacion.
|
'Si No coinciden, pone en CERO PC_ENVIO_OK y PE_ENVIO_OK y reinicia el proceso de validacion.
|
||||||
Sub revisaCantsYMontosTotales
|
Sub revisaCantsYMontosTotales
|
||||||
Log(">>>>>>> VALIDA CANTIDADES Y MONTOS")
|
LogColor("##############################################", Colors.Red)
|
||||||
|
Logcolor("###### VALIDA CANTIDADES Y MONTOS", Colors.red)
|
||||||
|
LogColor("##############################################", Colors.Red)
|
||||||
Private almacen As String = Subs.traeAlmacen
|
Private almacen As String = Subs.traeAlmacen
|
||||||
Private laRuta As String = Subs.traeRuta
|
Private laRuta As String = Subs.traeRuta
|
||||||
c = skmt.ExecQuery("SELECT * FROM PEDIDO_CLIENTE where PC_ENVIO_OK = 2 or 1") ' El uno del final es para que SIEMPRE revise las cantidades y montos, por si se borra la orden desde web, para que se envíe NUEVAMENTE.
|
c = skmt.ExecQuery("SELECT * FROM PEDIDO_CLIENTE where PC_ENVIO_OK = 2 or 1") ' El uno del final es para que SIEMPRE revise las cantidades y montos, por si se borra la orden desde web, para que se envíe NUEVAMENTE.
|
||||||
@@ -230,6 +340,7 @@ Sub JobDone(Job As HttpJob)
|
|||||||
Next
|
Next
|
||||||
' pedidoGuardando("Listo")
|
' pedidoGuardando("Listo")
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' PEDIDOS GUARDADOS PRODS
|
' PEDIDOS GUARDADOS PRODS
|
||||||
Dim resultado As DBResult = reqManager.HandleJob(Job)
|
Dim resultado As DBResult = reqManager.HandleJob(Job)
|
||||||
If resultado.Tag.As(String).IndexOf("ins_mandaGuardados_prods_") > -1 Then
|
If resultado.Tag.As(String).IndexOf("ins_mandaGuardados_prods_") > -1 Then
|
||||||
@@ -248,6 +359,25 @@ Sub JobDone(Job As HttpJob)
|
|||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
' PEDIDOS GUARDADOS BATCH
|
||||||
|
If Job.JobName = "DBRequest" Then
|
||||||
|
Dim RESULT As DBResult = reqManager.HandleJob(Job)
|
||||||
|
If RESULT.Tag.As(String).Contains("pedido_completo") Then 'query tag
|
||||||
|
Subs.logJobDoneResultados(RESULT)
|
||||||
|
For Each records() As Object In resultado.Rows
|
||||||
|
Log("AffectedRows: " & records(resultado.Columns.Get("AffectedRows")))
|
||||||
|
If records(resultado.Columns.Get("AffectedRows")).As(Int) > 0 Then
|
||||||
|
Private pars() As String = Regex.Split("_", RESULT.tag)
|
||||||
|
B4XPages.MainPage.skmt.ExecNonQuery($"update PEDIDO set PE_ENVIO_OK = 1 where PE_CLIENTE = '${pars(2)}'"$)
|
||||||
|
Log($"update PEDIDO set PE_ENVIO_OK = 1, PE_GUARDADO = 1 where PE_CLIENTE = '${pars(2)}'"$)
|
||||||
|
B4XPages.MainPage.skmt.ExecNonQuery($"update PEDIDO_CLIENTE set PC_ENVIO_OK = 1, PC_GUARDADO = 1 where PC_CLIENTE = '${pars(2)}'"$)
|
||||||
|
Log($"update PEDIDO_CLIENTE set PC_ENVIO_OK = 1 where PC_CLIENTE = '${pars(2)}'"$)
|
||||||
|
End If
|
||||||
|
Next
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
' REVISA GUARDADOS PRODS
|
' REVISA GUARDADOS PRODS
|
||||||
Dim resultado As DBResult = reqManager.HandleJob(Job)
|
Dim resultado As DBResult = reqManager.HandleJob(Job)
|
||||||
If resultado.Tag.As(String).IndexOf("ins_revisaGuardados_prods_") > -1 Then
|
If resultado.Tag.As(String).IndexOf("ins_revisaGuardados_prods_") > -1 Then
|
||||||
@@ -265,6 +395,7 @@ Sub JobDone(Job As HttpJob)
|
|||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' REVISA GUARDADOS HEAD
|
' REVISA GUARDADOS HEAD
|
||||||
If resultado.Tag.As(String).IndexOf("ins_revisaGuardados_head_") > -1 Then
|
If resultado.Tag.As(String).IndexOf("ins_revisaGuardados_head_") > -1 Then
|
||||||
Log("ins_revisaGuardados_head_")
|
Log("ins_revisaGuardados_head_")
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -164,7 +164,7 @@ Version=12.8
|
|||||||
#Region Project Attributes
|
#Region Project Attributes
|
||||||
#ApplicationLabel: Intmex
|
#ApplicationLabel: Intmex
|
||||||
#VersionCode: 1
|
#VersionCode: 1
|
||||||
#VersionName: 5.11.25
|
#VersionName: 6.03.16
|
||||||
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||||
#SupportedOrientations: portrait
|
#SupportedOrientations: portrait
|
||||||
#CanInstallToExternalStorage: False
|
#CanInstallToExternalStorage: False
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ ModuleClosedNodes1=
|
|||||||
ModuleClosedNodes10=
|
ModuleClosedNodes10=
|
||||||
ModuleClosedNodes11=3
|
ModuleClosedNodes11=3
|
||||||
ModuleClosedNodes12=
|
ModuleClosedNodes12=
|
||||||
ModuleClosedNodes13=
|
ModuleClosedNodes13=1,4,5
|
||||||
ModuleClosedNodes14=
|
ModuleClosedNodes14=
|
||||||
ModuleClosedNodes15=
|
ModuleClosedNodes15=
|
||||||
ModuleClosedNodes16=
|
ModuleClosedNodes16=
|
||||||
@@ -73,7 +73,7 @@ ModuleClosedNodes17=
|
|||||||
ModuleClosedNodes18=
|
ModuleClosedNodes18=
|
||||||
ModuleClosedNodes19=
|
ModuleClosedNodes19=
|
||||||
ModuleClosedNodes2=
|
ModuleClosedNodes2=
|
||||||
ModuleClosedNodes20=
|
ModuleClosedNodes20=6
|
||||||
ModuleClosedNodes21=
|
ModuleClosedNodes21=
|
||||||
ModuleClosedNodes22=
|
ModuleClosedNodes22=
|
||||||
ModuleClosedNodes23=
|
ModuleClosedNodes23=
|
||||||
@@ -91,6 +91,6 @@ ModuleClosedNodes6=
|
|||||||
ModuleClosedNodes7=
|
ModuleClosedNodes7=
|
||||||
ModuleClosedNodes8=
|
ModuleClosedNodes8=
|
||||||
ModuleClosedNodes9=
|
ModuleClosedNodes9=
|
||||||
NavigationStack=C_Principal,JobDone,1499,0,C_Principal,cargar_Click,967,0,C_NuevoCliente,p_transparenteCN_Click,588,0,C_NuevoCliente,et_cp_TextChanged,569,0,C_NuevoCliente,b_clienteNuevo_Click,582,6,Diseñador Visual,nuevocliente.bal,-100,6,C_NuevoCliente,B4XPage_Created,168,0,C_NuevoCliente,Initialize,166,0,C_NuevoCliente,Class_Globals,115,4,C_NuevoCliente,B4XPage_Appear,234,6
|
NavigationStack=C_Validador,mandaGuardados,184,5,B4XMainPage,b_enviarbd_Click,776,0,B4XMainPage,b_importarBD_Click,782,0,C_Principal,getTableColumnList,365,0,Main,Globals,25,0,Main,Process_Globals,21,0,Main,Activity_Create,33,0,Main,Activity_ActionBarHomeClick,39,0,C_Principal,Subir_Click,746,0,C_Principal,connecta_Click,2166,0,C_Principal,JobDone,1209,0
|
||||||
SelectedBuild=0
|
SelectedBuild=0
|
||||||
VisibleModules=28,2,13,20,14,29,15,9,4,11
|
VisibleModules=28,2,13,14,29,15,4,20,21
|
||||||
|
|||||||
22
B4A/Subs.bas
22
B4A/Subs.bas
@@ -1546,3 +1546,25 @@ Sub traeTicketConsecutivo(idCliente As String) As Int
|
|||||||
Loop
|
Loop
|
||||||
Return sigTicket + 1
|
Return sigTicket + 1
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
' Regresa la geocerca desde CAT_VARIABLES, default = TRUE
|
||||||
|
Sub traeGeocerca As Boolean
|
||||||
|
Private usarGeo As Boolean = True
|
||||||
|
Private c As Cursor = Starter.skmt.ExecQuery("select * from cat_variables where cat_va_descripcion ='GEOCERCA'")
|
||||||
|
If c.RowCount> 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
If c.GetInt("CAT_VA_VALOR") = 0 Then usarGeo = False
|
||||||
|
End If
|
||||||
|
Return usarGeo
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Revisa si la geocerca debe de estar activa
|
||||||
|
Sub geocercaActiva As Boolean
|
||||||
|
Private resultado As Boolean = True
|
||||||
|
Private c As Cursor = Starter.skmt.ExecQuery("select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'GEOCERCA'")
|
||||||
|
If c.RowCount > 0 Then
|
||||||
|
c.Position = 0
|
||||||
|
If c.GetString("CAT_VA_VALOR") = 0 Then resultado = False
|
||||||
|
End If
|
||||||
|
Return resultado
|
||||||
|
End Sub
|
||||||
|
|||||||
305
B4A/Tracker.bas
305
B4A/Tracker.bas
@@ -4,300 +4,6 @@ ModulesStructureVersion=1
|
|||||||
Type=Service
|
Type=Service
|
||||||
Version=10.2
|
Version=10.2
|
||||||
@EndOfDesignText@
|
@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
|
|
||||||
|
|
||||||
|
|
||||||
#Region Service Attributes
|
#Region Service Attributes
|
||||||
#StartAtBoot: True
|
#StartAtBoot: True
|
||||||
#End Region
|
#End Region
|
||||||
@@ -403,7 +109,6 @@ Public Sub StartFLPSmall
|
|||||||
Sleep(500)
|
Sleep(500)
|
||||||
Log("sleeping")
|
Log("sleeping")
|
||||||
Loop
|
Loop
|
||||||
dameUltimaUbicacionConocida 'Regresamos ultima ubicacion conocida
|
|
||||||
FLP.RequestLocationUpdates(CreateLocationRequestSmallD) 'Buscamos ubicacion 2 peticiones
|
FLP.RequestLocationUpdates(CreateLocationRequestSmallD) 'Buscamos ubicacion 2 peticiones
|
||||||
' Log("Buscamos ubicacion Small displacement")
|
' Log("Buscamos ubicacion Small displacement")
|
||||||
' Log("GPSSmallestDisplacement = " & actualLR.GetSmallestDisplacement)
|
' Log("GPSSmallestDisplacement = " & actualLR.GetSmallestDisplacement)
|
||||||
@@ -434,16 +139,6 @@ Private Sub CreateLocationRequestSmallD As LocationRequest
|
|||||||
Return lr
|
Return lr
|
||||||
End Sub
|
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
|
Public Sub StopFLP
|
||||||
'Log("StopFLP")
|
'Log("StopFLP")
|
||||||
If flpStarted Then
|
If flpStarted Then
|
||||||
|
|||||||
127
B4A/_git_tag.ps1
Normal file
127
B4A/_git_tag.ps1
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
# --- SCRIPT DE COMMIT Y TAG (MODO IDE B4A) ---
|
||||||
|
|
||||||
|
# 0. CONFIGURACIÓN
|
||||||
|
$HacerPush = $true # Cambia a $true para que suba los cambios a GitHub
|
||||||
|
|
||||||
|
# Cargar librería visual para el MessageBox (por si se necesita en el Push)
|
||||||
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
|
|
||||||
|
# 1. AUTODESCUBRIMIENTO
|
||||||
|
$projectPath = $PSScriptRoot
|
||||||
|
Write-Host "Ruta del proyecto: $projectPath"
|
||||||
|
|
||||||
|
$b4aFileItem = Get-ChildItem -Path $projectPath -Filter "*.b4a" | Select-Object -First 1
|
||||||
|
|
||||||
|
if (-Not $b4aFileItem) {
|
||||||
|
Write-Host "ERROR: No hay archivo .b4a en esta carpeta."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
$projectName = $b4aFileItem.BaseName
|
||||||
|
Write-Host "Proyecto detectado: $projectName"
|
||||||
|
|
||||||
|
# 2. LEER VERSIÓN
|
||||||
|
$versionLine = Get-Content $b4aFileItem.FullName | Select-String "#VersionName:"
|
||||||
|
if (-Not $versionLine) {
|
||||||
|
Write-Host "ERROR: Falta #VersionName en el archivo .b4a"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
$version = ($versionLine -split ":")[1].Trim()
|
||||||
|
# Reemplaza cualquier espacio en blanco por un guion bajo solo para el tag
|
||||||
|
$tagName = "$version".Replace(" ", "_")
|
||||||
|
|
||||||
|
Set-Location $projectPath
|
||||||
|
|
||||||
|
# 3. COMMIT CON TORTOISEGIT
|
||||||
|
$oldCommit = git rev-parse HEAD 2>$null
|
||||||
|
|
||||||
|
Write-Host "----------------------------------------"
|
||||||
|
Write-Host "Version a etiquetar: $version"
|
||||||
|
Write-Host "Abriendo ventana de TortoiseGit..."
|
||||||
|
|
||||||
|
$pathArg = '/path:"{0}"' -f $projectPath
|
||||||
|
$msgArg = '/logmsg:"VERSION {0}"' -f $version
|
||||||
|
$cmdArg = "/command:commit"
|
||||||
|
|
||||||
|
Start-Process "TortoiseGitProc.exe" -ArgumentList $cmdArg, $pathArg, $msgArg
|
||||||
|
|
||||||
|
Write-Host "Esperando a que termines el commit en TortoiseGit..."
|
||||||
|
# El freno de mano: espera a que cierres la ventana
|
||||||
|
while (Get-Process "TortoiseGitProc" -ErrorAction SilentlyContinue) {
|
||||||
|
Start-Sleep -Seconds 1
|
||||||
|
}
|
||||||
|
|
||||||
|
$newCommit = git rev-parse HEAD 2>$null
|
||||||
|
|
||||||
|
# 4. VALIDACIÓN
|
||||||
|
if ($oldCommit -eq $newCommit) {
|
||||||
|
Write-Host "WARNING: Commit cancelado o sin cambios detectados."
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Commit registrado exitosamente: $newCommit"
|
||||||
|
|
||||||
|
# 5. GESTIÓN DE TAGS
|
||||||
|
$tagGenerado = $false
|
||||||
|
|
||||||
|
# Revisamos si el tag ya existe localmente y lo borramos para recrearlo con el nuevo commit
|
||||||
|
if (git tag -l $tagName) {
|
||||||
|
git tag -d $tagName 2>$null | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Creamos el tag nuevo apuntando al commit que acabamos de hacer
|
||||||
|
git tag -a $tagName -m "Release version $version"
|
||||||
|
if ($?) { $tagGenerado = $true }
|
||||||
|
|
||||||
|
# 6. LÓGICA DE PUSH
|
||||||
|
if ($HacerPush) {
|
||||||
|
Write-Host "Conectando con GitHub..."
|
||||||
|
$remoteTagInfo = git ls-remote --tags origin $tagName
|
||||||
|
|
||||||
|
if ($remoteTagInfo) {
|
||||||
|
# Conflicto: Ya existe en remoto
|
||||||
|
$topForm = New-Object System.Windows.Forms.Form
|
||||||
|
$topForm.TopMost = $true
|
||||||
|
$topForm.Opacity = 0
|
||||||
|
$topForm.ShowInTaskbar = $false
|
||||||
|
$topForm.StartPosition = "CenterScreen"
|
||||||
|
$topForm.Show()
|
||||||
|
$topForm.Activate()
|
||||||
|
|
||||||
|
[System.Console]::Beep(1000, 200)
|
||||||
|
|
||||||
|
$msgBody = "El tag '$tagName' YA EXISTE en GitHub.`n`nDeseas SOBRESCRIBIRLO?`n`nSi = Borrar anterior y actualizar (Force Push).`nNo = Subir solo codigo (mantener tag viejo)."
|
||||||
|
$msgTitle = "Conflicto de Versiones - $projectName"
|
||||||
|
|
||||||
|
$respuesta = [System.Windows.Forms.MessageBox]::Show($topForm, $msgBody, $msgTitle, "YesNo", "Warning")
|
||||||
|
$topForm.Dispose()
|
||||||
|
|
||||||
|
if ($respuesta -eq "Yes") {
|
||||||
|
Write-Host "Sobrescribiendo tag en GitHub (Force Push)..."
|
||||||
|
git push origin
|
||||||
|
git push origin $tagName --force
|
||||||
|
} else {
|
||||||
|
Write-Host "Conservando tag anterior en GitHub..."
|
||||||
|
git push origin
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
# Tag Nuevo
|
||||||
|
Write-Host "Subiendo codigo y tag nuevo a GitHub..."
|
||||||
|
git push origin --follow-tags
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "Push OMITIDO (Switch de control apagado)."
|
||||||
|
}
|
||||||
|
|
||||||
|
# 7. REPORTE FINAL PARA EL IDE
|
||||||
|
$EstadoPush = if($HacerPush) { "SI" } else { "NO (Modo de prueba local)" }
|
||||||
|
$EstadoTag = if($tagGenerado) { "SI ($tagName)" } else { "NO (Error al generar)" }
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "========================================"
|
||||||
|
Write-Host " REPORTE DE VERSION "
|
||||||
|
Write-Host "========================================"
|
||||||
|
Write-Host " PROYECTO : $projectName"
|
||||||
|
Write-Host " TAG CREADO : $EstadoTag"
|
||||||
|
Write-Host " PUSH GITHUB: $EstadoPush"
|
||||||
|
Write-Host "========================================"
|
||||||
127
B4A/_juntaBas.ps1
Normal file
127
B4A/_juntaBas.ps1
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
# SCRIPT: _juntaBas_Master_FinalIA.ps1
|
||||||
|
# FIX: Corregida sintaxis de comillas y concatenación de tags XML.
|
||||||
|
# OBJETIVO: Fuente de verdad para IA con navegación ultra estructurada.
|
||||||
|
|
||||||
|
$ErrorActionPreference = 'SilentlyContinue'
|
||||||
|
$Dir = Get-Location
|
||||||
|
$LT = [char]60; $GT = [char]62; $SL = [char]47
|
||||||
|
$NL = [Environment]::NewLine
|
||||||
|
|
||||||
|
Write-Output '--- GENERANDO MASTER IA DEFINITIVO (FIX ESTRUCTURAL) ---'
|
||||||
|
|
||||||
|
# 1. PARSEO DEL PROYECTO .B4A
|
||||||
|
$b4a = Get-ChildItem -Path ".\*" -Include "*.b4a" -Recurse | Select-Object -First 1
|
||||||
|
$Name = 'App'; $Ver = '0.0'; $ModulosValidos = @(); $Librerias = @()
|
||||||
|
|
||||||
|
if ($b4a) {
|
||||||
|
$lines = [System.IO.File]::ReadAllLines($b4a.FullName)
|
||||||
|
foreach ($L in $lines) {
|
||||||
|
if ($L -match '#ApplicationLabel:\s*(.*)') { $Name = $Matches[1].Trim() }
|
||||||
|
if ($L -match '#VersionName:\s*(.*)') { $Ver = $Matches[1].Trim() }
|
||||||
|
if ($L -match '^Module\d+=(.*)') {
|
||||||
|
$m = [System.IO.Path]::GetFileName($Matches[1].Trim())
|
||||||
|
if (-not $m.EndsWith(".bas") -and $m -ne "Main") { $m += ".bas" }
|
||||||
|
$ModulosValidos += $m
|
||||||
|
}
|
||||||
|
if ($L -match '^Library\d+=(.*)') { $Librerias += $Matches[1].Trim() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$OutName = "_" + $Name + "_" + $Ver + "_IA.md"
|
||||||
|
$OutFile = Join-Path $Dir $OutName
|
||||||
|
|
||||||
|
# 2. HEADER CON TUS INSTRUCCIONES CRÍTICAS
|
||||||
|
$CurrentDate = Get-Date -Format 'yyyy-MM-dd HH:mm'
|
||||||
|
$Header = @"
|
||||||
|
# PROYECTO: $Name
|
||||||
|
- Version: $Ver
|
||||||
|
- Fecha: $CurrentDate
|
||||||
|
- Librerias Activas: $($Librerias -join ", ")
|
||||||
|
|
||||||
|
## INSTRUCCIONES CRITICAS (B4A / BASIC4ANDROID)
|
||||||
|
0. **Integridad del Contexto:** Antes de procesar peticiones, cuenta si el numero de modulos listados en el indice coincide con los detallados en el cuerpo.
|
||||||
|
1. **Source of Truth (Codigo):** Este archivo contiene el codigo fuente ACTUAL del proyecto.
|
||||||
|
2. **Source of Truth (Librerias):** Basa tus sugerencias en la lista de 'Librerias Activas'.
|
||||||
|
3. **Anti-Alucinacion:** Antes de sugerir, VERIFICA la 'Interfaz Pública' o el código fuente del módulo.
|
||||||
|
4. **Existencia Estricta:** Si una variable/Sub no está en el texto, NO EXISTE.
|
||||||
|
5. **Formato:** Usa bloques 'vb'.
|
||||||
|
6. **Navegacion Estructural:** Usa los tags <module>, <interface> y <method> para localizar codigo.
|
||||||
|
7. **Inferencia de Datos:** Deduce la BD solo de los strings SQL presentes.
|
||||||
|
"@
|
||||||
|
|
||||||
|
Set-Content -Path $OutFile -Value $Header -Encoding UTF8
|
||||||
|
|
||||||
|
# 3. LISTAR ARCHIVOS
|
||||||
|
$files = Get-ChildItem -Path $Dir -Include *.bas,*.b4a -Recurse | Where-Object {
|
||||||
|
$_.FullName -notmatch 'Objects' -and ($_.Extension -eq '.b4a' -or $ModulosValidos -contains $_.Name)
|
||||||
|
}
|
||||||
|
|
||||||
|
# 4. INDICE DE MODULOS
|
||||||
|
Add-Content $OutFile ($NL + "## INDICE DE MODULOS" + $NL) -Encoding UTF8
|
||||||
|
foreach ($f in $files) {
|
||||||
|
$Ref = $f.Name.Replace('.', '').Replace(' ', '-').ToLower()
|
||||||
|
Add-Content $OutFile ("- [" + $f.Name + "](#modulo-" + $Ref + ")") -Encoding UTF8
|
||||||
|
}
|
||||||
|
|
||||||
|
# 5. CODIGO FUENTE ESTRUCTURADO
|
||||||
|
Add-Content $OutFile ($NL + '## CODIGO FUENTE DETALLADO' + $NL) -Encoding UTF8
|
||||||
|
|
||||||
|
foreach ($f in $files) {
|
||||||
|
Write-Host " -> $($f.Name)... " -NoNewline
|
||||||
|
$txt = [System.IO.File]::ReadAllLines($f.FullName)
|
||||||
|
|
||||||
|
# Pre-escaneo para <interface>
|
||||||
|
$Methods = @()
|
||||||
|
foreach ($line in $txt) {
|
||||||
|
if ($line.Trim() -match '^(?:Public\s+|Private\s+)?Sub\s+([\w\d_]+)') {
|
||||||
|
$Methods += $Matches[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$Ref = $f.Name.Replace('.', '').Replace(' ', '-').ToLower()
|
||||||
|
Add-Content $OutFile "$NL<module name='$($f.Name)' id='modulo-$Ref'>" -Encoding UTF8
|
||||||
|
|
||||||
|
Add-Content $OutFile " <interface>" -Encoding UTF8
|
||||||
|
foreach($m in $Methods) {
|
||||||
|
Add-Content $OutFile " <method_ref name='$m' />" -Encoding UTF8
|
||||||
|
}
|
||||||
|
Add-Content $OutFile " </interface>$NL" -Encoding UTF8
|
||||||
|
|
||||||
|
Add-Content $OutFile "```vb" -Encoding UTF8
|
||||||
|
|
||||||
|
$skip = ($f.Extension -eq '.b4a')
|
||||||
|
|
||||||
|
foreach ($l in $txt) {
|
||||||
|
$trim = $l.Trim()
|
||||||
|
|
||||||
|
if ($skip) {
|
||||||
|
if ($trim.StartsWith("#") -and -not $trim.StartsWith("#Region")) { Add-Content $OutFile $l -Encoding UTF8 }
|
||||||
|
if ($l.Contains("@EndOfDesignText@")) { $skip = $false }
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
# Inicio de Método
|
||||||
|
if ($trim -match '^(?:Public\s+|Private\s+)?Sub\s+([\w\d_]+)') {
|
||||||
|
Add-Content $OutFile "<method name='$($Matches[1])'>" -Encoding UTF8
|
||||||
|
}
|
||||||
|
|
||||||
|
# Limpieza de comentarios y escritura de línea
|
||||||
|
if ($trim.StartsWith("'")) {
|
||||||
|
if (-not ($trim.StartsWith("'#") -or ($trim -match 'TODO:') -or ($trim -match 'FIX:'))) { continue }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not [string]::IsNullOrWhiteSpace($trim)) {
|
||||||
|
Add-Content $OutFile $l -Encoding UTF8
|
||||||
|
}
|
||||||
|
|
||||||
|
# Fin de Método
|
||||||
|
if ($trim -eq "End Sub") {
|
||||||
|
Add-Content $OutFile "</method>" -Encoding UTF8
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Add-Content $OutFile "```$NL</module>" -Encoding UTF8
|
||||||
|
Write-Host "OK" -ForegroundColor Green
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Output ("--- FINALIZADO: " + $OutName + " ---")
|
||||||
BIN
INTMEX_LL.lnk
BIN
INTMEX_LL.lnk
Binary file not shown.
61
_sync_project.ps1
Normal file
61
_sync_project.ps1
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# 1. Mensaje inicial y pausa
|
||||||
|
Clear-Host
|
||||||
|
Write-Host "Se va a hacer un respaldo del codigo actual en el directorio ""AutoBackups""" -ForegroundColor Yellow
|
||||||
|
Write-Host "y al terminar, traemos desde GitHub la ultima version del codigo." -ForegroundColor Yellow
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Presione cualquier tecla para continuar..." -ForegroundColor Yellow
|
||||||
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||||
|
|
||||||
|
# 2. Asegurar ubicación en la raíz
|
||||||
|
Set-Location $PSScriptRoot
|
||||||
|
Write-Host "`nScript ejecutado desde: $PWD" -ForegroundColor DarkGray
|
||||||
|
|
||||||
|
# 3. Buscar el proyecto
|
||||||
|
$B4AFile = Get-ChildItem -Path ".\B4A\*.b4a" | Select-Object -First 1
|
||||||
|
if (!$B4AFile) {
|
||||||
|
Write-Host "ERROR: No encontre el archivo .b4a" -ForegroundColor Red
|
||||||
|
Start-Sleep -Seconds 3
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
|
||||||
|
$ProjectName = $B4AFile.BaseName
|
||||||
|
$BackupDir = ".\B4A\AutoBackups"
|
||||||
|
if (!(Test-Path $BackupDir)) { New-Item -ItemType Directory -Path $BackupDir }
|
||||||
|
|
||||||
|
Write-Host "Respaldando $ProjectName..." -ForegroundColor Cyan
|
||||||
|
|
||||||
|
# 4. Preparar archivos limpios (Método Copiar y Podar)
|
||||||
|
$tempFolder = Join-Path $env:TEMP "B4A_Stage_$ProjectName"
|
||||||
|
if (Test-Path $tempFolder) { Remove-Item $tempFolder -Recurse -Force -ErrorAction SilentlyContinue }
|
||||||
|
New-Item -ItemType Directory -Path $tempFolder | Out-Null
|
||||||
|
|
||||||
|
Write-Host "Extrayendo archivos de codigo..." -ForegroundColor Gray
|
||||||
|
foreach ($f in @("B4A", "Files")) {
|
||||||
|
if (Test-Path $f) {
|
||||||
|
$target = Join-Path $tempFolder $f
|
||||||
|
Copy-Item -Path $f -Destination $target -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Podando carpetas Objects y AutoBackups..." -ForegroundColor Gray
|
||||||
|
Remove-Item -Path "$tempFolder\B4A\Objects" -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
Remove-Item -Path "$tempFolder\B4A\AutoBackups" -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
Remove-Item -Path "$tempFolder\B4A\*.zip" -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
# 5. Zipear
|
||||||
|
$Timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
|
||||||
|
Write-Host "Comprimiendo..." -ForegroundColor Gray
|
||||||
|
Compress-Archive -Path "$tempFolder\*" -DestinationPath "$BackupDir\$ProjectName`_$Timestamp.zip" -Force
|
||||||
|
Remove-Item $tempFolder -Recurse -Force -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
|
Write-Host "¡Respaldo limpio creado con exito en AutoBackups!`n" -ForegroundColor Green
|
||||||
|
|
||||||
|
# 6. Sincronizar con GitHub (Pull forzado)
|
||||||
|
Write-Host "--- Sincronizando con GitHub (Borrando cambios locales) ---" -ForegroundColor Cyan
|
||||||
|
git fetch --all
|
||||||
|
git reset --hard origin/main
|
||||||
|
git pull
|
||||||
|
|
||||||
|
Write-Host "`n¡PROCESO COMPLETADO!" -ForegroundColor Green
|
||||||
|
# Pausa de 3 segundos para que veas el resultado antes de que se cierre sola
|
||||||
|
Start-Sleep -Seconds 3
|
||||||
Reference in New Issue
Block a user