diff --git a/B4A/C_Cliente.bas b/B4A/C_Cliente.bas index e58a928..ae0538c 100644 --- a/B4A/C_Cliente.bas +++ b/B4A/C_Cliente.bas @@ -165,6 +165,7 @@ Sub Class_Globals Private encuestaRes As String Dim TOMAR_FOTO As String Private l_segmentoK2 As Label + dim salirDeEncuesta as Boolean End Sub Sub initialize @@ -223,6 +224,7 @@ End Sub Sub B4XPage_Appear indicePregunta = 0 + salirDeEncuesta = False If TOMAR_FOTO <> 0 Then Cuestionario c=Starter.skmt.ExecQuery2("select CAT_VA_VALOR from CAT_VARIABLES WHERE CAT_VA_DESCRIPCION = ?", Array As String ("MARCAS")) c.Position =0 @@ -500,7 +502,13 @@ End Sub Private Sub B4XPage_CloseRequest As ResumableSub cuest.encuestaIniciada = False cuest.ocultPanelPregunta - If sv_encuesta.Visible = True Then + Log(p_encuesta.Visible) + If p_encuesta.Visible Then + salirDeEncuesta = True + botonPresionado = 1 + ocultaPanelEncuesta + Return False + Else If sv_encuesta.Visible = True Then Return False Else If Subs.hayPedido Then ToastMessageShow("Hay VENTA, por favor presiona GUARDAR para continuar.", True) @@ -1840,21 +1848,16 @@ Sub Cuestionario b_encuesta_continuar.Visible = False et_encuesta.Visible = False DateTime.DateFormat = "MM/dd/yyyy" - sDate=DateTime.Date(DateTime.Now) - sTime=DateTime.Time(DateTime.Now) + sDate = DateTime.Date(DateTime.Now) + sTime = DateTime.Time(DateTime.Now) Private fecha As String = $"${DateTime.Date(DateTime.Now)} ${DateTime.Time(DateTime.Now)}"$ CUANTOS = 0 -' indicePregunta = 0 If logger Then Log($"Tomar_Foto = ${TOMAR_FOTO}"$) If TOMAR_FOTO = 0 Then s = Starter.skmt.ExecQuery("select COUNT(*) AS CUANTOS from HIST_ENCUESTA where HE_CLIE In (Select cuenta from cuentaa)") s.Position= 0 CUANTOS = s.GetString("CUANTOS") Private CUANTOS2 As Int = 0 -' s = Starter.skmt.ExecQuery("select COUNT(*) AS CUANTOS2 from HIST_ENCUESTA2 where HE_CLIENTE In (Select cuenta from cuentaa)") -' s.Position = 0 -' CUANTOS2 = s.GetString("CUANTOS2") -' If logger Then LogColor($"Hist:encuesta=${CUANTOS}, hist_encuesta2 = ${CUANTOS2}"$, Colors.Magenta) End If If logger Then Log(CUANTOS & "|" & CUANTOS2) If CUANTOS = 0 And CUANTOS2 = 0 Then @@ -1871,21 +1874,16 @@ Sub Cuestionario If logger Then Log(listaPreguntas) enc.position = 0 For i = 0 To enc.RowCount - 1 + Log($"SALIR DE ENCUESTA = ${salirDeEncuesta}"$) i = indicePregunta Log("####################################################") Log($"i = ${i}, indicePregunta = ${indicePregunta}"$) -' enc.Position = i -' If logger Then Log($"ROWCOUNT: ${enc.RowCount}"$) -' If logger Then Log($"tipo: ${enc.GetString("CAT_EP_IDTIPOPREGUNTA")}"$) If logger Then Log($"Tipo: ${enc.GetString("CAT_EP_IDTIPOPREGUNTA")}, CAT_EP_ID=${enc.GetString("CAT_EP_ID")}, CAT_EP_PREGUNTA=${enc.GetString("CAT_EP_PREGUNTA")}"$) - If enc.GetInt("CAT_EP_IDTIPOPREGUNTA") <> 4 And indicePregunta <> 0 Then - Log(333) indicePregunta = listaPreguntas.IndexOf(enc.GetString("CAT_EP_ID")) + 1 'Nos movemos a la posicion especificada por la respuesta, en las preguntas de tipo desicion, la respuesta nos indica a que pregunta movernos. i = indicePregunta Log($"i = ${i}"$) End If - If logger Then Log($"i = ${i}, indicePregunta: "$ & indicePregunta & ", TIPO: " & enc.GetString("CAT_EP_IDTIPOPREGUNTA")) ' Log($"Tomar_Foto = ${TOMAR_FOTO}"$) If logger Then Log($"EncuestaRes = ${encuestaRes}"$) @@ -1900,11 +1898,13 @@ Sub Cuestionario If logger Then Log($"i = ${i}"$) TOMAR_FOTO = 0 End If - If i > (enc.RowCount - 1) Then Exit ' Si se contestó la ultima pregunta, entonces salimos. - -' indicePregunta = listaPreguntas.IndexOf(enc.GetString("CAT_EP_ID")) 'Nos movemos a la posicion especificada por la respuesta, en las preguntas de tipo desicion, la respuesta nos indica a que pregunta movernos. -' i = indicePregunta - + If salirDeEncuesta = True Then + i = enc.RowCount + End If + If i > (enc.RowCount - 1) Then + Log("TERMINAMOS LA ENCUESTA") + Exit ' Si se contestó la ultima pregunta, entonces salimos. + End If enc.Position = i ' Log($"POSICION = ${enc.Position}"$) If enc.GetString("CAT_EP_IDTIPOPREGUNTA") = 1 Then ' Tipo Abierta @@ -1921,7 +1921,7 @@ Sub Cuestionario muestraEncuesta Log("Esperamos respuesta") Do Until botonPresionado = 1 'Esperamos que respondan la pregunta - Sleep(0) + Sleep(10) Loop indicePregunta = listaPreguntas.IndexOf(enc.GetString("CAT_EP_ID")) + 1 'Nos movemos a la posicion especificada por la respuesta, en las preguntas de tipo desicion, la respuesta nos indica a que pregunta movernos. Log($"Respuesta: ${encuestaRes}"$) @@ -2024,21 +2024,23 @@ Sub Cuestionario TOMAR_FOTO = 1 CURSOR_FOTO = i i = 0 -' Exit Else -' Starter.tipov = "VENTA" B4XPages.ShowPage("productos") End If Next enc.Close Else -' Starter.tipov = "VENTA" B4XPages.ShowPage("productos") End If Else -' Starter.tipov = "VENTA" B4XPages.ShowPage("productos") End If + If salirDeEncuesta Then ' Si se presionó BACK antes de terminar la encuesta, entonces borramos las preguntas contestadas. + Log("BORRAMOS RESPUESTAS") + Starter.skmt.ExecNonQuery($"delete from HIST_ENCUESTA where HE_CLIE = '${Subs.traeCliente}'"$) + indicePregunta = 0 + salirDeEncuesta = False + End If End Sub 'Muestra el panel de la encuesta, le da el alto y ancho de la pantalla y la pone en 0,0 diff --git a/B4A/Durakelo.b4a b/B4A/Durakelo.b4a index d6cbf21..24fb829 100644 --- a/B4A/Durakelo.b4a +++ b/B4A/Durakelo.b4a @@ -1398,7 +1398,7 @@ Version=12.8 #Region Project Attributes #ApplicationLabel: Durakelo #VersionCode: 1 - #VersionName: 4.05.21 + #VersionName: 4.05.22 'SupportedOrientations possible values: unspecified, landscape or portrait. #SupportedOrientations: portrait #CanInstallToExternalStorage: False diff --git a/B4A/Durakelo.b4a.meta b/B4A/Durakelo.b4a.meta index d483399..e06350d 100644 --- a/B4A/Durakelo.b4a.meta +++ b/B4A/Durakelo.b4a.meta @@ -60,7 +60,7 @@ ModuleClosedNodes16= ModuleClosedNodes17= ModuleClosedNodes18= ModuleClosedNodes19= -ModuleClosedNodes2= +ModuleClosedNodes2=2 ModuleClosedNodes20= ModuleClosedNodes21= ModuleClosedNodes22=1 @@ -73,6 +73,6 @@ ModuleClosedNodes6= ModuleClosedNodes7= ModuleClosedNodes8= ModuleClosedNodes9= -NavigationStack=C_Cliente,Class_Globals,1,0,C_Principal,cargar_Click,939,0,C_Principal,JobDone,1132,0,C_Cliente,B4XPage_Created,174,0,C_Cliente,B4XPage_Appear,234,6,Main,Globals,25,0,Main,Process_Globals,21,0,C_Cliente,muestraEncuesta,2033,0,C_Cliente,b_encuesta_1_Click,2069,0,C_Cliente,GPS_LocationChanged,397,0,C_Cliente,Cuestionario,1900,6 +NavigationStack=C_Cliente,b_encuesta_1_Click,2074,0,C_Cliente,GPS_LocationChanged,397,0,B4XMainPage,B4XPage_Created,148,0,C_Cliente,B_E_NEXT_Click,1607,0,C_Cliente,B_VENTA_Click,1314,1,C_Cliente,gest_Click,482,1,C_Cliente,Class_Globals,161,4,C_Cliente,B4XPage_Appear,219,6,C_Cliente,Cuestionario,2031,6,C_Cliente,B4XPage_CloseRequest,495,6 SelectedBuild=0 VisibleModules=2,10,4,19,5,6,8,9,11,24