function obtenerCustodios($exp_id)
 {
     $nom = "";
     $tusuario = new Tab_usuario();
     $sql = "SELECT\r\n                tu.usu_id,\r\n                tu.usu_nombres,\r\n                tu.usu_apellidos\r\n\t\tFROM tab_usuario tu\r\n\t\tINNER JOIN tab_expusuario teu ON teu.usu_id=tu.usu_id\r\n\t\tWHERE teu.exp_id ='" . $exp_id . "' AND teu.eus_estado = '1' ";
     $users = $tusuario->dbSelectBySQL($sql);
     if (count($users) > 0) {
         foreach ($users as $user) {
             $nom .= $user->usu_nombres . " " . $user->usu_apellidos . ", ";
         }
     }
     $nom = substr($nom, 0, -2);
     return $nom;
 }
 function verRpte()
 {
     $spr_id = $_REQUEST["spr_id"];
     //        $where = " AND tab_usuario.usu_id = " . $_SESSION['USU_ID'];
     $where = "";
     $where = " AND tab_solprestamo.spr_id = " . $spr_id;
     $order_by = "";
     $order_by .= " ORDER BY dpr_orden";
     $sql = "SELECT\r\n                tab_solprestamo.spr_id,\r\n                tab_solprestamo.spr_fecha,\r\n                (SELECT uni_descripcion from tab_unidad WHERE uni_id=tab_solprestamo.uni_id) AS uni_id,\r\n                (SELECT usu_nombres || ' ' || usu_apellidos from tab_usuario WHERE usu_id=tab_solprestamo.usu_id) AS usu_id,\r\n                tab_solprestamo.spr_solicitante,\r\n                tab_solprestamo.spr_email,\r\n                tab_solprestamo.spr_tel,\r\n                tab_solprestamo.spr_fecent,\r\n                tab_solprestamo.spr_fecren,\r\n                (SELECT usu_nombres || ' ' || usu_apellidos from tab_usuario WHERE usu_id=tab_solprestamo.usua_id) AS usua_id,\r\n                (SELECT usu_nombres || ' ' || usu_apellidos from tab_usuario WHERE usu_id=tab_solprestamo.usur_id) AS usur_id,\r\n                tab_solprestamo.spr_fecdev,\r\n                tab_solprestamo.spr_obs,\r\n                tab_solprestamo.spr_estado,\r\n                tab_docprestamo.dpr_orden,\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_archivo.fil_titulo,\r\n                tab_archivo.fil_proc,\r\n                tab_archivo.fil_firma,\r\n                tab_archivo.fil_tomovol,\r\n                tab_sopfisico.sof_nombre,\r\n                tab_archivo.fil_nrofoj,\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_nrocaj,\r\n                tab_docprestamo.dpr_obs\r\n                FROM\r\n                tab_fondo\r\n                INNER JOIN tab_unidad ON tab_fondo.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_docprestamo ON tab_archivo.fil_id = tab_docprestamo.fil_id\r\n                INNER JOIN tab_solprestamo ON tab_solprestamo.spr_id = tab_docprestamo.spr_id\r\n                INNER JOIN tab_sopfisico ON tab_sopfisico.sof_id = tab_archivo.sof_id\r\n                WHERE\r\n                tab_fondo.fon_estado = 1 AND\r\n                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_archivo.fil_estado = 1 AND\r\n                tab_docprestamo.dpr_estado = 1 AND\r\n                tab_solprestamo.spr_estado = 1 " . $where . $order_by;
     $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 Prestamos');
     $pdf->SetSubject('Reporte de Prestamos');
     //        aumentado
     $pdf->SetKeywords('Castellon, TEAM DIGITAL');
     // 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->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);
     $sqltop = "SELECT\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                    FROM\r\n                    tab_unidad\r\n                    INNER JOIN tab_usuario ON tab_usuario.uni_id = tab_unidad.uni_id\r\n                    INNER JOIN tab_rol ON tab_usuario.rol_id = tab_rol.rol_id\r\n                    WHERE tab_usuario.usu_estado = 1 AND tab_usuario.usu_id = " . $_SESSION['USU_ID'];
     $usuario = new Tab_usuario();
     $resultop = $usuario->dbselectBySQL($sqltop);
     $cadena = "<br/><br/><br/><br/><br/><br/><br/><br/>";
     if (count($resultop) > 0) {
         $cadena .= '<table width="760" border="0" cellpadding="2">';
         $cadena .= '<tr><td align="center">';
         $cadena .= '<span style="font-size: 24px;">' . $resultop[0]->uni_descripcion . ' (' . $resultop[0]->uni_codigo . ')</span>';
         $cadena .= '</td></tr>';
         $cadena .= '<tr><td align="center">';
         $cadena .= '<span style="font-size: 24px;">' . $resultop[0]->rol_titulo . ' (' . $resultop[0]->rol_cod . ')</span>';
         $cadena .= '</td></tr>';
         $cadena .= '<tr><td align="center">';
         $cadena .= '<span style="font-size: 30px;font-weight: bold;text-decoration: underline;">';
         $cadena .= 'FORMULARIO DE SALIDA DOCUMENTAL';
         $cadena .= '</span>';
         $cadena .= '</td></tr>';
         $cadena .= '<tr><td align="center">';
         $cadena .= '<span style="font-size: 24px;">(Para uso de las diferentes unidades y/o &aacute;reas solicitantes)</span>';
         $cadena .= '</td></tr>';
         $cadena .= '</table>';
         $cadena .= '<br/><br/>';
     }
     if (count($result) > 0) {
         $cadena .= '<table width="760" border="1" cellpadding="2">';
         $cadena .= '<tr>';
         $cadena .= '<td width="130" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">FECHA DE SOLICITUD:</span></td>';
         $cadena .= '<td width="130"><span style="font-size: 14px;">' . $result[0]->spr_fecha . '</span></td>';
         $cadena .= '<td width="130" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">Ubicado:</span></td>';
         $cadena .= '<td width="130"><span style="font-size: 14px;">' . $result[0]->spr_fecha . '</span></td>';
         $cadena .= '<td width="130" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">Nro. DE PR&Eacute;STAMO:</span></td>';
         $cadena .= '<td width="110"><span style="font-size: 14px;">' . 'no hay query' . '</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr>';
         $cadena .= '<td width="130" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">GCIA/UNIDAD/&Aacute;REA:</span></td>';
         $cadena .= '<td width="130"><span style="font-size: 14px;">' . $result[0]->uni_id . '</span></td>';
         $cadena .= '<td width="130" bgcolor="#CCCCCC"><span style="font-size: 14px;font-weight: bold;">SOLICITADO POR:</span></td>';
         $cadena .= '<td colspan="3"><span style="font-size: 14px;">' . 'no hay query' . '</span></td>';
         $cadena .= '</tr>';
         $cadena .= '</table>';
     }
     $cadena .= '<table width="760" border="1" cellpadding="2">';
     $cadena .= '<tr bgcolor="#CCCCCC">';
     $cadena .= '<td width="30" rowspan="2" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">N</span></td>';
     $cadena .= '<td width="70" rowspan="2" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">C&oacute;digo de Referencia</span></td>';
     $cadena .= '<td width="120" rowspan="2" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Documento Solicitado</span></td>';
     $cadena .= '<td width="70" rowspan="2" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Productor</span></td>';
     $cadena .= '<td width="60" rowspan="2" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Firma</span></td>';
     $cadena .= '<td width="60" rowspan="2" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Fechas Extremas</span></td>';
     $cadena .= '<td width="35" rowspan="2" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Tomo/Vol.</span></td>';
     $cadena .= '<td width="35" rowspan="2" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Sop. Fis.</span></td>';
     $cadena .= '<td width="35" rowspan="2" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">N Fojas</span></td>';
     $cadena .= '<td width="175" colspan="5" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Localizaci&oacute;n Topogr&aacute;fica</span></td>';
     $cadena .= '<td width="70" 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="35" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Sala</span></td>';
     $cadena .= '<td width="35" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Estante</span></td>';
     $cadena .= '<td width="35" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Cuerpo</span></td>';
     $cadena .= '<td width="35" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Balda</span></td>';
     $cadena .= '<td width="35" align="center" valign="middle"><span style="font-size: 11px;font-weight: bold;">Caja</span></td>';
     $cadena .= '</tr>';
     foreach ($result as $fila) {
         $cadena .= '<tr>';
         $cadena .= '<td width="30"><span style="font-size: 11px;">' . $fila->dpr_orden . '</span></td>';
         $cadena .= '<td width="70"><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="120"><span style="font-size: 11px;">' . $fila->fil_titulo . '</span></td>';
         $cadena .= '<td width="70"><span style="font-size: 11px;">' . $fila->fil_proc . '</span></td>';
         $cadena .= '<td width="60"><span style="font-size: 11px;">' . $fila->fil_firma . '</span></td>';
         $cadena .= '<td width="60"><span style="font-size: 11px;">' . 'no hay query' . '</span></td>';
         $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_tomovol . '</span></td>';
         $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->sof_nombre . '</span></td>';
         $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_nrofoj . '</span></td>';
         $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_sala . '</span></td>';
         $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_estante . '</span></td>';
         $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_cuerpo . '</span></td>';
         $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_balda . '</span></td>';
         $cadena .= '<td width="35"><span style="font-size: 11px;">' . $fila->fil_nrocaj . '</span></td>';
         $cadena .= '<td width="70"><span style="font-size: 11px;">' . $fila->dpr_obs . '</span></td>';
         $cadena .= '</tr>';
     }
     $cadena .= '</table>';
     if (count($result) > 0) {
         $cadena .= '<br/>';
         $cadena .= '<table width="760" border="1" cellpadding="2">';
         $cadena .= '<tr>';
         $cadena .= '<td width="130" height="50"><span style="font-size: 14px;font-weight: bold;">Nombre Completo del Solicitante:</span></td>';
         $cadena .= '<td width="500" height="50"><span style="font-size: 14px;">' . $result[0]->spr_solicitante . '</span></td>';
         $cadena .= '<td width="130" height="50" align="center"><span style="font-size: 14px;">Firma</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr>';
         $cadena .= '<td width="130"><span style="font-size: 14px;font-weight: bold;">Documento Retirado del Archivo:</span></td>';
         $cadena .= '<td colspan="2"><span style="font-size: 14px;">' . 'no hay query' . '</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr>';
         $cadena .= '<td width="130"><span style="font-size: 14px;font-weight: bold;">Fecha Entrega Doc.:</span></td>';
         $cadena .= '<td colspan="2"><span style="font-size: 14px;">' . $result[0]->spr_fecha . '</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr>';
         $cadena .= '<td width="130" height="50"><span style="font-size: 14px;font-weight: bold;">Nombre Completo del que Autoriza:</span></td>';
         $cadena .= '<td width="500" height="50"><span style="font-size: 14px;">' . $result[0]->usua_id . '</span></td>';
         $cadena .= '<td width="130" height="50" align="center"><span style="font-size: 14px;">Firma</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr>';
         $cadena .= '<td width="130" height="50"><span style="font-size: 14px;font-weight: bold;">Archivista Responsable:</span></td>';
         $cadena .= '<td width="500" height="50"><span style="font-size: 14px;">' . $result[0]->usur_id . '</span></td>';
         $cadena .= '<td width="130" height="50" align="center"><span style="font-size: 14px;">Firma</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr bordercolor="#FFFFFF">';
         $cadena .= '<td colspan="3"><span style="font-size: 14px">Llenado unicamente por el personal de archivo</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr>';
         $cadena .= '<td width="130"><span style="font-size: 14px;font-weight: bold;">Fecha de Devoluci&oacute;n:</span></td>';
         $cadena .= '<td colspan="2"><span style="font-size: 14px;">' . $result[0]->spr_fecdev . '</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr>';
         $cadena .= '<td width="130"><span style="font-size: 14px;font-weight: bold;">Observaciones:</span></td>';
         $cadena .= '<td colspan="2"><span style="font-size: 14px;">' . $result[0]->spr_obs . '</span></td>';
         $cadena .= '</tr>';
         $cadena .= '<tr bordercolor="#FFFFFF">';
         $cadena .= '<td colspan="3"><span style="font-size: 14px"><strong>Nota:</strong> A trav&eacute;s de este formulario cada funcionario se responsabiliza por el cuidado o cualquier deterioro del documento.</span></td>';
         $cadena .= '</tr>';
         $cadena .= '</table>';
     }
     //echo ($cadena);
     $pdf->writeHTML($cadena, true, false, false, false, '');
     // -----------------------------------------------------------------------------
     //Close and output PDF document
     $pdf->Output('reporte_prestamo.pdf', 'I');
 }
Exemplo n.º 3
0
 function imprimirMenu($seleccionado = '', $usuId = '')
 {
     $liMenu = "";
     $menu = new menu();
     //        $urm = new usurolmenu ();
     //        $swMenu = 0;
     //        $swSubMenu = 0;
     $parent = '0';
     if ($usuId != null || $usuId != "") {
         $usuario = new Tab_usuario();
         $sql = "SELECT\r\n                    usu_id,\r\n                    rol_id\r\n                    FROM tab_usuario\r\n                    WHERE usu_id='" . $usuId . "' ";
         $rolUsu = $usuario->dbSelectBySQL($sql);
         $arrayMenus = $menu->obtenerMenu($parent, $usuId);
         foreach ($arrayMenus as $menus) {
             $arraySubmenus = $menu->obtenerMenuUsuario($menus->men_id, $rolUsu[0]->rol_id);
             //                $id_urm = $urm->obtenerPermisosArchivosUsuarios($menus->men_id, $usuId);
             $classMenu = '';
             $classAct = '';
             if ($seleccionado != "") {
                 $padre = $menu->obtenerPadreXEnlace($seleccionado);
                 if (is_object($padre) && $padre->men_par == $menus->men_id) {
                     $classMenu = ' class="pagAct" ';
                     $classAct = ' class="Act" ';
                 } elseif ($menus->men_id == $menu->isHijo("plandesastre") && $seleccionado == "cronoact") {
                     $classMenu = ' class="pagAct" ';
                     $classAct = ' class="Act" ';
                 }
             }
             $liMenu .= '<li>';
             $liMenu .= '<!--[if lte IE 9]><a href="#"><table><tr><td><![endif]-->';
             $liMenu .= '<dl' . $classAct . '>';
             $addMenu = '';
             if ($classMenu != "pagAct") {
                 $addMenu .= ' class="' . $menus->men_id . 'x" style="display:none;" ';
             }
             $liMenu .= '<dt><a href="#" id="' . $menus->men_id . '" onclick="return false;" ' . $classMenu . '> ' . $menus->men_titulo . '</a></dt>';
             foreach ($arraySubmenus as $submenus) {
                 if (strtoupper($seleccionado) == strtoupper($submenus->men_enlace)) {
                     $classSubMenu = " class='subAct' ";
                 } elseif ($menus->men_id == $menu->isHijo("plandesastre") && $seleccionado == "cronoact" && strstr(strtoupper($submenus->men_enlace), strtoupper("plandesastre"))) {
                     $classSubMenu = " class='subAct' ";
                 } else {
                     $classSubMenu = "";
                 }
                 //                    $id_urm2 = $urm->obtenerPermisosArchivosUsuarios($submenus->men_id, $usuId);
                 $liMenu .= "<dd>" . "<a href='" . PATH_DOMAIN . "/" . $submenus->men_enlace . "/' " . $classSubMenu . ">" . $submenus->men_titulo . "</a></dd>\n";
             }
             $liMenu .= "</dl><!--[if lte IE 9]></td></tr></table></a><![endif]-->";
             $liMenu .= "</li>\n";
         }
     } else {
         Header("Location: " . PATH_DOMAIN . "/");
     }
     return $liMenu;
 }
    function verRpte()
    {
        set_time_limit(300);
        $series = new series();
        $this->registry->template->seccion = $series->obtenerSeccion();
        $this->registry->template->PATH_WEB = PATH_WEB;
        $this->registry->template->PATH_DOMAIN = PATH_DOMAIN;
        $this->registry->template->PATH_EVENT = "verRpte";
        $filtro_seccion = $_POST['filtro_seccion'];
        $palclave = new palclave();
        $usuario = new Tab_usuario();
        $where = "";
        $where .= " AND tab_usuario.usu_id ='" . $_SESSION['USU_ID'] . "' AND tab_usu_serie.usu_id='" . $_SESSION['USU_ID'] . "' ";
        $where .= " AND tab_unidad.uni_id = {$filtro_seccion}";
        //PARA LA ORDENACION SOLO SE ESCOJE UNA OPCION
        $order_by = "";
        $order_by .= " ORDER BY tab_expediente.exp_id ";
        //PARA LOS FILTROS
        $sqlh = "SELECT\r\nfonp.fon_descripcion AS fondes,\r\ntab_expediente.exp_id,\r\ntab_fondo.fon_cod,\r\ntab_unidad.uni_descripcion,\r\ntab_unidad.uni_cod,\r\ntab_unidad.uni_id,\r\ntab_tipoarch.tar_nombre,\r\ntab_tipocorr.tco_codigo,\r\ntab_series.ser_id,\r\ntab_series.ser_par,\r\ntab_series.ser_codigo,\r\n(NULLIF(tab_expediente.exp_codigo,'')::int) as correlativo,\r\ntab_expediente.exp_codigo,\r\ntab_expediente.exp_tomovol,\r\ntab_expediente.exp_nrocaj,\r\ntab_expediente.exp_nrofoj,\r\ntab_expediente.exp_sala,\r\ntab_expediente.exp_estante,\r\ntab_expediente.exp_cuerpo,\r\ntab_expediente.exp_balda,\r\ntab_expediente.exp_obs,\r\ntab_usuario.usu_nombres,\r\ntab_usuario.usu_apellidos,\r\ntab_expisadg.exp_titulo,\r\ntab_expisadg.exp_anioi,\r\ntab_expisadg.exp_aniof,\r\ntab_expisadg.exp_fecha_exi,\r\ntab_expisadg.exp_notas,\r\ntab_expisadg.exp_id,\r\ntab_expisadg.exp_alccon,\r\ntab_expisadg.exp_nomprod,\r\ntab_expfondo.fon_id,   \r\ntab_series.ser_id,\r\ntab_usu_serie.usu_id,\r\ntab_unidad.uni_par,\r\ntab_unidad.uni_id,\r\ntab_fondo.fon_descripcion,\r\ntab_series.ser_categoria\r\nFROM\r\n            tab_usuario\r\n            INNER JOIN tab_expusuario ON tab_usuario.usu_id = tab_expusuario.usu_id\r\n            INNER JOIN tab_expediente ON tab_expusuario.exp_id = tab_expediente.exp_id\r\n            INNER JOIN tab_expfondo ON tab_expediente.exp_id = tab_expfondo.exp_id\r\n            INNER JOIN tab_series ON tab_expediente.ser_id = tab_series.ser_id\r\n            INNER JOIN tab_usu_serie ON tab_series.ser_id = tab_usu_serie.ser_id\r\n            INNER JOIN tab_expisadg ON tab_expediente.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_tipoarch ON tab_tipoarch.tar_id = tab_unidad.tar_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            INNER JOIN tab_fondo as fonp ON tab_fondo.fon_par = fonp.fon_id\r\n            WHERE tab_fondo.fon_estado = 1\r\n            AND tab_unidad.uni_estado = 1\r\n            AND tab_series.ser_estado = 1\r\n            AND tab_tipocorr.tco_estado = 1\r\n            AND tab_expediente.exp_estado = 1\r\n            AND tab_expisadg.exp_estado = 1\r\n            AND tab_expfondo.exf_estado = 1\r\n            AND tab_expusuario.eus_estado = 1 " . $where . "order by correlativo";
        $expedienteh = new Tab_expediente();
        $resulth = $expedienteh->dbselectBySQL($sqlh);
        $cadenah = "";
        $exp_titulo = "";
        if (count($resulth) > 0) {
            $sumar = 0;
            $piezas = 0;
            $cadenah .= '<table width="100%" border="0" cellpadding="2">';
            $cadenah .= '</table>';
            $cadenah .= '<br/><br/>';
        }
        $cadena = "";
        $cadena .= '<table width="100%" border="1" cellpadding="2">';
        $cadena .= '<tr bgcolor="#CCCCCC">';
        $cadena .= '<td width="15" align="center"><span style="font-size: 7px;font-weight: bolder;">ACCI&Oacute;N</span></td>';
        $cadena .= '<td colspan="11" align="center" width="700"><span style="font-size: 10px;font-weight: bolder;">&Aacute;REA DE IDENTIFICACI&Oacute;N</span></td>';
        $cadena .= '<td width="60" align="center"><span style="font-size: 10px;font-weight: bolder;">&Aacute;REA DE NOTAS</span></td>';
        $cadena .= '</tr>';
        $cadena .= '<tr bgcolor="#CCCCCC">';
        $cadena .= '<td width="15" align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;"></span></td>';
        $cadena .= '<td width="65"  align="center"><span style="font-size: 10px ;font-weight: bold;">C&oacute;digo</span></td>';
        $cadena .= '<td width="200" align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Titulo/Subtitulo</span></td>';
        $cadena .= '<td width="65"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Fechas Extremas</span></td>';
        $cadena .= '<td width="45"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Tomo/V</span></td>';
        $cadena .= '<td width="45"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Responsable/<br>Productor</span></td>';
        $cadena .= '<td width="20"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Nro Fojas</span></td>';
        $cadena .= '<td width="25"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Caja</span></td>';
        $cadena .= '<td width="25"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Sala</span></td>';
        $cadena .= '<td width="30"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Estante</span></td>';
        $cadena .= '<td width="30"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Cuerpo</span></td>';
        $cadena .= '<td width="30"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Balda</span></td>';
        $cadena .= '<td width="200" align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;">Observaciones</span></td>';
        $cadena .= '</tr>';
        $i = 1;
        $j = 1;
        foreach ($resulth as $rows) {
            $cadena .= '<tr >';
            $cadena .= '<td colspan="11"><b>Serie/Subserie:</b> ' . $rows->ser_categoria . '</td>';
            $cadena .= '</tr>';
            $cadena .= '<tr>';
            $cadena .= '<td colspan="11"><span id="text-tituloexp' . $j . '"><b>Expediente:</b> ' . $rows->exp_titulo . '</span><input type="text" id="tituloexp' . $j . '" value="' . $rows->exp_titulo . '" style="display:none" size="110"></td>';
            $cadena .= '</tr>';
            $cadena .= '<tr style="color:green">';
            $cadena .= '<td><input type="image" src="' . PATH_DOMAIN . '/web/lib/32/edit.png" width="28"  id="editarexp' . $j . '" alt="Editar" onclick="editarexp(' . $j . ')" ><input type="image" src="' . PATH_DOMAIN . '/web/lib/32/disk2.png" id="guardarexp' . $j . '" onclick="guardarexpedientes(' . $j . ',' . $rows->exp_id . ')" style="display:none" ></td>';
            $cadena .= '<td style="font-size:10px"><b>' . $rows->fon_cod . DELIMITER . $rows->uni_cod . DELIMITER . $rows->tco_codigo . DELIMITER . $rows->ser_codigo . DELIMITER . $rows->exp_codigo . '</b></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-contenidoexp' . $j . '"><b>Alcance y contenido:</b><br>' . trim($rows->exp_alccon) . '<br><b>&Aacute;rea de Notas:</b><br>' . trim($rows->exp_notas) . '</span><textarea cols="40" rows="3" style="display:none" id="alconexp' . $j . '">' . $rows->exp_alccon . '</textarea><textarea cols="40" rows="3" style="display:none" id="notasexp' . $j . '">' . $rows->exp_notas . '</textarea></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-fechaexp' . $j . '"><b>' . $rows->exp_anioi . ' - ' . $rows->exp_aniof . '</b></span><input type="text" size="3" id="exp_anioi' . $j . '" style="display:none" value="' . $rows->exp_anioi . '"><input type="text" size="3" id="exp_aniof' . $j . '" style="display:none" value="' . $rows->exp_aniof . '"></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-tomovolexp' . $j . '"><b>' . $rows->exp_tomovol . '</b></span><input type="text" size="3" id="tomovolexp' . $j . '" style="display:none" value="' . $rows->exp_tomovol . '"></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-productorexp' . $j . '"><b>' . $rows->exp_nomprod . '</b></span><input type="text" size="25" id="productorexp' . $j . '" style="display:none" value="' . $rows->exp_nomprod . '"></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-nrofojasexp' . $j . '"><b>' . $rows->exp_nrofoj . '</b></span><input type="text" size="4" id="nrofojasexp' . $j . '" style="display:none" value="' . $rows->exp_nrofoj . '"></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-nrocajexp' . $j . '"><b>' . $rows->exp_nrocaj . '</b></span><input type="text" size="3" id="nrocajexp' . $j . '" style="display:none" value="' . $rows->exp_nrocaj . '"></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-salaexp' . $j . '"><b>' . $rows->exp_sala . '</b></span><input type="text" size="3" id="salaexp' . $j . '" style="display:none" value="' . $rows->exp_sala . '"></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-estanteexp' . $j . '"><b>' . $rows->exp_estante . '</b></span><input type="text" size="3" id="estanteexp' . $j . '" style="display:none" value="' . $rows->exp_estante . '"></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-cuerpoexp' . $j . '"><b>' . $rows->exp_cuerpo . '</b></span><input type="text" size="3" id="cuerpoexp' . $j . '" style="display:none" value="' . $rows->exp_cuerpo . '"></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-baldaexp' . $j . '"><b>' . $rows->exp_balda . '</b></span><input type="text" size="3" id="baldaexp' . $j . '" style="display:none" value="' . $rows->exp_balda . '"></td>';
            $cadena .= '<td style="font-size:10px"><span id="text-obsexp' . $j . '"><b>' . trim($rows->exp_obs) . '</b></span><textarea cols="40" rows="3" style="display:none" id="obsexp' . $j . '">' . trim($rows->exp_obs) . '</textarea></td>';
            $cadena .= '</tr>';
            $j++;
            $sql_doc = "SELECT\r\ntab_expediente.exp_id,\r\ntab_tipocorr.tco_codigo,\r\ntab_series.ser_id,\r\ntab_series.ser_codigo,\r\ntab_expediente.exp_codigo,\r\ntab_usuario.usu_nombres,\r\ntab_usuario.usu_apellidos,\r\ntab_expisadg.exp_titulo,\r\ntab_expisadg.exp_anioi,\r\ntab_expisadg.exp_aniof,\r\ntab_expisadg.exp_fecha_exi,\r\ntab_expfondo.fon_id,\r\ntab_series.ser_id,\r\ntab_usu_serie.usu_id,\r\ntab_unidad.uni_par,\r\ntab_unidad.uni_id,\r\ntab_fondo.fon_descripcion,\r\ntab_series.ser_categoria,\r\ntab_archivo.fil_subtitulo,\r\ntab_archivo.fil_nro,\r\ntab_archivo.fil_id,\r\ntab_archivo.fil_nropaq,\r\ntab_archivo.fil_titulo,\r\nfonp.fon_cod,\r\ntab_unidad.uni_cod,\r\ntab_archivo.fil_tomovol,\r\n(SELECT\r\ntab_sopfisico.sof_nombre\r\nFROM\r\ntab_sopfisico\r\nwhere tab_sopfisico.sof_id=tab_archivo.sof_id) AS cuaderno,\r\ntab_archivo.fil_nrocaj,\r\ntab_archivo.fil_sala,\r\ntab_archivo.fil_estante,\r\ntab_archivo.fil_cuerpo,\r\ntab_archivo.fil_balda,\r\ntab_archivo.fil_obs,\r\ntab_archivo.fil_proc,\r\ntab_archivo.fil_alccon,\r\ntab_archivo.fil_firma,\r\ntab_archivo.fil_nrofoj,\r\ntab_archivo.fil_anio,\r\ntab_archivo.fil_cantpaq,\r\ntab_archivo.fil_aniof\r\nFROM\r\ntab_usuario\r\nINNER JOIN tab_expusuario ON tab_usuario.usu_id = tab_expusuario.usu_id\r\nINNER JOIN tab_expediente ON tab_expusuario.exp_id = tab_expediente.exp_id\r\nINNER JOIN tab_expfondo ON tab_expediente.exp_id = tab_expfondo.exp_id\r\nINNER JOIN tab_series ON tab_expediente.ser_id = tab_series.ser_id\r\nINNER JOIN tab_usu_serie ON tab_series.ser_id = tab_usu_serie.ser_id\r\nINNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_id\r\nINNER JOIN tab_unidad ON tab_unidad.uni_id = tab_series.uni_id\r\nINNER JOIN tab_tipoarch ON tab_tipoarch.tar_id = tab_unidad.tar_id\r\nINNER JOIN tab_fondo ON tab_fondo.fon_id = tab_unidad.fon_id\r\nINNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id\r\nINNER JOIN tab_fondo AS fonp ON tab_fondo.fon_par = fonp.fon_id\r\nINNER JOIN tab_exparchivo ON tab_exparchivo.exp_id = tab_expediente.exp_id\r\nINNER JOIN tab_archivo ON tab_exparchivo.fil_id = tab_archivo.fil_id\r\nWHERE\r\ntab_fondo.fon_estado = 1 AND\r\ntab_unidad.uni_estado = 1 AND\r\ntab_series.ser_estado = 1 AND\r\ntab_tipocorr.tco_estado = 1 AND\r\ntab_archivo.fil_estado = 1 AND\r\ntab_expediente.exp_estado = 1 AND\r\ntab_expisadg.exp_estado = 1 AND\r\ntab_expfondo.exf_estado = 1 AND\r\ntab_expusuario.eus_estado = 1 and tab_expediente.exp_id={$rows->exp_id} {$where} order by tab_archivo.fil_nro";
            $rows2 = $usuario->dbSelectBySQL($sql_doc);
            foreach ($rows2 as $row) {
                $cadena .= '<tr style="color:#006699">';
                $cadena .= '<td><input type="image" src="' . PATH_DOMAIN . '/web/lib/32/edit.png" width="28"  id="editar' . $i . '" alt="Editar" onclick="editar(' . $i . ')" ><input type="image" src="' . PATH_DOMAIN . '/web/lib/32/disk2.png" id="guardar' . $i . '" onclick="guardar(' . $i . ',' . $row->fil_id . ')" style="display:none" ></td>';
                $cadena .= '<td width="65"  align="center"><span style="font-size: 10px ;font-weight: bold;">' . $row->fon_cod . DELIMITER . $row->uni_cod . DELIMITER . $row->tco_codigo . DELIMITER . $row->ser_codigo . DELIMITER . $row->exp_codigo . DELIMITER . $row->fil_nro . '</span></td>';
                $cadena .= '<td width="200"style="font-size: 10px ;font-weight: bold;" ><span  id="text-titulo' . $i . '">' . $row->fil_titulo . ' - ' . $row->fil_subtitulo . '</span><input type="text" size="25"  id="titulo' . $i . '" style="display:none" value="' . $row->fil_titulo . '"><input type="text" size="25"  id="subtitulo' . $i . '" style="display:none" value="' . $row->fil_subtitulo . '"><br><span id="text-alccon' . $i . '"><b>Alcance y contenido:</b><br>' . $row->fil_alccon . '</span><textarea cols="40" rows="3" style="display:none" id="alccon' . $i . '">' . $row->fil_alccon . '</textarea></td>';
                $cadena .= '<td width="65"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;"  id="text-fecha' . $i . '">' . $row->fil_anio . ' - ' . $row->fil_aniof . '</span><input type="text" size="3" id="fechai' . $i . '" style="display:none" value="' . $row->fil_anio . '"><input type="text" size="3" id="fechaf' . $i . '" style="display:none" value="' . $row->fil_aniof . '"></td>';
                $cadena .= '<td width="45"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;" id="text-tomovol' . $i . '">' . $row->fil_tomovol . '</span><input type="text" size="3" id="tomovol' . $i . '" style="display:none" value="' . $row->fil_tomovol . '"></td>';
                $cadena .= '<td style="font-size:10px"><span style="font-size: 10px ;font-weight: bold;" id="text-resproc' . $i . '"><b>Responsable:</b><br>' . $row->fil_firma . '<br><b>Productor:</b><br>' . $row->fil_proc . '</span><input type="text" size="25"  id="responsable' . $i . '" style="display:none" value="' . $row->fil_firma . '"><br><input type="text" size="25"  id="productor' . $i . '" style="display:none" value="' . $row->fil_proc . '"></td>';
                $cadena .= '<td width="45"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;" id="text-nrofojas' . $i . '">' . $row->fil_nrofoj . '</span><input type="text" size="3" id="nrofojas' . $i . '" style="display:none" value="' . $row->fil_nrofoj . '"></td>';
                $cadena .= '<td width="25"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;" id="text-nrocaj' . $i . '">' . $row->fil_nrocaj . '</span><input type="text" size="3" id="nrocaj' . $i . '" style="display:none" value="' . $row->fil_nrocaj . '"></td>';
                $cadena .= '<td width="25"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;" id="text-sala' . $i . '">' . $row->fil_sala . '</span><input type="text"  size="3" id="sala' . $i . '" style="display:none" value="' . $row->fil_sala . '"></td>';
                $cadena .= '<td width="30"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;" id="text-estante' . $i . '">' . $row->fil_estante . '</span><input type="text"  size="3" id="estante' . $i . '" style="display:none" value="' . $row->fil_estante . '"></td>';
                $cadena .= '<td width="30"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;" id="text-cuerpo' . $i . '">' . $row->fil_cuerpo . '</span><input type="text"  size="3" id="cuerpo' . $i . '" style="display:none" value="' . $row->fil_cuerpo . '"></td>';
                $cadena .= '<td width="30"  align="center" valign="middle"><span style="font-size: 10px ;font-weight: bold;" id="text-balda' . $i . '">' . $row->fil_balda . '</span><input type="text"  size="3" id="balda' . $i . '" style="display:none" value="' . $row->fil_balda . '"></td>';
                $cadena .= '<td width="200"  ><span style="font-size: 10px ;font-weight: bold;" id="text-obs' . $i . '">' . trim($row->fil_obs) . '</span><textarea cols="40" rows="3" style="display:none" id="obs' . $i . '">' . $row->fil_obs . '</textarea></td>';
                $cadena .= '</tr>';
                $cadena .= '<tr style="color:#006699">';
                $cadena .= '<td colspan="13" style="font-size: 10px ;font-weight: bold;"><span id="text-palclaves' . $i . '">Palabras Claves:';
                $fil_descripcion = $palclave->listaPCFile($row->fil_id);
                $cadena .= " " . $fil_descripcion;
                $cadena .= '</span>
    <input type="text" id="palclaves' . $i . '" value="' . $fil_descripcion . '" style="display:none" size="120" autocomplete="off" maxlength="2050"/>
    <br>
<b>Nro. paquetes: </b><span id="text-nropaq' . $i . '"> ' . $row->fil_nropaq . '</span> <input type="text" id="nropaq' . $i . '" value="' . $row->fil_nropaq . '" style="display:none;color:black" size="15"/>    
<BR><b>Paquetes A-B.. : </b><span id="text-cantpaq' . $i . '"> ' . trim($row->fil_cantpaq) . '</span> <input type="text" id="cantpaq' . $i . '" value="' . trim($row->fil_cantpaq) . '" style="display:none;color:black" size="15"/>
    </td>';
                $cadena .= '</tr>';
                $i++;
            }
        }
        //obtenerSelectCamposRepC
        $cadena .= '</table>';
        $cadena = "{$cadenah} {$cadena}";
        $this->registry->template->contenido = $cadena;
        $this->registry->template->show('tab_editSeccion.tpl');
        $this->registry->template->show('footer');
        //        $pdf->writeHTML($cadena, true, false, false, false, '');
        //
        //        // -----------------------------------------------------------------------------
        //        //Close and output PDF document
        //        $pdf->Output('reporte_inventario.pdf', 'I');
    }
 function verificaPass()
 {
     $usuario = new Tab_usuario();
     $row = $usuario->dbSelectBySQL("SELECT * FROM tab_usuario WHERE\r\n\t\tusu_id='" . $_SESSION['USU_ID'] . "' AND\r\n\t\tusu_pass ='******'pass_usu']) . "' ");
     if (count($row)) {
         echo 'OK';
     } else {
         echo 'La contrase&ntilde;a no coincide. Digite el password correcto';
     }
 }
 function verRpte()
 {
     // Include the main TCPDF library (search for installation path).
     require_once 'tcpdf/tcpdf.php';
     // create new PDF document
     //$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf = new TCPDF('P', PDF_UNIT, 'LETTER', true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Castellon S.R.L.');
     $pdf->SetTitle('Marbetes de documentos y expedientes');
     $pdf->SetSubject('Marbetes de documentos y expedientes');
     $pdf->SetKeywords('Marbetes, documentos y expedientes');
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     // set default header data
     //$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 027', PDF_HEADER_STRING);
     // set header and footer fonts
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     //$pdf->SetMargins(PDF_MARGIN_LEFT, 7, PDF_MARGIN_RIGHT);
     //$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     //$pdf->SetMargins(5, 7, 5);
     $pdf->SetMargins(6, 7, 6);
     // Margin Header
     //        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     //        $pdf->SetHeaderMargin(10);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE);
     //$pdf->SetAutoPageBreak(FALSE);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set some language-dependent strings (optional)
     if (@file_exists(dirname(__FILE__) . 'tcpdf/lang/eng.php')) {
         require_once dirname(__FILE__) . 'tcpdf/lang/eng.php';
         $pdf->setLanguageArray($l);
     }
     // ---------------------------------------------------------
     // set a barcode on the page footer
     //$pdf->setBarcode(date('Y-m-d H:i:s'));
     // set font
     // add a page
     $pdf->AddPage();
     //$pdf->SetFont('helvetica', '', 10);
     $pdf->SetFont('helvetica', 'U', 18);
     // create columns content
     //$pdf->Ln(6);
     $pdf->Ln(6);
     $style1 = array('position' => '', 'align' => '', 'stretch' => false, 'fitwidth' => true, 'cellfitalign' => 'L', 'border' => true, 'hpadding' => 'auto', 'vpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'font' => 'helvetica', 'fontsize' => 8, 'stretchtext' => 4);
     $style2 = array('position' => '', 'align' => '', 'stretch' => false, 'fitwidth' => true, 'cellfitalign' => 'R', 'border' => true, 'hpadding' => 'auto', 'vpadding' => 'auto', 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'font' => 'helvetica', 'fontsize' => 8);
     // Tipo de reporte
     $tiporeporte = $_REQUEST['tiporeporte'];
     // Filtro seccion
     $uni_id = $_REQUEST['uni_id'];
     $ser_id = $_REQUEST['ser_id'];
     // Nuevo c&oacute;digo
     $where = "";
     // Resultset
     $result = null;
     $kl = 0;
     $v2[$kl] = 0;
     $doxexp[$kl] = 0;
     $de[$kl] = 0;
     $n = 0;
     $where = "";
     if ($ser_id) {
         $where .= " AND tab_series.ser_id = '{$ser_id}' ";
     }
     if ($_SESSION["ROL_COD"] != 'AA') {
         $where .= " AND tab_expusuario.usu_id= '" . $_SESSION["USU_ID"] . "'";
     }
     // ************
     // Series
     // ************
     if ($uni_id != "") {
         // Expedientes
         $sql_marbete = "SELECT\r\n                tab_expediente.exp_id,\r\n                tab_series.ser_orden,\r\n                tab_series.ser_codigo,\r\n                tab_expediente.exp_codigo,\r\n                tab_expisadg.exp_titulo,\r\n                tab_expediente.exp_nrocaj\r\n                FROM\r\n                tab_usuario\r\n                INNER JOIN tab_expusuario ON tab_usuario.usu_id = tab_expusuario.usu_id\r\n                INNER JOIN tab_expediente ON tab_expusuario.exp_id = tab_expediente.exp_id\r\n                INNER JOIN tab_expfondo ON tab_expediente.exp_id = tab_expfondo.exp_id\r\n                INNER JOIN tab_series ON tab_expediente.ser_id = tab_series.ser_id                \r\n                INNER JOIN tab_expisadg ON tab_expediente.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 tab_fondo.fon_estado = 1\r\n                AND tab_unidad.uni_estado = 1\r\n                AND tab_series.ser_estado = 1\r\n                AND tab_tipocorr.tco_estado = 1\r\n                AND tab_expediente.exp_estado = 1\r\n                AND tab_expisadg.exp_estado = 1\r\n                AND tab_expfondo.exf_estado = 1\r\n                AND tab_expusuario.eus_estado = 1\r\n                AND tab_unidad.uni_id = '{$uni_id}'\r\n                {$where}\r\n                ORDER BY \r\n                tab_fondo.fon_cod,\r\n                tab_unidad.uni_cod,\r\n                tab_series.ser_orden, \r\n                tab_series.ser_codigo, \r\n                tab_expediente.exp_codigo::int ";
         // INNER JOIN tab_usu_serie ON tab_series.ser_id = tab_usu_serie.ser_id
         $tab_usuario = new Tab_usuario();
         $rows_expedientes = $tab_usuario->dbSelectBySQL($sql_marbete);
         $kl = 0;
         $tarchivo = new tab_archivo();
         foreach ($rows_expedientes as $rows) {
             $x = new Tab_archivo();
             $sqlcantidad = "SELECT\r\n                            COUNT(tab_archivo.fil_id) as cantidad\r\n                            FROM\r\n                            tab_exparchivo\r\n                            INNER JOIN tab_archivo ON tab_exparchivo.fil_id = tab_archivo.fil_id\r\n                            WHERE\r\n                            tab_exparchivo.exp_id = '" . $rows->exp_id . "'\r\n                            AND tab_exparchivo.exa_estado = 1 ";
             $cantidad_documentos = $x->dbSelectBySQL($sqlcantidad);
             $ct = $cantidad_documentos[0]->cantidad;
             if ($ct == 0) {
                 // Series
                 $sqlsoloexpedientes = "SELECT\r\n                            (SELECT fon_codigo from tab_fondo WHERE fon_id=f.fon_par) ||'.'|| f.fon_codigo ||'.'||tab_unidad.uni_cod ||'.'|| tab_tipocorr.tco_codigo ||'.'||tab_series.ser_codigo||'.'||\r\n                            tab_expediente.exp_codigo AS codigo,\r\n                            tab_expediente.exp_nroejem,\r\n                            tab_expediente.exp_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                            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_id={$rows->exp_id}\r\n                            ORDER BY \r\n                            f.fon_cod,\r\n                            tab_unidad.uni_cod,\r\n                            tab_series.ser_orden, \r\n                            tab_series.ser_codigo, \r\n                            tab_expediente.exp_codigo::int ";
                 $tab_fondo = new Tab_fondo();
                 $rows_marb = $tab_fondo->dbSelectBySQL($sqlsoloexpedientes);
                 $result = $tab_fondo->dbSelectBySQL($sqlsoloexpedientes);
                 foreach ($rows_marb as $list) {
                     $m = $list->exp_nroejem;
                     for ($n = 1; $n <= $m; $n++) {
                         $v2[$kl] = $list->codigo;
                         $doxexp[$kl] = 'E' . $list->exp_id;
                         $de[$kl] = 'e';
                         $kl++;
                     }
                 }
             } else {
                 // Documentos
                 $sqldocumentos = "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) ||'.'|| f.fon_codigo ||'.'||tab_unidad.uni_cod ||'.'|| tab_tipocorr.tco_codigo ||'.'||tab_series.ser_codigo||'.'||\r\n                            tab_expediente.exp_codigo as codigoexp,                            \r\n                            (SELECT fon_codigo from tab_fondo WHERE fon_id=f.fon_par) ||'.'|| f.fon_codigo ||'.'||tab_unidad.uni_cod ||'.'|| tab_tipocorr.tco_codigo ||'.'||tab_series.ser_codigo||'.'||\r\n                            tab_expediente.exp_codigo||'.'||tab_archivo.fil_nro as codigo,\r\n                            tab_archivo.fil_nroejem,\r\n                            tab_archivo.fil_id,\r\n                            (NULLIF(tab_archivo.fil_codigo,'')::int) as correlativo\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_archivo.fil_estado = 1 AND\r\n                            tab_exparchivo.exa_estado = 1 AND\r\n                            tab_expusuario.eus_estado = 1 AND\r\n                            tab_expediente.exp_id ='{$rows->exp_id}' \r\n                            ORDER BY \r\n                            f.fon_cod,\r\n                            tab_unidad.uni_cod,\r\n                            tab_series.ser_orden, \r\n                            tab_series.ser_codigo, \r\n                            tab_expediente.exp_codigo::int, \r\n                            tab_archivo.fil_nro::int ";
                 $result_documentos = $tarchivo->dbSelectBySQL($sqldocumentos);
                 $result = $tarchivo->dbSelectBySQL($sqldocumentos);
                 $exp_id = 0;
                 foreach ($result_documentos as $list2) {
                     if ($exp_id != $list2->exp_id) {
                         // Exp
                         $v2[$kl] = $list2->codigoexp;
                         $doxexp[$kl] = 'E' . $list2->exp_id;
                         $de[$kl] = 'e';
                         $kl++;
                         // Doc
                         $m = $list2->fil_nroejem;
                         for ($n = 1; $n <= $m; $n++) {
                             $v2[$kl] = $list2->codigo;
                             $doxexp[$kl] = $list2->fil_id;
                             $de[$kl] = 'd';
                             $kl++;
                         }
                         $exp_id = $list2->exp_id;
                     } else {
                         $m = $list2->fil_nroejem;
                         for ($n = 1; $n <= $m; $n++) {
                             $v2[$kl] = $list2->codigo;
                             $doxexp[$kl] = $list2->fil_id;
                             $de[$kl] = 'd';
                             $kl++;
                         }
                         $exp_id = $list2->exp_id;
                     }
                 }
             }
         }
         // end row expedientes
         //            if ($kl < 1) {
         //                echo "Esta Serie no tiene Marbetes";
         //                exit();
         //            }
     }
     //        else {
     //            $sqlnoexpedientes = "SELECT
     //                        (SELECT fon_codigo from tab_fondo WHERE fon_id=f.fon_par) ||'.'|| f.fon_codigo ||'.'||tab_unidad.uni_cod ||'.'|| tab_tipocorr.tco_codigo ||'.'||tab_series.ser_codigo||'.'||
     //                        tab_expediente.exp_codigo AS codigo,
     //                        tab_expediente.exp_nroejem,
     //                        tab_expediente.exp_id
     //                        FROM
     //                        tab_fondo AS f
     //                        INNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id
     //                        INNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id
     //                        INNER JOIN tab_tipocorr ON tab_tipocorr.tco_id = tab_series.tco_id
     //                        INNER JOIN tab_expediente ON tab_series.ser_id = tab_expediente.ser_id
     //                        WHERE
     //                        f.fon_estado = 1 AND
     //                        tab_unidad.uni_estado = 1 AND
     //                        tab_tipocorr.tco_estado = 1 AND
     //                        tab_series.ser_estado = 1 AND
     //                        tab_expediente.exp_id=$exp_id";
     //            $tab_fondo = new Tab_fondo();
     //            $rows_marb = $tab_fondo->dbSelectBySQL($sqlnoexpedientes);
     //            $result = $tab_fondo->dbSelectBySQL($sqlnoexpedientes);
     //        }
     $t = 1;
     $numero = 0;
     $j = 1;
     // **********************
     // Todos los documentos
     // **********************
     $cantidad_ejem = 0;
     $cantidad_ejem2 = $kl;
     $n = $kl;
     if ($cantidad_ejem == 1) {
         $j = 1;
         $tip = 1;
         $cantidad_ejem2 = 1;
     } else {
         $j = 1;
         $tip = 2;
     }
     $l = 0;
     $codigoizquierda = "";
     while ($j <= $n) {
         //                $codigo = $v[$l];
         //                $fil_ids = $vdoc[$l];
         //
         $codigo = $v2[$l];
         $fil_ids = $doxexp[$l];
         $tipode = $de[$l];
         $l++;
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetTextColor(58, 35, 9);
         $tipo = "";
         $izq = 0;
         $lugar = 0;
         if ($j % 2 == 1) {
             $izq = 104;
             $lugar = 0;
         } else {
             $izq = 100;
             //
             $lugar = 1;
         }
         if ($fil_ids) {
             // Grid Code Document
             if ($j == $cantidad_ejem2) {
                 if ($j % 2 == 1) {
                     //                    if ($tipode=='e'){
                     //                        $pdf->MultiCell($izq, 0, $codigo, 1, 'J', 1, $lugar, '', '', true, 0, false, true, 0);
                     //                    }else{
                     //                        $pdf->MultiCell($izq, 0, $codigo, 0, 'J', 1, $lugar, '', '', true, 0, false, true, 0);
                     //                    }
                     //
                     for ($k = 1; $k <= 2; $k++) {
                         if ($k == 1) {
                             if ($tipode == 'e') {
                                 // MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
                                 // write the first column
                                 $pdf->MultiCell($izq, 0, $codigo, 1, 'J', 1, $lugar, '', '', true, 0, false, true, 0);
                             } else {
                                 // MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
                                 $pdf->MultiCell($izq, 0, $codigo, 0, 'J', 1, $lugar, '', '', true, 0, false, true, 0);
                             }
                         } else {
                             $pdf->MultiCell(100, 0, '', 0, 'J', 1, 1, '', '', true, 0, false, true, 0);
                         }
                     }
                 } else {
                     if ($tipode == 'e') {
                         $pdf->MultiCell($izq, 0, $codigo, 1, 'J', 1, $lugar, '', '', true, 0, false, true, 0);
                     } else {
                         $pdf->MultiCell($izq, 0, $codigo, 0, 'J', 1, $lugar, '', '', true, 0, false, true, 0);
                     }
                 }
             } else {
                 if ($tipode == 'e') {
                     $pdf->MultiCell($izq, 0, $codigo, 1, 'J', 1, $lugar, '', '', true, 0, false, true, 0);
                 } else {
                     $pdf->MultiCell($izq, 0, $codigo, 0, 'J', 1, $lugar, '', '', true, 0, false, true, 0);
                 }
             }
         }
         // Bar Code
         if ($j % 2 == 0) {
             for ($i = 1; $i <= $tip; $i++) {
                 if ($i % 2 == 1) {
                     $tipo = "";
                     $style = $style1;
                     $pdf->write1DBarcode(str_pad($codigoizquierda, 7, "0", STR_PAD_LEFT), 'C39', '', '', '', 18, 0.61, $style, $tipo);
                 } else {
                     $tipo = "N";
                     $style = $style2;
                     $pdf->write1DBarcode(str_pad($fil_ids, 7, "0", STR_PAD_LEFT), 'C39', '', '', '', 18, 0.61, $style, $tipo);
                 }
             }
             //*************************
             // New line for new bar code
             //*************************
             $pdf->Ln(12);
             //                        // Count lines
             //                        if (j!=14){
             //                            $pdf->Ln(11);
             //                        }else{
             //                            $pdf->Ln(20);
             //                        }
         } else {
             if ($j == $cantidad_ejem2) {
                 $pdf->write1DBarcode(str_pad($fil_ids, 7, "0", STR_PAD_LEFT), 'C39', '', '', '', 18, 0.61, $style1, "");
             }
         }
         $j++;
         if ($j > 14) {
             //$pdf->SetMargins(PDF_MARGIN_LEFT, 14, PDF_MARGIN_RIGHT);
             //$pdf->SetMargins(5, 14, 5);
             $pdf->SetMargins(6, 14, 6);
         }
         $t++;
         $codigoizquierda = $fil_ids;
     }
     //end foreach
     $pdf->Output('listado_marbetes.pdf', 'I');
 }