<?php

  $Position = "../../";
  require_once($Position.'config/config.php');
  require_once($Position.'config/conexion.php');
  $Pagina   = 2;
  $Menu     = 3;

  //Propiedad
  $Query = "
    SELECT
      pro.Id,
      pro.Fk_Desarrollo, pro.Nombre, pro.Ubicacion,
      pro.TextoBoton, pro.Descripcion, pro.Mapa, pro.Activo,
      pro.Recamaras, pro.Banos, pro.Estacionamientos,
      pro.Terreno, pro.Construccion,
      pro.Precio,
      tip.Tipo,
      est.Nombre AS Estado
    FROM Propiedades pro
    LEFT JOIN Estados est ON est.Id = pro.Fk_Estado
    LEFT JOIN PropiedadesTipos tip ON tip.Id = pro.Fk_Tipo
    WHERE pro.Id = '$_GET[Id]'
  ";
  $Result = mysqli_query($mysqli, $Query);
  $Prop = mysqli_fetch_assoc($Result);

?>
<!doctype html>
<html lang="en">
  <?php require_once($Position.'head.php'); ?>
  <!--<body class="pace-on pace-squares">-->
  <body>
    <!--<div class="pace-overlay"></div>-->
    <?php require_once($Position.'header.php'); ?>

    <!-- Titulo -->
    <div
      class="section"
      style="
        background: #333;
        color: #fff;
      "
    >
      <div class="section-content">
        <div class="container">
          <div class="row p-top-30 p-bottom-10">

            <div class="col-sm-12 SubTitle">
              <div class="row">
                <div class="col-sm-8">
                  <h2 class="ProTitle m-bottom-10" style="color:#fff;"><?php echo $Prop[Nombre]; ?></h2>
                  <h3 class="ProSubTitle" style="color:#fff;">
                    <i class="fa fa-map-marker" style="margin-right:10px;"></i>
                    <?php echo $Prop[Ubicacion]; ?>
                    <?php
                    if( $Prop[Estado] ){
                      echo ", ".$Prop[Estado];
                    }
                    ?>
                  </h3>
                </div>
                <div class="col-sm-4 text-right">
                  <?php if( $Prop[Precio] ){ ?>
                    <h3
                      style="color:#fff; font-size: 1.3em;"
                    >
                      <?php echo $Prop[Tipo]; ?>
                      <br>
                      <strong>
                        <?php echo $Prop[Precio]; ?>
                      </strong>
                    </h3>
                  <?php } ?>
                </div>
              </div>
            </div>

          </div>
        </div>
      </div>
    </div>
    <!-- End Titulo -->

    <!-- Galeria -->
    <div
      class="section p-bottom-40"
      style="background: #eee;"
    >
      <div class="section-content">
        <div class="container">
          <div class="row">
            <div class="col-sm-12">
              <div class="card-img-container">
                  <div id="carousel-card-1" class="carousel slide" data-ride="carousel">
                    <div class="carousel-inner" role="listbox">
                      <?php
                        //Images
                        $Query = "
                          SELECT
                            img.Id, img.Nombre
                          FROM PropiedadesGaleria img
                          WHERE img.Fk_Propiedad = '$Prop[Id]'
                          ORDER BY img.Orden ASC
                        ";
                        $Images = $mysqli->query($Query);
                        mysqli_data_seek($Images, 0);
                        $Cont = 0;
                        while($Img = mysqli_fetch_array($Images)) {
                          $Cont++;
                      ?>
                        <div class="carousel-item <?php if( $Cont == 1 ){ echo "active"; } ?>">
                          <img class="card-img" src="<?php echo $Position; ?>images/propiedades/galeria/<?php echo $Img[Id]; ?>.jpg" alt="Card image">
                        </div>
                      <?php } ?>
                    </div>

                    <ol class="carousel-indicators">
                      <?php
                        mysqli_data_seek($Images, 0);
                        $Cont = -1;
                        while($Img = mysqli_fetch_array($Images)) {
                          $Cont++;
                      ?>
                        <li
                          data-target="#carousel-card-1" data-slide-to="<?php echo $Cont; ?>"
                          <?php if( $Cont == 0 ){ ?>
                            class="active"
                          <?php } ?>
                          style="
                            background-image: url('<?php echo $Position; ?>images/propiedades/galeria/<?php echo $Img[Id]; ?>.jpg');
                          "
                        >
                        </li>
                      <?php } ?>
                    </ol>

                  </div>
                  <a class="left carousel-control" href="#carousel-card-1" role="button" data-slide="prev">
                    <span class="icon-prev" aria-hidden="true"></span>
                    <span class="sr-only">Previous</span>
                  </a>
                  <a class="right carousel-control" href="#carousel-card-1" role="button" data-slide="next">
                    <span class="icon-next" aria-hidden="true"></span>
                    <span class="sr-only">Next</span>
                  </a>
              </div>
            </div>

          </div>
        </div>
      </div>
    </div>
    <!-- End Galeria -->

    <!-- Card Caracteristicas -->
    <section
      style="
        background:#eee;
        display: table;
        width: 100%;
      "
    >
      <div class="container">
        <div class="card Card-Caracteristicas">
          <div class="card-body">
            <div class="row">

              <?php if( $Prop[Precio] ){ ?>
                <!-- Precio -->
                <div class="col-sm-3 text-center Card-Ca-In">
                  <div>
                    <h4>
                      <?php echo $Prop[Precio]; ?>
                    </h4>
                    <p>
                      <?php echo $Prop[Tipo]; ?>
                    </p>
                  </div>
                </div>
                <!-- End Precio -->
              <?php } ?>

              <?php if( $Prop[Recamaras] ){ ?>
                <!-- Recamaras -->
                <div class="col-sm-3 text-center Card-Ca-In">
                    <div>
                    <h4>
                      <i class="fa fa-bed"></i>
                    </h4>
                    <p>
                      <?php echo $Prop[Recamaras]; ?>
                    </p>
                  </div>
                </div>
                <!-- End Recamaras -->
              <?php } ?>

              <?php if( $Prop[Banos] ){ ?>
                <!-- Banos -->
                <div class="col-sm-3 text-center Card-Ca-In">
                  <div>
                    <h4>
                      <i class="fa fa-bath"></i>
                    </h4>
                    <p>
                      <?php echo $Prop[Banos]; ?>
                    </p>
                  </div>
                </div>
                <!-- End Banos -->
              <?php } ?>

              <?php if( $Prop[Estacionamientos] ){ ?>
                <!-- Estacionamientos -->
                <div class="col-sm-3 text-center Card-Ca-In">
                  <div>
                    <h4>
                      <i class="fa fa-car"></i>
                    </h4>
                    <p>
                      <?php echo $Prop[Estacionamientos]; ?>
                    </p>
                  </div>
                </div>
                <!-- End Estacionamientos -->
              <?php } ?>

              <?php if( $Prop[Precio] ){ ?>
                <!-- Construccion -->
                <div class="col-sm-3 text-center Card-Ca-In">
                  <div>
                    <h4>
                      <?php echo $Prop[Construccion]; ?>
                    </h4>
                    <p>
                      de construcción
                    </p>
                  </div>
                </div>
                <!-- End Construccion -->
              <?php } ?>

              <?php if( $Prop[Terreno] ){ ?>
                <!-- Terreno -->
                <div class="col-sm-3 text-center Card-Ca-In">
                  <div>
                    <h4>
                      <?php echo $Prop[Terreno]; ?>
                    </h4>
                    <p>
                      de terreno
                    </p>
                  </div>
                </div>
                <!-- End Terreno -->
              <?php } ?>

            </div>
          </div>
        </div>
      </div>
    </section>
    <!-- End Card Caracteristicas -->

    <!-- Icons -->
    <div class="section">
      <div class="section-content"
        style="
          background: #eee;
          background-size: cover;
          background-position: center;
          padding: .5em 0px;
        "
      >
        <div class="container">
          <div class="row">
            <div class="col-sm-12">
              <div class="card">
                <div class="card-body">
                  <div class="row">
                    <?php
                      $Query = "
                        SELECT
                          ite.Id, ite.Fk_Item, ite.Texto
                        FROM PorpiedadesItems ite
                        WHERE ite.Fk_Propiedad = '$Prop[Id]'
                        ORDER BY ite.Orden ASC
                      ";
                      $Items = $mysqli->query($Query);
                      mysqli_data_seek($Items, 0);
                      while($Item = mysqli_fetch_array($Items)) {
                    ?>
                      <!-- Icon -->
                      <div
                        class="col-sm-4"
                        style="margin-bottom: .25em;"
                      >
                        <p>
                          <i class="fa fa-check" style="margin-rigth:5px;"></i>
                          <?php echo $Item[Texto]; ?>
                        </p>
                      </div>
                      <!-- End Icon -->
                    <?php } ?>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- Icons -->

    <!-- Description -->
    <div class="section m-top-80">
      <div class="section-conten">
        <div class="container">
          <div class="row">
            <div class="col-sm-12" style="margin-bottom:40px;">
              <h3>
                Descripción
              </h3>
              <p><?php echo $Prop[Descripcion]; ?></p>
            </div>

            <?php if( $Prop[Mapa] ){ ?>
              <!-- Mapa -->
              <div class="col-sm-12">
                <div>
                  <h3>
                    Mapa
                  </h3>
                </div>
                <?php echo $Prop[Mapa]; ?>
              </div>
              <!-- End Mapa -->
            <?php } ?>

          </div>
        </div>
      </div>
    </div>
    <!-- End Description -->

    <!-- Contacto -->
    <div
      class="section p-top-80 p-bottom-60"
      style="
        background-color: #222222;
      "
    >
      <div class="section-conten">
        <div class="container">
          <div class="row">
            <div class="col-sm-12 text-center">

              <h3 style="color:#fff;">¿Necesitas más información?</h3>

              <!-- Btn Contacto -->
              <a href="<?php echo $Url; ?>/contacto">
                <button class="btn btn-lg btn-success" type="button">
                  Contáctanos
                </button>
              </a>
              <!-- End Btn Contacto -->

            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- Contacto -->

    <?php require_once($Position.'footer.php'); ?>
    <?php require_once($Position.'scripts.php'); ?>
  </body>
</html>
