Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] Organizar Precios y Temporadas

Estas en el tema de Organizar Precios y Temporadas en el foro de PHP en Foros del Web. En primer lugar un saludo a Todos. Tengo un problemilla a la hora de poner un precio por temporada pues ahora mismo no tengo ni ...

  #1 (permalink)  
Antiguo 13/01/2016, 06:03
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Organizar Precios y Temporadas

En primer lugar un saludo a Todos.
Tengo un problemilla a la hora de poner un precio por temporada pues ahora mismo no tengo ni idea como abordarlo.
Este es el código que tengo:
Código PHP:
<?php                                                     
                                                      
$desde 
$_GET['FDesde'];
$hasta $_GET["FHasta"];

// Temporada Baja = 13/01 al 10/03  -  07/04 al 14/06  -  01/09 al 26/11
// Temporada Media =  11/03 al 26/03  -  15/06 al 31/07  -  27/11 al 14/12
// Temporada Alta = 27/03 al 06/04  -  01/08 al 31/08  -  01/08 al 31/08

$Alta $row_ConsultaHabitaciones['intPrecio_Alta']; 
$Media $row_ConsultaHabitaciones['intPrecio_Media'];
$Baja $row_ConsultaHabitaciones['intPrecio_Baja']; 
$Especial $row_ConsultaHabitaciones['intPrecio_Especial'];    

// Tengo que ver como hace estor, ahora es Alta para poder seguir con la facturación más abajo     
$PrecioHabitacion $Alta;                                            

// DIFERENCIA DE DIAS ENTRE Fdesde HASTA Fhasta //
$inicio strtotime($_GET['FDesde']);
$fin strtotime($_GET["FHasta"]);
$dateDiff $fin $inicio;
echo 
"<strong>Días Totales:</strong> ".($dateDiffTotal floor($dateDiff/(60*60*24))+1)." días";
echo 
"<br />";

// CALCULOS FACTURACIÓN //
echo "<strong>Precio/Día:</strong> ".$PrecioHabitacion." €";
echo 
"<br />";
echo 
"<strong>Sub Total:</strong> ".number_format($SubTotal $PrecioHabitacion $dateDiffTotal)." €";
echo 
"<br />";
$Impuesto 15;
$Impuestos = (($Impuesto $SubTotal) / 100);
echo 
"<strong>".$Impuesto."% "."IGIC:</strong> ".$Impuestos." €";
echo 
"<br />";
echo 
"<strong>Total:</strong> ".number_format($Total $Impuestos $SubTotal)." €";

?>
Como podría hacer u organizar Los precios con las temporadas para obtener $PrecioHabitacion
Muchísimas gracias de antemano y cordial Saludo: Manyblue
  #2 (permalink)  
Antiguo 13/01/2016, 07:20
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

Hola, es que precio temporada no es tan facil como lo pensabas ya que un rango de fechas puede incluir todas las temporadas...

Prueba esto, todo en una pagina:
Código PHP:
<?php

class Temporadas {

    protected 
$temporadas = [];

    protected 
$acumulador 0.0;

    public function 
__construct($baja$media$alta$especial) {
        
$this->temporadas['baja']      = $baja;
        
$this->temporadas['media']     = $media;
        
$this->temporadas['alta']      = $alta;
        
$this->temporadas['especial']  = $especial;
    }

    protected function 
esTemporada($temporada$dia) {
        foreach(
$this->temporadas[$temporada] as $rango) {
            
$desde $this->getTime($rango[0]);
            
$hasta $this->getTime($rango[1]);

            if (
$dia >= $desde && $dia <= $hasta) {
                return 
true;
            }
        }

        return 
false;
    }

    public function 
esTemporadaBaja($dia) {
        return 
$this->esTemporada('baja'$dia);
    }

    public function 
esTemporadaMedia($dia) {
        return 
$this->esTemporada('media'$dia);
    }

    public function 
esTemporadaAlta($dia) {
        return 
$this->esTemporada('alta'$dia);
    }

    public function 
esEspecial($dia) {
        return 
$this->esTemporada('especial'$dia);
    }

    public function 
acumular($precio) {
        
$this->acumulador += floatval($precio);
    }

    public function 
precioTotal() {
        return 
$this->acumulador;
    }

    public function 
getTime($dia) {
        
// Cambia el orden para strtotime, es mm/dd/yyyy
        
list($dia$mes) = explode('/'$dia);
        return 
strtotime($mes '/' $dia '/' date('Y'));
    }
}


// Temporada Baja = 13/01 al 10/03  -  07/04 al 14/06  -  01/09 al 26/11
// Temporada Media =  11/03 al 26/03  -  15/06 al 31/07  -  27/11 al 14/12
// Temporada Alta = 27/03 al 06/04  -  01/08 al 31/08  -  01/08 al 31/08

$temporadaBaja = [
    [
'13/01''10/03'],
    [
'07/04''14/06'],
    [
'01/09''26/11']
];

$temporadaMedia = [
    [
'11/03''26/03'],
    [
'15/06''31/07'],
    [
'27/11''14/12'],
];

$temporadaAlta = [
    [
'27/03''06/04'],
    [
'01/08''31/08'],
    
// ['01/08', '31/08']
];

$especial = [
    [
'01/01''12/01']
];

// Precios por temporada
$precioBaja     number_format(10.002) . ' €';
$precioMedia    number_format(15.502) . ' €';
$precioAlta     number_format(19.992) . ' €';
$precioEspecial number_format5.952) . ' €';

$helper = new Temporadas($temporadaBaja$temporadaMedia$temporadaAlta$especial);

// Fechas seleccionadas
$inicio $helper->getTime('30/08');
$final  $helper->getTime('04/09');

echo <<<TABLE
<table width="50%" border="1">
    <thead>
    <tr>
        <th>Fecha (dd/mm/yyyy)</th>
        <th>Temporada</th>
        <th>Precio</th>
    </tr>
    </thead>
    <tbody>
TABLE;

for (
$i $inicio$i $final$i += 60 60 24) {
    echo 
'<tr>';

    if (
$helper->esEspecial($i)) {
        
// Acumular precio
        
$helper->acumular($precioEspecial);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Precio Especial</td><td>$precioEspecial</td>";

    } else if (
$helper->esTemporadaAlta($i)) {
        
// Acumular precio
        
$helper->acumular($precioAlta);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Alta</td><td>$precioAlta</td>";

    } else if (
$helper->esTemporadaMedia($i)) {
        
// Acumular precio
        
$helper->acumular($precioMedia);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Media</td><td>$precioMedia</td>";

    } else if (
$helper->esTemporadaBaja($i)) {
        
// Acumular precio
        
$helper->acumular($precioBaja);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada baja</td><td>$precioBaja</td>";

    }

    echo 
'</tr>';
}

$total number_format($helper->precioTotal(), 2) . ' €';

echo <<<ENDTABLE
    <tr>
        <td colspan='2'><b>TOTAL:</b></td>
        <td>$total</td>
    </tr>
    </tbody>
</table>
ENDTABLE;
Le falta los impuestos, le falta saber los días etc ... pero como idea de partida no esta mal.

Un saludo,
  #3 (permalink)  
Antiguo 13/01/2016, 07:46
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

x_atrix MUCHÍSIMAS GRACIAS.
Lo probaré y te cuento.
Si, lo se que es un poco enreversado pues estás trabajando con fechas.
Un saludo: manyblue
  #4 (permalink)  
Antiguo 13/01/2016, 08:05
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Me dá errores tu código o yo lo he insertado mal
Por el momento este es el código que tengo:
Código PHP:
<div class="panel panel-default">
                                       
      <div id="fondo" class="panel-heading negrita" align="center">
      PAGO HABITACIÓN Nº <?php echo $row_ConsultaHabitaciones['intNumero_Habitacion']; ?>
      </div>
      <div class="panel-body">

               <form action="hoteles_usuario_reserva_previa.php" name="buscador" class="form-inline" id="buscador" method="get" onSubmit="javascript:return validarbuscarhotel();" >
         
                  <div class="form-group col-sm-6 col-md-8">
                  <p><img src="imagenes/paypal.jpg"></p>
                  
                  <p>
                  
                  <strong>Reserva Habitación: Nº <?php echo $row_ConsultaHabitaciones['intNumero_Habitacion']; ?> de: <?php echo $row_DatosDatosConsulta['strNombre']; ?></strong><br />
                  <strong>Desde el:</strong> <?php if(isset($_GET['FDesde'])) echo $_GET['FDesde']; ?>&nbsp;&nbsp;<strong>Hasta el:</strong> <?php if(isset($_GET["FHasta"])) echo $_GET["FHasta"]; ?><br />
                  
                  <?php 
                  
                  
                  $desde 
$_GET['FDesde'];
                  
$hasta $_GET["FHasta"];
                  
                  
// Temporada Baja = 13/01 al 10/03 - 07/04 al 14/06 - 01/09 al 26/11
                  // Temporada Media =  11/03 al 26/03 - 15/06 al 31/07 - 27/11 al 14/12
                  // Temporada Alta = 27/03 al 06/04 - 01/08 al 31/08 - 01/08 al 31/08
                  
                  
$Alta $row_ConsultaHabitaciones['intPrecio_Alta']; 
                  
$Media $row_ConsultaHabitaciones['intPrecio_Media'];
                  
$Baja $row_ConsultaHabitaciones['intPrecio_Baja']; 
                  
$Especial $row_ConsultaHabitaciones['intPrecio_Especial'];
                    
                  
// PRECIO DE LA HABITACION //
                  
$PrecioHabitacion $Alta;                                                  
                  
                  
// DIFERENCIA DE DIAS ENTRE Fdesde HASTA Fhasta //
                  
$inicio strtotime($_GET['FDesde']);
                  
$fin strtotime($_GET["FHasta"]);
                  
$dateDiff $fin $inicio;
                  echo 
"<strong>Días Totales:</strong> ".($dateDiffTotal floor($dateDiff/(60*60*24))+1)." días";
                  echo 
"<br />"?>
                  <strong>Fecha Factura:</strong> <?php echo date("d-m-Y");?><br />
                  <strong>Cliente:</strong> 
                  <?php echo ObtenerNombreUsuario($row_DatosDatosConsulta['refUsuario']); ?>
                  <?php echo ObtenerAlellidosUsuario($row_DatosDatosConsulta['refUsuario']); ?>
                  <br />
                  <?php
                  
// CALCULOS FACTURACIÓN //
                  
echo "<strong>Precio/Día:</strong> ".$PrecioHabitacion." €";
                  echo 
"<br />";
                  echo 
"<strong>Sub Total:</strong> ".$SubTotal $PrecioHabitacion $dateDiffTotal." €";
                  echo 
"<br />";
                  
$Impuesto $row_ConsultaHabitaciones['intValor_Impuesto']; 
                  
$NombreImpuesto $row_ConsultaHabitaciones['strNombre_Impuesto'];
                  
$Impuestos = (($Impuesto $SubTotal) / 100);
                  echo 
"<strong>".$Impuesto."% ".$NombreImpuesto.":</strong> ".$Impuestos." €";
                  echo 
"<br />";
                  echo 
"<strong>Total:</strong> ".$Total $Impuestos $SubTotal." €";
                  
                  
?>
                  
                 </p> 
                  
                  
                                         
                  
                      <input type='hidden' name="FDesde" id='datetimepicker6' class="form-control" placeholder="Desde" value="<?php if(isset($_GET['FDesde'])) echo $_GET['FDesde']; ?>" />                                                                                                          
                      <input type='hidden' name="FHasta" class="form-control" id='datetimepicker7' placeholder="Hasta" value="<?php if(isset($_GET["FHasta"])) echo $_GET["FHasta"]; ?>" />
                    
                 </div>
                        
                 <div class="form-group col-sm-6 col-md-4">
                  <span class="pull-right">
                  <?php if ((isset($_SESSION['MM_IDUsuario'])) && ($_SESSION['MM_IDUsuario'] != "0")) { ?>
                  <button type="submit" class="btn btn-success btn-lg"><strong>Pagar Ahora</strong></button>
                  <?php ?>
                  </span>
                 </div>
                  
                  <input name="recordID" type='hidden' value="<?php echo $varHabitacion_ConsultaHotel?>" />
                  <input type='hidden' name='MM_Buscar' value="buscador" />
                  <input type='hidden' name='idProvincia' value="<?php echo $_GET['idProvincia']; ?>" />
                  
               </form>
                 
      </div>
Como insertar tu código ??
Realmente lo que debo calcular es $PrecioHabitacion
precio especial no me interesa pues en la tabla de habitaciones existe dos campos intEstado_Precio_Especial y intPrecio_Especial pudiebdo jugar con el estado para el precio especial.
Muchísimas gracias por tus molestias, un saludo: Manyblue

Última edición por manyblue; 13/01/2016 a las 08:10
  #5 (permalink)  
Antiguo 13/01/2016, 08:13
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Por si lo quieres ver o necesitas esta es la tabla de habitaciones:
Código:
CREATE TABLE IF NOT EXISTS `tbl_habitaciones_hotel` (
  `id_Habitacion` int(11) NOT NULL AUTO_INCREMENT,
  `refHotel` int(11) DEFAULT NULL,
  `refImagenes` int(11) DEFAULT NULL,
  `refTipo_Habitacion` int(11) DEFAULT NULL,
  `refUsuario` int(11) DEFAULT NULL,
  `intNumero_Habitacion` int(11) DEFAULT NULL,
  `intEstado` int(2) DEFAULT NULL,
  `intAdultos` int(2) DEFAULT NULL,
  `intNinos` int(2) DEFAULT NULL,
  `intBebes` int(2) DEFAULT NULL,
  `intPrecio_Especial` double DEFAULT NULL,
  `intPrecio_Alta` double DEFAULT NULL,
  `intPrecio_Media` double DEFAULT NULL,
  `intPrecio_Baja` double DEFAULT NULL,
  `strNombre_Impuesto` varchar(100) DEFAULT NULL,
  `intValor_Impuesto` int(3) DEFAULT NULL,
  `strDescuento` varchar(50) DEFAULT NULL,
  `intDescuento_Estado` int(2) DEFAULT NULL,
  `intPromocion` int(2) DEFAULT NULL,
  `strPromocion_Contenido` text,
  `Fecha_Alta_habitacion` timestamp NULL DEFAULT NULL,
  `Fecha_Modificacion_Habitacion` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `strDescripcion` text,
  `strDescripcion_ing` text,
  `strDescripcion_ale` text,
  `strDescripcion_fra` text,
  `strDescripcion_hol` text,
  `intTDT` int(2) DEFAULT NULL,
  `intTV_Sat` int(2) DEFAULT NULL,
  `intTelefono` int(2) DEFAULT NULL,
  `intInternet_Cable` int(2) DEFAULT NULL,
  `intWifi` int(2) DEFAULT NULL,
  `intNevera` int(2) DEFAULT NULL,
  `intCaja_Fuerte` int(2) NOT NULL,
  `intBanera` int(2) DEFAULT NULL,
  `intJacuzzi` int(2) DEFAULT NULL,
  `intSecador_Pelo` int(2) DEFAULT NULL,
  `intAire_Acondicionado` int(2) DEFAULT NULL,
  `intMicroondas` int(2) DEFAULT NULL,
  `intCocina` int(2) DEFAULT NULL,
  `intLavadora` int(2) DEFAULT NULL,
  `intServicio_habitaciones` int(2) DEFAULT NULL,
  `intMenage_Cocina` int(2) DEFAULT NULL,
  `intCuna_Bebe` int(2) DEFAULT NULL,
  `intBalcon` int(2) DEFAULT NULL,
  `intInsonorizacion` int(2) DEFAULT NULL,
  `intPlancha_Tabla` int(2) DEFAULT NULL,
  `intClimatizacion` int(2) DEFAULT NULL,
  `intBide` int(2) DEFAULT NULL,
  `intHilo_musical` int(2) DEFAULT NULL,
  `intMaximo_Personas` int(2) DEFAULT NULL,
  `intVista_Mar` int(2) DEFAULT NULL,
  `intVista_Montana` int(2) DEFAULT NULL,
  `intVista_Ciudad` int(2) DEFAULT NULL,
  `intVista_Panoramica` int(2) DEFAULT NULL,
  `intAdmite_Mascotas` int(2) DEFAULT NULL,
  PRIMARY KEY (`id_Habitacion`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
  #6 (permalink)  
Antiguo 14/01/2016, 01:38
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

x_atrix , he implementado el código que tan amablemente me has pasado, también lo he remirado varias veces para intertar cogerlo pues trabajas con clases y yo aún no llego a tanto.
Fijate en las líneas comentadas con mayúsculas pues me dan error y no se por que.
Código PHP:
<?php

$desde 
$_GET['FDesde'];
$hasta $_GET["FHasta"];
                                                      
$precioAlta $row_ConsultaHabitaciones['intPrecio_Alta']; 
$precioMedia $row_ConsultaHabitaciones['intPrecio_Media'];
$precioBaja $row_ConsultaHabitaciones['intPrecio_Baja']; 
$PrecioEspecial $row_ConsultaHabitaciones['intPrecio_Especial'];


class 
Temporadas {

    protected 
$temporadas = []; // ESTA LÍNEA ME DA ERROR

    
protected $acumulador 0.0;

    public function 
__construct($baja$media$alta$especial) {
        
$this->temporadas['baja']      = $baja;
        
$this->temporadas['media']     = $media;
        
$this->temporadas['alta']      = $alta;
        
$this->temporadas['especial']  = $especial;
    }

    protected function 
esTemporada($temporada$dia) {
        foreach(
$this->temporadas[$temporada] as $rango) {
            
$desde $this->getTime($rango[0]);
            
$hasta $this->getTime($rango[1]);

            if (
$dia >= $desde && $dia <= $hasta) {
                return 
true;
            }
        }

        return 
false;
    }

    public function 
esTemporadaBaja($dia) {
        return 
$this->esTemporada('baja'$dia);
    }

    public function 
esTemporadaMedia($dia) {
        return 
$this->esTemporada('media'$dia);
    }

    public function 
esTemporadaAlta($dia) {
        return 
$this->esTemporada('alta'$dia);
    }

    public function 
esEspecial($dia) {
        return 
$this->esTemporada('especial'$dia);
    }

    public function 
acumular($precio) {
        
$this->acumulador += floatval($precio);
    }

    public function 
precioTotal() {
        return 
$this->acumulador;
    }

    public function 
getTime($dia) {
        
// Cambia el orden para strtotime, es mm/dd/yyyy
        
list($dia$mes) = explode('/'$dia);
        return 
strtotime($mes '/' $dia '/' date('Y'));
    }
}


// Temporada Baja = 13/01 al 10/03  -  07/04 al 14/06  -  01/09 al 26/11
// Temporada Media =  11/03 al 26/03  -  15/06 al 31/07  -  27/11 al 14/12
// Temporada Alta = 27/03 al 06/04  -  01/08 al 31/08  -  01/08 al 31/08

$temporadaBaja = [
    [
'13/01''10/03'],
    [
'07/04''14/06'],
    [
'01/09''26/11']
];  
// ESTA LÍNEA ME DA ERROR

$temporadaMedia = [
    [
'11/03''26/03'],
    [
'15/06''31/07'],
    [
'27/11''14/12']
];  
// ESTA LÍNEA ME DA ERROR

$temporadaAlta = [
    [
'27/03''06/04'],
    [
'01/08''31/08'],
    [
'01/08''31/08']
];  
// ESTA LÍNEA ME DA ERROR

$especial = [
    [
'01/01''12/01']
];  
// ESTA LÍNEA ME DA ERROR

// Precios por temporada
$precioBaja     number_format(10.002) . ' €';
$precioMedia    number_format(15.502) . ' €';
$precioAlta     number_format(19.992) . ' €';
$precioEspecial number_format5.952) . ' €';

$helper = new Temporadas($temporadaBaja$temporadaMedia$temporadaAlta$especial);

// Fechas seleccionadas
$inicio $helper->getTime('30/08');
$final  $helper->getTime('04/09');

echo <<<TABLE
<table width="50%" border="1">
    <thead>
    <tr>
        <th>Fecha (dd/mm/yyyy)</th>
        <th>Temporada</th>
        <th>Precio</th>
    </tr>
    </thead>
    <tbody>
TABLE;

for (
$i $inicio$i $final$i += 60 60 24) {
    echo 
'<tr>';

    if (
$helper->esEspecial($i)) {
        
// Acumular precio
        
$helper->acumular($precioEspecial);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Precio Especial</td><td>$precioEspecial</td>";

    } else if (
$helper->esTemporadaAlta($i)) {
        
// Acumular precio
        
$helper->acumular($precioAlta);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Alta</td><td>$precioAlta</td>";

    } else if (
$helper->esTemporadaMedia($i)) {
        
// Acumular precio
        
$helper->acumular($precioMedia);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Media</td><td>$precioMedia</td>";

    } else if (
$helper->esTemporadaBaja($i)) {
        
// Acumular precio
        
$helper->acumular($precioBaja);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada baja</td><td>$precioBaja</td>";

    }

    echo 
'</tr>';
}

$total number_format($helper->precioTotal(), 2) . ' €';

echo <<<ENDTABLE
    <tr>
        <td colspan='2'><b>TOTAL:</b></td>
        <td>$total</td>
    </tr>
    </tbody>
</table>
ENDTABLE;
?>
Los valores de estas fechas vienen en español (d-m-Y):
$desde = $_GET['FDesde'];
$hasta = $_GET["FHasta"];

Muchísimas gracias y un saludo: manyblue

Última edición por manyblue; 14/01/2016 a las 02:26
  #7 (permalink)  
Antiguo 14/01/2016, 05:40
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

Hola,

Te da error por la version de PHP.
Prueba con esto otro:
Código PHP:
<?php

class Temporadas {

    protected 
$temporadas = array();

    protected 
$acumulador 0.0;

    public function 
__construct($baja$media$alta$especial) {
        
$this->temporadas['baja']      = $baja;
        
$this->temporadas['media']     = $media;
        
$this->temporadas['alta']      = $alta;
        
$this->temporadas['especial']  = $especial;
    }

    protected function 
esTemporada($temporada$dia) {
        foreach(
$this->temporadas[$temporada] as $rango) {
            
$desde $this->getTime($rango[0]);
            
$hasta $this->getTime($rango[1]);

            if (
$dia >= $desde && $dia <= $hasta) {
                return 
true;
            }
        }

        return 
false;
    }

    public function 
esTemporadaBaja($dia) {
        return 
$this->esTemporada('baja'$dia);
    }

    public function 
esTemporadaMedia($dia) {
        return 
$this->esTemporada('media'$dia);
    }

    public function 
esTemporadaAlta($dia) {
        return 
$this->esTemporada('alta'$dia);
    }

    public function 
esEspecial($dia) {
        return 
$this->esTemporada('especial'$dia);
    }

    public function 
acumular($precio) {
        
$this->acumulador += floatval($precio);
    }

    public function 
precioTotal() {
        return 
$this->acumulador;
    }

    public function 
getTime($dia) {
        
// Cambia el orden para strtotime, es mm/dd/yyyy
        
list($dia$mes) = explode('/'$dia);
        return 
strtotime($mes '/' $dia '/' date('Y'));
    }
}


// Temporada Baja = 13/01 al 10/03  -  07/04 al 14/06  -  01/09 al 26/11
// Temporada Media =  11/03 al 26/03  -  15/06 al 31/07  -  27/11 al 14/12
// Temporada Alta = 27/03 al 06/04  -  01/08 al 31/08  -  01/08 al 31/08

// Los rangos los espera segun tus comentarios. dd/mm
$temporadaBaja = array(
    array(
'13/01''10/03'),
    array(
'07/04''14/06'),
    array(
'01/09''26/11')
);

$temporadaMedia = array(
    array(
'11/03''26/03'),
    array(
'15/06''31/07'),
    array(
'27/11''14/12'),
);

$temporadaAlta = array(
    array(
'27/03''06/04'),
    array(
'01/08''31/08'),
    
// ['01/08', '31/08']
);

$especial = array(
    array(
'01/01''12/01')
);

// Precios por temporada
$precioBaja     number_format(10.002) . ' €';
$precioMedia    number_format(15.502) . ' €';
$precioAlta     number_format(19.992) . ' €';
$precioEspecial number_format5.952) . ' €';

$helper = new Temporadas($temporadaBaja$temporadaMedia$temporadaAlta$especial);

// Fechas seleccionadas
$inicio $helper->getTime('30/08');
$final  $helper->getTime('04/09');

echo <<<TABLE
<table width="50%" border="1">
    <thead>
    <tr>
        <th>Fecha (dd/mm/yyyy)</th>
        <th>Temporada</th>
        <th>Precio</th>
    </tr>
    </thead>
    <tbody>
TABLE;

for (
$i $inicio$i $final$i += 60 60 24) {
    echo 
'<tr>';

    if (
$helper->esEspecial($i)) {
        
// Acumular precio
        
$helper->acumular($precioEspecial);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Precio Especial</td><td>$precioEspecial</td>";

    } else if (
$helper->esTemporadaAlta($i)) {
        
// Acumular precio
        
$helper->acumular($precioAlta);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Alta</td><td>$precioAlta</td>";

    } else if (
$helper->esTemporadaMedia($i)) {
        
// Acumular precio
        
$helper->acumular($precioMedia);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Media</td><td>$precioMedia</td>";

    } else if (
$helper->esTemporadaBaja($i)) {
        
// Acumular precio
        
$helper->acumular($precioBaja);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada baja</td><td>$precioBaja</td>";

    }

    echo 
'</tr>';
}

$total number_format($helper->precioTotal(), 2) . ' €';

echo <<<ENDTABLE
    <tr>
        <td colspan='2'><b>TOTAL:</b></td>
        <td>$total</td>
    </tr>
    </tbody>
</table>
ENDTABLE;
Prueba esto en una pagina php sola.

En casos un poco mas complejos las clases te dan claridad al código, para algo sencillito añaden complejidad innecesaria.
  #8 (permalink)  
Antiguo 14/01/2016, 05:48
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

En cuanto a esto:
Código PHP:
Ver original
  1. Los valores de estas fechas vienen en español (d-m-Y):
  2. $desde = $_GET['FDesde'];
  3. $hasta = $_GET["FHasta"];

Puedes hacer por ejemplo:
Código PHP:
Ver original
  1. list($dia, $mes, $anno) = explode('-', $_GET['FDesde']);
  2. $desde = "$dia/$mes";
  3.  
  4. list($dia, $mes, $anno) = explode('-', $_GET['FHasta']);
  5. $hasta= "$dia/$mes";
O
Código PHP:
Ver original
  1. $desde = date('d/m', strtotime($_GET['FDesde']));
  2. $hasta = date('d/m', strtotime($_GET['FHasta']));
  #9 (permalink)  
Antiguo 14/01/2016, 06:41
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

x_atrix, muchísimas gracias, probaré lo que me dices y te comento.
Bueno, al final me decidí por lo más complicado para mi por tener que corregir consultas pero... facilitará al usuario del hotel decidir sus propias temporadas.

1) Cree una nueva tabla:
Código:
CREATE TABLE IF NOT EXISTS `tbl_temporadas_precios_habitaciones` (
  `id_temporada` int(11) NOT NULL AUTO_INCREMENT,
  `refHabitacion` int(11) DEFAULT NULL,
  `strNombreTemporada` varchar(150) DEFAULT NULL,
  `dateDesde` date DEFAULT NULL,
  `dateHasta` date DEFAULT NULL,
  `intPrecio` double DEFAULT NULL,
  `strDescripcionTemporada` varchar(250) DEFAULT NULL,
  PRIMARY KEY (`id_temporada`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Por que refHotel y no refHabitacion, pues con el hotel tengo usuario y es menos lioso.
2) Me hago esta consulta:
Código PHP:
<?php
$varHotel 
"0";
if (isset(
$_GET["idHotel"])) {
  
$varHotel $_GET["idHotel"];
}
mysql_select_db($database_Conexion_db_WebReservas$Conexion_db_WebReservas);
$query_ConsultaPrecios sprintf("SELECT tbl_usuarios.idUsuario, tbl_hotel.refUsuario, tbl_hotel.idHotel, tbl_temporadas_precios_habitaciones.refHotel, tbl_temporadas_precios_habitaciones.id_Temporada, tbl_temporadas_precios_habitaciones.strNombreTemporada, tbl_temporadas_precios_habitaciones.dateDesde, tbl_temporadas_precios_habitaciones.dateHasta, tbl_temporadas_precios_habitaciones.intPrecio, tbl_temporadas_precios_habitaciones.strDescripcionTemporada, tbl_usuarios.strNombre, tbl_usuarios.strApellidos, tbl_usuarios.strEmail, tbl_usuarios.intEstado, tbl_usuarios.strNick_Usuario, tbl_usuarios.strImagen_Usuario, tbl_usuarios.strTelefono, tbl_usuarios.strMovil, tbl_usuarios.intNivel, tbl_usuarios.Fecha_Alta_Usuario, tbl_usuarios.Fecha_Actualizacion_Usuario, tbl_hotel.strNombre, tbl_hotel.strNombreCEO, tbl_hotel.strNombre_Empresa, tbl_hotel.strNIF_CIF, tbl_hotel.intEstado, tbl_hotel.intCategoria, tbl_hotel.strDireccion, tbl_hotel.strPoblacion, tbl_hotel.idProvincia, tbl_hotel.strEstadoPaisExtrangero, tbl_hotel.intCodigo_Postal, tbl_hotel.strPais, tbl_hotel.strtDescripcion, tbl_hotel.strResumen, tbl_hotel.strResumen_ing, tbl_hotel.strResumen_ale, tbl_hotel.strResumen_fra, tbl_hotel.strResumen_hol, tbl_hotel.strDescripcion_ing, tbl_hotel.strDescripcion_ale, tbl_hotel.strDescripcion_fra, tbl_hotel.strDescripcion_hol, tbl_hotel.dblLatitud, tbl_hotel.dblLongitud, tbl_hotel.intNumero_Habitaciones, tbl_hotel.strEmail, tbl_hotel.strTelefono, tbl_hotel.strFax,tbl_hotel.strMovil, tbl_hotel.intWifi, tbl_hotel.intRestaurante, tbl_hotel.intCafeteria, tbl_hotel.intGaraje, tbl_hotel.intJardines, tbl_hotel.strInstalaciones_Deportivas, tbl_hotel.intPiscinaExterior, tbl_hotel.intPiscinaInterior, tbl_hotel.intAnimalesCompania, tbl_hotel.intServicioDiscrecional, tbl_hotel.intSpa, tbl_hotel.Fecha_Alta_Hotel, tbl_hotel.Fecha_Modificacion_Hotel FROM tbl_usuarios INNER JOIN tbl_hotel ON tbl_hotel.refUsuario = tbl_usuarios.idUsuario INNER JOIN tbl_temporadas_precios_habitaciones ON tbl_temporadas_precios_habitaciones.refHotel = tbl_hotel.idHotel WHERE tbl_temporadas_precios_habitaciones.refHotel = %s"GetSQLValueString($varHotel"int"));
$ConsultaPrecios mysql_query($query_ConsultaPrecios$Conexion_db_WebReservas) or die(mysql_error());
$row_ConsultaPrecios mysql_fetch_assoc($ConsultaPrecios);
$totalRows_ConsultaPrecios mysql_num_rows($ConsultaPrecios);
?>
3) Lo presento de esta forma:
Código PHP:
<?php 
                                                      
                                                      
  $desde 
$_GET['FDesde'];
  
$hasta $_GET["FHasta"];
  
$new_desde date"m-d"strtotime($desde));
  
$dateHasta date"m-d"strtotime($hasta));

  
// Temporada Baja = 13/01 al 10/03 - 07/04 al 14/06 - 01/09 al 26/11
  // Temporada Media =  11/03 al 26/03 - 15/06 al 31/07 - 27/11 al 14/12
  // Temporada Alta = 27/03 al 06/04 - 01/08 al 31/08 - 01/08 al 31/08
  
  // DATOS FACTURACIÓN //
  
  
do {
      
  
$dateDesde date("m-d"strtotime($row_ConsultaPrecios['dateDesde']));
  
$dateHasta date("m-d"strtotime($row_ConsultaPrecios['dateHasta']));
  
$NombreTemporada $row_ConsultaPrecios['strNombreTemporada'];
  
$PrecioTemporada $row_ConsultaPrecios['intPrecio'];
  
  if((
$dateDesde <= $new_desde) && ($dateHasta >= $dateHasta) && ($row_ConsultaPrecios['strNombreTemporada'] = "Baja")):
     
$PrecioHabitacion $row_ConsultaPrecios['intPrecio'];
     
$Temporada $NombreTemporada;
  elseif((
$dateDesde <= $new_desde) && ($dateHasta >= $dateHasta) && ($row_ConsultaPrecios['strNombreTemporada'] = "Media")):
     
$PrecioHabitacion $row_ConsultaPrecios['intPrecio'];
     
$Temporada $NombreTemporada;
  elseif((
$dateDesde <= $new_desde) && ($dateHasta >= $dateHasta) && ($row_ConsultaPrecios['strNombreTemporada'] = "Alta")):
     
$PrecioHabitacion $row_ConsultaPrecios['intPrecio'];
     
$Temporada $NombreTemporada;
  endif;

  } while (
$row_ConsultaPrecios mysql_fetch_assoc($ConsultaPrecios));
  
  
  
// DIFERENCIA DE DIAS ENTRE Fdesde HASTA Fhasta //
  
$inicio strtotime($_GET['FDesde']);
  
$fin strtotime($_GET["FHasta"]);
  
$dateDiff $fin $inicio;
  echo 
"<strong>Días Totales:</strong> ".($dateDiffTotal floor($dateDiff/(60*60*24))+1)." días";
  echo 
"<br />"?>
  <strong>Fecha Factura:</strong> <?php echo date("d-m-Y");?><br />
  <strong>Cliente:</strong> 
  <?php echo ObtenerNombreUsuario($row_DatosDatosConsulta['refUsuario']); ?>
  <?php echo ObtenerAlellidosUsuario($row_DatosDatosConsulta['refUsuario']); ?>
  <br />
  
  <?php
  
// CALCULOS FACTURACIÓN //
  
echo "<strong>Precio/Día:</strong> ".$PrecioHabitacion." €"."&nbsp;&nbsp;&nbsp;<strong>Temporada:</strong> ".$Temporada;
  echo 
"<br />";
  echo 
"<strong>Sub Total:</strong> ".$SubTotal $PrecioHabitacion $dateDiffTotal." €";
  echo 
"<br />";
  
$Impuesto $row_ConsultaHabitaciones['intValor_Impuesto']; 
  
$NombreImpuesto $row_ConsultaHabitaciones['strNombre_Impuesto'];
  
$Impuestos = (($Impuesto $SubTotal) / 100);
  echo 
"<strong>".$Impuesto."% ".$NombreImpuesto.":</strong> ".$row_ConsultaPrecios['strNombreTemporada']." €";
  echo 
"<br />";
  echo 
"<strong>Total:</strong> ".$Total $Impuestos $SubTotal." €";
  
  
?>
Me va genial, pero lo dicho, probaré como me dices tu x_atrix
Un saludo: Manyblue
  #10 (permalink)  
Antiguo 14/01/2016, 07:18
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

Lo que estas haciendo no lo veo muy correcto que digamos...
Según tu código, cual es el total de una reserva desde el 08/03/2016 al 31/03/2016?

NOTA*** los días del 08/03 al 10/03 es temporada baja, del 11/03 al 26/03 es temporada media y del 27/03 al 31/03 es temporada alta.

Por otro lado, esto:
Código PHP:
Ver original
  1. ($dateHasta >= $dateHasta)
SIEMPRE será TRUE!!!
Si $dateHasta = 1 la comparacion es: (1 >= 1) siempre true ...
  #11 (permalink)  
Antiguo 14/01/2016, 07:41
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Al final me quedó así:
Código PHP:
 <?php 

$desde 
$_GET['FDesde'];
$hasta $_GET["FHasta"];
$new_desde date"m-d"strtotime($desde));
$new_Hasta date"m-d"strtotime($hasta));

// Temporada Baja = 13/01 al 10/03 - 07/04 al 14/06 - 01/09 al 26/11
// Temporada Media =  11/03 al 26/03 - 15/06 al 31/07 - 27/11 al 14/12
// Temporada Alta = 27/03 al 06/04 - 01/08 al 31/08 - 01/08 al 31/08

// DATOS FACTURACIÓN //

do {
    
$dateDesde date("m-d"strtotime($row_ConsultaPrecios['dateDesde']));
$dateHasta date("m-d"strtotime($row_ConsultaPrecios['dateHasta']));
$NombreTemporada $row_ConsultaPrecios['strNombreTemporada'];
$PrecioTemporada $row_ConsultaPrecios['intPrecio'];

if((
$dateDesde <= $new_desde) && ($dateHasta >= $new_Hasta) && ($row_ConsultaPrecios['strNombreTemporada'] = "Baja")):
   
$PrecioHabitacion $row_ConsultaPrecios['intPrecio'];
   
$Temporada $NombreTemporada;
elseif((
$dateDesde <= $new_desde) && ($dateHasta >= $new_Hasta) && ($row_ConsultaPrecios['strNombreTemporada'] = "Media")):
   
$PrecioHabitacion $row_ConsultaPrecios['intPrecio'];
   
$Temporada $NombreTemporada;
elseif((
$dateDesde <= $new_desde) && ($dateHasta >= $new_Hasta) && ($row_ConsultaPrecios['strNombreTemporada'] = "Alta")):
   
$PrecioHabitacion $row_ConsultaPrecios['intPrecio'];
   
$Temporada $NombreTemporada;
endif;

} while (
$row_ConsultaPrecios mysql_fetch_assoc($ConsultaPrecios));


// DIFERENCIA DE DIAS ENTRE Fdesde HASTA Fhasta //
$inicio strtotime($_GET['FDesde']);
$fin strtotime($_GET["FHasta"]);
$dateDiff $fin $inicio;
echo 
"<strong>Días Totales:</strong> ".($dateDiffTotal floor($dateDiff/(60*60*24))+1)." días";
echo 
"<br />"?>
<strong>Fecha Factura:</strong> <?php echo date("d-m-Y");?><br />
<strong>Cliente:</strong> 
<?php echo ObtenerNombreUsuario($row_DatosDatosConsulta['refUsuario']); ?>
<?php 
echo ObtenerAlellidosUsuario($row_DatosDatosConsulta['refUsuario']); ?>
<br />

<?php
// CALCULOS FACTURACIÓN //
echo "<strong>Precio/Día:</strong> ".$PrecioHabitacion." €"."&nbsp;&nbsp;&nbsp;<strong>Temporada:</strong> ".$Temporada;
echo 
"<br />";
echo 
"<strong>Sub Total:</strong> ".$SubTotal $PrecioHabitacion $dateDiffTotal." €";
echo 
"<br />";
$Impuesto $row_ConsultaHabitaciones['intValor_Impuesto']; 
$NombreImpuesto $row_ConsultaHabitaciones['strNombre_Impuesto'];
$Impuestos = (($Impuesto $SubTotal) / 100);
echo 
"<strong>".$Impuesto."% ".$NombreImpuesto.":</strong> ".$row_ConsultaPrecios['strNombreTemporada'].$Impuestos." €";
echo 
"<br />";
echo 
"<strong>Total:</strong> ".$Total $Impuestos $SubTotal." €";

?>
Con tu código y los correcciones que me dices funciona también.
Si es la versión de wampserver y php
Si tengo de 10-12-2016 al 12-12-2016 son 3 días pues en el hotel puedes entrar desde las 00:00 del día 10-12-2016 y sales a las 12:00 del día 12-12-2016 aunque solo tengas 12 horas del día 12-12-2016 pagas día completo.
Esto:
SIEMPRE será TRUE!!!
Si $dateHasta = 1 la comparacion es: (1 >= 1) siempre true ...
No lo comprendo muy bién.
Un saludo: Manyblue
  #12 (permalink)  
Antiguo 14/01/2016, 07:50
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

No te puede funcionar correctamente porque solo tienes un precio cuando deberías tener 3 diferentes. Has probado con las fechas que te dije. En tu código, pon estas fechas: 08/03/2016 al 31/03/2016

Te mostrará un precio... eso si, pero realmente es correcto? Calcula tu con la calculadora cada día según temporada y compara con lo que te dice tu script, no van a cuadrar ...
  #13 (permalink)  
Antiguo 14/01/2016, 08:30
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Notice: Undefined variable: PrecioHabitacion in C:\wamp\www\WEBRESPONSIVERESERVAS\hoteles_usuario_ reserva_previa.php on line 247

Notice: Undefined variable: Temporada in C:\wamp\www\WEBRESPONSIVERESERVAS\hoteles_usuario_ reserva_previa.php on line 247

Notice: Undefined variable: PrecioHabitacion in C:\wamp\www\WEBRESPONSIVERESERVAS\hoteles_usuario_ reserva_previa.php on line 249

Si pongo las fechas que me dices me dan errores anteriores.
Es decir, deberia poner tres precios para alta media y baja ??
Un saludo: Manyblue
  #14 (permalink)  
Antiguo 14/01/2016, 08:47
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

Lo esperado ... no funciona :)
Claro, debes tener precio por cada día no por el rango entero. Las fechas que te dije incluyen las 3 temporadas. Pon estas fechas en el código que te pase yo y mira a ver la tabla que te genera...
  #15 (permalink)  
Antiguo 14/01/2016, 12:35
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Y que solución me propones??
En vez de poner dos campos de fechas poner cuatro dos para mes y dia y otros dos para mes y dia (comienzo y fin) con tres precios para alta media y baja ??
Un saludo: Manyblue
  #16 (permalink)  
Antiguo 14/01/2016, 12:43
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

Has ejecutado lo que te pase en el primer post? Esto te lo soluciona ...
  #17 (permalink)  
Antiguo 14/01/2016, 12:56
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

No estoy con ello.
Quedaría asi ??:
Código PHP:
<?php
 
list($dia$mes$anno) = explode('-'$_GET['FDesde']);
$desde "$dia-$mes"
list(
$dia$mes$anno) = explode('-'$_GET['FHasta']);
$hasta"$dia-$mes";

class 
Temporadas {
 
    protected 
$temporadas = array(); 

 
    protected 
$acumulador 0.0;
 
    public function 
__construct($baja$media$alta$especial) {
        
$this->temporadas['baja']      = $baja;
        
$this->temporadas['media']     = $media;
        
$this->temporadas['alta']      = $alta;
        
$this->temporadas['especial']  = $especial;
    }
 
    protected function 
esTemporada($temporada$dia) {
        foreach(
$this->temporadas[$temporada] as $rango) {
            
$desde $this->getTime($rango[0]);
            
$hasta $this->getTime($rango[1]);
 
            if (
$dia >= $desde && $dia <= $hasta) {
                return 
true;
            }
        }
 
        return 
false;
    }
 
    public function 
esTemporadaBaja($dia) {
        return 
$this->esTemporada('baja'$dia);
    }
 
    public function 
esTemporadaMedia($dia) {
        return 
$this->esTemporada('media'$dia);
    }
 
    public function 
esTemporadaAlta($dia) {
        return 
$this->esTemporada('alta'$dia);
    }
 
    public function 
esEspecial($dia) {
        return 
$this->esTemporada('especial'$dia);
    }
 
    public function 
acumular($precio) {
        
$this->acumulador += floatval($precio);
    }
 
    public function 
precioTotal() {
        return 
$this->acumulador;
    }
 
    public function 
getTime($dia) {
        
// Cambia el orden para strtotime, es mm/dd/yyyy

        
list($dia$mes) = explode('/'$dia);
        return 
strtotime($mes '/' $dia '/' date('Y'));
    }
}
 
 
// Temporada Baja = 13/01 al 10/03  -  07/04 al 14/06  -  01/09 al 26/11

// Temporada Media =  11/03 al 26/03  -  15/06 al 31/07  -  27/11 al 14/12

// Temporada Alta = 27/03 al 06/04  -  01/08 al 31/08  -  01/08 al 31/08

$temporadaBaja = array(
    array(
'13-01''10-03'),
    array(
'07-04''14-06'),
    array(
'01-09''26-11')
);

$temporadaMedia = array(
    array(
'11-03''26-03'),
    array(
'15-06''31-07'),
    array(
'27-11''14-12')
);

$temporadaAlta = array(
    array(
'27-03''06-04'),
    array(
'01-08''31-08'),
    array(
'01-08''31-08')
);

$Especial = array(
    array(
'01-01''12-01')
);
 
// Precios por temporada

$precioBaja     number_format(10.002) . ' €';
$precioMedia    number_format(15.502) . ' €';
$precioAlta     number_format(19.992) . ' €';
$precioEspecial number_format5.952) . ' €';
 
$helper = new Temporadas($temporadaBaja$temporadaMedia$temporadaAlta$Especial);
 
// Fechas seleccionadas

$inicio $helper->getTime('30/08');
$final  $helper->getTime('04/09');
 
echo <<<TABLE
<table width="50%" border="1">
    <thead>
    <tr>
        <th>Fecha (dd/mm/yyyy)</th>
        <th>Temporada</th>
        <th>Precio</th>
    </tr>
    </thead>
    <tbody>
TABLE;
 
for (
$i $inicio$i $final$i += 60 60 24) {
    echo 
'<tr>';
 
    if (
$helper->esEspecial($i)) {
        
// Acumular precio

        
$helper->acumular($precioEspecial);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Precio Especial</td><td>$precioEspecial</td>";
 
    } else if (
$helper->esTemporadaAlta($i)) {
        
// Acumular precio

        
$helper->acumular($precioAlta);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Alta</td><td>$precioAlta</td>";
 
    } else if (
$helper->esTemporadaMedia($i)) {
        
// Acumular precio

        
$helper->acumular($precioMedia);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Media</td><td>$precioMedia</td>";
 
    } else if (
$helper->esTemporadaBaja($i)) {
        
// Acumular precio

        
$helper->acumular($precioBaja);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada baja</td><td>$precioBaja</td>";
 
    }
 
    echo 
'</tr>';
}
 
$total number_format($helper->precioTotal(), 2) . ' €';
 
echo <<<ENDTABLE
    <tr>
        <td colspan='2'><b>TOTAL:</b></td>
        <td>$total</td>
    </tr>
    </tbody>
</table>
ENDTABLE;
?>
  #18 (permalink)  
Antiguo 14/01/2016, 14:55
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

si, eso, ejecutalo y mira a ver lo que te muestra si es lo esperado ...
  #19 (permalink)  
Antiguo 14/01/2016, 15:23
Avatar de xfxstudios  
Fecha de Ingreso: junio-2015
Ubicación: Valencia - Venezuela
Mensajes: 2.448
Antigüedad: 8 años, 10 meses
Puntos: 263
Respuesta: Organizar Precios y Temporadas

de casualidad no te tiro algun error esto:
Código PHP:
Ver original
  1. list($dia, $mes, $anno) = explode('-', $_GET['FDesde']);
  2. $desde = "$dia-$mes";
  3. list($dia, $mes, $anno) = explode('-', $_GET['FHasta']);
  4. $hasta= "$dia-$mes";

lo pregunto porque estas repitiendo estas variables $dia, $mes, $anno en 2 GET distintos?
__________________
[email protected]
HITCEL
  #20 (permalink)  
Antiguo 14/01/2016, 16:05
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

Lo sobreescribe, no debe dar error por eso. De todas forma, este no es el codigo de mi primer post.
Ve arriba, el primer post mio ... el segundo del hilo. Prueba este codigo.
  #21 (permalink)  
Antiguo 15/01/2016, 02:15
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Me explota por un lado jajajajaja, que torpe soy.

Se llega a esta página desde el enlace:

hoteles_usuario_reserva_previa.php?recordID=<?php echo $row_ConsultaHabitaciones['id_Habitacion']; ?>&refHotel=<?php echo $row_ConsultaHabitaciones['refHotel']; ?>&FDesde=<?php echo $_GET['FDesde']; ?>&FHasta=<?php echo $_GET['FHasta']; ?>&idProvincia=<?php echo $row_DatosDatosConsulta['idProvincia']; ?>&idHotel=<?php echo $row_ConsultaHabitaciones['refHotel']; ?>

Es decir, le estoy pasando:
recordID = idHabitacion
refHotel = idHotel
FDesde
Fhasta
idProvincia

Código PHP:
<?php

list($dia$mes$anno) = explode('-'$_GET['FDesde']);
$desde "$dia-$mes"
list(
$dia$mes$anno) = explode('-'$_GET['FHasta']);
$hasta"$dia-$mes";

$precioAlta $row_ConsultaHabitaciones['intPrecio_Alta']; //viene de tabla habitaciones
$precioMedia $row_ConsultaHabitaciones['intPrecio_Media'];
$precioBaja $row_ConsultaHabitaciones['intPrecio_Baja']; 
$PrecioEspecial $row_ConsultaHabitaciones['intPrecio_Especial'];
 
list(
$dia$mes$anno) = explode('-'$_GET['FDesde']);
$desde "$dia-$mes"
list(
$dia$mes$anno) = explode('-'$_GET['FHasta']);
$hasta"$dia-$mes";

class 
Temporadas {
 
    protected 
$temporadas = array(); 

 
    protected 
$acumulador 0.0;
 
    public function 
__construct($baja$media$alta$especial) {
        
$this->temporadas['baja']      = $baja;
        
$this->temporadas['media']     = $media;
        
$this->temporadas['alta']      = $alta;
        
$this->temporadas['especial']  = $especial;
    }
 
    protected function 
esTemporada($temporada$dia) {
        foreach(
$this->temporadas[$temporada] as $rango) {
            
$desde $this->getTime($rango[0]);
            
$hasta $this->getTime($rango[1]);
 
            if (
$dia >= $desde && $dia <= $hasta) {
                return 
true;
            }
        }
 
        return 
false;
    }
 
    public function 
esTemporadaBaja($dia) {
        return 
$this->esTemporada('baja'$dia);
    }
 
    public function 
esTemporadaMedia($dia) {
        return 
$this->esTemporada('media'$dia);
    }
 
    public function 
esTemporadaAlta($dia) {
        return 
$this->esTemporada('alta'$dia);
    }
 
    public function 
esEspecial($dia) {
        return 
$this->esTemporada('especial'$dia);
    }
 
    public function 
acumular($precio) {
        
$this->acumulador += floatval($precio);
    }
 
    public function 
precioTotal() {
        return 
$this->acumulador;
    }
 
    public function 
getTime($dia) {
        
// Cambia el orden para strtotime, es mm/dd/yyyy

        
list($dia$mes) = explode('/'$dia);
        return 
strtotime($mes '/' $dia '/' date('Y'));
    }
}
 
 
// Temporada Baja = 13/01 al 10/03  -  07/04 al 14/06  -  01/09 al 26/11

// Temporada Media =  11/03 al 26/03  -  15/06 al 31/07  -  27/11 al 14/12

// Temporada Alta = 27/03 al 06/04  -  01/08 al 31/08  -  01/08 al 31/08

$temporadaBaja = array(
    array(
'13-01''10-03'),
    array(
'07-04''14-06'),
    array(
'01-09''26-11')
);

$temporadaMedia = array(
    array(
'11-03''26-03'),
    array(
'15-06''31-07'),
    array(
'27-11''14-12')
);

$temporadaAlta = array(
    array(
'27-03''06-04'),
    array(
'01-08''31-08'),
    array(
'01-08''31-08')
);

$especial = array(
    array(
'01-01''12-01')
);
 
// Precios por temporada

$precioBaja     number_format(10.002) . ' €';
$precioMedia    number_format(15.502) . ' €';
$precioAlta     number_format(19.992) . ' €';
$precioEspecial number_format5.952) . ' €';
 
$helper = new Temporadas($temporadaBaja$temporadaMedia$temporadaAlta$especial);
 
// Fechas seleccionadas

$inicio $helper->getTime('30/08');
$final  $helper->getTime('04/09');
 
echo <<<TABLE
<table width="50%" border="1">
    <thead>
    <tr>
        <th>Fecha (dd/mm/yyyy)</th>
        <th>Temporada</th>
        <th>Precio</th>
    </tr>
    </thead>
    <tbody>
TABLE;
 
for (
$i $inicio$i $final$i += 60 60 24) {
    echo 
'<tr>';
 
    if (
$helper->esEspecial($i)) {
        
// Acumular precio

        
$helper->acumular($precioEspecial);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Precio Especial</td><td>$precioEspecial</td>";
 
    } else if (
$helper->esTemporadaAlta($i)) {
        
// Acumular precio

        
$helper->acumular($precioAlta);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Alta</td><td>$precioAlta</td>";
 
    } else if (
$helper->esTemporadaMedia($i)) {
        
// Acumular precio

        
$helper->acumular($precioMedia);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Media</td><td>$precioMedia</td>";
 
    } else if (
$helper->esTemporadaBaja($i)) {
        
// Acumular precio

        
$helper->acumular($precioBaja);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada baja</td><td>$precioBaja</td>";
 
    }
 
    echo 
'</tr>';
}
 
$total number_format($helper->precioTotal(), 2) . ' €';
 
echo <<<ENDTABLE
    <tr>
        <td colspan='2'><b>TOTAL:</b></td>
        <td>$total</td>
    </tr>
    </tbody>
</table>
ENDTABLE;
?>
Al poner tu código me salta error:
Notice: Undefined offset: 1 in C:\wamp\www\WEBRESPONSIVERESERVAS\hoteles_usuario_ reserva_previa.php on line 265

Esta línea:
list($dia, $mes) = explode('/', $dia);

Muchísimas gracias, aunque aún no he resuelto el tema.Un saludo: manyblue
  #22 (permalink)  
Antiguo 15/01/2016, 02:33
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Me gustaría que este tema quedase solucionados de las dos formas, con tabla y sin tabla de Temporadas.
Sin tabla es en el tema que estamos.
Con tabla me aconsejaron que variara la tabla de esta forma que es más facil:
Código PHP:
CREATE TABLE IF NOT EXISTS `tbl_temporadas_precios_habitaciones` (
  `
id_Temporadaint(11NOT NULL AUTO_INCREMENT,
  `
refHotelint(11) DEFAULT NULL,
  `
strNombreTemporadavarchar(150) DEFAULT NULL,
  `
diaDesdevarchar(50) DEFAULT NULL,
  `
mesDesdevarchar(50) DEFAULT NULL,
  `
diaHastavarchar(50) DEFAULT NULL,
  `
mesHastavarchar(50) DEFAULT NULL,
  `
intPreciodouble DEFAULT NULL,
  `
strDescripcionTemporadavarchar(250) DEFAULT NULL,
  
PRIMARY KEY (`id_Temporada`)
ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 
Espero opiniones .....
Un saludo: Manyblue
  #23 (permalink)  
Antiguo 15/01/2016, 06:41
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Bueno, logré que funcionara el codigo de x_atrix quedando así:
Código PHP:
<?php


    $desde 
date('d/m'strtotime($_GET['FDesde']));
    
$hasta date('d/m'strtotime($_GET['FHasta']));
                                                       
$precioAlta $row_ConsultaHabitaciones['intPrecio_Alta']; 
$precioMedia $row_ConsultaHabitaciones['intPrecio_Media'];
$precioBaja $row_ConsultaHabitaciones['intPrecio_Baja']; 
$precioEspecial $row_ConsultaHabitaciones['intPrecio_Especial'];

class 
Temporadas {
 
    protected 
$temporadas = array(); 

 
    protected 
$acumulador 0.0;
 
    public function 
__construct($baja$media$alta$especial) {
        
$this->temporadas['baja']      = $baja;
        
$this->temporadas['media']     = $media;
        
$this->temporadas['alta']      = $alta;
        
$this->temporadas['especial']  = $especial;
    }
 
    protected function 
esTemporada($temporada$dia) {
        foreach(
$this->temporadas[$temporada] as $rango) {
            
$desde $this->getTime($rango[0]);
            
$hasta $this->getTime($rango[1]);
 
            if (
$dia >= $desde && $dia <= $hasta) {
                return 
true;
            }
        }
 
        return 
false;
    }
 
    public function 
esTemporadaBaja($dia) {
        return 
$this->esTemporada('baja'$dia);
    }
 
    public function 
esTemporadaMedia($dia) {
        return 
$this->esTemporada('media'$dia);
    }
 
    public function 
esTemporadaAlta($dia) {
        return 
$this->esTemporada('alta'$dia);
    }
 
    public function 
esEspecial($dia) {
        return 
$this->esTemporada('especial'$dia);
    }
 
    public function 
acumular($precio) {
        
$this->acumulador += floatval($precio);
    }
 
    public function 
precioTotal() {
        return 
$this->acumulador;
    }
 
    public function 
getTime($dia) {
        
// Cambia el orden para strtotime, es mm/dd/yyyy

        
list($dia$mes) = explode('/'$dia);
        return 
strtotime($mes '/' $dia '/' date('Y'));
    }
}
 
 
// Temporada Baja = 13/01 al 10/03  -  07/04 al 14/06  -  01/09 al 26/11

// Temporada Media =  11/03 al 26/03  -  15/06 al 31/07  -  27/11 al 14/12

// Temporada Alta = 27/03 al 06/04  -  01/08 al 31/08  -  01/08 al 31/08

$temporadaBaja = array(
    array(
'13/01''10/03'),
    array(
'07/04''14/06'),
    array(
'01/09''26/11')
);

$temporadaMedia = array(
    array(
'11/03''26/03'),
    array(
'15/06''31/07'),
    array(
'27/11''14/12')
);

$temporadaAlta = array(
    array(
'27/03''06/04'),
    array(
'01/08''31/08'),
    array(
'01/08''31/08')
);

$especial = array(
    array(
'01/01''12/01')
);
 
// Precios por temporada

$precioBaja     number_format(10.002) . ' €';
$precioMedia    number_format(15.502) . ' €';
$precioAlta     number_format(19.992) . ' €';
$precioEspecial number_format5.952) . ' €';
 
$helper = new Temporadas($temporadaBaja$temporadaMedia$temporadaAlta$especial);
 
// Fechas seleccionadas

$inicio $helper->getTime('30/08');
$final  $helper->getTime('04/09');
 
echo <<<TABLE
<table width="50%" border="1">
    <thead>
    <tr>
        <th>Fecha (dd/mm/yyyy)</th>
        <th>Temporada</th>
        <th>Precio</th>
    </tr>
    </thead>
    <tbody>
TABLE;
 
for (
$i $inicio$i $final$i += 60 60 24) {
    echo 
'<tr>';
 
    if (
$helper->esEspecial($i)) {
        
// Acumular precio

        
$helper->acumular($precioEspecial);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Precio Especial</td><td>$precioEspecial</td>";
 
    } else if (
$helper->esTemporadaAlta($i)) {
        
// Acumular precio

        
$helper->acumular($precioAlta);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Alta</td><td>$precioAlta</td>";
 
    } else if (
$helper->esTemporadaMedia($i)) {
        
// Acumular precio

        
$helper->acumular($precioMedia);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Media</td><td>$precioMedia</td>";
 
    } else if (
$helper->esTemporadaBaja($i)) {
        
// Acumular precio

        
$helper->acumular($precioBaja);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada baja</td><td>$precioBaja</td>";
 
    }
 
    echo 
'</tr>';
}
 
$total number_format($helper->precioTotal(), 2) . ' €';
 
echo <<<ENDTABLE
    <tr>
        <td colspan='2'><b>TOTAL:</b></td>
        <td>$total</td>
    </tr>
    </tbody>
</table>
ENDTABLE;
?>
Esto dá como resultado:
Código HTML:
Reserva Habitación: Nº 1 de: Hotel San Telmo
Desde el: 18-01-2016  Hasta el: 23-01-2016
Fecha (dd/mm/yyyy)         Temporada         Precio               
30/08/2016Temporada Alta19.99 €
31/08/2016Temporada Alta19.99 €
01/09/2016Temporada baja10.00 €
02/09/2016Temporada baja10.00 €
03/09/2016Temporada baja10.00 €             
TOTAL:         69.98 €
Me gustaría que fuera un poco más como esto:
Código HTML:
Reserva Habitación: Nº 1 de: Hotel San Telmo
Desde el: 18-01-2016  Hasta el: 23-01-2016
Días Totales: 6 días
Fecha Factura: 15-01-2016
Cliente:  Pepe Lo que Sea                                                      
Precio/Día: 30 €   Temporada: Baja
Sub Total: 180 €
17% IGIC: 30.6 €
Total: 210.6 €                                                                                                            
el código que tenía con tabla temporadas es este:
Código PHP:
<?php 

$desde 
$_GET['FDesde'];
$hasta $_GET["FHasta"];
$new_desde date"m-d"strtotime($desde));
$new_Hasta date"m-d"strtotime($hasta));

// Temporada Baja = 13/01 al 10/03 - 07/04 al 14/06 - 01/09 al 26/11
// Temporada Media =  11/03 al 26/03 - 15/06 al 31/07 - 27/11 al 14/12
// Temporada Alta = 27/03 al 06/04 - 01/08 al 31/08 - 01/08 al 31/08

// DATOS FACTURACIÓN //

do {
    
$dateDesde date("m-d"strtotime($row_ConsultaPrecios['dateDesde']));
$dateHasta date("m-d"strtotime($row_ConsultaPrecios['dateHasta']));
$NombreTemporada $row_ConsultaPrecios['strNombreTemporada'];
$PrecioTemporada $row_ConsultaPrecios['intPrecio'];

if((
$dateDesde <= $new_desde) && ($dateHasta >= $new_Hasta) && ($row_ConsultaPrecios['strNombreTemporada'] = "Baja")):
  
$PrecioHabitacion $row_ConsultaPrecios['intPrecio'];
   
$Temporada $NombreTemporada;
elseif((
$dateDesde <= $new_desde) && ($dateHasta >= $new_Hasta) && ($row_ConsultaPrecios['strNombreTemporada'] = "Media")):
  
$PrecioHabitacion $row_ConsultaPrecios['intPrecio'];
   
$Temporada $NombreTemporada;
elseif((
$dateDesde <= $new_desde) && ($dateHasta >= $new_Hasta) && ($row_ConsultaPrecios['strNombreTemporada'] = "Alta")):
  
$PrecioHabitacion $row_ConsultaPrecios['intPrecio'];
   
$Temporada $NombreTemporada;
endif;

} while (
$row_ConsultaPrecios mysql_fetch_assoc($ConsultaPrecios));


// DIFERENCIA DE DIAS ENTRE Fdesde HASTA Fhasta //
$inicio strtotime($_GET['FDesde']);
$fin strtotime($_GET["FHasta"]);
$dateDiff $fin $inicio;
echo 
"<strong>Días Totales:</strong> ".($dateDiffTotal floor($dateDiff/(60*60*24))+1)." días";
echo 
"<br />"?>
<strong>Fecha Factura:</strong> <?php echo date("d-m-Y");?><br />
<strong>Cliente:</strong> 
<?php echo ObtenerNombreUsuario($row_DatosDatosConsulta['refUsuario']); ?>
<?php 
echo ObtenerAlellidosUsuario($row_DatosDatosConsulta['refUsuario']); ?>
<br />

<?php
// CALCULOS FACTURACIÓN //
echo "<strong>Precio/Día:</strong> ".$PrecioHabitacion." €"."&nbsp;&nbsp;&nbsp;<strong>Temporada:</strong> ".$Temporada;
echo 
"<br />";
echo 
"<strong>Sub Total:</strong> ".$SubTotal $PrecioHabitacion $dateDiffTotal." €";
echo 
"<br />";
$Impuesto $row_ConsultaHabitaciones['intValor_Impuesto']; 
$NombreImpuesto $row_ConsultaHabitaciones['strNombre_Impuesto'];
$Impuestos = (($Impuesto $SubTotal) / 100);
echo 
"<strong>".$Impuesto."% ".$NombreImpuesto.":</strong> ".$row_ConsultaPrecios['strNombreTemporada'].$Impuestos." €";
echo 
"<br />";
echo 
"<strong>Total:</strong> ".$Total $Impuestos $SubTotal." €";

?>
Un saludo y mil gracias: Manyblue
  #24 (permalink)  
Antiguo 15/01/2016, 08:24
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

Si quieres que quede como indicas debes tener SOLO una temporada. En caso de varias como lo quieres mostrar simplemente no es real porque se pueden seleccionar días de varias temporadas por tanto el precio por día varia.
En este caso no le puedes decir al cliente que el precio para, por ejemplo 6 días (3 baja y 3 alta) es el precio de alta porque lo engañas y tampoco baja porque pierdes dinero ... Primero debes definir bien el requerimiento. Si es una temporada (un único precio) o son varias. En caso de varias no puedes mostrar lo que indicas. (podrías hacerlo dividiendo el precio total por el numero de días - en mi ejemplo seria 69.98 € / 5 días).
  #25 (permalink)  
Antiguo 15/01/2016, 09:33
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Ya lo he cogido, eres un fenómeno así que muchísimas gracias por tus molestias.
El código quedaría así:
Código PHP:
<?php

$desde 
date('d/m'strtotime($_GET['FDesde']));
$hasta date('d/m'strtotime($_GET['FHasta']));
                                                       
$precioAlta $row_ConsultaHabitaciones['intPrecio_Alta']; 
$precioMedia $row_ConsultaHabitaciones['intPrecio_Media'];
$precioBaja $row_ConsultaHabitaciones['intPrecio_Baja']; 
$precioEspecial $row_ConsultaHabitaciones['intPrecio_Especial'];

class 
Temporadas {
 
    protected 
$temporadas = array(); 

 
    protected 
$acumulador 0.0;
 
    public function 
__construct($baja$media$alta$especial) {
        
$this->temporadas['baja']      = $baja;
        
$this->temporadas['media']     = $media;
        
$this->temporadas['alta']      = $alta;
        
$this->temporadas['especial']  = $especial;
    }
 
    protected function 
esTemporada($temporada$dia) {
        foreach(
$this->temporadas[$temporada] as $rango) {
            
$desde $this->getTime($rango[0]);
            
$hasta $this->getTime($rango[1]);
 
            if (
$dia >= $desde && $dia <= $hasta) {
                return 
true;
            }
        }
 
        return 
false;
    }
 
    public function 
esTemporadaBaja($dia) {
        return 
$this->esTemporada('baja'$dia);
    }
 
    public function 
esTemporadaMedia($dia) {
        return 
$this->esTemporada('media'$dia);
    }
 
    public function 
esTemporadaAlta($dia) {
        return 
$this->esTemporada('alta'$dia);
    }
 
    public function 
esEspecial($dia) {
        return 
$this->esTemporada('especial'$dia);
    }
 
    public function 
acumular($precio) {
        
$this->acumulador += floatval($precio);
    }
 
    public function 
precioTotal() {
        return 
$this->acumulador;
    }
 
    public function 
getTime($dia) {
        
// Cambia el orden para strtotime, es mm/dd/yyyy

        
list($dia$mes) = explode('/'$dia);
        return 
strtotime($mes '/' $dia '/' date('Y'));
    }
}
 
 
// Temporada Baja = 13/01 al 10/03  -  07/04 al 14/06  -  01/09 al 26/11

// Temporada Media =  11/03 al 26/03  -  15/06 al 31/07  -  27/11 al 14/12

// Temporada Alta = 27/03 al 06/04  -  01/08 al 31/08  -  01/08 al 31/08

$temporadaBaja = array(
    array(
'13/01''10/03'),
    array(
'07/04''14/06'),
    array(
'01/09''26/11'));

$temporadaMedia = array(
    array(
'11/03''26/03'),
    array(
'15/06''31/07'),
    array(
'27/11''14/12'));

$temporadaAlta = array(
    array(
'27/03''06/04'),
    array(
'01/08''31/08'),
    array(
'01/08''31/08'));

$especial = array(
    array(
'01/01''12/01'));
 
// Precios por temporada

$precioBaja     number_format(10.002) . ' €';
$precioMedia    number_format(15.502) . ' €';
$precioAlta     number_format(19.992) . ' €';
$precioEspecial number_format5.952) . ' €';
 
$helper = new Temporadas($temporadaBaja$temporadaMedia$temporadaAlta$especial);
 
// Fechas seleccionadas

$inicio $helper->getTime('30/08');
$final  $helper->getTime('04/09');
 
echo <<<TABLE
<table width="100%" border="1">

     <thead>
      <tr>
        <strong>Temporadas y Precios</strong>
      </tr>
    </thead>

    <tbody>
TABLE;
 
for (
$i $inicio$i $final$i += 60 60 24) {
    echo 
'<tr>';
 
    if (
$helper->esEspecial($i)) {
        
// Acumular precio

        
$helper->acumular($precioEspecial);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Precio Especial</td><td>$precioEspecial</td>";
 
    } else if (
$helper->esTemporadaAlta($i)) {
        
// Acumular precio

        
$helper->acumular($precioAlta);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Alta</td><td>$precioAlta</td>";
 
    } else if (
$helper->esTemporadaMedia($i)) {
        
// Acumular precio

        
$helper->acumular($precioMedia);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada Media</td><td>$precioMedia</td>";
 
    } else if (
$helper->esTemporadaBaja($i)) {
        
// Acumular precio

        
$helper->acumular($precioBaja);
        echo 
"<td>".date('d/m/Y',$i)."</td><td>Temporada baja</td><td>$precioBaja</td>";
 
    }
 
    echo 
'</tr>';
}
 
$total number_format($helper->precioTotal(), 2);
 
echo <<<ENDTABLE
    </tbody>
</table>
ENDTABLE;

// DIFERENCIA DE DIAS ENTRE Fdesde HASTA Fhasta //
$inicio strtotime($_GET['FDesde']);
$fin strtotime($_GET["FHasta"]);
$dateDiff $fin $inicio;
?>
<br />
<img src="imagenes/paypal.jpg">
<br /><br />
<strong>Reserva Habitación: Nº <?php echo $row_ConsultaHabitaciones['intNumero_Habitacion']; ?> de: <?php echo $row_DatosDatosConsulta['strNombre']; ?></strong>
<br />
<strong>Desde el:</strong> <?php if(isset($_GET['FDesde'])) echo $_GET['FDesde']; ?>&nbsp;&nbsp;<strong>Hasta el:</strong> <?php if(isset($_GET["FHasta"])) echo $_GET["FHasta"]; ?>
<br />

<?php
echo "<strong>Días Totales:</strong> ".($dateDiffTotal floor($dateDiff/(60*60*24))+1)." días";
echo 
"<br />"
?>
<strong>Fecha Factura:</strong> <?php echo date("d-m-Y");?><br />
<strong>Cliente:</strong> 
<?php echo ObtenerNombreUsuario($row_DatosDatosConsulta['refUsuario']); ?>
<?php 
echo ObtenerAlellidosUsuario($row_DatosDatosConsulta['refUsuario']); ?>
<br />

<?php
$Impuesto 
$row_ConsultaHabitaciones['intValor_Impuesto']; 
$NombreImpuesto $row_ConsultaHabitaciones['strNombre_Impuesto'];
$Impuestos = (($Impuesto $total) / 100);
echo 
"<strong>Sub Total:</strong> ".$total." €";
echo 
"<br />";
echo 
"<strong>".$Impuesto."% ".$NombreImpuesto.":</strong> ".$row_ConsultaPrecios['strNombreTemporada'].$Impuestos." €";
echo 
"<br />";
echo 
"<strong>Total:</strong> ".$Total $Impuestos $total." €";
?>
Ahora debo alimentar dinámicamente esto:
Código PHP:
$temporadaBaja = array(
    array(
'13/01''10/03'),
    array(
'07/04''14/06'),
    array(
'01/09''26/11'));

$temporadaMedia = array(
    array(
'11/03''26/03'),
    array(
'15/06''31/07'),
    array(
'27/11''14/12'));

$temporadaAlta = array(
    array(
'27/03''06/04'),
    array(
'01/08''31/08'),
    array(
'01/08''31/08'));

$especial = array(
    array(
'01/01''12/01')); 
y esto:
Código PHP:
$precioBaja     number_format(10.002) . ' €';
$precioMedia    number_format(15.502) . ' €';
$precioAlta     number_format(19.992) . ' €';
$precioEspecial number_format5.952) . ' €'
En relación a cada hotel (así un usuario que tenga suscritos 3 hoteles podrá decidir temporadas diferentes por hotel) por lo que debo crear una tabla tbl_temporadas_hoteles en la que esten los campos:
idTemporada
refHotel
precioBaja
precioMedia
precioAlta
precioEspecial
NombreTemporada
diaDesde
diaHasta
¿Que es lo que piensas?

Y otra cosa, ¿que sería esto?:
Código PHP:
// Fechas seleccionadas
$inicio $helper->getTime('30/08');
$final  $helper->getTime('04/09'); 
Un saludo: Armando
  #26 (permalink)  
Antiguo 16/01/2016, 02:01
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

He estado revisando tu código detenidamente y no va como debería, te explico:
He hecho una reserva Desde el: 18-01-2016 Hasta el: 20-01-2016, son 2 días en temporada baja, el precio de la habitación temporada baja que es la que le corresponde es 10.00 € teoricamente tu $total debería ser la media de precio temporada pòr los días de reserva mi SUBTOTAL deberia ser tu $total pero no es así.
En el ejemplo con tu códogo mira lo que da:
Reserva Habitación: Nº 1 de: Hotel El Galeon
Desde el: 18-01-2016 Hasta el: 20-01-2016
Días Totales: 2 días
Fecha Factura: 16-01-2016
Cliente: pepe Flores
SUB TOTAL: 270.00 €

17.00% IGIC: 45.90 €
TOTAL: 315.90 €
No es
Inadmisible pues es erroneo, no se que es lo que hace tu código pues no comprendo bien todavía las clases de php.
El resultado debería ser este:
Reserva Habitación: Nº 1 de: Hotel El Galeon
Desde el: 18-01-2016 Hasta el: 20-01-2016
Días Totales: 2 días
Fecha Factura: 16-01-2016
Cliente: Pepe Flores
SUB TOTAL: 20.00 €
17.00% IGIC: 3.4 €
TOTAL: 23.4 €

Dime algo ??
Hecho con tu código que está encima de este post.
Michísimas gracias por tus molestias: Manyblue

Última edición por manyblue; 16/01/2016 a las 02:09
  #27 (permalink)  
Antiguo 16/01/2016, 06:39
 
Fecha de Ingreso: enero-2016
Mensajes: 71
Antigüedad: 8 años, 3 meses
Puntos: 14
Respuesta: Organizar Precios y Temporadas

Que es lo que no funciona?

Estas son las fechas seleccionadas por el cliente.
Código PHP:
Ver original
  1. // Fechas seleccionadas
  2. $inicio = $helper->getTime('30/08');
  3. $final  = $helper->getTime('04/09');

Pon aquí el inicio a 18/01 y el final a 20/01
Código PHP:
Ver original
  1. // Fechas seleccionadas
  2. $inicio = $helper->getTime('18/01');
  3. $final  = $helper->getTime('20/01');
Esto te da el subtotal de 20 ...

Me da que siempre te sale 270 sin importar lo que seleccionas ...
  #28 (permalink)  
Antiguo 17/01/2016, 04:06
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Vamos a terminarlo de pulir pues hay datos que son dinámicos y no estáticos OK.

1) Tu código me queda así:
Código PHP:
<?php
                                                      
$desde 
date('d/m'strtotime($_GET['FDesde']));
$hasta date('d/m'strtotime($_GET['FHasta']));
                                                       
//$precioAlta = $row_ConsultaHabitaciones['intPrecio_Alta']; 
//$precioMedia = $row_ConsultaHabitaciones['intPrecio_Media'];
//$precioBaja = $row_ConsultaHabitaciones['intPrecio_Baja']; 
//$precioEspecial = $row_ConsultaHabitaciones['intPrecio_Especial'];

class Temporadas {
 
    protected 
$temporadas = array(); 

 
    protected 
$acumulador 0.0;
 
    public function 
__construct($baja$media$alta$especial) {
        
$this->temporadas['baja']      = $baja;
        
$this->temporadas['media']     = $media;
        
$this->temporadas['alta']      = $alta;
        
$this->temporadas['especial']  = $especial;
    }
 
    protected function 
esTemporada($temporada$dia) {
        foreach(
$this->temporadas[$temporada] as $rango) {
            
$desde $this->getTime($rango[0]);
            
$hasta $this->getTime($rango[1]);
 
            if (
$dia >= $desde && $dia <= $hasta) {
                return 
true;
            }
        }
 
        return 
false;
    }
 
    public function 
esTemporadaBaja($dia) {
        return 
$this->esTemporada('baja'$dia);
    }
 
    public function 
esTemporadaMedia($dia) {
        return 
$this->esTemporada('media'$dia);
    }
 
    public function 
esTemporadaAlta($dia) {
        return 
$this->esTemporada('alta'$dia);
    }
 
    public function 
esEspecial($dia) {
        return 
$this->esTemporada('especial'$dia);
    }
 
    public function 
acumular($precio) {
        
$this->acumulador += floatval($precio);
    }
 
    public function 
precioTotal() {
        return 
$this->acumulador;
    }
 
    public function 
getTime($dia) {
        
// Cambia el orden para strtotime, es mm/dd/yyyy

        
list($dia$mes) = explode('/'$dia);
        return 
strtotime($mes '/' $dia '/' date('Y'));
    }
}
 
 
// Temporada Baja = 13/01 al 10/03  -  07/04 al 14/06  -  01/09 al 26/11

// Temporada Media =  11/03 al 26/03  -  15/06 al 31/07  -  27/11 al 14/12

// Temporada Alta = 27/03 al 06/04  -  01/08 al 31/08  -  01/08 al 31/08

$temporadaBaja = array(
    array(
'13/01''10/03'),
    array(
'07/04''14/06'),
    array(
'01/09''26/11'));

$temporadaMedia = array(
    array(
'11/03''26/03'),
    array(
'15/06''31/07'),
    array(
'27/11''14/12'));

$temporadaAlta = array(
    array(
'27/03''06/04'),
    array(
'01/08''31/08'),
    array(
'01/08''31/08'));

$especial = array(
    array(
'01/01''12/01'));
 
// Precios por temporada

$precioBaja     number_format($row_ConsultaHabitaciones['intPrecio_Baja'], 2) . ' €';
$precioMedia    number_format($row_ConsultaHabitaciones['intPrecio_Media'], 2) . ' €';
$precioAlta     number_format($row_ConsultaHabitaciones['intPrecio_Alta'], 2) . ' €';
$precioEspecial number_format($row_ConsultaHabitaciones['intPrecio_Especial'], 2) . ' €';
 
$helper = new Temporadas($temporadaBaja$temporadaMedia$temporadaAlta$especial);
 
// Fechas seleccionadas

$inicio $helper->getTime($desde);
$final  $helper->getTime($hasta);
 
 
for (
$i $inicio$i $final$i += 60 60 24) {
  
 
    if (
$helper->esEspecial($i)) {
        
// Acumular precio

        
$helper->acumular($precioEspecial);
         
"<td>".date('d/m/Y',$i)."</td><td>Precio Especial</td><td>$precioEspecial</td>";
 
    } else if (
$helper->esTemporadaAlta($i)) {
        
// Acumular precio

        
$helper->acumular($precioAlta);
         
"<td>".date('d/m/Y',$i)."</td><td>Temporada Alta</td><td>$precioAlta</td>";
 
    } else if (
$helper->esTemporadaMedia($i)) {
        
// Acumular precio

        
$helper->acumular($precioMedia);
         
"<td>".date('d/m/Y',$i)."</td><td>Temporada Media</td><td>$precioMedia</td>";
 
    } else if (
$helper->esTemporadaBaja($i)) {
        
// Acumular precio

        
$helper->acumular($precioBaja);
         
"<td>".date('d/m/Y',$i)."</td><td>Temporada baja</td><td>$precioBaja</td>";
 
    }
 
    
}
 
$total number_format($helper->precioTotal(), 2);
 


// DIFERENCIA DE DIAS ENTRE Fdesde HASTA Fhasta //
$inicio strtotime($_GET['FDesde']);
$fin strtotime($_GET["FHasta"]);
$dateDiff $fin $inicio;
?>

<img src="imagenes/paypal.jpg">
<br /><br />
<strong>Reserva Habitación: Nº <?php echo $row_ConsultaHabitaciones['intNumero_Habitacion']; ?> de: <?php echo $row_DatosDatosConsulta['strNombre']; ?></strong>
<br />
<strong>Desde el:</strong> <?php if(isset($_GET['FDesde'])) echo $_GET['FDesde']; ?>&nbsp;&nbsp;<strong>Hasta el:</strong> <?php if(isset($_GET["FHasta"])) echo $_GET["FHasta"]; ?>
<br />

<?php
echo "<strong>Días Totales:</strong> ".($dateDiffTotal floor($dateDiff/(60*60*24)))." días";
echo 
"<br />"
?>
<strong>Fecha Factura:</strong> <?php echo date("d-m-Y");?><br />
<strong>Cliente:</strong> 
<?php echo ObtenerNombreUsuario($row_DatosDatosConsulta['refUsuario']); ?>
<?php 
echo ObtenerAlellidosUsuario($row_DatosDatosConsulta['refUsuario']); ?>
<br />

<?php
$Impuesto 
$row_ConsultaHabitaciones['intValor_Impuesto'];
$NombreImpuesto $row_ConsultaHabitaciones['strNombre_Impuesto'];
$Impuestos = (($Impuesto $total) / 100);
echo 
"<strong>SUB TOTAL:</strong> ".$total." €";
echo 
"<br />";
echo 
"<strong>".$Impuesto."% ".$NombreImpuesto.":</strong> ".number_format($Impuestos2)." €";
echo 
"<br />";
echo 
"<strong>TOTAL:</strong> ".number_format($Total $Impuestos $total2)." €";
?>
2) Resultado del código anterior:
Reserva Habitación: Nº 1 de: Hotel El Galeon
Desde el: 18-01-2016 Hasta el: 20-01-2016
Días Totales: 2 días
Fecha Factura: 17-01-2016
Cliente: Manyblue
SUB TOTAL: 80.00 €
17% IGIC: 13.60 €
TOTAL: 93.60 €
3) Los días seleccionados:
Corresponden todos a temporada baja y el $precioBaja = $row_ConsultaHabitaciones['intPrecio_Baja'] = 30 €
4) Resultado que debería dar:
mi SUBTOTAL = tu $total deberia ser 60 € no 80 €
5) Resultado debería ser esto:
Reserva Habitación: Nº 1 de: Hotel El Galeon
Desde el: 18-01-2016 Hasta el: 20-01-2016
Días Totales: 2 días
Fecha Factura: 17-01-2016
Cliente: Manyblue
SUB TOTAL: 60.00 €
17% IGIC: 7.8 €
TOTAL: 67.8 €
Que te parece ?? es lo que te quería decir, los cálculos parecen no ser correctos.
Muchísimas gracias por tus aportes y un saludo: Manyblue

Última edición por manyblue; 17/01/2016 a las 04:45
  #29 (permalink)  
Antiguo 17/01/2016, 07:12
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

Vamos acabando jajajajajaja.
En primer lugar, x_atrix, muchísimas gracias por tu aporte, inestimable para mi.
Ya me funciona ben tu código, todo perfecto creo.
Que he hecho:
1) He creado dos tablas:
tbl_hoteles
Código PHP:
CREATE TABLE IF NOT EXISTS `tbl_hotel` (
  `
idHotelint(11NOT NULL AUTO_INCREMENT,
  `
refUsuarioint(11) DEFAULT NULL,
  `
strNombrevarchar(150) DEFAULT NULL,
  `
strNombreCEOvarchar(150) DEFAULT NULL,
  `
strNombre_Empresavarchar(150) DEFAULT NULL,
  `
strNIF_CIFvarchar(50) DEFAULT NULL,
  `
intEstadoint(2) DEFAULT NULL,
  `
intCategoriaint(3) DEFAULT NULL,
  `
strDireccionvarchar(100) DEFAULT NULL,
  `
strPoblacionvarchar(100) DEFAULT NULL,
  `
idProvinciaint(5) DEFAULT NULL,
  `
strEstadoPaisExtrangerovarchar(250) DEFAULT NULL,
  `
intCodigo_Postalint(8) DEFAULT NULL,
  `
strPaisvarchar(100) DEFAULT NULL,
  `
strtDescripciontext,
  `
strResumentext,
  `
strResumen_ingtext,
  `
strResumen_aletext,
  `
strResumen_fratext,
  `
strResumen_holtext,
  `
strDescripcion_ingtext,
  `
strDescripcion_aletext,
  `
strDescripcion_fratext,
  `
strDescripcion_holtext,
  `
dblLatituddouble DEFAULT NULL,
  `
dblLongituddouble DEFAULT NULL,
  `
intNumero_Habitacionesint(11) DEFAULT NULL,
  `
strEmailvarchar(150) DEFAULT NULL,
  `
strTelefonovarchar(50) DEFAULT NULL,
  `
strFaxvarchar(50) DEFAULT NULL,
  `
strMovilvarchar(50) DEFAULT NULL,
  `
intWifiint(2) DEFAULT NULL,
  `
intRestauranteint(2) DEFAULT NULL,
  `
intCafeteriaint(2) DEFAULT NULL,
  `
intGarajeint(2) DEFAULT NULL,
  `
intJardinesint(11) DEFAULT NULL,
  `
strInstalaciones_Deportivasint(2) DEFAULT NULL,
  `
intPiscinaExteriorint(2) DEFAULT NULL,
  `
intPiscinaInteriorint(2) DEFAULT NULL,
  `
intAnimalesCompaniaint(2) DEFAULT NULL,
  `
intServicioDiscrecionalint(2) DEFAULT NULL,
  `
intSpaint(2) DEFAULT NULL,
  `
Fecha_Alta_Hoteldatetime DEFAULT NULL,
  `
Fecha_Modificacion_Hoteltimestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  
PRIMARY KEY (`idHotel`)
ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=
tbl_habitaciones_hotel
Código PHP:
CREATE TABLE IF NOT EXISTS `tbl_habitaciones_hotel` (
  `
id_Habitacionint(11NOT NULL AUTO_INCREMENT,
  `
refHotelint(11) DEFAULT NULL,
  `
refImagenesint(11) DEFAULT NULL,
  `
refTipo_Habitacionint(11) DEFAULT NULL,
  `
refUsuarioint(11) DEFAULT NULL,
  `
intNumero_Habitacionint(11) DEFAULT NULL,
  `
intEstadoint(2) DEFAULT NULL,
  `
intAdultosint(2) DEFAULT NULL,
  `
intNinosint(2) DEFAULT NULL,
  `
intBebesint(2) DEFAULT NULL,
  `
intPrecio_Especialdouble DEFAULT NULL,
  `
intPrecio_Altadouble DEFAULT NULL,
  `
intPrecio_Mediadouble DEFAULT NULL,
  `
intPrecio_Bajadouble DEFAULT NULL,
  `
strNombre_Impuestovarchar(100) DEFAULT NULL,
  `
intValor_Impuestoint(3) DEFAULT NULL,
  `
strDescuentovarchar(50) DEFAULT NULL,
  `
intDescuento_Estadoint(2) DEFAULT NULL,
  `
intPromocionint(2) DEFAULT NULL,
  `
strPromocion_Contenidotext,
  `
Fecha_Alta_habitaciontimestamp NULL DEFAULT NULL,
  `
Fecha_Modificacion_Habitaciontimestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  `
strDescripciontext,
  `
strDescripcion_ingtext,
  `
strDescripcion_aletext,
  `
strDescripcion_fratext,
  `
strDescripcion_holtext,
  `
intTDTint(2) DEFAULT NULL,
  `
intTV_Satint(2) DEFAULT NULL,
  `
intTelefonoint(2) DEFAULT NULL,
  `
intInternet_Cableint(2) DEFAULT NULL,
  `
intWifiint(2) DEFAULT NULL,
  `
intNeveraint(2) DEFAULT NULL,
  `
intCaja_Fuerteint(2NOT NULL,
  `
intBaneraint(2) DEFAULT NULL,
  `
intJacuzziint(2) DEFAULT NULL,
  `
intSecador_Peloint(2) DEFAULT NULL,
  `
intAire_Acondicionadoint(2) DEFAULT NULL,
  `
intMicroondasint(2) DEFAULT NULL,
  `
intCocinaint(2) DEFAULT NULL,
  `
intLavadoraint(2) DEFAULT NULL,
  `
intServicio_habitacionesint(2) DEFAULT NULL,
  `
intMenage_Cocinaint(2) DEFAULT NULL,
  `
intCuna_Bebeint(2) DEFAULT NULL,
  `
intBalconint(2) DEFAULT NULL,
  `
intInsonorizacionint(2) DEFAULT NULL,
  `
intPlancha_Tablaint(2) DEFAULT NULL,
  `
intClimatizacionint(2) DEFAULT NULL,
  `
intBideint(2) DEFAULT NULL,
  `
intHilo_musicalint(2) DEFAULT NULL,
  `
intMaximo_Personasint(2) DEFAULT NULL,
  `
intVista_Marint(2) DEFAULT NULL,
  `
intVista_Montanaint(2) DEFAULT NULL,
  `
intVista_Ciudadint(2) DEFAULT NULL,
  `
intVista_Panoramicaint(2) DEFAULT NULL,
  `
intAdmite_Mascotasint(2) DEFAULT NULL,
  
PRIMARY KEY (`id_Habitacion`)
ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=
Sigue debajo .........
Un saludo: Manyblue
  #30 (permalink)  
Antiguo 17/01/2016, 07:14
Avatar de manyblue  
Fecha de Ingreso: marzo-2008
Mensajes: 329
Antigüedad: 16 años, 1 mes
Puntos: 10
Respuesta: Organizar Precios y Temporadas

El código quedaría en principio así:
Código PHP:
<?php
                                                      
$desde 
date('d/m'strtotime($_GET['FDesde']));
$hasta date('d/m'strtotime($_GET['FHasta']));
                                                       
//$precioAlta = $row_ConsultaHabitaciones['intPrecio_Alta']; 
//$precioMedia = $row_ConsultaHabitaciones['intPrecio_Media'];
//$precioBaja = $row_ConsultaHabitaciones['intPrecio_Baja']; 
//$precioEspecial = $row_ConsultaHabitaciones['intPrecio_Especial'];

class Temporadas {
 
    protected 
$temporadas = array(); 

 
    protected 
$acumulador 0.0;
 
    public function 
__construct($baja$media$alta$especial) {
        
$this->temporadas['baja']      = $baja;
        
$this->temporadas['media']     = $media;
        
$this->temporadas['alta']      = $alta;
        
$this->temporadas['especial']  = $especial;
    }
 
    protected function 
esTemporada($temporada$dia) {
        foreach(
$this->temporadas[$temporada] as $rango) {
            
$desde $this->getTime($rango[0]);
            
$hasta $this->getTime($rango[1]);
 
            if (
$dia >= $desde && $dia <= $hasta) {
                return 
true;
            }
        }
 
        return 
false;
    }
 
    public function 
esTemporadaBaja($dia) {
        return 
$this->esTemporada('baja'$dia);
    }
 
    public function 
esTemporadaMedia($dia) {
        return 
$this->esTemporada('media'$dia);
    }
 
    public function 
esTemporadaAlta($dia) {
        return 
$this->esTemporada('alta'$dia);
    }
 
    public function 
esEspecial($dia) {
        return 
$this->esTemporada('especial'$dia);
    }
 
    public function 
acumular($precio) {
        
$this->acumulador += floatval($precio);
    }
 
    public function 
precioTotal() {
        return 
$this->acumulador;
    }
 
    public function 
getTime($dia) {
        
// Cambia el orden para strtotime, es mm/dd/yyyy

        
list($dia$mes) = explode('/'$dia);
        return 
strtotime($mes '/' $dia '/' date('Y'));
    }
}
 
 
// Temporada Baja = 13/01 al 10/03  -  07/04 al 14/06  -  01/09 al 26/11

// Temporada Media =  11/03 al 26/03  -  15/06 al 31/07  -  27/11 al 14/12

// Temporada Alta = 27/03 al 06/04  -  01/08 al 31/08  -  01/08 al 31/08

$temporadaBaja = array(
    array(
'13/01''10/03'),
    array(
'07/04''14/06'),
    array(
'01/09''26/11'));

$temporadaMedia = array(
    array(
'11/03''26/03'),
    array(
'15/06''31/07'),
    array(
'27/11''14/12'));

$temporadaAlta = array(
    array(
'27/03''06/04'),
    array(
'01/08''31/08'),
    array(
'01/08''31/08'));

$especial = array(
    array(
'01/01''12/01'));
 
// Precios por temporada

$precioBaja     number_format($row_ConsultaHabitaciones['intPrecio_Baja'], 2) . ' €';
$precioMedia    number_format($row_ConsultaHabitaciones['intPrecio_Media'], 2) . ' €';
$precioAlta     number_format($row_ConsultaHabitaciones['intPrecio_Alta'], 2) . ' €';
$precioEspecial number_format($row_ConsultaHabitaciones['intPrecio_Especial'], 2) . ' €';
 
$helper = new Temporadas($temporadaBaja$temporadaMedia$temporadaAlta$especial);
 
// Fechas seleccionadas

$inicio $helper->getTime($desde);
$final  $helper->getTime($hasta);
 
 
for (
$i $inicio$i $final$i += 60 60 24) {
  
 
    if (
$helper->esEspecial($i)) {
        
// Acumular precio

        
$helper->acumular($precioEspecial);
         
"<td>".date('d/m/Y',$i)."</td><td>Precio Especial</td><td>$precioEspecial</td>";
 
    } else if (
$helper->esTemporadaAlta($i)) {
        
// Acumular precio

        
$helper->acumular($precioAlta);
         
"<td>".date('d/m/Y',$i)."</td><td>Temporada Alta</td><td>$precioAlta</td>";
 
    } else if (
$helper->esTemporadaMedia($i)) {
        
// Acumular precio

        
$helper->acumular($precioMedia);
         
"<td>".date('d/m/Y',$i)."</td><td>Temporada Media</td><td>$precioMedia</td>";
 
    } else if (
$helper->esTemporadaBaja($i)) {
        
// Acumular precio

        
$helper->acumular($precioBaja);
         
"<td>".date('d/m/Y',$i)."</td><td>Temporada baja</td><td>$precioBaja</td>";
 
    }
 
    
}
 
$total number_format($helper->precioTotal(), 2);
 


// DIFERENCIA DE DIAS ENTRE Fdesde HASTA Fhasta //
$inicio strtotime($_GET['FDesde']);
$fin strtotime($_GET["FHasta"]);
$dateDiff $fin $inicio;
?>
<img src="imagenes/paypal.jpg">
<br /><br />
<strong>Reserva Habitación: Nº <?php echo $row_ConsultaHabitaciones['intNumero_Habitacion']; ?> de: <?php echo $row_DatosDatosConsulta['strNombre']; ?></strong>
<br />
<strong>Desde el:</strong> <?php if(isset($_GET['FDesde'])) echo $_GET['FDesde']; ?>&nbsp;&nbsp;<strong>Hasta el:</strong> <?php if(isset($_GET["FHasta"])) echo $_GET["FHasta"]; ?>
<br />

<?php
echo "<strong>Días Totales:</strong> ".($dateDiffTotal floor($dateDiff/(60*60*24)))." días";
echo 
"<br />"
?>
<strong>Fecha Factura:</strong> <?php echo date("d-m-Y");?><br />
<strong>Cliente:</strong> 
<?php echo ObtenerNombreUsuario($row_DatosDatosConsulta['refUsuario']); ?>
<?php 
echo ObtenerAlellidosUsuario($row_DatosDatosConsulta['refUsuario']); ?>
<br />

<?php
$Impuesto 
$row_ConsultaHabitaciones['intValor_Impuesto'];
$NombreImpuesto $row_ConsultaHabitaciones['strNombre_Impuesto'];
$Impuestos = (($Impuesto $total) / 100);
echo 
"<strong>SUB TOTAL:</strong> ".$total." €";
echo 
"<br />";
echo 
"<strong>".$Impuesto."% ".$NombreImpuesto.":</strong> ".number_format($Impuestos2)." €";
echo 
"<br />";
echo 
"<strong>TOTAL:</strong> ".number_format($Total $Impuestos $total2)." €";
?>
sigue debajo .........
Un saludo: Manyblue

Etiquetas: organizar, precios
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:43.