//          http://www.gnu.org/copyleft/gpl.html                         //
//                                                                       //
///////////////////////////////////////////////////////////////////////////
require '../../../functions/globales.php';
require '../include/rutas.php';
require '../functions/main.php';
require '../struct/login2.php';
require '../functions/doc_functions.php';
if ($_POST['pdf']) {
    require FPDF_PDF_RUTA . 'lib/pdftable.inc.php';
    $p = new PDFTable('P');
    $p->SetMargins(3, 43, 0);
    $p->SetTitle(date("d-m-Y") . "_revision_direccion");
    $p->SetFillColor(255, 255, 255);
    $p->SetTextColor(0, 0, 0);
    $p->SetDrawColor(0, 0, 0);
    $doc_real = select_normal("Select * from kz_tec_doc_documentos_reales where id = " . $_POST['documento_real'] . "");
    $doc_real = $doc_real[0];
    $p->AddPage('P');
    $p->SetMargins(10, 10, 0);
    $p->setfont('Arial', 'B', 12);
    $color1 = 'A6A6A6';
    $color2 = 'FFFFFF';
    $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=8";
    $nor = "align=center height=5 valign=middle";
    $p->cell(0, 0, $doc_real['titulo'], 0, 0, 'C');
    $p->ln(15);
    $p->setfont('Arial', '', 10);
    $p->MultiCell(188, 5, $doc_real['contenido'], 0, 'J');
    $p->output();
}
 $p->SetTextColor(0, 0, 0);
 $p->SetDrawColor(0, 0, 0);
 $manual = select_normal("Select * from kz_tec_doc_procedimientos WHERE 1=1 {$filtros}");
 if ($manual) {
     foreach ($manual as $key => $valor) {
         $p->AddPage('P');
         $p->SetMargins(3, 10, 0);
         $p->titulo(5, $titulo);
         $p->setfont('Arial', '', 8);
         $color1 = '5F5F5F';
         $color2 = 'FFFFFF';
         $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=4";
         $p->SetFont('Arial', 'B', 8);
         $p->SetTextColor(255, 255, 255);
         $p->SetFillColor(166, 166, 166);
         $p->MultiCell(204, 8, "Objeto", 1, "C", true);
         $p->SetTextColor(0, 0, 0);
         $p->SetFont('Arial', '', 7);
         $p->MultiCell(204, 4, $valor['objeto'], 1, "L", false);
         $p->ln(5);
         $p->SetFont('Arial', 'B', 8);
         $p->SetTextColor(255, 255, 255);
         $p->SetFillColor(166, 166, 166);
         $p->MultiCell(204, 8, "Alcance", 1, "C", true);
         $p->SetTextColor(0, 0, 0);
         $p->SetFont('Arial', '', 7);
         $p->MultiCell(204, 3, $valor['alcance'], 1, "L", false);
         $p->ln(5);
         $p->SetFont('Arial', 'B', 8);
         $p->SetTextColor(255, 255, 255);
         $p->SetFillColor(166, 166, 166);
 if ($rev) {
     foreach ($rev as $key => $valor) {
         $p->AddPage('P');
         $p->SetMargins(3, 10, 0);
         $p->titulo(5, $titulo);
         $p->setfont('Arial', '', 8);
         $color1 = '5F5F5F';
         $color2 = 'FFFFFF';
         $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=4";
         $tabla = "<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td {$tit} width=204>" . $valor['fecha'] . "</td>\n\t\t\t\t</tr>\n\t\t\t</table>";
         $p->htmltable($tabla);
         $p->ln(5);
         $p->SetFont('Arial', 'B', 8);
         $p->SetTextColor(255, 255, 255);
         $p->SetFillColor(166, 166, 166);
         $p->MultiCell(204, 8, "Asistentes", 1, "C", true);
         $p->SetTextColor(0, 0, 0);
         $p->SetFont('Arial', '', 7);
         $p->MultiCell(204, 4, $valor['asistentes'], 1, "C", false);
         $p->ln(5);
         $p->SetFont('Arial', 'B', 8);
         $p->SetTextColor(255, 255, 255);
         $p->SetFillColor(166, 166, 166);
         $p->MultiCell(204, 8, "Resultado de auditoria", 1, "C", true);
         $p->SetTextColor(0, 0, 0);
         $p->SetFont('Arial', '', 7);
         $p->MultiCell(204, 3, $valor['resultado'], 1, "L", false);
         $p->ln(5);
         $p->SetFont('Arial', 'B', 8);
         $p->SetTextColor(255, 255, 255);
         $p->SetFillColor(166, 166, 166);
$titulo = "" . html_entity_decode("Pol&iacute;tica de Calidad") . "";
if ($_POST['politica'] != '') {
    $filtropolitica = " where id = " . $_POST['politica'] . "";
}
$politicas = select_normal("SELECT * FROM kz_tec_dir_politicas {$filtropolitica} order by nombre asc");
if ($politicas) {
    if ($_POST['pdf']) {
        require FPDF_PDF_RUTA . 'lib/pdftable.inc.php';
        $p = new PDFTable('P');
        $p->SetMargins(15, 43, 300);
        foreach ($politicas as $key => $valor) {
            $p->AddPage('P');
            $p->SetMargins(15, 10, 170);
            $p->titulo(5, $titulo);
            $p->setfont('Arial', '', 12);
            $p->SetTitle(date("d-m-Y") . "_informe");
            $p->SetFillColor(255, 255, 255);
            $p->SetTextColor(0, 0, 0);
            $p->SetDrawColor(0, 0, 0);
            $p->SetTextColor(0, 0, 0);
            $p->SetFont('Arial', '', 12);
            $p->MultiCell(180, 5, $valor['politica'], 0, "J", false);
            $p->ln(15);
            $p->MultiCell(180, 6, $valor['fecha'], 0, "R", false);
        }
        $p->output();
    }
} else {
    echo "<script>alert('No se puede mostrar el informe. " . html_entity_decode("No hay pol&iacute;tica") . ".');</script>";
    echo "<script>window.close();</script>";
}
 $p->SetTextColor(0, 0, 0);
 $p->SetDrawColor(0, 0, 0);
 $manual = select_normal("Select * from kz_tec_doc_manual WHERE 1=1 {$filtros}");
 if ($manual) {
     foreach ($manual as $key => $valor) {
         $p->AddPage('P');
         $p->SetMargins(3, 10, 0);
         $p->titulo(5, $titulo);
         $p->setfont('Arial', '', 8);
         $color1 = '5F5F5F';
         $color2 = 'FFFFFF';
         $tit = "bgcolor=#{$color1} color=#{$color2} align=center valign=middle style=bold height=4";
         $p->SetFont('Arial', 'B', 8);
         $p->SetTextColor(255, 255, 255);
         $p->SetFillColor(166, 166, 166);
         $p->MultiCell(204, 8, "" . html_entity_decode("Presentaci&oacute;n") . " de la empresa y su actividad", 1, "C", true);
         $p->SetTextColor(0, 0, 0);
         $p->SetFont('Arial', '', 7);
         $p->MultiCell(204, 4, $valor['presentacion_empresa'], 1, "L", false);
         $p->ln(5);
         $p->SetFont('Arial', 'B', 8);
         $p->SetTextColor(255, 255, 255);
         $p->SetFillColor(166, 166, 166);
         $p->MultiCell(204, 8, "" . html_entity_decode("Pol&iacute;tica") . " de calidad de la " . html_entity_decode("organizaci&oacute;n") . "", 1, "C", true);
         $p->SetTextColor(0, 0, 0);
         $p->SetFont('Arial', '', 7);
         $p->MultiCell(204, 3, $valor['politica_calidad'], 1, "L", false);
         $p->ln(5);
         $p->SetFont('Arial', 'B', 8);
         $p->SetTextColor(255, 255, 255);
         $p->SetFillColor(166, 166, 166);