mirror of
https://github.com/KeymonSoft/Guna_Preventa.git
synced 2026-04-17 21:06:32 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f756cc5ca4 | |||
| e5eb82e2de | |||
| 49e08a557c | |||
| 7fff665461 | |||
| 5f6f3ac545 | |||
|
|
ceb093b6c2 | ||
|
|
3f23591294 | ||
|
|
5fc486d742 |
@@ -38,6 +38,8 @@ Sub Class_Globals
|
||||
Public pedidos As C_Pedidos
|
||||
Public promos As C_Promos
|
||||
Public historico As C_Historico
|
||||
|
||||
Public historicobat As C_historicobat
|
||||
Dim reqManager As DBRequestManager
|
||||
Dim v As String = Application.VersionName
|
||||
Dim ruta As String
|
||||
@@ -110,6 +112,8 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
Root.LoadLayout("login")
|
||||
' B4XPages.SetTitle(Me, "Guna Preventa")
|
||||
|
||||
|
||||
login.Initialize
|
||||
B4XPages.AddPage("Login", login)
|
||||
principal.Initialize
|
||||
@@ -138,6 +142,10 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
B4XPages.AddPage("Promos", promos)
|
||||
historico.Initialize
|
||||
B4XPages.AddPage("Historico", historico)
|
||||
historicobat.Initialize
|
||||
B4XPages.AddPage("historicobat", historicobat)
|
||||
|
||||
|
||||
p_Main.Height = Root.Height
|
||||
p_Main.Width = Root.Width
|
||||
ruta = Starter.ruta
|
||||
@@ -200,15 +208,21 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Subs.agregaColumna("PEDIDO", "PE_RECCEDIS", "TEXT")
|
||||
Subs.agregaColumna("PEDIDO", "PE_RECALCULOTOT", "TEXT")
|
||||
Subs.agregaColumna("HIST_ENCUESTA", "HE_LON", "TEXT")
|
||||
Subs.agregaColumna("HIST_VENTAS", "HVD_FECHA", "TEXT")
|
||||
Subs.agregaColumna("kmt_info3", "encuesta", "TEXT")
|
||||
Subs.agregaColumna("kmt_info3", "CAT_CL_CLASIFICADOR3", "TEXT")
|
||||
Subs.agregaColumna("kmt_info3", "CAT_CL_CLASIFICADOR2", "TEXT")
|
||||
Subs.agregaColumna("kmt_info3", "CAT_CL_TIPOCLIENTE", "TEXT")
|
||||
Subs.agregaColumna("kmt_info3", "CAT_CL_LIMITECREDITO", "TEXT")
|
||||
Subs.agregaColumna("kmt_info3", "CAT_CL_DIASCREDITO", "TEXT")
|
||||
Subs.agregaColumna("kmt_info3", "CAT_CL_BCREDITO", "TEXT") '########################## CODIGO PARA CREDITOS ####################
|
||||
Subs.agregaColumna("CAT_GUNAPROD", "CAT_GP_DEV", "TEXT")
|
||||
Subs.agregaColumna("CAT_GUNAPROD", "CAT_PA_BSEGMENTA", "TEXT")
|
||||
Subs.agregaColumna("CAT_GUNAPROD", "CAT_LISTAPRECIO", "TEXT")
|
||||
Subs.agregaColumna("CAT_GUNAPROD", "CAT_PA_SEGMENTAV", "TEXT")
|
||||
Subs.agregaColumna("CAT_GUNAPROD2", "CAT_PA_BSEGMENTA", "TEXT")
|
||||
Subs.agregaColumna("CAT_GUNAPROD2", "CAT_PA_SEGMENTAV", "TEXT")
|
||||
Subs.agregaColumna("PEDIDO", "PE_RECCANT", "TEXT")
|
||||
Try 'Intentamos usar "pragma_table_info" para revisar si existe la columna "P10" en la tabla
|
||||
c=skmt.ExecQuery("SELECT COUNT(*) AS fCol FROM pragma_table_info('ENCUESTA_MODULO3') WHERE name='P10'")
|
||||
c.Position = 0
|
||||
@@ -366,7 +380,7 @@ Sub B4XPage_Appear
|
||||
B4XSwitch2.Value = False
|
||||
End If
|
||||
Else
|
||||
B4XSwitch1.Value = False
|
||||
B4XSwitch2.Value = False
|
||||
End If
|
||||
Subs.guardaAppInfo
|
||||
|
||||
@@ -536,7 +550,7 @@ Sub JobDone(Job As HttpJob)
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
|
||||
|
||||
If Job.JobName = "DBRequest" Then
|
||||
Dim result1 As DBResult = B4XPages.MainPage.reqManager.HandleJob(Job)
|
||||
If result1.Tag = "CHECAENCUESTA" Then 'query tag
|
||||
@@ -992,7 +1006,7 @@ Sub revisaActualizacion 'Parte de la funcionalidad "appUpdater"
|
||||
'## Hay que actualizar la version en el archivo "gunaPreventa.ver" ##
|
||||
'################################################
|
||||
LogColor("Buscarmos archivo Ver", Colors.red)
|
||||
Private link As String = "https://keymon.lat/movil/guna/gunaPreventa.ver"
|
||||
Private link As String = "https://keymon.net/movil/guna/gunaPreventa.ver"
|
||||
Wait For (traeArchivoVer(Me, link)) JobDone (j As HttpJob)
|
||||
If j.Success Then
|
||||
LogColor("Archivo .VER encontrado.", Colors.red)
|
||||
@@ -1079,13 +1093,13 @@ Private Sub cb_importarBDWA_CheckedChange(Checked As Boolean)
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub i_engrane_LongClick
|
||||
Dim Intent1 As Intent
|
||||
Intent1.Initialize(Intent1.ACTION_VIEW, "guna://tienda360/config?clienteId=12&almacen=45&ruta=143")
|
||||
Try
|
||||
StartActivity(Intent1)
|
||||
Catch
|
||||
' Log(LastException)
|
||||
ToastMessageShow("La aplicación Tienda 360 no está instalada o no puede manejar la URL.", True)
|
||||
End Try
|
||||
End Sub
|
||||
'Private Sub i_engrane_LongClick
|
||||
'' Dim Intent1 As Intent
|
||||
'' Intent1.Initialize(Intent1.ACTION_VIEW, "guna://tienda360/config?clienteId=12&almacen=45&ruta=143")
|
||||
'' Try
|
||||
'' StartActivity(Intent1)
|
||||
'' Catch
|
||||
''' Log(LastException)
|
||||
'' ToastMessageShow("La aplicación Tienda 360 no está instalada o no puede manejar la URL.", True)
|
||||
'' End Try
|
||||
'End Sub
|
||||
|
||||
1179
B4A/C_Cliente.bas
1179
B4A/C_Cliente.bas
File diff suppressed because it is too large
Load Diff
@@ -70,7 +70,7 @@ Sub B4XPage_Appear
|
||||
C.Position=0
|
||||
Existe = C.GetString("EXISTE")
|
||||
C.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_PRONOMBRE asc")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT, HVD_FECHA from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_FECHA asc")
|
||||
ListView1.Clear
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
@@ -78,12 +78,12 @@ Sub B4XPage_Appear
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
label1.TextColor = Colors.White
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 10
|
||||
label2.TextColor = Colors.Blue
|
||||
ListView1.AddTwoLines(c.GetString("HVD_PRONOMBRE"),"Cantidad #"& c.GetString("HVD_CANT")& " SubTotal $"& c.GetString("HVD_COSTO_TOT"))
|
||||
label2.TextSize = 15
|
||||
label2.TextColor = Colors.White
|
||||
ListView1.AddTwoLines(c.GetString("HVD_PRONOMBRE"),"Cantidad #"& c.GetString("HVD_CANT")& " SubTotal $"& c.GetString("HVD_COSTO_TOT")&" Fecha: "& c.GetString("HVD_FECHA"))
|
||||
Next
|
||||
End If
|
||||
If Existe <> 0 Then
|
||||
@@ -92,6 +92,10 @@ Sub B4XPage_Appear
|
||||
L_CANT.Text = c.GetString("PC_NOART")
|
||||
L_TOTAL.Text = c.GetString("PC_MONTO")
|
||||
End If
|
||||
' ListView1.Visible = False
|
||||
' CustomListView1.AsView.Visible = True
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
|
||||
167
B4A/C_Historico2.bas
Normal file
167
B4A/C_Historico2.bas
Normal file
@@ -0,0 +1,167 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=11.5
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
|
||||
Dim g As GPS
|
||||
Dim clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
|
||||
Dim c As Cursor
|
||||
Dim ruta As String
|
||||
Dim Regresar As Button
|
||||
|
||||
|
||||
Dim ListView1 As ListView
|
||||
Dim L_CANT As Label
|
||||
Dim L_TOTAL As Label
|
||||
Dim borra As Button
|
||||
Dim Existe As String
|
||||
Dim result As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
|
||||
Private Titulo As Label
|
||||
Private b_desc As Button
|
||||
Private ListView2 As ListView
|
||||
Dim tgl As Toggle
|
||||
Private p_nota As Panel
|
||||
Private Panel1 As Panel
|
||||
Private l_productohist As Label
|
||||
Private l_s1 As Label
|
||||
Private l_s2 As Label
|
||||
Private l_s3 As Label
|
||||
Private l_s4 As Label
|
||||
Private CustomListView1 As CustomListView
|
||||
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
'Public Sub Initialize As Object
|
||||
'' Return Me
|
||||
'End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
ruta = File.DirInternal
|
||||
Root.LoadLayout("nota2")
|
||||
borra.Visible = False
|
||||
Titulo.Text = "Acumulado"
|
||||
b_desc.Visible = False
|
||||
If File.Exists(ruta, "kmt.db") = False Then
|
||||
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
|
||||
End If
|
||||
' skmt.Initialize(ruta,"kmt.db", True)
|
||||
End Sub
|
||||
|
||||
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||
|
||||
Sub B4XPage_Appear
|
||||
p_nota.Height = Root.Height * 0.9
|
||||
p_nota.Width = Root.Width * 0.9
|
||||
Panel1.Visible = False
|
||||
If Not(Starter.gps.GPSEnabled) Then
|
||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
End If
|
||||
L_CANT.Text =""
|
||||
L_TOTAL.Text=""
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select count(*) as EXISTE from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
Existe = C.GetString("EXISTE")
|
||||
C.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT, HVD_FECHA from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_FECHA asc")
|
||||
ListView1.Clear
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.White
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 15
|
||||
label2.TextColor = Colors.White
|
||||
ListView1.AddTwoLines(c.GetString("HVD_PRONOMBRE"),"Cantidad #"& c.GetString("HVD_CANT")& " SubTotal $"& c.GetString("HVD_COSTO_TOT")&" Fecha: "& c.GetString("HVD_FECHA"))
|
||||
Next
|
||||
End If
|
||||
If Existe <> 0 Then
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select SUM(HVD_CANT) AS PC_NOART, SUM(HVD_COSTO_TOT) AS PC_MONTO from HIST_VENTAS where HVD_CLIENTE in (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
L_CANT.Text = c.GetString("PC_NOART")
|
||||
L_TOTAL.Text = c.GetString("PC_MONTO")
|
||||
End If
|
||||
' ListView1.Visible = False
|
||||
' CustomListView1.AsView.Visible = True
|
||||
' c=B4XPages.MainPage.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT, HVD_FECHA from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_FECHA asc")
|
||||
'
|
||||
For sfdf = 0 To 1
|
||||
CustomListView1.Add(CreateListItem("ejemplo","1","2","3","4", 284, 144),sfdf)
|
||||
|
||||
Next
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Sub CreateListItem(prodhis As String, s1 As Int, s2 As Int, s3 As Int,s4 As Int, Width As Int, Height As Int) As Panel 'ignore
|
||||
Dim p As B4XView = xui.CreatePanel("")
|
||||
p.SetLayoutAnimated(0, 0, 0, Width, Height)
|
||||
p.LoadLayout("historicobat")
|
||||
' l_prodX.TextSize = 15
|
||||
' l_prodX.Text = Text
|
||||
' l_prodX.TextSize = 15
|
||||
'' p_prods.Height = Height + 70
|
||||
'' l_prodX.Height = Height
|
||||
' p_prods.height = su.MeasureMultilineTextHeight(l_prodX, l_prodX.Text) + 20 'Calculamos la altura del panel de acuerdo al texto contenido.
|
||||
' If p_prods.Height < Height Then p_prods.Height = Height
|
||||
' l_prodX.Height = p_prods.Height
|
||||
' l_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
||||
' et_pCant.Tag = precioU&"|"&inv&"|"&prodId
|
||||
' et_pCant.BringToFront
|
||||
'' i_prod.Bitmap = img
|
||||
' p.Height = p_prods.Height
|
||||
Return p
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
'lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
||||
'lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
||||
End Sub
|
||||
|
||||
Sub Regresar_Click
|
||||
B4XPages.ShowPage("Cliente")
|
||||
End Sub
|
||||
|
||||
Private Sub B4XPage_CloseRequest As ResumableSub
|
||||
' BACK key pressed
|
||||
' Return True To close, False To cancel
|
||||
B4XPages.ShowPage("Cliente")
|
||||
Return False
|
||||
End Sub
|
||||
|
||||
Sub ListView2_ItemClick (Position As Int, Value As Object)
|
||||
ListView2.Visible = False
|
||||
ListView1.Visible = True
|
||||
End Sub
|
||||
|
||||
Sub ListView1_ItemClick (Position As Int, Value As Object)
|
||||
ListView2.Visible = True
|
||||
ListView1.Visible = False
|
||||
Dim label1 As Label
|
||||
For i=0 To 20
|
||||
label1 = ListView2.SingleLineLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.Black
|
||||
ListView2.AddSingleLine(i)
|
||||
Next
|
||||
End Sub
|
||||
@@ -129,28 +129,22 @@ Sub B4XPage_Appear
|
||||
Private s3 As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select * FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and PE_RECALCULO <> ? OR PE_RECALCULO <> ? OR PE_RECALCULO IS NOT NULL",Array As String("","null"))
|
||||
LogColor(s3.RowCount,Colors.Yellow)
|
||||
If s3.RowCount > 0 Then
|
||||
|
||||
Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and (PE_RECALCULO = ? or PE_RECALCULO = ? or PE_RECALCULO IS NULL)",Array As String("","null"))
|
||||
s.Position=0
|
||||
Private s5 As Cursor = B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(PE_RECALCULOTOT),0) as TOTAL_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa) and (PE_RECALCULO <> ? or PE_RECALCULO <> ? OR PE_RECALCULO IS NOT NULL)",Array As String("","null"))
|
||||
s5.Position = 0
|
||||
|
||||
|
||||
L_TOTAL.Text =NumberFormat2(s.GetString("TOTAL_CLIE") + s5.GetString("TOTAL_CLIE"),0,2,2,True)
|
||||
|
||||
s.Close
|
||||
|
||||
|
||||
Else If s3.RowCount = 0 Then
|
||||
Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO WHERE PE_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
s.Position=0
|
||||
|
||||
L_TOTAL.Text =NumberFormat2(s.GetString("TOTAL_CLIE"),0,2,2,True)
|
||||
|
||||
s.Close
|
||||
End If
|
||||
' *************************************************
|
||||
L_TOTAL.text = Subs.calculaTotalConPromoXRango(Subs.traeCliente)
|
||||
' *************************************************
|
||||
'AQUI TERMINA
|
||||
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -183,7 +177,7 @@ Sub borra_Click
|
||||
If folio <> "" Then
|
||||
result = Msgbox2("Seguro que desa borrar el pedido?","Cancelar pedido", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
If result = DialogResponse.POSITIVE Then
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select PE_PROID,PE_CANT FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) ")
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select PE_PROID,PE_CANT FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) AND PE_CEDIS <> 'DUR'")
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
@@ -309,8 +303,13 @@ Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
' For j = 0 To c.RowCount -1
|
||||
' Log("aqui tronare?")
|
||||
'' c.Position = j
|
||||
|
||||
If cedis <> "DUR" Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery($"update ${Subs.traeTablaProds(tipo_venta)} set cat_gp_almacen = cat_gp_almacen + ${c.GetString("PE_CANT")} where cat_gp_id = '${c.GetString("PE_PROID")}'"$)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("delete from pedido where pe_cedis= ? and pe_cliente in (Select CUENTA from cuentaa) AND PE_FOLIO = ?", Array As Object(cedis, c.GetString("PE_FOLIO")))
|
||||
Else
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("delete from pedido where pe_cedis= ? and pe_cliente in (Select CUENTA from cuentaa) AND PE_FOLIO = ?", Array As Object(cedis, c.GetString("PE_FOLIO")))
|
||||
End If
|
||||
' Next
|
||||
' End If
|
||||
' j3.Close
|
||||
@@ -396,8 +395,13 @@ Sub ListView1_ItemLongClick (Position As Int, Value As Object)
|
||||
' For j = 0 To c.RowCount -1
|
||||
' Log("aqui tronare?")
|
||||
' ' c.Position = j
|
||||
|
||||
If cedis <> "DUR" Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery($"update ${Subs.traeTablaProds(tipo_venta)} set cat_gp_almacen = cat_gp_almacen + ${c.GetString("PE_CANT")} where cat_gp_id = '${c.GetString("PE_PROID")}'"$)
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("delete from pedido where pe_cedis= ? and pe_cliente in (Select CUENTA from cuentaa) AND PE_FOLIO = ?", Array As Object(cedis, c.GetString("PE_FOLIO")))
|
||||
Else
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("delete from pedido where pe_cedis= ? and pe_cliente in (Select CUENTA from cuentaa) AND PE_FOLIO = ?", Array As Object(cedis, c.GetString("PE_FOLIO")))
|
||||
End If
|
||||
' Next
|
||||
' End If
|
||||
' j3.Close
|
||||
|
||||
@@ -20,6 +20,9 @@ Sub Class_Globals
|
||||
Dim no_cliente As String
|
||||
Dim no_ruta As String
|
||||
|
||||
Dim lat As Double = 0
|
||||
Dim lon As Double = 0
|
||||
|
||||
Dim r_4 As RadioButton
|
||||
Dim E_NOMBRE As EditText
|
||||
Dim tgl As Toggle
|
||||
@@ -55,6 +58,17 @@ Sub B4XPage_Appear
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
End If
|
||||
GUARDA.Visible = False
|
||||
|
||||
CallSubDelayed(Tracker, "Track")
|
||||
CallSubDelayed(Tracker, "StartFLPSmall")
|
||||
If Tracker.FLP.IsInitialized And Tracker.FLP.GetLastKnownLocation.IsInitialized Then 'Si tenemos "UltimaUbicaccionConocida" la usamos.
|
||||
B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude
|
||||
B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude
|
||||
' Log($"Tenemos UUC: ${Tracker.FLP.GetLastKnownLocation.Latitude},${Tracker.FLP.GetLastKnownLocation.Longitude}"$)
|
||||
GPS_LocationChanged(Tracker.FLP.GetLastKnownLocation)
|
||||
End If
|
||||
|
||||
|
||||
' Subs.panelVisible(p_nuevoCliente,, 0)
|
||||
' p_nuevoCliente.Height = Root.Height
|
||||
' p_nuevoCliente.Width = Root.Width
|
||||
@@ -65,15 +79,27 @@ Sub B4XPage_Appear
|
||||
' E_NOMBRE.Left = Round(Root.Width/2)-(E_NOMBRE.Width/2)
|
||||
If B4XPages.MainPage.lat_gps <> "0.0" Then
|
||||
GUARDA.Visible = True 'Si hay ubicaccion, mostramos el boton de guardar.
|
||||
l_sinUbicacion.Visible = False
|
||||
l_sinUbicacion.Visible = True
|
||||
End If
|
||||
Starter.skmt.ExecNonQuery("delete from cuentaa")
|
||||
End Sub
|
||||
|
||||
Sub GPS_LocationChanged (Location1 As Location)
|
||||
Log("NC GPS_LocationChanged")
|
||||
If B4XPages.MainPage.lat_gps <> "0.0" Then
|
||||
If GUARDA.IsInitialized Then
|
||||
GUARDA.Visible = True 'Si hay ubicaccion, mostramos el boton de guardar.
|
||||
l_sinUbicacion.Visible = False
|
||||
l_sinUbicacion.Visible = True
|
||||
End If
|
||||
End If
|
||||
If B4XPages.MainPage.lat_gps <> "0.0" Then
|
||||
If GUARDA.IsInitialized Then
|
||||
GUARDA.Visible = True 'Si hay ubicaccion, mostramos el boton de guardar.
|
||||
l_sinUbicacion.Visible = True
|
||||
lat = Location1.Latitude
|
||||
lon = Location1.Longitude
|
||||
l_sinUbicacion.Text = ("Latitud: " & lat & ", Longotud: "& lon)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
@@ -102,7 +128,7 @@ Sub GUARDA_Click
|
||||
no_cliente= "N" & sTime & no_ruta
|
||||
Log("++ ++ no_cliente = "&no_cliente)
|
||||
' c.Close
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO kmt_info3(CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO, gestion) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,0) ",Array As Object (no_cliente,no_ruta, E_NOMBRE.Text,"null","null","null","null","null","null","null","null","null","null","null","null","null",B4XPages.MainPage.lon_gps,B4XPages.MainPage.lat_gps))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO kmt_info3(CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO, gestion) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,0,0) ",Array As Object (no_cliente,no_ruta, E_NOMBRE.Text,"null","null","null","null","null","null","null","null","null","null","null","null","null",lon,lat))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_STAY_STORE(HSS_CODIGO, HSS_IN , HSS_OUT , HSS_TOT) VALUES (?,0,0,0)", Array As Object (no_cliente))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery("delete from CUENTAA")
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO CUENTAA VALUES (?)", Array As Object(no_cliente))
|
||||
|
||||
@@ -732,6 +732,7 @@ Sub Subir_Click
|
||||
End If
|
||||
c.Close
|
||||
|
||||
' PEDIDO
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("SELECT PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO, PE_COSTO_SIN, PE_RUTA, PE_DESC, PE_FOLIO FROM PEDIDO WHERE (PE_RECALCULO = ? or PE_RECALCULO = ? or PE_RECALCULO IS NULL)",Array As String("","null"))
|
||||
d=B4XPages.MainPage.skmt.ExecQuery("SELECT COUNT(*) as CUANTOS_PEDIDO FROM PEDIDO")
|
||||
If c.RowCount>0 Then
|
||||
@@ -746,44 +747,68 @@ Sub Subir_Click
|
||||
End If
|
||||
c.Close
|
||||
d.Position=0
|
||||
|
||||
cuantos_pedido = D.GetString("CUANTOS_PEDIDO")
|
||||
d.Close
|
||||
|
||||
If ALMACEN = "88" Or ALMACEN = "6" Then
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("SELECT PE_RECALCULO,PE_RECALCULOTOT,PE_RECCEDIS,PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO, PE_COSTO_SIN, PE_RUTA, PE_DESC, PE_FOLIO FROM PEDIDO WHERE PE_RECALCULO <> ? or PE_RECALCULO <> ? or PE_RECALCULO IS NOT NULL",Array As String("","null"))
|
||||
d=B4XPages.MainPage.skmt.ExecQuery($"SELECT COUNT(*) as CUANTOS_PEDIDO FROM PEDIDO where PE_RUTA = '${Subs.traeRuta}'"$)
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "insert_pedido_GV2"
|
||||
cmd.Parameters = Array As Object(C.GetString("PE_RECCEDIS"), ALMACEN, C.GetString("PE_RECALCULOTOT"), C.GetString("PE_RECALCULO"), 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"))
|
||||
B4XPages.MainPage.reqManager.ExecuteCommand(cmd , "ins_pedido")
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
d.Position=0
|
||||
cuantos_pedido = D.GetString("CUANTOS_PEDIDO")
|
||||
d.Close
|
||||
Else
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("SELECT PE_RECALCULO,PE_RECALCULOTOT,PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO, PE_COSTO_SIN, PE_RUTA, PE_DESC, PE_FOLIO FROM PEDIDO WHERE PE_RECALCULO <> ? or PE_RECALCULO <> ? or PE_RECALCULO IS NOT NULL",Array As String("","null"))
|
||||
d=B4XPages.MainPage.skmt.ExecQuery($"SELECT COUNT(*) as CUANTOS_PEDIDO FROM PEDIDO where PE_RUTA = '${Subs.traeRuta}'"$)
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
|
||||
' If ALMACEN = "88" Or ALMACEN = "6" Then
|
||||
c=B4XPages.MainPage.skmt.ExecQuery2("SELECT PE_RECALCULO,PE_RECALCULOTOT,ifnull(PE_RECCEDIS,'') as PE_RECCEDIS,PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO, PE_COSTO_SIN, PE_RUTA, PE_DESC, PE_FOLIO, PE_RECCANT FROM PEDIDO WHERE PE_RECALCULO <> ? or PE_RECALCULO <> ? or PE_RECALCULO IS NOT NULL",Array As String("","null"))
|
||||
d=B4XPages.MainPage.skmt.ExecQuery($"SELECT COUNT(*) as CUANTOS_PEDIDO FROM PEDIDO where PE_RUTA = '${Subs.traeRuta}'"$)
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
If c.GetString("PE_RECCEDIS") = "" Then
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "insert_pedido_GV2"
|
||||
cmd.Parameters = Array As Object(C.GetString("PE_CEDIS"), ALMACEN, C.GetString("PE_RECALCULOTOT"), C.GetString("PE_RECALCULO"), 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"))
|
||||
B4XPages.MainPage.reqManager.ExecuteCommand(cmd , "ins_pedido")
|
||||
Next
|
||||
End If
|
||||
Else
|
||||
If c.GetString("PE_RECCANT") = c.GetString("PE_CANT") Then
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "insert_pedido_GV2"
|
||||
cmd.Parameters = Array As Object(C.GetString("PE_RECCEDIS"), ALMACEN, C.GetString("PE_RECALCULOTOT"), C.GetString("PE_RECALCULO"), 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"))
|
||||
B4XPages.MainPage.reqManager.ExecuteCommand(cmd , "ins_pedido")
|
||||
Else
|
||||
'Con descuento
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "insert_pedido_GV2"
|
||||
cmd.Parameters = Array As Object(C.GetString("PE_RECCEDIS"), ALMACEN, C.GetString("PE_RECALCULOTOT"), C.GetString("PE_RECALCULO"), C.GetString("PE_RECCANT"), 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"))
|
||||
B4XPages.MainPage.reqManager.ExecuteCommand(cmd , "ins_pedido")
|
||||
'Sin descuento
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "insert_pedido_GV2"
|
||||
cmd.Parameters = Array As Object(C.GetString("PE_CEDIS"), ALMACEN, NumberFormat2((C.GetString("PE_CANT")-C.GetString("PE_RECCANT"))*C.GetString("PE_COSTOU"),1,2,2,False), C.GetString("PE_COSTOU"), (C.GetString("PE_CANT")-C.GetString("PE_RECCANT")), 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"))
|
||||
B4XPages.MainPage.reqManager.ExecuteCommand(cmd , "ins_pedido")
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
d.Position=0
|
||||
cuantos_pedido = D.GetString("CUANTOS_PEDIDO")
|
||||
d.Close
|
||||
End If
|
||||
' Else
|
||||
' c=B4XPages.MainPage.skmt.ExecQuery2("SELECT PE_RECALCULO,PE_RECALCULOTOT,PE_CEDIS,PE_COSTO_TOT,PE_COSTOU,PE_CANT,PE_PRONOMBRE,PE_PROID,PE_CLIENTE,PE_FECHA,PE_USUARIO, PE_COSTO_SIN, PE_RUTA, PE_DESC, PE_FOLIO FROM PEDIDO WHERE PE_RECALCULO <> ? or PE_RECALCULO <> ? or PE_RECALCULO IS NOT NULL",Array As String("","null"))
|
||||
' d=B4XPages.MainPage.skmt.ExecQuery($"SELECT COUNT(*) as CUANTOS_PEDIDO FROM PEDIDO where PE_RUTA = '${Subs.traeRuta}'"$)
|
||||
' If c.RowCount>0 Then
|
||||
' For i=0 To c.RowCount -1
|
||||
' c.Position=i
|
||||
' Dim cmd As DBCommand
|
||||
' cmd.Initialize
|
||||
' cmd.Name = "insert_pedido_GV2"
|
||||
' cmd.Parameters = Array As Object(C.GetString("PE_CEDIS"), ALMACEN, C.GetString("PE_RECALCULOTOT"), C.GetString("PE_RECALCULO"), 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"))
|
||||
' B4XPages.MainPage.reqManager.ExecuteCommand(cmd , "ins_pedido")
|
||||
' Next
|
||||
' End If
|
||||
' c.Close
|
||||
' d.Position=0
|
||||
' cuantos_pedido = D.GetString("CUANTOS_PEDIDO")
|
||||
' d.Close
|
||||
' End If
|
||||
|
||||
|
||||
' 'CUESTIONARIO
|
||||
@@ -800,7 +825,7 @@ Sub Subir_Click
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
|
||||
|
||||
' NOVENTA
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("SELECT NV_CLIENTE,NV_FECHA,NV_USER,NV_MOTIVO,NV_COMM,NV_LAT,NV_LON FROM NOVENTA")
|
||||
D=B4XPages.MainPage.skmt.ExecQuery("SELECT COUNT(*) AS CUANTOS_NOVENTA FROM NOVENTA")
|
||||
@@ -881,7 +906,7 @@ Sub Subir_Click
|
||||
|
||||
Private x As Cursor = B4XPages.MainPage.skmt.ExecQuery("Select CLIENTE, ALMACEN, P1, P2, P3, P4, P5, P6, P7, P8, P9 from ENCUESTA_MODULO1")
|
||||
If x.RowCount>0 Then
|
||||
For i=0 To x.RowCount -1
|
||||
For i=0 To x.RowCount -1
|
||||
x.Position=i
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
@@ -1152,8 +1177,8 @@ Sub cargar_Click
|
||||
|
||||
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_hist_datos_GV2_2"
|
||||
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN,e_ruta.text, ALMACEN,e_ruta.text, ALMACEN)
|
||||
cmd.Name = "select_hist_datos_GV2_3"
|
||||
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN,e_ruta.text, ALMACEN)
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "hist_datos")
|
||||
|
||||
cmd.Initialize
|
||||
@@ -1209,34 +1234,34 @@ Sub cargar_Click
|
||||
cmd.Name = "selectPromo3055Jul-Sep_Guna"
|
||||
cmd.Parameters = Array As Object(e_ruta.text, ALMACEN)
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "hist_pro3055")
|
||||
|
||||
|
||||
'SUPLENCIA
|
||||
If E_RUTA2.text <> "" Then
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO RUTA_SUPLENCIA(RS_RUTA) VALUES(?)",Array As String(E_RUTA2.Text))
|
||||
E_RUTA2.Visible = False
|
||||
p_ruta2.Visible = False
|
||||
p_somvra_2.Visible = False
|
||||
|
||||
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_cat_clientes2_guna_GV2" '########################## CODIGO PARA CREDITOS ####################
|
||||
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN)
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "kmt_datos2")
|
||||
|
||||
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_hist_datos_GV2_2"
|
||||
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN,E_RUTA2.text, ALMACEN,E_RUTA2.text, ALMACEN)
|
||||
cmd.Name = "select_hist_datos_GV2_3"
|
||||
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN,E_RUTA2.text, ALMACEN)
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "hist_datos")
|
||||
|
||||
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_hist_promos_GV2"
|
||||
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN)
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "hist_promos")
|
||||
|
||||
|
||||
cmd.Initialize
|
||||
cmd.Name = "select_hist_cliente_promos_GV2"
|
||||
cmd.Parameters = Array As Object(E_RUTA2.text, ALMACEN)
|
||||
B4XPages.MainPage.reqManager.ExecuteQuery(cmd , 0, "hist_cliente_promos")
|
||||
|
||||
|
||||
cmd.Initialize
|
||||
cmd.Name = "SELECT_HIST_PRODPROM_GUNA"
|
||||
cmd.Parameters = Array As Object(ALMACEN,E_RUTA2.text)
|
||||
@@ -1418,10 +1443,13 @@ Sub JobDone(Job As HttpJob)
|
||||
Dim CAT_CL_NUM_SERIEFISICO As String = records(RESULT.Columns.Get("CAT_CL_NUM_SERIEFISICO"))
|
||||
Dim CAT_CL_TIPOCLIENTE As String = records(RESULT.Columns.Get("CAT_CL_TIPOCLIENTE"))
|
||||
Dim CAT_CL_LIMITECREDITO As String = records(RESULT.Columns.Get("CAT_CL_LIMITECREDITO"))
|
||||
Dim CAT_CL_DIASCREDITO As String = records(RESULT.Columns.Get("CAT_CL_DIASCREDITO"))
|
||||
Dim CAT_CL_CLASIFICADOR3 As String = records(RESULT.Columns.Get("CAT_CL_CLASIFICADOR3"))
|
||||
Dim CAT_CL_CLASIFICADOR2 As String = records(RESULT.Columns.Get("CAT_CL_CLASIFICADOR2"))
|
||||
|
||||
'########################## INICIA CODIGO PARA CREDITOS ####################
|
||||
Dim CAT_CL_BCREDITO As String = records(RESULT.Columns.Get("CAT_CL_BCREDITO"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO kmt_info3(CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO, gestion,CAT_CL_BCREDITO,CAT_CL_TIPOCLIENTE,FOTO,CAT_CL_LIMITECREDITO) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,?,?,?,?)", Array As Object (CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO,CAT_CL_BCREDITO,CAT_CL_TIPOCLIENTE,CAT_CL_FOTO,CAT_CL_LIMITECREDITO))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO kmt_info3(CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO, gestion,CAT_CL_BCREDITO,CAT_CL_TIPOCLIENTE,FOTO,CAT_CL_LIMITECREDITO,CAT_CL_DIASCREDITO,CAT_CL_CLASIFICADOR3,CAT_CL_CLASIFICADOR2) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,?,?,?,?,?,?,?)", Array As Object (CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO,CAT_CL_BCREDITO,CAT_CL_TIPOCLIENTE,CAT_CL_FOTO,CAT_CL_LIMITECREDITO,CAT_CL_DIASCREDITO,CAT_CL_CLASIFICADOR3,CAT_CL_CLASIFICADOR2))
|
||||
'########################## TERMINA CODIGO PARA CREDITOS ####################
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_STAY_STORE(HSS_CODIGO, HSS_IN , HSS_OUT , HSS_TOT) VALUES (?,0,0,0)", Array As Object (CAT_CL_CODIGO))
|
||||
Next
|
||||
@@ -1464,6 +1492,7 @@ Sub JobDone(Job As HttpJob)
|
||||
Dim CAT_CL_NUM_SERIEFISICO As String = records(RESULT.Columns.Get("CAT_CL_NUM_SERIEFISICO"))
|
||||
Dim CAT_CL_TIPOCLIENTE As String = records(RESULT.Columns.Get("CAT_CL_TIPOCLIENTE"))
|
||||
Dim CAT_CL_FOTO() As Byte = records(RESULT.Columns.Get("CAT_CL_FOTO"))
|
||||
|
||||
'########################## INICIA CODIGO PARA CREDITOS ####################
|
||||
Dim CAT_CL_BCREDITO As String = records(RESULT.Columns.Get("CAT_CL_BCREDITO"))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO kmt_info3(CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO, gestion,CAT_CL_BCREDITO,CAT_CL_TIPOCLIENTE,FOTO) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,0,?,?,?)", Array As Object (CAT_CL_CODIGO,CAT_CL_RUTA,CAT_CL_NOMBRE,CAT_CL_ATIENDE1,CAT_CL_ATIENTE2,CAT_CL_TELEFONO,CAT_CL_EMAIL,CAT_CL_CALLE,CAT_CL_NOEXT,CAT_CL_NOINT,CAT_CL_CALLE1,CAT_CL_CALLE2,CAT_CL_COLONIA,CAT_CL_MUNI,CAT_CL_EDO,CAT_CL_CP,CAT_CL_LONG,CAT_CL_LAT,CAT_CL_MTOCOMPRA,CAT_CL_NUM_SERIEFISICO,CAT_CL_BCREDITO,CAT_CL_TIPOCLIENTE,CAT_CL_FOTO))
|
||||
@@ -1800,14 +1829,14 @@ Sub JobDone(Job As HttpJob)
|
||||
Dim CAT_GP_SUBTIPO As String = records(RESULT.Columns.Get("CAT_GP_SUBTIPO"))
|
||||
Dim CAT_GP_IMG() As Byte = records(RESULT.Columns.Get("CAT_GP_IMG"))
|
||||
Dim CAT_GP_ALMACEN As Int = records(RESULT.Columns.Get("CAT_GP_ALMACEN"))
|
||||
' Dim CAT_GP_DEV As String = records(RESULT.Columns.Get("CAT_GP_DEV"))
|
||||
Dim CAT_GP_DEV As String = records(RESULT.Columns.Get("CAT_GP_DEV"))
|
||||
Dim CAT_GP_TIPOPROD As Int = records(RESULT.Columns.Get("CAT_GP_TIPOPROD"))
|
||||
Dim CAT_GP_INICIATIVA As Int = records(RESULT.Columns.Get("CAT_GP_INICIATIVA"))
|
||||
Dim CAT_LISTAPRECIO As String = records(RESULT.Columns.Get("CAT_LISTAPRECIO"))
|
||||
' Dim CAT_LISTAPRECIO As Int = 10
|
||||
' CAT_GP_INICIATIVA = 5
|
||||
' 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_DEV) 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_DEV))
|
||||
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,CAT_GP_INICIATIVA,CAT_LISTAPRECIO) 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_INICIATIVA,CAT_LISTAPRECIO))
|
||||
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,CAT_GP_INICIATIVA,CAT_LISTAPRECIO, CAT_GP_DEV) 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_INICIATIVA,CAT_LISTAPRECIO,CAT_GP_DEV))
|
||||
Next
|
||||
Listo2=1
|
||||
If PB2.Progress = 0 Then
|
||||
@@ -2015,8 +2044,9 @@ Sub JobDone(Job As HttpJob)
|
||||
Dim HVD_PRONOMBRE As String = records(RESULT.Columns.Get("HVD_PRONOMBRE"))
|
||||
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_FECHA As String = records(RESULT.Columns.Get("HVD_FECHA"))
|
||||
' Log(cont &" " &HVD_CLIENTE&"--"&HVD_PRONOMBRE&"--"&HVD_CANT&"--"&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))
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_VENTAS(HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT, HVD_FECHA) VALUES (?,?,?,?,?)", Array As Object (HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT,HVD_FECHA))
|
||||
Next
|
||||
Listo3 =1
|
||||
If PB1.Progress = 0 Then
|
||||
@@ -2325,7 +2355,7 @@ Sub connecta_Click
|
||||
l_forzarActualizacion.Text = "Hay una nueva actualización para la aplicación, por favor revise que tenga DATOS y espere mientras se descarga."
|
||||
p_transparenteActualizacion.Visible = True
|
||||
p_transparenteActualizacion.BringToFront
|
||||
Starter.nuevoLink = $"https://keymon.lat/movil/guna/GP_${revisaActualizacion.Get("nuevaVersion")}.apk"$
|
||||
Starter.nuevoLink = $"https://keymon.net/movil/guna/GP_${revisaActualizacion.Get("nuevaVersion")}.apk"$
|
||||
Log("Descargar: GP_" & Starter.newApp.appLink)
|
||||
CallSubDelayed(appUpdater, "download_newApk")
|
||||
else if revisaActualizacion.Get("forzar") = 2 Then ' No hay datos, regresamos al login y borramos usuario par que traiga los datos.
|
||||
@@ -2645,6 +2675,9 @@ Sub B_OK_PAS_Click
|
||||
Next
|
||||
End If
|
||||
c13.Close
|
||||
|
||||
|
||||
|
||||
checaPedido
|
||||
Else if CARGA = "CARGAR" And (S_CP.Text <> "LISTO" Or S_CC.Text <> "LISTO" Or S_CH.Text <> "LISTO") Then
|
||||
RES = Msgbox2("Seguro que desa abortar el proceso","Cierre", "Si", "", "No",LoadBitmap(File.DirAssets,"alert2.png")) 'ignore
|
||||
@@ -2790,46 +2823,72 @@ Sub resdia_Click
|
||||
l_monto_ks.Text = "0"
|
||||
End If
|
||||
c.Close
|
||||
|
||||
|
||||
'AQUI CAMBIAR
|
||||
Private s3 As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select * FROM PEDIDO WHERE PE_RECALCULO <> ? OR PE_RECALCULO <> ? OR PE_RECALCULO IS NOT NULL",Array As String("","null"))
|
||||
LogColor(s3.RowCount,Colors.Yellow)
|
||||
' Private s3 As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select * FROM PEDIDO WHERE PE_RECALCULO <> ? OR PE_RECALCULO <> ? OR PE_RECALCULO IS NOT NULL",Array As String("","null"))
|
||||
' LogColor(s3.RowCount,Colors.Yellow)
|
||||
' If s3.RowCount > 0 Then
|
||||
' s3.Position = 0
|
||||
' Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO WHERE (PE_RECALCULO = ? or PE_RECALCULO = ? or PE_RECALCULO IS NULL)",Array As String("","null"))
|
||||
' s.Position=0
|
||||
' Private s5 As Cursor = B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(PE_RECALCULOTOT),0) as TOTAL_CLIE FROM PEDIDO WHERE (PE_RECALCULO <> ? or PE_RECALCULO <> ? OR PE_RECALCULO IS NOT NULL)",Array As String("","null"))
|
||||
' s5.Position = 0
|
||||
'' l_ru_pri.Text = NumberFormat2(s.GetString("TOTAL_CLIE") + s5.GetString("TOTAL_CLIE"),0,2,2,False)
|
||||
' L_REAL.Text =NumberFormat2(s.GetString("TOTAL_CLIE") + s5.GetString("TOTAL_CLIE"),0,2,2,False)
|
||||
'' L_REAL.Text = Subs.calculaTotalConPromoXRango(s3.GetString("PE_CLIENTE"))
|
||||
' s.Close
|
||||
' Else If s3.RowCount = 0 Then
|
||||
' Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE, pe_cliente FROM PEDIDO ")
|
||||
' s.Position=0
|
||||
'' l_ru_pri.Text =NumberFormat2(s.GetString("TOTAL_CLIE"),0,2,2,False)
|
||||
' L_REAL.Text = NumberFormat2(s.GetString("TOTAL_CLIE"),0,2,2,False)
|
||||
'' L_REAL.Text = Subs.calculaTotalConPromoXRango(s.GetString("PE_CLIENTE"))
|
||||
' s.Close
|
||||
' End If
|
||||
' s3.Close
|
||||
|
||||
Private s3 As Cursor = B4XPages.MainPage.skmt.ExecQuery("select distinct(pe_cliente) FROM PEDIDO")
|
||||
If s3.RowCount > 0 Then
|
||||
|
||||
Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO WHERE (PE_RECALCULO = ? or PE_RECALCULO = ? or PE_RECALCULO IS NULL)",Array As String("","null"))
|
||||
s.Position=0
|
||||
Private s5 As Cursor = B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(PE_RECALCULOTOT),0) as TOTAL_CLIE FROM PEDIDO WHERE (PE_RECALCULO <> ? or PE_RECALCULO <> ? OR PE_RECALCULO IS NOT NULL)",Array As String("","null"))
|
||||
s5.Position = 0
|
||||
|
||||
' l_ru_pri.Text = NumberFormat2(s.GetString("TOTAL_CLIE") + s5.GetString("TOTAL_CLIE"),0,2,2,False)
|
||||
|
||||
L_REAL.Text =NumberFormat2(s.GetString("TOTAL_CLIE") + s5.GetString("TOTAL_CLIE"),0,2,2,False)
|
||||
s.Close
|
||||
|
||||
Else If s3.RowCount = 0 Then
|
||||
Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO ")
|
||||
s.Position=0
|
||||
|
||||
' l_ru_pri.Text =NumberFormat2(s.GetString("TOTAL_CLIE"),0,2,2,False)
|
||||
|
||||
L_REAL.Text =NumberFormat2(s.GetString("TOTAL_CLIE"),0,2,2,False)
|
||||
|
||||
s.Close
|
||||
Private total1 As String = 0
|
||||
For i = 0 To s3.RowCount - 1
|
||||
s3.Position = i
|
||||
' LogColor($"Total antes ${total1}"$, Colors.blue)
|
||||
total1 = total1 + Subs.calculaTotalConPromoXRango(s3.GetString("PE_CLIENTE"))
|
||||
' LogColor(Subs.calculaTotalConPromoXRango(s3.GetString("PE_CLIENTE")), Colors.Magenta)
|
||||
' LogColor($"Total despues ${total1}"$, Colors.blue)
|
||||
Next
|
||||
L_REAL.Text = total1
|
||||
End If
|
||||
|
||||
|
||||
'Prueba0
|
||||
Private ru_o As Cursor = B4XPages.MainPage.skmt.ExecQuery2("SELECT IFNULL(PE_RUTA, 0) AS PE_RUTA, IFNULL(SUM(PE_COSTO_TOT), 0) AS TOTAL_CLIE FROM PEDIDO LEFT JOIN RUTA_SUPLENCIA ON PE_RUTA = RS_RUTA WHERE RS_RUTA IS NULL", Null)
|
||||
ru_o.Position=0
|
||||
Log("------------->RutaOriginal "&ru_o)
|
||||
If ru_o.GetString("PE_RUTA") = 0 Then
|
||||
Label2.Text = "N/A"
|
||||
Else if ru_o.RowCount >=1 Then
|
||||
Private rutOr As String = ru_o.GetString("PE_RUTA")
|
||||
Label2.Text = "Ruta " & rutOr
|
||||
l_ru_pri.Text = NumberFormat2(ru_o.GetDouble("TOTAL_CLIE"), 0, 2, 2, False)
|
||||
' Private ru_o As Cursor = B4XPages.MainPage.skmt.ExecQuery2("SELECT IFNULL(PE_RUTA, 0) AS PE_RUTA, IFNULL(SUM(PE_COSTO_TOT), 0) AS TOTAL_CLIE, pe_cliente FROM PEDIDO LEFT JOIN RUTA_SUPLENCIA ON PE_RUTA = RS_RUTA WHERE RS_RUTA IS NULL", Null)
|
||||
' ru_o.Position=0
|
||||
' Log("------------->RutaOriginal "&ru_o)
|
||||
' If ru_o.GetString("PE_RUTA") = 0 Then
|
||||
' Label2.Text = "N/A"
|
||||
' Else if ru_o.RowCount >=1 Then
|
||||
' Private rutOr As String = ru_o.GetString("PE_RUTA")
|
||||
' Label2.Text = "Ruta " & rutOr
|
||||
'' l_ru_pri.Text = NumberFormat2(ru_o.GetDouble("TOTAL_CLIE"), 0, 2, 2, False)
|
||||
' l_ru_pri.Text = Subs.calculaTotalConPromoXRango(ru_o.GetString("PE_CLIENTE"))
|
||||
' End If
|
||||
' ru_o.Close
|
||||
|
||||
Private ru_o As Cursor = B4XPages.MainPage.skmt.ExecQuery2("SELECT distinct pe_cliente, pe_ruta FROM PEDIDO LEFT JOIN RUTA_SUPLENCIA ON PE_RUTA = RS_RUTA WHERE RS_RUTA IS NULL", Null)
|
||||
Label2.Text = "N/A"
|
||||
Log("##### " & ru_o.RowCount)
|
||||
Private total2 As String = 0
|
||||
If ru_o.RowCount > 0 Then
|
||||
For i2 = 0 To ru_o.RowCount - 1
|
||||
ru_o.Position = i2
|
||||
' LogColor($"${ru_o.GetString("PE_RUTA")}|${ru_o.GetString("PE_CLIENTE")}"$, Colors.Red)
|
||||
Private rutOr As String = ru_o.GetString("PE_RUTA")
|
||||
Label2.Text = "Ruta " & rutOr
|
||||
total2 = total2 + Subs.calculaTotalConPromoXRango(ru_o.GetString("PE_CLIENTE"))
|
||||
Next
|
||||
End If
|
||||
ru_o.Close
|
||||
|
||||
l_ru_pri.Text = total2
|
||||
|
||||
'Prueba1
|
||||
Private ru_s As Cursor = B4XPages.MainPage.skmt.ExecQuery2("SELECT IFNULL(PE_RUTA, 0) As PE_RUTA, IFNULL(SUM(PE_COSTO_TOT), 0) As TOTAL_CLIE FROM PEDIDO LEFT JOIN RUTA_SUPLENCIA ON PE_RUTA = RS_RUTA WHERE RS_RUTA Is Not Null", Null)
|
||||
ru_s.Position = 0
|
||||
@@ -3192,4 +3251,7 @@ Sub checaPedido
|
||||
If c.RowCount > 0 Then
|
||||
Starter.skmt.ExecNonQuery("Update kmt_info3 set gestion = 3 WHERE CAT_CL_CODIGO IN (SELECT NV_CLIENTE FROM NOVENTA)")
|
||||
End If
|
||||
|
||||
B4XPages.MainPage.skmt.ExecNonQuery2("UPDATE CAT_GUNAPROD SET CAT_GP_TIPOPROD = (?) WHERE CAT_GP_ID IN (SELECT CAT_PD_PRODUCTO FROM CAT_PROMOS_DESCUENTOS) ",Array As Object("PRIORITARIO"))
|
||||
|
||||
End Sub
|
||||
1149
B4A/C_Productos.bas
1149
B4A/C_Productos.bas
File diff suppressed because it is too large
Load Diff
@@ -596,6 +596,7 @@ Sub muestraPromo(promo As String, cliente As String)
|
||||
Private thisProd As Map = prodsPromo.Get(p)
|
||||
If thisLog Then Log(thisProd)
|
||||
clv_prodsVariabes.Add(CreateListItem(Subs.traeProdNombre(p)&CRLF&"Hay " & invDispPromo.Get(p) & " $" & estePrecio, estePrecio, invDispPromo.Get(p), clv_prodsVariabes.AsView.Width, 50dip, Null, p), p)
|
||||
|
||||
End If
|
||||
Next
|
||||
For Each p As String In pv2
|
||||
|
||||
@@ -54,7 +54,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
ListView1.TwoLinesLayout.ItemHeight = 95dip
|
||||
Label1.Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD)
|
||||
label2.Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD)
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),"Cantidad #"& c.GetString("PC_NOART")& " SubTotal $"& c.GetString("PC_MONTO"))
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),"Cantidad #"& c.GetString("PC_NOART")& " SubTotal $"& Subs.calculaTotalConPromoXRango(c.GetString("PC_CLIENTE")))
|
||||
Next
|
||||
End If
|
||||
End Sub
|
||||
@@ -100,17 +100,14 @@ Sub B4XPage_Appear
|
||||
label2.TextColor = Colors.White
|
||||
label1.Height = 25dip
|
||||
label2.Height = 60dip
|
||||
|
||||
|
||||
ListView1.TwoLinesLayout.ItemHeight = 95dip
|
||||
label1.Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD)
|
||||
label2.Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD)
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& (s.GetString("CANT_CLIE") + s5.GetString("CANT_CLIE")) & " SubTotal $"& NumberFormat2(s.GetString("TOTAL_CLIE") + s5.GetString("TOTAL_CLIE"),0,2,2,True))
|
||||
|
||||
|
||||
|
||||
Log(1)
|
||||
' ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& (s.GetString("CANT_CLIE") + s5.GetString("CANT_CLIE")) & " SubTotal $"& NumberFormat2(s.GetString("TOTAL_CLIE") + s5.GetString("TOTAL_CLIE"),0,2,2,True))
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& (s.GetString("CANT_CLIE") + s5.GetString("CANT_CLIE")) & " SubTotal $"& Subs.calculaTotalConPromoXRango(c.GetString("PC_CLIENTE")))
|
||||
s.Close
|
||||
|
||||
|
||||
Else If s3.RowCount = 0 Then
|
||||
Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO WHERE PE_CLIENTE = ?", Array As String(C.GetString("PC_CLIENTE")))
|
||||
s.Position=0
|
||||
@@ -129,16 +126,10 @@ Sub B4XPage_Appear
|
||||
ListView1.TwoLinesLayout.ItemHeight = 95dip
|
||||
label1.Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD)
|
||||
label2.Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD)
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& s.GetString("CANT_CLIE") & " SubTotal $"& NumberFormat2(s.GetString("TOTAL_CLIE"),0,2,2,True))
|
||||
|
||||
|
||||
|
||||
Log(2)
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& s.GetString("CANT_CLIE") & " SubTotal $"& Subs.calculaTotalConPromoXRango(c.GetString("PC_CLIENTE")))
|
||||
s.Close
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
Next
|
||||
End If
|
||||
c.Close
|
||||
@@ -210,15 +201,10 @@ Sub b_noventa_Click
|
||||
Private s3 As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select * FROM PEDIDO WHERE PE_CLIENTE = ? and PE_RECALCULO <> ? OR PE_RECALCULO <> ? OR PE_RECALCULO IS NOT NULL",Array As String(C.GetString("PC_CLIENTE"),"","null"))
|
||||
LogColor(s3.RowCount,Colors.Yellow)
|
||||
If s3.RowCount > 0 Then
|
||||
|
||||
Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, IFNULL(SUM(PE_CANT),0) AS CANT_CLIE FROM PEDIDO WHERE PE_CLIENTE = ? and (PE_RECALCULO = ? or PE_RECALCULO = ? or PE_RECALCULO IS NULL ) AND PE_PROID NOT IN (SELECT CAT_PA_ID FROM PROMOS_COMP)",Array As String(C.GetString("PC_CLIENTE"),"","null"))
|
||||
s.Position=0
|
||||
Private s5 As Cursor = B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(PE_RECALCULOTOT),0) as TOTAL_CLIE, IFNULL(SUM(PE_CANT),0) AS CANT_CLIE FROM PEDIDO WHERE PE_CLIENTE = ? and (PE_RECALCULO <> ? or PE_RECALCULO <> ? OR PE_RECALCULO IS NOT NULL) AND PE_PROID NOT IN (SELECT CAT_PA_ID FROM PROMOS_COMP)",Array As String(C.GetString("PC_CLIENTE"),"","null"))
|
||||
s5.Position = 0
|
||||
|
||||
|
||||
|
||||
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 20
|
||||
@@ -229,21 +215,17 @@ Sub b_noventa_Click
|
||||
label2.TextColor = Colors.White
|
||||
label1.Height = 25dip
|
||||
label2.Height = 60dip
|
||||
|
||||
|
||||
ListView1.TwoLinesLayout.ItemHeight = 95dip
|
||||
label1.Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD)
|
||||
label2.Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD)
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& (s.GetString("CANT_CLIE") + s5.GetString("CANT_CLIE")) & " SubTotal $"& NumberFormat2(s.GetString("TOTAL_CLIE") + s5.GetString("TOTAL_CLIE"),0,2,2,True))
|
||||
|
||||
|
||||
|
||||
' ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& (s.GetString("CANT_CLIE") + s5.GetString("CANT_CLIE")) & " SubTotal $"& NumberFormat2(s.GetString("TOTAL_CLIE") + s5.GetString("TOTAL_CLIE"),0,2,2,True))
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& (s.GetString("CANT_CLIE") + s5.GetString("CANT_CLIE")) & " SubTotal $"& Subs.calculaTotalConPromoXRango(c.GetString("PC_CLIENTE")))
|
||||
s.Close
|
||||
|
||||
|
||||
Else If s3.RowCount = 0 Then
|
||||
Private s As Cursor=B4XPages.MainPage.skmt.ExecQuery2("select iFNULL(sum(pe_costo_tot),0) as TOTAL_CLIE, SUM(PE_CANT) AS CANT_CLIE FROM PEDIDO WHERE PE_CLIENTE = ?", Array As String(C.GetString("PC_CLIENTE")))
|
||||
s.Position=0
|
||||
|
||||
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 20
|
||||
@@ -254,14 +236,11 @@ Sub b_noventa_Click
|
||||
label2.TextColor = Colors.White
|
||||
label1.Height = 25dip
|
||||
label2.Height = 60dip
|
||||
|
||||
|
||||
ListView1.TwoLinesLayout.ItemHeight = 95dip
|
||||
label1.Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD)
|
||||
label2.Typeface = Typeface.CreateNew(Typeface.DEFAULT_BOLD, Typeface.STYLE_BOLD)
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& s.GetString("CANT_CLIE") & " SubTotal $"& NumberFormat2(s.GetString("TOTAL_CLIE"),0,2,2,True))
|
||||
|
||||
|
||||
|
||||
ListView1.AddTwoLines(c.GetString("PC_CLIENTE"),c.GetString("NOMBRE") &" Cantidad #"& s.GetString("CANT_CLIE") & " SubTotal $"& Subs.calculaTotalConPromoXRango(s3.GetString("PE_CLIENTE")))
|
||||
s.Close
|
||||
End If
|
||||
|
||||
|
||||
202
B4A/C_historicobat.bas
Normal file
202
B4A/C_historicobat.bas
Normal file
@@ -0,0 +1,202 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.8
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
|
||||
Dim g As GPS
|
||||
Dim clie_id As String
|
||||
Dim sDate,sTime As String
|
||||
Dim usuario As String
|
||||
|
||||
Dim c As Cursor
|
||||
Dim ruta As String
|
||||
Dim Regresar As Button
|
||||
|
||||
|
||||
Dim ListView1 As ListView
|
||||
Dim L_CANT As Label
|
||||
Dim L_TOTAL As Label
|
||||
Dim borra As Button
|
||||
Dim Existe As String
|
||||
Dim result As String
|
||||
' Dim lat_gps, lon_gps As String
|
||||
|
||||
Private Titulo As Label
|
||||
Private b_desc As Button
|
||||
Private ListView2 As ListView
|
||||
Dim tgl As Toggle
|
||||
Private p_nota As Panel
|
||||
Private Panel1 As Panel
|
||||
Private l_productohist As Label
|
||||
Private l_s1 As Label
|
||||
Private l_s2 As Label
|
||||
Private l_s3 As Label
|
||||
Private l_s4 As Label
|
||||
Private CustomListView1 As CustomListView
|
||||
Private L_PROMEDIOHIST As Label
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
Root.LoadLayout("nota2")
|
||||
borra.Visible = False
|
||||
Titulo.Text = "Acumulado"
|
||||
b_desc.Visible = False
|
||||
End Sub
|
||||
|
||||
|
||||
Sub B4XPage_Appear
|
||||
' p_nota.Height = Root.Height
|
||||
' p_nota.Width = Root.Width
|
||||
Panel1.Visible = False
|
||||
If Not(Starter.gps.GPSEnabled) Then
|
||||
ToastMessageShow("Es necesario tener el GPS encendido", True)
|
||||
StartActivity(Starter.gps.LocationSettingsIntent)
|
||||
End If
|
||||
L_CANT.Text =""
|
||||
L_TOTAL.Text=""
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select count(*) as EXISTE from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
Existe = C.GetString("EXISTE")
|
||||
C.Close
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT, HVD_FECHA from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_FECHA asc")
|
||||
ListView1.Clear
|
||||
If c.RowCount>0 Then
|
||||
For i=0 To c.RowCount -1
|
||||
c.Position=i
|
||||
Dim label1 As Label
|
||||
label1 = ListView1.TwoLinesLayout.Label
|
||||
label1.TextSize = 15
|
||||
label1.TextColor = Colors.White
|
||||
Dim label2 As Label
|
||||
label2 = ListView1.TwoLinesLayout.SecondLabel
|
||||
label2.TextSize = 15
|
||||
label2.TextColor = Colors.White
|
||||
ListView1.AddTwoLines(c.GetString("HVD_PRONOMBRE"),"Cantidad #"& c.GetString("HVD_CANT")& " SubTotal $"& c.GetString("HVD_COSTO_TOT")&" Fecha: "& c.GetString("HVD_FECHA"))
|
||||
Next
|
||||
End If
|
||||
If Existe <> 0 Then
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("select SUM(HVD_CANT) AS PC_NOART, SUM(HVD_COSTO_TOT) AS PC_MONTO from HIST_VENTAS where HVD_CLIENTE in (Select CUENTA from cuentaa)")
|
||||
C.Position=0
|
||||
L_CANT.Text = c.GetString("PC_NOART")
|
||||
L_TOTAL.Text = c.GetString("PC_MONTO")
|
||||
End If
|
||||
ListView1.Visible = False
|
||||
' CustomListView1.AsView.Visible = True
|
||||
CustomListView1.AsView.Height = Root.Height * 0.45
|
||||
CustomListView1.Clear
|
||||
Dim prohit As Cursor = B4XPages.MainPage.skmt.ExecQuery("select distinct HVD_PRONOMBRE from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_PRONOMBRE asc")
|
||||
|
||||
If prohit.RowCount > 0 Then
|
||||
|
||||
' --- Bucle 1: Recorrer cada producto ---
|
||||
For sfdf = 0 To prohit.RowCount - 1
|
||||
prohit.Position = sfdf
|
||||
Dim nombreProducto As String = prohit.GetString("HVD_PRONOMBRE")
|
||||
|
||||
' 1. Preparamos las variables para las 4 semanas
|
||||
' (Sem4 = hace 28 días, Sem1 = hace 7 días)
|
||||
Dim cant_sem4 As String = "0"
|
||||
Dim cant_sem3 As String = "0"
|
||||
Dim cant_sem2 As String = "0"
|
||||
Dim cant_sem1 As String = "0"
|
||||
|
||||
' --- 2. Query 2: (MODIFICADO) ---
|
||||
' Este es el query de SQLite que hicimos, adaptado
|
||||
' para usar la variable 'nombreProducto'
|
||||
Dim sql As String = $"
|
||||
WITH FechasObjetivo (Fecha) AS (
|
||||
SELECT strftime('%d/%m/%Y', date('now', 'localtime', '-28 days'))
|
||||
UNION ALL
|
||||
SELECT strftime('%d/%m/%Y', date('now', 'localtime', '-21 days'))
|
||||
UNION ALL
|
||||
SELECT strftime('%d/%m/%Y', date('now', 'localtime', '-14 days'))
|
||||
UNION ALL
|
||||
SELECT strftime('%d/%m/%Y', date('now', 'localtime', '-7 days'))
|
||||
)
|
||||
SELECT
|
||||
COALESCE(SUM(H.HVD_CANT), 0) AS HVD_CANT_TOTAL
|
||||
FROM
|
||||
FechasObjetivo AS F
|
||||
LEFT JOIN
|
||||
HIST_VENTAS AS H
|
||||
ON F.Fecha = H.HVD_FECHA
|
||||
AND H.HVD_CLIENTE IN (SELECT CUENTA FROM cuentaa)
|
||||
AND H.HVD_PRONOMBRE = '${nombreProducto}'
|
||||
GROUP BY
|
||||
F.Fecha
|
||||
ORDER BY
|
||||
SUBSTR(F.Fecha, 7, 4),
|
||||
SUBSTR(F.Fecha, 4, 2),
|
||||
SUBSTR(F.Fecha, 1, 2)
|
||||
"$
|
||||
|
||||
' Log($"Ejecutando para: ${nombreProducto}")
|
||||
' Log(sql) ' Descomenta esto si necesitas depurar el query
|
||||
|
||||
Dim prohit2 As Cursor = B4XPages.MainPage.skmt.ExecQuery(sql)
|
||||
|
||||
' --- 3. Leer los 4 resultados (YA NO NECESITAMOS BUCLE) ---
|
||||
' Sabemos que el query SIEMPRE devuelve 4 filas
|
||||
' en el orden correcto (hace 28, 21, 14, 7 días)
|
||||
Log(prohit2.RowCount)
|
||||
If prohit2.RowCount = 4 Then
|
||||
prohit2.Position = 0
|
||||
cant_sem4 = prohit2.GetString("HVD_CANT_TOTAL") ' Fila 1 (-28 días)
|
||||
|
||||
prohit2.Position = 1
|
||||
cant_sem3 = prohit2.GetString("HVD_CANT_TOTAL") ' Fila 2 (-21 días)
|
||||
|
||||
prohit2.Position = 2
|
||||
cant_sem2 = prohit2.GetString("HVD_CANT_TOTAL") ' Fila 3 (-14 días)
|
||||
|
||||
prohit2.Position = 3
|
||||
cant_sem1 = prohit2.GetString("HVD_CANT_TOTAL") ' Fila 4 (-7 días)
|
||||
Else
|
||||
Log($"Error: El query no devolvió 4 filas para '${nombreProducto}'"$)
|
||||
End If
|
||||
|
||||
prohit2.Close ' Cerramos el cursor interno
|
||||
|
||||
Dim promx As Double = (cant_sem4 + cant_sem3 + cant_sem2 + cant_sem1) / 4
|
||||
|
||||
|
||||
CustomListView1.Add(CreateListItem(nombreProducto, cant_sem4, cant_sem3, cant_sem2, cant_sem1, promx ), 1)
|
||||
|
||||
Next
|
||||
|
||||
prohit.Close ' Cerramos el cursor externo
|
||||
|
||||
End If
|
||||
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
Sub CreateListItem(prodhis As String, s1 As Int, s2 As Int, s3 As Int,s4 As Int, prom As Double) As Panel 'ignore
|
||||
Dim p As B4XView = xui.CreatePanel("")
|
||||
p.SetLayoutAnimated(0, 0, 0, 288dip, 170dip)
|
||||
p.LoadLayout("historicobat")
|
||||
l_productohist.Text = prodhis
|
||||
l_s1.Text = s1
|
||||
l_s2.Text = s2
|
||||
l_s3.Text = s3
|
||||
l_s4.Text = s4
|
||||
L_PROMEDIOHIST.text = "Promedio " & prom
|
||||
|
||||
Return p
|
||||
End Sub
|
||||
Binary file not shown.
BIN
B4A/Files/historicobat.bal
Normal file
BIN
B4A/Files/historicobat.bal
Normal file
Binary file not shown.
BIN
B4A/Files/historicobat2.bal
Normal file
BIN
B4A/Files/historicobat2.bal
Normal file
Binary file not shown.
Binary file not shown.
BIN
B4A/Files/nota2.bal
Normal file
BIN
B4A/Files/nota2.bal
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
@@ -19,6 +19,8 @@ ModuleBookmarks24=
|
||||
ModuleBookmarks25=
|
||||
ModuleBookmarks26=
|
||||
ModuleBookmarks27=
|
||||
ModuleBookmarks28=
|
||||
ModuleBookmarks29=
|
||||
ModuleBookmarks3=
|
||||
ModuleBookmarks4=
|
||||
ModuleBookmarks5=
|
||||
@@ -47,6 +49,8 @@ ModuleBreakpoints24=
|
||||
ModuleBreakpoints25=
|
||||
ModuleBreakpoints26=
|
||||
ModuleBreakpoints27=
|
||||
ModuleBreakpoints28=
|
||||
ModuleBreakpoints29=
|
||||
ModuleBreakpoints3=
|
||||
ModuleBreakpoints4=
|
||||
ModuleBreakpoints5=
|
||||
@@ -64,17 +68,19 @@ ModuleClosedNodes14=
|
||||
ModuleClosedNodes15=
|
||||
ModuleClosedNodes16=
|
||||
ModuleClosedNodes17=
|
||||
ModuleClosedNodes18=4
|
||||
ModuleClosedNodes18=
|
||||
ModuleClosedNodes19=
|
||||
ModuleClosedNodes2=
|
||||
ModuleClosedNodes20=
|
||||
ModuleClosedNodes20=4
|
||||
ModuleClosedNodes21=
|
||||
ModuleClosedNodes22=
|
||||
ModuleClosedNodes23=
|
||||
ModuleClosedNodes24=
|
||||
ModuleClosedNodes25=4,6,7,8,9
|
||||
ModuleClosedNodes25=
|
||||
ModuleClosedNodes26=
|
||||
ModuleClosedNodes27=
|
||||
ModuleClosedNodes27=3,4,6,8,9
|
||||
ModuleClosedNodes28=
|
||||
ModuleClosedNodes29=20
|
||||
ModuleClosedNodes3=
|
||||
ModuleClosedNodes4=
|
||||
ModuleClosedNodes5=
|
||||
@@ -82,6 +88,6 @@ ModuleClosedNodes6=
|
||||
ModuleClosedNodes7=6,8,9,10,11
|
||||
ModuleClosedNodes8=
|
||||
ModuleClosedNodes9=
|
||||
NavigationStack=Diseñador Visual,cliente.bal,-100,2,Main,Activity_Resume,46,0,Main,Globals,22,0,Main,Activity_Create,28,0,Main,Activity_ActionBarHomeClick,37,0,C_Cliente,Class_Globals,0,0,C_Cliente,Impresion3,2685,0,C_Cliente,B_IMP_Click,2674,2,C_Cliente,B4XPage_Appear,1145,3,C_Cliente,TraeCantProd,1222,6
|
||||
NavigationStack=B4XMainPage,Class_Globals,30,0,C_Cliente,recalculoXcant,1300,0,C_Cliente,B4XPage_Appear,542,0,C_Cliente,LA_GPS_Click,1353,0,Tracker,StartFLP2,403,0,Tracker,StartFLPSmall,421,0,Tracker,CreateLocationRequest2,462,1,Tracker,CreateLocationRequestSmallD,453,1,C_Cliente,MejorarPrecisionGPS,1283,4,Tracker,CreateLocationRequest,440,0
|
||||
SelectedBuild=0
|
||||
VisibleModules=25,2,14,26,5,10,11,20,19,16
|
||||
VisibleModules=27,2,16,28,5,13,17,29,19,4,12,22
|
||||
|
||||
@@ -41,6 +41,7 @@ Sub Process_Globals
|
||||
Dim encuesta As String = 0
|
||||
Public fFileProvider As FileProvider
|
||||
Dim tabla As String
|
||||
Dim enCliente As Boolean = False
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
|
||||
128
B4A/Subs.bas
128
B4A/Subs.bas
@@ -741,7 +741,7 @@ Sub borraPedidoClienteActual As String
|
||||
' Return 1
|
||||
Private thisC As Cursor
|
||||
' Private tablaProds As String = "cat_gunaprod2"
|
||||
thisC=Starter.skmt.ExecQuery("select PE_PROID, PE_CANT, PE_FOLIO FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) ")
|
||||
thisC=Starter.skmt.ExecQuery("select PE_PROID, PE_CANT, PE_FOLIO FROM PEDIDO where pe_cliente in (Select CUENTA from cuentaa) AND PE_CEDIS <> 'DUR'")
|
||||
If thisC.RowCount>0 Then
|
||||
For i=0 To thisC.RowCount -1
|
||||
thisC.Position = i
|
||||
@@ -759,7 +759,7 @@ End Sub
|
||||
|
||||
'Regresa el total del pedido en la tabla "PEDIDO" del cliente actual.
|
||||
Sub totalPedido As String
|
||||
Private cT As Cursor = Starter.skmt.ExecQuery($"select sum(PE_COSTO_TOT) as total from PEDIDO where PE_CLIENTE = '${traeCliente}'"$)
|
||||
Private cT As Cursor = Starter.skmt.ExecQuery($"select sum(PE_COSTO_TOT) as total from PEDIDO where PE_CLIENTE = '${traeCliente}' AND PE_CEDIS <> 'DUR'"$)
|
||||
Private pTotal As String = "0"
|
||||
If cT.RowCount > 0 Then
|
||||
cT.Position = 0
|
||||
@@ -826,9 +826,12 @@ Sub traeCliente As String 'ignore
|
||||
Private c As Cursor
|
||||
Private cl As String
|
||||
c=B4XPages.MainPage.skmt.ExecQuery("Select CUENTA from cuentaa")
|
||||
c.Position=0
|
||||
cl = c.GetString("CUENTA")
|
||||
If c.RowCount > 0 Then
|
||||
c.Position=0
|
||||
cl = c.GetString("CUENTA")
|
||||
End If
|
||||
c.Close
|
||||
Log($"Cliente=${cl}"$)
|
||||
Return cl
|
||||
End Sub
|
||||
|
||||
@@ -1312,6 +1315,7 @@ Sub guardaAppInfo 'ignore
|
||||
B4XPages.MainPage.skmt.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('APP_VERSION', '${Application.VersionName}')"$)
|
||||
End Sub
|
||||
|
||||
' Promo $150
|
||||
Sub TraeMontoProd As Boolean
|
||||
Private x As Boolean = False
|
||||
Private c As Cursor = B4XPages.MainPage.skmt.ExecQuery("SELECT ifnull( SUM (PE_COSTO_TOT),0) As suma FROM PEDIDO JOIN CAT_PROMO_ESP ON CAT_PE_ID = PE_PROID WHERE PE_CLIENTE IN (Select CUENTA FROM CUENTAA)")
|
||||
@@ -1320,7 +1324,6 @@ Sub TraeMontoProd As Boolean
|
||||
Private c2 As Cursor = B4XPages.MainPage.skmt.ExecQuery("SELECT DISTINCT CAT_PE_MONTO FROM CAT_PROMO_ESP")
|
||||
If c2.RowCount > 0 Then
|
||||
c2.Position = 0
|
||||
|
||||
If c.GetString("suma") >= c2.GetString("CAT_PE_MONTO") Then
|
||||
x = True
|
||||
' Log("verdadero")
|
||||
@@ -1328,7 +1331,6 @@ Sub TraeMontoProd As Boolean
|
||||
x = False
|
||||
' Log("Falso")
|
||||
End If
|
||||
|
||||
End If
|
||||
End If
|
||||
Return x
|
||||
@@ -1755,40 +1757,71 @@ Sub traeUsarIntentBDWA As Boolean 'ignore
|
||||
Return BDWA
|
||||
End Sub
|
||||
|
||||
Sub actualizaProducto(cedis As String, costoU As String, cant As String, nombre As String, prodId As String, clienteId As String, fecha As String, usuario As String, rutaV As String, precioSin As String, tipoVenta As String)
|
||||
Sub actualizaProducto(cedis As String, costoU As String, cant As String, nombre As String, prodId As String, clienteId As String, fecha As String, usuario As String, rutaV As String, precioSin As String, tipoVenta As String,dev As String)
|
||||
If nombre.Length < 6 Then ToastMessageShow("(actualizaProducto) El nombre del producto no es valido " & nombre, True)
|
||||
precioSin = NumberFormat2(precioSin, 1, 2, 2, False)
|
||||
costoU = NumberFormat2(costoU, 1, 2, 2, False)
|
||||
LogColor($"actualizaProducto, c=${clienteId}, p=${prodId}, nombre=${nombre}, cant=${cant}, cedis=${cedis}, tipo=${tipoVenta}"$, Colors.Magenta)
|
||||
' Private tablaProds As String = "cat_gunaprod2"
|
||||
' If tipoVenta = "ABORDO" Then tablaProds = "cat_gunaprod"
|
||||
Private c As Cursor=Starter.skmt.ExecQuery($"select * from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}'"$)
|
||||
If c.RowCount > 0 Then
|
||||
If dev = 0 Then
|
||||
Private c As Cursor=Starter.skmt.ExecQuery($"select * from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' and PE_CEDIS <> 'DUR'"$)
|
||||
If c.RowCount > 0 Then
|
||||
' LogColor("ACTUALIZAMOS PROD - " & traeTablaProds(tipoVenta), Colors.Blue)
|
||||
c.Position = 0
|
||||
Private antCant As Int = 0
|
||||
If IsNumber(c.GetInt("PE_CANT")) Then antCant=c.GetInt("PE_CANT")
|
||||
Private difCant As Int = cant - antCant
|
||||
Starter.skmt.ExecNonQuery($"update pedido set pe_cant = ${cant}, pe_costo_tot = ${NumberFormat2((cant*c.GetString("PE_COSTOU")), 1, 2, 2, False)}, pe_folio = '${tipoVenta}' where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
|
||||
If cedis <> "DUR" Then Starter.skmt.ExecNonQuery($"update ${traeTablaProds(tipoVenta)} set cat_gp_almacen = cat_gp_almacen - (${difCant}) where cat_gp_id = '${prodId}' "$)
|
||||
If cant = 0 Then
|
||||
LogColor($"BORRAMOS PRODUCTO - ${prodId}"$, Colors.Red)
|
||||
Starter.skmt.ExecNonQuery($"delete from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
|
||||
Log($"Borramos pe_cedis='${cedis}' and pe_proid='${prodId}' and pe_cliente='${clienteId}'"$)
|
||||
Private pe As Cursor = Starter.skmt.ExecQuery("select count(pe_cliente) as cuantosPedidos from pedido where pe_cliente In (select cuenta from cuentaa)")
|
||||
pe.Position=0
|
||||
If pe.GetString("cuantosPedidos") = 0 Then
|
||||
Log("###### delete from pedido_cliente - " & traeCliente & "|" & clienteId)
|
||||
Log($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
|
||||
Starter.skmt.ExecNonQuery($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
|
||||
c.Position = 0
|
||||
Private antCant As Int = 0
|
||||
If IsNumber(c.GetInt("PE_CANT")) Then antCant=c.GetInt("PE_CANT")
|
||||
Private difCant As Int = cant - antCant
|
||||
Starter.skmt.ExecNonQuery($"update pedido set pe_cant = ${cant}, pe_costo_tot = ${NumberFormat2((cant*c.GetString("PE_COSTOU")), 1, 2, 2, False)}, pe_folio = '${tipoVenta}' where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
|
||||
If cedis <> "DUR" Then Starter.skmt.ExecNonQuery($"update ${traeTablaProds(tipoVenta)} set cat_gp_almacen = cat_gp_almacen - (${difCant}) where cat_gp_id = '${prodId}' "$)
|
||||
If cant = 0 Then
|
||||
LogColor($"BORRAMOS PRODUCTO - ${prodId}"$, Colors.Red)
|
||||
Starter.skmt.ExecNonQuery($"delete from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
|
||||
Log($"Borramos pe_cedis='${cedis}' and pe_proid='${prodId}' and pe_cliente='${clienteId}'"$)
|
||||
Private pe As Cursor = Starter.skmt.ExecQuery("select count(pe_cliente) as cuantosPedidos from pedido where pe_cliente In (select cuenta from cuentaa)")
|
||||
pe.Position=0
|
||||
If pe.GetString("cuantosPedidos") = 0 Then
|
||||
Log("###### delete from pedido_cliente - " & traeCliente & "|" & clienteId)
|
||||
Log($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
|
||||
Starter.skmt.ExecNonQuery($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
'INSERTAMOS
|
||||
Else
|
||||
'INSERTAMOS
|
||||
' LogColor("INSERTAMOS PROD", Colors.red)
|
||||
If cant > 0 Then guardaProductoSinGestion(cedis, costoU, cant, nombre, prodId, clienteId, fecha, usuario, rutaV, precioSin, tipoVenta)
|
||||
If cant > 0 Then guardaProductoSinGestion(cedis, costoU, cant, nombre, prodId, clienteId, fecha, usuario, rutaV, precioSin, tipoVenta)
|
||||
End If
|
||||
c.Close
|
||||
Else If dev = 1 Then
|
||||
Private c As Cursor=Starter.skmt.ExecQuery($"select * from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' and PE_CEDIS = 'DUR'"$)
|
||||
If c.RowCount > 0 Then
|
||||
' LogColor("ACTUALIZAMOS PROD - " & traeTablaProds(tipoVenta), Colors.Blue)
|
||||
c.Position = 0
|
||||
Private antCant As Int = 0
|
||||
If IsNumber(c.GetInt("PE_CANT")) Then antCant=c.GetInt("PE_CANT")
|
||||
Private difCant As Int = cant - antCant
|
||||
Starter.skmt.ExecNonQuery($"update pedido set pe_cant = ${cant}, pe_costo_tot = ${NumberFormat2((cant*c.GetString("PE_COSTOU")), 1, 2, 2, False)}, pe_folio = '${tipoVenta}' where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
|
||||
If cedis <> "DUR" Then Starter.skmt.ExecNonQuery($"update ${traeTablaProds(tipoVenta)} set cat_gp_almacen = cat_gp_almacen - (${difCant}) where cat_gp_id = '${prodId}' "$)
|
||||
If cant = 0 Then
|
||||
LogColor($"BORRAMOS PRODUCTO - ${prodId}"$, Colors.Red)
|
||||
Starter.skmt.ExecNonQuery($"delete from pedido where pe_cedis = '${cedis}' and pe_proid = '${prodId}' and pe_cliente = '${clienteId}' "$)
|
||||
Log($"Borramos pe_cedis='${cedis}' and pe_proid='${prodId}' and pe_cliente='${clienteId}'"$)
|
||||
Private pe As Cursor = Starter.skmt.ExecQuery("select count(pe_cliente) as cuantosPedidos from pedido where pe_cliente In (select cuenta from cuentaa)")
|
||||
pe.Position=0
|
||||
If pe.GetString("cuantosPedidos") = 0 Then
|
||||
Log("###### delete from pedido_cliente - " & traeCliente & "|" & clienteId)
|
||||
Log($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
|
||||
Starter.skmt.ExecNonQuery($"delete from pedido_cliente where PC_CLIENTE = '${traeCliente}'"$)
|
||||
End If
|
||||
End If
|
||||
Else
|
||||
'INSERTAMOS
|
||||
' LogColor("INSERTAMOS PROD", Colors.red)
|
||||
If cant > 0 Then guardaProductoSinGestion(cedis, costoU, cant, nombre, prodId, clienteId, fecha, usuario, rutaV, precioSin, tipoVenta)
|
||||
End If
|
||||
c.Close
|
||||
End If
|
||||
c.Close
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
@@ -2191,4 +2224,39 @@ Sub alcanzanLosVariablesParaPromo(promoMap As Map, inventarioSinFijos As Map) As
|
||||
End If
|
||||
' Log(res)
|
||||
Return res
|
||||
End Sub
|
||||
|
||||
'Calcula el total de pedido tomando en cuenta si hay productos con promos por rango.
|
||||
Sub calculaTotalConPromoXRango(idCliente As String) As String
|
||||
' caso 1 pe_recant = Null
|
||||
' monto del pedido = pe_costo_tot
|
||||
' caso 2 pe_recant = pe_cant (solo prods dentro de rango)
|
||||
' monto del pedido = pe_recalculotot
|
||||
' caso 3 pe_recant <> pe_cant (hay prod dentro de rango y producto extra
|
||||
' monto del pedido = ((pe_cant - pe_reccant) * pe_costou) + pe_recalculotot
|
||||
' Log("888888888888")
|
||||
Private totalParcial As String = 0
|
||||
Private total As String = 0
|
||||
Private cx As Cursor = Starter.skmt.ExecQuery($"select *, ifnull(pe_reccant, 'N') as RECANT from pedido where pe_cliente = '${idCliente}'"$)
|
||||
If cx.RowCount > 0 Then
|
||||
For i = 0 To cx.RowCount - 1
|
||||
' Log("999999999999999999999999999999999999")
|
||||
cx.Position = i
|
||||
Log("***************************************")
|
||||
If cx.getstring("RECANT") = "N" Then ' Sin productos dentro de rango.
|
||||
totalParcial = cx.getstring("PE_COSTO_TOT")
|
||||
else if cx.getstring("RECANT") = cx.getstring("PE_CANT") Then ' Solo productos dentro de rango.
|
||||
totalParcial = cx.getstring("PE_RECALCULOTOT")
|
||||
Else ' hay productos dentro de rango y productos arriba del rango.
|
||||
totalParcial = ((cx.getstring("PE_CANT") - cx.getstring("PE_RECCANT")) * cx.getstring("PE_COSTOU")) + (cx.getstring("PE_RECALCULO") * cx.getstring("PE_RECCANT"))
|
||||
Log($"${((cx.getstring("PE_CANT") - cx.getstring("PE_RECCANT")) * cx.getstring("PE_COSTOU"))} + ${(cx.getstring("PE_RECALCULO") * cx.getstring("PE_RECCANT"))} "$)
|
||||
End If
|
||||
Log($"Total:${total} + Total Parcial: ${totalParcial}"$)
|
||||
total = total + totalParcial
|
||||
Next
|
||||
End If
|
||||
cx.Close
|
||||
total = NumberFormat2(total, 1, 2, 2, False)
|
||||
Log($"Total con promocXrango = ${total}"$)
|
||||
Return total
|
||||
End Sub
|
||||
381
B4A/Tracker.bas
381
B4A/Tracker.bas
@@ -4,6 +4,310 @@ ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=10.2
|
||||
@EndOfDesignText@
|
||||
'#Region Service Attributes
|
||||
' #StartAtBoot: True
|
||||
'#End Region
|
||||
''******************************************************************************
|
||||
''No olvidar agregar esta linea al editor de manifiesto:
|
||||
'' SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
|
||||
''
|
||||
''En Starter agregar estas lineas en Process_Globals
|
||||
'' Public rp As RuntimePermissions
|
||||
'' Public FLP As FusedLocationProvider
|
||||
'' Private flpStarted As Boolean
|
||||
''
|
||||
''En Main agregar estas lineas a Activity_Resume
|
||||
'' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
'' Wait For Activity_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(40) '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(0) '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)
|
||||
' LogColor($"Loc changed:${Location1.Longitude},${Location1.Latitude}"$, Colors.Red)
|
||||
' B4XPages.MainPage.lat_gps = Location1.Latitude
|
||||
' B4XPages.MainPage.lon_gps = Location1.Longitude
|
||||
' UUGCoords = Location1
|
||||
'' Starter.ubicacionActual = 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
|
||||
' If B4XPages.MainPage.lat_gps = 0 Or B4XPages.MainPage.lat_gps = Null And FLP.GetLastKnownLocation.IsInitialized Then
|
||||
' B4XPages.MainPage.lat_gps = FLP.GetLastKnownLocation.Latitude
|
||||
' B4XPages.MainPage.lon_gps = FLP.GetLastKnownLocation.Longitude
|
||||
' Starter.ubicacionActual = FLP.GetLastKnownLocation
|
||||
' LogColor("Coords en CERO - Guardamos ultima ubicacion conocida", Colors.red)
|
||||
' 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
|
||||
' If B4XPages.MainPage.cliente.LA_GPS.IsInitialized Then
|
||||
' B4XPages.MainPage.cliente.LA_GPS.Text = "CON UBICACION GPS"
|
||||
' B4XPages.MainPage.cliente.LA_GPS.TextColor = Colors.Black
|
||||
' End If
|
||||
'' LogColor(Location1.Latitude, Colors.red)
|
||||
' 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("GUNA", 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
|
||||
#StartAtBoot: True
|
||||
#End Region
|
||||
@@ -18,7 +322,7 @@ Version=10.2
|
||||
'
|
||||
'En Main agregar estas lineas a Activity_Resume
|
||||
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
' Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
|
||||
' If Result Then
|
||||
' StartService(Tracker)
|
||||
' Log("Start Tracker")
|
||||
@@ -32,6 +336,7 @@ Version=10.2
|
||||
'#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
|
||||
@@ -72,7 +377,7 @@ Sub Service_Start (StartingIntent As Intent)
|
||||
End Sub
|
||||
|
||||
Public Sub Track
|
||||
' Log("Inicia Track - Tracking : "&Tracking)
|
||||
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
|
||||
@@ -102,8 +407,22 @@ Public Sub StartFLP
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Public Sub StartFLP2
|
||||
Log("StartFLP2")
|
||||
Private logger As Boolean = True
|
||||
If logger Then Log("StartFLP2 - flpStarted="&flpStarted)
|
||||
Do While FLP.IsConnected = False
|
||||
Sleep(500)
|
||||
If logger Then Log("kll - sleeping")
|
||||
Loop
|
||||
dameUltimaUbicacionConocida 'Regresamos ultima ubicacion conocida
|
||||
FLP.RequestLocationUpdates(CreateLocationRequest2) 'Buscamos ubicacion 2 peticiones
|
||||
If logger Then LogColor("Buscamos ubicacion (movimientoMinimo = "&actualLR.GetSmallestDisplacement&")", Colors.Magenta)
|
||||
' If logger Then Log(actualLR.GetSmallestDisplacement)
|
||||
End Sub
|
||||
|
||||
Public Sub StartFLPSmall
|
||||
' Log("StartFLPSmall - flpStarted="&flpStarted)
|
||||
Log("StartFLPSmall - flpStarted="&flpStarted)
|
||||
Do While FLP.IsConnected = False
|
||||
Sleep(500)
|
||||
Log("sleeping")
|
||||
@@ -115,12 +434,12 @@ Public Sub StartFLPSmall
|
||||
End Sub
|
||||
|
||||
Private Sub CreateLocationRequest As LocationRequest
|
||||
' Log("CreateLocationRequest")
|
||||
Log("CreateLocationRequest")
|
||||
Dim lr As LocationRequest
|
||||
lr.Initialize
|
||||
lr.SetInterval(10000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
lr.SetInterval(2000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
lr.SetFastestInterval(lr.GetInterval / 2) 'Intervalo minimo para actualizaciones de ubicacion
|
||||
lr.SetSmallestDisplacement(40) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||
lr.SetSmallestDisplacement(15) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||
lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
|
||||
actualLR=lr
|
||||
Return lr
|
||||
@@ -132,8 +451,22 @@ Private Sub CreateLocationRequestSmallD 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(0) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||
lr.setNumUpdates(2) 'Solicitamos solo x actualizaciones con estos parametros
|
||||
lr.SetSmallestDisplacement(3) '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 CreateLocationRequest2 As LocationRequest
|
||||
Private logger As Boolean = True
|
||||
If logger Then Log("Iniciamos CreateLocationRequest2")
|
||||
Dim lr As LocationRequest
|
||||
lr.Initialize
|
||||
lr.SetInterval(1000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
lr.SetFastestInterval(lr.GetInterval / 2) 'Intervalo minimo para actualizaciones de ubicacion
|
||||
lr.setNumUpdates(2) 'Solicitamos solo x 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
|
||||
@@ -144,13 +477,13 @@ Sub dameUltimaUbicacionConocida
|
||||
' 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)
|
||||
' CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
|
||||
' Subs.mandamosLoc(coords)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub StopFLP
|
||||
'Log("StopFLP")
|
||||
Log("StopFLP")
|
||||
If flpStarted Then
|
||||
FLP.RemoveLocationUpdates 'Eliminamos todas las solicitudes de ubicacion
|
||||
flpStarted = False
|
||||
@@ -158,24 +491,17 @@ Public Sub StopFLP
|
||||
End Sub
|
||||
|
||||
Sub flp_LocationChanged (Location1 As Location)
|
||||
Log($"Loc changed:${Location1.Longitude},${Location1.Latitude}"$)
|
||||
' ToastMessageShow("Loc changed", False)
|
||||
LogColor($"Loc changed:${Location1.Longitude},${Location1.Latitude}"$, Colors.Red)
|
||||
B4XPages.MainPage.lat_gps = Location1.Latitude
|
||||
B4XPages.MainPage.lon_gps = Location1.Longitude
|
||||
UUGCoords = Location1
|
||||
' Starter.ubicacionActual = 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
|
||||
If B4XPages.MainPage.lat_gps = 0 Or B4XPages.MainPage.lat_gps = Null And FLP.GetLastKnownLocation.IsInitialized Then
|
||||
B4XPages.MainPage.lat_gps = FLP.GetLastKnownLocation.Latitude
|
||||
B4XPages.MainPage.lon_gps = FLP.GetLastKnownLocation.Longitude
|
||||
Starter.ubicacionActual = FLP.GetLastKnownLocation
|
||||
LogColor("Coords en CERO - Guardamos ultima ubicacion conocida", Colors.red)
|
||||
End If
|
||||
'/////// para la ultima localización FL
|
||||
Dim sDate,sTime As String
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
@@ -192,19 +518,22 @@ Sub flp_LocationChanged (Location1 As Location)
|
||||
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)
|
||||
' 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
|
||||
If B4XPages.MainPage.cliente.LA_GPS.IsInitialized Then
|
||||
B4XPages.MainPage.cliente.LA_GPS.Text = "CON UBICACION GPS"
|
||||
B4XPages.MainPage.cliente.LA_GPS.TextColor = Colors.Black
|
||||
End If
|
||||
' LogColor(Location1.Latitude, Colors.red)
|
||||
|
||||
CallSub2(Starter, "GPS_LocationChanged", Location1)
|
||||
' CallSub2(B4XPages.MainPage.cliente, "GPS_LocationChanged", Location1)
|
||||
' CallSub2(gestion, "GPS_LocationChanged", Location1)
|
||||
CallSub2(B4XPages.GetPage("Cliente"), "GPS_LocationChanged", Location1)
|
||||
|
||||
If B4XPages.MainPage.cliente.IsInitialized And Starter.enCliente Then
|
||||
CallSub2(B4XPages.GetPage("Cliente"), "GPS_LocationChanged", Location1)
|
||||
End If
|
||||
If B4XPages.MainPage.nuevoCliente.IsInitialized Then
|
||||
CallSub2(B4XPages.GetPage("nuevocliente"), "GPS_LocationChanged", Location1)
|
||||
End If
|
||||
' CallSub2(nuevocliente, "GPS_LocationChanged", Location1)
|
||||
End Sub
|
||||
|
||||
@@ -212,7 +541,7 @@ Sub CreateNotification (Body As String) As Notification
|
||||
Dim notification As Notification
|
||||
notification.Initialize2(notification.IMPORTANCE_LOW)
|
||||
notification.Icon = "icon"
|
||||
notification.SetInfo("GUNA", Body, Main)
|
||||
notification.SetInfo("ADM", Body, Main)
|
||||
Return notification
|
||||
End Sub
|
||||
|
||||
|
||||
28
B4A/_juntaBas.ps1
Normal file
28
B4A/_juntaBas.ps1
Normal file
@@ -0,0 +1,28 @@
|
||||
# SCRIPT: _juntaBas.ps1 - Versión Saneada y Optimizada para LLM
|
||||
$OutputFile="_CODIGO_COMPLETO_PARA_LLM.txt"
|
||||
|
||||
# Eliminar el archivo anterior si existe (IMPORTANTE)
|
||||
Remove-Item -Path $OutputFile -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host "Iniciando fusion para LLM..."
|
||||
|
||||
# Itera sobre los archivos .bas, .b4a, .b4j
|
||||
Get-ChildItem -Path ".\*" -Include @("*.bas", "*.b4a", "*.b4j") | ForEach-Object {
|
||||
$currentFile = $_.Name
|
||||
Write-Host "Procesando: $currentFile"
|
||||
|
||||
# --- ENCABEZADO ESTRUCTURADO Y COMENTADO EN B4X (Agregado al archivo) ---
|
||||
Add-Content -Path $OutputFile -Value "`n'======================================================================================"
|
||||
Add-Content -Path $OutputFile -Value $"// ARCHIVO_INICIO: ${currentFile}"
|
||||
Add-Content -Path $OutputFile -Value "'======================================================================================`n"
|
||||
|
||||
# Vuelca el contenido del archivo
|
||||
Get-Content -Encoding UTF8 -Path $_.FullName -Raw | Add-Content -Path $OutputFile
|
||||
|
||||
# --- DELIMITADOR DE FIN DE ARCHIVO (Agregado al archivo) ---
|
||||
Add-Content -Path $OutputFile -Value "`n'======================================================================================"
|
||||
Add-Content -Path $OutputFile -Value $"// ARCHIVO_FIN: ${currentFile}"
|
||||
Add-Content -Path $OutputFile -Value "'======================================================================================`n"
|
||||
}
|
||||
|
||||
Write-Host "`nProceso terminado. Se ha creado el archivo: $OutputFile"
|
||||
@@ -78,7 +78,7 @@ Sub Process_Globals
|
||||
'These variables can be accessed from all modules.
|
||||
|
||||
'Aqui va la liga al archivo .ver en el servidor que contiene la información de la aplicacion
|
||||
Public lnk As String = "https://keymon.lat/movil/guna/gunaPreventa.ver"
|
||||
Public lnk As String = "https://keymon.net/movil/guna/gunaPreventa.ver"
|
||||
' Public lnk As String = "https://10.0.0.205/Movil/Guna/cedex.ver"
|
||||
'##########################################
|
||||
'## La ruta en el servidor es: ##
|
||||
|
||||
Reference in New Issue
Block a user