diff --git a/B4A/B4XMainPage.bas b/B4A/B4XMainPage.bas index b7ba452..0b131bb 100644 --- a/B4A/B4XMainPage.bas +++ b/B4A/B4XMainPage.bas @@ -103,6 +103,12 @@ Sub Class_Globals Private b_cargaLocalCancelar As Button Private p_botones As Panel Private b_importarBD As Button + Private cb_geocerca As CheckBox + Private p_geocerca As Panel + Private et_geocerca As EditText + Private b_geocerca As Button + Private l_greocerca As Label + Private b_aceptarGC As Button End Sub Public Sub Initialize @@ -343,6 +349,8 @@ Sub B4XPage_Appear End If End If kh.RD_Init + kh.SetButtonTintList(cb_geocerca, Colors.LightGray, Colors.RGB(43, 154, 211)) + cb_geocerca.Checked = kh.traeUsarGeocerca ' server = "http://keymon.com.mx:1782" ' server = "http://201.99.139.28:1782" ' server = "http://177.244.63.54:1782" @@ -596,7 +604,7 @@ Private Sub ImageView4_LongClick ' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE) ' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean) ' Subs.copiaDB(Result) - Dim x As Int = "a" +' Dim x As Int = "a" End Sub Sub B_SERVER_Click @@ -734,4 +742,38 @@ Private Sub b_importarBD_Click Else ToastMessageShow($"¡BD importada!"$, True) End If +End Sub + +Private Sub cb_geocerca_CheckedChange(Checked As Boolean) + Starter.skmt.ExecNonQuery("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'GEOCERCA'") + Starter.skmt.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('GEOCERCA', '${Checked}')"$) +End Sub + +Private Sub et_geocerca_TextChanged (Old As String, New As String) + Private x As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'FINDIA_PASS'"$) + If x.RowCount > 0 Then + x.Position = 0 + If New = x.GetString("CAT_VA_VALOR") Then + cb_geocerca.Enabled = True + l_greocerca.TextColor = Colors.RGB(43, 154, 211) + Else + cb_geocerca.Enabled = False + l_greocerca.TextColor = Colors.LightGray + End If + End If +End Sub + +Private Sub b_geocerca_Click + p_geocerca.Top = p_botones.Top + kh.centraPanel(p_geocerca, Root.Width) + p_geocerca.Elevation = 100dip + p_geocerca.BringToFront + p_geocerca.Visible = True +End Sub + +Private Sub p_geocerca_Click +End Sub + +Private Sub b_aceptarGC_Click + p_geocerca.Visible = False End Sub \ No newline at end of file diff --git a/B4A/C_Cliente.bas b/B4A/C_Cliente.bas index 930c93a..30329b0 100644 --- a/B4A/C_Cliente.bas +++ b/B4A/C_Cliente.bas @@ -9,6 +9,7 @@ Sub Class_Globals Private xui As XUI 'ignore '// Process Globals Dim g As GPS + dim kh as kms_helperSubs Dim reqManager As DBRequestManager Dim ruta As String Dim clie_id As String @@ -281,10 +282,13 @@ Sub Class_Globals Dim dentroDeGeocerca As Boolean = False Dim motivoNoVenta As String = "" Dim precision As Int = 0 + Dim clienteDeudor As Boolean = False + Dim usarGeocerca As Boolean = False End Sub 'You can add more parameters here. Public Sub Initialize As Object + kh.Initialize(Me, "kh") Return Me End Sub @@ -376,8 +380,8 @@ Sub B4XPage_Appear b_inicioFinVenta.Visible = False End If reqManager.Initialize(Me, Starter.DBReqServer) + usarGeocerca = kh.traeUsarGeocerca ' Log(Subs.traeUltimaActividadBD) - ' P_INF_GENERAL.Height = Root.Height ' P_INF_GENERAL.Width = Root.Width c = Starter.skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("MACIMP")) @@ -474,9 +478,11 @@ Sub B4XPage_Appear If CREDITO = "1" Then Msgbox("ALTO","A este cliente no se le puede vender ya que tienen adeudo en su crédito") 'ignore B_VENTA.Visible = False + clienteDeudor = True ' gest.Visible = False Else B_VENTA.Visible = True + clienteDeudor = False ' gest.Visible = True End If ' Msgbox(c.GetString("CAT_CL_NUM_SERIEFISICO"),"AVISO") @@ -704,27 +710,21 @@ Sub GPS_LocationChanged (Location1 As Location) '''' GEO CERCA '''' esto es para la geocerca validar tambien el las variables del whats y del no venta que las borra si existe venta - Dim l1, l2 As Location +' Dim l1, l2 As Location ' Log($"${Starter.lat_gps}, ${Starter.lon_gps}"$) If Starter.lat_gps = "null" Or Starter.lat_gps = Null Or Starter.lat_gps = "" Then 'Zocalo Starter.lat_gps = "19.432568527069805" Starter.lon_gps = "-99.13335030112772" End If - l1.Initialize2(Starter.lat_gps, Starter.lon_gps) - - -' Log($"Coordenadas de la tienda - lat:${m_lat}, lon:${m_lon}"$) - l2.Initialize2(m_lat, m_lon) - - Dim distance As Long - distance = l1.DistanceTo(l2) ' resultado en metros ' gest.Visible = True ' gps_boton_doe ="1" ' LogColor($"Distancia actual: ${distance}"$, Colors.Blue) - If distance <= 5000000 Or usuario = "KMTSKLL1" Or la_cuenta.Text = "0" Then + + 'Si no estamos usando la geocerca o ya estanos dentro de la geocerca o el usuario es KMTS1 o es abordo ... + If Not(usarGeocerca) Or dentroDeGeocerca Or usuario = "KMTSKLL1" Or la_cuenta.Text = "0" Then ' If pgs_boton_noventa = "1" Then b_noVenta.Visible = True ' If gps_boton_doe ="1" Then b_whats.Visible = True - B_VENTA.Visible = True + If Not(clienteDeudor) Then B_VENTA.Visible = True 'Si el cliente no tiene adeudo, habilitamos el boton de venta pedido_doe_muestra Else b_noVenta.Visible = False diff --git a/B4A/Files/login.bal b/B4A/Files/login.bal index 4085abc..1979ecb 100644 Binary files a/B4A/Files/login.bal and b/B4A/Files/login.bal differ diff --git a/B4A/KelloggsV4.b4a.meta b/B4A/KelloggsV4.b4a.meta index 0d9f88d..7e1b9cf 100644 --- a/B4A/KelloggsV4.b4a.meta +++ b/B4A/KelloggsV4.b4a.meta @@ -65,7 +65,7 @@ ModuleBreakpoints7= ModuleBreakpoints8= ModuleBreakpoints9= ModuleClosedNodes0= -ModuleClosedNodes1=2 +ModuleClosedNodes1=4 ModuleClosedNodes10= ModuleClosedNodes11= ModuleClosedNodes12= @@ -87,7 +87,7 @@ ModuleClosedNodes26=2 ModuleClosedNodes27= ModuleClosedNodes28= ModuleClosedNodes29= -ModuleClosedNodes3= +ModuleClosedNodes3=3 ModuleClosedNodes30=9,10,11 ModuleClosedNodes31= ModuleClosedNodes32= @@ -97,6 +97,6 @@ ModuleClosedNodes6= ModuleClosedNodes7= ModuleClosedNodes8= ModuleClosedNodes9= -NavigationStack=Subs,revisaBD,211,3,Subs,copiaDB,532,0,Starter,Application_Error,108,6,Visual Designer,MainPage.bal,-100,1,Visual Designer,login.bal,-100,3,errorManager,Activity_Pause,125,0,errorManager,Globals,57,0,Visual Designer,errormanager.bal,-100,6,errorManager,Activity_Resume,78,6,errorManager,Activity_Create,63,0,B4XMainPage,ImageView4_LongClick,592,0 +NavigationStack=C_Cliente,b_geopass_Click,3728,0,C_Cliente,Class_Globals,5,6,kms_helperSubs,traeUsarGeocerca,589,0,C_Cliente,B4XPage_Appear,376,6,kms_helperSubs,Class_Globals,24,0,B4XMainPage,b_importarBD_Click,738,0,kms_helperSubs,string2date,531,0,kms_helperSubs,SetButtonTintList,586,0,C_Cliente,Initialize,284,2,C_Cliente,GPS_LocationChanged,715,6,B4XMainPage,B4XPage_Appear,346,2 SelectedBuild=0 -VisibleModules=1,30,11,24,3,31 +VisibleModules=1,30,11,24,3,31,28 diff --git a/B4A/kms_helperSubs.bas b/B4A/kms_helperSubs.bas index bfc0546..218de28 100644 --- a/B4A/kms_helperSubs.bas +++ b/B4A/kms_helperSubs.bas @@ -28,6 +28,7 @@ Sub Class_Globals End Sub 'Inicializa la clase "kms_helperSubs". +'Ej. kh.Initialize(Me, "kh") Public Sub Initialize (vCallback As Object, vEventName As String) As Object EventName = vEventName CallBack = vCallback @@ -576,6 +577,31 @@ Sub CheckNotificationAccess As Boolean Return nstr.Contains(pstr) End Sub +'Change CheckBox colors +Sub SetButtonTintList(View As View, Disabled As Int, Enabled As Int) 'ignore + Dim States(2,1) As Int + Dim sd As StateListDrawable 'ignore + States(0, 0) = sd.State_Enabled + States(1, 0) = sd.State_Disabled + Dim Color(2) As Int = Array As Int(Enabled, Disabled) + Dim CSL As JavaObject + CSL.InitializeNewInstance("android.content.res.ColorStateList",Array(States,Color)) + Dim jo As JavaObject + jo.InitializeStatic("android.support.v4.widget.CompoundButtonCompat") + jo.RunMethod("setButtonTintList", Array(View, CSL)) +End Sub + +'Regresa si la geocerca se DEBE o NO de tomar en cuenta para la venta. +Sub traeUsarGeocerca As Boolean 'ignore + Private GC As Boolean = False + Private x As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'GEOCERCA'"$) + If x.RowCount > 0 Then + x.Position = 0 + If x.GetString("CAT_VA_VALOR") = "true" Then GC = True + End If + Return GC +End Sub + '################ Manage External Storage (MES) ######################### ' ''Inicializa "Manage External Storage" (MES), que nos da acceso a la tarjeta de memoria en Android 11+