function load() { $usuario = new usuario(); $id_transferencia = ""; if (isset($_SESSION['id_transferencia'])) { $id_transferencia = $_SESSION['id_transferencia']; //$id_listar=$_SESSION['id_lista']; } $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_series.ser_orden, \r\n tab_series.ser_codigo, \r\n tab_expediente.exp_codigo::int "; } else { $sortname = $sortname; } 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 = strtoupper(trim($_REQUEST['query'])); $qtype = $_REQUEST['qtype']; $where = ""; if ($query != "") { if ($qtype == 'exp_id') { $where .= " and tab_expediente.exp_id = '{$query}' "; } elseif ($qtype == 'exp_titulo') { $where .= " and tab_expisadg.exp_titulo LIKE '%{$query}%' "; } elseif ($qtype == 'fon_descripcion') { $where .= " and tab_fondo.fon_descripcion LIKE '%{$query}%' "; } elseif ($qtype == 'uni_descripcion') { $where .= " and tab_unidad.uni_descripcion LIKE '%{$query}%' "; } elseif ($qtype == 'custodio') { $nomArray = explode(" ", $query); $where .= " and (tab_usuario.usu_nombres LIKE '%{$nomArray['0']}%' OR tab_usuario.usu_apellidos LIKE '%{$nomArray['1']}%') "; } } if ($_SESSION["ROL_COD"] != 'AA') { $where .= " AND tab_usuario.usu_id ='" . $_SESSION['USU_ID'] . "' "; } $sql = "SELECT\r\n tab_fondo.fon_cod,\r\n tab_fondo.fon_codigo,\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_unidad.uni_descripcion,\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_id,\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 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_expusuario.eus_estado = 1\r\n AND tab_usuario.usu_estado = 1 \r\n {$where} \r\n {$sort} \r\n {$limit}"; $result = $this->expediente->dbselectBySQL($sql); $total = $this->expediente->countBySQL("SELECT count (tab_expediente.exp_id)\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 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_expusuario.eus_estado = 1\r\n AND tab_usuario.usu_estado = 1 \r\n {$where}"); if ($id_transferencia != "") { $explode = explode(",", $id_transferencia); $cantidad = count($explode); } else { $cantidad = 0; } /* header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header ( "Cache-Control: no-cache, must-revalidate" ); header ( "Pragma: no-cache" ); */ 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) { for ($t = 0; $t < $cantidad; $t++) { if ($explode[$t] == $un->exp_id) { $si = 1; } } if ($si == 1) { $chk = "<input id=\"chk_" . $un->exp_id . "\" restric=\"" . $un->exp_id . "\" class=\"fil_chk" . $j . "\" type=\"checkbox\" value=\"" . $un->exp_id . "\" checked=\"checked\"/>"; $si = 0; } else { $chk = "<input id=\"chk_" . $un->exp_id . "\" restric=\"" . $un->exp_id . "\" class=\"fil_chk" . $j . "\" 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($usuario->getRol($un->usu_id)) . "'"; $json .= ",'" . addslashes($un->fon_codigo) . "'"; $json .= ",'" . addslashes($un->uni_descripcion) . "'"; $json .= ",'" . addslashes($un->ser_categoria) . "'"; $json .= ",'" . addslashes($un->exp_titulo) . "'"; $expediente = new expediente(); $json .= ",'" . addslashes($expediente->obtenerCantidadDocs($un->exp_id)) . "'"; $json .= ",'" . addslashes($un->exp_fecha_exi) . "'"; $json .= ",'" . addslashes($un->exp_fecha_exf) . "'"; $json .= ",'" . addslashes($un->usu_nombres . ' ' . $un->usu_apellidos) . "'"; $json .= "]}"; $rc = true; $i++; $j++; } $json .= "]\n"; $json .= "}"; echo $json; }
function load() { $usuario = new usuario(); $adm = $usuario->esAdm(); $this->tab_expediente = new tab_expediente(); $this->tab_expediente->setRequest2Object($_REQUEST); $page = $_REQUEST['page']; $rp = $_REQUEST['rp']; $sortname = $_REQUEST['sortname']; $sortorder = $_REQUEST['sortorder']; if (!$sortname) { $sortname = " 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 "; } else { $sortname = $sortname; } 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 = strtoupper(trim($_REQUEST['query'])); $qtype = $_REQUEST['qtype']; $where = ""; if ($query != "") { $_SESSION["SER_ID"] = null; if ($qtype == 'exp_id') { $where .= " and tab_expediente.exp_id = '{$query}' "; } elseif ($qtype == 'exp_titulo') { $where .= " and tab_expisadg.exp_titulo LIKE '%{$query}%' "; } elseif ($qtype == 'fon_codigo') { $where .= " and tab_fondo.fon_descripcion LIKE '%{$query}%' "; } elseif ($qtype == 'uni_descripcion') { $where .= " and tab_unidad.uni_descripcion LIKE '%{$query}%' "; } elseif ($qtype == 'custodio') { $nomArray = explode(" ", $query); $where .= " and (tab_usuario.usu_nombres LIKE '%{$nomArray['0']}%' OR tab_usuario.usu_apellidos LIKE '%{$nomArray['1']}%') "; } else { $where .= " and {$qtype} LIKE '%{$query}%' "; } } else { // Serie if (VAR3) { $_SESSION["SER_ID"] = VAR3; } } if ($_SESSION["SER_ID"]) { $where .= " AND tab_series.ser_id='" . $_SESSION['SER_ID'] . "'"; } if ($_SESSION["ROL_COD"] == 'AAOR') { $where .= " AND tab_fondo.fon_id ='" . $_SESSION['FON_ID'] . "' "; } else { if ($_SESSION["ROL_COD"] != 'AA') { $where .= " AND tab_usuario.usu_id ='" . $_SESSION['USU_ID'] . "' "; } } $sql = "SELECT\r\n tab_expediente.exp_id,\r\n tab_fondo.fon_codigo,\r\n tab_fondo.fon_cod,\r\n tab_unidad.uni_descripcion,\r\n tab_unidad.uni_cod,\r\n tab_tipocorr.tco_codigo,\r\n tab_series.ser_id,\r\n tab_series.ser_par,\r\n tab_series.ser_codigo,\r\n tab_series.ser_categoria,\r\n tab_expediente.exp_codigo,\r\n tab_usuario.usu_id,\r\n tab_usuario.usu_nombres,\r\n tab_usuario.usu_apellidos,\r\n tab_expisadg.exp_titulo,\r\n tab_expisadg.exp_fecha_exi,\r\n tab_tipoarch.tar_nombre\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_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_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 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_expusuario.eus_estado = 1\r\n {$where}\r\n {$sort}\r\n {$limit} "; $result = $this->tab_expediente->dbSelectBySQL($sql); $total = $this->tab_expediente->countBySQL("SELECT count (tab_expediente.exp_id)\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_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_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 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_expusuario.eus_estado = 1\r\n {$where}"); // (tab_expisadg.exp_fecha_exi + // (SELECT tab_retensiondoc.red_prearc * INTERVAL '1 year' // FROM tab_retensiondoc // WHERE tab_retensiondoc.red_id = tab_series.red_id)) ::DATE AS exp_fecha_exf, header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); header("Content-type: text/x-json"); $json = ""; $json .= "{\n"; $json .= "page: {$page},\n"; $json .= "total: {$total},\n"; $json .= "rows: ["; $rc = false; $i = 0; foreach ($result as $un) { if ($rc) { $json .= ","; } $json .= "\n{"; $json .= "id:'" . $un->exp_id . "',"; $json .= "cell:['" . $un->exp_id . "'"; $json .= ",'" . addslashes($un->fon_cod . DELIMITER . $un->uni_cod . DELIMITER . $un->tco_codigo . DELIMITER . $un->ser_codigo . DELIMITER . $un->exp_codigo) . "'"; $json .= ",'" . addslashes($usuario->getRol($un->usu_id)) . "'"; if ($adm) { $json .= ",'" . addslashes($un->fon_codigo) . "'"; $json .= ",'" . addslashes($un->uni_descripcion) . "'"; $json .= ",'" . addslashes($un->ser_categoria) . "'"; } $json .= ",'" . addslashes($un->exp_titulo) . "'"; $expediente = new expediente(); $json .= ",'" . addslashes($expediente->obtenerCantidadDocs($un->exp_id)) . "'"; if ($adm) { $json .= ",'" . addslashes($un->usu_nombres . ' ' . $un->usu_apellidos) . "'"; } $json .= "]}"; $rc = true; $i++; } $json .= "]\n"; $json .= "}"; echo $json; }
function load() { $usuario = new usuario(); $adm = $usuario->esAdm(); $expediente = new tab_expediente(); $expediente->setRequest2Object($_REQUEST); $page = $_REQUEST['page']; $rp = $_REQUEST['rp']; $sortname = $_REQUEST['sortname']; $sortorder = $_REQUEST['sortorder']; if (!$sortname) { $sortname = 'exp_id'; } 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 = $_REQUEST['query']; $qtype = $_REQUEST['qtype']; $where = ""; if ($query != "") { if ($qtype == 'exp_id') { $where = " and tab_expediente.exp_id = '{$query}' "; } elseif ($qtype == 'ser_categoria') { $where = " and tab_series.ser_categoria LIKE '%{$query}%' "; } else { $where = " and {$qtype} LIKE '%{$query}%' "; } } // if ($_SESSION ["ROL_COD"] != 'AA') { // $where .= " AND tab_usuario.usu_id ='" . $_SESSION['USU_ID'] . "' "; // } if ($_SESSION["ROL_COD"] == 'AAOR') { $where .= " AND tab_fondo.fon_id ='" . $_SESSION['FON_ID'] . "' "; } else { if ($_SESSION["ROL_COD"] != 'AA') { $where .= " AND tab_usuario.usu_id ='" . $_SESSION['USU_ID'] . "' "; } } $sql = "SELECT\r\n tab_expediente.exp_id,\r\n tab_fondo.fon_codigo,\r\n tab_fondo.fon_cod,\r\n tab_unidad.uni_descripcion,\r\n tab_unidad.uni_cod,\r\n tab_tipocorr.tco_codigo,\r\n tab_series.ser_id,\r\n tab_series.ser_par,\r\n tab_series.ser_codigo,\r\n tab_series.ser_categoria,\r\n tab_expediente.exp_codigo,\r\n tab_usuario.usu_id,\r\n tab_usuario.usu_nombres,\r\n tab_usuario.usu_apellidos,\r\n tab_expisadg.exp_titulo,\r\n tab_expisadg.exp_fecha_exi,\r\n tab_tipoarch.tar_nombre,\r\n tab_etiquetas.ete_id\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_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_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_etiquetas ON tab_expediente.exp_id = tab_etiquetas.exp_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_expusuario.eus_estado = 1\r\n AND tab_etiquetas.ete_estado = '1'\r\n {$where}\r\n {$sort}\r\n {$limit} "; $result = $expediente->dbselectBySQL($sql); $total = $expediente->countBySQL("SELECT COUNT (tab_expediente.exp_id) \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_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_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_etiquetas ON tab_expediente.exp_id = tab_etiquetas.exp_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_expusuario.eus_estado = 1\r\n AND tab_etiquetas.ete_estado = '1'\r\n {$where} "); $expediente = new expediente(); /* header ( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header ( "Cache-Control: no-cache, must-revalidate" ); header ( "Pragma: no-cache" ); */ header("Content-type: text/x-json"); $json = ""; $json .= "{\n"; $json .= "page: {$page},\n"; $json .= "total: {$total},\n"; $json .= "rows: ["; $rc = false; $i = 0; foreach ($result as $un) { if ($rc) { $json .= ","; } $json .= "\n{"; $json .= "id:'" . $un->exp_id . "',"; $json .= "cell:['" . $un->exp_id . "'"; $json .= ",'" . addslashes($un->ete_id) . "'"; $json .= ",'" . addslashes($un->fon_cod . DELIMITER . $un->uni_cod . DELIMITER . $un->tco_codigo . DELIMITER . $un->ser_codigo . DELIMITER . $un->exp_codigo) . "'"; $json .= ",'" . addslashes($usuario->getRol($un->usu_id)) . "'"; if ($adm) { $json .= ",'" . addslashes($un->fon_codigo) . "'"; $json .= ",'" . addslashes($un->uni_descripcion) . "'"; $json .= ",'" . addslashes($un->ser_categoria) . "'"; } $json .= ",'" . addslashes($un->exp_titulo) . "'"; $expediente = new expediente(); $json .= ",'" . addslashes($expediente->obtenerCantidadDocs($un->exp_id)) . "'"; if ($adm) { $json .= ",'" . addslashes($un->usu_nombres . ' ' . $un->usu_apellidos) . "'"; } $json .= "]}"; $rc = true; $i++; } $json .= "]\n"; $json .= "}"; echo $json; }