function view()
 {
     if (!VAR3) {
         die("Error del sistema 404");
     }
     $this->expediente = new tab_expediente();
     $rows = $this->expediente->dbselectByField("exp_id", VAR3);
     $row = $rows[0];
     $this->registry->template->exp_id = $row->exp_id;
     $this->registry->template->ser_id = $row->ser_id;
     $series = new series();
     $uni_id = $series->obtenerSeccionIdSerie($row->ser_id);
     $this->registry->template->series = $series->obtenerSelectSeccionDefaultEdit($_SESSION['USU_ID'], $uni_id, $row->ser_id);
     $this->registry->template->ser_codigo = $series->obtenerCodigoSerie($row->ser_id);
     $this->registry->template->ser_corr = $series->obtenerTipoCorrSerie($row->ser_id);
     $this->registry->template->uni_descripcion = $series->obtenerSeccionSerie($row->ser_id);
     $this->registry->template->exp_codigo = $row->exp_codigo;
     // Dynamic fields
     $expcampo = new expcampo();
     $this->registry->template->expcampo = $expcampo->obtenerSelectCamposEdit($row->ser_id, VAR3);
     $sopfisico = new sopfisico();
     $this->registry->template->sof_id = $sopfisico->obtenerSelect($row->sof_id);
     $this->registry->template->exp_lugar = $row->exp_lugar;
     $this->registry->template->exp_nrofoj = $row->exp_nrofoj;
     $this->registry->template->exp_tomovol = $row->exp_tomovol;
     $this->registry->template->exp_nroejem = $row->exp_nroejem;
     $this->registry->template->exp_nrocaj = $row->exp_nrocaj;
     $this->registry->template->exp_sala = $row->exp_sala;
     $expediente = new expediente();
     $this->registry->template->exp_estante = $expediente->obtenerSelectEstante($row->exp_estante);
     $this->registry->template->exp_cuerpo = $row->exp_cuerpo;
     $this->registry->template->exp_balda = $row->exp_balda;
     $this->registry->template->exp_obs = $row->exp_obs;
     $this->registry->template->exp_ori = $row->exp_ori;
     $this->registry->template->exp_cop = $row->exp_cop;
     $this->registry->template->exp_fot = $row->exp_fot;
     // Validate keywords
     $palclave = new palclave();
     $sis_palclave = $palclave->obtenerSisPalclave();
     if ($sis_palclave == "RECORDAR") {
         $this->registry->template->exp_descripcion = $palclave->listaPCFile2($row->exp_id);
     } else {
         $this->registry->template->exp_descripcion = $palclave->listaPCFile2($row->exp_id);
     }
     // Automatic register
     if ($row->exp_corr == 'AUTO') {
         $this->registry->template->exp_corr = "<OPTION selected>AUTO</OPTION><OPTION>MANUAL</OPTION>";
     } else {
         $this->registry->template->exp_corr = "<OPTION>AUTO</OPTION><OPTION selected>MANUAL</OPTION>";
     }
     // isadg
     $expisadg = new tab_expisadg();
     $rows2 = $expisadg->dbselectByField("exp_id", VAR3);
     $row2 = $rows2[0];
     $this->registry->template->exp_titulo = $row2->exp_titulo;
     $this->registry->template->exp_fecha_exi = $row2->exp_fecha_exi;
     $this->registry->template->exp_mesi = $expediente->obtenerSelectMes($row2->exp_mesi);
     $this->registry->template->exp_anioi = $expediente->obtenerSelectAnio($row2->exp_anioi);
     $this->registry->template->exp_fecha_exf = $row2->exp_fecha_exf;
     $this->registry->template->exp_mesf = $expediente->obtenerSelectMes($row2->exp_mesf);
     $this->registry->template->exp_aniof = $expediente->obtenerSelectAnio($row2->exp_aniof);
     $this->registry->template->exp_volsop = $row2->exp_volsop;
     $this->registry->template->exp_nomprod = $row2->exp_nomprod;
     $this->registry->template->exp_hisins = $row2->exp_hisins;
     $this->registry->template->exp_hisarc = $row2->exp_hisarc;
     $this->registry->template->exp_foring = $row2->exp_foring;
     $this->registry->template->exp_alccon = $row2->exp_alccon;
     $this->registry->template->exp_vaseel = $row2->exp_vaseel;
     $this->registry->template->exp_nueing = $row2->exp_nueing;
     $this->registry->template->exp_org = $row2->exp_org;
     $this->registry->template->exp_conacc = $row2->exp_conacc;
     $this->registry->template->exp_conrep = $row2->exp_conrep;
     $idioma = new idioma();
     $this->registry->template->idi_id = $idioma->obtenerSelect($row2->idi_id);
     $this->registry->template->exp_carfis = $expediente->obtenerSelectEstado($row2->exp_carfis);
     $this->registry->template->exp_insdes = $row2->exp_insdes;
     $this->registry->template->exp_exloor = $row2->exp_exloor;
     $this->registry->template->exp_exloco = $row2->exp_exloco;
     $this->registry->template->exp_underel = $row2->exp_underel;
     $this->registry->template->exp_notpub = $row2->exp_notpub;
     $this->registry->template->exp_notas = $row2->exp_notas;
     $this->registry->template->exp_notarc = $row2->exp_notarc;
     $this->registry->template->exp_regnor = $row2->exp_regnor;
     $this->registry->template->exp_fecdes = $row2->exp_fecdes;
     $eus = new Tab_expusuario();
     $row_eus = $eus->dbselectBy2Field("exp_id", VAR3, "eus_estado", 1);
     $usu_id = $_SESSION['USU_ID'];
     if (!is_null($row_eus) && count($row_eus) > 0) {
         $usu_id = $row_eus[0]->usu_id;
     }
     // Keywords
     //        $palclave = new palclave();
     //        $this->registry->template->pac_nombre = $palclave->listaPC();
     $this->registry->template->pac_nombre = "";
     if (VAR4) {
         if (VAR4 == 0) {
             $msm = "HUBO ERROR AL REGISTRAR EL EXPEDIENTE!";
         } else {
             if (VAR4 == 1) {
                 $msm = "SE GUARDO CORRECTAMENTE EL EXPEDIENTE!";
             } else {
                 $msm = "";
             }
         }
     } else {
         $msm = "";
     }
     $this->registry->template->msm = $msm;
     $this->registry->template->PATH_WEB = PATH_WEB;
     $this->registry->template->PATH_DOMAIN = PATH_DOMAIN;
     $this->registry->template->PATH_EVENT = "update";
     $this->registry->template->GRID_SW = "true";
     $this->registry->template->PATH_J = "jquery-1.4.1";
     $this->registry->template->titulo = "HOJA DE TRABAJO - Editar";
     $this->menu = new menu();
     $this->liMenu = $this->menu->imprimirMenu(VAR1, $_SESSION['USU_ID']);
     $this->registry->template->men_titulo = $this->liMenu;
     $this->registry->template->show('headerG');
     $this->registry->template->show('expediente/tab_expediente.tpl');
     $this->registry->template->show('footer');
 }
 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;
                 }
             }
         }
     }
 }
 function verifyFields()
 {
     $sopfisico = new sopfisico();
     $sof_codido = trim($_POST['sof_codigo']);
     $Path_event = trim($_POST['Path_event']);
     if ($Path_event != 'update') {
         if ($sopfisico->existeCodigo($sof_codido)) {
             echo 'El c&oacute;digo ya existe, escriba otro.';
         } else {
             echo '';
         }
     } else {
         echo '';
     }
 }
 function view()
 {
     $exp_id = VAR3;
     $fil_id = VAR4;
     $this->archivo = new tab_archivo();
     $rows = $this->archivo->dbselectByField("fil_id", $fil_id);
     $row = $rows[0];
     // Tab_archivo
     // Tab_doccorr
     $tab_doccorr = new Tab_doccorr();
     $sql = "SELECT *\r\n                FROM tab_doccorr\r\n                WHERE fil_id='" . $row->fil_id . "'";
     $doccorr = $tab_doccorr->dbSelectBySQL($sql);
     if ($doccorr) {
         $doccorr = $doccorr[0];
         // Nur
         $hojas_ruta = new hojas_ruta();
         $this->registry->template->dco_id = $doccorr->dco_id;
         $this->registry->template->fil_cite = $hojas_ruta->obtenerSelect($doccorr->fil_cite);
         $seguimientos = new seguimientos();
         $this->registry->template->fil_nur_s = $seguimientos->obtenerSelect($doccorr->fil_nur_s);
         $this->registry->template->fil_nur = $doccorr->fil_nur;
         $this->registry->template->fil_asunto = $doccorr->fil_asunto;
         $this->registry->template->fil_sintesis = $doccorr->fil_sintesis;
         $this->registry->template->fil_nur_tipo = "";
     } else {
         // Nur
         $this->registry->template->dco_id = "";
         $this->registry->template->fil_cite = "";
         $this->registry->template->fil_nur_s = "";
         $this->registry->template->fil_nur = $_SESSION["codigo"];
         $this->registry->template->fil_asunto = "";
         $this->registry->template->fil_sintesis = "";
         $this->registry->template->fil_nur_tipo = "";
     }
     // Tab_exparchivo
     $sql = "SELECT *\r\n                FROM tab_exparchivo\r\n                WHERE fil_id='" . $row->fil_id . "'";
     $exa_rows = $this->archivo->dbSelectBySQL($sql);
     $exa_row = $exa_rows[0];
     $this->registry->template->exp_id = $exp_id;
     $this->registry->template->tra_id = $exa_row->tra_id;
     $this->registry->template->cue_id = $exa_row->cue_id;
     $this->registry->template->exa_id = $exa_row->exa_id;
     // Tab_archivo
     $this->registry->template->fil_id = $fil_id;
     $this->registry->template->fil_codigo = $row->fil_codigo;
     $expediente = new expediente();
     $this->registry->template->exp_codigo = $expediente->obtenerCodigo(VAR3);
     $this->registry->template->exp_nombre = "";
     $this->registry->template->exp_corr = $expediente->obtenerTipoCorrExpediente(VAR3);
     $this->registry->template->fil_nro = $row->fil_nro;
     $this->registry->template->fil_titulo = $row->fil_titulo;
     $this->registry->template->fil_subtitulo = $row->fil_subtitulo;
     $this->registry->template->fil_fecha = $row->fil_fecha;
     $this->registry->template->fil_mes = $expediente->obtenerSelectMes($row->fil_mes);
     $this->registry->template->fil_anio = $expediente->obtenerSelectAnio($row->fil_anio);
     $this->registry->template->fil_mesf = $expediente->obtenerSelectMes($row->fil_mesf);
     $this->registry->template->fil_aniof = $expediente->obtenerSelectAnio($row->fil_aniof);
     $idioma = new idioma();
     $this->registry->template->idi_id = $idioma->obtenerSelect($row->idi_id);
     $this->registry->template->fil_proc = $row->fil_proc;
     $this->registry->template->fil_firma = $row->fil_firma;
     $this->registry->template->fil_cargo = $row->fil_cargo;
     $this->registry->template->fil_alccon = $row->fil_alccon;
     // Find ser_id
     $texpediente = new tab_expediente();
     $tab_expediente = $texpediente->dbselectById(VAR3);
     $ser_id = $tab_expediente->getSer_id();
     // Include dynamic fields
     $expcampo = new expcampo();
     $this->registry->template->filcampo = $expcampo->obtenerSelectCampos($ser_id);
     $sopfisico = new sopfisico();
     $this->registry->template->sof_id = $sopfisico->obtenerSelect($row->sof_id);
     $this->registry->template->fil_nrofoj = $row->fil_nrofoj;
     $this->registry->template->fil_tomovol = $row->fil_tomovol;
     $this->registry->template->fil_nroejem = $row->fil_nroejem;
     $this->registry->template->fil_nrocaj = $row->fil_nrocaj;
     $this->registry->template->fil_nropaq = $row->fil_nropaq;
     $this->registry->template->fil_cantpaq = $row->fil_cantpaq;
     $this->registry->template->fil_cantcaj = $row->fil_cantcaj;
     $this->registry->template->fil_sala = $row->fil_sala;
     $archivo = new archivo();
     $this->registry->template->fil_estante = $archivo->obtenerSelectEstante($row->fil_estante);
     $this->registry->template->fil_cuerpo = $row->fil_cuerpo;
     $this->registry->template->fil_balda = $row->fil_balda;
     $this->registry->template->fil_tipoarch = $row->fil_tipoarch;
     $this->registry->template->fil_mrb = $row->fil_mrb;
     if ($row->fil_ori) {
         $this->registry->template->fil_ori = $row->fil_ori;
     } else {
         $this->registry->template->fil_ori = '0';
     }
     if ($row->fil_cop) {
         $this->registry->template->fil_cop = $row->fil_cop;
     } else {
         $this->registry->template->fil_cop = '0';
     }
     if ($row->fil_fot) {
         $this->registry->template->fil_fot = $row->fil_fot;
     } else {
         $this->registry->template->fil_fot = '0';
     }
     $this->registry->template->fil_confidencilidad = $row->fil_confidencialidad;
     $this->registry->template->fil_obs = $row->fil_obs;
     $this->registry->template->required_archivo = "";
     // Validate keywords
     $palclave = new palclave();
     $sis_palclave = $palclave->obtenerSisPalclave();
     if ($sis_palclave == "RECORDAR") {
         $this->registry->template->fil_descripcion = $palclave->listaPCFile($row->fil_id);
         $this->registry->template->pac_nombre = "";
     } else {
         $this->registry->template->fil_descripcion = "";
         $this->registry->template->pac_nombre = "";
     }
     $tab_serie = new tab_series();
     $row1 = $tab_serie->dbselectById($ser_id);
     $expisadg = new tab_expisadg();
     $row2 = $expisadg->dbselectById(VAR3);
     $expediente2 = new expediente();
     $this->registry->template->detExpediente = "";
     $this->registry->template->detExpediente = $expediente2->getDetalles(VAR3);
     $this->registry->template->ubicacion = $expediente2->getUbicacion(VAR3);
     $this->registry->template->ser_id = $row1->ser_id;
     $this->registry->template->serie = $row1->ser_categoria;
     $this->registry->template->exp_fecha_exi = $row2->exp_fecha_exi;
     $this->registry->template->exp_fecha_exf = $row2->exp_fecha_exf;
     if (VAR5) {
         if (VAR5 == 0) {
             $msm = "HUBO ERROR AL REGISTRAR EL DOCUMENTO!";
         } else {
             if (VAR5 == 1) {
                 $msm = "SE GUARDO CORRECTAMENTE EL DOCUMENTO!";
             } else {
                 $msm = "";
             }
         }
     } else {
         $msm = "";
     }
     $this->registry->template->msm = $msm;
     $exp = new expediente();
     $this->registry->template->linkTree = $exp->linkTree($exp_id, $exa_row->tra_id, $exa_row->cue_id);
     $arc = new archivo();
     $this->registry->template->confidencialidad = $arc->loadConfidencialidad('1');
     $this->registry->template->PATH_WEB = PATH_WEB;
     $this->registry->template->PATH_DOMAIN = PATH_DOMAIN;
     $this->registry->template->PATH_EVENT = "update";
     $this->registry->template->controller = VAR1;
     $this->registry->template->GRID_SW = "true";
     $this->registry->template->PATH_J = "jquery-1.4.1";
     $this->registry->template->tituloEstructura = "<div class='titulo' align='center'>ESTRUCTURA DOCUMENTAL</div>";
     $this->menu = new menu();
     $liMenu = $this->menu->imprimirMenu(VAR1, $_SESSION['USU_ID']);
     $this->registry->template->men_titulo = $liMenu;
     $this->registry->template->show('headerG');
     //        $this->registry->template->show('archivo/exp_detallesView.tpl');
     $this->registry->template->show('archivo/tab_archivo.tpl');
     $this->registry->template->show('footer');
 }