<?php

if($_SESSION["perfil"] == "Especial"){

  echo '<script>

    window.location = "inicio";

  </script>';

  return;

}
$plantilla = new ControladorPlantilla();
$configuracion = $plantilla -> ctrConfiguracion()[0];

?>
<div class="content-wrapper">
  <section class="content-header">
    <h1>Configuración</h1>
    <ol class="breadcrumb">
      <li><a href=""><i class="fa fa-dashboard"></i>Inicio</a></li>
      <li class="active">Configuración</li>
    </ol>
  </section>

  <section class="content">
    <div class="row">
      <div class="col-lg-12 col-xs-12">
        <div class="box box-success" style="padding-top: 20px;">
          <form role="form" method="post" class="" enctype="multipart/form-data">
            <div class="row pt-4 mt-4">
              <div class="col-md-12 pt-4 sc">

                <div class="form-group form-space col-md-12">
                  <div class="panel panel-success">
                    <div class="panel-heading">
                      <center>
                      <h3 class="panel-title">Configuración</h3>
                      </center>
                    </div>
                    <div class="panel-body" style="padding:0px">

                        <div class="form-row">
                          <div class="form-group col-md-6">
                            <label for="inputCity">Razón social:</label>

                            <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-user"></i></span>
                              <input type="text" class="form-control" name="razon_social" id="razon_social" value="<?php echo $configuracion["razon_social"]; ?>" required>
                            </div>

                          </div>
                        </div>

                        <div class="form-row">
                          <div class="form-group col-md-6">
                            <label for="inputCity">Correo electronico:</label>

                            <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-user"></i></span>
                              <input type="email" class="form-control" name="email" id="email" value="<?php echo $configuracion["email"]; ?>" required>
                            </div>

                          </div>
                        </div>

                        <div class="form-row">
                          <div class="form-group col-md-2">
                            <label for="inputCity">Prefijo:</label>

                            <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-user"></i></span>
                              <input type="text" class="form-control" name="prefijo" id="prefijo" value="<?php echo $configuracion["prefijo"]; ?>" required>
                            </div>

                          </div>
                        </div>

                        <div class="form-row">
                          <div class="form-group col-md-4">
                            <label for="inputCity">Celular:</label>

                            <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-user"></i></span>
                              <input type="number" class="form-control" name="celular" id="celular" value="<?php echo $configuracion["celular"]; ?>" required>
                            </div>

                          </div>
                        </div>

                        <div class="form-row">
                          <div class="form-group col-md-6">
                            <label for="inputCity">Dirección:</label>
                            <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-user"></i></span>
                              <input type="text" class="form-control" name="direccion" id="direccion" value="<?php echo $configuracion["direccion"]; ?>" required>
                            </div>

                          </div>
                        </div>

                        <div class="form-row">
                          <div class="form-group col-md-6">
                            <label for="inputCity">Cambio:</label>
                            <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-user"></i></span>
                              <input type="text" class="form-control" name="cambio" id="cambio" value="<?php echo $configuracion["cambio"]; ?>" required>
                            </div>

                          </div>
                        </div>

                        <!-- CONFIGURACIÓN PARA SUBIR FOTO -->
                        <div class="form-row">
                            <div class="form-group col-md-6">
                                <label for="inputCity">Logo:</label>
                                <input type="file" class="nuevaFoto" name="logo" id="SelectLogo">

                                <p class="help-block">Peso máximo de la foto 2MB</p>

                                <img src="<?= empty($configuracion["logo"]) ? 'vistas/img/usuarios/default/anonymous.png' : $configuracion["logo"] ?>" class="img-thumbnail previsualizarEditar" width="100px">

                                <input type="hidden" name="id" value="<?= $configuracion["id"]; ?>">

                            </div>
                        </div>

                       


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


              </div>


            </div>
            <div class="box-footer">

             <!-- <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-arrow-circle-left"></i> Cancelar</button> -->
             <a href="contratos"  class="btn btn-danger" ><i class="fa fa-arrow-circle-left"></i> Cancelar</a>

             <!-- <button type="submit" class="btn btn-primary pull-right"><i class="fa fa-save"></i> Guardar</button> -->

            <button type="submit" class="btn btn-primary"><i class="fa fa-save"></i> Actualizar</button>

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

      <?php
        $plantilla2 = new ControladorPlantilla();
        $guardar = $plantilla2 -> ctrActualizarConf();
       print_r($guardar);

        ?>
    </div>
  </section>

</div>



<script>
    $(document).ready(function(){
        $('#SelectLogo').change(function(){
            filePreview(this);
        });
    })

    function filePreview(input) {
        if (input.files && input.files[0]) {
            var reader = new FileReader();
            reader.onload = function (e) {
                $('.previsualizarEditar').attr('src', e.target.result);
            }
            reader.readAsDataURL(input.files[0]);
        }
    }
</script>
