<html>
<head>
<meta name="GENERATOR">
</head>
<body>

<%
const adInteger = 3
const adDate = 7
const adChar = 129
const adVarChar = 200
const adLongVarChar = 201
const adParamInput = 1
const adParamOutput = 2
const adCmdText = 1
const adCmdStoredProc = 4
const adUseClient = 3
const adOpenForwardOnly = 0
const adLockReadOnly = 1
const ClienteInternetMadeira = 125
const ClienteDirectoBalcao = 17

Dim strCnn
Dim Tarifa_Default
Dim Tabela_Tarifas(200,12)
Dim Tabela_Tarifas_Ag(1300,13)
Dim Tabela_Tipo_Tarifas_Ag(10,2)
Dim Tabela_Dados_Tarifas_Ag(10,4)
Dim Tabela_Lugares(30,0)
Dim Tabela_Tipos(30,0)
Dim Tabela_Grupos(15,2)
Dim Tabela_Paises(20,2)
Dim Tabela_AgenciasInternet(20,2)
Dim Tabela_Hoteis(200,10)
Dim Tabela_Disponibilidade(10000,4)
Dim Tabela_Reservas(500,11)
Dim Tabela_Statement(400,7)
Dim Tabela_Guias(40,2)
Dim Tabela_Origens(100,22)
Dim GlobalResultado
Dim Viaturas_Livres
Dim Total_Viaturas
Dim NumeroReserva
Dim StatusReserva
Dim OBJComissoes
Dim Free_Days
Dim Maximo_Horas
Dim Fora_Hora_Entrega
Dim Fora_Min_Entrega
Dim Fora_Hora_Recolha
Dim Fora_Min_Recolha
Dim NomeUsuarioInternet
Dim NomeAgencia
Dim VerValores
Dim VerReservas
Dim nErro
Dim ip_servidor
Dim BasedeDados

strCnn = "driver={SQL Server};server=81.193.248.13;uid=sa;pwd=dbacdua06;database=RENTWAY"

Private Function GetRecordset(ByVal sQry)
    Dim oConn
    Dim oRec
    
    Set oConn = server.CreateObject("ADODB.Connection")
    Set oRec = server.CreateObject("ADODB.Recordset")
    
    oRec.CursorLocation = adUseClient
    oRec.CursorType = adOpenForwardOnly
    
    oConn.Open strCnn        
 
    oRec.Open sQry, oConn, adOpenForwardOnly, adLockReadOnly               
    Set GetRecordset = oRec
    
    Set oRec = Nothing
    Set oConn = Nothing
    
End Function

Function ConvertToJSArray2D(VBArray , ArrayName)
	Dim vb2jsRow, vb2jsCol , vb2jsStr, vb2jsi, vb2jsj
	vb2jsRow = Ubound(VBArray,1)
	vb2jsCol = Ubound(VBArray,2)
	%>
	<SCRIPT LANGUAGE = 'JAVASCRIPT' >
		var vb2jsi,vb2jsj
		<%=ArrayName%> = new Array(<%=vb2jsRow+1%> );
		for (vb2jsi=0; vb2jsi < <%=vb2jsRow+1%>; vb2jsi++) 
		{ 
		<%=ArrayName%>[vb2jsi] = new Array(<%=vb2jsCol+1%> )
		for (vb2jsj=0; vb2jsj < <%=vb2jsCol+1%>; vb2jsj++) <%=ArrayName%>[vb2jsi][vb2jsj] = " "
		}
	</SCRIPT>
	<%
	Response.Write("<SCR"&"IPT LANGUAGE = 'JAVASCRIPT' >"&chr(13))
	for vb2jsi=0 to vb2jsRow
	for vb2jsj=0 to vb2jsCol
	vb2jsstr = "VBArray("&vb2jsi&","&vb2jsj&")"
	%> 
	<%=ArrayName%>[<%=vb2jsi%>][<%=vb2jsj%>] = "<%=trim(eval(vb2jsstr))%>" 
	<%
	Next
	Next
	Response.Write("</SCR"&"IPT>")
End Function

Sub BuscarTarifasBalcon_XML()
	Dim oXML
	Dim OXML1
	Set oXML = Server.CreateObject("msxml2.DOMDocument")
	Set oXML1 = Server.CreateObject("msxml2.DOMDocument")
	oXML.async = False
	oXML1.async = False
	
	oXML.load(Server.MapPath("XML/Tarifas.xml"))
	longitud = oXML.selectNodes("Tarifas_Aluguer/Tarifas").length
	
    Free_Days = oXML.selectNodes("Tarifas_Aluguer/@Free_Days").Item(0).text
	Maximo_Horas = oXML.selectNodes("Tarifas_Aluguer/@Maximo_Horas").Item(0).text	
	Tarifa_Default = oXML.selectNodes("Tarifas_Aluguer/@Tarifa_Default").Item(0).text	
	Fora_Hora_Entrega = oXML.selectNodes("Tarifas_Aluguer/@Fora_Hora_Entrega").Item(0).text
	Fora_Min_Entrega = oXML.selectNodes("Tarifas_Aluguer/@Fora_Min_Entrega").Item(0).text
	Fora_Hora_Recolha = oXML.selectNodes("Tarifas_Aluguer/@Fora_Hora_Recolha").Item(0).text
	Fora_Min_Recolha = oXML.selectNodes("Tarifas_Aluguer/@Fora_Min_Recolha").Item(0).text
	
	'Carregar valores no array de vbscript
	i = 0
	k = 0	
	while i < longitud
		j = 0		
		oXML1.loadXML(oXML.selectNodes("Tarifas_Aluguer/Tarifas").Item(i).xml)
		nro_nodos   = oXML1.selectNodes("Tarifas/Tarifa").length		
		Rate_Period = oXML1.selectNodes("Tarifas/@Rate_Period").Item(0).text
		Start_Date  = oXML1.selectNodes("Tarifas/@Start_Date").Item(0).text
		End_Date    = oXML1.selectNodes("Tarifas/@End_Date").Item(0).text
		GroupID     = oXML1.selectNodes("Tarifas/@GroupID").Item(0).text
		
		while j < nro_nodos
			Tabela_Tarifas(k,0)  = Rate_Period
			Tabela_Tarifas(k,1)  = Start_Date
			Tabela_Tarifas(k,2)  = End_Date
			Tabela_Tarifas(k,3)  = GroupID
			Tabela_Tarifas(k,4)  = oXML1.selectNodes("Tarifas/Tarifa/Rate_Period_Type").Item(j).Text
			Tabela_Tarifas(k,5)  = oXML1.selectNodes("Tarifas/Tarifa/Day_From").Item(j).Text
			Tabela_Tarifas(k,6)  = oXML1.selectNodes("Tarifas/Tarifa/Day_To").Item(j).Text
			Tabela_Tarifas(k,7)  = oXML1.selectNodes("Tarifas/Tarifa/Value").Item(j).Text
			Tabela_Tarifas(k,8)  = oXML1.selectNodes("Tarifas/Tarifa/ExtraId").Item(j).Text
			Tabela_Tarifas(k,9)  = oXML1.selectNodes("Tarifas/Tarifa/Extra_Included").Item(j).Text
			Tabela_Tarifas(k,10) = oXML1.selectNodes("Tarifas/Tarifa/Tax_Id").Item(j).Text
			Tabela_Tarifas(k,11) = oXML1.selectNodes("Tarifas/Tarifa/Kms_Included").Item(j).Text
			Tabela_Tarifas(k,12) = oXML1.selectNodes("Tarifas/Tarifa/ValorPorReserva").Item(j).Text			
			j = j + 1
			k = k + 1
		wend	
	    i = i + 1	
	wend
	
	Set oXML = Nothing
	Set oXML1 = Nothing
	
end Sub
	
%>

</body>
</html>
