public function getComboPrg()
 {
     if (WEB) {
         //Web
         $objetosSalidas = $this->_ciudad->getCiudadCombo(Functions::invertirFecha($this->getTexto('fecha'), '/', '-'));
     } else {
         //Local
         $objetosSalidas = $this->_ciudad->getCiudadCombo(str_replace('/', '-', $this->getTexto('fecha')));
     }
     $salidasJSON = array();
     $codigosJSON = array();
     $JSONfinal = array();
     if ($objetosSalidas) {
         foreach ($objetosSalidas as $objSalida) {
             array_push($salidasJSON, $objSalida->getNombre());
             array_push($codigosJSON, $objSalida->getCodigo());
         }
         array_push($JSONfinal, $salidasJSON, $codigosJSON);
         echo json_encode($JSONfinal);
     } else {
         echo 'false';
     }
 }
 public function index($form = '')
 {
     $this->_view->form = $form;
     Session::acceso('Usuario');
     $reserva = $this->loadModel('reserva');
     $this->_view->objCiudades = $this->_ciudad->getCiudadesBloq();
     $this->_view->objCiudadesPRG = $this->_ciudad->getCiudadesPRG();
     $this->_view->rdbRes = false;
     $this->_view->rdbVia = false;
     if (Session::get('sess_CR_fechaDesde') && Session::get('sess_CR_fechaHasta')) {
         $this->_view->CR_fechaIni = Session::get('sess_CR_fechaDesde');
         $this->_view->CR_fechaFin = Session::get('sess_CR_fechaHasta');
         if (Session::get("sess_CR_tipoFecha") == 1) {
             $this->_view->rdbRes = 'checked';
         } else {
             $this->_view->rdbVia = 'checked';
         }
         if (WEB) {
             $this->_view->objReservas = $reserva->getReservas(Functions::invertirFecha(Session::get('sess_CR_fechaDesde'), '/', '-'), Functions::invertirFecha(Session::get('sess_CR_fechaHasta'), '/', '-'), Session::get('sess_CR_tipoFecha'), Session::get('sess_sp_acceso'), Session::get('sess_clave_usuario'));
         } else {
             //Local
             $this->_view->objReservas = $reserva->getReservas(str_replace('/', '-', Session::get('sess_CR_fechaDesde')), str_replace('/', '-', Session::get('sess_CR_fechaHasta')), Session::get('sess_CR_tipoFecha'), Session::get('sess_sp_acceso'), Session::get('sess_clave_usuario'));
         }
     } else {
         $this->_view->objReservas = false;
         $this->_view->CR_fechaIni = Session::get('sess_fechaDefault');
         $this->_view->CR_fechaFin = Functions::sumFecha(Session::get('sess_fechaDefault'), 0, 3);
         if (Session::get('sess_CR_tipoFecha') == 1) {
             $this->_view->rdbRes = 'checked';
         } else {
             $this->_view->rdbVia = 'checked';
         }
     }
     $this->_view->currentMenu = 1;
     $this->_view->titulo = 'ORISTRAVEL';
     $this->_view->renderingSystem('consultarReserva');
 }
                    } else {
                        $vHab_rowEnv = $tipoHab_Row[0];
                    }
                }
                $pRP_monedaSP = trim($pRP_columPRG["moneda"]);
                //$pRP_monedaSPView= $functions->formatoMoneda($pRP_monedaSP);
                $pRP_totalVenta = $pRP_vHab_1_Row + $pRP_vHab_2_Row + $pRP_vHab_3_Row;
                //$pRP_valorOpcionView= $functions->formatoValor($pRP_monedaSP, $pRP_valorOpcion);
                for ($i = 0; $i < 5; $i++) {
                    $pRP_arrayHotelesOpcion[$i] = NULL;
                }
                $pRP_cntHoteles = 0;
                for ($i = 0; $i < 5; $i++) {
                    if (trim($pRP_columPRG["hotel_" . ($i + 1)]) != '') {
                        ++$pRP_cntHoteles;
                        $pRP_sqlDetalle .= ", '" . trim($pRP_columPRG["codHotel_" . ($i + 1)]) . "', \n                        '" . Functions::invertirFecha(trim($pRP_columPRG["fechaIn_" . ($i + 1)]), '/', '-') . "', \n                        '" . trim($pRP_columPRG["noches_" . ($i + 1)]) . "', \n                        '" . trim($pRP_columPRG["codTipoHabitacion_" . ($i + 1)]) . "', \n                        '" . trim($pRP_columPRG["codPlanAlimenticio_" . ($i + 1)]) . "', \n                        '" . trim($pRP_columPRG["convenio_" . ($i + 1)]) . "' ";
                    } else {
                        $pRP_sqlDetalle .= ", '', '', '', '', '', '' ";
                    }
                }
            }
        }
    }
} else {
    $pRP_error = true;
    $pRP_msg = 'Ha ocurrido un erro al momento de reservar [pRP 1]';
}
$pRP_sqlDetalle .= ", '" . Session::get("sess_BP_cntHab") . "', '" . Session::get("sess_BP_Adl_1") . "', '" . Session::get("sess_BP_Chd_1") . "', '" . Session::get("sess_BP_Inf_1") . "' ";
if (Session::get("sess_BP_cntHab") == 3) {
    $pRP_sqlDetalle .= ", '" . Session::get("sess_BP_Adl_2") . "', '" . Session::get("sess_BP_Chd_2") . "', '" . Session::get("sess_BP_Inf_2") . "', \n                                        '" . Session::get("sess_BP_Adl_3") . "', '" . Session::get("sess_BP_Chd_3") . "', '" . Session::get("sess_BP_Inf_3") . "' ";
} else {
 /**
  * Metodo privado: Valida todos los pasajeros antes de realizar la reserva de un programa.
  * <PRE>
  * -.Creado: 19/05/2015
  * -.Modificado: 20/05/2015
  * </PRE>
  * @return String Contiene la cantidad de pasajeros a pasar al Stored Procedure 
  * @author Jonathan Estay
  */
 private function _validaPasajeros()
 {
     $cnt = 0;
     $pasajeros = '';
     for ($i = 1; $i <= Session::get('sess_DP_cntHab'); $i++) {
         /*
          * Begin: Validacion Adulto
          */
         for ($j = 1; $j <= Session::get('sess_DP_cmbAdultos_' . $i); $j++) {
             $cnt++;
             if (!$this->getTexto('DP_txtNombre_' . $i . '_' . $j)) {
                 throw new Exception("Debe ingresar un <b>Nombre</b> para el pasajero [" . $j . "], de la habitaci&oacute;n [" . $i . "]");
             }
             if (!$this->getTexto('DP_txtApellido_' . $i . '_' . $j)) {
                 throw new Exception("Debe ingresar un <b>Apellido</b> para el pasajero [" . $j . "], de la habitaci&oacute;n [" . $i . "]");
             }
             $pasajeros .= ', "' . $this->getTexto('DP_txtNombre_' . $i . '_' . $j) . ' ' . $this->getTexto('DP_txtApellido_' . $i . '_' . $j) . '"';
             if (!$this->getCheckbox('DP_chkPasaporte_' . $i . '_' . $j)) {
                 if (!$this->getTexto('DP_txtRut_' . $i . '_' . $j)) {
                     throw new Exception("Debe ingresar un <b>Rut</b> para el pasajero [" . $j . "], de la habitaci&oacute;n [" . $i . "]");
                 }
                 if (!Functions::validaRut($this->getTexto('DP_txtRut_' . $i . '_' . $j))) {
                     throw new Exception("<b>Rut</b> incorrecto del pasajero [" . $j . "], de la habitaci&oacute;n [" . $i . "]");
                 }
                 $pasajeros .= ', "' . $this->getTexto('DP_txtRut_' . $i . '_' . $j) . '"';
             } else {
                 if (!$this->getTexto('DP_txtPasaporte_' . $i . '_' . $j)) {
                     throw new Exception("Debe ingresar un <b>Pasaporte</b> para el pasajero [" . $j . "], de la habitaci&oacute;n [" . $i . "]");
                 }
                 $pasajeros .= ', "' . $this->getTexto('DP_txtPasaporte_' . $i . '_' . $j) . '"';
             }
             if (!$this->getTexto('DP_txtFecha_' . $i . '_' . $j)) {
                 throw new Exception("Debe ingresar una <b>Fecha de nacimiento</b> para el pasajero [" . $j . "], de la habitaci&oacute;n [" . $i . "]");
             }
             if (WEB) {
                 $pasajeros .= ', "' . Functions::invertirFecha($this->getTexto('DP_txtFecha_' . $i . '_' . $j), '/', '-') . '", "A"';
             } else {
                 $pasajeros .= ', "' . $this->getTexto('DP_txtFecha_' . $i . '_' . $j) . '", "A"';
             }
         }
         /*
          * End: Validacion Adulto
          */
         /*
          * Begin: Validacion Child
          */
         //if(Session::get('sess_DP_cmbChild_' . $i)) {
         for ($k = 1; $k <= Session::get('sess_DP_cmbChild_' . $i); $k++) {
             $cnt++;
             if (!$this->getTexto('DP_txtNombreC_' . $i . '_' . $k)) {
                 throw new Exception("Debe ingresar un <b>Nombre</b> para el child [" . $k . "], de la habitaci&oacute;n [" . $i . "]");
             }
             if (!$this->getTexto('DP_txtApellidoC_' . $i . '_' . $k)) {
                 throw new Exception("Debe ingresar un <b>Apellido</b> para el child [" . $k . "], de la habitaci&oacute;n [" . $i . "]");
             }
             $pasajeros .= ', "' . $this->getTexto('DP_txtNombreC_' . $i . '_' . $k) . ' ' . $this->getTexto('DP_txtApellidoC_' . $i . '_' . $k) . '"';
             if (!$this->getCheckbox('DP_chkPasaporteC_' . $i . '_' . $k)) {
                 if (!$this->getTexto('DP_txtRutC_' . $i . '_' . $k)) {
                     throw new Exception("Debe ingresar un <b>Rut</b> para el child [" . $k . "], de la habitaci&oacute;n [" . $i . "]");
                 }
                 if (!Functions::validaRut($this->getTexto('DP_txtRutC_' . $i . '_' . $k))) {
                     throw new Exception("<b>Rut</b> incorrecto del child [" . $k . "], de la habitaci&oacute;n [" . $i . "]");
                 }
                 $pasajeros .= ', "' . $this->getTexto('DP_txtRutC_' . $i . '_' . $k) . '"';
             } else {
                 if (!$this->getTexto('DP_txtPasaporteC_' . $i . '_' . $k)) {
                     throw new Exception("Debe ingresar un <b>Pasaporte</b> para el child [" . $k . "], de la habitaci&oacute;n [" . $i . "]");
                 }
                 $pasajeros .= ', "' . $this->getTexto('DP_txtPasaporteC_' . $i . '_' . $k) . '"';
             }
             if (!$this->getTexto('DP_txtFechaC_' . $i . '_' . $k)) {
                 throw new Exception("Debe ingresar una <b>Fecha de nacimiento</b> para el child [" . $k . "], de la habitaci&oacute;n [" . $i . "]");
             }
             if (WEB) {
                 $pasajeros .= ', "' . Functions::invertirFecha($this->getTexto('DP_txtFechaC_' . $i . '_' . $k), '/', '-') . '", "C"';
             } else {
                 $pasajeros .= ', "' . $this->getTexto('DP_txtFechaC_' . $i . '_' . $k) . '", "C"';
             }
         }
         /*
          * End: Validacion Child
          */
     }
     for ($l = $cnt; $l < 12; $l++) {
         $pasajeros .= ', "", "", "", ""';
     }
     return $pasajeros;
 }
 public function reservaPrograma($form = '')
 {
     $this->_view->form = $form;
     if (!Session::get('sess_boton_pago')) {
         Session::accForm('Usuario');
     }
     if (strtolower($this->getServer('HTTP_X_REQUESTED_WITH')) == 'xmlhttprequest') {
         $RP_rdbOpc = false;
         $RP_idProg = false;
         //$this->
         $tags = array_keys($this->getPOST());
         if (!empty($tags[1])) {
             $RP_rdbOpc = $this->getTexto('varCenterBox');
             $RP_idProg = $this->getTexto('varCenterBoxH');
         }
         if (!$RP_rdbOpc) {
             throw new Exception('Seleccione una opcion para poder reservar.');
         } else {
             if ($RP_idProg) {
                 Session::set('sessRP_rdbOpc', $RP_rdbOpc);
                 Session::set('sessRP_idPrograma', $RP_idProg);
                 $bloqueo = $this->loadModel('bloqueo');
                 $this->_view->objPrograma = $bloqueo->validaPrograma($RP_idProg, $RP_rdbOpc);
                 // se obtienen las edades de la opcion
                 $childEdad = $bloqueo->getChild($RP_rdbOpc);
                 if ($childEdad) {
                     Session::set('sessRP_edadChd1', $childEdad->getChd1());
                     Session::set('sessRP_edadChd2', $childEdad->getChd2());
                 } else {
                     ession::set('sessRP_edadChd1', 0);
                     Session::set('sessRP_edadChd2', 0);
                 }
                 if ($this->_view->objPrograma) {
                     $this->loadDTO('incluye');
                     if (WEB) {
                         //Web
                         $sql = "exec TS_GET_BLOQUEOS_PROG_ID " . $RP_idProg . ", " . $RP_rdbOpc . ", " . "'" . Functions::invertirFecha(Session::get('sess_BP_fechaIn'), '/', '-') . "', " . "'" . Functions::invertirFecha(Session::get('sess_BP_fechaOut'), '/', '-') . "', ";
                     } else {
                         //Local
                         $sql = "exec TS_GET_BLOQUEOS_PROG_ID " . $RP_idProg . ", " . $RP_rdbOpc . ", " . "'" . str_replace('/', '-', Session::get('sess_BP_fechaIn')) . "', " . "'" . str_replace('/', '-', Session::get('sess_BP_fechaOut')) . "', ";
                     }
                     $sql .= "'" . Session::get('sess_BP_hotel') . "'";
                     for ($i = 1; $i <= 3; $i++) {
                         $sql .= ", '" . Session::get('sess_BP_Adl_' . $i) . "', '" . Session::get('sess_BP_edadChd_1_' . $i) . "', \n                                '" . Session::get('sess_BP_edadChd_2_' . $i) . "', '" . Session::get('sess_BP_Inf_' . $i) . "'";
                         //habitaciones
                     }
                     //echo $sql; exit;
                     $this->_view->objOpcionPrograma = $bloqueo->TS_GET_BLOQUEOS_PROG_ID($sql, true);
                     $cnt = count($this->_view->objOpcionPrograma);
                     /* for($i=1; $i<$cnt; $i++)
                        {
                        echo $this->_view->objOpcionPrograma[$i]->getIdOpc();
                        if($this->_view->objOpcionPrograma[$i]->getIdOpc() == $RP_rdbOpc)
                        {
                        $this->_view->objOpcionProg[]= $this->_view->objOpcionPrograma[$i];
                        break;
                        }
                        } */
                     if ($cnt > 0) {
                         //Formateando valores
                         $this->_view->fechaSalida = Functions::invertirFecha($this->_view->objOpcionPrograma[0]->getDesde(), '/', '/');
                         $exp_fechaSalida = explode('/', $this->_view->objOpcionPrograma[0]->getDesde());
                         $this->_view->anoSalida = $exp_fechaSalida[0];
                         $this->_view->mesSalida = $exp_fechaSalida[1];
                         $this->_view->diaSalida = $exp_fechaSalida[2];
                         $valorHab = $this->_view->objOpcionPrograma[0]->getValorHab();
                         $precio = $valorHab[0] + $valorHab[1] + $valorHab[2];
                         Session::set('sess_BP_Precio', $precio);
                         $this->_view->precio = Functions::formatoValor($this->_view->objOpcionPrograma[0]->getMoneda(), $precio);
                         Session::set('sess_money_pay', $this->_view->objOpcionPrograma[0]->getMoneda());
                         if ($this->_view->objOpcionPrograma[0]->getMoneda() == 'D') {
                             if (!Session::get('sess_tcambio')) {
                                 $us = $this->loadModel('usuario');
                                 $tcambio = $us->getPaisTc(Session::get('sess_BP_ciudadDes'));
                                 $TcambioSess = $us->getTcambio($tcambio);
                                 Session::set('sess_tcambio', $TcambioSess->getTipoCambio());
                             }
                             if (Session::get('sess_tcambio') == 0) {
                                 $this->loadDTO('usuarioH2h');
                                 $us = $this->loadModel('reserva');
                                 $user = '******';
                                 $mail = $us->getCorreo($user);
                                 $mail->getCorreoEjecutivo();
                                 $this->mailTipoCambio('Actualizar tipo cambio', $mail->getCorreoEjecutivo(), '*****@*****.**');
                             }
                             $precio = $precio * Session::get('sess_tcambio');
                             if (Session::get('sess_codigo_cliente_url') == '3f7a2611ee08c6645796463e0bb1ae7f') {
                                 $this->_view->precio .= ' &nbsp;(T.Cambio $' . Session::get('sess_tcambio') . ',&nbsp; ' . Functions::formatoValor('P', $precio) . ')';
                             }
                         }
                         $this->_view->hoteles = $this->_view->objOpcionPrograma[0]->getHoteles();
                         $this->_view->hotelesCNT = count($this->_view->hoteles);
                         $this->_view->condicionesGenerales = Functions::getCondicionesGenerales();
                         if (Session::get('sess_boton_pago')) {
                             $this->_view->botonPago = Session::get('sess_boton_pago');
                             $this->_view->boton = "Pagar";
                         } else {
                             $this->_view->botonPago = false;
                             $this->_view->boton = "Reservar";
                         }
                         $this->_view->renderingCenterBox('reservarPrograma');
                     } else {
                         throw new Exception('Ya no se encuentran espacios disponibles para reservar.');
                     }
                 } else {
                     throw new Exception('Existe un error en el armado de programas, favor actualize la busqueda.');
                 }
             }
         }
     } else {
         throw new Exception('Error inesperado, intente nuevamente. Si el error persiste comuniquese con el administrador');
     }
 }
 public function validaAllotmen($pack, $fechaIn, $numHabi, $idopc)
 {
     $sql = 'SELECT proveedor,noches FROM det_pack WHERE packages ="' . $pack . '" and codigo = "HTL" ORDER BY linea';
     $re = false;
     $data = $this->_db->consulta($sql);
     $dato = $this->_db->fetchAll($data);
     $i = 0;
     $sql = 'SELECT codhotel,TipoHabitacion FROM h2h_ProgramaOpcDet POD WHERE POD.IdOpcion="' . $idopc . '" order by Orden asc';
     //echo $sql;exit;
     $ho = $this->_db->consulta($sql);
     $hotel = $this->_db->fetchAll($ho);
     foreach ($hotel as $h) {
         $fechaOut = Functions::sumFecha($fechaIn, $dato[$i]['noches']);
         if (WEB) {
             $sql = 'EXEC Valida_Allotment_alldays "' . trim($h['codhotel']) . '","' . trim($h['TipoHabitacion']) . '","' . $dato[$i]['proveedor'] . '","' . Functions::invertirFecha($fechaIn, '/', '/') . '","' . Functions::invertirFecha($fechaOut, '/', '/') . '"," ","' . $numHabi . '"';
         } else {
             $sql = 'EXEC Valida_Allotment_alldays "' . trim($h['codhotel']) . '","' . trim($h['TipoHabitacion']) . '","' . $dato[$i]['proveedor'] . '","' . $fechaIn . '","' . $fechaOut . '"," ","' . $numHabi . '"';
         }
         $fechaIn = $fechaOut;
         $allot = $this->_db->consulta($sql);
         $allotment = $this->_db->fetchAll($allot);
         if ($allotment[0][0] != 0) {
             $re = true;
         } else {
             $re = false;
         }
         $i++;
     }
     return $re;
 }