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 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; }