<?
include("../assets/lib_carrito.php");
header("location: fimreserva.php");
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE>insprv</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META NAME="Abstract" CONTENT="rent a car  madeira island, car rental lisbon, car rental algarve, car rental porto, car rental online bookings, funchal rent a car, madeira rent a car">
<META NAME="Copyright" CONTENT="Bravacar 2006 - Carlos Pontes">
<META NAME="Description" CONTENT="Bravacar - Easy rent a car bookings in Portugal.  Bookings available in Lisbon, Madeira Island, Algarve and Porto.  Customers pay only a small percentage when booking online and pay the remainder at pickup location.">
<META NAME="Generator" CONTENT="carlos alberto pontes">
<META NAME="Keywords" CONTENT="rent a car,car rentals portugal,bravacar, car rental in madeira, rent a car in lisbon, rent a car in oporto, porto car rental, lisbon car rental, faro car rental, algarve rent a car, netrent rent a car, rent, car, rent a car, car rental, rental, car rentals, rentals, holiday rentals, cheap rent a car, cheap car rental, cheap rental, cheap car rentals, cheap rentals, cheap holiday rentals, portugal rent a car, portugal car rental,madeira car rental,algarve car rental,lisbon car rental,porto car rental,bravacar madeira,bravacar porto, bravacar lisbon, bravacar faro">
<META NAME="Language" CONTENT="en">
<META NAME="revisit-after" CONTENT="2 days">
<LINK REL="STYLESHEET" TYPE="text/css" HREF="../html/style.css">
<LINK REL="STYLESHEET" TYPE="text/css" HREF="../html/site.css">
</HEAD>
<BODY STYLE="margin: 0px;">
    <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="666">
        <TR VALIGN="TOP" ALIGN="LEFT">
            <TD WIDTH="59" HEIGHT="74"><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH="59" HEIGHT="1" BORDER="0" ALT=""></TD>
            <TD WIDTH="607"><IMG SRC="../assets/images/autogen/clearpixel.gif" WIDTH="607" HEIGHT="1" BORDER="0" ALT=""></TD>
        </TR>
        <TR VALIGN="TOP" ALIGN="LEFT">
            <TD></TD>
            <TD WIDTH="607" CLASS="TextObject">
                <P><?
       include('main.php');
       include('insprv_functions.php');
       db_connect();       

       $i = 0;
       if($_SESSION['ocarrito']->array_id_prod[0][0]!=0 and $_SESSION['ocarrito']->array_id_prod[0][1]=='Car')
       {
              $cod_rentacar           = $_SESSION['ocarrito']->array_cars[$i][0];
              $desc_rentacar          = $_SESSION['ocarrito']->array_cars[$i][1];              
              $cod_regiao             = $_SESSION['ocarrito']->array_cars[$i][2];
              $desc_regiao            = $_SESSION['ocarrito']->array_cars[$i][3];
              $cod_categoria          = $_SESSION['ocarrito']->array_cars[$i][4];
              $desc_categoria         = $_SESSION['ocarrito']->array_cars[$i][5];
              $cod_grupo              = $_SESSION['ocarrito']->array_cars[$i][6];
              $desc_grupo             = $_SESSION['ocarrito']->array_cars[$i][7];

              #######  DADOS DO LOCAL DE ENTREGA  #######

              $cod_pick_up_location   = $_SESSION['ocarrito']->array_cars[$i][8];
              $desc_pick_up_location  = $_SESSION['ocarrito']->array_cars[$i][9];
              $pick_up_full_data      = $_SESSION['ocarrito']->array_cars[$i][10];
              $pick_up_data           = $_SESSION['ocarrito']->array_cars[$i][11];
              $pick_up_hour           = $_SESSION['ocarrito']->array_cars[$i][12];      
              $pick_up_min            = $_SESSION['ocarrito']->array_cars[$i][13];

              #######  DADOS DO LOCAL DE RECOLHA  #######

              $cod_region_dest        = $_SESSION['ocarrito']->array_cars[$i][14];
              $desc_region_dest       = $_SESSION['ocarrito']->array_cars[$i][15];
              $cod_drop_off_location  = $_SESSION['ocarrito']->array_cars[$i][16];
              $desc_drop_off_location = $_SESSION['ocarrito']->array_cars[$i][17];

              $drop_off_full_data     = $_SESSION['ocarrito']->array_cars[$i][18];
              $drop_off_data          = $_SESSION['ocarrito']->array_cars[$i][19];
              $drop_off_hour          = $_SESSION['ocarrito']->array_cars[$i][20];     
              $drop_off_min           = $_SESSION['ocarrito']->array_cars[$i][21];
              $nro_dias               = $_SESSION['ocarrito']->array_cars[$i][22];

              #######  DADOS DOS EXTRAS  #######
              
              $cod_extra1             = $_SESSION['ocarrito']->array_cars[$i][23];
              $desc_extra1            = $_SESSION['ocarrito']->array_cars[$i][24];
              $quantity_extra1        = $_SESSION['ocarrito']->array_cars[$i][25];     
              $price_day_extra1       = $_SESSION['ocarrito']->array_cars[$i][26];
              $price_total_extra1     = $_SESSION['ocarrito']->array_cars[$i][27];

              if ($cod_extra1=='' or $quantity_extra1==0)
              {
                  $desc_extra1        = '';
                  $quantity_extra1    = 0;     
                  $price_day_extra1   = 0;
                  $price_total_extra1 = 0;
              }

              $cod_extra2             = $_SESSION['ocarrito']->array_cars[$i][28];
              $desc_extra2            = $_SESSION['ocarrito']->array_cars[$i][29];
              $quantity_extra2        = $_SESSION['ocarrito']->array_cars[$i][30];     
              $price_day_extra2       = $_SESSION['ocarrito']->array_cars[$i][31];
              $price_total_extra2     = $_SESSION['ocarrito']->array_cars[$i][32];

              if ($cod_extra2=='' or $quantity_extra2==0)
              {
                  $desc_extra2        = '';
                  $quantity_extra2    = 0;     
                  $price_day_extra2   = 0;
                  $price_total_extra2 = 0;
              }

              $cod_extra3             = $_SESSION['ocarrito']->array_cars[$i][33];
              $desc_extra3            = $_SESSION['ocarrito']->array_cars[$i][34];
              $quantity_extra3        = $_SESSION['ocarrito']->array_cars[$i][35];     
              $price_day_extra3       = $_SESSION['ocarrito']->array_cars[$i][36];
              $price_total_extra3     = $_SESSION['ocarrito']->array_cars[$i][37];

              if ($cod_extra3=='' or $quantity_extra3==0)
              {
                  $desc_extra3        = '';
                  $quantity_extra3    = 0;     
                  $price_day_extra3   = 0;
                  $price_total_extra3 = 0;
              }

              $cod_extra4             = $_SESSION['ocarrito']->array_cars[$i][38];
              $desc_extra4            = $_SESSION['ocarrito']->array_cars[$i][39];
              $quantity_extra4        = $_SESSION['ocarrito']->array_cars[$i][40];     
              $price_day_extra4       = $_SESSION['ocarrito']->array_cars[$i][41];
              $price_total_extra4     = $_SESSION['ocarrito']->array_cars[$i][42];

              if ($cod_extra4=='' or $quantity_extra4==0)
              {
                  $desc_extra4        = '';
                  $quantity_extra4    = 0;     
                  $price_day_extra4   = 0;
                  $price_total_extra4 = 0;
              }

              $cod_extra5             = $_SESSION['ocarrito']->array_cars[$i][43];
              $desc_extra5            = $_SESSION['ocarrito']->array_cars[$i][44];
              $quantity_extra5        = $_SESSION['ocarrito']->array_cars[$i][45];     
              $price_day_extra5       = $_SESSION['ocarrito']->array_cars[$i][46];
              $price_total_extra5     = $_SESSION['ocarrito']->array_cars[$i][47];

              if ($cod_extra5=='' or $quantity_extra5==0)
              {
                  $desc_extra5        = '';
                  $quantity_extra5    = 0;     
                  $price_day_extra5   = 0;
                  $price_total_extra5 = 0;
              }

              #######  DADOS DO EXTRA FORA DE HORAS  #######

              $cod_extra_fh           = $_SESSION['ocarrito']->array_cars[$i][48];
              $desc_extra_fh          = $_SESSION['ocarrito']->array_cars[$i][49];
              $price_extra_fh         = $_SESSION['ocarrito']->array_cars[$i][50];     
              $price_total_extra_fh   = $_SESSION['ocarrito']->array_cars[$i][51];    

              if ($cod_extra_fh=='')
              {
                  $price_extra_fh       = 0;
                  $price_total_extra_fh = 0;
              }
          
              #######  DADOS DOS EXTRAS INCLUIDOS  #######

              $desc_extra_inc1        = $_SESSION['ocarrito']->array_cars[$i][52];     
              $desc_extra_inc2        = $_SESSION['ocarrito']->array_cars[$i][53];              

              $desc_extra_inc3        = $_SESSION['ocarrito']->array_cars[$i][54];     
              $desc_extra_inc4        = $_SESSION['ocarrito']->array_cars[$i][55];              

              $desc_extra_inc5        = $_SESSION['ocarrito']->array_cars[$i][56];     
              $desc_extra_inc6        = $_SESSION['ocarrito']->array_cars[$i][57];              

              $desc_extra_inc7        = $_SESSION['ocarrito']->array_cars[$i][58];     
              $desc_extra_inc8        = $_SESSION['ocarrito']->array_cars[$i][59];              

              $desc_extra_inc9        = $_SESSION['ocarrito']->array_cars[$i][60];     
              $desc_extra_inc10       = $_SESSION['ocarrito']->array_cars[$i][61];              

              $desc_extra_inc11       = $_SESSION['ocarrito']->array_cars[$i][62];     
              $desc_extra_inc12       = $_SESSION['ocarrito']->array_cars[$i][63];              


              #######  VALORES  #######

              $commission             = $_SESSION['ocarrito']->array_cars[$i][64];     
              $price_day              = $_SESSION['ocarrito']->array_cars[$i][65];              
              $price_total_day        = $_SESSION['ocarrito']->array_cars[$i][66];     

              $charged_prod           = $_SESSION['ocarrito']->array_cars[$i][67];                   
              $balance_prod           = $_SESSION['ocarrito']->array_cars[$i][68];              
              $price_total            = $_SESSION['ocarrito']->array_cars[$i][69];     


              #######  DADOS DO CLIENTE  #######

              $_SESSION['ocarrito']->array_cars[$i][70] = '';
              $_SESSION['ocarrito']->array_cars[$i][71] = $_POST['nome_condutor'];

              $trato                  = $_SESSION['ocarrito']->array_cars[$i][70]; 
              $nome_cliente           = $_SESSION['ocarrito']->array_cars[$i][71];

              $nome_hotel             = $_SESSION['ocarrito']->array_cars[$i][72];     
              $nro_voo                = $_SESSION['ocarrito']->array_cars[$i][73];

              $address_pick_up        = $_SESSION['ocarrito']->array_cars[$i][74];
              $address_drop_off       = $_SESSION['ocarrito']->array_cars[$i][75];

              $email_cliente          = $_POST['email'];
              $telefone_cliente       = $_POST['telefone'];
              $pais_cliente           = $_POST['pais'];

              $_SESSION['ocarrito']->array_cars[$i][76] = $email_cliente;
              $_SESSION['ocarrito']->array_cars[$i][77] = $telefone_cliente;
              $_SESSION['ocarrito']->array_cars[$i][78] = $pais_cliente;

              #########  PARAMETROS PARA A FUNÇAO DE VOUCHER PARA RENTA A CAR  ########
              $data_pick_up  = FormatarDataHora($pick_up_data,$pick_up_hour,$pick_up_min);
              $data_drop_off = FormatarDataHora($drop_off_data,$drop_off_hour,$drop_off_min);

              $lugar_entrega = $desc_regiao.' - '.$desc_pick_up_location.' - '.$address_pick_up;
              $lugar_recolha = $desc_region_dest.' - '.$desc_drop_off_location.' - '.$address_drop_off;

              $included = '';

              if ($desc_extra_inc1 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc1;
                  else
                      $included = $included.', '.$desc_extra_inc1;
              }

              if ($desc_extra_inc2 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc2;
                  else
                      $included = $included.', '.$desc_extra_inc2;
              }

              if ($desc_extra_inc3 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc3;
                  else
                      $included = $included.', '.$desc_extra_inc3;
              }

              if ($desc_extra_inc4 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc4;
                  else
                      $included = $included.', '.$desc_extra_inc4;
              }

              if ($desc_extra_inc5 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc5;
                  else
                      $included = $included.', '.$desc_extra_inc5;
              }

              if ($desc_extra_inc6 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc6;
                  else
                      $included = $included.', '.$desc_extra_inc6;
              }

              if ($desc_extra_inc7 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc7;
                  else
                      $included = $included.', '.$desc_extra_inc7;
              }

              if ($desc_extra_inc8 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc8;
                  else
                      $included = $included.', '.$desc_extra_inc8;
              }

              if ($desc_extra_inc9 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc9;
                  else
                      $included = $included.', '.$desc_extra_inc9;
              }

              if ($desc_extra_inc10 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc10;
                  else
                      $included = $included.', '.$desc_extra_inc10;
              }

              if ($desc_extra_inc11 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc11;
                  else
                      $included = $included.', '.$desc_extra_inc11;
              }

              if ($desc_extra_inc12 !='')
              {
                  if ($included=='')
                      $included = $desc_extra_inc12;
                  else
                      $included = $included.', '.$desc_extra_inc12;
              }

              $idade = 0;
              $special_request = '';
                    
              $nome_cliente_final = "'".$trato.' '.$nome_cliente."'";
 
              $id_voucher = md5(uniqid(rand(), true));          
              $nro_voucher = insert_voucher_car($id_voucher,$cod_rentacar,$lugar_entrega,$data_pick_up,$lugar_recolha,$data_drop_off,$nro_dias,$nome_cliente_final,$email_cliente,$telefone_cliente,$pais_cliente,$cod_grupo,$desc_grupo,$included,$nome_hotel,$nro_voo,$special_request,$commission,0,$price_total,$price_total,$price_day,$price_total_day,$desc_extra1,$quantity_extra1,$price_day_extra1,$price_total_extra1,$desc_extra2,$quantity_extra2,$price_day_extra2,$price_total_extra2,$desc_extra3,$quantity_extra3,$price_day_extra3,$price_total_extra3,$desc_extra4,$quantity_extra4,$price_day_extra4,$price_total_extra4,$desc_extra5,$quantity_extra5,$price_day_extra5,$price_total_extra5,$desc_extra_fh,$price_extra_fh,$price_total_extra_fh);

              $_SESSION['ocarrito']->array_id_prod[$i][2] = $nro_voucher;
              $_SESSION['ocarrito']->array_id_prod[$i][3] = $id_voucher;                            
        }
        
        envio_email();
        db_disconnect();
?>
&nbsp;</P>
            </TD>
        </TR>
    </TABLE>
</BODY>
</HTML>
 