B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=12.5
@EndOfDesignText@
Sub Class_Globals
	Private Root As B4XView 'ignore
	Private xui As XUI 'ignore
	Private p_check As Panel
	Private sv_datos As ScrollView
	
	Private camEx As CameraExClass
	Dim frontCamera As Boolean = False
	Private p_cam As Panel
	Dim  nombrefoto As String = "0"
	Dim  nombrefoto1 As String = "0"
	Dim  nombrefoto2 As String = "0"
	Dim  nombrefoto3 As String = "0"
	Private p_camara As Panel
	Private teclado As IME
	Dim fototomada As String
	Private ImageView1 As ImageView
	Private ImageView3 As ImageView
	Private ImageView2 As ImageView
	Private ImageView4 As ImageView
	Private b_foto As Button
	Dim device As Phone
	Dim MES1 As ManageExternalStorage
	Dim x As Int = 0
	Private rb_docsi1 As RadioButton
	Private rb_docno1 As RadioButton
	Private rb_docsi2 As RadioButton
	Private rb_docno2 As RadioButton
	Private rb_docsi3 As RadioButton
	Private rb_docno3 As RadioButton
	Private rb_docsi4 As RadioButton
	Private rb_docno4 As RadioButton
	Private rb_docsi5 As RadioButton
	Private rb_docno5 As RadioButton
	Private rb_docsi6 As RadioButton
	Private rb_docno6 As RadioButton
	Private rb_docsi7 As RadioButton
	Private rb_docno7 As RadioButton
	Private rb_docsi8 As RadioButton
	Private rb_docno8 As RadioButton
	Private rb_docsi9 As RadioButton
	Private rb_docno9 As RadioButton
	Private rb_docsi10 As RadioButton
	Private rb_docno10 As RadioButton
	Private rb_docsi11 As RadioButton
	Private rb_docno11 As RadioButton
	Private rb_docsi12 As RadioButton
	Private rb_docno12 As RadioButton
	Private rb_docsi13 As RadioButton
	Private rb_docno13 As RadioButton
	Private rb_docsi14 As RadioButton
	Private rb_docno14 As RadioButton
	Private rb_docsi15 As RadioButton
	Private rb_docno15 As RadioButton
	Private rb_docsi16 As RadioButton
	Private rb_docno16 As RadioButton
	Private rb_docsi17 As RadioButton
	Private rb_docno17 As RadioButton
	Private rb_docsi18 As RadioButton
	Private rb_docno18 As RadioButton
	Private rb_docsi19 As RadioButton
	Private rb_docno19 As RadioButton
	Private et_carroceria As EditText
	Private et_luces As EditText
	Private et_placas As EditText
	Private et_liquidos As EditText
	
	Dim p1 As String
	Dim p2 As String
	Dim p3 As String
	Dim p4 As String
	Dim p5 As String
	Dim p6 As String
	Dim p7 As String
	Dim p8 As String
	Dim p9 As String
	Dim p10 As String
	Dim p11 As String
	Dim p12 As String
	Dim p13 As String
	Dim p14 As String
	Dim p15 As String
	Dim p16 As String
	Dim p17 As String
	Dim p18 As String
	Dim p19 As String
	Private cb_izqdel As B4XComboBox
	Private cb_derdel As B4XComboBox
	Private cb_izqatras As B4XComboBox
	Private cb_deratras As B4XComboBox
	Dim itemselect1 As String
	Dim itemselect2 As String
	Dim itemselect3 As String
	Dim itemselect4 As String
	Dim foto1() As Byte
	Dim foto2() As Byte
	Dim foto3() As Byte
	Dim foto4() As Byte
	Dim c As Cursor
	Dim reqManager As DBRequestManager
	Private l_placa As Label
	Private et_km As EditText
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
	Root.LoadLayout("checklist")
	
	sv_datos.Height = Root.Height
	sv_datos.Width = Root.Width
	sv_datos.Panel.LoadLayout("check")
	sv_datos.Panel.Height = p_check.Height
	p_check.Width = Root.Width
	p_camara.Width = Root.Width
	p_camara.Height = Root.Height
	
	
	Dim items As List
	items.Initialize
	items.Add("100%")
	items.Add("75%")
	items.Add("50%")
	items.Add("25%")
	cb_deratras.SetItems(items)
	cb_izqatras.SetItems(items)
	cb_derdel.SetItems(items)
	cb_izqdel.SetItems(items)
	itemselect1 = "100%"
	itemselect2 = "100%"
	itemselect3 = "100%"
	itemselect4 = "100%"
	
	reqManager.Initialize(Me, B4XPages.MainPage.server)
End Sub

Private Sub B4XPage_Appear
	c = Starter.skmt.ExecQuery("SELECT PLACA FROM HIST_VENTAS")
	c.Position = 0
	Log(c.GetString("PLACA"))
	l_placa.Text = c.GetString("PLACA")
	c.Close
	Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CAMERA)
	Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
	If Result Then
'		camEx.Initialize(p_cam, frontCamera, Me, "Camera1")
'		frontCamera = camEx.Front
		Log("inicializamos Camara")
	Else
		ToastMessageShow("No permission Camara!!!", True)
	End If
	MES1.Initialize(Me, "MES1")
	
	' get the device SDK version
	Dim SdkVersion As Int = device.SdkVersion
	
	' Choose which permission to request in order to access external storgage
	If SdkVersion < 30 Then
		Log("SDK = " & SdkVersion & " : Requesting WRITE_EXTERNAL_STORAGE permission")
		Dim rp As RuntimePermissions
		rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE) ' Implicit read capability if granted
		Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
		Log($"PERMISSION_WRITE_EXTERNAL_STORAGE = ${Result}"$)
	Else
		Log("SDK = " & SdkVersion & " : Requesting MANAGE_EXTERNAL_STORAGE permission")
		Log("On Entry MANAGE_EXTERNAL_STORAGE = " & MES1.HasPermission)
		If Not(MES1.HasPermission) Then
			MsgboxAsync("Esta aplicación requiere acceso a todos los archivos, habilite la opción", "Administrar todos los archivos")
			Wait For Msgbox_Result(Res As Int)
			Log("Getting permission")
			MES1.GetPermission
			Wait For MES_StorageAvailable
		End If
	End If
	p_camara.Visible = False
	
	
'	Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
'	Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
'	If Result Then
'		Log("conpermisos para escritura")
'	Else
'		ToastMessageShow("No permission 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("conpermisos para escritura")
'	Else
'		ToastMessageShow("No permission Lectura!!!", True)
'	End If
End Sub

Private Sub B4XPage_CloseRequest As ResumableSub
	' BACK key pressed
	If p_camara.visible Then
		p_camara.visible = False
		StopCamera2
	Else
		B4XPages.ShowPage("principal")
	End If
	' Returning False signals the system to handle the key
	Return False
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
		camEx.Initialize(p_cam, frontCamera, Me, "Camera1")
		frontCamera = camEx.Front
		Log("inicializamos Camara")
	Else
		ToastMessageShow("No permission Camara!!!", True)
	End If
End Sub

Sub Camera1_Ready (Success As Boolean)
	Log("Camara ready")
	If Success Then
		camEx.SetJpegQuality(90)
		camEx.SetContinuousAutoFocus
		camEx.CommitParameters
		camEx.StartPreview
		Log(camEx.GetPreviewSize)
	Else
		ToastMessageShow("Cannot open camera.", True)
		Log("Cannot open camera")
	End If
End Sub

Sub Camera1_PictureTaken (Data()As Byte)
	If x = 1 Then
		DateTime.DateFormat="ddMMyyyyHHmmss"
		nombrefoto = DateTime.Now & "_FOTO1.jpg"
		teclado.HideKeyboard
		fototomada = nombrefoto
		
	Else If x = 2 Then
		DateTime.DateFormat="ddMMyyyyHHmmss"
		nombrefoto1 = DateTime.Now & "_FOTO2.jpg"
		teclado.HideKeyboard
		fototomada = nombrefoto1
		
	Else If x = 3 Then
		DateTime.DateFormat="ddMMyyyyHHmmss"
		nombrefoto2 = DateTime.Now & "_FOTO3.jpg"
		teclado.HideKeyboard
		fototomada = nombrefoto2
		
	Else If x = 4 Then
		DateTime.DateFormat="ddMMyyyyHHmmss"
		nombrefoto3 = DateTime.Now & "_FOTO4.jpg"
		teclado.HideKeyboard
		fototomada = nombrefoto3
		
	End If
	
	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,"/md")
		Dir = "/md"
		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
	
	camEx.SavePictureToFile(Data, Dirp&Dir, filename)
	camEx.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
	
	Log(nombrefoto)
	Log(nombrefoto1)
	Log(nombrefoto2)
	Log(nombrefoto3)
	
	If nombrefoto <> "0" Then
		Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 450, 600, True)
		Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, True)
		img.WriteToStream(out, 100, "PNG")
'		foto1 = File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto)
		
		out.Close
		ImageView1.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto)
		
	End If
	
	If nombrefoto1 <> "0" Then
		Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 450, 600, True)
		Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
		img.WriteToStream(out, 100, "PNG")
'		foto2 = File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto1)
		
		out.Close
		ImageView2.Bitmap = LoadBitmap(File.DirInternal & Dir& Dir2,nombrefoto1)
	End If
	
	If nombrefoto2 <> "0" Then
		Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 450, 600, True)
		Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
		img.WriteToStream(out, 100, "PNG")
'		foto3 = File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto2)
		
		out.Close
		ImageView3.Bitmap = LoadBitmap(File.DirInternal & Dir& Dir2,nombrefoto2)
	End If
	
	If nombrefoto3 <> "0" Then
		Dim img As B4XBitmap = xui.LoadBitmapResize(File.DirInternal & Dir, filename, 450, 600, True)
		Dim out As OutputStream = File.OpenOutput(File.DirInternal & Dir & Dir2, filename, False)
		img.WriteToStream(out, 100, "PNG")
'		foto4 = File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto3)
		
		out.Close
		ImageView4.Bitmap = LoadBitmap(File.DirInternal & Dir & Dir2,nombrefoto3)
	End If
	
	StopCamera2
	
End Sub

Private Sub p_camara_Click
	
End Sub

Private Sub b_foto_Click
	camEx.TakePicture
	p_camara.Visible = False
'	StopCamera2
End Sub

Private Sub StopCamera2
'	Capturing = False
	If camEx.IsInitialized Then
		camEx.Release
	End If
End Sub

Private Sub ImageView1_Click

	x = 1
	InitializeCamera2
	p_camara.Visible = True

End Sub

Private Sub ImageView2_Click

	x = 2
	InitializeCamera2
	p_camara.Visible = True

End Sub

Private Sub ImageView3_Click

	x = 3
	InitializeCamera2
	p_camara.Visible = True

End Sub

Private Sub ImageView4_Click

	x = 4
	InitializeCamera2
	p_camara.Visible = True

End Sub

Private Sub rb_docno1_CheckedChange(Checked As Boolean)
	p1 = "No"
End Sub

Private Sub rb_docsi1_CheckedChange(Checked As Boolean)
	p1 = "Si"
End Sub

Private Sub rb_docno2_CheckedChange(Checked As Boolean)
	p2 = "No"
End Sub

Private Sub rb_docsi2_CheckedChange(Checked As Boolean)
	p2 = "Si"
End Sub

Private Sub rb_docno3_CheckedChange(Checked As Boolean)
	p3 = "No"
End Sub

Private Sub rb_docsi3_CheckedChange(Checked As Boolean)
	p3 = "Si"
End Sub

Private Sub rb_docno4_CheckedChange(Checked As Boolean)
	p4 = "No"
End Sub

Private Sub rb_docsi4_CheckedChange(Checked As Boolean)
	p4 = "Si"
End Sub

Private Sub rb_docno5_CheckedChange(Checked As Boolean)
	p5 = "No"
End Sub

Private Sub rb_docsi5_CheckedChange(Checked As Boolean)
	p5 = "Si"
End Sub

Private Sub rb_docno6_CheckedChange(Checked As Boolean)
	p6 = "No"
End Sub

Private Sub rb_docsi6_CheckedChange(Checked As Boolean)
	p6 = "Si"
End Sub

Private Sub rb_docno7_CheckedChange(Checked As Boolean)
	p7 = "No"
End Sub

Private Sub rb_docsi7_CheckedChange(Checked As Boolean)
	p7 = "Si"
End Sub

Private Sub rb_docno8_CheckedChange(Checked As Boolean)
	p8 = "No"
End Sub

Private Sub rb_docsi8_CheckedChange(Checked As Boolean)
	p8 = "Si"
End Sub

Private Sub rb_docno9_CheckedChange(Checked As Boolean)
	p9 = "Incorrecto"
End Sub

Private Sub rb_docsi9_CheckedChange(Checked As Boolean)
	p9 = "Correcto"
End Sub

Private Sub rb_docno11_CheckedChange(Checked As Boolean)
	p11 = "Incorrecto"
End Sub

Private Sub rb_docsi11_CheckedChange(Checked As Boolean)
	p11 = "Correcto"
End Sub

Private Sub rb_docno13_CheckedChange(Checked As Boolean)
	p13 = "Incorrecto"
End Sub

Private Sub rb_docsi13_CheckedChange(Checked As Boolean)
	p13 = "Correcto"
End Sub

Private Sub rb_docno15_CheckedChange(Checked As Boolean)
	p15 = "Incorrecto"
End Sub

Private Sub rb_docsi15_CheckedChange(Checked As Boolean)
	p15 = "Correcto"
End Sub

Private Sub rb_docno16_CheckedChange(Checked As Boolean)
	p16 = "Incorrecto"
End Sub

Private Sub rb_docsi16_CheckedChange(Checked As Boolean)
	p16 = "Correcto"
End Sub

Private Sub rb_docno17_CheckedChange(Checked As Boolean)
	p17 = "Incorrecto"
End Sub

Private Sub rb_docsi17_CheckedChange(Checked As Boolean)
	p17 = "Correcto"
End Sub

Private Sub rb_docno18_CheckedChange(Checked As Boolean)
	p18 = "Incorrecto"
End Sub

Private Sub rb_docsi18_CheckedChange(Checked As Boolean)
	p18 = "Correcto"
End Sub

Private Sub rb_docno19_CheckedChange(Checked As Boolean)
	p19 = "Incorrecto"
End Sub

Private Sub rb_docsi19_CheckedChange(Checked As Boolean)
	p19 = "Correcto"
End Sub

Private Sub cb_izqdel_SelectedIndexChanged (Index As Int)
	itemselect1 = cb_izqdel.SelectedItem
	Log(itemselect1)
End Sub

Private Sub cb_izqatras_SelectedIndexChanged (Index As Int)
	itemselect2 = cb_izqatras.SelectedItem
	Log(itemselect2)
End Sub

Private Sub cb_derdel_SelectedIndexChanged (Index As Int)
	itemselect3 = cb_derdel.SelectedItem
	Log(itemselect3)
End Sub

Private Sub cb_deratras_SelectedIndexChanged (Index As Int)
	itemselect4 = cb_deratras.SelectedItem
	Log(itemselect4)
End Sub

Private Sub b_guardar_Click
	
	Dim Dirp As String = File.DirInternal
	Dim Dir As String
	Dim Dir2 As String
	Try
		File.MakeDir(Dirp,"/md")
		Dir = "/md"
		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
	
	DateTime.TimeFormat="HH:mm:ss"
	DateTime.DateFormat="dd/MM/yyyy"
	Dim checkdate As String = DateTime.Date(DateTime.Now)
	Dim checktime As String = DateTime.Time(DateTime.Now)
	If et_km.Text <> "" Then
		If rb_docno1.Checked Or rb_docsi1.Checked Then
			If rb_docno2.Checked Or rb_docsi2.Checked Then
				If rb_docno3.Checked Or rb_docsi3.Checked Then
					If rb_docno4.Checked Or rb_docsi4.Checked Then
						If rb_docno5.Checked Or rb_docsi5.Checked Then
							If rb_docno6.Checked Or rb_docsi6.Checked Then
								If rb_docno7.Checked Or rb_docsi7.Checked Then
									If rb_docno8.Checked Or rb_docsi8.Checked Then
										If rb_docno9.Checked Or rb_docsi9.Checked Then
											If (rb_docno9.Checked And et_carroceria.Text <> "") Or (rb_docsi9.Checked And et_carroceria.Text = "") Then
												If rb_docno11.Checked Or rb_docsi11.Checked Then
													If (rb_docno11.Checked And et_luces.Text <> "") Or (rb_docsi11.Checked And et_luces.Text = "") Then
														If rb_docno13.Checked Or rb_docsi13.Checked Then
															If (rb_docno12.Checked And et_placas.Text <> "") Or (rb_docsi13.Checked And et_placas.Text = "") Then
																If rb_docno15.Checked Or rb_docsi15.Checked Then
																	If rb_docno16.Checked Or rb_docsi16.Checked Then
																		If rb_docno17.Checked Or rb_docsi17.Checked Then
																			If rb_docno18.Checked Or rb_docsi18.Checked Then
																				If rb_docno19.Checked Or rb_docsi19.Checked Then
																					If et_liquidos.Text <> ""  And (rb_docno15.Checked Or rb_docno16.Checked Or rb_docno17.Checked Or rb_docno18.Checked Or rb_docno19.Checked) Or  et_liquidos.Text = ""  And (rb_docsi15.Checked And rb_docsi16.Checked And rb_docsi17.Checked And rb_docsi18.Checked And rb_docsi19.Checked) Then
																						If nombrefoto <> "0" And nombrefoto1 <> "0" And nombrefoto2 <> "0" And nombrefoto3 <> "0" Then
																							c = Starter.skmt.ExecQuery("SELECT RUTAA FROM RUTAA")
																							c.Position = 0
																							Private rutacheck As String = c.GetString("RUTAA")
																							c.Close
																							Starter.skmt.ExecNonQuery("DELETE FROM CHECKLIST2")
																							Starter.skmt.ExecNonQuery2("INSERT INTO CHECKLIST2(USUARIO, PLACA, FECHA_CAPTURA, TARJETA_CIRCULACION , POLIZA_SEGURO, LICENCIA_CONDUCIR, LIMPIA_EXTERNA, LIMPIA_INTERNA, TRIANGULO, GATO, LLANTA_REFACCION, CARROCERIA, CARROCERIA_COMENTARIOS, LUCES, LUCES_COMENTARIOS, CONDICION_PLACAS, CONDICION_PLACAS_COMENTARIOS, CONDICION_LLANTAS_DEL_DER, CONDICION_LLANTAS_DEL_IZQ, CONDICION_LLANTAS_TRASERA_DER, CONDICION_LLANTAS_TRASERA_IZQ, ACEITE, ANTICONGELANTE, FRENOS, AIRE, FUGAS, COMETARIOS_FUGAS, FOTO1, FOTO12, FOTO3, FOTO4, KILIMETRAJE,RUTA) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",Array As Object(B4XPages.MainPage.usuario,l_placa.Text,checkdate&" "&checktime,p1,p2,p3,p4,p5,p6,p7,p8,p9,et_carroceria.Text,p11,et_luces.Text,p13,et_placas.Text,itemselect1,itemselect2,itemselect3,itemselect4,p15,p16,p17,p18,p19,et_liquidos.Text,File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto),File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto1),File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto2),File.ReadBytes(File.DirInternal & Dir & Dir2, nombrefoto3), et_km.Text, rutacheck))
																									
																									
																							mandaPendientes
																									
																							rb_docno1.Checked = False
																							rb_docno2.Checked = False
																							rb_docno3.Checked = False
																							rb_docno4.Checked = False
																							rb_docno5.Checked = False
																							rb_docno6.Checked = False
																							rb_docno7.Checked = False
																							rb_docno8.Checked = False
																							rb_docno9.Checked = False
																							rb_docno11.Checked = False
																							rb_docno13.Checked = False
																							rb_docno15.Checked = False
																							rb_docno16.Checked = False
																							rb_docno17.Checked = False
																							rb_docno18.Checked = False
																							rb_docno19.Checked = False
																									
																							rb_docsi1.Checked = False
																							rb_docsi2.Checked = False
																							rb_docsi3.Checked = False
																							rb_docsi4.Checked = False
																							rb_docsi5.Checked = False
																							rb_docsi6.Checked = False
																							rb_docsi7.Checked = False
																							rb_docsi8.Checked = False
																							rb_docsi9.Checked = False
																							rb_docsi11.Checked = False
																							rb_docsi13.Checked = False
																							rb_docsi15.Checked = False
																							rb_docsi16.Checked = False
																							rb_docsi17.Checked = False
																							rb_docsi18.Checked = False
																							rb_docsi19.Checked = False
																									
																							cb_deratras.SelectedIndex = 0
																							cb_derdel.SelectedIndex = 0
																							cb_izqatras.SelectedIndex = 0
																							cb_izqdel.SelectedIndex = 0
																									
																							et_carroceria.Text = ""
																							et_liquidos.Text = ""
																							et_luces.Text = ""
																							et_placas.Text = ""
																									
																							ImageView1.Bitmap = LoadBitmap(File.DirAssets,"frontal1.png")
																							ImageView2.Bitmap = LoadBitmap(File.DirAssets,"derecha1.png")
																							ImageView3.Bitmap = LoadBitmap(File.DirAssets,"atras1.png")
																							ImageView4.Bitmap = LoadBitmap(File.DirAssets,"izquierda1.png")
																									
																							nombrefoto = "0"
																							nombrefoto1 = "0"
																							nombrefoto2 = "0"
																							nombrefoto3 = "0"
																									
																							B4XPages.ShowPage("Principal")
																						Else
																							MsgboxAsync("Favor de tomar todas las fotos","Atención")
																						End If
																					Else
																						MsgboxAsync("Especifica Fugas o detallaes en los liquidos","Atención")
																					End If
																				Else
																					MsgboxAsync("Seleeciona una opción en Niveles de Liquidos y aire de Fugas","Atención")
																				End If
																			Else
																				MsgboxAsync("Seleeciona una opción en Niveles de Liquidos y aire de Aire","Atención")
																			End If
																		Else
																			MsgboxAsync("Seleeciona una opción en Niveles de Liquidos y aire de Frenos","Atención")
																		End If
																	Else
																		MsgboxAsync("Seleeciona una opción en Niveles de Liquidos y aire de Anticongelante","Atención")
																	End If
																Else
																	MsgboxAsync("Seleeciona una opción en Niveles de Liquidos y aire de Aceite","Atención")
																End If
															Else
																MsgboxAsync("Especifica daños en las condiciones de placas","Atención")
															End If
														Else
															MsgboxAsync("Seleeciona una opción en Conciciones de placas de Correcto","Atención")
														End If
													Else
														MsgboxAsync("Especifica daños en las luces","Atención")
													End If
												Else
													MsgboxAsync("Seleeciona una opción en Funcionamiento de luces de Correcto","Atención")
												End If
											Else
												MsgboxAsync("Especifica daños en la carrocería","Atención")
											End If
										Else
											MsgboxAsync("Seleeciona una opción en Carrocería de Buen estado","Atención")
										End If
									Else
										MsgboxAsync("Seleeciona una opción en Seguridad y refación de Llanta de refacción","Atención")
									End If
								Else
									MsgboxAsync("Seleeciona una opción en Seguridad y refación de gato","Atención")
								End If
							Else
								MsgboxAsync("Seleeciona una opción en Seguridad y refación de Triagulo reflectante","Atención")
							End If
						Else
							MsgboxAsync("Seleeciona una opción en Limpieza unidad interna","Atención")
						End If
					Else
						MsgboxAsync("Seleeciona una opción en Limpieza unidad externa","Atención")
					End If
				Else
					MsgboxAsync("Seleeciona una opción en Documentación viegnte de Licencia de conducir","Atención")
				End If
			Else
				MsgboxAsync("Seleeciona una opción en Documentación viegnte de Póliza de seguro","Atención")
			End If
		Else
			MsgboxAsync("Seleeciona una opción en Documentación viegnte de tarjeta de circulación","Atención")
		End If
	Else
		MsgboxAsync("Captura el kilometraje inicial.","Atención")
	End If

End Sub

Sub mandaPendientes
	Log("MandaPendientes")
	'PEDIDO (Pendientes)
	c=Starter.skmt.ExecQuery("SELECT USUARIO, PLACA, FECHA_CAPTURA, TARJETA_CIRCULACION , POLIZA_SEGURO, LICENCIA_CONDUCIR, LIMPIA_EXTERNA, LIMPIA_INTERNA, TRIANGULO, GATO, LLANTA_REFACCION, CARROCERIA, CARROCERIA_COMENTARIOS, LUCES, LUCES_COMENTARIOS, CONDICION_PLACAS, CONDICION_PLACAS_COMENTARIOS, CONDICION_LLANTAS_DEL_DER, CONDICION_LLANTAS_DEL_IZQ, CONDICION_LLANTAS_TRASERA_DER, CONDICION_LLANTAS_TRASERA_IZQ, ACEITE, ANTICONGELANTE, FRENOS, AIRE, FUGAS, COMETARIOS_FUGAS, FOTO1, FOTO12, FOTO3, FOTO4 FROM CHECKLIST2")
	Log($"Pedido PENDIENTE: ${c.RowCount}"$)
	If c.RowCount > 0 Then
		For i = 0 To c.RowCount -1
			c.Position=i
			Dim cmd As DBCommand
			
			foto1 = c.GetBlob("FOTO1")
			foto2 = c.GetBlob("FOTO12")
			foto3 = c.GetBlob("FOTO3")
			foto4 = c.GetBlob("FOTO4")
			
			cmd.Initialize
			cmd.Name = "insert_CHECK_MARDS"
			cmd.Parameters = Array As Object(C.GetString("USUARIO"),C.GetString("PLACA"),C.GetString("FECHA_CAPTURA"),C.GetString("TARJETA_CIRCULACION"),C.GetString("POLIZA_SEGURO"),C.GetString("LICENCIA_CONDUCIR"),C.GetString("LIMPIA_EXTERNA"),C.GetString("LIMPIA_INTERNA"),C.GetString("TRIANGULO"),C.GetString("GATO"), C.GetString("LLANTA_REFACCION"),C.GetString("CARROCERIA"),c.GetString("CARROCERIA_COMENTARIOS"),c.GetString("LUCES"),c.GetString("LUCES_COMENTARIOS"),c.GetString("CONDICION_PLACAS"),c.GetString("CONDICION_PLACAS_COMENTARIOS"))'c.GetString("CONDICION_PLACAS_INCORRECTO"),c.GetString("CONDICION_PLACAS_COMENTARIOS"),c.GetString("CONDICION_LLANTAS_DEL_DER"),c.GetString("CONDICION_LLANTAS_DEL_IZQ"),c.GetString("CONDICION_LLANTAS_TRASERA_DER"),c.GetString("CONDICION_LLANTAS_TRASERA_IZQ"),c.GetString("ACEITE"),c.GetString("ANTICONGELANTE"),c.GetString("FRENOS"),c.GetString("AIRE"),c.GetString("FUGAS"),c.GetString("COMETARIOS_FUGAS"),foto1,foto2,foto3,foto4,B4XPages.MainPage.principal.ALMACEN)
			reqManager.ExecuteCommand(cmd , $"ins_checkliPendientes_head_${c.GetString("USUARIO")}"$)
		Next
	End If
End Sub

Sub JobDone(Job As HttpJob)
	Log("JOBDONE CLIENTE . " & Job.Success)
	If Job.Success = False Then
'		ToastMessageShow("Error: " & Job.ErrorMessage, True)
'		LogColor("JobDone Error: '" & reqManager.HandleJob(Job).tag, Colors.red)  'Mod por CHV - 211027
		LogColor("Error: " & Job.tag & " : " & Job.ErrorMessage, Colors.Blue)
	Else
		LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green)
		If Job.JobName = "DBRequest" Then
			Dim resultado As DBResult = reqManager.HandleJob(Job)
			If resultado.Tag.As(String).IndexOf("ins_checkliPendientes_head_") > -1 Then
				Private cliente As String= resultado.Tag
				cliente = cliente.SubString(cliente.IndexOf("_")+24)
				Log($"Cliente1:${cliente}"$)
				
				c=Starter.skmt.ExecQuery("SELECT USUARIO, PLACA, FECHA_CAPTURA, TARJETA_CIRCULACION , POLIZA_SEGURO, LICENCIA_CONDUCIR, LIMPIA_EXTERNA, LIMPIA_INTERNA, TRIANGULO, GATO, LLANTA_REFACCION, CARROCERIA, CARROCERIA_COMENTARIOS, LUCES, LUCES_COMENTARIOS, CONDICION_PLACAS, CONDICION_PLACAS_COMENTARIOS, CONDICION_LLANTAS_DEL_DER, CONDICION_LLANTAS_DEL_IZQ, CONDICION_LLANTAS_TRASERA_DER, CONDICION_LLANTAS_TRASERA_IZQ, ACEITE, ANTICONGELANTE, FRENOS, AIRE, FUGAS, COMETARIOS_FUGAS, FOTO1, FOTO12, FOTO3, FOTO4, KILIMETRAJE, RUTA FROM CHECKLIST2")
				Log($"Pedido PENDIENTE: ${c.RowCount}"$)
				If c.RowCount > 0 Then
					For i = 0 To c.RowCount -1
						c.Position=i
						Dim cmd As DBCommand
			
						foto1 = c.GetBlob("FOTO1")
						foto2 = c.GetBlob("FOTO12")
						foto3 = c.GetBlob("FOTO3")
						foto4 = c.GetBlob("FOTO4")
			
						cmd.Initialize
						cmd.Name = "update_CHECK_MARDS"
						cmd.Parameters = Array As Object(c.GetString("CONDICION_LLANTAS_DEL_DER"),c.GetString("CONDICION_LLANTAS_DEL_IZQ"),c.GetString("CONDICION_LLANTAS_TRASERA_DER"),c.GetString("CONDICION_LLANTAS_TRASERA_IZQ"),c.GetString("ACEITE"),c.GetString("ANTICONGELANTE"),c.GetString("FRENOS"),c.GetString("AIRE"),c.GetString("FUGAS"),c.GetString("COMETARIOS_FUGAS"),foto1,foto2,foto3,foto4,B4XPages.MainPage.principal.ALMACEN, C.GetString("KILIMETRAJE"),C.GetString("RUTA"), C.GetString("USUARIO"),C.GetString("PLACA"),C.GetString("FECHA_CAPTURA"))
						reqManager.ExecuteCommand(cmd , "update")
					Next
				End If
				
				For Each records() As Object In resultado.Rows
					For Each k As String In resultado.Columns.Keys
						Log(resultado.Tag & ": " & k & ": " & records(resultado.Columns.Get(k)))
					Next
				Next
				Starter.skmt.ExecNonQuery("UPDATE CHECADO_CHECK set CHECADO = 1 ")
'				B4XPages.MainPage.principal.checachek
			End If
		End If
	
		Job.Release
	End If
	
End Sub
