<?php

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

  $Query = "
    SELECT
      pro.Id,
      pro.Fk_Desarrollo, pro.Nombre, pro.Ubicacion,
      pro.TextoBoton, pro.Descripcion, pro.Mapa, pro.Activo,
      des.Nombre AS Desarrollo
    FROM Propiedades pro
    LEFT JOIN Desarrollos des ON des.Id = pro.Fk_Desarrollo
    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: #423978;
        color: #fff;
      "
    >
      <div class="section-content">
        <div class="container">
          <div class="row p-top-30 p-bottom-10">

            <!-- <div class="col-sm-12 SecTitle">
              <h1 class="m-bottom-5" style="color:#fff;"><?php echo $Prop[Desarrollo]; ?></h1>
            </div> -->

            <div class="col-sm-12 SubTitle">
              <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]; ?>
              </h3>
            </div>

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

    <!-- Galeria -->
    <div class="section p-bottom-80">
      <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>
                  </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 class="m-top-20 col-sm-12">
              <div class="row">
                <?php
                  mysqli_data_seek($Images, 0);
                  while($Img = mysqli_fetch_array($Images)) {
                ?>
                  <!-- Img -->
                  <div class="col-sm-3">
                    <img class="W100 m-bottom-20" src="<?php echo $Position; ?>images/propiedades/galeria/<?php echo $Img[Id]; ?>.jpg" />
                  </div>
                  <!-- Img -->
                <?php } ?>
              </div>
            </div>

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

    <!-- Icons -->
    <div class="section">
      <div class="section-content"
        style="
          /* background-image:url('<?php echo $Position; ?>assets/images/bgs/1.jpg'); */
          background: #423978;
          background-size: cover;
          background-position: center;
          padding: 40px 0px;
        "
      >
        <div class="container">
          <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-nu-8 ItemIcons">
                <div class="IconBox">
                  <img class="W100" src="<?php echo $Position; ?>images/icons/<?php echo $Item[Fk_Item]; ?>.png" />
                </div>
                <h4><?php echo $Item[Texto]; ?></h4>
              </div>
              <!-- End Icon -->
            <?php } ?>

          </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;">
              <h4 style="color: #423978; font-size: 25px;">
                Descripción
              </h4>
              <p><?php echo $Prop[Descripcion]; ?></p>
            </div>

            <?php if( $Prop[Mapa] ){ ?>
              <!-- Mapa -->
              <div class="col-sm-12">
                <div>
                  <h4 style="color: #423978; font-size: 25px;">
                    Mapa
                  </h4>
                </div>
                <?php echo $Prop[Mapa]; ?>
              </div>
              <!-- End Mapa -->
            <?php } ?>

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

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