diff --git a/B4A/C_Cliente.bas b/B4A/C_Cliente.bas index 9a69955..bb1fe9e 100644 --- a/B4A/C_Cliente.bas +++ b/B4A/C_Cliente.bas @@ -337,9 +337,7 @@ Sub B4XPage_Appear End If c.Close If ALMACEN = "1" Then - Tels.Visible = False - gest.Visible = False -' B_GPS.Visible = False + ocultamosBotonesPorGeocerca End If If ALMACEN = "4" Then ' b_like.Visible = True @@ -361,12 +359,22 @@ Sub B4XPage_Appear Else ' b_like.Visible = False End If - If ALMACEN = "16" Or ALMACEN = "13" Then + If Not(Subs.geocercaActiva) And ALMACEN = "16" Or ALMACEN = "13" Then + Log("Mostramos botones venta") Tels.Visible = True gest.Visible = True + b_ventaabordo.Visible = True + End If + + If Not(Subs.geocercaActiva) Then + Log("Mostramos botones venta") + Tels.Visible = True + gest.Visible = True + b_ventaabordo.Visible = True + Else + Log("Ocultamos botones venta") + ocultamosBotonesPorGeocerca End If - Tels.Visible = True - gest.Visible = True ' h = B4XPages.MainPage.skmt.ExecQuery("SELECT CUENTA from CUENTAA") ' h.Position = 0 @@ -446,42 +454,41 @@ Sub B4XPage_disappear End Sub Sub GPS_LocationChanged (Location1 As Location) -' LogColor($"Entrando a Cliente.GPS_LocationChanged"$, Colors.red) -' If Tracker.FLP.GetLastKnownLocation.IsInitialized And Tracker.FLP.GetLastKnownLocation.Latitude <> 0 Then -' B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude -' B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude -'' Log("Coords set to: " & B4XPages.MainPage.lat_gps & " and " & B4XPages.MainPage.lon_gps) -' End If - B4XPages.MainPage.lat_gps = Location1.Latitude - B4XPages.MainPage.lon_gps = Location1.Longitude + LogColor($"Entrando a Cliente.GPS_LocationChanged"$, Colors.red) + If Tracker.FLP.GetLastKnownLocation.IsInitialized And Tracker.FLP.GetLastKnownLocation.Latitude <> 0 Then + B4XPages.MainPage.lat_gps = Tracker.FLP.GetLastKnownLocation.Latitude + B4XPages.MainPage.lon_gps = Tracker.FLP.GetLastKnownLocation.Longitude +' Log("Coords set to: " & B4XPages.MainPage.lat_gps & " and " & B4XPages.MainPage.lon_gps) + End If - Dim locTienda As Location - locTienda.Initialize2(m_lat, m_lon) + Dim l1, l2 As Location + l1.Initialize2(B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps) ' Log($"Coordenadas de la tienda - lat:${m_lat}, lon:${m_lon}"$) + l2.Initialize2(m_lat, m_lon) BT_QR.Enabled = True LA_GPS.TextColor = Colors.Blue LA_GPS.Text = "CON UBICACION GPS" - distance = Location1.DistanceTo(locTienda) 'Distancia de la ubicacion actual a coords de la tienda. - Log("Distancia a tienda: " & distance) - If distance < 50 Then - gest.Visible = True + Log("CON UBICACION GPS") +' B_GPS.Enabled = True + 'now we need the distance between our location and the target location + distance = l1.DistanceTo(l2) 'the result is in meter + Log(distance) + Log((Subs.geocercaActiva And distance < 100)) + Log(Not(Subs.geocercaActiva)) + If (Subs.geocercaActiva And distance < 100) Or (Not(Subs.geocercaActiva)) Then + Log("Mostramos botones venta") + LA_GEO.TextColor = Colors.Blue Tels.Visible = True - If la_cuenta.Text = "0" Then - b_ventaabordo.Visible = False - Else - b_ventaabordo.Visible = True - End If + gest.Visible = True + b_ventaabordo.Visible = True Else - LA_GEO.TextColor = Colors.Red - If Subs.traeGeocerca Then - ocultamosBotonesPorGeocerca - End If +' LA_GEO.TextColor = Colors.Red End If LA_GEO.Text= $"$1.2{distance/1000} kms"$ B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM HIST_GPS") B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps)) -' CallSubDelayed(Tracker, "CreateLocationRequest") + CallSubDelayed(Tracker, "CreateLocationRequest") End Sub Sub ListView1_ItemLongClick (Position As Int, Value As Object) @@ -1048,6 +1055,7 @@ Sub B_GUARDA_C_Click Tar.Visible = True Tels.Visible = True gest.Visible = True + b_ventaabordo.Visible = True ' b_like.Visible = False Guardar.Visible = True End Sub @@ -1445,6 +1453,14 @@ Sub JobDone(Job As HttpJob) End If End If + 'Guarda coords nuevas + If Job.JobName = "DBRequest" Then + Dim resultado As DBResult = reqManager.HandleJob(Job) + If resultado.Tag = "insCoordsNuevas" Then + ToastMessageShow("Coordenadas actualizadas", False) + End If + End If + 'CUESTIONARIO If Job.JobName = "DBRequest" Then Dim resultado As DBResult = reqManager.HandleJob(Job) @@ -1737,4 +1753,22 @@ Sub ocultamosBotonesPorGeocerca gest.Visible = False b_ventaabordo.Visible = False Tels.Visible = False +End Sub + +Private Sub la_nombre_Click + Log("Clicked") + Log("Enviando coords") + DateTime.DateFormat = "MM/dd/yyyy" + sDate=DateTime.Date(DateTime.Now) + sTime=DateTime.Time(DateTime.Now) + B4XPages.MainPage.skmt.ExecNonQuery($"update kmt_info set cat_cl_lat = '${B4XPages.MainPage.lat_gps}', cat_cl_long = '${B4XPages.MainPage.lon_gps}' where cat_cl_codigo = '${la_cuenta.text}'"$) + + Dim cmd As DBCommand + cmd.Initialize + cmd.Name = "insert_coordsNuevas_INTMEX" + cmd.Parameters = Array As Object(B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps, Subs.traeAlmacen, Subs.traeRuta, la_cuenta.text) +' cmd.Parameters = Array As Object("1", "1", "5", "6", "CLN13478") + Log($"${Subs.traeAlmacen}, ${Subs.traeRuta},${la_cuenta.text},${B4XPages.MainPage.lat_gps},${B4XPages.MainPage.lon_gps}"$) + reqManager.ExecuteCommand(cmd , "insCoordsNuevas") + B4XPage_Appear End Sub \ No newline at end of file diff --git a/B4A/INTMEX.b4a b/B4A/INTMEX.b4a index 48b6feb..87545bd 100644 --- a/B4A/INTMEX.b4a +++ b/B4A/INTMEX.b4a @@ -164,7 +164,7 @@ Version=12.8 #Region Project Attributes #ApplicationLabel: Intmex #VersionCode: 1 - #VersionName: 6.02.20 GPS + #VersionName: 6.02.21 'SupportedOrientations possible values: unspecified, landscape or portrait. #SupportedOrientations: portrait #CanInstallToExternalStorage: False diff --git a/B4A/INTMEX.b4a.meta b/B4A/INTMEX.b4a.meta index 46e0d1c..e1ced1d 100644 --- a/B4A/INTMEX.b4a.meta +++ b/B4A/INTMEX.b4a.meta @@ -91,6 +91,6 @@ ModuleClosedNodes6= ModuleClosedNodes7= ModuleClosedNodes8= ModuleClosedNodes9= -NavigationStack=C_Cliente,Guardar_Click,619,6,C_Cliente,mandaPendientes,1277,0,Diseñador Visual,cliente.bal,-100,3,C_Cliente,Class_Globals,137,0,C_Cliente,B4XPage_Appear,238,0,C_Cliente,B4XPage_Created,209,6,C_Principal,Class_Globals,0,0,B4XMainPage,b_guardar_Click,789,0,Main,Activity_Create,29,0,B4XMainPage,Class_Globals,24,0 +NavigationStack=C_Cliente,B4XPage_disappear,440,0,C_Principal,JobDone,2068,0,C_Principal,cargar_Click,1030,0,C_Principal,Subir_Click,819,0,C_Principal,B4XPage_Appear,550,0,C_Principal,GPS_LocationChanged,2619,0,C_Cliente,GPS_LocationChanged,481,0,C_Cliente,B_GUARDA_C_Click,1055,0,C_Cliente,B4XPage_Appear,354,0,C_Cliente,la_nombre_Click,1769,0,C_Cliente,JobDone,1448,6 SelectedBuild=0 VisibleModules=28,2,13,20,14,29,15,4,11,21 diff --git a/B4A/Subs.bas b/B4A/Subs.bas index 7cbfa20..0f73523 100644 --- a/B4A/Subs.bas +++ b/B4A/Subs.bas @@ -1556,4 +1556,15 @@ Sub traeGeocerca As Boolean If c.GetInt("CAT_VA_VALOR") = 0 Then usarGeo = False End If Return usarGeo +End Sub + +'Revisa si la geocerca debe de estar activa +Sub geocercaActiva As Boolean + Private resultado As Boolean = True + Private c As Cursor = Starter.skmt.ExecQuery("select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'GEOCERCA'") + If c.RowCount > 0 Then + c.Position = 0 + If c.GetString("CAT_VA_VALOR") = 0 Then resultado = False + End If + Return resultado End Sub \ No newline at end of file diff --git a/B4A/_juntaBas.ps1 b/B4A/_juntaBas.ps1 index 2fd691d..30e34be 100644 --- a/B4A/_juntaBas.ps1 +++ b/B4A/_juntaBas.ps1 @@ -1,28 +1,127 @@ -# SCRIPT: _juntaBas.ps1 - Versión Saneada y Optimizada para LLM -$OutputFile="_CODIGO_COMPLETO_PARA_LLM.txt" +# SCRIPT: _juntaBas_Master_FinalIA.ps1 +# FIX: Corregida sintaxis de comillas y concatenación de tags XML. +# OBJETIVO: Fuente de verdad para IA con navegación ultra estructurada. -# Eliminar el archivo anterior si existe (IMPORTANTE) -Remove-Item -Path $OutputFile -ErrorAction SilentlyContinue +$ErrorActionPreference = 'SilentlyContinue' +$Dir = Get-Location +$LT = [char]60; $GT = [char]62; $SL = [char]47 +$NL = [Environment]::NewLine -Write-Host "Iniciando fusion para LLM..." +Write-Output '--- GENERANDO MASTER IA DEFINITIVO (FIX ESTRUCTURAL) ---' -# Itera sobre los archivos .bas, .b4a, .b4j -Get-ChildItem -Path ".\*" -Include @("*.bas", "*.b4a", "*.b4j") | ForEach-Object { - $currentFile = $_.Name - Write-Host "Procesando: $currentFile" +# 1. PARSEO DEL PROYECTO .B4A +$b4a = Get-ChildItem -Path ".\*" -Include "*.b4a" -Recurse | Select-Object -First 1 +$Name = 'App'; $Ver = '0.0'; $ModulosValidos = @(); $Librerias = @() - # --- 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" +if ($b4a) { + $lines = [System.IO.File]::ReadAllLines($b4a.FullName) + foreach ($L in $lines) { + if ($L -match '#ApplicationLabel:\s*(.*)') { $Name = $Matches[1].Trim() } + if ($L -match '#VersionName:\s*(.*)') { $Ver = $Matches[1].Trim() } + if ($L -match '^Module\d+=(.*)') { + $m = [System.IO.Path]::GetFileName($Matches[1].Trim()) + if (-not $m.EndsWith(".bas") -and $m -ne "Main") { $m += ".bas" } + $ModulosValidos += $m + } + if ($L -match '^Library\d+=(.*)') { $Librerias += $Matches[1].Trim() } + } } -Write-Host "`nProceso terminado. Se ha creado el archivo: $OutputFile" \ No newline at end of file +$OutName = "_" + $Name + "_" + $Ver + "_IA.md" +$OutFile = Join-Path $Dir $OutName + +# 2. HEADER CON TUS INSTRUCCIONES CRÍTICAS +$CurrentDate = Get-Date -Format 'yyyy-MM-dd HH:mm' +$Header = @" +# PROYECTO: $Name +- Version: $Ver +- Fecha: $CurrentDate +- Librerias Activas: $($Librerias -join ", ") + +## INSTRUCCIONES CRITICAS (B4A / BASIC4ANDROID) +0. **Integridad del Contexto:** Antes de procesar peticiones, cuenta si el numero de modulos listados en el indice coincide con los detallados en el cuerpo. +1. **Source of Truth (Codigo):** Este archivo contiene el codigo fuente ACTUAL del proyecto. +2. **Source of Truth (Librerias):** Basa tus sugerencias en la lista de 'Librerias Activas'. +3. **Anti-Alucinacion:** Antes de sugerir, VERIFICA la 'Interfaz Pública' o el código fuente del módulo. +4. **Existencia Estricta:** Si una variable/Sub no está en el texto, NO EXISTE. +5. **Formato:** Usa bloques 'vb'. +6. **Navegacion Estructural:** Usa los tags , y para localizar codigo. +7. **Inferencia de Datos:** Deduce la BD solo de los strings SQL presentes. +"@ + +Set-Content -Path $OutFile -Value $Header -Encoding UTF8 + +# 3. LISTAR ARCHIVOS +$files = Get-ChildItem -Path $Dir -Include *.bas,*.b4a -Recurse | Where-Object { + $_.FullName -notmatch 'Objects' -and ($_.Extension -eq '.b4a' -or $ModulosValidos -contains $_.Name) +} + +# 4. INDICE DE MODULOS +Add-Content $OutFile ($NL + "## INDICE DE MODULOS" + $NL) -Encoding UTF8 +foreach ($f in $files) { + $Ref = $f.Name.Replace('.', '').Replace(' ', '-').ToLower() + Add-Content $OutFile ("- [" + $f.Name + "](#modulo-" + $Ref + ")") -Encoding UTF8 +} + +# 5. CODIGO FUENTE ESTRUCTURADO +Add-Content $OutFile ($NL + '## CODIGO FUENTE DETALLADO' + $NL) -Encoding UTF8 + +foreach ($f in $files) { + Write-Host " -> $($f.Name)... " -NoNewline + $txt = [System.IO.File]::ReadAllLines($f.FullName) + + # Pre-escaneo para + $Methods = @() + foreach ($line in $txt) { + if ($line.Trim() -match '^(?:Public\s+|Private\s+)?Sub\s+([\w\d_]+)') { + $Methods += $Matches[1] + } + } + + $Ref = $f.Name.Replace('.', '').Replace(' ', '-').ToLower() + Add-Content $OutFile "$NL" -Encoding UTF8 + + Add-Content $OutFile " " -Encoding UTF8 + foreach($m in $Methods) { + Add-Content $OutFile " " -Encoding UTF8 + } + Add-Content $OutFile " $NL" -Encoding UTF8 + + Add-Content $OutFile "```vb" -Encoding UTF8 + + $skip = ($f.Extension -eq '.b4a') + + foreach ($l in $txt) { + $trim = $l.Trim() + + if ($skip) { + if ($trim.StartsWith("#") -and -not $trim.StartsWith("#Region")) { Add-Content $OutFile $l -Encoding UTF8 } + if ($l.Contains("@EndOfDesignText@")) { $skip = $false } + continue + } + + # Inicio de Método + if ($trim -match '^(?:Public\s+|Private\s+)?Sub\s+([\w\d_]+)') { + Add-Content $OutFile "" -Encoding UTF8 + } + + # Limpieza de comentarios y escritura de línea + if ($trim.StartsWith("'")) { + if (-not ($trim.StartsWith("'#") -or ($trim -match 'TODO:') -or ($trim -match 'FIX:'))) { continue } + } + + if (-not [string]::IsNullOrWhiteSpace($trim)) { + Add-Content $OutFile $l -Encoding UTF8 + } + + # Fin de Método + if ($trim -eq "End Sub") { + Add-Content $OutFile "" -Encoding UTF8 + } + } + + Add-Content $OutFile "```$NL" -Encoding UTF8 + Write-Host "OK" -ForegroundColor Green +} + +Write-Output ("--- FINALIZADO: " + $OutName + " ---") \ No newline at end of file