function verRpteExcel()
 {
     $id = VAR3;
     $where = "";
     $tab_extransferencia = new tab_exptransferencia();
     $result = $tab_extransferencia->dbSelectBySQL("select* from tab_exptransferencia where str_id={$id}");
     $cantidad = count($result);
     $valor3 = "";
     $t = 1;
     foreach ($result as $row) {
         $valor3 .= "tab_expediente.exp_id={$row->exp_id}";
         if ($t < $cantidad) {
             $valor3 .= " or ";
         }
         $t++;
     }
     $where .= " AND {$valor3} ";
     $sql = "SELECT\r\n            f.fon_codigo,\r\n            f.fon_cod,\r\n            (SELECT fon_codigo from tab_fondo WHERE fon_id=f.fon_par) ||'.'|| f.fon_codigo ||'.'||tab_unidad.uni_cod ||'.'|| tab_tipocorr.tco_codigo ||'.'||tab_series.ser_codigo||'.'||\r\n            tab_expediente.exp_codigo AS codigo,\r\n            (NULLIF(tab_expediente.exp_codigo,'')::int) as cantidad,\r\n            tab_soltransferencia.str_id,\r\n            tab_soltransferencia.str_fecha,\r\n            tab_soltransferencia.uni_id,\r\n            tab_soltransferencia.unid_id,\r\n            tab_soltransferencia.str_nrocajas,\r\n            tab_soltransferencia.str_totpzas,\r\n            tab_soltransferencia.str_totml,\r\n            tab_soltransferencia.str_nroreg,\r\n            tab_soltransferencia.str_fecini,\r\n            tab_soltransferencia.str_fecfin,\r\n            tab_soltransferencia.str_estado,\r\n            tab_soltransferencia.usu_id,\r\n            tab_soltransferencia.usud_id,\r\n            tab_soltransferencia.str_direccion,\r\n            tab_soltransferencia.str_telefono,\r\n            tab_expisadg.exp_fecha_exi,\r\n            tab_expisadg.exp_fecha_exf,\r\n            tab_expisadg.exp_anioi,\r\n            tab_expisadg.exp_aniof,\r\n            tab_expisadg.exp_titulo,\r\n            tab_series.ser_codigo,\r\n            tab_unidad.uni_codigo,\r\n            tab_unidad.uni_id,\r\n            tab_unidad.uni_par,\r\n            tab_unidad.uni_cod,\r\n            tab_unidad.uni_descripcion,\r\n            f.fon_cod,\r\n            tab_series.ser_categoria,\r\n            tab_expisadg.exp_titulo,\r\n            tab_expediente.exp_obs,\r\n            tab_series.ser_id,\r\n            tab_series.ser_par,\r\n            tab_expediente.exp_id\r\n            FROM\r\n            tab_unidad\r\n            INNER JOIN tab_fondo as f ON tab_unidad.fon_id = f.fon_id\r\n            INNER JOIN tab_series ON tab_series.uni_id = tab_unidad.uni_id\r\n            INNER JOIN tab_expediente ON tab_expediente.ser_id = tab_series.ser_id\r\n            INNER JOIN tab_expisadg ON tab_expisadg.exp_id = tab_expediente.exp_id\r\n            INNER JOIN tab_exptransferencia ON tab_expediente.exp_id = tab_exptransferencia.exp_id\r\n            INNER JOIN tab_soltransferencia ON tab_soltransferencia.str_id = tab_exptransferencia.str_id\r\n            INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n            WHERE\r\n            tab_soltransferencia.str_estado = 2 AND\r\n            tab_expediente.exp_estado = 1 {$where} order by tab_expediente.exp_id ";
     $usua = new usuario();
     $subfondo = new fondo();
     $seccion = new unidad();
     $expedientes = new expediente();
     $archivo = new tab_archivo();
     $archivo2 = new tab_archivo();
     $query = $archivo->dbSelectBySQL($sql);
     $query2 = $archivo2->dbSelectBySQL($sql);
     foreach ($query2 as $ids) {
         $usu_id = $ids->usu_id;
         $uni_id = $ids->uni_id;
         $uni_par = $ids->uni_par;
         $uni_cod = $ids->uni_cod;
         $str_telefono = $ids->str_telefono;
         $str_id = $ids->str_id;
         $str_fecha = $ids->str_fecha;
         $str_direccion = $ids->str_direccion;
         $uni_descripcion = $ids->uni_descripcion;
     }
     $usuarioOrigen = $usua->obtenerNombre($usu_id);
     $usuarioDestino = $usua->obtenerNombre($usu_id);
     $fond = $subfondo->obtenerfon($usu_id);
     $ob_seccion = $seccion->obtenerSeccion($uni_id);
     $cadena = "";
     $cadena = "<br/><br/><br/><br/><br/><br/><br/>";
     $cadena .= '<table width="740" border="1">';
     $cadena .= '<tr>';
     $cadena .= '<td colspan="10" align="center" ><b>';
     $cadena .= 'FORMULARIO DE RELACION DE TRANSFERENCIAS</b><br /></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr>';
     $cadena .= '<td colspan="9" align="right" style=border:none ><b>';
     $cadena .= 'Nº de transferencia:</b></td><td align="center">' . $str_id . '</td>';
     $cadena .= '</tr>';
     //    $cadena.='<tr>';
     //  $cadena.='<td colspan="10" align="right" ><b>';
     //  $cadena.='<b>Nº de transferencia:</b> '.$str_id.'</td>';
     //  $cadena.='</tr>';
     $cadena .= '<tr>';
     $cadena .= '<td colspan="5"><blockquote>';
     $cadena .= '<b>Subfondo:</b> ' . $fond . '<br />';
     $cadena .= '<b>Secci&oacute;n:</b> ';
     $explode = explode(".", $uni_cod);
     $contado = count($explode);
     $codigo = "";
     for ($t = 0; $t < $contado - 1; $t++) {
         $codigo .= $explode[$t];
         if ($t < $contado - 2) {
             $codigo .= ".";
         }
     }
     $codigo2 = $codigo;
     if (strlen($codigo) == 1) {
         $codigo = $codigo . ".0";
     } else {
         $estraer_codigo = explode(".", $codigo);
         $codigo = $estraer_codigo[0] . ".0";
     }
     $tab_unidad = new Tab_unidad();
     $unidad = new unidad();
     $sqlUni2 = "SELECT\r\n                    tab_unidad.uni_descripcion\r\n                    FROM\r\n                    tab_unidad\r\n                    WHERE\r\n                    tab_unidad.uni_cod = '{$codigo}'";
     $codigoss = explode(".", $codigo2);
     $cantcodigo2 = count($codigoss);
     if ($cantcodigo2 == 1) {
         $codigo2 = "{$codigo2}.1";
     }
     $sqlUni1 = "SELECT\r\n                    tab_unidad.uni_descripcion\r\n                    FROM\r\n                    tab_unidad\r\n                    WHERE\r\n                    tab_unidad.uni_cod = '{$codigo2}'";
     $resultadott = $tab_unidad->dbSelectBySQL($sqlUni2);
     $resultadott1 = $tab_unidad->dbSelectBySQL($sqlUni1);
     $ca1 = "";
     foreach ($resultadott1 as $rowss2) {
         $ca1 = $rowss2->uni_descripcion;
     }
     foreach ($resultadott as $rowss) {
         $ca = $rowss->uni_descripcion;
     }
     $variable = $ca;
     $excluirparent = explode("(", $variable);
     if ($excluirparent[1] == "") {
         $ca = $ca;
     } else {
         $excluirultimoparent = $excluirparent[1] . "x";
         $imprimir_descripcion = explode(")", $excluirultimoparent);
         $ca = $imprimir_descripcion[0];
     }
     $ca = $unidad->obtenerPadre($uni_par, $uni_descripcion);
     $cadena .= $ca;
     $cadena .= '<br><b>Subsecci&oacute;n:</b> ';
     $cadena .= $ca1;
     $cadena .= '</blockquote></td>';
     //$cadena.='<td colspan="5"  ><blockquote><b>Unidad:</b> '.$uni_descripcion;
     $cadena .= '<td colspan="5"  ><blockquote>';
     $cadena .= '<br /><b>Tel&eacute;fono:</b> ' . $str_telefono . '</blockquote></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr>';
     $cadena .= '<td width="20" rowspan="2" align="center" bgcolor="#CCCCCC"><strong>Nº</strong></td>';
     $cadena .= '<td width="105" rowspan="2" style="text-align:center" bgcolor="#CCCCCC"><strong>Serie</strong></td>';
     $cadena .= '<td width="120" rowspan="2" style="text-align:center" bgcolor="#CCCCCC"><strong>Subserie</strong></td>';
     $cadena .= '<td width="125" rowspan="2" style="text-align:center" bgcolor="#CCCCCC"><strong>T&iacute;tulo del Expediente</strong></td>';
     $cadena .= '<td width="80" rowspan="2" style="text-align:center" bgcolor="#CCCCCC"><strong>C&oacute;digo de Referencia</strong></td>';
     $cadena .= '<td colspan="2" width="130" style="text-align:center" bgcolor="#CCCCCC"><strong>Fechas extremas</strong></td>';
     $cadena .= '<td width="30" rowspan="2" bgcolor="#CCCCCC" style="font-size:25px"><strong >NºDoc.</strong></td>';
     $cadena .= '<td width="30" rowspan="2" bgcolor="#CCCCCC"><strong>Cajas</strong></td>';
     $cadena .= '<td width="100" rowspan="2" style="text-align:center" bgcolor="#CCCCCC"><p><strong>Observ.</strong></p></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr>';
     $cadena .= '<td width="65" style="text-align:center" bgcolor="#CCCCCC"><strong>Inicio</strong></td>';
     $cadena .= '<td width="65" style="text-align:center" bgcolor="#CCCCCC"><strong>Final</strong></td>';
     $cadena .= '</tr>';
     $sum = 0;
     $i = 1;
     $cant = 0;
     foreach ($query as $row) {
         $tabserie = new tab_series();
         if ($row->exp_fecha_exi == "") {
             $fei = "";
         } else {
             $fechainicial = explode("-", $row->exp_fecha_exi);
             $fei = $fechainicial[2] . "/" . $fechainicial[1] . "/" . $fechainicial[0];
         }
         if ($row->exp_fecha_exf == "") {
             $fef = "";
         } else {
             $fechafinal = explode("-", $row->exp_fecha_exf);
             $fef = $fechafinal[2] . "/" . $fechafinal[1] . "/" . $fechafinal[0];
         }
         $lugar = "";
         $cadena .= '<tr>';
         $cadena .= '<td align="center">' . $i . '</td>';
         $cadena .= '<td style="font-size:22px">';
         $tab_serie = new Tab_series();
         $lugar2 = "";
         if ($row->ser_par != -1) {
             $rowsdb = $tab_serie->dbselectByField("ser_id", $row->ser_par);
             foreach ($rowsdb as $fila) {
                 $ser_par = $fila->ser_par;
                 $ser_categoria = $fila->ser_categoria;
             }
             if ($ser_par != -1) {
                 $cadena .= $ser_categoria;
             } else {
                 $cadena .= $row->ser_categoria;
                 $lugar = $row->ser_categoria;
             }
         } else {
             $cadena .= $row->ser_categoria;
             $lugar2 = $row->ser_categoria;
         }
         $cadena .= '</td>';
         $cadena .= '<td style="font-size:22px">';
         if ($lugar2 != $row->ser_categoria && $row->ser_categoria != $lugar) {
             $cadena .= $row->ser_categoria;
         }
         $expsum = $expedientes->cantidadExpedientes($row->exp_id);
         //     $cajas=$expedientes->cantidadCajas($row->exp_id);
         $cant = $cant + $expsum;
         //     $sum=$sum+$cajas;
         $cadena .= '</td>';
         $cadena .= '<td align="left" style="font-size:22px">' . htmlentities($row->exp_titulo, ENT_COMPAT, 'utf-8') . '</td>';
         $cadena .= '<td align="center" style="font-size:22px">' . $row->codigo . '</td>';
         $cadena .= '<td align="center" style="font-size:22px">' . $row->exp_anioi . '</td>';
         $cadena .= '<td align="center"  style="font-size:22px">' . $row->exp_aniof . '</td>';
         $cadena .= '<td align="center" style="font-size:22px">' . $expsum . '</td>';
         $cadena .= '<td align="center"></td>';
         $cadena .= '<td style="font-size:22px">' . $row->exp_obs . '</td>';
         $cadena .= '</tr>';
         $i++;
     }
     $cadena .= '<tr>';
     $cadena .= '<td colspan="6" align="right" >TOTAL</td>';
     $cadena .= '<td align="center"></td>';
     $cadena .= '<td align="center">' . $cant . '</td>';
     $cadena .= '<td></td>';
     $cadena .= '<td>&nbsp;</td>';
     $cadena .= '</tr>';
     $cadena .= '</table>';
     $fecha = explode("-", $str_fecha);
     $anio = $fecha[0];
     $mes = $fecha[1];
     $dia = $fecha[2];
     switch ($mes) {
         case 1:
             $mes = "Enero";
             break;
         case 2:
             $mes = "Enero";
             break;
         case 3:
             $mes = "Enero";
             break;
         case 4:
             $mes = "Enero";
             break;
         case 5:
             $mes = "Enero";
             break;
         case 6:
             $mes = "Enero";
             break;
         case 7:
             $mes = "Enero";
             break;
         case 8:
             $mes = "Enero";
             break;
         case 9:
             $mes = "Enero";
             break;
         case 10:
             $mes = "Enero";
             break;
         case 11:
             $mes = "Enero";
             break;
         case 12:
             $mes = "Enero";
             break;
     }
     $cadena .= '<b>Lugar y fecha de la transferencia:</b> ' . $str_direccion . '  ' . $dia . ' de ' . $mes . ' de ' . $anio;
     $cadena .= '<br/>';
     require_once 'tcpdf/config/lang/eng.php';
     require_once 'tcpdf/tcpdf.php';
     $pdf = new TCPDF('L', PDF_UNIT, 'LETTER', true, 'UTF-8', false);
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->setFontSubsetting(FALSE);
     $pdf->SetAuthor("Castellon");
     $pdf->SetTitle('Reporte de Transferencia');
     $pdf->SetSubject('Reporte de Transferencia');
     //        aumentado
     $pdf->SetKeywords('Castellon, TEAM DIGITAL');
     // set default header data
     $pdf->SetHeaderData('logo2.png', 20, 'MPD', 'ADMINISTRADORA BOLIVIANA DE CARRETERAS (MPD)');
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     //        $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     //
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     $pdf->SetMargins(5, 30, 10);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     //        $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, 14);
     //        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set some language-dependent strings
     $pdf->setLanguageArray($l);
     $pdf->SetFont('helvetica', '', 10);
     // add a page
     $pdf->AddPage();
     //        $pdf->SetXY(110, 200);
     $pdf->Image(PATH_ROOT . '/web/img/iso.png', '255', '8', 15, 15, 'PNG', '', 'T', false, 300, '', false, false, 1, false, false, false);
     $cadena2 = "";
     $cadena2 .= "<br/><br/><br/><br/>";
     $cadena2 .= '<table width="740" border="0">';
     $cadena2 .= '<tr>';
     $cadena2 .= '<td width="100" height="65" ></td><td width="160" align="center" >';
     $cadena2 .= '<h4 style="border-top:1px solid black">Archivista Remitente<br>' . $usuarioOrigen . '</h4>';
     $cadena2 .= '</td><td width="100"></td>';
     $cadena2 .= '<td width="100" ></td><td width="150" align="center">';
     $cadena2 .= '<h4 style="border-top:1px solid black">Archivista de Recepci&oacute;n<br>' . $usuarioDestino . '</h4></td>';
     $cadena2 .= '<td width="100"></td></tr>';
     $cadena2 .= '<tr>';
     $cadena2 .= '<td width="100" height="65" ></td><td width="160" align="center" >';
     $cadena2 .= '<h4 style="border-top:1px solid black">Autoridad<br>Unidad Remitente</h4>';
     $cadena2 .= '</td><td width="100"></td>';
     $cadena2 .= '<td width="100" ></td><td width="150" align="center">';
     $cadena2 .= '<h4 style="border-top:1px solid black">SGE / DOC<br></h4></td>';
     $cadena2 .= '<td width="100"></td></tr>';
     $cadena2 .= '</table>';
     $cadena = $cadena . $cadena2;
     $pdf->writeHTML($cadena, true, false, false, false, '');
     // -----------------------------------------------------------------------------
     //Close and output PDF document
     //   $pdf->Output('reporte_transferencia.pdf', 'D');
     $pdf->Output('reporte_transferencia.pdf', 'I');
     Header("Location: " . PATH_DOMAIN . "/soltransferencia/");
 }
 function viewCaratulas2()
 {
     $id_valor = $_REQUEST['exp_id'];
     $cantidad = $_REQUEST['cantidad_ejem'];
     $texp = new Tab_etiquetas();
     $usuario = new usuario();
     $sql = "SELECT\r\n                tab_fondo.fon_cod,\r\n                u.uni_id,\r\n                u.uni_cod,\r\n                tab_tipocorr.tco_codigo,\r\n                tab_series.ser_codigo,\r\n                tab_expediente.exp_codigo,\r\n                tab_fondo.fon_descripcion,\r\n                (SELECT uni_descripcion from tab_unidad WHERE tab_unidad.uni_id=u.uni_par) AS uni_par_cod,\r\n                u.uni_codigo,\r\n                u.uni_descripcion,\r\n                tab_series.ser_categoria,\r\n                tab_expisadg.exp_titulo,\r\n                tab_expediente.exp_nroejem,\r\n                tab_expediente.exp_tomovol,\r\n                tab_expediente.exp_nrocaj,\r\n                (SELECT sof_nombre FROM tab_sopfisico WHERE sof_id=tab_expediente.sof_id AND tab_sopfisico.sof_estado = '1' ) AS sof_nombre,\r\n                tab_expediente.exp_sala,\r\n                tab_expediente.exp_estante,\r\n                tab_expediente.exp_cuerpo,\r\n                tab_expediente.exp_balda,\r\n                tab_expediente.exp_obs,\r\n                tab_sopfisico.sof_codigo,\r\n                tab_expisadg.exp_volsop,\r\n                tab_expisadg.exp_mesi,\r\n                tab_expisadg.exp_anioi,\r\n                tab_expisadg.exp_mesf,\r\n                tab_expisadg.exp_aniof,\r\n                tab_expisadg.exp_notas,\r\n                tab_series.ser_par\r\n                FROM\r\n                tab_fondo\r\n                INNER JOIN tab_unidad as u ON tab_fondo.fon_id = u.fon_id\r\n                INNER JOIN tab_series ON u.uni_id = tab_series.uni_id\r\n                INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n                INNER JOIN tab_expediente ON tab_series.ser_id = tab_expediente.ser_id\r\n                INNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_id\r\n                INNER JOIN tab_exparchivo ON tab_exparchivo.exp_id = tab_expediente.exp_id\r\n                INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n                INNER JOIN tab_sopfisico ON tab_sopfisico.sof_id = tab_archivo.sof_id\r\n                WHERE\r\n                tab_fondo.fon_estado = 1 AND\r\n                u.uni_estado = 1 AND\r\n                tab_tipocorr.tco_estado = 1 AND\r\n                tab_series.ser_estado = 1 AND\r\n                tab_expediente.exp_estado = 1 AND\r\n                tab_expisadg.exp_estado = 1 AND\r\n                tab_expediente.exp_id = '" . $id_valor . "' ";
     $sql2 = "SELECT\r\n                tab_fondo.fon_cod,\r\n                u.uni_id,\r\n                u.uni_cod,\r\n                tab_tipocorr.tco_codigo,\r\n                tab_series.ser_codigo,\r\n                tab_expediente.exp_codigo,\r\n                tab_fondo.fon_descripcion,\r\n                (SELECT uni_descripcion from tab_unidad WHERE tab_unidad.uni_id=u.uni_par) AS uni_par_cod,\r\n                u.uni_codigo,\r\n                u.uni_descripcion,\r\n                tab_series.ser_categoria,\r\n                tab_expisadg.exp_titulo,\r\n                tab_expediente.exp_nroejem,\r\n                tab_expediente.exp_tomovol,\r\n                tab_expediente.exp_nrocaj,\r\n                (SELECT sof_nombre FROM tab_sopfisico WHERE sof_id=tab_expediente.sof_id AND tab_sopfisico.sof_estado = '1' ) AS sof_nombre,\r\n                tab_expediente.exp_sala,\r\n                tab_expediente.exp_estante,\r\n                tab_expediente.exp_cuerpo,\r\n                tab_expediente.exp_balda,\r\n                tab_expediente.exp_obs,\r\n                tab_expisadg.exp_volsop,\r\n                tab_expisadg.exp_mesi,\r\n                tab_expisadg.exp_anioi,\r\n                tab_expisadg.exp_mesf,\r\n                tab_expisadg.exp_aniof,\r\n                tab_expisadg.exp_notas,\r\n                tab_series.ser_par\r\n                FROM\r\n                tab_fondo\r\n                INNER JOIN tab_unidad AS u ON tab_fondo.fon_id = u.fon_id\r\n                INNER JOIN tab_series ON u.uni_id = tab_series.uni_id\r\n                INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n                INNER JOIN tab_expediente ON tab_series.ser_id = tab_expediente.ser_id\r\n                INNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_id\r\n                WHERE\r\n                tab_fondo.fon_estado = 1 AND\r\n                u.uni_estado = 1 AND\r\n                tab_tipocorr.tco_estado = 1 AND\r\n                tab_series.ser_estado = 1 AND\r\n                tab_expediente.exp_estado = 1 AND\r\n                tab_expisadg.exp_estado = 1 AND\r\n                tab_expediente.exp_id ='" . $id_valor . "' ";
     $foncod = "";
     $rows = $texp->dbSelectBySQL($sql);
     //$rows = $rows[0];
     foreach ($rows as $cs) {
         $foncod = $cs->fon_cod;
     }
     if ($foncod == "") {
         $rows = $texp->dbSelectBySQL($sql2);
         $rows = $rows[0];
     } else {
         $rows = $rows[0];
     }
     // Include the main TCPDF library (search for installation path).
     //require_once('tcpdf/tcpdf_include.php');
     require_once 'tcpdf/tcpdf.php';
     // create new PDF document
     $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Castellon S.R.L.');
     $pdf->SetTitle('UNIDAD DE TECNOLOG�?A, INFORMACION Y COMUNICACION');
     $pdf->SetSubject('Etiquetado de Caratulas');
     $pdf->SetKeywords('Etiquetado, Caratulas, cajas, caratulas, folders');
     // set default header data
     $pdf->SetHeaderData('logo2.png', 25, '');
     //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 048', PDF_HEADER_STRING);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(15, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(0);
     $pdf->AddPage();
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     if (@file_exists(dirname(__FILE__) . '/lang/eng.php')) {
         require_once dirname(__FILE__) . '/lang/eng.php';
         $pdf->setLanguageArray($l);
     }
     // ---------------------------------------------------------
     // set font
     $pdf->SetFont('helvetica', 'B', 8);
     // add a page
     $st = "";
     for ($i = 1; $i <= $cantidad; $i++) {
         //$st.='<table border="0"><tr><td align="center" style="font-size:65px"><b>CARATULA</b></td></tr></table>';
         // -----------------------------------------------------------------------------
         $st .= '<table width="640" border="1" style="font-family:Tahoma, Geneva, sans-serif;font-size:50px">';
         $st .= '<tr>';
         $st .= '<td colspan="4" bgcolor="#CCCCCC" height="35" ><b>CODIGO DE REFERENCIA:</b></td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" height="40" align="center" style="font-size:65px">' . $rows->fon_cod . DELIMITER . $rows->uni_cod . DELIMITER . $rows->tco_codigo . DELIMITER . $rows->ser_codigo . DELIMITER . $rows->exp_codigo . '</td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" bgcolor="#CCCCCC" height="35" ><b>SUBFONDO:</b></td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" height="40" align="center" style="font-size:50px">' . $rows->fon_descripcion . '</td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" bgcolor="#CCCCCC" height="35" ><b>SECCION:</b></td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" height="40" align="center" style="font-size:40px">';
         $unidad = new unidad();
         $uni_descripcion = $unidad->obtenerPadre($rows->uni_id);
         $st .= $uni_descripcion;
         $st .= '</td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" bgcolor="#CCCCCC" height="35"><b>SUBSECCION:</b></td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" height="40" align="center" style="font-size:40px">';
         if ($uni_descripcion != $rows->uni_descripcion) {
             $st .= $rows->uni_descripcion;
         }
         if ($rows->exp_mesi == "") {
             $fechaInicial = $rows->exp_anioi;
         } else {
             $fechaInicial = $rows->exp_mesi . " " . $rows->exp_anioi;
         }
         if ($rows->exp_mesf == "") {
             $fechaFinal = $rows->exp_aniof;
         } else {
             $fechaFinal = $rows->exp_mesf . " " . $rows->exp_aniof;
         }
         $st .= '</td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" bgcolor="#CCCCCC" height="35"><b>SERIE / SUBSERIE:</b></td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" height="40" align="center" style="font-size:40px">';
         $tab_serie = new Tab_series();
         if ($rows->ser_par != -1) {
             $rowsdb = $tab_serie->dbselectByField("ser_id", $rows->ser_par);
             if ($rowsdb[0]->ser_par != -1) {
                 $st .= $rowsdb[0]->ser_categoria;
                 $st .= " / ";
             }
         }
         $st .= $rows->ser_categoria;
         $st .= '</td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" bgcolor="#CCCCCC" height="35"><b>TITULO DEL EXPEDIENTE:</b></td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" height="130" align="center" style="font-size:55px">' . $rows->exp_titulo . '</td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" bgcolor="#CCCCCC" height="35" ><b>NRO. DE VOLUMEN/TOMO:</b></td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" height="45" align="center" style="font-size:45px">' . $rows->exp_tomovol . '</td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" bgcolor="#CCCCCC" height="35"><br><b>FECHAS EXTREMAS:</b></td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" height="40" align="center" style="font-size:60px">' . $fechaInicial . '   -   ' . $fechaFinal . '</td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" bgcolor="#CCCCCC" height="35"><br><b>OBSERVACIONES:</b></td>';
         $st .= '</tr>';
         $st .= '<tr>';
         $st .= '<td colspan="4" height="62" align="center" style="font-size:45px">' . $rows->exp_obs . '</td>';
         $st .= '</tr>';
         $st .= '</table><br>';
     }
     $pdf->Write(0, '', '', 0, 'L', true, 0, false, false, 0);
     $pdf->SetFont('helvetica', '', 8);
     $pst = $st;
     // -----------------------------------------------------------------------------
     $pdf->writeHTML($pst, true, false, false, false, '');
     //Close and output PDF document
     $pdf->Output('example_048.pdf', 'I');
     //============================================================+
     // END OF FILE
     //============================================================+
 }
 function verRpte()
 {
     // Header
     $filtro_series = $_REQUEST["filtro_series"];
     if (!$filtro_series) {
         $filtro_expediente = VAR3;
     } else {
         $filtro_expediente = 0;
     }
     $filtro_serie = 0;
     $where = "";
     //PARA LA ORDENACION SOLO SE ESCOJE UNA OPCION
     $order_by = "";
     $order_by .= " ORDER BY  tab_archivo.fil_nro ASC ";
     //PARA LOS FILTROS
     if ($filtro_expediente != '') {
         $where .= " AND tab_expediente.exp_id = '{$filtro_expediente}' ";
     }
     $sqlh = "SELECT                \r\n                fonp.fon_descripcion as fondes,\r\n                tab_fondo.fon_descripcion,tab_unidad.uni_par,tab_unidad.uni_id,\r\n                ( SELECT sec.uni_descripcion\r\n                FROM tab_unidad AS sec \r\n                WHERE  sec.uni_id = tab_unidad.uni_par) AS seccion,\r\n\t\ttab_fondo.fon_cod,\r\n                tab_unidad.uni_cod,\r\n                tab_unidad.uni_par,\r\n                tab_tipocorr.tco_codigo,\r\n                tab_series.ser_codigo,\r\n                tab_expediente.exp_codigo,\r\n                tab_unidad.uni_descripcion,\r\n                tab_unidad.uni_codigo,\r\n                tab_rol.rol_titulo,\r\n                tab_rol.rol_cod,\r\n                tab_series.ser_categoria,\r\n                tab_expisadg.exp_titulo,\r\n                tab_expisadg.exp_anioi,\r\n                tab_expisadg.exp_aniof,\r\n                tab_expisadg.exp_mesi,\r\n                tab_expisadg.exp_mesf,\r\n                (SELECT COUNT (DISTINCT arc.fil_nrocaj)\r\n                             FROM tab_archivo as arc INNER JOIN\r\n                             tab_exparchivo AS exa ON arc.fil_id = exa.fil_id\r\n                  WHERE exa.exp_id = tab_expediente.exp_id and arc.fil_estado=1) AS totcja,\r\n                (SELECT COUNT (arc.fil_id) FROM tab_archivo as arc INNER JOIN\r\n                             tab_exparchivo AS exa ON arc.fil_id = exa.fil_id\r\n                  WHERE exa.exp_id = tab_expediente.exp_id and arc.fil_estado=1) AS totpzs,\r\n                      (SELECT SUM (NULLIF(arc.fil_nroejem,'')::int) FROM tab_archivo as arc INNER JOIN\r\n                             tab_exparchivo AS exa ON arc.fil_id = exa.fil_id\r\n                  WHERE exa.exp_id = tab_expediente.exp_id and arc.fil_estado=1) AS totalpiezas,\r\n                (SELECT (COUNT (DISTINCT arc.fil_nrocaj))* 0.32\r\n                             FROM tab_archivo as arc INNER JOIN\r\n                             tab_exparchivo AS exa ON arc.fil_id = exa.fil_id\r\n                  WHERE exa.exp_id = tab_expediente.exp_id) AS totml,\r\n                (SELECT MIN (isad.exp_fecha_exi)\r\n                             FROM tab_expediente as exp INNER JOIN\r\n                                                                 tab_expisadg AS isad ON exp.exp_id = isad.exp_id INNER JOIN\r\n                             tab_expusuario AS use ON exp.exp_id = use.exp_id\r\n                  WHERE exp.ser_id = tab_series.ser_id AND use.usu_id = tab_usuario.usu_id AND use.eus_estado = 1) AS fechaini,\r\n                (SELECT MAX (isad.exp_fecha_exf)\r\n                             FROM tab_expediente as exp INNER JOIN\r\n                                                                 tab_expisadg AS isad ON exp.exp_id = isad.exp_id INNER JOIN\r\n                             tab_expusuario AS use ON exp.exp_id = use.exp_id\r\n                  WHERE exp.ser_id = tab_series.ser_id AND use.usu_id = tab_usuario.usu_id AND use.eus_estado = 1) AS fechafin\r\n                FROM\r\n\t\ttab_expediente\r\n                    INNER JOIN tab_expisadg ON tab_expediente.exp_id =tab_expisadg.exp_id\r\n                    INNER JOIN tab_series ON tab_expediente.ser_id = tab_series.ser_id\r\n                    INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n                    INNER JOIN tab_expusuario ON tab_expediente.exp_id = tab_expusuario.exp_id\r\n                    INNER JOIN tab_usuario ON tab_expusuario.usu_id = tab_usuario.usu_id\r\n                    INNER JOIN tab_rol ON tab_usuario.rol_id = tab_rol.rol_id\r\n                    INNER JOIN tab_unidad ON tab_series.uni_id = tab_unidad.uni_id\r\n                    INNER JOIN tab_fondo ON tab_unidad.fon_id = tab_fondo.fon_id\r\n                    INNER JOIN tab_fondo as fonp ON tab_fondo.fon_par = fonp.fon_id \r\n                    WHERE tab_expusuario.eus_estado = 1 " . $where;
     $expedienteh = new Tab_expediente();
     $resulth = $expedienteh->dbselectBySQL($sqlh);
     $cadenah = "<br/><br/><br/><br/><br/><br/><br/><br/>";
     $exp_titulo = "";
     if (count($resulth) > 0) {
         $cadenah .= '<table width="980" border="0" cellpadding="2">';
         $cadenah .= '<tr><td align="center">';
         $cadenah .= '<span style="font-size:24px;">' . $resulth[0]->uni_descripcion . ' (' . $resulth[0]->uni_codigo . ')</span>';
         $cadenah .= '</td></tr>';
         $cadenah .= '<tr><td align="center">';
         $cadenah .= '<span style="font-size:24px;">' . $resulth[0]->rol_titulo . ' (' . $resulth[0]->rol_cod . ')</span>';
         $cadenah .= '</td></tr>';
         $cadenah .= '<tr><td align="center">';
         $cadenah .= '<span style="font-size: 30px;font-weight: bold;text-decoration: underline;">';
         $cadenah .= 'FORMULARIO DE INVENTARIO DE EXPEDIENTES';
         $cadenah .= '</span>';
         $cadenah .= '</td></tr>';
         $cadenah .= '</table>';
         $cadenah .= '<br/><br/>';
         $cadenah .= '<table width="980" border="1" cellpadding="2">';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">FONDO:</span></td>';
         $cadenah .= '<td width="390"><span style="font-size: 22px;">' . $resulth[0]->fondes . '</span></td>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">INSTRUMENTO DE CONSULTA:</span></td>';
         $cadenah .= '<td width="290"><span style="font-size: 22px;">INVENTARIO DE DOCUMENTOS</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">SUB-FONDO:</span></td>';
         $cadenah .= '<td width="390"><span style="font-size: 22px;">' . $resulth[0]->fon_descripcion . '</span></td>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">TOTAL DE CAJAS:</span></td>';
         $cadenah .= '<td width="290"><span style="font-size: 22px;">' . $resulth[0]->totcja . '</span></td>';
         $cadenah .= '</tr>';
         $unidad = new unidad();
         $cadenah .= '<tr>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">SECCI&Oacute;N:</span></td>';
         $cadenah .= '<td width="390"><span style="font-size:22px;">' . $unidad->obtenerPadre($resulth[0]->uni_par, $resulth[0]->uni_descripcion) . '</span></td>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">TOTAL DE PIEZAS:</span></td>';
         $cadenah .= '<td width="290"><span style="font-size: 22px;">' . $resulth[0]->totalpiezas . '</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">SUB SECCI&Oacute;N:</span></td>';
         $cadenah .= '<td width="390"><span style="font-size: 22px;">' . $unidad->obtenerPadres($resulth[0]->uni_par, $resulth[0]->uni_descripcion) . '</span></td>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">TOTAL DE ML:</span></td>';
         $cadenah .= '<td width="290"><span style="font-size: 22px;">' . $resulth[0]->totml . '</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">C&Oacute;DIGO DE REFERENCIA:</span></td>';
         $cadenah .= '<td width="390"><span style="font-size: 22px;">' . $resulth[0]->fon_cod . DELIMITER . $resulth[0]->uni_cod . DELIMITER . $resulth[0]->tco_codigo . DELIMITER . $resulth[0]->ser_codigo . DELIMITER . $resulth[0]->exp_codigo . '</span></td>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">NIVEL DE DESCRIPCI&Oacute;N:</span></td>';
         $cadenah .= '<td width="290"><span style="font-size: 22px;">UNIDAD DOCUMENTAL SIMPLE</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">SERIES:</span></td>';
         $cadenah .= '<td width="390"><span style="font-size: 22px;">' . $resulth[0]->ser_categoria . '</span></td>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">FECHAS EXTREMAS:</span></td>';
         $cadenah .= '<td width="290"><span style="font-size: 22px;">' . $resulth[0]->exp_mesi . ' ' . $resulth[0]->exp_anioi;
         if (trim($resulth[0]->exp_aniof) != "") {
             $cadenah .= ' - ' . $resulth[0]->exp_mesf . ' ' . $resulth[0]->exp_aniof;
         }
         $cadenah .= '</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">EXPEDIENTE(PROYECTO):</span></td>';
         $cadenah .= '<td width="390" ><span style="font-size: 22px;">' . htmlentities($resulth[0]->exp_titulo, ENT_IGNORE, 'utf-8') . '</span></td>';
         $cadenah .= '<td width="150" bgcolor="#CCCCCC"><span style="font-size: 22px;font-weight: bold;">TOTAL REGISTROS:</span></td>';
         $cadenah .= '<td width="290"><span style="font-size: 22px;">' . $resulth[0]->totpzs . '</span></td>';
         $cadenah .= '</tr>';
         $exp_titulo = $resulth[0]->exp_titulo;
         //consulta para campos adicionales
         $camposc = new expcampo();
         $resultdc = $camposc->obtenerSelectCamposRepDoc($filtro_serie, $filtro_expediente);
         $cadenah .= $resultdc;
         $cadenah .= '</table>';
     }
     // Tcpdf
     require_once 'tcpdf/config/lang/eng.php';
     require_once 'tcpdf/tcpdf.php';
     $this->usuario = new usuario();
     // create new PDF document
     $pdf = new TCPDF('L', PDF_UNIT, 'LEGAL', true, 'UTF-8', false);
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->setFontSubsetting(FALSE);
     $pdf->SetAuthor($this->usuario->obtenerNombre($_SESSION['USU_ID']));
     $pdf->SetTitle('Reporte de Inventario');
     $pdf->SetSubject('Reporte de Inventario');
     //        aumentado
     $pdf->SetKeywords('Castellon, TEAM DIGITAL');
     // set default header data
     $pdf->SetHeaderData('logo2.png', 20, 'MPD', $exp_titulo);
     // set header and footer fonts
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     //        $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     //
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     $pdf->SetMargins(5, 30, 10);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     //        $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     //set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, 15);
     //        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set some language-dependent strings
     $pdf->setLanguageArray($l);
     $pdf->SetFont('helvetica', '', 9);
     // add a page
     $pdf->AddPage();
     //        $pdf->SetXY(110, 200);
     $pdf->Image(PATH_ROOT . '/web/img/iso.png', '330', '8', 15, 15, 'PNG', '', 'T', false, 300, '', false, false, 1, false, false, false);
     //
     // Body
     $sql = "SELECT\r\n            tab_archivo.fil_nrocaj,\r\n            tab_archivo.fil_nroejem,\r\n            tab_fondo.fon_cod,\r\n            tab_unidad.uni_cod,\r\n            tab_tipocorr.tco_codigo,\r\n            tab_series.ser_codigo,\r\n            tab_expediente.exp_codigo,\r\n            tab_cuerpos.cue_codigo,\r\n            tab_archivo.fil_codigo,\r\n            tab_archivo.fil_nro,\r\n            tab_expediente.exp_lugar,\r\n            tab_archivo.fil_titulo,\r\n            tab_archivo.fil_subtitulo,\r\n            tab_archivo.fil_proc,\r\n            tab_archivo.fil_firma,\r\n            tab_expisadg.exp_fecha_exi,\r\n            tab_expisadg.exp_fecha_exf,\r\n            tab_archivo.fil_tomovol,\r\n            tab_archivo.fil_nrofoj,\r\n            (SELECT tab_sopfisico.sof_codigo\r\n            FROM tab_sopfisico \r\n            WHERE tab_sopfisico.sof_id = tab_archivo.sof_id ) AS sof_codigo,\r\n            tab_archivo.fil_mrb,\r\n            tab_archivo.fil_sala,\r\n            tab_archivo.fil_estante,\r\n            tab_archivo.fil_cuerpo,\r\n            tab_archivo.fil_balda,\r\n            tab_archivo.fil_obs,\r\n            tab_archivo.fil_mes,\r\n            tab_archivo.fil_anio,\r\n            tab_archivo.fil_mesf,\r\n            tab_archivo.fil_aniof,\r\n            tab_tramite.tra_descripcion\r\n            FROM\r\n            tab_expediente\r\n            INNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_id\r\n            INNER JOIN tab_series ON tab_expediente.ser_id = tab_series.ser_id\r\n            INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n            INNER JOIN tab_expusuario ON tab_expediente.exp_id = tab_expusuario.exp_id\r\n            INNER JOIN tab_usuario ON tab_expusuario.usu_id = tab_usuario.usu_id\r\n            INNER JOIN tab_unidad ON tab_series.uni_id = tab_unidad.uni_id\r\n            INNER JOIN tab_fondo ON tab_unidad.fon_id = tab_fondo.fon_id\r\n            INNER JOIN tab_exparchivo ON tab_expediente.exp_id = tab_exparchivo.exp_id\r\n            INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n            INNER JOIN tab_ubicacion ON tab_unidad.ubi_id = tab_ubicacion.ubi_id\r\n            INNER JOIN tab_localidad ON tab_ubicacion.loc_id = tab_localidad.loc_id\r\n            INNER JOIN tab_provincia ON tab_localidad.pro_id = tab_provincia.pro_id\r\n            INNER JOIN tab_departamento ON tab_provincia.dep_id = tab_departamento.dep_id\r\n            INNER JOIN tab_cuerpos ON tab_cuerpos.cue_id = tab_exparchivo.cue_id\r\n            INNER JOIN tab_tramite ON tab_tramite.tra_id = tab_exparchivo.tra_id\r\n            WHERE tab_expusuario.eus_estado = 1 AND tab_archivo.fil_estado=1" . $where . $order_by;
     $expediente = new Tab_expediente();
     $result = $expediente->dbselectBySQL($sql);
     $cadena = "";
     $cadena .= '<table width="980" border="1" cellpadding="2">';
     $cadena .= '<tr bgcolor="#CCCCCC">';
     $cadena .= '<td colspan="19" align="center" width="860"><span style="font-size: 13px;font-weight: bolder;">&Aacute;REA DE IDENTIFICACI&Oacute;N</span></td>';
     $cadena .= '<td width="120" align="center"><span style="font-size: 13px;font-weight: bolder;">&Aacute;REA DE NOTAS</span></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr bgcolor="#CCCCCC">';
     $cadena .= '<td width="35"  rowspan="2" align="center"><span style="font-size: 13px ;font-weight: bold;">N de Caja</span></td>';
     $cadena .= '<td width="35" rowspan="2" align="center"><span style="font-size: 13px ;font-weight: bold;">Total piezas/cajas</span></td>';
     $cadena .= '<td width="35" rowspan="2" align="center"><span style="font-size: 13px ;font-weight: bold;">N ejem.</span></td>';
     $cadena .= '<td width="35" rowspan="2" align="center"><span style="font-size: 13px; font-weight: bold;">ML</span></td>';
     $cadena .= '<td width="70" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">N de Orden doc.</span></td>';
     $cadena .= '<td width="50" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Depto.</span></td>';
     $cadena .= '<td width="100" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Titulo del Documento</span></td>';
     $cadena .= '<td width="80" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Sub titulo</span></td>';
     $cadena .= '<td width="55" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Productor</span></td>';
     $cadena .= '<td width="50" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Firma</span></td>';
     $cadena .= '<td width="45" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Fecha</span></td>';
     $cadena .= '<td width="45" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Tomo/Volumen</span></td>';
     $cadena .= '<td width="35" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Fojas</span></td>';
     $cadena .= '<td width="40" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Soporte F&iacute;sico</span></td>';
     $cadena .= '<td width="40" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Conser. Doc.</span></td>';
     $cadena .= '<td width="110" colspan="4" align="center"><span style="font-size: 13px ;font-weight: bold;">Ubicaci&oacute;n Topografica</span></td>';
     $cadena .= '<td width="120" rowspan="2" align="center" valign="middle"><span style="font-size: 13px ;font-weight: bold;">Observaciones</span></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr bgcolor="#CCCCCC">';
     $cadena .= '<td width="27" align="center"><span style="font-size: 13px ;font-weight: bold;">Sala</span></td>';
     $cadena .= '<td width="27" align="center"><span style="font-size: 13px ;font-weight: bold;">Estante</span></td>';
     $cadena .= '<td width="28" align="center"><span style="font-size: 13px ;font-weight: bold;">Cuerpo</span></td>';
     $cadena .= '<td width="28" align="center"><span style="font-size: 13px ;font-weight: bold;">Balda</span></td>';
     $cadena .= '</tr>';
     $numero = 1;
     $tra_descripciona = "";
     $tra_descripcionn = "";
     foreach ($result as $fila) {
         // New
         $tra_descripcionn = $fila->tra_descripcion;
         if ($tra_descripcionn != $tra_descripciona) {
             $cadena .= '<tr>';
             $cadena .= '<td width="290" colspan="20"><span style="font-size: 13px;">' . htmlentities($fila->tra_descripcion, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '</tr>';
             //
             $cadena .= '<tr>';
             $cadena .= '<td  width="35"><span style="font-size: 17px;">' . $fila->fil_nrocaj . '</span></td>';
             $cadena .= '<td  width="35"><span style="font-size: 17px;"></span></td>';
             $cadena .= '<td  width="35"><span style="font-size: 17px;">' . $fila->fil_nroejem . '</span></td>';
             $cadena .= '<td  width="35"><span style="font-size: 17px;"></span></td>';
             $cadena .= '<td  width="70"><span style="font-size: 17px;">' . $fila->fon_cod . DELIMITER . $fila->uni_cod . DELIMITER . $fila->tco_codigo . DELIMITER . $fila->ser_codigo . DELIMITER . $fila->exp_codigo . DELIMITER . $fila->fil_nro . '</span></td>';
             $cadena .= '<td width="50"><span style="font-size: 17px;">' . $fila->exp_lugar . '</span></td>';
             $cadena .= '<td width="100"><span style="font-size: 17px;">' . htmlentities($fila->fil_titulo, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="80"><span style="font-size: 17px;">' . htmlentities($fila->fil_subtitulo, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="55"><span style="font-size: 17px;">' . htmlentities($fila->fil_proc, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="50"><span style="font-size: 17px;">' . htmlentities($fila->fil_firma, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="45"><span style="font-size: 17px;">' . $fila->fil_mes . ' ' . $fila->fil_anio . ' - ' . $fila->fil_mesf . ' ' . $fila->fil_aniof . '</span></td>';
             $cadena .= '<td width="45"><span style="font-size: 17px;">' . htmlentities($fila->fil_tomovol, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="35"><span style="font-size: 17px;">' . htmlentities($fila->fil_nrofoj, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="40"><span style="font-size: 17px;">' . htmlentities($fila->sof_codigo, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="40"><span style="font-size: 17px;">' . htmlentities($fila->fil_mrb, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="27"><span style="font-size: 17px;">' . htmlentities($fila->fil_sala, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="27"><span style="font-size: 17px;">' . htmlentities($fila->fil_estante, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="28"><span style="font-size: 17px;">' . htmlentities($fila->fil_cuerpo, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="28"><span style="font-size: 17px;">' . htmlentities($fila->fil_balda, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="120"><span style="font-size: 17px;">' . htmlentities($fila->fil_obs, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '</tr>';
         } else {
             $cadena .= '<tr>';
             $cadena .= '<td  width="35"><span style="font-size: 17px;">' . htmlentities($fila->fil_nrocaj, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td  width="35"><span style="font-size: 17px;"></span></td>';
             $cadena .= '<td  width="35"><span style="font-size: 17px;">' . htmlentities($fila->fil_nroejem, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td  width="35"><span style="font-size: 17px;"></span></td>';
             $cadena .= '<td  width="70"><span style="font-size: 17px;">' . $fila->fon_cod . DELIMITER . $fila->uni_cod . DELIMITER . $fila->tco_codigo . DELIMITER . $fila->ser_codigo . DELIMITER . $fila->exp_codigo . DELIMITER . $fila->fil_nro . '</span></td>';
             $cadena .= '<td width="50"><span style="font-size: 17px;">' . htmlentities($fila->exp_lugar, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="100"><span style="font-size: 17px;">' . htmlentities($fila->fil_titulo, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="80"><span style="font-size: 17px;">' . htmlentities($fila->fil_subtitulo, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="55"><span style="font-size: 17px;">' . htmlentities($fila->fil_proc, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="50"><span style="font-size: 17px;">' . htmlentities($fila->fil_firma, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="45"><span style="font-size: 17px;">' . $fila->fil_mes . ' ' . $fila->fil_anio;
             if (trim($fila->fil_aniof) != "" && trim($fila->fil_mesf) != "") {
                 $cadena .= ' - ' . $fila->fil_mesf . ' ' . $fila->fil_aniof;
             }
             $cadena .= '</span></td>';
             $cadena .= '<td width="45"><span style="font-size: 17px;">' . htmlentities($fila->fil_tomovol, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="35"><span style="font-size: 17px;">' . htmlentities($fila->fil_nrofoj, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="40"><span style="font-size: 17px;">' . htmlentities($fila->sof_codigo, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="40"><span style="font-size: 17px;">' . htmlentities($fila->fil_mrb, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="27"><span style="font-size: 17px;">' . htmlentities($fila->fil_sala, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="27"><span style="font-size: 17px;">' . htmlentities($fila->fil_estante, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="28"><span style="font-size: 17px;">' . htmlentities($fila->fil_cuerpo, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="28"><span style="font-size: 17px;">' . htmlentities($fila->fil_balda, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '<td width="120"><span style="font-size: 17px;">' . htmlentities($fila->fil_obs, ENT_IGNORE, 'utf-8') . '</span></td>';
             $cadena .= '</tr>';
         }
         $numero++;
         $tra_descripciona = $fila->tra_descripcion;
     }
     //obtenerSelectCamposRepC
     $cadena .= '</table>';
     //
     $cadena = $cadenah . $cadena;
     $pdf->writeHTML($cadena, true, false, false, false, '');
     // -----------------------------------------------------------------------------
     //Close and output PDF document
     $pdf->Output('reporte_inventario.pdf', 'I');
 }
 function verRpteExcel()
 {
     header("Content-type: application/vnd.ms-excel; name='excel'");
     header("Content-Disposition: filename=transferencia_expedientes.xls");
     header("Pragma: no-cache");
     header("Expires: 0");
     $id = VAR3;
     $where = "";
     $tab_extransferencia = new tab_exptransferencia();
     $result = $tab_extransferencia->dbSelectBySQL("select* from tab_exptransferencia where str_id={$id}");
     $cantidad = count($result);
     $valor3 = "";
     $t = 1;
     foreach ($result as $row) {
         $valor3 .= "tab_expediente.exp_id={$row->exp_id}";
         if ($t < $cantidad) {
             $valor3 .= " or ";
         }
         $t++;
     }
     $where .= " AND {$valor3} ";
     $sql = "SELECT\r\n            f.fon_codigo,\r\n            f.fon_cod,\r\n            (SELECT fon_codigo from tab_fondo WHERE fon_id=f.fon_par) ||'.'|| f.fon_codigo ||'.'||tab_unidad.uni_cod ||'.'|| tab_tipocorr.tco_codigo ||'.'||tab_series.ser_codigo||'.'||\r\n            tab_expediente.exp_codigo AS codigo,\r\n            (NULLIF(tab_expediente.exp_codigo,'')::int) as cantidad,\r\n            tab_soltransferencia.str_id,\r\n            tab_soltransferencia.str_fecha,\r\n            tab_soltransferencia.uni_id,\r\n            tab_soltransferencia.unid_id,\r\n            tab_soltransferencia.str_nrocajas,\r\n            tab_soltransferencia.str_totpzas,\r\n            tab_soltransferencia.str_totml,\r\n            tab_soltransferencia.str_nroreg,\r\n            tab_soltransferencia.str_fecini,\r\n            tab_soltransferencia.str_fecfin,\r\n            tab_soltransferencia.str_estado,\r\n            tab_soltransferencia.usu_id,\r\n            tab_soltransferencia.usud_id,\r\n            tab_soltransferencia.str_direccion,\r\n            tab_soltransferencia.str_telefono,\r\n            tab_expisadg.exp_fecha_exi,\r\n            tab_expisadg.exp_fecha_exf,\r\n            tab_expisadg.exp_anioi,\r\n            tab_expisadg.exp_aniof,\r\n            tab_expisadg.exp_titulo,\r\n            tab_series.ser_codigo,\r\n            tab_unidad.uni_codigo,\r\n            tab_unidad.uni_id,\r\n            tab_unidad.uni_par,\r\n            tab_unidad.uni_cod,\r\n            tab_unidad.uni_descripcion,\r\n            f.fon_cod,\r\n            tab_series.ser_categoria,\r\n            tab_expisadg.exp_titulo,\r\n            tab_expediente.exp_obs,\r\n            tab_series.ser_id,\r\n            tab_series.ser_par,\r\n            tab_expediente.exp_id\r\n            FROM\r\n            tab_unidad\r\n            INNER JOIN tab_fondo as f ON tab_unidad.fon_id = f.fon_id\r\n            INNER JOIN tab_series ON tab_series.uni_id = tab_unidad.uni_id\r\n            INNER JOIN tab_expediente ON tab_expediente.ser_id = tab_series.ser_id\r\n            INNER JOIN tab_expisadg ON tab_expisadg.exp_id = tab_expediente.exp_id\r\n            INNER JOIN tab_exptransferencia ON tab_expediente.exp_id = tab_exptransferencia.exp_id\r\n            INNER JOIN tab_soltransferencia ON tab_soltransferencia.str_id = tab_exptransferencia.str_id\r\n            INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n            WHERE\r\n            tab_soltransferencia.str_estado = 2 \r\n            AND tab_expediente.exp_estado = 1 \r\n            {$where} \r\n            ORDER BY f.fon_cod,\r\n            tab_unidad.uni_cod,\r\n            tab_series.ser_orden, \r\n            tab_series.ser_codigo, \r\n            tab_expediente.exp_codigo::int ";
     $usua = new usuario();
     $subfondo = new fondo();
     $seccion = new unidad();
     $expedientes = new expediente();
     $archivo = new tab_archivo();
     $archivo2 = new tab_archivo();
     $query = $archivo->dbSelectBySQL($sql);
     $query2 = $archivo2->dbSelectBySQL($sql);
     $usu_id = "";
     $usud_id = "";
     $uni_id = "";
     foreach ($query2 as $ids) {
         $usu_id = $ids->usu_id;
         $usud_id = $ids->usud_id;
         $uni_id = $ids->uni_id;
         $uni_par = $ids->uni_par;
         $uni_cod = $ids->uni_cod;
         $str_telefono = $ids->str_telefono;
         $str_id = $ids->str_id;
         $str_fecha = $ids->str_fecha;
         $str_direccion = $ids->str_direccion;
         $uni_descripcion = $ids->uni_descripcion;
     }
     $usuarioOrigen = $usua->obtenerNombre($usu_id);
     $usuarioDestino = $usua->obtenerNombre($usud_id);
     $fond = $subfondo->obtenerfon($usu_id);
     $ob_seccion = $seccion->obtenerSeccion($uni_id);
     $cadena = "";
     $cadena .= '<table width="740" border="1">';
     $cadena .= '<tr>';
     $cadena .= '<td colspan="10" align="center" ><b>';
     $cadena .= 'FORMULARIO DE RELACION DE TRANSFERENCIAS</b><br /></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr>';
     $cadena .= '<td colspan="9" align="right" style=border:none ><b>';
     $cadena .= 'Nro. de transferencia:</b></td><td align="center">' . $str_id . '</td>';
     $cadena .= '</tr>';
     $cadena .= '<tr>';
     $cadena .= '<td colspan="5">';
     $cadena .= '<b>Subfondo:</b> ' . $fond . '<br />';
     $cadena .= '<b>Secci&oacute;n:</b> ';
     $explode = explode(".", $uni_cod);
     $contado = count($explode);
     $codigo = "";
     for ($t = 0; $t < $contado - 1; $t++) {
         $codigo .= $explode[$t];
         if ($t < $contado - 2) {
             $codigo .= ".";
         }
     }
     $codigo2 = $codigo;
     if (strlen($codigo) == 1) {
         $codigo = $codigo . ".0";
     } else {
         $estraer_codigo = explode(".", $codigo);
         $codigo = $estraer_codigo[0] . ".0";
     }
     $tab_unidad = new Tab_unidad();
     $unidad = new unidad();
     $sqlUni2 = "SELECT\r\n                    tab_unidad.uni_descripcion\r\n                    FROM\r\n                    tab_unidad\r\n                    WHERE\r\n                    tab_unidad.uni_cod = '{$codigo}'";
     $codigoss = explode(".", $codigo2);
     $cantcodigo2 = count($codigoss);
     if ($cantcodigo2 == 1) {
         $codigo2 = "{$codigo2}.1";
     }
     $sqlUni1 = "SELECT\r\n                    tab_unidad.uni_descripcion\r\n                    FROM\r\n                    tab_unidad\r\n                    WHERE\r\n                    tab_unidad.uni_cod = '{$codigo2}'";
     $resultadott = $tab_unidad->dbSelectBySQL($sqlUni2);
     $resultadott1 = $tab_unidad->dbSelectBySQL($sqlUni1);
     $ca1 = "";
     foreach ($resultadott1 as $rowss2) {
         $ca1 = $rowss2->uni_descripcion;
     }
     foreach ($resultadott as $rowss) {
         $ca = $rowss->uni_descripcion;
     }
     $variable = $ca;
     $excluirparent = explode("(", $variable);
     if ($excluirparent[1] == "") {
         $ca = $ca;
     } else {
         $excluirultimoparent = $excluirparent[1] . "x";
         $imprimir_descripcion = explode(")", $excluirultimoparent);
         $ca = $imprimir_descripcion[0];
     }
     $ca = $unidad->obtenerPadre($uni_par, $uni_descripcion);
     $cadena .= $ca;
     $cadena .= '<br><b>Subsecci&oacute;n:</b> ';
     $cadena .= $ca1;
     $cadena .= '</td>';
     $cadena .= '<td colspan="5"  >';
     $cadena .= '<br /><b>Tel&eacute;fono:</b> ' . $str_telefono . '</td>';
     $cadena .= '</tr>';
     $cadena .= '<tr>';
     $cadena .= '<td width="20" rowspan="2" align="center" bgcolor="#CCCCCC"><strong>Nro.</strong></td>';
     $cadena .= '<td width="125" colspan="2" rowspan="2" style="text-align:center" bgcolor="#CCCCCC"><strong>Serie/Subserie</strong></td>';
     $cadena .= '<td width="225" rowspan="2" style="text-align:center" bgcolor="#CCCCCC"><strong>T&iacute;tulo del Expediente</strong></td>';
     $cadena .= '<td width="90" rowspan="2" style="text-align:center" bgcolor="#CCCCCC"><strong>C&oacute;digo de Referencia</strong></td>';
     $cadena .= '<td width="100" colspan="2" style="text-align:center" bgcolor="#CCCCCC"><strong>Fechas extremas</strong></td>';
     $cadena .= '<td width="40" rowspan="2" bgcolor="#CCCCCC" style="font-size:25px"><strong >Nro.Doc.</strong></td>';
     $cadena .= '<td width="40" rowspan="2" bgcolor="#CCCCCC"><strong>Cajas</strong></td>';
     $cadena .= '<td width="100" rowspan="2" style="text-align:center" bgcolor="#CCCCCC"><p><strong>Obs.</strong></p></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr>';
     $cadena .= '<td width="50" style="text-align:center" bgcolor="#CCCCCC"><strong>Inicio</strong></td>';
     $cadena .= '<td width="50" style="text-align:center" bgcolor="#CCCCCC"><strong>Final</strong></td>';
     $cadena .= '</tr>';
     $sum = 0;
     $i = 1;
     $cant = 0;
     foreach ($query as $row) {
         $tabserie = new tab_series();
         if ($row->exp_fecha_exi == "") {
             $fei = "";
         } else {
             $fechainicial = explode("-", $row->exp_fecha_exi);
             $fei = $fechainicial[2] . "/" . $fechainicial[1] . "/" . $fechainicial[0];
         }
         if ($row->exp_fecha_exf == "") {
             $fef = "";
         } else {
             $fechafinal = explode("-", $row->exp_fecha_exf);
             $fef = $fechafinal[2] . "/" . $fechafinal[1] . "/" . $fechafinal[0];
         }
         $cadena .= '<tr>';
         $cadena .= '<td align="center">' . $i . '</td>';
         $cadena .= '<td colspan="2" style="font-size:22px">';
         $cadena .= $row->ser_categoria;
         $expsum = $expedientes->cantidadExpedientes($row->exp_id);
         $cant = $cant + $expsum;
         $cadena .= '</td>';
         $cadena .= '<td align="left" style="font-size:22px">' . htmlentities($row->exp_titulo, ENT_COMPAT, 'utf-8') . '</td>';
         $cadena .= '<td align="center" style="font-size:22px">' . $row->codigo . '</td>';
         $cadena .= '<td align="center" style="font-size:22px">' . $row->exp_anioi . '</td>';
         $cadena .= '<td align="center"  style="font-size:22px">' . $row->exp_aniof . '</td>';
         $cadena .= '<td align="center" style="font-size:22px">' . $expsum . '</td>';
         $cadena .= '<td align="center"></td>';
         $cadena .= '<td style="font-size:22px">' . $row->exp_obs . '</td>';
         $cadena .= '</tr>';
         $i++;
     }
     $cadena .= '<tr>';
     $cadena .= '<td colspan="6" align="right" >TOTAL</td>';
     $cadena .= '<td align="center"></td>';
     $cadena .= '<td align="center">' . $cant . '</td>';
     $cadena .= '<td></td>';
     $cadena .= '<td>&nbsp;</td>';
     $cadena .= '</tr>';
     $cadena .= '</table>';
     $fecha = explode("-", $str_fecha);
     $anio = $fecha[0];
     $mes = $fecha[1];
     $dia = $fecha[2];
     switch ($mes) {
         case 1:
             $mes = "Enero";
             break;
         case 2:
             $mes = "Febrero";
             break;
         case 3:
             $mes = "Marzo";
             break;
         case 4:
             $mes = "Abril";
             break;
         case 5:
             $mes = "Mayo";
             break;
         case 6:
             $mes = "Junio";
             break;
         case 7:
             $mes = "Julio";
             break;
         case 8:
             $mes = "Agosto";
             break;
         case 9:
             $mes = "Septiembre";
             break;
         case 10:
             $mes = "Octubre";
             break;
         case 11:
             $mes = "Noviembre";
             break;
         case 12:
             $mes = "Diciembre";
             break;
     }
     $cadena .= '<b>Lugar y fecha de la transferencia:</b> ' . $str_direccion . '  ' . $dia . ' de ' . $mes . ' de ' . $anio;
     $cadena2 = "";
     $cadena2 .= '<table width="740" border="0">';
     $cadena2 .= '<tr>';
     $cadena2 .= '<td width="100" height="65" ></td><td width="160" align="center" >';
     $cadena2 .= '<h4 style="border-top:1px solid black">Archivista Remitente<br>' . $usuarioOrigen . '</h4>';
     $cadena2 .= '</td><td width="100"></td>';
     $cadena2 .= '<td width="100" ></td><td width="150" align="center">';
     $cadena2 .= '<h4 style="border-top:1px solid black">Archivista de Recepci&oacute;n<br>' . $usuarioDestino . '</h4></td>';
     $cadena2 .= '<td width="100"></td></tr>';
     $cadena2 .= '<tr>';
     $cadena2 .= '<td width="100" height="65" ></td><td width="160" align="center" >';
     $cadena2 .= '<h4 style="border-top:1px solid black">Autoridad<br>Unidad Remitente</h4>';
     $cadena2 .= '</td><td width="100"></td>';
     $cadena2 .= '<td width="100" ></td><td width="150" align="center">';
     $cadena2 .= '<h4 style="border-top:1px solid black">SGE / DOC<br></h4></td>';
     $cadena2 .= '<td width="100"></td></tr>';
     $cadena2 .= '</table>';
     $cadena = $cadena . $cadena2;
     echo $cadena;
 }
 function verRpte()
 {
     $where = "";
     $filtro_seccion = $_POST['filtro_seccion'];
     $tiporeporte = $_POST['tiporeporte'];
     $nrocajas = $_POST['nro_cajas'];
     $usuario = new Tab_usuario();
     $where .= " AND tab_unidad.uni_id = {$filtro_seccion}";
     if ($tiporeporte == 1) {
         require_once 'tcpdf/config/lang/eng.php';
         require_once 'tcpdf/tcpdf.php';
         $this->usuario = new usuario();
         // create new PDF document
         $pdf = new TCPDF('L', PDF_UNIT, 'LETTER', true, 'UTF-8', false);
         $pdf->SetCreator(PDF_CREATOR);
         $pdf->setFontSubsetting(FALSE);
         $pdf->SetAuthor($this->usuario->obtenerNombre($_SESSION['USU_ID']));
         $pdf->SetTitle('Reporte de Inventario');
         $pdf->SetSubject('Reporte de Inventario');
         $pdf->SetKeywords('Castellon, SAD');
         // set default header data
         $pdf->SetHeaderData('logo2.png', 20, 'MPD', "");
         // set header and footer fonts
         $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
         $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
         $pdf->SetMargins(5, 30, 10);
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->setPrintFooter(false);
         //set auto page breaks
         $pdf->SetAutoPageBreak(TRUE, 15);
         //set some language-dependent strings
         $pdf->setLanguageArray($l);
         $pdf->SetFont('helvetica', '', 9);
         // add a page
         $pdf->AddPage();
         $pdf->Image(PATH_ROOT . '/web/img/iso.png', '255', '8', 15, 15, 'PNG', '', 'T', false, 300, '', false, false, 1, false, false, false);
     } else {
         if ($tiporeporte == 2) {
             header("Content-type: application/vnd.ms-excel; name='excel'");
             header("Content-Disposition: filename=inventario_sec.xls");
             header("Pragma: no-cache");
             header("Expires: 0");
         } else {
             if ($tiporeporte == 3) {
             }
         }
     }
     // Count data
     $sql = "SELECT\r\n                e.exp_id,\r\n                (SELECT \r\n                count(tab_archivo.fil_nroejem) as cont\r\n                FROM\r\n                tab_expediente\r\n                INNER JOIN tab_exparchivo ON tab_expediente.exp_id = tab_exparchivo.exp_id\r\n                INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n                WHERE tab_expediente.exp_id = e.exp_id) AS contador,\r\n                tab_fondo.fon_cod,\r\n                tab_unidad.uni_descripcion,\r\n                tab_unidad.uni_cod,\r\n                tab_unidad.uni_id,\r\n                tab_tipocorr.tco_codigo,\r\n                tab_series.ser_id,\r\n                tab_series.ser_par,\r\n                tab_series.ser_codigo,\r\n                e.exp_codigo,\r\n                tab_expisadg.exp_titulo,\r\n                tab_expisadg.exp_anioi,\r\n                tab_expisadg.exp_aniof,\r\n                tab_expisadg.exp_fecha_exi,\r\n                tab_expisadg.exp_id,\r\n                tab_series.ser_id,\r\n                tab_unidad.uni_par,\r\n                tab_unidad.uni_id,\r\n                tab_fondo.fon_descripcion,\r\n                tab_series.ser_categoria\r\n                FROM\r\n                tab_expediente e\r\n                INNER JOIN tab_series ON e.ser_id = tab_series.ser_id\r\n                INNER JOIN tab_expisadg ON e.exp_id = tab_expisadg.exp_id\r\n                INNER JOIN tab_unidad ON tab_unidad.uni_id = tab_series.uni_id\r\n                INNER JOIN tab_fondo ON tab_fondo.fon_id = tab_unidad.fon_id\r\n                INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n                WHERE\r\n                tab_fondo.fon_estado = 1 AND\r\n                tab_unidad.uni_estado = 1 AND\r\n                tab_series.ser_estado = 1 AND\r\n                tab_tipocorr.tco_estado = 1 AND\r\n                e.exp_estado = 1 AND\r\n                tab_expisadg.exp_estado = 1 AND\r\n                tab_unidad.uni_id = '{$filtro_seccion}'\r\n                ORDER BY\r\n                e.exp_id::int ASC";
     $expediente = new Tab_expediente();
     $result = $expediente->dbselectBySQL($sql);
     $piezas = 0;
     if (count($result) > 0) {
         foreach ($result as $row) {
             if ($row->contador == 0) {
                 $piezas = $piezas + 1;
             } else {
                 $piezas = $piezas + $row->contador;
             }
         }
     }
     // Header data
     $sqlh = "SELECT\r\n                e.exp_id,\r\n                (SELECT fon_descripcion from tab_fondo WHERE fon_id=f.fon_par) as fon_par,\r\n                f.fon_descripcion,                \r\n                f.fon_cod,\r\n                (SELECT uni_descripcion from tab_unidad WHERE uni_id=u.uni_par) as uni_padre,\r\n                u.uni_descripcion,\r\n                u.uni_cod,\r\n                u.uni_id,\r\n                u.uni_par,\r\n                tab_tipocorr.tco_codigo,\r\n                tab_series.ser_id,\r\n                tab_series.ser_par,\r\n                tab_series.ser_codigo,\r\n                e.exp_codigo,\r\n                tab_expisadg.exp_titulo,\r\n                tab_expisadg.exp_anioi,\r\n                tab_expisadg.exp_aniof,\r\n                tab_expisadg.exp_fecha_exi,\r\n                tab_expisadg.exp_id,\r\n                tab_series.ser_id,\r\n                u.uni_par,\r\n                u.uni_id,\r\n                tab_series.ser_categoria\r\n                FROM\r\n                tab_expediente e\r\n                INNER JOIN tab_series ON e.ser_id = tab_series.ser_id\r\n                INNER JOIN tab_expisadg ON e.exp_id = tab_expisadg.exp_id\r\n                INNER JOIN tab_unidad u ON u.uni_id = tab_series.uni_id\r\n                INNER JOIN tab_fondo f ON f.fon_id = u.fon_id\r\n                INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n                WHERE\r\n                f.fon_estado = 1 AND\r\n                u.uni_estado = 1 AND\r\n                tab_series.ser_estado = 1 AND\r\n                tab_tipocorr.tco_estado = 1 AND\r\n                e.exp_estado = 1 AND\r\n                tab_expisadg.exp_estado = 1 AND\r\n                u.uni_id = '{$filtro_seccion}'\r\n                ORDER BY\r\n                e.exp_id ASC";
     $exp_titulo = "";
     $expedienteh = new Tab_expediente();
     $resulth = $expedienteh->dbselectBySQL($sqlh);
     $cadena = "";
     if (count($resulth) > 0) {
         // Header
         $cadena .= '<table width="100%" cellpadding="2" border="1" style="border-collapse: collapse; "  >';
         $cadena .= '<tr><td align="center" colspan="12" >';
         $cadena .= '<span style="font-family: helvetica; font-size: 20px;font-weight: bold;text-decoration: underline;">';
         $cadena .= 'FORMULARIO DE INVENTARIO POR SECCIONES';
         $cadena .= '</span>';
         $cadena .= '</td></tr>';
         $cadena .= '<tr>';
         $cadena .= '<td width="5%" colspan="2" bgcolor="#CCCCCC"><span style="font-family: helvetica; font-size: 16px;font-weight: bold; text-align:justify;"> FONDO:</span></td>';
         $cadena .= '<td width="50%" colspan="4"><span style="font-family: helvetica; font-size: 16px; text-align:justify;">' . $resulth[0]->fon_par . '</span></td>';
         $cadena .= '<td width="5%" colspan="3" bgcolor="#CCCCCC"><span style="font-family: helvetica; font-size: 16px;font-weight: bold; text-align:justify;">INSTRUMENTO DE CONSULTA:</span></td>';
         $cadena .= '<td width="40%" colspan="3"><span style="font-family: helvetica; font-size: 16px; text-align:justify;">INVENTARIO DE DOCUMENTOS POR SECCIONES</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr>';
         $cadena .= '<td width="5%" colspan="2" bgcolor="#CCCCCC"><span style="font-family: helvetica; font-size: 16px;font-weight: bold; text-align:justify;">SUB-FONDO:</span></td>';
         $cadena .= '<td width="50%" colspan="4"><span style="font-family: helvetica; font-size: 16px; text-align:justify;">' . $resulth[0]->fon_descripcion . '</span></td>';
         $cadena .= '<td width="5%" colspan="3" bgcolor="#CCCCCC"><span style="font-family: helvetica; font-size: 16px;font-weight: bold; text-align:justify;">TOTAL DE CAJAS:</span></td>';
         $cadena .= '<td width="40%" colspan="3"><span style="font-family: helvetica; font-size: 16px; text-align:justify;">' . $nrocajas . '</span></td>';
         $cadena .= '</tr>';
         $unidad = new unidad();
         $cadena .= '<tr>';
         $cadena .= '<td width="5%" colspan="2" bgcolor="#CCCCCC"><span style="font-family: helvetica; font-size: 16px;font-weight: bold; text-align:justify;">SECCI&Oacute;N:</span></td>';
         $cadena .= '<td width="50%" colspan="4"><span style="font-family: helvetica; font-size:16px;">' . $unidad->obtenerPadre($resulth[0]->uni_par, $resulth[0]->uni_descripcion) . '</span></td>';
         $cadena .= '<td width="5%" colspan="3" bgcolor="#CCCCCC"><span style="font-size: 16px;font-weight: bold; text-align:justify;">TOTAL DE PIEZAS:</span></td>';
         $cadena .= '<td width="40%" colspan="3"><span style="font-size: 16px;">' . $piezas . '</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr>';
         $cadena .= '<td width="5%" colspan="2" bgcolor="#CCCCCC"><span style="font-size: 16px;font-weight: bold; text-align:justify;">SUB SECCI&Oacute;N:</span></td>';
         $cadena .= '<td width="50%" colspan="4"><span style="font-size: 16px;">' . $unidad->obtenerPadres($resulth[0]->uni_par, $resulth[0]->uni_descripcion) . '</span></td>';
         $cadena .= '<td width="5%" colspan="3" bgcolor="#CCCCCC"><span style="font-size: 16px;font-weight: bold; text-align:justify;"></span></td>';
         $cadena .= '<td width="40%" colspan="3"><span style="font-size: 16px;"></span></td>';
         $cadena .= '</tr>';
         // Body - Header
         $cadena .= '<tr bgcolor="#CCCCCC">';
         $cadena .= '<td width="95%" align="center" colspan="11"><span style="font-family: helvetica; font-size: 11px;font-weight: bold;">&Aacute;REA DE IDENTIFICACI&Oacute;N</span></td>';
         $cadena .= '<td width="5%" align="left"><span style="font-family: helvetica; font-size: 11px;font-weight: bold;">&Aacute;REA DE NOTAS</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr bgcolor="#CCCCCC">';
         $cadena .= '<td width="5%"  align="left"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold;">Archivo</span></td>';
         $cadena .= '<td width="5%"  align="left"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold;">C&oacute;digo</span></td>';
         $cadena .= '<td width="60%" align="center"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold;">Titulo/Subtitulo</span></td>';
         $cadena .= '<td width="5%"  align="center"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold;">T/V</span></td>';
         $cadena .= '<td width="5%"  align="center"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold;">Fechas Extremas</span></td>';
         $cadena .= '<td width="3%"  align="center"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold;">Caja</span></td>';
         $cadena .= '<td width="3%"  align="center"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold;">Sala</span></td>';
         $cadena .= '<td width="3%"  align="center"><span style="font-family: helvetica; font-size: 9px ;font-weight: bold;">Estante</span></td>';
         $cadena .= '<td width="3%"  align="center"><span style="font-family: helvetica; font-size: 9px ;font-weight: bold;">Cuerpo</span></td>';
         $cadena .= '<td width="3%"  align="center"><span style="font-family: helvetica; font-size: 9px ;font-weight: bold;">Balda</span></td>';
         $cadena .= '<td width="5%"  align="center"><span style="font-family: helvetica; font-size: 9px ;font-weight: bold;">Soporte Fisico</span></td>';
         $cadena .= '<td width="5%" align="left"><span style="font-family: helvetica; font-size: 9px ;font-weight: bold; height: auto; ">Observaciones</span></td>';
         $cadena .= '</tr>';
         // Body - Data
         $sql = "SELECT\r\n            tab_unidad.uni_id,\r\n            tab_unidad.uni_descripcion,\r\n            tab_series.ser_id,\r\n            tab_series.ser_categoria\r\n            FROM\r\n            tab_unidad\r\n            INNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\n            WHERE tab_unidad.uni_id = {$filtro_seccion}\r\n            ORDER BY\r\n            tab_series.ser_orden, ser_codigo ";
         $expedienteh = new Tab_expediente();
         $result = $expedienteh->dbselectBySQL($sql);
         foreach ($result as $res) {
             // Serie
             // Expedientes sin documentos
             // Search exps
             $select = "SELECT\r\n                    tab_expediente.exp_id,\r\n                    (SELECT fon_codigo from tab_fondo WHERE fon_id=f.fon_par) AS fon_codigo,\r\n                    tab_unidad.uni_descripcion,\r\n                    tab_series.ser_categoria,\r\n                    tab_expisadg.exp_titulo,\r\n                    tab_expisadg.exp_mesi,\r\n                    tab_expisadg.exp_anioi,\r\n                    tab_expisadg.exp_mesf,\r\n                    tab_expisadg.exp_aniof,\r\n                    f.fon_cod,\r\n                    tab_unidad.uni_cod,\r\n                    tab_tipocorr.tco_codigo,\r\n                    tab_series.ser_codigo,\r\n                    tab_expediente.exp_codigo,\r\n                    tab_expediente.exp_tomovol,\r\n                    tab_expediente.sof_id,\r\n                    tab_expediente.exp_nrocaj,\r\n                    tab_expediente.exp_sala,\r\n                    tab_expediente.exp_estante,\r\n                    tab_expediente.exp_cuerpo,\r\n                    tab_expediente.exp_balda,\r\n                    tab_expediente.exp_obs\r\n                    FROM\r\n                    tab_fondo as f\r\n                    INNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\n                    INNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\n                    INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n                    INNER JOIN tab_expediente ON tab_series.ser_id = tab_expediente.ser_id\r\n                    INNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_id\r\n                    INNER JOIN tab_expusuario ON tab_expediente.exp_id = tab_expusuario.exp_id\r\n                    WHERE\r\n                    f.fon_estado = 1 AND\r\n                    tab_unidad.uni_estado = 1 AND\r\n                    tab_tipocorr.tco_estado = 1 AND\r\n                    tab_series.ser_estado = 1 AND\r\n                    tab_expediente.exp_estado = 1 AND\r\n                    tab_expisadg.exp_estado = 1 AND \r\n                    tab_expusuario.eus_estado = 1 AND \r\n                    tab_series.ser_id = '{$res->ser_id}'\r\n                    ORDER BY tab_unidad.uni_cod, \r\n                    tab_series.ser_id, \r\n                    tab_expediente.exp_codigo::int ";
             $ser_categoria = "";
             $exp_titulo = "";
             $sopfisico = new sopfisico();
             $rows2 = $expedienteh->dbSelectBySQL($select);
             if (count($rows2) > 0) {
                 // Expedientes
                 // Data body
                 foreach ($rows2 as $row) {
                     if ($row->ser_categoria != $ser_categoria) {
                         // Validate
                         // Aqui
                         // Expedientes
                         // Search docs
                         $select = "SELECT\r\n                                     tab_expediente.exp_id,\r\n                                     (SELECT fon_codigo from tab_fondo WHERE fon_id=f.fon_par) AS fon_codigo,\r\n                                     tab_unidad.uni_descripcion,\r\n                                     tab_series.ser_categoria,\r\n                                     tab_expisadg.exp_titulo,\r\n                                     tab_expisadg.exp_mesi,\r\n                                     tab_expisadg.exp_anioi,\r\n                                     tab_expisadg.exp_mesf,\r\n                                     tab_expisadg.exp_aniof,\r\n                                     tab_expisadg.exp_aniof,                    \r\n                                     f.fon_cod,\r\n                                     tab_unidad.uni_cod,\r\n                                     tab_tipocorr.tco_codigo,\r\n                                     tab_series.ser_codigo,\r\n                                     tab_expediente.exp_codigo,\r\n                                     tab_expediente.exp_tomovol,\r\n                                     tab_expediente.sof_id,\r\n                                     tab_expediente.exp_nrocaj,\r\n                                     tab_expediente.exp_sala,\r\n                                     tab_expediente.exp_estante,\r\n                                     tab_expediente.exp_cuerpo,\r\n                                     tab_expediente.exp_balda\r\n                                     FROM\r\n                                     tab_fondo as f\r\n                                     INNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\n                                     INNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\n                                     INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n                                     INNER JOIN tab_expediente ON tab_series.ser_id = tab_expediente.ser_id\r\n                                     INNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_id\r\n                                     INNER JOIN tab_expusuario ON tab_expediente.exp_id = tab_expusuario.exp_id\r\n                                     WHERE\r\n                                     f.fon_estado = 1 AND\r\n                                     tab_unidad.uni_estado = 1 AND\r\n                                     tab_tipocorr.tco_estado = 1 AND\r\n                                     tab_series.ser_estado = 1 AND\r\n                                     tab_expediente.exp_estado = 1 AND\r\n                                     tab_expisadg.exp_estado = 1 AND \r\n                                     tab_expusuario.eus_estado = 1 AND \r\n                                     tab_expediente.exp_id = '{$row->exp_id}'\r\n                                     ORDER BY tab_unidad.uni_id, \r\n                                     tab_series.ser_id, \r\n                                     tab_expediente.exp_codigo::int ";
                         $sopfisico = new sopfisico();
                         $rows4 = $expedienteh->dbSelectBySQL($select);
                         if (count($rows4) > 0) {
                             // SERIE
                             $cadena .= '<tr bgcolor="#969696">';
                             $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;"></span></td>';
                             $cadena .= '<td width="5%" align="left"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold; text-align:left;">' . $row->fon_cod . DELIMITER . $row->uni_cod . DELIMITER . $row->tco_codigo . DELIMITER . $row->ser_codigo . DELIMITER . '</span></td>';
                             $cadena .= '<td width="60%"><span style="font-family: helvetica; font-size: 11px; text-align:left;">' . $row->ser_categoria . '</span></td>';
                             $cadena .= '<td width="5%"><span style="font-family: helvetica; font-size: 11px; text-align:center;"></span></td>';
                             $cadena .= '<td width="5%"><span style="font-family: helvetica; font-size: 11px; text-align:center;"></span></td>';
                             $cadena .= '<td width="3%"><span style="font-family: helvetica; font-size: 11px; text-align:center;"></span></td>';
                             $cadena .= '<td width="3%"><span style="font-family: helvetica; font-size: 11px; text-align:center;"></span></td>';
                             $cadena .= '<td width="3%"><span style="font-family: helvetica; font-size: 11px; text-align:center;"></span></td>';
                             $cadena .= '<td width="3%"><span style="font-family: helvetica; font-size: 11px; text-align:center;"></span></td>';
                             $cadena .= '<td width="3%"><span style="font-family: helvetica; font-size: 11px; text-align:center;"></span></td>';
                             $cadena .= '<td width="5%"><span style="font-family: helvetica; font-size: 11px; text-align:center;"></span></td>';
                             $cadena .= '<td width="5%" height="auto"><span style="font-family: helvetica; font-size: 7px; text-align:left; "></span></td>';
                             $cadena .= '</tr>';
                             $ser_categoria = $row->ser_categoria;
                         }
                     }
                     // Aqui
                     // Documentos
                     // Search docs
                     $select = "SELECT\r\n                                 tab_expediente.exp_id,\r\n                                 (SELECT fon_codigo from tab_fondo WHERE fon_id=f.fon_par) AS fon_codigo,\r\n                                 tab_unidad.uni_descripcion,\r\n                                 tab_series.ser_categoria,\r\n                                 tab_expisadg.exp_titulo,\r\n                                 tab_expisadg.exp_mesi,\r\n                                 tab_expisadg.exp_anioi,\r\n                                 tab_expisadg.exp_mesf,\r\n                                 tab_expisadg.exp_aniof,\r\n                                 tab_expisadg.exp_aniof,                    \r\n                                 f.fon_cod,\r\n                                 tab_unidad.uni_cod,\r\n                                 tab_tipocorr.tco_codigo,\r\n                                 tab_series.ser_codigo,\r\n                                 tab_expediente.exp_codigo,\r\n                                 tab_expediente.exp_tomovol,\r\n                                 tab_expediente.sof_id,\r\n                                 tab_expediente.exp_nrocaj,\r\n                                 tab_expediente.exp_sala,\r\n                                 tab_expediente.exp_estante,\r\n                                 tab_expediente.exp_cuerpo,\r\n                                 tab_expediente.exp_balda,\r\n                                 tab_expusuario.usu_id\r\n                                 FROM\r\n                                 tab_fondo as f\r\n                                 INNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\n                                 INNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\n                                 INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n                                 INNER JOIN tab_expediente ON tab_series.ser_id = tab_expediente.ser_id\r\n                                 INNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_id\r\n                                 INNER JOIN tab_expusuario ON tab_expediente.exp_id = tab_expusuario.exp_id\r\n                                 WHERE\r\n                                 f.fon_estado = 1 AND\r\n                                 tab_unidad.uni_estado = 1 AND\r\n                                 tab_tipocorr.tco_estado = 1 AND\r\n                                 tab_series.ser_estado = 1 AND\r\n                                 tab_expediente.exp_estado = 1 AND\r\n                                 tab_expisadg.exp_estado = 1 AND \r\n                                 tab_expusuario.eus_estado = 1 AND \r\n                                 tab_expediente.exp_id = '{$row->exp_id}'\r\n                                 ORDER BY tab_unidad.uni_id, \r\n                                 tab_series.ser_id, \r\n                                 tab_expediente.exp_codigo::int ";
                     $exp_titulo = "";
                     $sopfisico = new sopfisico();
                     $usuario = new usuario();
                     $rows3 = $expedienteh->dbSelectBySQL($select);
                     if (count($rows3) > 0) {
                         // Data body
                         foreach ($rows3 as $row) {
                             // EXPEDIENTE
                             if ($row->exp_titulo != $exp_titulo) {
                                 $cadena .= '<tr bgcolor="#DDDDDD">';
                                 $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $usuario->getRol($row->usu_id) . '</span></td>';
                                 $cadena .= '<td width="5%" align="left"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold; text-align: left;">' . $row->fon_cod . DELIMITER . $row->uni_cod . DELIMITER . $row->tco_codigo . DELIMITER . $row->ser_codigo . DELIMITER . $row->exp_codigo . '</span></td>';
                                 $cadena .= '<td width="60%"><span style="font-family: helvetica; font-size: 11px; text-align: left;">' . $row->exp_titulo . '</span></td>';
                                 $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row->exp_tomovol . '</span></td>';
                                 if ($row->exp_aniof) {
                                     if ($row->exp_aniof != " ") {
                                         $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row->exp_anioi . ' - ' . $row->exp_aniof . '</span></td>';
                                     } else {
                                         $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row->exp_anioi . '</span></td>';
                                     }
                                 } else {
                                     $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row->exp_anioi . '</span></td>';
                                 }
                                 $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row->exp_nrocaj . '</span></td>';
                                 $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row->exp_sala . '</span></td>';
                                 $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row->exp_estante . '</span></td>';
                                 $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row->exp_cuerpo . '</span></td>';
                                 $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row->exp_balda . '</span></td>';
                                 $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $sopfisico->obtenerNombre($row->sof_id) . '</span></td>';
                                 $cadena .= '<td width="5%" height="auto" align="left" valign="top"><span style="font-family: helvetica; font-size: 7px; text-align: left; height: auto; ">' . $row->exp_obs . '</span></td>';
                                 $cadena .= '</tr>';
                                 $exp_titulo = $row->exp_titulo;
                                 // Documento
                                 // Aqui
                                 // Documentos
                                 // Search docs
                                 $select = "SELECT\r\n                                             tab_expediente.exp_id,\r\n                                             tab_archivo.fil_id,\r\n                                             (SELECT fon_codigo from tab_fondo WHERE fon_id=f.fon_par) AS fon_codigo,\r\n                                             tab_unidad.uni_descripcion,\r\n                                             tab_series.ser_categoria,\r\n                                             tab_expisadg.exp_titulo,\r\n                                             tab_expisadg.exp_mesi,\r\n                                             tab_expisadg.exp_anioi,\r\n                                             tab_expisadg.exp_mesf,\r\n                                             tab_expisadg.exp_aniof,\r\n                                             tab_expisadg.exp_aniof,                    \r\n                                             f.fon_cod,\r\n                                             tab_unidad.uni_cod,\r\n                                             tab_tipocorr.tco_codigo,\r\n                                             tab_series.ser_codigo,\r\n                                             tab_expediente.exp_codigo,\r\n                                             tab_expediente.exp_tomovol,\r\n                                             tab_expediente.exp_nrocaj,\r\n                                             tab_expediente.exp_sala,\r\n                                             tab_expediente.exp_estante,\r\n                                             tab_expediente.exp_cuerpo,\r\n                                             tab_expediente.exp_balda,\r\n                                             tab_expusuario.usu_id,\r\n                                             tab_cuerpos.cue_codigo,\r\n                                             tab_archivo.fil_codigo,\r\n                                             tab_archivo.fil_nro,\r\n                                             tab_cuerpos.cue_descripcion,\r\n                                             tab_archivo.fil_titulo,\r\n                                             tab_archivo.fil_subtitulo,\r\n                                             tab_archivo.fil_proc,\r\n                                             tab_archivo.fil_firma,\r\n                                             tab_archivo.fil_cargo,\r\n                                             tab_archivo.fil_nrofoj,\r\n                                             tab_archivo.fil_tomovol,\r\n                                             tab_archivo.fil_nroejem,\r\n                                             tab_archivo.fil_nrocaj,\r\n                                             tab_archivo.fil_sala,\r\n                                             tab_archivo.fil_estante,\r\n                                             tab_archivo.fil_cuerpo,\r\n                                             tab_archivo.fil_balda,\r\n                                             tab_archivo.fil_tipoarch,\r\n                                             tab_archivo.fil_mrb,\r\n                                             tab_archivo.fil_ori,\r\n                                             tab_archivo.fil_cop,\r\n                                             tab_archivo.fil_fot,\r\n                                             tab_archivo.sof_id,\r\n                                             tab_archivo.sof_id,\r\n                                             tab_archivo.fil_anio,\r\n                                             tab_archivo.fil_aniof,\r\n                                             (CASE tab_exparchivo.exa_condicion \r\n                                                                 WHEN '1' THEN 'DISPONIBLE' \r\n                                                                 WHEN '2' THEN 'PRESTADO' END) AS disponibilidad,\r\n                                             (SELECT fil_nomoriginal FROM tab_archivo_digital WHERE tab_archivo_digital.fil_id=tab_archivo.fil_id AND tab_archivo_digital.fil_estado = '1' ) AS fil_nomoriginal,\r\n                                             (SELECT fil_extension FROM tab_archivo_digital WHERE tab_archivo_digital.fil_id=tab_archivo.fil_id AND tab_archivo_digital.fil_estado = '1' ) AS fil_extension,\r\n                                             (SELECT fil_tamano/1048576 FROM tab_archivo_digital WHERE tab_archivo_digital.fil_id=tab_archivo.fil_id AND tab_archivo_digital.fil_estado = '1' ) AS fil_tamano,\r\n                                             (SELECT fil_nur FROM tab_doccorr WHERE tab_doccorr.fil_id=tab_archivo.fil_id AND tab_doccorr.dco_estado = '1' ) AS fil_nur,                \r\n                                             (SELECT fil_asunto FROM tab_doccorr WHERE tab_doccorr.fil_id=tab_archivo.fil_id AND tab_doccorr.dco_estado = '1' ) AS fil_asunto,                \r\n                                             tab_archivo.fil_obs\r\n                                             FROM\r\n                                             tab_fondo as f\r\n                                             INNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\n                                             INNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\n                                             INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n                                             INNER JOIN tab_expediente ON tab_series.ser_id = tab_expediente.ser_id\r\n                                             INNER JOIN tab_exparchivo ON tab_expediente.exp_id = tab_exparchivo.exp_id\r\n                                             INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n                                             INNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_id\r\n                                             INNER JOIN tab_expusuario ON tab_expediente.exp_id = tab_expusuario.exp_id\r\n                                             INNER JOIN tab_cuerpos ON tab_cuerpos.cue_id = tab_exparchivo.cue_id\r\n                                             INNER JOIN tab_tramitecuerpos ON tab_cuerpos.cue_id = tab_tramitecuerpos.cue_id\r\n                                             INNER JOIN tab_tramite ON tab_tramite.tra_id = tab_tramitecuerpos.tra_id\r\n                                             WHERE\r\n                                             f.fon_estado = 1 AND\r\n                                             tab_unidad.uni_estado = 1 AND\r\n                                             tab_tipocorr.tco_estado = 1 AND\r\n                                             tab_series.ser_estado = 1 AND\r\n                                             tab_expediente.exp_estado = 1 AND\r\n                                             tab_expisadg.exp_estado = 1 AND \r\n                                             tab_archivo.fil_estado = 1 AND\r\n                                             tab_exparchivo.exa_estado = 1 AND\r\n                                             tab_expediente.exp_id = '{$row->exp_id}'\r\n                                             ORDER BY tab_unidad.uni_id, \r\n                                             tab_series.ser_id, \r\n                                             tab_expediente.exp_codigo::int,\r\n                                             tab_archivo.fil_nro::int ";
                                 $sopfisico = new sopfisico();
                                 $rows6 = $expedienteh->dbSelectBySQL($select);
                                 if (count($rows6) > 0) {
                                     foreach ($rows6 as $row6d) {
                                         // Documentos
                                         $cadena .= '<tr>';
                                         $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $usuario->getRol($row6d->usu_id) . '</span></td>';
                                         $cadena .= '<td width="5%"  align="left"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold; text-align: left;">' . $row6d->fon_cod . DELIMITER . $row6d->uni_cod . DELIMITER . $row6d->tco_codigo . DELIMITER . $row6d->ser_codigo . DELIMITER . $row6d->exp_codigo . DELIMITER . $row6d->fil_nro . '</span></td>';
                                         if ($row6d->fil_subtitulo) {
                                             $cadena .= '<td width="60%"><span style="font-family: helvetica; font-size: 11px; text-align: left;">' . $row6d->fil_titulo . '-' . $row6d->fil_subtitulo . '</span></td>';
                                         } else {
                                             $cadena .= '<td width="60%"><span style="font-family: helvetica; font-size: 11px; text-align: left;">' . $row6d->fil_titulo . '</span></td>';
                                         }
                                         $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_tomovol . '</span></td>';
                                         if ($row6d->fil_aniof) {
                                             $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;;">' . $row6d->fil_anio . ' - ' . $row6d->fil_aniof . '</span></td>';
                                         } else {
                                             $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;;">' . $row6d->fil_anio . '</span></td>';
                                         }
                                         $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_nrocaj . '</span></td>';
                                         $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_sala . '</span></td>';
                                         $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_estante . '</span></td>';
                                         $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_cuerpo . '</span></td>';
                                         $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_balda . '</span></td>';
                                         $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $sopfisico->obtenerNombre($row6d->sof_id) . '</span></td>';
                                         $cadena .= '<td width="5%" height="auto" align="left" valign="top"><span style="font-family: helvetica; font-size: 7px; text-align: left; height: auto; ">' . $row6d->fil_obs . '</span></td>';
                                         $cadena .= '</tr>';
                                     }
                                 }
                                 $exp_titulo = $row->exp_titulo;
                             } else {
                                 // Documento
                                 // Aqui
                                 // Documentos
                                 // Search docs
                                 $select = "SELECT\r\n                                             tab_expediente.exp_id,\r\n                                             tab_archivo.fil_id,\r\n                                             (SELECT fon_codigo from tab_fondo WHERE fon_id=f.fon_par) AS fon_codigo,\r\n                                             tab_unidad.uni_descripcion,\r\n                                             tab_series.ser_categoria,\r\n                                             tab_expisadg.exp_titulo,\r\n                                             tab_expisadg.exp_mesi,\r\n                                             tab_expisadg.exp_anioi,\r\n                                             tab_expisadg.exp_mesf,\r\n                                             tab_expisadg.exp_aniof,\r\n                                             tab_expisadg.exp_aniof,                    \r\n                                             f.fon_cod,\r\n                                             tab_unidad.uni_cod,\r\n                                             tab_tipocorr.tco_codigo,\r\n                                             tab_series.ser_codigo,\r\n                                             tab_expediente.exp_codigo,\r\n                                             tab_expediente.exp_tomovol,\r\n                                             tab_expediente.exp_nrocaj,\r\n                                             tab_expediente.exp_sala,\r\n                                             tab_expediente.exp_estante,\r\n                                             tab_expediente.exp_cuerpo,\r\n                                             tab_expediente.exp_balda,\r\n                                             tab_expusuario.usu_id,\r\n                                             tab_cuerpos.cue_codigo,\r\n                                             tab_archivo.fil_codigo,\r\n                                             tab_archivo.fil_nro,\r\n                                             tab_cuerpos.cue_descripcion,\r\n                                             tab_archivo.fil_titulo,\r\n                                             tab_archivo.fil_subtitulo,\r\n                                             tab_archivo.fil_proc,\r\n                                             tab_archivo.fil_firma,\r\n                                             tab_archivo.fil_cargo,\r\n                                             tab_archivo.fil_nrofoj,\r\n                                             tab_archivo.fil_tomovol,\r\n                                             tab_archivo.fil_nroejem,\r\n                                             tab_archivo.fil_nrocaj,\r\n                                             tab_archivo.fil_sala,\r\n                                             tab_archivo.fil_estante,\r\n                                             tab_archivo.fil_cuerpo,\r\n                                             tab_archivo.fil_balda,\r\n                                             tab_archivo.fil_tipoarch,\r\n                                             tab_archivo.fil_mrb,\r\n                                             tab_archivo.fil_ori,\r\n                                             tab_archivo.fil_cop,\r\n                                             tab_archivo.fil_fot,\r\n                                             tab_archivo.sof_id,\r\n                                             tab_archivo.fil_anio,\r\n                                             tab_archivo.fil_aniof,\r\n                                             (CASE tab_exparchivo.exa_condicion \r\n                                                                 WHEN '1' THEN 'DISPONIBLE' \r\n                                                                 WHEN '2' THEN 'PRESTADO' END) AS disponibilidad,\r\n                                             (SELECT fil_nomoriginal FROM tab_archivo_digital WHERE tab_archivo_digital.fil_id=tab_archivo.fil_id AND tab_archivo_digital.fil_estado = '1' ) AS fil_nomoriginal,\r\n                                             (SELECT fil_extension FROM tab_archivo_digital WHERE tab_archivo_digital.fil_id=tab_archivo.fil_id AND tab_archivo_digital.fil_estado = '1' ) AS fil_extension,\r\n                                             (SELECT fil_tamano/1048576 FROM tab_archivo_digital WHERE tab_archivo_digital.fil_id=tab_archivo.fil_id AND tab_archivo_digital.fil_estado = '1' ) AS fil_tamano,\r\n                                             (SELECT fil_nur FROM tab_doccorr WHERE tab_doccorr.fil_id=tab_archivo.fil_id AND tab_doccorr.dco_estado = '1' ) AS fil_nur,                \r\n                                             (SELECT fil_asunto FROM tab_doccorr WHERE tab_doccorr.fil_id=tab_archivo.fil_id AND tab_doccorr.dco_estado = '1' ) AS fil_asunto,                \r\n                                             tab_archivo.fil_obs\r\n                                             FROM\r\n                                             tab_fondo as f\r\n                                             INNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\n                                             INNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\n                                             INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\n                                             INNER JOIN tab_expediente ON tab_series.ser_id = tab_expediente.ser_id\r\n                                             INNER JOIN tab_exparchivo ON tab_expediente.exp_id = tab_exparchivo.exp_id\r\n                                             INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n                                             INNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_id\r\n                                             INNER JOIN tab_expusuario ON tab_expediente.exp_id = tab_expusuario.exp_id\r\n                                             INNER JOIN tab_cuerpos ON tab_cuerpos.cue_id = tab_exparchivo.cue_id\r\n                                             INNER JOIN tab_tramitecuerpos ON tab_cuerpos.cue_id = tab_tramitecuerpos.cue_id\r\n                                             INNER JOIN tab_tramite ON tab_tramite.tra_id = tab_tramitecuerpos.tra_id\r\n                                             WHERE\r\n                                             f.fon_estado = 1 AND\r\n                                             tab_unidad.uni_estado = 1 AND\r\n                                             tab_tipocorr.tco_estado = 1 AND\r\n                                             tab_series.ser_estado = 1 AND\r\n                                             tab_expediente.exp_estado = 1 AND\r\n                                             tab_expisadg.exp_estado = 1 AND \r\n                                             tab_archivo.fil_estado = 1 AND\r\n                                             tab_exparchivo.exa_estado = 1 AND\r\n                                             tab_expediente.exp_id = '{$row->exp_id}'\r\n                                             ORDER BY tab_unidad.uni_id, \r\n                                             tab_series.ser_id, \r\n                                             tab_expediente.exp_codigo::int, \r\n                                             tab_archivo.fil_nro::int ";
                                 $sopfisico = new sopfisico();
                                 $rows6 = $expedienteh->dbSelectBySQL($select);
                                 if (count($rows6) > 0) {
                                     foreach ($rows6 as $row6d) {
                                         // Documentos
                                         $cadena .= '<tr>';
                                         $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $usuario->getRol($row6d->usu_id) . '</span></td>';
                                         $cadena .= '<td width="5%"  align="left"><span style="font-family: helvetica; font-size: 11px ;font-weight: bold; text-align: left;">' . $row6d->fon_cod . DELIMITER . $row6d->uni_cod . DELIMITER . $row6d->tco_codigo . DELIMITER . $row6d->ser_codigo . DELIMITER . $row6d->exp_codigo . DELIMITER . $row6d->fil_nro . '</span></td>';
                                         if ($row6d->fil_subtitulo) {
                                             $cadena .= '<td width="60%"><span style="font-family: helvetica; font-size: 11px; text-align: left;">' . $row6d->fil_titulo . '-' . $row6d->fil_subtitulo . '</span></td>';
                                         } else {
                                             $cadena .= '<td width="60%"><span style="font-family: helvetica; font-size: 11px; text-align: left;">' . $row6d->fil_titulo . '</span></td>';
                                         }
                                         $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_tomovol . '</span></td>';
                                         if ($row6d->fil_aniof) {
                                             $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_anio . ' - ' . $row6d->fil_aniof . '</span></td>';
                                         } else {
                                             $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_anio . '</span></td>';
                                         }
                                         $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_nrocaj . '</span></td>';
                                         $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_sala . '</span></td>';
                                         $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_estante . '</span></td>';
                                         $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_cuerpo . '</span></td>';
                                         $cadena .= '<td width="3%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $row6d->fil_balda . '</span></td>';
                                         $cadena .= '<td width="5%" align="center" valign="top"><span style="font-family: helvetica; font-size: 11px; text-align: center;">' . $sopfisico->obtenerNombre($row6d->sof_id) . '</span></td>';
                                         $cadena .= '<td width="5%" height="auto" align="left" valign="top"><span style="font-family: helvetica; font-size: 7px; text-align: left; height: auto; ">' . $row6d->fil_obs . '</span></td>';
                                         $cadena .= '</tr>';
                                     }
                                 }
                                 $exp_titulo = $row->exp_titulo;
                             }
                         }
                         // end for
                     }
                 }
                 // end for
             }
         }
         // End foreach
         $cadenaLogo = '';
         $cadena .= '</table>';
         if ($tiporeporte == 1) {
             $pdf->writeHTML($cadena, true, false, false, false, '');
             //Close and output PDF document
             $pdf->Output('reporte_inventario.pdf', 'I');
         } else {
             if ($tiporeporte == 2) {
                 echo $cadena;
             } else {
                 if ($tiporeporte == 3) {
                     $cadenaLogo .= '<tr';
                     $cadenaLogo .= '<td width="760"  align="left"><img src="' . PATH_DOMAIN . '/web/img/logo2.png" width="80" height="100"></td>';
                     $cadenaLogo .= '</tr>';
                     $cadena = $cadenaLogo . $cadena;
                     echo $cadena;
                 }
             }
         }
     }
 }