Version: 4.12.15

Se agrego la geocerca a 50 mts
Se agregaron validaciones para tomar promociones aprovadas.
This commit is contained in:
Isaac
2024-12-17 11:51:44 -06:00
parent 52a14506b9
commit e5342c0236
12 changed files with 271 additions and 280 deletions

View File

@@ -7,11 +7,9 @@ Version=11.5
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Dim g As GPS
Dim ruta As String
Dim c As Cursor
Dim c As Cursor
Dim CANCELA As Button
Dim GUARDA As Button
Dim cuenta As String
@@ -19,8 +17,7 @@ Sub Class_Globals
Dim sDate,sTime As String
Dim sDate2,sTime2 As String
Dim no_cliente As String
Dim no_ruta As String
Dim no_ruta As String
Dim r_4 As RadioButton
Dim E_NOMBRE As EditText
Dim tgl As Toggle
@@ -31,7 +28,6 @@ Sub Class_Globals
Private p_cam As Panel
Private p_camara As Panel
Private b_foto_inci As Button
' Private camEx2 As CameraExClass2
Dim frontCamera As Boolean = False
Dim fototomada As String = "0"
Dim ALMACEN As String
@@ -44,6 +40,7 @@ Sub Class_Globals
Private cb_giro As B4XComboBox
Dim giros As String
Dim hr_ini As String
Dim hr_fin As String
Private L_Atiende As Label
Private ET_Atiende As EditText
Private Label5 As Label
@@ -59,33 +56,17 @@ Sub Class_Globals
Private l_ini 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)
' B4XPages.SetTitle(Me, $"${Subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
Root = Root1
'load the layout to Root
Root.LoadLayout("nuevocliente")
ruta = File.DirInternal
If File.Exists(ruta, "kmt.db") = False Then
File.Copy(File.DirAssets, "kmt.db", ruta, "kmt.db")
End If
' skmt.Initialize(ruta,"kmt.db", True)
' p_camara.Height = Root.Height
' p_camara.Width = Root.Width
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CAMERA)
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
' If Result Then
'' camEx2.Initialize(p_cam, frontCamera, Me, "Camera1")
'' frontCamera = camEx2.Front
' Log("inicializamos Camara")
' Else
' ToastMessageShow("Sin permisos de camara!!!", True)
' End If
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result Then
@@ -93,7 +74,6 @@ Private Sub B4XPage_Created (Root1 As B4XView)
Else
ToastMessageShow("Sin permisos de escritura!!!", True)
End If
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
If Result Then
@@ -103,8 +83,6 @@ Private Sub B4XPage_Created (Root1 As B4XView)
End If
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub B4XPage_Appear
et_direccion.Text = ""
E_NOMBRE.Text = ""
@@ -140,7 +118,6 @@ Sub B4XPage_Appear
StartActivity(Starter.GPS.LocationSettingsIntent)
Else
Starter.GPS.Start(0, 0)
' If Starter.ubicacionActual.Latitude <> 0 Then GPS_LocationChanged(Starter.ubicacionActual)
End If
CallSubDelayed(Tracker, "StartFLPSmall")
@@ -157,9 +134,7 @@ Sub B4XPage_Appear
End If
giros = "SELECCIONA UNA OPCIÓN"
c.Close
'-------------------------------------------------------------
Dim Items2 As List
Items2.Initialize
Items2.Add("SELECCIONA UNA OPCIÓN")
@@ -172,8 +147,13 @@ Sub B4XPage_Appear
hr_ini = ("SELECCIONA UNA OPCIÓN")
' --------------------------------------------------------------
Dim Item3 As List
Item3.Initialize
Item3.Add("SELECCIONA UNA OPCIÓN")
cb_hora_fin.SetItems(Item3)
hr_fin = "SELECCIONA UNA OPCIÓN"
l_ini.Text=""
l_fin.Text=""
End Sub
@@ -201,16 +181,11 @@ Sub CANCELA_Click
End Sub
Sub GUARDA_Click
' Verifica si el nombre de la tienda está vacío
If E_NOMBRE.Text = "" Then
MsgboxAsync("Por favor captura el nombre de la Tienda","Atención")
' Verifica si la dirección tiene más de 3 caracteres
Else If et_direccion.Text.Length > 3 Then
' Verifica si la latitud es diferente de 0
If lat <> 0 Then
' Verifica si el giro del cliente está seleccionado
If giros <> "SELECCIONA UNA OPCIÓN" Or cb_giro.SelectedItem <> "SELECCIONA UNA OPCIÓN" Then
' Verifica si el encargado que atiende el negocio está capturado
If ET_Atiende.Text <> "" Then
If et_colonia.Text <> "" Then
If et_colonia.Text <> "" Then
@@ -221,7 +196,6 @@ Sub GUARDA_Click
sDate = DateTime.Date(DateTime.Now)
sTime = DateTime.Time(DateTime.Now)
Log($" //////////// Date: ${sDate} - Time: ${sTime} ////////////////"$)
' Aquí creamos manualmente la hora con el separador de los 2 puntos porque en algunas versiones de Android no respeta el formato "Timeformat = 'HH:mm:ss'"
Private hora As String = sTime.SubString2(0,2)
Private mins As String = sTime.SubString2(2,4)
Private segs As String = sTime.SubString(4)
@@ -247,23 +221,19 @@ Sub GUARDA_Click
c.Position = 0
usuario = c.GetString("USUARIO")
c.Close
' Starter.skmt.ExecNonQuery2("INSERT INTO HIST_FOTO_CLIENTE(CODIGO, ALMACEN, RUTA) VALUES(?,?,?)", Array As Object(no_cliente, ALMACEN, no_ruta))
' Starter.skmt.ExecNonQuery2("INSERT INTO NOVENTA (NV_CLIENTE,NV_FECHA,NV_USER,NV_MOTIVO,NV_LAT,NV_LON,NV_NOMBRE,NV_DIRECCION) VALUES(?,?,?,?,?,?,?,?) ", Array As Object (no_cliente,sDate & sTime, usuario, "NUEVO CLIENTE", lat, lon, E_NOMBRE.Text,et_direccion.Text))
DateTime.DateFormat = "dd/MM/yyyy"
DateTime.Timeformat = "HH:mm:ss"
sDate2 = DateTime.Date(DateTime.Now)
sTime2 = DateTime.Time(DateTime.Now)
Starter.skmt.ExecNonQuery2("INSERT INTO CLIENTES_NUEVOS(CN_ID, CN_FECHA, CN_USER, CN_LAT, CN_LON, CN_NOMBRE, CN_DIRECCION, CN_FOTO, CN_RUTA, CN_GIRO, CN_SOLICITA,CN_COLONIA, CN_TELEFONO, CN_REFERENCIA, CN_HR_INICIO, CN_HR_FIN) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", Array As String(no_cliente, sDate2 &" "&sTime2, usuario, lat, lon, E_NOMBRE.Text, et_direccion.Text, ALMACEN, no_ruta, cb_giro.SelectedItem, ET_Atiende.Text,et_colonia.Text,et_telefono.Text, et_referencia.Text, cb_hora_ini.SelectedItem, cb_hora_fin.SelectedItem))
' fototomada = "0"
B4XPages.ShowPage("Cliente")
B4XPages.ShowPage("Principal")
CallSubDelayed(Tracker, "StartFLP")
Else
MsgboxAsync("Por favor, debe capturar la referencia de el negocio.","Atención")
MsgboxAsync("Por favor, debe capturar la apertura del negocio.","Atención")
End If
Else
MsgboxAsync("Por favor, debe capturar la referencia de el negocio.","Atención")
MsgboxAsync("Por favor, debe capturar el cierre del negocio.","Atención")
End If
Else
MsgboxAsync("Por favor, debe capturar la colonia el negocio.","Atención")
@@ -272,7 +242,6 @@ Sub GUARDA_Click
MsgboxAsync("Por favor, debe capturar el telfono.","Atención")
End If
Else
' Mensaje de advertencia si ET_Atiende.Text está vacío
MsgboxAsync("Por favor, debe capturar al encargado que atiende el negocio.","Atención")
End If
Else
@@ -286,147 +255,50 @@ Sub GUARDA_Click
End If
End Sub
Private Sub p_nuevoCliente_Click
End Sub
'Private Sub b_foto_inci_Click
' camEx2.TakePicture
' p_camara.Visible = False
'' StopCamera2
'End Sub
'
'Private Sub InitializeCamera2
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CAMERA)
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
' If Result Then
' camEx2.Initialize(p_cam, frontCamera, Me, "Camera1")
' frontCamera = camEx2.Front
' Log("inicializamos Camara")
' Else
' ToastMessageShow("Sin permisos de camara!!!", True)
' End If
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
' If Result Then
' Log("con permisos para escritura")
' Else
' ToastMessageShow("Sin permisos de escritura!!!", True)
' End If
'
' Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_READ_EXTERNAL_STORAGE)
' Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
' If Result Then
' Log("con permisos para escritura")
' Else
' ToastMessageShow("Sin permisos de lectura!!!", True)
' End If
'End Sub
'
'Sub Camera1_Ready (Success As Boolean)
' Log("Camara ready")
' If Success Then
' camEx2.SetJpegQuality(90)
' camEx2.SetContinuousAutoFocus
' camEx2.CommitParameters
' camEx2.StartPreview
' Log(camEx2.GetPreviewSize)
' Else
' ToastMessageShow("Cannot open camera.", True)
' Log("Cannot open camera")
' End If
'End Sub
'
'Sub Camera1_PictureTaken (Data()As Byte)
' Log("tome foto")
' Dim filename As String = fototomada
' Dim Dirp As String = File.DirInternal
' Dim Dir As String
' Dim Dir2 As String
' Try
' File.MakeDir(Dirp,"/promotoriakmts")
' Dir = "/promotoriakmts"
' Log("creado en promotoria " & Dirp & Dir)
' Catch
' Dir = ""
' Log("creado en raiz")
' End Try
'
' Try
' File.MakeDir(Dirp & Dir,"/reduccion")
' Dir2 = "/reduccion"
' Log("creado en promotoria " & Dirp & Dir & Dir2)
' Catch
' Dir = ""
' Log("creado en raiz")
' End Try
'
' camEx2.SavePictureToFile(Data, Dirp&Dir, filename)
' camEx2.StartPreview 'restart preview
' ToastMessageShow("Picture saved." & CRLF & "File size: " & File.Size(Dir, filename) & Dir &"," & filename, True)
' Log("Picture saved." & CRLF & "File size: " & File.Size(Dir, filename) & Dir &"," & filename)
' p_camara.Visible = False
' StopCamera2
'
'End Sub
'
'Private Sub StopCamera2
'' Capturing = False
' If camEx2.IsInitialized Then
' camEx2.Release
' End If
'End Sub
'
'
'Private Sub B_FOTO_Click
' DateTime.DateFormat="ddMMyyyyHHmmss"
' InitializeCamera2
' Subs.panelVisible(p_camara, 0, 0)
' fototomada = DateTime.Now & "_cliente.jpg"
'End Sub
Private Sub cb_giro_SelectedIndexChanged (Index As Int)
giros = cb_giro.SelectedItem
End Sub
Private Sub cb_hora_ini_SelectedIndexChanged (Index As Int)
Private Sub cb_hora_ini_SelectedIndexChanged(Index As Int)
Dim Item3 As List
Item3.Initialize
Item3.Add("SELECCIONA UNA OPCIÓN")
If cb_hora_ini.SelectedIndex > 0 Then
Dim horaInicio As Int = cb_hora_ini.SelectedItem + 1
For i = horaInicio To 23
Dim hora As String
hora = i
Item3.Add(hora)
Next
Else
Item3.Add("SELECCIONA UNA OPCIÓN")
If Index = 0 Then
l_ini.Text = ""
cb_hora_fin.SetItems(Item3)
Return
End If
Dim horaInicio As Int = cb_hora_ini.SelectedItem + 1
For i = horaInicio To 23
Dim hora As String
hora = i
Item3.Add(hora)
Next
cb_hora_fin.SetItems(Item3)
If cb_hora_ini.SelectedItem >= 7 And cb_hora_ini.SelectedItem <= 11 Then
l_ini.Text = "AM"
Else If cb_hora_ini.SelectedItem >= 12 And cb_hora_ini.SelectedItem <= 23 Then
l_ini.Text = "PM"
Else
l_ini.Text = ""
End If
End Sub
Private Sub cb_hora_fin_SelectedIndexChanged (Index As Int)
Private Sub cb_hora_fin_SelectedIndexChanged(Index As Int)
If Index = 0 Then
l_fin.Text = ""
Return
End If
If cb_hora_fin.SelectedItem >= 7 And cb_hora_fin.SelectedItem <= 11 Then
l_fin.Text = "AM"
Else If cb_hora_fin.SelectedItem >= 12 And cb_hora_fin.SelectedItem <= 23 Then
l_fin.Text = "PM"
Else
l_fin.Text = ""
End If
End Sub