function loadTrans() { $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_expediente.exp_fecha_exf'; } 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}%' "; } } } //$where2=""; $valor3 = ""; // $where="AND tab_expediente.exp_id=23 or tab_expediente.exp_id=24"; if ($id_transferencia != "") { $explode3 = explode(",", $id_transferencia); $cantidad3 = count($explode3); for ($i = 0; $i < $cantidad3; $i++) { $valor3 .= "tab_expediente.exp_id='" . $explode3[$i] . "'"; if ($i < $cantidad3 - 1) { $valor3 .= " or "; } } $where .= " AND {$valor3} "; } $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_expusuario.usu_id = " . $_SESSION['USU_ID'] . "\r\n AND 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 = 1\r\n {$where} {$sort} {$limit}"; $expediente = new expediente(); $result = $this->expediente->dbselectBySQL($sql); $total = $expediente->countExp2($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_descripcion) . "'"; $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; }