$p->titulo(5, $titulo);
 $p->setfont('Arial', '', 8);
 $color1 = 'A6A6A6';
 $color2 = 'FFFFFF';
 $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=8";
 $nor = "align=center height=5 valign=middle";
 $tabla .= "<table border=1>\n\t\t<tr>\n\t\t\t<td {$tit} width=40>Fecha: </td>\n\t\t\t<td {$nor} width=100>" . $reunion['fecha'] . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit}>Asistentes: </td>\n\t\t\t<td {$nor}> " . $reunion['asistentes'] . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit}>" . html_entity_decode("Objeto de la reuni&oacute;n") . ": </td>\n\t\t\t<td {$nor}>" . $reunion['objeto'] . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit}>" . html_entity_decode("Fecha siguiente reuni&oacute;n") . ": </td>\n\t\t\t<td {$nor}>" . $reunion['fechasig'] . ", " . $reunion['horasig'] . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit}>Departamento: </td><td {$nor}>" . $reunion['departamento'] . "</td>\n\t\t</tr>\n\t</table>";
 $p->HTMLtable($tabla);
 $p->Ln(5);
 $temas_tratados = select_normal("Select * from kz_tec_dir_temasreunion where idreunion  = " . $reunion['id'] . "");
 $tabla = "<table border=1>\n\t\t<tr>\n\t\t\t<td {$tit} width=191>" . html_entity_decode("&Oacute;rden del d&iacute;a") . "</td>\n\t\t\t<td {$tit} width=13>Cerrado</td>\n\t\t</tr>";
 if ($temas_tratados) {
     foreach ($temas_tratados as $key => $valor) {
         $tema = select_normal("Select * from kz_tec_dir_temas where id=" . $valor['idtema'] . "");
         $tema = $tema[0];
         $tabla .= "<tr>\n\t\t\t\t<td {$nor}>" . $tema['tema'] . "</td>\n\t\t\t\t<td {$nor}>" . siono($valor['cerrado']) . "</td>\n\t\t\t</tr>";
     }
 }
 $tabla .= "</table>";
 $p->HTMLtable($tabla);
 $p->ln(5);
 $dec = select_normal("Select * from kz_tec_dir_decisionesreunion a, kz_tec_dir_decisiones b where idreunion=" . $reunion['id'] . " and a.iddecision=b.id");
 $tabla = "<table border=1>\n\t\t<tr>\n\t\t\t<td {$tit} width=132>" . html_entity_decode("Decisi&oacute;n adoptada") . "</td>\n\t\t\t<td {$tit} width=55>Responsable</td>\n\t\t\t<td {$tit} width=17>Plazo</td>\n\t\t</tr>";
 if ($dec) {
     foreach ($dec as $keydec => $valordec) {
         $tabla .= "<tr>\n\t\t\t\t<td {$nor}>" . $valordec['decision'] . "</td>\n\t\t\t\t<td {$nor}>" . $valordec['responsable'] . "</td>\n\t\t\t\t<td {$nor}>" . $valordec['plazo'] . "</td>\n\t\t\t</tr>";
     }
 }
 $tabla .= "</table>";
 $p->HTMLtable($tabla);
 $p->output();
                 $tabla .= "</table>";
                 $color1 = '5F5F5F';
                 $color2 = 'FFFFFF';
                 $tit = "bgcolor=#{$color1} color=#{$color2} valign=middle style=bold height=4";
                 $p->HTMLtable($tabla);
                 $tabla = "<table>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td {$tit}>" . $valor['tipo_accion'] . "</td>\n\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t</table>";
                 $p->ln(5);
                 $p->htmltable($tabla);
                 $color1 = 'A6A6A6';
                 $color2 = 'FFFFFF';
                 $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=8";
                 $nor = "align=center height=5 valign=middle";
                 $tabla = "<table border=1>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td {$tit} width=20>Num NC</td>\n\t\t\t\t\t\t\t\t\t<td {$tit} width=23>Fecha apertura</td>\n\t\t\t\t\t\t\t\t\t<td {$tit} width=140>Causa probable</td>\n\t\t\t\t\t\t\t\t\t<td {$tit} width=54>" . html_entity_decode("Tipo acci&oacute;n") . "</td>\n\t\t\t\t\t\t\t\t\t<td {$tit} width=15>Coste</td>\n\t\t\t\t\t\t\t\t\t<td {$tit} width=19>Fecha cierre</td>\n\t\t\t\t\t\t\t\t\t<td {$tit} width=19>Cierre eficaz</td>\n\t\t\t\t\t\t\t\t</tr>";
             }
         }
         $tabla .= "<tr>\n\t\t\t\t\t\t<td {$nor}>" . $ARRAY_NC[$valor['num_nc']] . "</td>\n\t\t\t\t\t\t<td {$nor}>" . $valor['fecha_apertura'] . "</td>\n\t\t\t\t\t\t<td {$nor}>" . $valor['causa_probable'] . "</td>\n\t\t\t\t\t\t<td {$nor}>" . $valor['tipo_accion'] . "</td>\n\t\t\t\t\t\t<td {$nor}>" . $valor['coste'] . "</td>\n\t\t\t\t\t\t<td {$nor}>" . $valor['fecha_cierre'] . "</td>\n\t\t\t\t\t\t<td {$nor}>" . siono($valor['cierre_eficaz']) . "</td>\n\t\t\t\t\t</tr>";
         $tipo_accion_ul = $valor['tipo_accion'];
     }
     $coste[$valor['tipo_accion']] = $coste[$valor['tipo_accion']] + $valor['coste'];
     $sumacoste = $sumacoste + $valor['coste'];
 }
 if ($_POST['modo_resumen']) {
     $tabla .= "</table>";
     $p->HTMLtable($tabla);
 }
 $p->ln(5);
 foreach ($coste as $keycoste => $valorcoste) {
     $p->Cell(40, 5, "COSTE de -> {$keycoste}: {$valorcoste} euros", 0, 1);
 }
 $p->ln(5);
 $p->Cell(40, 5, "COSTE TOTAL OCASIONADO: {$sumacoste} euros", 0, 1);
 $p->SetTitle(date("d-m-Y") . "_informe_objetivos");
 $p->SetFillColor(255, 255, 255);
 $p->SetTextColor(0, 0, 0);
 $p->SetDrawColor(0, 0, 0);
 $tit = "bgcolor = #b5d6ff";
 $color1 = '5F5F5F';
 $color2 = 'FFFFFF';
 $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=4";
 $tabla = "<table border=1>";
 $tabla .= "<tr>\n\t\t\t\t\t<td {$tit} width=25>OBJETIVO</td>\n\t\t\t\t</tr>\n\t\t\t</table>";
 $color1 = 'A6A6A6';
 $color2 = 'FFFFFF';
 $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=8";
 $contenido = "align=center height=5 valign=middle";
 $tabla .= "<table border=1>\n\t\t\t\t<tr>\n\t\t\t\t\t<td {$tit} width=35>Objetivo</td>\n\t\t\t\t\t<td {$tit} width=27>" . html_entity_decode("Fecha de creaci&oacute;n") . "</td>\n\t\t\t\t\t<td {$tit} width=9>" . html_entity_decode("A&ntilde;o") . "</td>\n\t\t\t\t\t<td {$tit} width=186>" . html_entity_decode("Descripci&oacute;n") . "</td>\n\t\t\t\t\t<td {$tit} width=17>Plazo</td>\n\t\t\t\t\t<td {$tit} width=16>Cumplido</td>\n\t\t\t\t</tr>";
 $tabla .= "<tr>\n\t\t\t\t\t<td {$contenido}>" . $valor['objetivo'] . "</td>\n\t\t\t\t\t<td {$contenido}>" . $valor['fechacreacion'] . "</td>\n\t\t\t\t\t<td {$contenido}>" . $valor['anno'] . "</td>\t\n\t\t\t\t\t<td {$contenido}>" . $valor['descripcion'] . "</td>\n\t\t\t\t\t<td {$contenido}>" . $valor['plazoconsecucion'] . "</td>\n\t\t\t\t\t<td {$contenido}>" . siono($valor['cumplido']) . "</td>\t\n\t\t\t\t</tr>";
 $tabla .= "</table>";
 $p->htmltable($tabla);
 $p->SetMargins(10, 43, 0);
 $p->ln(5);
 if ($_POST['seg_obj']) {
     $seg_obj = select_normal("Select * from kz_tec_dir_seguimientoobjetivos where objetivo like '" . $valor['id'] . "' order by fecha");
     if ($seg_obj) {
         $color1 = '5F5F5F';
         $color2 = 'FFFFFF';
         $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=4";
         $tabla2 = "<table border=1>";
         $tabla2 .= "<tr>\n\t\t\t\t\t\t\t<td {$tit} width=55>SEGUIMIENTOS DEL OBJETIVO</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>";
         $p->htmltable($tabla2);
         $color1 = 'A6A6A6';
         $color2 = 'FFFFFF';
        ?>
</td>
	         <td><?php 
        echo $valor_rev['soporte'];
        ?>
</td>
	         <td><?php 
        echo $valor_rev['realizado'];
        ?>
</td>
	         <td><?php 
        echo $valor_rev['aprobado'];
        ?>
</td>
	         <td><?php 
        echo siono($valor_rev["vigor"]);
        ?>
</td>
	         <td><?php 
        echo $valor_rev['cambio'];
        ?>
</td>
	         <td><?php 
        $periodo = explode(',', $valor_rev['periodo']);
        echo $periodo[0] . " a&ntilde;os, " . $periodo[1] . " meses";
        ?>
			 </td>
	         <td><?php 
        echo $valor_rev['lugar'];
        ?>
</td>
                        $p->Cell(0, 3, "Cantidad total de NC: " . count($nc), 0, 1);
                        $p->Ln(5);
                        $color1 = 'A6A6A6';
                        $color2 = 'FFFFFF';
                        $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=8";
                        $nor = "align=center height=5 valign=middle";
                        $tabla = "<table border=1>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit} width=40>CNC:</td>\n\t\t\t\t\t    \t\t<td {$nor} width=80> " . $valor['cnc'] . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>Origen del problema:</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['tipoNC'] . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>" . html_entity_decode("Especificaci&oacute;n de origen") . ":</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['detectada_en'] . "</td>\n\t\t\t\t\t    \t</tr>    \t\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>" . html_entity_decode("Clasificaci&oacute;n de origen") . ":</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['detectada_por'] . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>Detectada por:</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['detectada_por_'] . "</td>\n\t\t\t\t\t    \t</tr>   \t\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>" . html_entity_decode("Fecha de detecci&oacute;n") . ":</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['fecha_deteccion'] . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>Orden / Pedido:</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['orden_pedido'] . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    </table>";
                        $p->htmltable($tabla);
                        $p->ln(5);
                        $tabla = "<table border=1>\n\t\t\t\t\t\t    <tr>\n\t\t\t\t\t\t    \t<td {$tit} width=70>" . html_entity_decode("Descripci&oacute;n del problema &iquest;Qu&eacute; ha pasado?") . ":</td>\n\t\t\t\t\t\t    \t<td {$nor} width=134> " . $valor['descripcion'] . "</td>\n\t\t\t\t\t\t    </tr>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>Causa estimada:</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['causa_estimada'] . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>" . html_entity_decode("Soluci&oacute;n a tomar: &iquest;Qu&eacute; hago para solucionarlo?") . "</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['tratamiento'] . "</td>\n\t\t\t\t\t    \t</tr>    \t\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>" . html_entity_decode("Responsable tratamiento: &iquest;Qui&eacute;n lo hace?") . "</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['responsable'] . "</td>\n\t\t\t\t\t    \t</tr>    \t\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>" . html_entity_decode("&iquest;Cu&aacute;ndo tiene que estar hecho?") . "</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['fecha_prevista'] . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>" . html_entity_decode("Seguimiento realizado de la soluci&oacute;n adoptada") . ":</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . $valor['seguimiento'] . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td {$tit}>" . html_entity_decode("Fecha cierre: &iquest;Cu&aacute;ndo se ha hecho?") . ":</td>\n\t\t\t\t\t\t\t\t<td {$nor}>" . $valor['fecha_cierre'] . "</td>\n\t\t\t\t\t\t\t</tr>  \n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td {$tit}>Cierre eficaz: </td>\n\t\t\t\t\t\t\t\t<td {$nor}>" . siono($valor['cierre_eficaz']) . "</td>\n\t\t\t\t\t\t\t</tr>    \t\n\t\t\t\t\t    </table>";
                        $p->htmltable($tabla);
                        $p->ln(5);
                        $tabla = "<table border=1 >\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit} width=30>Coste ocasionado:</td>\n\t\t\t\t\t    \t\t<td {$nor} width=20> " . $valor['coste'] . " euros</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>Maquinaria</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . siono($valor['maquinaria']) . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>Mano de obra</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . siono($valor['mano_obra']) . "</td>\n\t\t\t\t\t    \t</tr>    \t\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>Materia prima</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . siono($valor['materia_prima']) . "</td>\n\t\t\t\t\t    \t</tr>    \t\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>Mediciones</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . siono($valor['mediciones']) . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    \t<tr>\n\t\t\t\t\t    \t\t<td {$tit}>" . html_entity_decode("M&eacute;todos") . "</td>\n\t\t\t\t\t    \t\t<td {$nor}>" . siono($valor['metodos']) . "</td>\n\t\t\t\t\t    \t</tr>\n\t\t\t\t\t    </table>";
                        $p->htmltable($tabla);
                    } else {
                        $tabla .= "<tr>\n\t\t\t\t\t\t\t<td {$nor}>" . $valor['cnc'] . "</td>\n\t\t\t\t\t\t\t<td {$nor}>" . $valor['fecha_deteccion'] . "</td>\n\t\t\t\t\t\t\t<td {$nor}>" . $valor['tipoNC'] . "</td>\n\t\t\t\t\t\t\t<td {$nor}>" . $valor['detectada_en'] . "</td>\n\t\t\t\t\t\t\t<td {$nor}>" . $valor['detectada_por'] . "</td>\n\t\t\t\t\t\t\t<td {$nor}>" . $valor['detectada_por_'] . "</td>\n\t\t\t\t\t\t\t<td {$nor}>" . $valor['descripcion'] . "</td>\n\t\t\t\t\t\t\t<td {$nor}>" . $valor['coste'] . "</td>\n\t\t\t\t\t\t\t<td {$nor}>" . $valor['unidades'] . "</td>\n\t\t\t\t\t\t\t<td {$nor}>" . $valor['fecha_cierre'] . "</td>\n\t\t\t\t\t\t\t<td {$nor}>" . siono($valor['cierre_eficaz']) . "</td>\n\t\t\t\t\t\t</tr>";
                    }
                    $sumacoste = $sumacoste + $valor['coste'];
                }
                if ($_POST['modo_resumen']) {
                    $tabla .= "</table>";
                    $p->HTMLtable($tabla);
                }
                $p->ln(5);
                $p->Cell(40, 10, "COSTE TOTAL OCASIONADO: {$sumacoste} euros", 0, 1);
            }
            $p->output();
        }
    }
} else {
    echo "<script>alert('No se puede mostrar el informe. No hay No Conformidades.');</script>";
        echo $titulo;
        ?>
</td></table>
	<?php 
    }
    $color1 = 'A6A6A6';
    $color2 = 'FFFFFF';
    $clasetd = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=8";
    $clasetd2 = "align=center height=5 valign=middle";
    $tablam .= "<table border=1>\n\t\t<tr>\n\t\t\t<td {$clasetd} width=26>Tipo documento</td>\n\t\t\t<td {$clasetd} width=18>" . html_entity_decode("C&oacute;digo") . "</td>\n\t\t\t<td {$clasetd} width=33>Nombre</td>\n\t\t\t<td {$clasetd} width=49>" . html_entity_decode("Descripci&oacute;n") . "</td>\n\t\t\t<td {$clasetd} width=23>Tipo</td>\n\t\t\t<td {$clasetd} width=23>Soporte</td>\n\t\t\t<td {$clasetd} width=21>Generado</td>\n\t\t\t<td {$clasetd} width=21>Aprobado</td>\n\t\t\t<td {$clasetd} width=17>Fecha</td>\n\t\t\t<td {$clasetd} width=26>Periodo</td>\n\t\t\t<td {$clasetd} width=16>Lugar</td>\n\t\t\t<td {$clasetd} width=10>Vigor</td>\n\t\t\t<td {$clasetd} width=7>Int.</td>\n\t\t</tr>";
    $tablam .= "";
    foreach ($documentos as $key => $valor) {
        if ($_POST['vigor'] != '' && $_POST['vigor'] == $valor['vigor'] || $_POST['vigor'] == '') {
            $periodo = explode(',', $valor['periodo']);
            $periodo = $periodo[0] . " " . html_entity_decode("a&ntilde;os") . ", " . $periodo[1] . " meses";
            $tablam .= "<tr>\n\t\t\t\t\t<td {$clasetd2}>" . $valor['tipo'] . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . $valor['cod'] . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . $valor['nombre'] . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . $valor['descripcion'] . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . $valor['tipo_doc'] . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . $valor['soporte'] . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . $valor['generado'] . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . $valor['aprobado'] . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . $valor['fecha'] . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . $periodo . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . $valor['lugar'] . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . siono($valor['vigor']) . "</td>\n\t\t\t\t\t<td {$clasetd2}>" . siono($valor['interno']) . "</td>\n\t\t\t\t</tr>";
        }
    }
    $tablam .= "</table>";
    if ($_POST['xls']) {
        echo $tabladocs . $tablam;
    }
    if ($_POST['pdf']) {
        require FPDF_PDF_RUTA . 'lib/pdftable.inc.php';
        $p = new PDFTable('P');
        $p->SetMargins(3, 43, 0);
        $p->AddPage('L');
        $p->SetMargins(3, 10, 0);
        $p->titulo(5, $titulo);
        $p->setfont('Arial', '', 8);
        $p->SetTitle(date("d-m-Y") . "_informe");
    $cuestionario = $cuestionario[0];
    $color1 = 'A6A6A6';
    $color2 = 'FFFFFF';
    $color3 = 'CECECE';
    $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=8";
    $tit2 = "bgcolor=#{$color3} color=#{$color2} align=center valign=middle style=bold height=8";
    $nor = "align=center height=5 valign=middle";
    $tabla .= "<table border=1>\n\t\t<tr>\n\t\t\t<td {$tit} width=50>Cliente / Bezeroa: </td>\n\t\t\t<td {$nor} width=52>" . $cuestionario['organizacion'] . "</td>\n\t\t\t<td {$tit} width=50>Comercial / Komertziala: </td>\n\t\t\t<td {$nor} width=52>" . $cuestionario['comercial'] . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit}>Nombre / Izena: </td>\n\t\t\t<td {$nor}>" . $cuestionario['nombre'] . "</td>\n\t\t\t<td {$tit}>Apellido / Abizena: </td>\n\t\t\t<td {$nor}>" . $cuestionario['apellidos'] . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit}>Fecha encuesta / Inkesta data: </td>\n\t\t\t<td {$nor}>" . $cuestionario['fechaencuesta'] . "</td>\n\t\t\t<td {$tit}>Fecha respuesta / Erantzute data: </td>\n\t\t\t<td {$nor}>" . $cuestionario['fecharespuesta'] . "</td>\n\t\t</tr>\n\t</table>";
    $p->HTMLtable($tabla);
    $p->Ln(5);
    $aspectos = select_normal("Select kz_tec_mej_campos.id, kz_tec_mej_campos.descripcion, kz_tec_mej_valoraciones.campo from kz_tec_mej_campos, kz_tec_mej_valoraciones WHERE kz_tec_mej_campos.id = kz_tec_mej_valoraciones.campo AND kz_tec_mej_valoraciones.idencuesta='" . $cuestionario['id'] . "'");
    $tabla = "<table border=1>\n\t\t<tr>\n\t\t\t<td {$tit} width=70>Aspecto a valorar / Baloratu beharrekoa</td>\n\t\t\t<td {$tit} width=34>" . html_entity_decode("Valoraci&oacute;n") . " / Balorazioa</td>\n\t\t\t<td {$tit} width=60>" . html_entity_decode("Valoraci&oacute;n") . " frente a la comp. / Balorazioa konpetentziarekiko</td>\n\t\t\t<td {$tit} width=40>Importancia / Garrantzia</td>\n\t\t</tr>";
    if ($aspectos) {
        foreach ($aspectos as $key => $valor) {
            $valoraciones = select_normal("Select * from kz_tec_mej_valoraciones where idencuesta='" . $cuestionario['id'] . "' and campo = '" . $valor['id'] . "'");
            $valoraciones = $valoraciones[0];
            $tabla .= "<tr>\n\t\t\t\t<td {$nor} align=left>" . $valor['descripcion'] . "</td>\n\t\t\t\t<td {$nor}>" . $valoraciones['valoracion'] . "</td>\n\t\t\t\t<td {$nor}>" . $valoraciones['valcompetencia'] . "</td>\n\t\t\t\t<td {$nor}>" . siono($valoraciones['aspectoimportante']) . "</td>\n\t\t\t\t</tr>";
        }
    }
    $tabla .= "</table>";
    $p->HTMLtable($tabla);
    $p->ln(5);
    $motivos = select_normal("Select * from kz_tec_mej_motivosencuesta where idencuesta = '" . $cuestionario['id'] . "'");
    $valormotivos = $motivos[0];
    $tabla = "<table border=1>\n\t\t<tr>\n\t\t\t<td {$tit} colspan=2>Motivos de compra</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit2} width=25>Calidad</td>\n\t\t\t<td {$nor} width=40>" . siono($valormotivos['calidad']) . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit2}>Precio</td>\n\t\t\t<td {$nor}>" . siono($valormotivos['precio']) . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit2}>Confianza</td>\n\t\t\t<td {$nor}>" . siono($valormotivos['confianza']) . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit2}>" . html_entity_decode("Atenci&oacute;n") . "</td>\n\t\t\t<td {$nor}>" . siono($valormotivos['atencion']) . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit2}>Servicio</td>\n\t\t\t<td {$nor}>" . siono($valormotivos['servicio']) . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit2}>" . html_entity_decode("Cercan&iacute;a") . "</td>\n\t\t\t<td {$nor}>" . siono($valormotivos['cercania']) . "</td>\n\t\t</tr>\t\t\t\n\t\t<tr>\n\t\t\t<td {$tit2}>Experiencia</td>\n\t\t\t<td {$nor}>" . siono($valormotivos['experiencia']) . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit2}>Otros</td>\n\t\t\t<td {$nor}>" . $valormotivos['otros'] . "</td>\n\t\t</tr>\n\t</table>";
    $p->HTMLtable($tabla);
    $p->ln(5);
    $tabla = "<table border=1>\n\t\t<tr>\n\t\t\t<td {$tit} height=15 width=25>Sugerencias: </td>\n\t\t\t<td {$nor} width=179>" . $cuestionario['sugerencias'] . "</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td {$tit} height=15>" . html_entity_decode("An&aacute;lisis") . ": </td>\n\t\t\t<td {$nor}>" . $cuestionario['analisis'] . "</td>\n\t\t</tr>\n\t</table>";
    $p->HTMLtable($tabla);
    $p->output();
}