<?php

    

    session_start();

    header("Content-Type: text/html; charset=UTF-8"); 

    require_once('../motormobil/motormobil.php');



?>

<?php

    require_once('../bussines/fix_characters.php');

$Obj_fix_characters = new fix_characters();



    require_once('../odbconexion/config.php');



?>

<?php

$Titulo_App='';

$Descripcion_Login_App='';

$Logo_APP='';

$Logo_Fav_Icon='';

$Habilitar_Formulario_Registro='';

try{    



    $Odbj_conexion = new odbconexion;

    $conexion=$Odbj_conexion->openconection();

    $consulta="SELECT * FROM configuracion_app_appquadrata";

    $Array_adapter_config=$conexion->query($consulta);

    $conexion->close();

    while($Field_config=$Array_adapter_config->fetch_assoc())

    {   

        $Titulo_App=$Field_config['Titulo_App'];

        $Descripcion_Login_App=$Field_config['Descripcion_Login_App'];

        $Logo_APP=$Field_config['Logo_APP'];

        $Logo_Fav_Icon=$Field_config['Logo_Fav_Icon'];

        $Habilitar_Formulario_Registro=$Field_config['Habilitar_Formulario_Registro'];

    }

}catch (Exception $e) {

        echo 'Excepcion capturada: ',  $e->getMessage(), "

                    ";

}



//Declaramos la variable time, para que al modificar un archivo, este no se guarde en cache y se vizualicen los cambios

$time_log_assets=time();

/*inicializamos valores para la configuracion del template*/

$setting_template='../settings_template.txt';

$variables=[];

$_Color='';

$_Template='';

$_Theme_Template='';

$_Css='';

$_Js='';

$_Css_Version='';

$_Js_Version='';

if (file_exists($setting_template)) {

    $lines = file($setting_template, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

    foreach ($lines as $line) {

        list($nombre_variable, $valor) = explode('=', $line);

        $variables[$nombre_variable] = $valor;

    }

    /*recogemos los valores de las variables*/

    if (isset($variables['Color'])) {

        $_Color = $variables['Color'];



        //echo "El color es: $_Color";

    }

    if (isset($variables['Template'])) {

        $_Template = $variables['Template'];

        //echo "El Template es: $_template";

    }

    if (isset($variables['Theme_Template'])) {

        $_Theme_Template = $variables['Theme_Template'];

        //echo "El Theme_Template es: $_Theme_Template";

    }

    if (isset($variables['css'])) {

        $_Css = $variables['css'];

        //echo "El css es: $_Css";

    }

    if (isset($variables['js'])) {

        $_Js = $variables['js'];

        //echo "El js es: $_Js";

    }

    if (isset($variables['css_version'])) {

        $_Css_Version = $variables['css_version'];

        //echo "El css es: $_Css";

    }

    if (isset($variables['js_version'])) {

        $_Js_Version = $variables['js_version'];

        //echo "El js es: $_Js";

    }

}

/*terminan valores de configuracion pára el template*/

$redirect_to = isset($_GET['redirect_to']) ? $_GET['redirect_to'] : 'index';

?>

<!DOCTYPE html>

<html lang="es" class="light <?php if($_Color!=''){ echo 'theme-user'; }else{ echo $_Theme_Template; }?>">

    <!-- BEGIN: Head -->

    <head>

        <meta charset="utf-8">

        <?php

            if($Logo_Fav_Icon==''){

                echo "

                <link href=\"../dist/images/logo.svg\" rel=\"shortcut icon\" type=\"image/x-icon\" style=\"color:black;\">

                ";

            }else{

                try {

                    if (file_exists("../".str_replace('../','',$Logo_Fav_Icon))){

                        $time_icon=time();

                        $time_icon=filectime("../".str_replace('../','',$Logo_Fav_Icon));

                        echo "

                        <link href=\"../".str_replace('../','',$Logo_Fav_Icon)."?dummy=".$time_icon."\" rel=\"shortcut icon\">

                        ";

                    }else{

                        echo "

                        <link href=\"../dist/images/logo.svg\" rel=\"shortcut icon\" type=\"image/x-icon\" style=\"color:black;\">

                        ";  

                    }

                } catch (Exception $e) {

                    //echo "Ha ocurrido un error: " . $e->getMessage();

                }

            }

        ?>

        <meta name="viewport" content="width=device-width, initial-scale=1">

        <meta name="description" content="Desarrollado por SINAPSYS DEVOPS SA DE CV">

        <meta name="keywords" content="admin template, Midone Admin Template, dashboard template, flat admin template, responsive admin template, web app">

        <meta name="author" content="SINAPSYS">

        <title>Requerido!</title>

        <!-- BEGIN: CSS Assets-->

        <link rel="stylesheet" href="../dist/css/<?=$_Css;?>?time=<?=$_Css_Version;?>" />

        <!-- END: CSS Assets-->

    </head>

    <!-- END: Head -->

    <body class="py-5">

        <div class="container">

            <!-- BEGIN: Error Page -->

            <div class="error-page flex flex-col lg:flex-row items-center justify-center h-screen text-center lg:text-left">

                <div class="-intro-x lg:mr-20">

                    <img alt="Midone - HTML Admin Template" class="h-48 lg:h-auto" src="img/escanear_qr.png">

                </div>

                <div class="text-white mt-10 lg:mt-0">

                    <!--<div class="intro-x text-8xl font-medium">QR No Asociado</div>-->

                    <div class="intro-x text-xl lg:text-3xl font-medium mt-5">QR No Asociado</div>

                    <div class="intro-x text-lg mt-3">Lo sentimos, el código QR que has escaneado no está asociado a ningún registro en nuestro sistema.</div>

                    <p class="intro-x text-lg mt-3">Para gestionar tus registros, <a onclick="document.getElementById('inicia-sesion').click();">inicia sesión</a> o <a  onclick="document.getElementById('crea-cuenta').click();">Crea una cuenta</a> y accede a tu panel administrativo.</p>

                    <?php

                        if($q==''){

                    ?>

                        <button onclick="window.location.href='../login?redirect_to=<?php echo urlencode($redirect_to); ?>'" id='inicia-sesion' class="intro-x btn py-3 px-4 text-white border-white dark:border-darkmode-400 dark:text-slate-200 mt-10">Iniciar sesión</button>

                        <button onclick="window.location.href='../login/crear-cuenta?redirect_to=<?php echo urlencode($redirect_to); ?>'" id='crea-cuenta' class="intro-x btn py-3 px-4 text-white border-white dark:border-darkmode-400 dark:text-slate-200 mt-10">Crear cuenta</button>

                    <?php }else{?>

                        <button onclick="window.location.href='../home/qr_tag/view/update?q=<?= $q; ?>'" id='update' class="intro-x btn py-3 px-4 text-white border-white dark:border-darkmode-400 dark:text-slate-200 mt-10">Escribir tarjeta</button>

                    

                    <?php }?>

                </div>

            </div>

            <!-- END: Error Page -->

        </div>

    </body>

</html>