<?php
include_once('../vendor/autoload.php');
include_once("../config/ConfiguracionBD.php");
include_once("../models/Encuesta133.php");
include_once("../resources/php/FuncionesComunes.php");
$nombreAlumno = FuncionesComunes::decrypt($_REQUEST["nombreAlumno"]);
$encuesta133Id = FuncionesComunes::decrypt($_REQUEST["encuestaId"]);
$arrItems= array('Visionario','Coach','Afiliativo','Democrático','Timonel','Autoritario');
$arrItemsValores= array(0,0,0,0,0,0);
$Encuesta133 = new Encuesta133();
$Encuesta133->encuesta133Id = $encuesta133Id;
$resultadoEncuesta = $Encuesta133->consultarEncuestas133(1);
$rowResultadoEncuesta = $resultadoEncuesta->fetch_assoc();
$html='
<style>
    th span
    {
        vertical-align: bottom;
        text-align: center;
        -ms-writing-mode: tb-rl;
        -webkit-writing-mode: vertical-rl;
        writing-mode: vertical-rl;
        transform: rotate(180deg);
        white-space: nowrap;
    }
</style>
<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 <b>'.$nombreAlumno.'</b>.</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>
<div class="form-group row">
    <span class="col-md-12 col-xs-12 col-sm-12">
        <p class="text-justify">
            If you answered <strong>yes </strong>to two or more of the items that correspond to one of the <strong>leadership styles</strong>, you probably apply it in your <strong>professional career.</strong><br><br>
           Identify which leadership style predominates in you.
        </p>
        <table class="table" >
            <tr style="background: #004E70;color: #fff;padding: 1px;">
                <th scope="col" color="#fffaf0" width="80px">Estilo</th>
                <th scope="col" color="#fffaf0" width="100px">'.utf8_decode($arrItems[0]).'</th>
                <th scope="col" color="#fffaf0" width="100px">'.utf8_decode($arrItems[1]).'</th>
                <th scope="col" color="#fffaf0" width="100px">'.utf8_decode($arrItems[2]).'</th>
                <th scope="col" color="#fffaf0" width="100px">'.utf8_decode($arrItems[3]).'</th>
                <th scope="col" color="#fffaf0" width="100px">'.utf8_decode($arrItems[4]).'</th>
                <th scope="col" color="#fffaf0" width="100px">'.utf8_decode($arrItems[5]).'</th>
            </tr>
            <tbody>
                <tr>
                    <th style="background: #87C8E9"><span>Items correspondientes</span></th>
                    <td>
                        <ul>';

                            $resultadoItems0 = $Encuesta133->consultarItemsCategoriaEncuestas133(2,$arrItems[0]);
                            while($rowItems0 = $resultadoItems0->fetch_object())
                            {
                                $icono = '&nbsp;<img src="../resources/images/tachitaroja.png" width="15px" height="15px">';
                                if($rowResultadoEncuesta["pregunta".$rowItems0->orden]==1)
                                {
                                    $icono = '&nbsp;<img src="../resources/images/iconopaloma.png" width="15px" height="15px">';
                                    $arrItemsValores[0]++;
                                }
                                $html.= '<li><strong>'.$rowItems0->orden.$icono.'</strong></li>';
                            }

                    $html.= '</ul>
                    </td>
                    <td>
                        <ul>';
                            $resultadoItems0 = $Encuesta133->consultarItemsCategoriaEncuestas133(2,$arrItems[1]);
                            while($rowItems0 = $resultadoItems0->fetch_object())
                            {
                                $icono = '&nbsp;<img src="../resources/images/tachitaroja.png" width="15px" height="15px">';
                                if($rowResultadoEncuesta["pregunta".$rowItems0->orden]==1)
                                {
                                    $icono = '&nbsp;<img src="../resources/images/iconopaloma.png" width="15px" height="15px">';
                                    $arrItemsValores[1]++;
                                }
                                $html.= "<li><strong>".$rowItems0->orden.$icono."</strong></li>";
                            }
                        $html.= '</ul>
                    </td>
                    <td>
                        <ul>';
                            $resultadoItems0 = $Encuesta133->consultarItemsCategoriaEncuestas133(2,$arrItems[2]);
                            while($rowItems0 = $resultadoItems0->fetch_object())
                            {
                                $icono = '&nbsp;<img src="../resources/images/tachitaroja.png" width="15px" height="15px">';
                                if($rowResultadoEncuesta["pregunta".$rowItems0->orden]==1)
                                {
                                    $icono = '&nbsp;<img src="../resources/images/iconopaloma.png" width="15px" height="15px">';
                                    $arrItemsValores[2]++;
                                }
                                $html.= "<li><strong>".$rowItems0->orden.$icono."</strong></li>";
                            }

                        $html.= '</ul>
                    </td>
                    <td>
                        <ul>';
                            $resultadoItems0 = $Encuesta133->consultarItemsCategoriaEncuestas133(2, utf8_decode($arrItems[3]));
                            while($rowItems0 = $resultadoItems0->fetch_object())
                            {
                                $icono = '&nbsp;<img src="../resources/images/tachitaroja.png" width="15px" height="15px">';
                                if($rowResultadoEncuesta["pregunta".$rowItems0->orden]==1)
                                {
                                    $arrItemsValores[3]++;
                                    $icono = '&nbsp;<img src="../resources/images/iconopaloma.png" width="15px" height="15px">';
                                }
                                $html.=  "<li><strong>".$rowItems0->orden.$icono."</strong></li>";
                            }
                        $html.= '</ul>
                    </td>
                    <td>
                        <ul>';
                            $resultadoItems0 = $Encuesta133->consultarItemsCategoriaEncuestas133(2, $arrItems[4]);
                            while($rowItems0 = $resultadoItems0->fetch_object())
                            {
                                $icono = '&nbsp;<img src="../resources/images/tachitaroja.png" width="15px" height="15px">';
                                if($rowResultadoEncuesta["pregunta".$rowItems0->orden]==1)
                                {
                                    $icono = '&nbsp;<img src="../resources/images/iconopaloma.png" width="15px" height="15px">';
                                    $arrItemsValores[4]++;
                                }
                                $html.=  "<li><strong>".$rowItems0->orden.$icono."</strong></li>";
                            }
                        $html.= '</ul>
                    </td>
                    <td>
                        <ul>';
                            $resultadoItems0 = $Encuesta133->consultarItemsCategoriaEncuestas133(2, $arrItems[5]);
                            while($rowItems0 = $resultadoItems0->fetch_object())
                            {
                                $icono = '&nbsp;<img src="../resources/images/tachitaroja.png" width="15px" height="15px">';
                                if($rowResultadoEncuesta["pregunta".$rowItems0->orden]==1)
                                {
                                    $arrItemsValores[5]++;
                                    $icono = '&nbsp;<img src="../resources/images/iconopaloma.png" width="15px" height="15px">';
                                }
                                $html.=  "<li><strong>".$rowItems0->orden.$icono."</strong></li>";
                            }
                        $html.= '</ul>
                    </td>
                </tr>
            </tbody>
        </table>';
$html.='
    <table>
        <tr>
            <td width="50%">
                <img width="500px" height="400px"  src="'. $rowResultadoEncuesta["imagenGrafica"].'" />     
            </td>
            <td width="50%" style="text-align: justify;">
                <div class="col-md-6 col-xs-6 col-sm-6 text-center">
                    <br><br>
                    <div >
                        <h2><strong style="color: #004E70">Retroalimentaci&oacute;n</strong></h2>
                        <br>
                        <p style="font-size: 18px">
                            The results of research on Resonant Leadership Styles by researchers Daniel Goleman, Richard Boyatzis and Anne McKee show that the best leaders use at least three different styles and know how to switch nimbly from one to another depending on the situation or the type of collaborator.  <br><br>
							In the test you have taken, a leadership style <strong>predominates</strong> in you if you have answered yes to at least <strong>5 of the 7</strong> possibilities. Between 3 and 4 is considered a <strong>moderately predominant</strong> style and below 2 is an <strong>occasional style</strong> in you.   <br><br>
							The styles are not "good" or "bad" but appropriate to deal with each situation. The <strong>pacesetting</strong> and <strong>commanding</strong> styles should only be used at specific times since their continued use can have a negative effect on teams.<br><br>
                            Tae a look on the <strong>supplementary reading on Resonant Leadership Styles</strong> to delve into the characteristics of each style. It will allow you to assess whether or not you are currently using the appropriate combination of styles for your current goals or role and it will brainstorm ideas for developing new styles if you find it necessary.
                        </p>
                    </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);
ob_clean(); // cleaning the buffer before Output()
$nombreArchivo = 'Encuesta133_' . $encuesta133Id;
$mpdf->Output($nombreArchivo . '.pdf', "I");