<?php

  $Seccion      = 'Acerca';
  $SubSeccion   = 'Acerca';
  $NameSec      = 'Acerca';
  $Position     = '../../';
  $UrlImgs      = 'images/banners';
  $Pagina       = '2';
  $SecLine      = array('Nosotros');

  require_once($Position.'config/config.php');
  require_once($Position.'config/conexion.php');
  require_once($Position.'config/user.php');
  require_once($Position.'funciones/acces.php');
  require_once($Position.'funciones/logout.php');
  require_once($Position.'funciones/funciones.php');
  require_once($Position.'funciones/resize-class.php');

  $Hoy      = date('Y-m-d');
  $HoyFecha = CambioFechaInversa($Hoy);

  if( $_POST['Save'] == 'Ok' ){
    //Datos de formulario
    $ImgNew             = $_POST['ImgNew'];
    $Fk_Pagina          = $_POST['Fk_Pagina'];
    $TextHorizontal     = $_POST['TextHorizontal'];
    $TextVetical        = $_POST['TextVetical'];

    $Title                = addslashes($_POST['Title']);
    $TitleFk_Font         = $_POST['TitleFk_Font'];
    $TitleSize            = $_POST['TitleSize'];
    $TitleLineHeight      = $_POST['TitleLineHeight'];
    $TitleFk_SizeFormats  = $_POST['TitleFk_SizeFormats'];
    $TitleColor           = $_POST['TitleColor'];
    $TitleAlign           = $_POST['TitleAlign'];
    $TitleClass           = $_POST['TitleClass'];

    $SubTitle                 = addslashes($_POST['SubTitle']);
    $SubTitleFk_Font          = $_POST['SubTitleFk_Font'];
    $SubTitleSize             = $_POST['SubTitleSize'];
    $SubTitleLineHeight       = $_POST['SubTitleLineHeight'];
    $SubTitleFk_SizeFormats   = $_POST['SubTitleFk_SizeFormats'];
    $SubTitleColor            = $_POST['SubTitleColor'];
    $SubTitleAlign            = $_POST['SubTitleAlign'];
    $SubTitleClass            = $_POST['SubTitleClass'];

    $Text                     = addslashes($_POST['Text']);
    $TextFk_Font              = $_POST['TextFk_Font'];
    $TextSize                 = $_POST['TextSize'];
    $TextLineHeight           = $_POST['TextLineHeight'];
    $TextFk_SizeFormats       = $_POST['TextFk_SizeFormats'];
    $TextColor                = $_POST['TextColor'];
    $TextAlign                = $_POST['TextAlign'];
    $TextClass                = $_POST['TextClass'];

    //Inserta Nuevo Registro
    if( $_POST['New'] == 'Ok' ){

      //Inserta Banner
      $Query = "
        INSERT INTO BannersItem
        (
          Fk_Pagina, TextHorizontal, TextVetical,
          Title, TitleFk_Font, TitleSize,
          TitleLineHeight, TitleFk_SizeFormats,
          TitleColor, TitleAlign, TitleClass,
          SubTitle, SubTitleFk_Font, SubTitleSize,
          SubTitleLineHeight, SubTitleFk_SizeFormats,
          SubTitleColor, SubTitleAlign, SubTitleClass,
          Text, TextFk_Font, TextSize,
          TextLineHeight, TextFk_SizeFormats,
          TextColor, TextAlign, TextClass
        )
        VALUES (
          '$Pagina', '$TextHorizontal', '$TextVetical',
          '$Title', '$TitleFk_Font', '$TitleSize',
          '$TitleLineHeight', '$TitleFk_SizeFormats',
          '$TitleColor', '$TitleAlign', '$TitleClass',
          '$SubTitle', '$SubTitleFk_Font', '$SubTitleSize',
          '$SubTitleLineHeight', '$SubTitleFk_SizeFormats',
          '$SubTitleColor', '$SubTitleAlign', '$SubTitleClass',
          '$Text', '$TextFk_Font', '$TextSize',
          '$TextLineHeight', '$TextFk_SizeFormats',
          '$TextColor', '$TextAlign', '$TextClass'
        )
      ";
      $Result = mysqli_query($mysqli, $Query);
      $Id = mysqli_insert_id($mysqli);

    }
    //End Inserta Nuevo Registro

    //Edita datos
    if( $_POST['Edit'] == 'Ok' ){

      $Id		= $_POST['Id'];

      //Update
      $Query = "
        UPDATE BannersItem
        SET
          TextHorizontal = '$TextHorizontal', TextVetical = '$TextVetical',
          Title = '$Title', TitleFk_Font = '$TitleFk_Font', TitleSize = '$TitleSize',
          TitleLineHeight = '$TitleLineHeight', TitleFk_SizeFormats = '$TitleFk_SizeFormats',
          TitleColor = '$TitleColor', TitleAlign = '$TitleAlign', TitleClass = '$TitleClass',
          SubTitle = '$SubTitle', SubTitleFk_Font = '$SubTitleFk_Font', SubTitleSize = '$SubTitleSize',
          SubTitleLineHeight = '$SubTitleLineHeight', SubTitleFk_SizeFormats = '$SubTitleFk_SizeFormats',
          SubTitleColor = '$SubTitleColor', SubTitleAlign = '$SubTitleAlign', SubTitleClass = '$SubTitleClass',
          Text = '$Text', TextFk_Font = '$TextFk_Font', TextSize = '$TextSize',
          TextLineHeight = '$TextLineHeight', TextFk_SizeFormats = '$TextFk_SizeFormats',
          TextColor = '$TextColor', TextAlign = '$TextAlign', TextClass = '$TextClass'
        WHERE Id = '$Id'
      ";
      $Result = mysqli_query($mysqli, $Query);

      $Saved = 'Ok';

    }
    //End Edita datos

    //Sube Imagen
    $Imagen = "image";
    if(empty($_FILES[$Imagen]['name'])){}else{
      $_FILES[$Imagen]["name"];
      $allowedExts = array("JPEG", "jpeg", "jpg", "JPG");
      $temp = explode(".", $_FILES[$Imagen]["name"]);
      $extension = end($temp);
      if((
      ($_FILES[$Imagen]["type"] == "image/jpeg")
      || ($_FILES[$Imagen]["type"] == "image/jpg")
      || ($_FILES[$Imagen]["type"] == "image/JPEG")
      || ($_FILES[$Imagen]["type"] == "image/JPG")
      )
      && ($_FILES[$Imagen]["size"] < 10000000)
      && in_array($extension, $allowedExts)) {
      if ($_FILES[$Imagen]["error"] > 0) {
      }else{

        //RootSite del Sitio Seleccionado
        $ImageUp = $RootSite.'/'.$UrlImgs."/".$Id.".jpg";

        if ( move_uploaded_file($_FILES[$Imagen]["tmp_name"], $ImageUp) ){
        //if ( copy($_FILES["image"]["tmp_name"], $ImageUp) ){
          //echo "Img Up";
          chmod($ImageUp, 0777);
          //Ajuste de tamaño
          $width = getWidth($ImageUp);
          $height = getHeight($ImageUp);
          $max_width = "1800";
          if ($width > $max_width){
            $scale = $max_width/$width;
            $resizeObj = new resize($ImageUp);
            $resizeObj -> resizeImage(1800, 920, 'crop');
            $resizeObj -> saveImage($ImageUp, 100);
          }else{
            $scale = 1;
            $resizeObj = new resize($ImageUp);
            $resizeObj -> resizeImage(1800, 920, 'crop');
            $resizeObj -> saveImage($ImageUp, 100);
          }
        }else{
          //echo "Img Not<br>";
          print_r(error_get_last());
        }

      }}else{
      }
    }
    //End Sube Imagen

    //Redirecciona
    if( $_POST['New'] == 'Ok' ){
      echo '<script type="text/javascript">document.location.href="?ban='.$Pagina.'&Id='.$Id.'&New=Ok"</script>';
    }
    //End Redirecciona

  }



  //Banner
  $Query = "
    SELECT
      ban.Id,
      ban.Fk_Pagina, ban.TextHorizontal, ban.TextVetical,
      ban.Title, ban.TitleFk_Font, ban.TitleSize,
      ban.TitleLineHeight, ban.TitleFk_SizeFormats,
      ban.TitleColor, ban.TitleAlign, ban.TitleClass,
      ban.SubTitle, ban.SubTitleFk_Font, ban.SubTitleSize,
      ban.SubTitleLineHeight, ban.SubTitleFk_SizeFormats,
      ban.SubTitleColor, ban.SubTitleAlign, ban.SubTitleClass,
      ban.Text, ban.TextFk_Font, ban.TextSize,
      ban.TextLineHeight, ban.TextFk_SizeFormats,
      ban.TextColor, ban.TextAlign, ban.TextClass
    FROM BannersItem ban
    WHERE ban.Id = '$_GET[Id]' AND ban.Fk_Pagina = '$_GET[ban]'
  ";
  $Result = mysqli_query($mysqli, $Query);
  $Banner = mysqli_fetch_assoc($Result);

  //Fonts
  $Query = "
    SELECT
      fon.Id, fon.Name, fon.Font, fon.Link
    FROM Fonts fon
    ORDER BY fon.Name ASC
  ";
  $Fonts = $mysqli->query($Query);

  //LandingCentering
  $Query = "
    SELECT
      cen.Id, cen.Name, cen.Code
    FROM Centering cen
    ORDER BY cen.Name ASC
  ";
  $Centers = $mysqli->query($Query);

  //Fonts
  /*$Query = "
    SELECT
      fo.Id, fo.Name, fo.Format
    FROM SizeFormats fo
    ORDER BY fo.Name ASC
  ";
  $FontsFormats = $mysqli->query($Query);*/

?>

<!DOCTYPE html>
<html lang="en">

<?php require_once($Position.'head.php'); ?>

<body class="fix-sidebar fix-header card-no-border">
  <?php
    mysqli_data_seek($Fonts, 0);
    while($Font = mysqli_fetch_array($Fonts)) {
      if( $Font['Link'] ){
          echo '<link href="'.$Font['Link'].'" rel="stylesheet">';
      }
    }
  ?>

    <div class="preloader">
      <svg class="circular" viewBox="25 25 50 50">
      <circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
    </div>

    <div id="main-wrapper">
      <?php require_once($Position.'header.php'); ?>
      <?php require_once($Position.'menu.php'); ?>

      <div class="page-wrapper">

        <form method="post" enctype="multipart/form-data" data-validate="parsley" role="form" id="FormPer">
          <div class="container-fluid">

            <div class="row page-titles page-titles-fixed">

                <?php require_once($Position.'title.php'); ?>

                <!-- Botones -->
                <div class="col-md-7 align-self-center text-right">
                  <div class="btn-group" role="group" aria-label="Basic example">
                    <button type="button" class="btn btn-sm btn-secondary" onclick="window.location.href='../?Id=<?php echo $_GET['ban']; ?>'">Regresar <i class="fa fa-arrow-left m-l-5"></i></button>
                    <button type="button" class="btn btn-sm btn-secondary" onclick="window.location.href='?ban=<?php echo $_GET['ban']; ?>'">Nuevo<i class="fa fa-plus m-l-5"></i></button>
                    <button type="submit" class="btn btn-sm btn-secondary">Guardar<i class="fa fa-check m-l-5"></i></button>
                    <input type="hidden" name="Save" value="Ok">
                    <?php if( !empty($Banner['Id']) ){ ?>
                      <input type="hidden" name="Id" value="<?php echo $Banner['Id']; ?>">
                      <input type="hidden" name="Edit" value="Ok">
                    <?php }else{ ?>
                      <input type="hidden" name="New" value="Ok">
                    <?php } ?>
                    <input type="hidden" name="Fk_Pagina" value="<?php echo $Ban[Id]; ?>" />
                  </div>
                </div>
                <!-- End Botones -->

            </div>

            <!-- Información del Banner -->
            <div class="row inner-fixed-content">
              <div class="col-lg-12">

                <!-- Imagen -->
                <div class="card card-outline-info">
                  <div class="card-body">
                    <div class="row">

                      <div class="col-sm-12">
                        <h4 class="m-b-0">Imagen</h4>
                        <hr />
                      </div>

                      <!-- Imagen Principal -->
                      <div class="col-sm-6">
                        <h4>Imagen para escritorio:</h4>
                        <?php
                          $Image = $RootSite.'/images/banners/'.$Banner['Id'].'.jpg';
                          if (file_exists($Image)) {
                        ?>
                          <div class="m-b-10">
                            <img class="img-responsive" src="<?php echo $UrlSite.'/'.$UrlImgs.'/'.$Banner['Id'].'.jpg'; ?>">
                          </div>
                        <?php }else{ ?>
                          <div class="m-b-10">
                            <!--<img class="img-responsive" src="<?php echo $UrlSite.'/'.$UrlImgs.'/0.jpg'; ?>">-->
                          </div>
                        <?php } ?>

                      </div>
                      <div class="col-sm-6">
                        <label for="input-file-now-custom-1">La fotografía deberá estar en la siguiente resolución: 1800 pxw x 920 pxh y 72 dpi; <strong>solo se acepta formato jpg.</strong></label>
                        <input name="image" type="file" id="input-file-now-custom-1" class="dropify"/>
                      </div>
                      <!-- End Imagen Principal -->

                      <div class="col-sm-12">
                        <hr>
                      </div>

                      <!-- Imagen Movil -->
                      <div class="col-sm-6">
                        <h4>Imagen para móvil:</h4>
                        <?php
                        $Image = $RootSite.'/images/banners/'.$Banner['Id'].'-m.jpg';
                        if (file_exists($Image)) {
                        ?>
                          <div class="m-b-10">
                            <img class="img-responsive" src="<?php echo $UrlSite.'/'.$UrlImgs.'/'.$Banner['Id'].'-m.jpg'; ?>">
                          </div>
                        <?php }else{ ?>
                          <div class="m-b-10">
                            <!--<img class="img-responsive" src="<?php echo $UrlSite.'/'.$UrlImgs.'/0.jpg'; ?>">-->
                          </div>
                        <?php } ?>
                      </div>
                      <div class="col-sm-6">
                        <label for="input-file-now-custom-1">La fotografía deberá estar en la siguiente resolución: 478 pxw x 850 pxh y 72 dpi; <strong>solo se acepta formato jpg.</strong></label>
                        <input name="image<?php echo $ImgTraId; ?>-m" type="file" id="input-file-now-custom-1" class="dropify"/>
                      </div>
                      <!-- End Imagen Movil -->

                    </div>
                  </div>
                </div>
                <!-- End Imagen -->

                <!-- Posición de Caja de Texto -->
                <div class="card card-outline-info">
                  <div class="card-body">
                    <div class="row">

                      <div class="col-sm-12">
                        <h4>Posición de caja de texto</h4>
                        <hr>
                      </div>

                      <!-- Posición Text Vertical -->
                      <div class="col-sm-3 form-group">
                        <label>Posición Text Vertical</label>
                        <select name="TextVetical" class="form-control chosen-select">
                            <option value="1" <?php if( $Banner['TextVetical'] == '1' ){ echo "selected"; } ?>>Centro</option>
                            <option value="2" <?php if( $Banner['TextVetical'] == '2' ){ echo "selected"; } ?>>Arriba</option>
                            <option value="3" <?php if( $Banner['TextVetical'] == '3' ){ echo "selected"; } ?>>Abajo</option>
                        </select>
                      </div>
                      <!-- End Posición Text Vertical -->

                      <!-- Posición Text Vertical -->
                      <div class="col-sm-3 form-group">
                        <label>Posición Text Horizontal</label>
                        <select name="TextHorizontal" class="form-control chosen-select">
                            <option value="1" <?php if( $Banner['TextHorizontal'] == '1' ){ echo "selected"; } ?>>Centro</option>
                            <option value="2" <?php if( $Banner['TextHorizontal'] == '2' ){ echo "selected"; } ?>>Izquierda</option>
                            <option value="3" <?php if( $Banner['TextHorizontal'] == '3' ){ echo "selected"; } ?>>Derecha</option>
                        </select>
                      </div>
                      <!-- End Posición Text Vertical -->

                    </div>
                  </div>
                </div>
                <!-- End Posición de Caja de Texto -->

                <!-- Titulo -->
                <div class="card card-outline-info">
                  <div class="card-body">
                    <div class="row">

                      <div class="col-sm-12"><br>
                        <h3>Título banner principal:</h3>
                        <hr />
                      </div>

                      <!-- Mensaje principal -->
                      <div class="col-sm-12 form-group">
                        <label>Texto para banner:</label>
                        <textarea name="Title" class="form-control IncEditor"><?php echo $Banner['Title']; ?></textarea>
                      </div>
                      <!-- End Mensaje principal -->

                      <!-- Titulo Fuente --
                      <div class="col-sm-3 form-group">
                        <label>Tipo de letra:</label>
                        <select name="TitleFk_Font" class="form-control chosen-select FontSel">
                          <option value="0"></option>
                          <?php
                            mysqli_data_seek($Fonts, 0);
                            while($Font = mysqli_fetch_array($Fonts)) {
                          ?>
                            <option value="<?php echo $Font['Id']; ?>" data-font="<?php echo $Font['Font']; ?>" <?php if( $Banner['TitleFk_Font'] == $Font['Id'] ){ echo "selected"; }elseif( !$Banner[Id] && ( $Font[Id] == '1' ) ){ echo "selected"; } ?>><?php echo $Font['Name']; ?></option>
                          <?php } ?>
                        </select>
                      </div>
                      <!-- End Titulo Fuente -->

                      <!-- Tamaño de fuente -->
                      <div class="col-sm-3 form-group">
                        <label>Tamaño de la letra:</label>
                        <input name="TitleSize" class="form-control" value="<?php if( $Banner[TitleSize] ){ echo $Banner[TitleSize]; }else{ echo "40"; } ?>" autocomplete="off">
                      </div>
                      <!-- End Tamaño de fuente -->

                      <!-- Separación de Linea --
                      <div class="col-sm-3 form-group">
                        <label>Separación de Linea:</label>
                        <input name="TitleLineHeight" class="form-control" value="<?php if( $Banner[TitleLineHeight] ){ echo $Banner[TitleLineHeight]; }else{  } ?>" autocomplete="off">
                      </div>
                      <!-- End Separación de Linea -->

                      <!-- Formato de Texto --
                      <div class="col-sm-3 form-group">
                        <label>Formato de Texto</label>
                        <select data-required="true" name="TitleFk_SizeFormats" class="form-control chosen-select">
                          <option></option>
                          <?php
                            mysqli_data_seek($FontsFormats, 0);
                            while($FontFormat = mysqli_fetch_array($FontsFormats)) {
                          ?>
                            <option value="<?php echo $FontFormat['Id']; ?>" <?php if( $Banner[TitleFk_SizeFormats] == $FontFormat[Id] || (!$Banner[TitleFk_SizeFormats] && $FontFormat[Id] == 1 ) ){ echo "selected"; } ?>><?php echo $FontFormat['Name'].' ('.$FontFormat['Format'].')'; ?></option>
                          <?php } ?>
                        </select>
                      </div>
                      <!-- End Formato de Texto -->

                      <!-- Titulo Alinear -->
                      <div class="col-sm-3 form-group">
                        <label>Alineación</label>
                        <select name="TitleAlign" class="form-control chosen-select">
                          <option value="0"></option>
                          <?php
                            mysqli_data_seek($Centers, 0);
                            while($Center = mysqli_fetch_array($Centers)) {
                          ?>
                            <option value="<?php echo $Center[Id]; ?>" <?php if( $Banner[TitleAlign] == $Center[Id] ){ echo "selected"; }elseif( !$Banner[Id] && $Center[Id] == 1 ){ echo "selected"; } ?>><?php echo $Center[Name]; ?></option>
                          <?php } ?>
                        </select>
                      </div>
                      <!-- End Titulo Alinear -->

                      <!-- Titulo Color -->
                      <div class="col-sm-3 form-group">
                        <label>Color del texto:</label>
                        <input name="TitleColor" type="text" class="colorpicker form-control" value="<?php if( $Banner[TitleColor] ){ echo $Banner[TitleColor]; }else{ echo "#ffffff"; } ?>" />
                      </div>
                      <!-- End Titulo Color -->

                      <!-- Titulo Clase --
                      <div class="col-sm-3 form-group">
                        <label>Clase:</label>
                        <input
                          name="TitleClass"
                          type="text"
                          class="form-control"
                          value="<?php echo $Banner[TitleClass]; ?>"
                        />
                      </div>
                      <!-- End Titulo Clase -->

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

                <?php if( $ShowSub == '1' ){ ?>'
                  <!-- Subtitulo -->
                  <div class="card card-outline-info">
                    <div class="card-body">
                      <div class="row">

                        <div class="col-sm-12"><br>
                          <h3>Sub-título banner principal:</h3>
                          <hr />
                        </div>

                        <!-- SubTitle -->

                        <div class="col-sm-12 form-group">
                          <label>Texto para banner:</label>
                          <textarea name="SubTitle" class="form-control IncEditor"><?php echo $Banner['SubTitle']; ?></textarea>
                        </div>

                        <div class="col-sm-3 form-group">
                          <label>Tipo de letra:</label>
                          <select name="SubTitleFk_Font" class="form-control chosen-select FontSel">
                            <option value="0"></option>
                            <?php
                              mysqli_data_seek($Fonts, 0);
                              while($Font = mysqli_fetch_array($Fonts)) {
                            ?>
                              <option value="<?php echo $Font['Id']; ?>" data-font="<?php echo $Font[Font]; ?>" <?php if( $Banner[SubTitleFk_Font] == $Font['Id'] ){ echo "selected"; }elseif( !$Banner[Id] && ( $Font[Id] == '1' ) ){ echo "selected"; } ?> ><?php echo $Font[Name]; ?></option>
                            <?php } ?>
                          </select>
                        </div>

                        <!-- Tamaño Texto -->
                        <div class="col-sm-3 form-group">
                          <label>Tamaño de la letra:</label>
                          <input name="SubTitleSize" class="form-control" value="<?php if( $Banner['SubTitleSize'] ){ echo $Banner['SubTitleSize']; }else{ echo "18"; } ?>" autocomplete="off">
                        </div>
                        <!-- End Tamaño Texto -->

                        <!-- Separación de Linea -->
                        <div class="col-sm-3 form-group">
                          <label>Separación de Linea:</label>
                          <input name="SubTitleLineHeight" class="form-control" value="<?php if( $Banner[SubTitleLineHeight] ){ echo $Banner[SubTitleLineHeight]; }else{  } ?>" autocomplete="off">
                        </div>
                        <!-- End Separación de Linea -->

                        <!-- Formato de Texto -->
                        <div class="col-sm-3 form-group">
                          <label>Formato de Texto ... <?php echo $Banner[SubTitleFk_SizeFormats]; ?></label>
                          <select data-required="true" name="SubTitleFk_SizeFormats" class="form-control chosen-select">
                            <option></option>
                            <?php
                              mysqli_data_seek($FontsFormats, 0);
                              while($FontFormat = mysqli_fetch_array($FontsFormats)) {
                            ?>
                              <option value="<?php echo $FontFormat['Id']; ?>" <?php if( $Banner[SubTitleFk_SizeFormats] == $FontFormat[Id] || (!$Banner[SubTitleFk_SizeFormats] && $FontFormat[Id] == 1 ) ){ echo "selected"; } ?>><?php echo $FontFormat['Name'].' ('.$FontFormat['Format'].')'; ?></option>
                            <?php } ?>
                          </select>
                        </div>
                        <!-- End Formato de Texto -->

                        <!-- SubTitle Alinear -->
                        <div class="col-sm-3 form-group">
                          <label>Alineación</label>
                          <select name="SubTitleAlign" class="form-control chosen-select">
                            <option value="0"></option>
                            <?php
                              mysqli_data_seek($Centers, 0);
                              while($Center = mysqli_fetch_array($Centers)) {
                            ?>
                              <option value="<?php echo $Center['Id']; ?>" <?php if( $Banner[SubTitleAlign] == $Center[Id] ){ echo "selected"; }elseif( !$Banner[Id] && $Center[Id] == 1 ){ echo "selected"; } ?>><?php echo $Center['Name']; ?></option>
                            <?php } ?>
                          </select>
                        </div>
                        <!-- End SubTitle Alinear -->

                        <!-- Color Texto -->
                        <div class="col-sm-3 form-group">
                          <label>Color del texto:</label>
                          <input name="SubTitleColor" type="text" class="colorpicker form-control" value="<?php if( $Banner['SubTitleColor'] ){ echo $Banner['SubTitleColor']; }else{ echo "#ffffff"; } ?>" />
                        </div>
                        <!-- End Color Texto -->

                        <!-- SubTitulo Clase -->
                        <div class="col-sm-3 form-group">
                          <label>Clase:</label>
                          <input
                            name="SubTitleClass"
                            type="text"
                            class="form-control"
                            value="<?php echo $Banner[SubTitleClass]; ?>"
                          />
                        </div>
                        <!-- End SubTitulo Clase -->

                      </div>
                    </div>
                  </div>
                  <!-- End Subtitulo -->
                <?php } ?>

                <!-- Text -->
                <div class="card card-outline-info">
                  <div class="card-body">
                    <div class="row">

                      <div class="col-sm-12"><br>
                        <h3>Texto:</h3>
                        <hr />
                      </div>

                      <!-- Text -->

                      <div class="col-sm-12 form-group">
                        <label>Texto descriptivo:</label>
                        <textarea name="Text" class="form-control IncEditor"><?php echo $Banner['Text']; ?></textarea>
                      </div>

                      <!-- Tipo de letr --
                      <div class="col-sm-3 form-group">
                        <label>Tipo de letra:</label>
                        <select name="TextFk_Font" class="form-control chosen-select FontSel">
                          <option value="0"></option>
                          <?php
                            mysqli_data_seek($Fonts, 0);
                            while($Font = mysqli_fetch_array($Fonts)) {
                          ?>
                            <option value="<?php echo $Font['Id']; ?>" data-font="<?php echo $Font['Font']; ?>" <?php if( $Banner[TextFk_Font] == $Font['Id'] ){ echo "selected"; }elseif( !$Banner[Id] && ( $Font[Id] == '1' ) ){ echo "selected"; } ?>><?php echo $Font['Name']; ?></option>
                          <?php } ?>
                        </select>
                      </div>
                      <!-- End Tipo de letr -->

                      <!-- Tamaño Texto -->
                      <div class="col-sm-3 form-group">
                        <label>Tamaño de la letra:</label>
                        <input name="TextSize" class="form-control" value="<?php if( $Banner['TextSize'] ){ echo $Banner['TextSize']; }else{ echo "14"; } ?>" autocomplete="off">
                      </div>
                      <!-- End Tamaño Texto -->

                      <!-- Separación de Linea --
                      <div class="col-sm-3 form-group">
                        <label>Separación de Linea:</label>
                        <input name="TextLineHeight" class="form-control" value="<?php if( $Banner[TextLineHeight] ){ echo $Banner[TextLineHeight]; }else{  } ?>" autocomplete="off">
                      </div>
                      <!-- End Separación de Linea -->

                      <!-- Formato de Texto --
                      <div class="col-sm-3 form-group">
                        <label>Formato de Texto</label>
                        <select data-required="true" name="TextFk_SizeFormats" class="form-control chosen-select">
                          <option></option>
                          <?php
                            mysqli_data_seek($FontsFormats, 0);
                            while($FontFormat = mysqli_fetch_array($FontsFormats)) {
                          ?>
                            <option value="<?php echo $FontFormat['Id']; ?>" <?php if( $Banner[TextFk_SizeFormats] == $FontFormat[Id] || (!$Banner[TextFk_SizeFormats] && $FontFormat[Id] == 1 ) ){ echo "selected"; } ?>><?php echo $FontFormat['Name'].' ('.$FontFormat['Format'].')'; ?></option>
                          <?php } ?>
                        </select>
                      </div>
                      <!-- End Formato de Texto -->

                      <!-- Text Alinear -->
                      <div class="col-sm-3 form-group">
                        <label>Alineación</label>
                        <select name="TextAlign" class="form-control chosen-select">
                          <option value="0"></option>
                          <?php
                            mysqli_data_seek($Centers, 0);
                            while($Center = mysqli_fetch_array($Centers)) {
                          ?>
                            <option value="<?php echo $Center['Id']; ?>" <?php if( $Banner[TextAlign] == $Center[Id] ){ echo "selected"; }elseif( !$Banner[Id] && $Center[Id] == 1 ){ echo "selected"; } ?>><?php echo $Center['Name']; ?></option>
                          <?php } ?>
                        </select>
                      </div>
                      <!-- End Text Alinear -->

                      <!-- Color Texto -->
                      <div class="col-sm-3 form-group">
                        <label>Color del texto:</label>
                        <input name="TextColor" type="text" class="colorpicker form-control" value="<?php if( $Banner['TextColor'] ){ echo $Banner['TextColor']; }else{ echo "#ffffff"; } ?>" />
                      </div>
                      <!-- End Color Texto -->

                      <!-- Texto Clase --
                      <div class="col-sm-3 form-group">
                        <label>Clase:</label>
                        <input
                          name="TextClass"
                          type="text"
                          class="form-control"
                          value="<?php echo $Banner[TextClass]; ?>"
                        />
                      </div>
                      <!-- End Texto Clase -->

                      <!-- End Text -->

                      <div class="col-sm-12">
                        <hr class="m-t-0">
                      </div>

                    </div>
                  </div>
                </div>
                <!-- End Texto-->

                <!-- Buton -->
                <div class="card card-outline-info">
                  <div class="card-body">
                    <div class="row">

                      <div class="col-sm-12">
                        <h4>Botón</h4>
                        <hr>
                      </div>

                      <div class="col-sm-3 form-group">
                        <label>Text del botón:</label>
                        <input name="BotonText[]" class="form-control" value="<?php echo $Banner['BotonText']; ?>" autocomplete="off">
                      </div>

                      <div class="col-sm-6 form-group">
                        <label>URL de destino:</label>
                        <input name="Url[]" data-type="url" class="form-control" value="<?php echo $Banner['Url']; ?>" autocomplete="off">
                      </div>

                      <div class="col-sm-3 form-group">
                        <label>Redirección</label>
                        <select name="Redireccion[]" class="form-control chosen-select">
                          <option value="1" <?php if( $Banner['Redireccion'] == '1' ){ echo "selected"; } ?>>Misma Ventana</option>
                          <option value="2" <?php if( $Banner['Redireccion'] == '2' ){ echo "selected"; } ?>>Nueva Ventana</option>
                        </select>
                      </div>

                    </div>
                  </div>
                </div>
                <!-- End Buton -->

              </div>
            </div>


          </div>
        </form>
      </div>

      <?php require_once($Position.'footer.php'); ?>

    </div>

    <?php require_once($Position.'scripts.php'); ?>
    <script src="<?php echo $Position; ?>js/extra.js"></script>
    <script>
      $(document).ready(function(){

        //Areas de Texto
        tinymce.init({
            selector: ".IncEditor",
            theme: "modern",
            height: 300,
            force_br_newlines : true,
            force_p_newlines : false,
            forced_root_block : '',
            plugins: "paste",
            paste_as_text: true,
            plugins: [
                "advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
                "searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
                "save table contextmenu directionality emoticons template paste textcolor"
            ],
            toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | l      ink image | print preview media fullpage | forecolor backcolor emoticons",
        });
        //End Areas de Texto

        // Actualiza Imagenes
        $("img").each(function(){
          $(this).attr('src', $(this).attr('src')+'?'+Math.random());
        });

        //Date datepicker
        $('.datepicker').datepicker({
          autoclose: true,
          todayHighlight: true,
          format: "dd / MM / yyyy",
          startView: 2
        });
        //End Date datepicker

        //Seleccion de Fuente
        $(document.body).on('change', '.FontSel' ,function(){
          $("option:selected", this).each(function () {
            font = $( this ).data( "font" );
            console.log(font);
            $( this ).parents('.FontSel').css("font-family", font);
            $( this ).parents('.FontSel').parents('.form-group').find('.chosen-single').css("font-family", font);
          });
        });

      });
    </script>
    <!-- End Extra js -->

    <!-- Cerrar Conexion -->
    <?php require_once($Position.'cerrarconexion.php'); ?>
    <!-- End Cerrar Conexion -->

</body>

</html>
