function update()
 {
     $this->expediente = new tab_expediente();
     $this->expediente->setRequest2Object($_REQUEST);
     $rows2 = $this->expediente->dbselectByField("exp_id", $_REQUEST['exp_id']);
     $row2 = $rows2[0];
     $exp_id = $row2->exp_id;
     //        $this->expediente->setExp_id($_REQUEST['exp_id']);
     $this->expediente->setExp_id($row2->exp_id);
     $this->expediente->setSer_id($_REQUEST['ser_id']);
     if ($_REQUEST['ser_corr'] == 'AUTO') {
         $this->expediente->setExp_codigo($_REQUEST['exp_codigo']);
     } else {
         $this->expediente->setExp_codigo($_REQUEST['exp_codigo']);
     }
     $this->expediente->setExp_lugar(strtoupper($_REQUEST['exp_lugar']));
     $this->expediente->setSof_id($_REQUEST['sof_id']);
     $this->expediente->setExp_nrofoj(strtoupper($_REQUEST['exp_nrofoj']));
     $this->expediente->setExp_tomovol(strtoupper($_REQUEST['exp_tomovol']));
     $this->expediente->setExp_nroejem(strtoupper($_REQUEST['exp_nroejem']));
     $this->expediente->setExp_nrocaj(strtoupper($_REQUEST['exp_nrocaj']));
     $this->expediente->setExp_sala(strtoupper($_REQUEST['exp_sala']));
     $this->expediente->setExp_estante(strtoupper($_REQUEST['exp_estante']));
     $this->expediente->setExp_cuerpo(strtoupper($_REQUEST['exp_cuerpo']));
     $this->expediente->setExp_balda(strtoupper($_REQUEST['exp_balda']));
     if ($_REQUEST['exp_ori']) {
         $this->expediente->setExp_ori($_REQUEST['exp_ori']);
     } else {
         $this->expediente->setExp_ori(0);
     }
     if ($_REQUEST['exp_cop']) {
         $this->expediente->setExp_cop($_REQUEST['exp_cop']);
     } else {
         $this->expediente->setExp_cop(0);
     }
     if ($_REQUEST['exp_fot']) {
         $this->expediente->setExp_fot($_REQUEST['exp_fot']);
     } else {
         $this->expediente->setExp_fot(0);
     }
     $this->expediente->setExp_obs($_REQUEST['exp_obs']);
     $this->expediente->setExp_corr($_REQUEST['exp_corr']);
     $this->expediente->setExp_estado(1);
     $this->expediente->setExp_mexcel(0);
     $this->expediente->update2();
     // isadg
     $this->tab_expisadg = new tab_expisadg();
     $rows = $this->tab_expisadg->dbselectByField("exp_id", $_REQUEST['exp_id']);
     $row = $rows[0];
     $this->tab_expisadg->setEig_id($row->eig_id);
     $this->tab_expisadg->setExp_id($_REQUEST['exp_id']);
     $this->tab_expisadg->setExp_titulo(strtoupper(trim($_REQUEST['exp_titulo'])));
     if ($_REQUEST['exp_anioi'] == "") {
         $anioi = " ";
     } else {
         $anioi = $_REQUEST['exp_anioi'];
     }
     if ($_REQUEST['exp_aniof'] == "") {
         $aniof = " ";
     } else {
         $aniof = $_REQUEST['exp_aniof'];
     }
     if ($_REQUEST['exp_mesi'] == "") {
         $mesi = " ";
     } else {
         $mesi = $_REQUEST['exp_mesi'];
     }
     if ($_REQUEST['exp_mesf'] == "") {
         $mesf = " ";
     } else {
         $mesf = $_REQUEST['exp_mesf'];
     }
     $this->tab_expisadg->setExp_fecha_exi($_REQUEST['exp_fecha_exi']);
     $this->tab_expisadg->setExp_mesi($mesi);
     $this->tab_expisadg->setExp_anioi($anioi);
     $this->tab_expisadg->setExp_fecha_exf($_REQUEST['exp_fecha_exf']);
     $this->tab_expisadg->setExp_mesf($mesf);
     $this->tab_expisadg->setExp_aniof($aniof);
     $this->tab_expisadg->setExp_volsop(strtoupper(trim($_REQUEST['exp_volsop'])));
     $this->tab_expisadg->setExp_nomprod(strtoupper(trim($_REQUEST['exp_nomprod'])));
     $this->tab_expisadg->setExp_hisins(strtoupper(trim($_REQUEST['exp_hisins'])));
     $this->tab_expisadg->setExp_hisarc(strtoupper(trim($_REQUEST['exp_hisarc'])));
     $this->tab_expisadg->setExp_foring(strtoupper(trim($_REQUEST['exp_foring'])));
     $this->tab_expisadg->setExp_alccon(strtoupper(trim($_REQUEST['exp_alccon'])));
     $this->tab_expisadg->setExp_vaseel(strtoupper(trim($_REQUEST['exp_vaseel'])));
     $this->tab_expisadg->setExp_nueing(strtoupper(trim($_REQUEST['exp_nueing'])));
     $this->tab_expisadg->setExp_org(strtoupper(trim($_REQUEST['exp_org'])));
     $this->tab_expisadg->setExp_conacc(strtoupper(trim($_REQUEST['exp_conacc'])));
     $this->tab_expisadg->setExp_conrep(strtoupper(trim($_REQUEST['exp_conrep'])));
     $this->tab_expisadg->setIdi_id($_REQUEST['idi_id']);
     $this->tab_expisadg->setExp_carfis(strtoupper(trim($_REQUEST['exp_carfis'])));
     $this->tab_expisadg->setExp_insdes(strtoupper(trim($_REQUEST['exp_insdes'])));
     $this->tab_expisadg->setExp_exloor(strtoupper(trim($_REQUEST['exp_exloor'])));
     $this->tab_expisadg->setExp_exloco(strtoupper(trim($_REQUEST['exp_exloco'])));
     $this->tab_expisadg->setExp_underel(strtoupper(trim($_REQUEST['exp_underel'])));
     $this->tab_expisadg->setExp_notpub(strtoupper(trim($_REQUEST['exp_notpub'])));
     $this->tab_expisadg->setExp_notas(strtoupper(trim($_REQUEST['exp_notas'])));
     $this->tab_expisadg->setExp_notarc(strtoupper(trim($_REQUEST['exp_notarc'])));
     $this->tab_expisadg->setExp_regnor(strtoupper(trim($_REQUEST['exp_regnor'])));
     $this->tab_expisadg->setExp_estado(1);
     $this->tab_expisadg->update();
     // Update dynamic data
     $expcampo = new expcampo();
     $rows3 = $expcampo->obtenerCampos($_REQUEST['ser_id']);
     if (count($rows3) > 0) {
         foreach ($rows3 as $val) {
             if ($val->ecp_tipdat == 'Lista') {
                 $ecp_id = $val->ecp_id;
                 $ecp_valor = $_REQUEST[$ecp_id];
                 $expcampovalor = new expcampovalor();
                 $ecv_id = $expcampovalor->obtenerIdCampoValorporExpediente($ecp_id, $exp_id);
                 if ($ecv_id == 0) {
                     $this->expcampovalor = new tab_expcampovalor();
                     $this->expcampovalor->setExp_id($exp_id);
                     $this->expcampovalor->setEcp_id($ecp_id);
                     $this->expcampovalor->setEcl_id($ecp_valor);
                     $this->expcampovalor->setEcv_valor($ecp_valor);
                     $this->expcampovalor->setEcv_estado(1);
                     $this->expcampovalor->insert();
                 } else {
                     $this->expcampovalor = new tab_expcampovalor();
                     $this->expcampovalor->setEcv_id($ecv_id);
                     $this->expcampovalor->setExp_id($exp_id);
                     $this->expcampovalor->setEcp_id($ecp_id);
                     $this->expcampovalor->setEcl_id($ecp_valor);
                     $this->expcampovalor->setEcv_valor($ecp_valor);
                     $this->expcampovalor->setEcv_estado(1);
                     $this->expcampovalor->update();
                 }
             } else {
                 $ecp_id = (string) $val->ecp_id;
                 $ecp_valor = $_REQUEST[$ecp_id];
                 $expcampovalor = new expcampovalor();
                 $ecv_id = $expcampovalor->obtenerIdCampoValorporExpediente($ecp_id, $exp_id);
                 if ($ecv_id == 0) {
                     $this->expcampovalor = new tab_expcampovalor();
                     $this->expcampovalor->setExp_id($exp_id);
                     $this->expcampovalor->setEcp_id($ecp_id);
                     $this->expcampovalor->setEcv_valor($ecp_valor);
                     $this->expcampovalor->setEcv_estado(1);
                     $this->expcampovalor->insert();
                 } else {
                     $this->expcampovalor = new tab_expcampovalor();
                     $this->expcampovalor->setEcv_id($ecv_id);
                     $this->expcampovalor->setExp_id($exp_id);
                     $this->expcampovalor->setEcp_id($ecp_id);
                     $this->expcampovalor->setEcv_valor($ecp_valor);
                     $this->expcampovalor->setEcv_estado(1);
                     $this->expcampovalor->update();
                 }
             }
         }
     }
     $expusuario = new tab_expusuario();
     $row4 = $expusuario->dbselectByField("exp_id", $_REQUEST['exp_id']);
     if (count($row4) == 0) {
         $this->expusuario = new Tab_expusuario();
         $this->expusuario->eus_id = '';
         $this->expusuario->exp_id = $_REQUEST['exp_id'];
         $this->expusuario->usu_id = $_SESSION['USU_ID'];
         $this->expusuario->eus_fecha_crea = date("Y-m-d");
         $this->expusuario->eus_estado = '1';
         $this->expusuario->insert();
     }
     // Keywords
     $this->palclave = new tab_palclave();
     $this->palclave->deleteByField("exp_id", $exp_id);
     if (!empty($_REQUEST['exp_descripcion'])) {
         $pac_nombre = trim($_REQUEST['exp_descripcion']);
         $array = explode(SEPARATOR_SEARCH, $pac_nombre);
         for ($j = 0; $j < count($array); $j++) {
             if ($array[$j] != '') {
                 $this->palclave->setExp_id($exp_id);
                 $this->palclave->setPac_nombre(strtoupper(trim($array[$j])));
                 $this->palclave->setPac_formulario('Expediente');
                 $this->palclave->setPac_estado(1);
                 $this->palclave->insert();
             }
         }
     }
     if ($_REQUEST['accion'] == 'guardarsinsalir') {
         $msm_guardado_archivo = 1;
         Header("Location: " . PATH_DOMAIN . "/expediente/view/" . $_REQUEST['exp_id'] . "/" . $msm_guardado_archivo . "/");
     } else {
         if ($_REQUEST['accion'] == 'guardarnuevo') {
             $_SESSION['SER_ID'] = $_REQUEST['ser_id'];
             $this->add();
         } else {
             if ($_REQUEST['accion'] == 'guardar') {
                 Header("Location: " . PATH_DOMAIN . "/expediente/index/");
             } else {
                 Header("Location: " . PATH_DOMAIN . "/expediente/index/");
             }
         }
     }
 }
 function verRpteDoc()
 {
     $filtro_expediente = $_REQUEST["exp_id"];
     $filtro_serie = $_REQUEST["ser_id"];
     $where = "";
     //PARA LA ORDENACION SOLO SE ESCOJE UNA OPCION
     $order_by = "";
     $order_by .= " ORDER BY tab_archivo.fil_codigo, tab_archivo.fil_titulo 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,\r\n                sec.uni_descripcion AS seccion,\r\n\t\ttab_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_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                (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) 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) AS totpzs,\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\t\t\t\t\t\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_unidad AS sec ON tab_unidad.uni_par = sec.uni_id\r\n                    INNER JOIN tab_fondo ON sec.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/>";
     if (count($resulth) > 0) {
         $cadenah .= '<table width="780" 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="760" border="1" cellpadding="2">';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;"> FONDO:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">' . $resulth[0]->fondes . '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">INSTRUMENTO DE CONSULTA:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">INVENTARIO DE DOCUMENTOS</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">SUB-FONDO:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">' . $resulth[0]->fon_descripcion . '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">TOTAL DE CAJAS:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">' . $resulth[0]->totcja . '</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">SECCI&Oacute;N:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">' . $resulth[0]->seccion . '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">TOTAL DE PIEZAS:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">' . $resulth[0]->totpzs . '</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">SUB SECCI&Oacute;N:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">' . $resulth[0]->uni_descripcion . '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">TOTAL DE ML:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">' . $resulth[0]->totml . '</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">C&Oacute;DIGO DE REFERENCIA:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">' . $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="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">NIVEL DE DESCRIPCI&Oacute;N:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">UNIDAD DOCUMENTAL SIMPLE</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">SERIES:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">' . $resulth[0]->ser_categoria . '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">FECHAS EXTREMAS:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">' . $resulth[0]->fechaini . '-' . $resulth[0]->fechafin . '</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">EXPEDIENTE(PROYECTO):</span></td>';
         $cadenah .= '<td width="350" ><span style="font-size: 14px;">' . $resulth[0]->exp_titulo . '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;"></span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;"></span></td>';
         $cadenah .= '</tr>';
         /////
         //consulta para campos adicionales
         $camposc = new expcampo();
         $resultdc = $camposc->obtenerSelectCamposRepDoc($filtro_serie, $filtro_expediente);
         $cadenah .= $resultdc;
         /////
         $cadenah .= '</table>';
     }
     $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_archivo.fil_codigo,\r\n                        tab_departamento.dep_nombre,\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                        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_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_unidad AS sec ON tab_unidad.uni_par = sec.uni_id\r\n                        INNER JOIN tab_fondo ON sec.fon_id = tab_fondo.fon_id\r\n                        INNER JOIN tab_fondo as fonp ON tab_fondo.fon_par = fonp.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_archivo_digital ON tab_archivo.fil_id = tab_archivo_digital.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                        WHERE tab_expusuario.eus_estado = 1 " . $where . $order_by;
     //
     //        //echo ($sql); die ();
     //
     $expediente = new Tab_expediente();
     $result = $expediente->dbselectBySQL($sql);
     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');
     //        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, 15);
     //        $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     //set some language-dependent strings
     $pdf->setLanguageArray($l);
     $pdf->SetFont('helvetica', '', 8);
     // 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);
     $cadena = "";
     $cadena .= '<table width="760" border="1" cellpadding="2">';
     $cadena .= '<tr bgcolor="#CCCCCC">';
     $cadena .= '<td colspan="19" align="center" width="700"><span style="font-size: 20px;font-weight: bolder;">ļæ½?REA DE IDENTIFICACI&Oacute;N</span></td>';
     $cadena .= '<td width="80" align="center"><span style="font-size: 20px;font-weight: bolder;">ļæ½?REA DE NOTAS</span></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr bgcolor="#CCCCCC">';
     $cadena .= '<td width="25"  rowspan="2" align="center"><span style="font-size: 11px ;font-weight: bold;">N de Caja</span></td>';
     $cadena .= '<td width="25" rowspan="2" align="center"><span style="font-size: 11px ;font-weight: bold;">Total piezas/cajas</span></td>';
     $cadena .= '<td width="25" rowspan="2" align="center"><span style="font-size: 11px ;font-weight: bold;">N ejem.</span></td>';
     $cadena .= '<td width="25" rowspan="2" align="center"><span style="font-size: 11px; font-weight: bold;">ML</span></td>';
     $cadena .= '<td width="60" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">N de Orden doc.</span></td>';
     $cadena .= '<td width="40" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Depto.</span></td>';
     $cadena .= '<td width="90" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Titulo del Documento</span></td>';
     $cadena .= '<td width="70" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Sub titulo</span></td>';
     $cadena .= '<td width="45" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Productor</span></td>';
     $cadena .= '<td width="40" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Firma</span></td>';
     $cadena .= '<td width="35" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Fecha</span></td>';
     $cadena .= '<td width="125" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Tomo/Volumen</span></td>';
     $cadena .= '<td width="25" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Fojas</span></td>';
     $cadena .= '<td width="30" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Soporte F&iacute;sico</span></td>';
     $cadena .= '<td width="30" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Conser. Doc.</span></td>';
     $cadena .= '<td width="100" colspan="4" align="center"><span style="font-size: 11px ;font-weight: bold;">Ubicaci&oacute;n Topografica</span></td>';
     $cadena .= '<td width="60" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Observaciones</span></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr bgcolor="#CCCCCC">';
     $cadena .= '<td width="25" align="center"><span style="font-size: 11px ;font-weight: bold;">Sala</span></td>';
     $cadena .= '<td width="25" align="center"><span style="font-size: 11px ;font-weight: bold;">Estante</span></td>';
     $cadena .= '<td width="25" align="center"><span style="font-size: 11px ;font-weight: bold;">Cuerpo</span></td>';
     $cadena .= '<td width="25" align="center"><span style="font-size: 11px ;font-weight: bold;">Balda</span></td>';
     $cadena .= '</tr>';
     $numero = 1;
     foreach ($result as $fila) {
         $cadena .= '<tr>';
         $cadena .= '<td  width="25"><span style="font-size: 11px;">' . $fila->fil_nrocaj . '</span></td>';
         $cadena .= '<td  width="25"><span style="font-size: 11px;"></span></td>';
         $cadena .= '<td  width="25"><span style="font-size: 11px;">' . $fila->fil_nroejem . '</span></td>';
         $cadena .= '<td  width="25"><span style="font-size: 11px;">0,32</span></td>';
         $cadena .= '<td  width="60"><span style="font-size: 11px;">' . $fila->fon_cod . DELIMITER . $fila->uni_cod . DELIMITER . $fila->tco_codigo . DELIMITER . $fila->ser_codigo . DELIMITER . $fila->exp_codigo . DELIMITER . $fila->fil_codigo . '</span></td>';
         $cadena .= '<td width="40"><span style="font-size: 11px;">' . $fila->dep_nombre . '</span></td>';
         $cadena .= '<td width="90"><span style="font-size: 11px;">' . $fila->fil_titulo . '</span></td>';
         $cadena .= '<td width="70"><span style="font-size: 11px;">' . $fila->fil_subtitulo . '</span></td>';
         $cadena .= '<td width="45"><span style="font-size: 11px;">' . $fila->fil_proc . '</span></td>';
         $cadena .= '<td width="40"><span style="font-size: 11px;">' . $fila->fil_firma . '</span></td>';
         $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->exp_fecha_exi . ' - ' . $fila->exp_fecha_exf . '</span></td>';
         $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_tomovol . '</span></td>';
         $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_nrofoj . '</span></td>';
         $cadena .= '<td width="30"><span style="font-size: 11px;">' . $fila->sof_codigo . '</span></td>';
         $cadena .= '<td width="30"><span style="font-size: 11px;">' . $fila->fil_mrb . '</span></td>';
         $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_sala . '</span></td>';
         $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_estante . '</span></td>';
         $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_cuerpo . '</span></td>';
         $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_balda . '</span></td>';
         $cadena .= '<td width="60"><span style="font-size: 11px;">' . $fila->fil_obs . '</span></td>';
         $cadena .= '</tr>';
         $numero++;
     }
     //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 verRpteXls()
 {
     header("Content-type: application/vnd.ms-excel; name='excel'");
     header("Content-Disposition: filename=inventario_documentos.xls");
     header("Pragma: no-cache");
     header("Expires: 0");
     if (isset($_REQUEST["exp_id2"])) {
         $filtro_expediente = $_REQUEST["exp_id2"];
     } else {
         $filtro_expediente = "";
     }
     $filtro_serie = $_REQUEST["ser_id2"];
     $where = "";
     $order_by = "";
     $order_by .= " ORDER BY tab_tramite.tra_orden, tab_archivo.fil_nro ASC ";
     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_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) 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 (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 = "";
     $exp_titulo = "";
     if (count($resulth) > 0) {
         $cadenah .= '<table width="780" border="0" cellpadding="2">';
         $cadenah .= '<tr><td align="center">';
         $cadenah .= 'MPD';
         $cadenah .= '</td></tr>';
         $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 .= '<table width="760" border="1" cellpadding="2">';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;"> FONDO:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">' . $resulth[0]->fondes . '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">INSTRUMENTO DE CONSULTA:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">INVENTARIO DE DOCUMENTOS</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">SUB-FONDO:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">' . $resulth[0]->fon_descripcion . '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">TOTAL DE CAJAS:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">' . $resulth[0]->totcja . '</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">SECCI&Oacute;N:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size:14px;">';
         if ($resulth[0]->uni_par == -1) {
             $seccion = $resulth[0]->uni_descripcion;
             $variable = $seccion;
             $excluirparent = explode("(", $variable);
             if ($excluirparent[1] == "") {
                 $cadenah .= $resulth[0]->uni_descripcion;
             } else {
                 $excluirultimoparent = $excluirparent[1] . "x";
                 $imprimir_descripcion = explode(")", $excluirultimoparent);
                 $cadenah .= $imprimir_descripcion[0];
             }
         } else {
             $t = 0;
             if ($resulth[0]->uni_par == $resulth[0]->uni_id) {
                 $buscar = $resulth[0]->uni_par - 1;
             } else {
                 $buscar = $resulth[0]->uni_par;
             }
             while ($t < 1) {
                 $sql = "SELECT\r\n                            tab_unidad.uni_descripcion,tab_unidad.uni_par\r\n                            FROM\r\n                            tab_unidad\r\n                            WHERE\r\n                            tab_unidad.uni_id = {$buscar}";
                 $tab_unidad = new tab_unidad();
                 $resultado = $tab_unidad->dbSelectBySQL($sql);
                 $uni_par = $resultado[0]->uni_par;
                 if ($resultado[0]->uni_par == -1) {
                     $t++;
                     $seccion = $resultado[0]->uni_descripcion;
                     $variable = $seccion;
                     $excluirparent = explode("(", $variable);
                     if ($excluirparent[1] == "") {
                         $cadenah .= $resultado[0]->uni_descripcion;
                     } else {
                         $excluirultimoparent = $excluirparent[1] . "x";
                         $imprimir_descripcion = explode(")", $excluirultimoparent);
                         $cadenah .= $imprimir_descripcion[0];
                     }
                 } else {
                     $buscar = $resultado[0]->uni_par - 1;
                 }
             }
         }
         //fin de codigo de seccion
         $cadenah .= '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">TOTAL DE PIEZAS:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">' . $resulth[0]->totpzs . '</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">SUB SECCI&Oacute;N:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">';
         $cadenah .= $resulth[0]->uni_descripcion;
         $cadenah .= '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">TOTAL DE ML:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">' . $resulth[0]->totml . '</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">C&Oacute;DIGO DE REFERENCIA:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">' . $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="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">NIVEL DE DESCRIPCI&Oacute;N:</span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;">UNIDAD DOCUMENTAL SIMPLE</span></td>';
         $cadenah .= '</tr>';
         $cadenah .= '<tr>';
         $cadenah .= '<td width="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">SERIES:</span></td>';
         $cadenah .= '<td width="350"><span style="font-size: 14px;">' . $resulth[0]->ser_categoria . '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">FECHAS EXTREMAS:</span></td>';
         $cadenah .= '<td width="270"><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="100" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">EXPEDIENTE(PROYECTO):</span></td>';
         $cadenah .= '<td width="350" ><span style="font-size: 14px;">' . $resulth[0]->exp_titulo . '</span></td>';
         $cadenah .= '<td width="90" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;"></span></td>';
         $cadenah .= '<td width="220"><span style="font-size: 14px;"></span></td>';
         $cadenah .= '</tr>';
         $exp_titulo = $resulth[0]->exp_titulo;
         $camposc = new expcampo();
         $resultdc = $camposc->obtenerSelectCamposRepDoc($filtro_serie, $filtro_expediente);
         $cadenah .= $resultdc;
         $cadenah .= '</table>';
     }
     $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);
     $this->usuario = new usuario();
     $cadena = "";
     $cadena .= '<table width="760" border="1" cellpadding="2">';
     $cadena .= '<tr bgcolor="#CCCCCC">';
     $cadena .= '<td colspan="19" align="center" width="700"><span style="font-size: 12px;font-weight: bolder;">&Aacute;REA DE IDENTIFICACI&Oacute;N</span></td>';
     $cadena .= '<td width="60" align="center"><span style="font-size: 12px;font-weight: bolder;">&Aacute;REA DE NOTAS</span></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr bgcolor="#CCCCCC">';
     $cadena .= '<td width="25"  rowspan="2" align="center"><span style="font-size: 11px ;font-weight: bold;">N de Caja</span></td>';
     $cadena .= '<td width="25" rowspan="2" align="center"><span style="font-size: 11px ;font-weight: bold;">Total piezas/cajas</span></td>';
     $cadena .= '<td width="25" rowspan="2" align="center"><span style="font-size: 11px ;font-weight: bold;">N ejem.</span></td>';
     $cadena .= '<td width="25" rowspan="2" align="center"><span style="font-size: 11px; font-weight: bold;">ML</span></td>';
     $cadena .= '<td width="60" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">N de Orden doc.</span></td>';
     $cadena .= '<td width="40" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Depto.</span></td>';
     $cadena .= '<td width="90" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Titulo del Documento</span></td>';
     $cadena .= '<td width="70" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Sub titulo</span></td>';
     $cadena .= '<td width="45" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Productor</span></td>';
     $cadena .= '<td width="40" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Firma</span></td>';
     $cadena .= '<td width="35" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Fecha</span></td>';
     $cadena .= '<td width="35" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Tomo/Volumen</span></td>';
     $cadena .= '<td width="25" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Fojas</span></td>';
     $cadena .= '<td width="30" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Soporte F&iacute;sico</span></td>';
     $cadena .= '<td width="30" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Conser. Doc.</span></td>';
     $cadena .= '<td width="100" colspan="4" align="center"><span style="font-size: 11px ;font-weight: bold;">Ubicaci&oacute;n Topografica</span></td>';
     $cadena .= '<td width="60" rowspan="2" align="center" valign="middle"><span style="font-size: 11px ;font-weight: bold;">Observaciones</span></td>';
     $cadena .= '</tr>';
     $cadena .= '<tr bgcolor="#CCCCCC">';
     $cadena .= '<td width="25" align="center"><span style="font-size: 11px ;font-weight: bold;">Sala</span></td>';
     $cadena .= '<td width="25" align="center"><span style="font-size: 11px ;font-weight: bold;">Estante</span></td>';
     $cadena .= '<td width="25" align="center"><span style="font-size: 11px ;font-weight: bold;">Cuerpo</span></td>';
     $cadena .= '<td width="25" align="center"><span style="font-size: 11px ;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="100%" colspan="20"><span style="font-size: 11px;">' . $fila->tra_descripcion . '</span></td>';
             $cadena .= '</tr>';
             //
             $cadena .= '<tr>';
             $cadena .= '<td  width="25"><span style="font-size: 11px;">' . $fila->fil_nrocaj . '</span></td>';
             $cadena .= '<td  width="25"><span style="font-size: 11px;"></span></td>';
             $cadena .= '<td  width="25"><span style="font-size: 11px;">' . $fila->fil_nroejem . '</span></td>';
             $cadena .= '<td  width="25"><span style="font-size: 11px;"></span></td>';
             $cadena .= '<td  width="60"><span style="font-size: 11px;">' . $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="40"><span style="font-size: 11px;">' . $fila->exp_lugar . '</span></td>';
             $cadena .= '<td width="90"><span style="font-size: 11px;">' . $fila->fil_titulo . '</span></td>';
             $cadena .= '<td width="70"><span style="font-size: 11px;">' . $fila->fil_subtitulo . '</span></td>';
             $cadena .= '<td width="45"><span style="font-size: 11px;">' . $fila->fil_proc . '</span></td>';
             $cadena .= '<td width="40"><span style="font-size: 11px;">' . $fila->fil_firma . '</span></td>';
             $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_mes . ' ' . $fila->fil_anio . ' - ' . $fila->fil_mesf . ' ' . $fila->fil_aniof . '</span></td>';
             $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_tomovol . '</span></td>';
             $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_nrofoj . '</span></td>';
             $cadena .= '<td width="30"><span style="font-size: 11px;">' . $fila->sof_codigo . '</span></td>';
             $cadena .= '<td width="30"><span style="font-size: 11px;">' . $fila->fil_mrb . '</span></td>';
             $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_sala . '</span></td>';
             $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_estante . '</span></td>';
             $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_cuerpo . '</span></td>';
             $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_balda . '</span></td>';
             $cadena .= '<td width="60"><span style="font-size: 11px;">' . $fila->fil_obs . '</span></td>';
             $cadena .= '</tr>';
         } else {
             $cadena .= '<tr>';
             $cadena .= '<td  width="25"><span style="font-size: 11px;">' . $fila->fil_nrocaj . '</span></td>';
             $cadena .= '<td  width="25"><span style="font-size: 11px;"></span></td>';
             $cadena .= '<td  width="25"><span style="font-size: 11px;">' . $fila->fil_nroejem . '</span></td>';
             $cadena .= '<td  width="25"><span style="font-size: 11px;"></span></td>';
             $cadena .= '<td  width="60"><span style="font-size: 11px;">' . $fila->fon_cod . DELIMITER . $fila->uni_cod . DELIMITER . $fila->tco_codigo . DELIMITER . $fila->ser_codigo . DELIMITER . $fila->exp_codigo . DELIMITER . $fila->cue_codigo . DELIMITER . $fila->fil_nro . '</span></td>';
             $cadena .= '<td width="40"><span style="font-size: 11px;">' . $fila->exp_lugar . '</span></td>';
             $cadena .= '<td width="90"><span style="font-size: 11px;">' . $fila->fil_titulo . '</span></td>';
             $cadena .= '<td width="70"><span style="font-size: 11px;">' . $fila->fil_subtitulo . '</span></td>';
             $cadena .= '<td width="45"><span style="font-size: 11px;">' . $fila->fil_proc . '</span></td>';
             $cadena .= '<td width="40"><span style="font-size: 11px;">' . $fila->fil_firma . '</span></td>';
             $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_mes . ' ' . $fila->fil_anio . ' - ' . $fila->fil_mesf . ' ' . $fila->fil_aniof . '</span></td>';
             $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_tomovol . '</span></td>';
             $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_nrofoj . '</span></td>';
             $cadena .= '<td width="30"><span style="font-size: 11px;">' . $fila->sof_codigo . '</span></td>';
             $cadena .= '<td width="30"><span style="font-size: 11px;">' . $fila->fil_mrb . '</span></td>';
             $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_sala . '</span></td>';
             $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_estante . '</span></td>';
             $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_cuerpo . '</span></td>';
             $cadena .= '<td width="25"><span style="font-size: 11px;">' . $fila->fil_balda . '</span></td>';
             $cadena .= '<td width="60"><span style="font-size: 11px;">' . $fila->fil_obs . '</span></td>';
             $cadena .= '</tr>';
         }
         $numero++;
         $tra_descripciona = $fila->tra_descripcion;
     }
     //obtenerSelectCamposRepC
     $cadena .= '</table>';
     $cadena = $cadenah . $cadena;
     echo $cadena;
 }
 function printFichaSearchExpediente()
 {
     $exp_id = VAR3;
     $dov_id = VAR4;
     $where = "";
     //        if ($_SESSION['ROL_COD'] != 'AA') {
     //            $where = " AND tab_expusuario.usu_id=" . $_SESSION['USU_ID'] . "";
     //        }
     $tarchivo = new tab_archivo();
     $select = "SELECT\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                f.fon_cod,\r\n                tab_unidad.uni_cod,\r\n                tab_tipocorr.tco_codigo,\r\n                tab_series.ser_id,\r\n                tab_series.ser_codigo,\r\n                tab_expediente.exp_id,\r\n                tab_expediente.exp_codigo,\r\n                tab_expisadg.exp_fecha_exi,\r\n                tab_expisadg.exp_fecha_exf,\r\n                tab_expisadg.exp_nivdes,\r\n                tab_expisadg.exp_volsop,\r\n                tab_expisadg.exp_nomprod,\r\n                tab_expisadg.exp_hisins,\r\n                tab_expisadg.exp_hisarc,\r\n                tab_expisadg.exp_foring,\r\n                tab_expisadg.exp_alccon,\r\n                tab_expisadg.exp_vaseel,\r\n                tab_expisadg.exp_nueing,\r\n                tab_expisadg.exp_org,\r\n                tab_expisadg.exp_conacc,\r\n                tab_expisadg.exp_conrep,\r\n                tab_expisadg.exp_lengua,\r\n                tab_expisadg.exp_carfis,\r\n                tab_expisadg.exp_insdes,\r\n                tab_expisadg.exp_exloor,\r\n                tab_expisadg.exp_exloco,\r\n                tab_expisadg.exp_underel,\r\n                tab_expisadg.exp_notpub,\r\n                tab_expisadg.exp_notas,\r\n                tab_expisadg.exp_notarc,\r\n                tab_expisadg.exp_regnor,\r\n                tab_expisadg.exp_fecdes,\r\n                tab_expisadg.exp_estado,\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_expediente.sof_id,\r\n                tab_expediente.exp_nrofoj,\r\n                tab_expediente.exp_tomovol,\r\n                tab_expediente.exp_nroejem,\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                tab_expediente.exp_estado,\r\n                tab_expisadg.idi_id,\r\n                tab_expediente.exp_ori,\r\n                tab_expediente.exp_cop,\r\n                tab_expediente.exp_fot,\r\n                tab_expediente.exp_lugar";
     $from = "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_expusuario.eus_estado = 1 AND\r\n                tab_expediente.exp_id = '{$exp_id}'\r\n                {$where} ";
     $sql = "{$select} {$from} ";
     $result = $tarchivo->dbSelectBySQL($sql);
     //print $sql;
     $this->usuario = new usuario();
     // PDF
     // Landscape
     require_once 'tcpdf/config/lang/eng.php';
     require_once 'tcpdf/tcpdf.php';
     $pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->setFontSubsetting(FALSE);
     $pdf->SetAuthor($this->usuario->obtenerNombre($_SESSION['USU_ID']));
     $pdf->SetTitle('Reporte Ficha del Expediente');
     $pdf->SetSubject('Reporte Ficha del Expediente');
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     //        aumentado
     $pdf->SetKeywords('Castellon, SISTEMA DE PASAJES Y VIƁTICOS');
     // set default header data
     $pdf->SetHeaderData('logo2.png', 20, 'MPD', 'Administradora Boliviana de Carreteras');
     // 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->SetMargins(10, 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);
     $pdf->SetFont('helvetica', '', 11);
     // add a page
     $pdf->AddPage();
     // Report
     $pdf->Image(PATH_ROOT . '/web/img/iso.png', '255', '8', 15, 15, 'PNG', '', 'T', false, 300, '', false, false, 1, false, false, false);
     $cadena = "<br/><br/><br/><br/><br/><br/>";
     $cadena .= '<table width="580" border="0" >';
     $cadena .= '<tr><td align="center">';
     $cadena .= '<span style="font-size: 30px;font-weight: bold;">';
     $cadena .= 'Reporte Ficha del Expediente';
     $cadena .= '</span>';
     $cadena .= '</td></tr>';
     foreach ($result as $fila) {
         $cadena .= '<tr><td align="left"><b>1. AREA DE INDENTIFICACI&Oacute;N</b></td></tr>';
         $cadena .= '<tr><td align="left"><b>Id: </b>' . $fila->exp_id . '</td></tr>';
         $cadena .= '<tr><td align="left"><b>C&oacute;digo: </b>' . $fila->fon_cod . DELIMITER . $fila->uni_cod . DELIMITER . $fila->tco_codigo . DELIMITER . $fila->ser_codigo . DELIMITER . $fila->exp_codigo . '</td></tr>';
         $cadena .= '<tr><td align="left"><b>Fondo:</b> ' . $fila->fon_codigo . '</td></tr>';
         $cadena .= '<tr><td align="left"><b>Secci&oacute;n:</b> ' . $fila->uni_descripcion . '</td></tr>';
         $cadena .= '<tr><td align="left"><b>Serie:</b> ' . $fila->ser_categoria . '</td></tr>';
         $cadena .= '<tr><td align="left"><b>T&iacute;tulo:</b> <b>' . $fila->exp_titulo . '</b></td></tr>';
         if ($fila->exp_mesi) {
             if ($fila->exp_anioi) {
                 $cadena .= '<tr><td align="left"><b>Fecha Inicial:</b> ' . $fila->exp_mesi . "/" . $fila->exp_anioi . '</td></tr>';
             } else {
                 $cadena .= '<tr><td align="left"><b>Fecha Inicial:</b> ' . $fila->exp_mesi . '</td></tr>';
             }
         } else {
             if ($fila->exp_anioi) {
                 $cadena .= '<tr><td align="left"><b>Fecha Inicial:</b> ' . $fila->fil_anioi . '</td></tr>';
             }
         }
         if ($fila->exp_mesf) {
             if ($fila->exp_aniof) {
                 $cadena .= '<tr><td align="left"><b>Fecha Final:</b> ' . $fila->exp_mesf . "/" . $fila->exp_aniof . '</td></tr>';
             } else {
                 $cadena .= '<tr><td align="left"><b>Fecha Final:</b> ' . $fila->exp_mesf . '</td></tr>';
             }
         } else {
             if ($fila->exp_aniof) {
                 $cadena .= '<tr><td align="left"><b>Fecha Final:</b> ' . $fila->exp_aniof . '</td></tr>';
             }
         }
         //            $cadena .= '<tr><td align="left"><b>Fecha Inicial:</b> ' . $fila->exp_mesi . "/" . $fila->exp_anioi . '</td></tr>';
         //            $cadena .= '<tr><td align="left"><b>Fecha Final:</b> ' . $fila->exp_mesf . "/" . $fila->exp_aniof . '</td></tr>';
         $cadena .= '<tr><td align="left"><b>Ubicaci&oacute;n Geogr&aacute;fica:</b> ' . $fila->exp_lugar . '</td></tr>';
         $cadena .= '<tr><td align="left"><b>Volumen y soporte de la Unidad de Descripci&oacute;n:</b> ' . $fila->exp_volsop . '</td></tr>';
         // Include dynamic fields
         $expcampo = new expcampo();
         $filcampo = $expcampo->obtenerSelectCamposShow($fila->ser_id, $fila->exp_id);
         if ($filcampo) {
             $cadena .= '<br/>';
             $cadena .= '<tr><td align="left"><b>Datos adicionales en la identificaci&oacute;n:</b> ' . "" . '</td></tr>';
             $cadena .= $filcampo;
         }
         $cadena .= '<br/><tr><td align="left"><b>2. AREA DE CONTEXTO</b></td></tr>';
         if ($fila->exp_nomprod) {
             $cadena .= '<tr><td align="left"><b>Nombre del o de los Productores:</b> ' . $fila->exp_nomprod . '</td></tr>';
         }
         if ($fila->exp_hisins) {
             $cadena .= '<tr><td align="left"><b>Historia Institucional/Rese&ntilde;a biogr&aacute;fica:</b> ' . $fila->exp_hisins . '</td></tr>';
         }
         if ($fila->exp_hisarc) {
             $cadena .= '<tr><td align="left"><b>Historia Archiv&iacute;stica:</b> ' . $fila->exp_hisarc . '</td></tr>';
         }
         if ($fila->exp_foring) {
             $cadena .= '<tr><td align="left"><b>Forma de ingreso:</b> ' . $fila->exp_foring . '</td></tr>';
         }
         $cadena .= '<br/><tr><td align="left"><b>3. AREA DE CONTENIDO Y ESTRUCTURA</b></td></tr>';
         if ($fila->exp_alccon) {
             $cadena .= '<tr><td align="left"><b>Alcance y contenido:</b> ' . $fila->exp_alccon . '</td></tr>';
         }
         if ($fila->exp_vaseel) {
             $cadena .= '<tr><td align="left"><b>Valoraci&oacute;n, selecci&oacute;n y eliminaci&oacute;n:</b> ' . $fila->exp_vaseel . '</td></tr>';
         }
         if ($fila->exp_nueing) {
             $cadena .= '<tr><td align="left"><b>Nuevos Ingresos:</b> ' . $fila->exp_nueing . '</td></tr>';
         }
         if ($fila->exp_org) {
             $cadena .= '<tr><td align="left"><b>Organizaci&oacute;n:</b> ' . $fila->exp_org . '</td></tr>';
         }
         $idioma = new idioma();
         $cadena .= '<br/><tr><td align="left"><b>4. AREA DE CONDICIONES DE ACCESO Y USO</b></td></tr>';
         if ($fila->exp_conacc) {
             $cadena .= '<tr><td align="left"><b>Condiciones de Acceso:</b> ' . $fila->exp_conacc . '</td></tr>';
         }
         if ($fila->exp_conrep) {
             $cadena .= '<tr><td align="left"><b>Condiciones de Reproducci&oacute;n:</b> ' . $fila->exp_conrep . '</td></tr>';
         }
         if ($fila->idi_id) {
             $cadena .= '<tr><td align="left"><b>Lengua/Escritura de la documentaci&oacute;n:</b> ' . $idioma->obtenerIdioma($fila->idi_id) . '</td></tr>';
         }
         if ($fila->exp_carfis) {
             $cadena .= '<tr><td align="left"><b>Carater&iacute;sticas f&iacute;sicas o requisitos t&eacute;cnicos:</b> ' . $fila->exp_carfis . '</td></tr>';
         }
         if ($fila->exp_insdes) {
             $cadena .= '<tr><td align="left"><b>Instrumentos de descripci&oacute;n:</b> ' . $fila->exp_insdes . '</td></tr>';
         }
         $cadena .= '<br/><tr><td align="left"><b>5. AREA DE DOCUMENTACI&Oacute;N ASOCIADA</b></td></tr>';
         if ($fila->exp_exloor) {
             $cadena .= '<tr><td align="left"><b>Existencia y localizaci&oacute;n de originales:</b> ' . $fila->exp_exloor . '</td></tr>';
         }
         if ($fila->exp_exloco) {
             $cadena .= '<tr><td align="left"><b>Existencia y localizaci&oacute;n de copias:</b> ' . $fila->exp_exloco . '</td></tr>';
         }
         if ($fila->exp_underel) {
             $cadena .= '<tr><td align="left"><b>Unidades de descripci&oacute;n relacionadas:</b> ' . $fila->exp_underel . '</td></tr>';
         }
         if ($fila->exp_notpub) {
             $cadena .= '<tr><td align="left"><b>Notas de publicaci&oacute;n:</b> ' . $fila->exp_notpub . '</td></tr>';
         }
         $cadena .= '<br/><tr><td align="left"><b>6. AREA DE NOTAS</b></td></tr>';
         if ($fila->exp_notas) {
             $cadena .= '<tr><td align="left"><b>Notas:</b> ' . $fila->exp_notas . '</td></tr>';
         }
         $cadena .= '<br/><tr><td align="left"><b>7. AREA DE CONTROL DE LA DESCRIPCI&Oacute;N</b></td></tr>';
         if ($fila->exp_notarc) {
             $cadena .= '<tr><td align="left"><b>Notas del archivero:</b> ' . $fila->exp_notarc . '</td></tr>';
         }
         if ($fila->exp_regnor) {
             $cadena .= '<tr><td align="left"><b>Reglas o Normas:</b> ' . $fila->exp_regnor . '</td></tr>';
         }
         if ($fila->exp_fecdes) {
             $cadena .= '<tr><td align="left"><b>Fecha de la descripci&oacute;n:</b> ' . $fila->exp_fecdes . '</td></tr>';
         }
         $sop_fisico = new tab_sopfisico();
         $nombresopf = $sop_fisico->dbselectByField("sof_id", $fila->sof_id);
         $nombresopf = $nombresopf[0];
         $cadena .= '<br/><tr><td align="left"><b>8. PRESENTACI&Oacute;N DEL EXPEDIENTE</b></td></tr>';
         if ($nombresopf->sof_nombre) {
             $cadena .= '<tr><td align="left"><b>Soporte F&iacute;sico:</b> ' . $nombresopf->sof_nombre . '</td></tr>';
         }
         if ($fila->exp_nrofoj) {
             $cadena .= '<tr><td align="left"><b>Nro. de Fojas:</b> ' . $fila->exp_nrofoj . '</td></tr>';
         }
         if ($fila->exp_tomovol) {
             $cadena .= '<tr><td align="left"><b>Tomos (Vols):</b> ' . $fila->exp_tomovol . '</td></tr>';
         }
         if ($fila->exp_nroejem) {
             $cadena .= '<tr><td align="left"><b>Nro. Ejemplares:</b> ' . $fila->exp_nroejem . '</td></tr>';
         }
         if ($fila->exp_ori) {
             $cadena .= '<tr><td align="left"><b>Originales:</b> ' . $fila->exp_ori . '</td></tr>';
         }
         if ($fila->exp_cop) {
             $cadena .= '<tr><td align="left"><b>Copias:</b> ' . $fila->exp_cop . '</td></tr>';
         }
         if ($fila->exp_fot) {
             $cadena .= '<tr><td align="left"><b>Duplicados:</b> ' . $fila->exp_fot . '</td></tr>';
         }
         if ($fila->exp_nrocaj) {
             $cadena .= '<tr><td align="left"><b>Nro. de Caja:</b> ' . $fila->exp_nrocaj . '</td></tr>';
         }
         if ($fila->exp_sala) {
             $cadena .= '<tr><td align="left"><b>Sala:</b> ' . $fila->exp_sala . '</td></tr>';
         }
         if ($fila->exp_estante) {
             $cadena .= '<tr><td align="left"><b>Estante:</b> ' . $fila->exp_estante . '</td></tr>';
         }
         if ($fila->exp_cuerpo) {
             $cadena .= '<tr><td align="left"><b>Cuerpo:</b> ' . $fila->exp_cuerpo . '</td></tr>';
         }
         if ($fila->exp_balda) {
             $cadena .= '<tr><td align="left"><b>Balda:</b> ' . $fila->exp_balda . '</td></tr>';
         }
         if ($fila->exp_obs) {
             $cadena .= '<tr><td align="left"><b>Observaciones:</b> ' . $fila->exp_obs . '</td></tr>';
         }
         // Key words
         $palclave = new palclave();
         $cadena .= '<tr><td align="left"><b>Palabras claves:</b> ' . $palclave->listaPCFile2($fila->exp_id) . '</td></tr>';
     }
     $cadena .= '</table>';
     //$cadena .= '</table>';
     $pdf->writeHTML($cadena, true, false, false, false, '');
     // Close and output PDF document
     $pdf->Output('ficha_expediente.pdf', 'I');
 }
 function view()
 {
     if (!VAR3) {
         die("Error del sistema 404");
     }
     $expcampo = new expcampo();
     $ser_categoria = "";
     $this->expcampo = new tab_expcampo();
     $sql = "SELECT * \r\n                FROM tab_expcampo \r\n                WHERE ecp_id = " . VAR3;
     $resul = $this->expcampo->dbselectBySQL($sql);
     if (!$resul) {
         die("Error del sistema 404");
     }
     if (count($resul)) {
         $ser_id = $resul[0]->ser_id;
         $series = new series();
         $ser_categoria = $series->getTitle($ser_id);
     } else {
         $ser_id = "";
     }
     $this->expcampo->setRequest2Object($_REQUEST);
     $ecp_id = VAR3;
     $row = $this->expcampo->dbselectByField("ecp_id", $ecp_id);
     $row = $row[0];
     $this->registry->template->ser_categoria = $ser_categoria;
     $this->registry->template->ser_id = $ser_id;
     $this->registry->template->ecp_id = $row->ecp_id;
     $this->registry->template->ecp_orden = $row->ecp_orden;
     $this->registry->template->ecp_nombre = $row->ecp_nombre;
     $this->registry->template->ecp_eti = $row->ecp_eti;
     $this->registry->template->ecp_tipdat = $expcampo->obtenerSelectTipoDato($row->ecp_tipdat);
     $this->registry->template->titulo = "Editar ";
     $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";
     $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('serie/tab_expcampo.tpl');
     $this->registry->template->show('footer');
 }
 function getDetalles($id)
 {
     $expediente = new expediente();
     $det = "";
     $tab_expediente = new Tab_expediente();
     $rows = $tab_expediente->dbselectByField("exp_id", $id);
     if (count($rows) == 1) {
         $tab_expediente = $rows[0];
         // Expediente ISAD-G
         $tab_expisadg = new Tab_expisadg();
         $rows2 = $tab_expisadg->dbselectByField("exp_id", $id);
         $tab_expisadg = $rows2[0];
         // Include dynamic fields
         $expcampo = new expcampo();
         $expadicional = $expcampo->obtenerSelectCamposMostrar($tab_expediente->ser_id, $tab_expediente->exp_id);
         $det .= '<tr><td><strong>C&oacute;digo:</strong></td><td colspan="3">' . $expediente->obtenerCodigo($id) . '</td></tr>';
         $det .= '<tr><td><strong>Fecha Inicial:</strong></td><td colspan="3">' . $tab_expisadg->exp_mesi . '/' . $tab_expisadg->exp_anioi . '</td></tr>';
         $det .= '<tr><td><strong>Fecha Final:</strong></td><td colspan="3">' . $tab_expisadg->exp_mesf . '/' . $tab_expisadg->exp_aniof . '</td></tr>';
         if ($tab_expediente->exp_sala || $tab_expediente->exp_estante || $tab_expediente->exp_cuerpo || $tab_expediente->exp_balda) {
             $det .= '<tr><td>Unidad de instalaci&oacute;n:</td><td colspan="3"></td></tr>';
         }
         if ($tab_expediente->exp_sala) {
             $det .= '<tr><td><strong>Sala:</strong></td><td colspan="3">' . $tab_expediente->exp_sala . '</td></tr>';
         }
         if ($tab_expediente->exp_estante) {
             $det .= '<tr><td><strong>Estante:</strong></td><td colspan="3">' . $tab_expediente->exp_estante . '</td></tr>';
         }
         if ($tab_expediente->exp_cuerpo) {
             $det .= '<tr><td><strong>Cuerpo:</strong></td><td colspan="3">' . $tab_expediente->exp_cuerpo . '</td></tr>';
         }
         if ($tab_expediente->exp_balda) {
             $det .= '<tr><td><strong>Balda:</strong></td><td colspan="3">' . $tab_expediente->exp_balda . '</td></tr>';
         }
         if ($expadicional) {
             $det .= '<tr><td>Datos adicionales:</td><td colspan="3"></td></tr>' . $expadicional;
         }
     }
     return $det;
 }