B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=11.5
@EndOfDesignText@
Sub Class_Globals
	Private Root As B4XView 'ignore
	Private xui As XUI 'ignore
	'//Process Globals
	Dim g As GPS
	Dim clie_id As String
	Dim sDate,sTime As String
	Dim usuario As String
	'//Globals
	Dim c As Cursor
	Dim ruta As String
	Dim Regresar As Button
	Dim ListView1 As ListView
	Dim L_CANT As Label
	Dim L_TOTAL As Label
	Dim borra As Button
	Dim Existe As String
	Dim result As String
	Dim lat_gps, lon_gps As String
	Private Titulo As Label
	Private b_desc As Button
	Private ListView2 As ListView
	Private B_RMI As Button
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
	'load the layout to Root
	ruta = File.DirInternal
	Root.LoadLayout("historico")
	B_RMI.Visible = True
	borra.Visible = False
	Titulo.Text = "Acumulado"
	b_desc.Visible = False
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Sub B4XPage_Appear
	L_CANT.Text =""
	L_TOTAL.Text=""
	c=Starter.skmt.ExecQuery("select count(*) as EXISTE from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa)")
	C.Position=0
	Existe = C.GetString("EXISTE")
	C.Close
	c=Starter.skmt.ExecQuery("select HVD_CLIENTE,HVD_PRONOMBRE,HVD_CANT,HVD_COSTO_TOT, HVD_FECHA from HIST_VENTAS WHERE HVD_CLIENTE IN (Select CUENTA from cuentaa) order by HVD_FECHA asc")
	ListView1.Clear
	If c.RowCount>0 Then
		For i=0 To c.RowCount -1
			c.Position=i
			Dim label1 As Label
			label1 = ListView1.TwoLinesLayout.Label
			label1.TextSize = 15
			label1.TextColor = Colors.Black
			Dim label2 As Label
			label2 = ListView1.TwoLinesLayout.SecondLabel
			label2.TextSize = 10
			label2.TextColor = Colors.Black
			ListView1.AddTwoLines(c.GetString("HVD_PRONOMBRE"),"Cantidad #"& c.GetString("HVD_CANT")& " SubTotal $"& c.GetString("HVD_COSTO_TOT")& " FECHA " &c.GetString("HVD_FECHA") )
		Next
	End If
	If Existe <> 0 Then
		c=Starter.skmt.ExecQuery("select SUM(HVD_CANT) AS PC_NOART, SUM(HVD_COSTO_TOT) AS PC_MONTO from HIST_VENTAS where HVD_CLIENTE in (Select CUENTA from cuentaa)")
		C.Position=0
		L_CANT.Text = c.GetString("PC_NOART")
		L_TOTAL.Text = c.GetString("PC_MONTO")
	End If
End Sub

Sub GPS_LocationChanged (Location1 As Location)
'	lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
'	lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
End Sub

Sub Regresar_Click
	B_RMI.Visible = False
	Subs.iniciaActividad("Cliente")
End Sub

Sub B4XPage_CloseRequest As ResumableSub
	Log("Vamos a Cliente")
'	BACK key pressed
'	Return True To close, False To cancel
	Regresar_Click
'	Return True
	Return False
End Sub

Sub ListView2_ItemClick (Position As Int, Value As Object)
	ListView2.Visible = False
	ListView1.Visible = True
End Sub

Sub ListView1_ItemClick (Position As Int, Value As Object)
	ListView2.Visible = True
	ListView1.Visible = False
	Dim label1 As Label
	For i=0 To 20
		label1 = ListView2.SingleLineLayout.Label
		label1.TextSize = 15
		label1.TextColor = Colors.Black
		ListView2.AddSingleLine(i)
	Next
End Sub

Sub B_RMI_Click
	c=Starter.skmt.ExecQuery("select HR_CLIENTE,HR_PRONOMBRE,HR_CANT from HIST_RMI WHERE HR_CLIENTE IN (Select CUENTA from cuentaa)")
	ListView1.Clear
	If c.RowCount>0 Then
		For i=0 To c.RowCount -1
			c.Position=i
			Dim label1 As Label
			label1 = ListView1.TwoLinesLayout.Label
			label1.TextSize = 15
			label1.TextColor = Colors.Black
			Dim label2 As Label
			label2 = ListView1.TwoLinesLayout.SecondLabel
			label2.TextSize = 10
			label2.TextColor = Colors.Black
			ListView1.AddTwoLines(c.GetString("HR_PRONOMBRE"),"Cantidad #"& c.GetString("HR_CANT") )
		Next
	End If
End Sub