function loadExp()
 {
     $id_trans = VAR3;
     $usuario = $_SESSION['USU_ID'];
     $this->series = new series();
     $this->expediente = new tab_expediente();
     $this->expediente->setRequest2Object($_REQUEST);
     $this->usuario = new usuario();
     $page = $_REQUEST['page'];
     $rp = $_REQUEST['rp'];
     $sortname = $_REQUEST['sortname'];
     $sortorder = $_REQUEST['sortorder'];
     if (!$sortname) {
         $sortname = ' tab_fondo.fon_cod,
             tab_unidad.uni_cod,
             tab_series.ser_orden, 
             tab_series.ser_codigo,
             tab_expediente.exp_codigo::int ';
     }
     if (!$sortorder) {
         $sortorder = 'desc';
     }
     $sort = "ORDER BY {$sortname} {$sortorder} ";
     if (!$page) {
         $page = 1;
     }
     if (!$rp) {
         $rp = 15;
     }
     $start = ($page - 1) * $rp;
     $limit = "LIMIT {$rp} OFFSET {$start} ";
     $query = utf8_encode($_REQUEST['query']);
     $qtype = $_REQUEST['qtype'];
     $where = "";
     if ($query != "") {
         if ($qtype == 'exp_id') {
             $where .= " and tab_expediente.exp_id LIKE '{$query}' ";
         } elseif ($qtype == 'ser_categoria') {
             if ($query == 'TODOS') {
                 $where .= "";
             } else {
                 $where .= " and tab_series.ser_categoria LIKE '%{$query}%' ";
             }
         } elseif ($qtype == 'custodio') {
             $nomArray = explode(" ", $query);
             foreach ($nomArray as $nom) {
                 $where .= " and (tab_usuario.usu_nombres LIKE '%{$nom}%' OR tab_usuario.usu_apellidos LIKE '%{$nom}%') ";
             }
         } else {
             if ($query == 'TODOS') {
                 $where .= "";
             } else {
                 $where .= " and {$qtype} LIKE '%{$query}%' ";
             }
         }
     }
     $tab_expusuario = new tab_expusuario();
     $tab_extransferencia = new tab_exptransferencia();
     $result = $tab_extransferencia->dbSelectBySQL("select* from tab_exptransferencia where str_id={$id_trans}");
     $cantidad = count($result);
     $valor3 = "";
     $t = 1;
     foreach ($result as $row) {
         $nuevo = $tab_expusuario->dbSelectBySQL("select* from tab_expusuario where exp_id=" . $row->exp_id . " and usu_id={$usuario} and eus_estado=2");
         foreach ($nuevo as $list) {
             $valor3 .= "tab_expusuario.eus_id=" . $list->eus_id . "";
             if ($t < $cantidad) {
                 $valor3 .= " or ";
             }
             $t++;
         }
     }
     $where .= " AND {$valor3} ";
     if ($_SESSION["ROL_COD"] != 'AA') {
         $where .= " AND tab_expusuario.usu_id ='" . $_SESSION['USU_ID'] . "' ";
     }
     $sql = "SELECT\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_unidad.uni_id,\r\n                tab_series.ser_id,\r\n                tab_expediente.exp_id,\r\n                tab_series.ser_categoria,\r\n                tab_expisadg.exp_titulo,\r\n                tab_expisadg.exp_fecha_exi,\r\n                (tab_expisadg.exp_fecha_exi + \r\n                    (SELECT tab_retensiondoc.red_prearc * INTERVAL '1 year' \r\n                    FROM tab_retensiondoc \r\n                    WHERE tab_retensiondoc.red_id = tab_series.red_id)) ::DATE AS exp_fecha_exf,\r\n                tab_usuario.usu_nombres,\r\n                tab_usuario.usu_apellidos,\r\n                tab_expfondo.exf_estado\r\n                FROM\r\n                tab_unidad\r\n                INNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\n                INNER JOIN tab_expediente ON tab_series.ser_id = tab_expediente.ser_id\r\n                INNER JOIN tab_expfondo ON tab_expediente.exp_id = tab_expfondo.exp_id\r\n                INNER JOIN tab_expusuario ON tab_expediente.exp_id = tab_expusuario.exp_id\r\n                INNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_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_usuario ON tab_usuario.usu_id = tab_expusuario.usu_id\r\n                WHERE                \r\n                tab_series.ser_estado = 1\r\n                AND tab_expediente.exp_estado = 1\r\n                AND tab_usuario.usu_estado = 1\r\n                AND tab_expfondo.exf_estado = 1                \r\n                AND tab_expusuario.eus_estado = 2\r\n                {$where} \r\n                {$sort} \r\n                {$limit}";
     // tab_expusuario.usu_id = " . $_SESSION['USU_ID'] . "
     $expediente = new expediente();
     $result = $this->expediente->dbselectBySQL($sql);
     $total = $this->expediente->countBySQL("SELECT COUNT(tab_fondo.fon_cod)\r\n                                                FROM\r\n                                                tab_unidad\r\n                                                INNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\n                                                INNER JOIN tab_expediente ON tab_series.ser_id = tab_expediente.ser_id\r\n                                                INNER JOIN tab_expfondo ON tab_expediente.exp_id = tab_expfondo.exp_id\r\n                                                INNER JOIN tab_expusuario ON tab_expediente.exp_id = tab_expusuario.exp_id\r\n                                                INNER JOIN tab_expisadg ON tab_expediente.exp_id = tab_expisadg.exp_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_usuario ON tab_usuario.usu_id = tab_expusuario.usu_id\r\n                                                WHERE                \r\n                                                tab_series.ser_estado = 1\r\n                                                AND tab_expediente.exp_estado = 1\r\n                                                AND tab_usuario.usu_estado = 1\r\n                                                AND tab_expfondo.exf_estado = 1                \r\n                                                AND tab_expusuario.eus_estado = 2\r\n                                                {$where}");
     header("Content-type: text/x-json");
     $json = "";
     $json .= "{\n";
     $json .= "page: {$page},\n";
     $json .= "total: {$total},\n";
     $json .= "rows: [";
     $rc = false;
     $i = 0;
     $j = 1;
     $si = 0;
     foreach ($result as $un) {
         $chk = "<input id=\"chk_" . $un->exp_id . "\" restric=\"" . $un->exp_id . "\" class=\"fil_chk" . $j . "\"   checked=\"checked\" type=\"checkbox\" value=\"" . $un->exp_id . "\"   />";
         if ($rc) {
             $json .= ",";
         }
         $json .= "\n{";
         $json .= "id:'" . $un->exp_id . "',";
         $json .= "cell:['" . $un->exp_id . "'";
         $json .= ",'" . $chk . "'";
         $json .= ",'" . addslashes($un->fon_cod . DELIMITER . $un->uni_cod . DELIMITER . $un->tco_codigo . DELIMITER . $un->ser_codigo . DELIMITER . $un->exp_codigo) . "'";
         $json .= ",'" . addslashes($un->ser_categoria) . "'";
         $json .= ",'" . addslashes($un->exp_titulo) . "'";
         $json .= ",'" . addslashes($un->exp_fecha_exi) . "'";
         $json .= ",'" . addslashes($un->exp_fecha_exf) . "'";
         $json .= ",'" . addslashes($expediente->obtenerCustodios($un->exp_id)) . "'";
         $json .= "]}";
         $rc = true;
         $i++;
         $j++;
     }
     $json .= "]\n";
     $json .= "}";
     echo $json;
 }