<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
define("MYSQL_CONN_ERROR", "Unable to connect to database.");
mysqli_report(MYSQLI_REPORT_STRICT);
include_once('../vendor/autoload.php');
include_once("../config/ConfiguracionBD.php");
include_once("../models/Encuesta242.php");
include_once("../resources/php/FuncionesComunes.php");
$nombreAlumno = FuncionesComunes::decrypt($_REQUEST["nombreAlumno"]);
$encuesta242Id = FuncionesComunes::decrypt($_REQUEST["encuestaId"]);
$Encuesta242 = new Encuesta242();
$Encuesta242->encuesta242Id = $encuesta242Id;
$resultadoEncuesta = $Encuesta242->consultarEncuestas242(1);
$rowResultadoEncuesta = $resultadoEncuesta->fetch_assoc();
$tituloResultado = "";
$textoResultado = "";
switch ($rowResultadoEncuesta["semaforoEncuesta"])
{
    case "success":
        $textoResultado='<p style="color: #212529;text-align: justify">you carry out very good networking practices and you seem to apply them frequently with people in your different environments (personal, family, work, professional, social, community, etc.).<br><br>
        It would be great if you could grow your network of relationships even more by meeting more people outside your closest circle (family, friends, co-workers). People that are different in the profession, age, interests, hobbies, etc. The wider and more diverse your network is and the more you take care of it, the more opportunities you will have to expand your personal branding. 
        </p>';
        $tituloResultado='<h2><strong style="color: #198754">Excellent!</strong></h2><br>
        <h4><strong style="color: #0d6efd">Your result reveals that...</strong></h4>';
        $semaforoResultados ='<img src="../resources/images/bid_enc_semaforo_verde-01.png" alt="Imagen">';
        $retroResultados ='<img src="../resources/images/bid_enc_retro_verde-01.png" alt="Imagen">';
        break;
    case "warning":
        $textoResultado='<p style="color: #212529;text-align: justify">you engage in good networking practices, although you may not do it frequently or you may choose whom you do it with, rather than applying it consistently with people in your various environments (personal, family, work, professional, social, community, etc.).<br><br>
        You have a base to further strengthen your network of relationships. So, spend more time getting to know people outside your close circle (family, friends, co-workers). People that are different in the profession, age, interests, hobbies, etc. Because the wider and more diverse your network is and the more you take care of it, the more opportunities you will have to expand your personal brand.<br>
        </p>';
        $tituloResultado='<h2><strong style="color: #0d6efd">Good result!</strong></h2><br>
        <h4><strong style="color: #0d6efd">Your score reveals that...</strong></h4>';
        $semaforoResultados ='<img src="../resources/images/bid_enc_semaforo_amarillo-01.png" alt="Imagen">';
        $retroResultados ='<img src="../resources/images/bid_enc_retro_amarillo-01.png" alt="Imagen">';
        break;
    case "danger":
        $textoResultado='<p style="color: #212529;text-align: justify">you should identify more practices that allow you to build and maintain a wider and more diverse network of relationships. It would be great if you could identify frequent actions to leave a memorable footprint, applying them consistently with people in your different environments (personal, family, work, professional, social, community, etc.). <br><br>
        Spend time getting to know people outside your close circle (family, friends, co-workers). People who are different in their profession, age, interests, hobbies, etc. Because the wider and more diverse your network is and the more you take care of it, the more opportunities you will have to expand your personal brand.  <br><br>
        </p>';
        $tituloResultado='<h2><strong style="color: #dc3545">&iexcl;Worrying result!</strong></h2><br>
        <h4><strong style="color: #0d6efd">Your result suggests that ...</strong></h4>';
        $semaforoResultados ='<img src="../resources/images/bid_enc_semaforo_rojo-01.png" alt="Imagen">';
        $retroResultados ='<img src="../resources/images/bid_enc_retro_rojo-01.png" alt="Imagen">';
        break;
}



$html='
<link rel="stylesheet" href="../resources/css/resultadosemaforo.css" type="text/css">
<div class="form-group row">
    <div class="col-md-12 col-xs-12 col-sm-12">
        <img src="../resources/images/headerpdf.jpg" alt="Imagen" width="100%">
    </div>
</div>
<div class="form-group row">
        <div class="col-md-12 col-xs-12 col-sm-12">
            <h5>Hola <strong>'.$nombreAlumno.'</strong>.</h5>
        </div>
    </div>
    <div class="form-group row">
        <div class="col-md-12 col-xs-12 col-sm-12">
            <div class="card">
                 <div class="card-header" style="background: #B9F0D0;text-align: center;">
                <strong  style="color: #00B74A;"><img src="../resources/images/iconopaloma.png" width="20px" height="20px">&nbsp;See your results.</strong>
            </div>
            </div>
        </div>
    </div>
    <br>
    <table border="0">
        <tr VALIGN=top>
            <td width="20%">
                '.$semaforoResultados.'
            </td>
            <td width="20%" VALIGN=top>
                '.$retroResultados.'
            </td>
            <td width="20%" style="text-align: justify">
                <div class="col-md-6 col-xs-6 col-sm-6 text-center">
                    <div>
                    '.$tituloResultado.'<br>'.$textoResultado.'
                    </div>
                </div>
            </td>
        </tr>
    </table>
';
$html=utf8_encode($html);

$mpdf = new \Mpdf\Mpdf(['tempDir' => sys_get_temp_dir().DIRECTORY_SEPARATOR.'mpdf', 'mode' => 'utf-8' ,
    'format' => 'Letter' , 'margin_left' => 8 , 'margin_right' => 8 , 'margin_top' => 5 ,
    'margin_bottom' => 10 ,'margin-header'=>5, 'margin-footer'=>10,'orientation' => 'P' ]);
$mpdf->ignore_invalid_utf8 = true;
$mpdf->SetDisplayMode('fullpage');
//$cssbootstrap=file_get_contents('https://sadpro.osvaldo.com/encuesta2/resources/css/bootstrap.css');
//$mpdf->WriteHTML($cssbootstrap,1);
$mpdf->WriteHTML($html);
$nombreArchivo = 'Encuesta242_' . $encuesta242Id;
$mpdf->Output($nombreArchivo . '.pdf', "I");