function update() { $ser_id = $_REQUEST["ser_id"]; $exp_id = $_REQUEST["exp_id"]; $tra_id = $_REQUEST["tra_id"]; $cue_id = $_REQUEST["cue_id"]; // file $this->archivo = new tab_archivo(); $this->archivo->setRequest2Object($_REQUEST); $this->archivo->setFil_id($_REQUEST['dov_id']); $msm_guardado_archivo = 0; if ($_FILES["archivo"]["error"] == 4) { } else { // Digital file $archivo_digital = new tab_archivo_digital(); $archivo_type = $_FILES["archivo"]["type"]; $archivo = $_FILES["archivo"]["tmp_name"]; $archivo_size = $_FILES["archivo"]["size"]; $archivo_name = $_FILES["archivo"]["name"]; $nombre = basename($_FILES["archivo"]["name"]); $nombreFichero = $_FILES["archivo"]["name"]; $archivo_name_array = explode(".", $archivo_name); $archivo_ext = array_pop($archivo_name_array); $archivo_cifrado = md5($archivo_name); $sis_tammax = 0; // Data Parameters $sis_tipcarga = 2; $nombreDirectorio = ""; $tsistema = new tab_sistema(); $sql = "SELECT *\r\n FROM tab_sistema"; $rows2 = $tsistema->dbselectBySQL($sql); if (count($rows2) >= 1) { $sis_tipcarga = $rows2[0]->sis_tipcarga; $sis_tammax = $rows2[0]->sis_tammax; $nombreDirectorio = $rows2[0]->sis_ruta; } // Verify size if ($archivo_size > $sis_tammax) { $errores["archivo"] = "El tamanio del fichero supera el limite permitido ({$maxsize} bytes)!"; $error = true; } else { $nombreArchivo = $_FILES['archivo']['name']; if ($nombreArchivo == "") { } else { if ($sis_tipcarga == 2) { $error = false; $copiarFichero = false; if (is_uploaded_file($_FILES['archivo']['tmp_name'])) { $nombreFichero = $_FILES['archivo']['name']; $copiarFichero = true; $nombreCompleto = $nombreDirectorio . $nombreFichero; if (is_file($nombreCompleto)) { $idUnico = time(); $nombreFichero = $idUnico . "-" . $nombreFichero; } } else { if ($_FILES['archivo']['error'] == UPLOAD_ERR_FORM_SIZE) { $maxsize = $_REQUEST['MAX_FILE_SIZE']; $errores["archivo"] = "El tamanio del fichero supera el limite permitido ({$maxsize} bytes)!"; $error = true; } else { if ($_FILES['archivo']['name'] == "") { $nombreFichero = ''; } else { $errores["archivo"] = "No se ha podido subir el fichero!"; $msm_guardado_archivo = 0; $error = true; } } } if ($error == false) { // Validate $dov_id = $_REQUEST['dov_id']; $rows = $archivo_digital->dbselectByField("dov_id", $dov_id); if (count($rows)) { $sql = "UPDATE tab_archivo_digital\r\n SET fil_nomoriginal='{$nombreFichero}', \r\n fil_nomcifrado='{$archivo_cifrado}', \r\n fil_tipo='{$archivo_type}', \r\n fil_tamano='{$archivo_size}', \r\n fil_extension='{$archivo_ext}', \r\n nombre='{$nombre}', \r\n mime='{$archivo_type}', \r\n size={$archivo_size}, \r\n archivo='{$nombreFichero}', \r\n dov_estado=1\r\n WHERE dov_id = '{$dov_id}' "; $link = $archivo_digital->connect(); pg_query($link, "begin"); pg_query($link, $sql) or die(pg_last_error($link)); pg_query($link, "commit"); if ($copiarFichero) { move_uploaded_file($_FILES['archivo']['tmp_name'], $nombreDirectorio . $nombreFichero); } $msm_guardado_archivo = 1; } else { $sql = "INSERT INTO tab_archivo_digital(dov_id,\r\n fil_nomoriginal,\r\n fil_nomcifrado,\r\n fil_tipo,\r\n fil_tamano,\r\n fil_extension,\r\n nombre,\r\n mime,\r\n size,\r\n archivo,\r\n dov_estado)\r\n VALUES ({$dov_id},\r\n '{$nombreFichero}',\r\n '{$archivo_cifrado}',\r\n '{$archivo_type}',\r\n '{$archivo_size}' ,\r\n '{$archivo_ext}' ,\r\n '{$nombre}',\r\n '{$archivo_type}',\r\n {$archivo_size},\r\n '{$nombreFichero}',\r\n 1)"; $link = $archivo_digital->connect(); pg_query($link, "begin"); pg_query($link, $sql) or die(pg_last_error($link)); pg_query($link, "commit"); if ($copiarFichero) { move_uploaded_file($_FILES['archivo']['tmp_name'], $nombreDirectorio . $nombreFichero); } $msm_guardado_archivo = 1; } } } else { // Validate $dov_id = $_REQUEST['dov_id']; $rows = $this->series->dbselectByField("dov_id", $dov_id); $row = $rows[0]; if (count($row)) { $sql = "UPDATE tab_archivo_digital\r\n SET fil_nomoriginal='{$archivo_name}', \r\n fil_nomcifrado='{$archivo_cifrado}', \r\n fil_tipo='{$archivo_type}', \r\n fil_tamano='{$archivo_size}', \r\n fil_extension='{$archivo_ext}', \r\n nombre='{$nombre}', \r\n archivo_oid={$oid}, \r\n mime='{$archivo_type}', \r\n size={$archivo_size}, \r\n archivo='{$nombreFichero}', \r\n dov_estado=1\r\n WHERE dov_id = {$dov_id} "; $link = $archivo_digital->connect(); $fp = fopen($archivo, "rb"); $contenido = fread($fp, filesize($archivo)); fclose($fp); pg_query($link, "begin"); $oid = pg_lo_create($link); pg_query($link, $sql) or die(pg_last_error($link)); $blob = pg_lo_open($link, $oid, "w"); pg_lo_write($blob, $contenido); pg_lo_close($blob); pg_query($link, "commit"); $msm_guardado_archivo = 1; //"Se subio correctamente el archivo" } else { $sql = "INSERT INTO tab_archivo_digital(dov_id,\r\n fil_nomoriginal,\r\n fil_nomcifrado,\r\n fil_tipo,\r\n fil_tamano,\r\n fil_extension,\r\n nombre,\r\n archivo_oid,\r\n mime,\r\n size,\r\n archivo)\r\n VALUES ({$dov_id},\r\n '{$archivo_name}',\r\n '{$archivo_cifrado}',\r\n '{$archivo_type}',\r\n '{$archivo_size}',\r\n '{$archivo_ext}',\r\n '{$nombre}',\r\n {$oid},\r\n '{$archivo_type}',\r\n {$archivo_size},\r\n '{$nombreFichero}')"; $link = $archivo_digital->connect(); $fp = fopen($archivo, "rb"); $contenido = fread($fp, filesize($archivo)); fclose($fp); pg_query($link, "begin"); $oid = pg_lo_create($link); pg_query($link, $sql) or die(pg_last_error($link)); $blob = pg_lo_open($link, $oid, "w"); pg_lo_write($blob, $contenido); pg_lo_close($blob); pg_query($link, "commit"); $msm_guardado_archivo = 1; } } } } } $dov_id = $_REQUEST['dov_id']; // Forwarding if ($_REQUEST['accion'] == 'guardarsinsalir') { $msm_guardado_archivo = 1; Header("Location: " . PATH_DOMAIN . "/archivo/view/" . $exp_id . "/" . $dov_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 . "/archivo/viewTree/" . $exp_id . "/" . $msm_guardado_archivo . "/{$cue_id}/"); } else { header("location:" . PATH_DOMAIN . "/archivo/viewTree/" . $exp_id . "/" . $msm_guardado_archivo . "/{$cue_id}/"); } } }
function Migrar() { $msg = ""; set_time_limit(1024); ini_set("memory_limit", "1024M"); if ($_FILES["archivo"]) { $Size = $_FILES["archivo"]['size']; $Type = $_FILES["archivo"]['type']; $File = $_FILES["archivo"]['name']; if ($File != '') { $dominio = PATH_FTPDIR_EXCEL; $Dir = $dominio . "/" . $File; if (copy($_FILES['archivo']['tmp_name'], $Dir)) { $status = "Correcto"; } else { $status = "Error"; } } else { $status = "Error"; } } $tipoformato = $_POST['tiporeporte']; require_once $dominio . '/PHPExcel/IOFactory.php'; $objPHPExcel = PHPExcel_IOFactory::load("web/" . $File); foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { $worksheetTitle = $worksheet->getTitle(); $highestRow = $worksheet->getHighestRow(); // e.g. 10 $highestColumn = $worksheet->getHighestColumn(); // e.g 'F' $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); $nrColumns = ord($highestColumn) - 64; } $id_serie = ""; $id_seccion = ""; //obtener datos de la base de datos like $fechadocAnioInicial = ""; $fechadocMesInicial = ""; if ($tipoformato == 1) { //GNT-SCT $cantidaddoc = $highestRow - 37; $fondo = $objPHPExcel->getActiveSheet()->getCell("E8")->getValue(); $subfondo = $objPHPExcel->getActiveSheet()->getCell("E9")->getValue(); $seccion = $objPHPExcel->getActiveSheet()->getCell("E10")->getValue(); $subseccion = $objPHPExcel->getActiveSheet()->getCell("E11")->getValue(); $serie = $objPHPExcel->getActiveSheet()->getCell("E13")->getValue(); $tituloexpediente = $objPHPExcel->getActiveSheet()->getCell("E14")->getValue(); $fechasExtremas = $objPHPExcel->getActiveSheet()->getCell("O13")->getValue(); $ml = $objPHPExcel->getActiveSheet()->getCell("D16")->getValue(); $objHoja = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); $objWorksheet = $objPHPExcel->getActiveSheet(); $tituloserie = explode("\n", $serie); $cantidaserie = count($tituloserie); if ($cantidaserie > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea del Título de la Serie</font><br>"; unlink($Dir); $this->index($msg); exit; } $tituloexp = explode("\n", $tituloexpediente); $cantidaexpediente = count($tituloexp); if ($cantidaexpediente > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea en Título de Expediente </font><br>"; unlink($Dir); $this->index($msg); exit; } if ($highestColumn != "Q") { $msg = "<font color='red'>FORMATO GNT - SCT NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } //$msg= '<table border="1">' . "\n"; //foreach ($objWorksheet->getRowIterator() as $row) { //$msg= '<tr>' . "\n"; // //$cellIterator = $row->getCellIterator(); //$cellIterator->setIterateOnlyExistingCells(false); // This loops all cells, //foreach ($cellIterator as $cell) { //$msg= '<td>' . htmlentities($cell->getValue(), ENT_IGNORE, 'utf-8') . '</td>' . "\n"; //} // //$msg= '</tr>' . "\n"; //} //$msg= '</table>' . "\n"; //if(trim($subseccion)=="SUBGERENCIA DE CONSERVACION VIAL"){ // $subseccion="PROYECTOS DE CONSERVACION VIAL"; //} $tab_fondo = new Tab_fondo(); $tab_unidad = new Tab_unidad(); $tab_series = new Tab_series(); //obtener fondo y subfondo $sql = "select* from tab_fondo where fon_descripcion LIKE '%{$fondo}%'"; $sql2 = "select* from tab_fondo where fon_descripcion LIKE '%{$subfondo}%'"; $resultado = $tab_fondo->dbSelectBySQL($sql); $resultado2 = $tab_fondo->dbSelectBySQL($sql2); $id_fondo = $resultado[0]->fon_id; $id_subfondo = $resultado2[0]->fon_id; $ubicacion = $resultado2[0]->fon_codigo; switch ($ubicacion) { case "ON": $ubicacion = "LA PAZ"; break; case "LP": $ubicacion = "LA PAZ"; break; case "SC": $ubicacion = "SANTA CRUZ"; break; case "PT": $ubicacion = "POTOSI"; break; case "BN": $ubicacion = "BENI"; break; case "PN": $ubicacion = "PANDO"; break; case "CB": $ubicacion = "COCHABAMBA"; break; case "OR": $ubicacion = "ORURO"; break; case "CH": $ubicacion = "CHUQUISACA"; break; case "TJ": $ubicacion = "TARIJA"; break; } if ($seccion == "DIRECCION GENERAL TECNICA") { if ($id_subfondo == 3) { $seccion = "TECNICA-OPERATIVA"; } else { $seccion = "AREA TECNICA"; } } //obtener el fon_id $subseccion = trim($subseccion); if ($subseccion == "") { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$seccion}%'"; } else { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$subseccion}%'"; } $resultado3 = $tab_unidad->dbSelectBySQL($sql3); foreach ($resultado3 as $rowseccion) { $id_seccion = $rowseccion->uni_id; } //obtengo la serie $sql4 = "SELECT\r\ntab_series.ser_categoria,\r\ntab_series.ser_id\r\nFROM\r\ntab_fondo\r\nINNER JOIN tab_unidad ON tab_fondo.fon_id = tab_unidad.fon_id\r\nINNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\nWHERE\r\ntab_fondo.fon_id = {$id_subfondo} AND tab_series.ser_categoria LIKE '%{$serie}%'"; $resultado4 = $tab_series->dbSelectBySQL($sql4); foreach ($resultado4 as $rowserie) { $id_serie = $rowserie->ser_id; } $ml = $objPHPExcel->getActiveSheet()->getCell("D16")->getValue(); if ($id_serie == "") { $msg = "<font color='red'>Error, No existe la Serie Asignada</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_subfondo == "") { $msg = "<font color='red'>Error, No existe el Subfondo</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_seccion == "") { $msg = "<font color='red'>Error, No existe la Sección</font><br>"; unlink($Dir); $this->index($msg); exit; } } } if ($highestColumn == "Q") { if ($ml == "ML") { $i = 1; $ct = 18; $t = 0; $expsadg = new Tab_expisadg(); $resulall = $expsadg->dbselectByField("exp_titulo", strtoupper($tituloexpediente)); foreach ($resulall as $list) { $t++; } $fechafinal = ''; $fechainicial = ''; $exp_fechas = explode("-", $fechasExtremas); if (!empty($exp_fechas[1])) { $fechafinal = trim($exp_fechas[1]); } if (!empty($exp_fechas[0])) { $fechainicial = trim($exp_fechas[0]); } if ($t > 0) { $msg = "<font color='red'>Error! existe otro nombre duplicado</font>"; unlink($Dir); $this->index($msg); exit; } $expediente = new expediente(); $hoy = date("Y-m-d"); $this->expediente = new tab_expediente(); // $this->expediente->setRequest2Object($_REQUEST); $this->expediente->setExp_id(''); $this->expediente->setSer_id($id_serie); // Generation code $this->expediente->setExp_codigo($expediente->generaCodigo($id_serie)); $this->expediente->setExp_lugar($ubicacion); $this->expediente->setSof_id(1); $this->expediente->setExp_ori(0); $this->expediente->setExp_cop(0); $this->expediente->setExp_fot(0); $this->expediente->setExp_obs(''); $this->expediente->setExp_corr('AUTO'); $this->expediente->setExp_estado(1); $this->expediente->setExp_migrarexcel(1); $exp_id = $this->expediente->insert2(); // Update count // if ($_REQUEST['ser_corr'] == 'AUTO') { // // Auto // $tseries = new tab_series(); // $row2 = $tseries->dbselectByField("ser_id", $_REQUEST['ser_id']); // $row2 = $row2[0]; // $tseries->setSer_id($_REQUEST['ser_id']); // $ser_exp = $row2->ser_exp + 1; // $tseries->setSer_exp($ser_exp); // $tseries->update(); // } else { // // Manual // $tseries = new tab_series(); // $tseries->setSer_id($_REQUEST['ser_id']); // $tseries->setSer_exp($_REQUEST['exp_codigo']); // $tseries->update(); // } //$this->expisadg->setTrm_id(1); // $expisadg = new tab_expisadg(); // $expisadg->setExp_id($exp_id); // $expisadg->setExp_titulo($expediente); // $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_fecha_exi(date('Y-m-d')); // $expisadg->setExp_fecha_exf(date('Y-m-d')); // $expisadg->setExp_anioi($fechainicial); // $expisadg->setExp_aniof($fechafinal); // $expisadg->setIdi_id(1); // $expisadg->setExp_estado(1); // $eig_id = $expisadg->insert(); $fechahoy = date('Y-m-d'); $expisadg = new tab_expisadg(); $expisadg->setExp_id($exp_id); $expisadg->setExp_titulo($tituloexpediente); $expisadg->setExp_fecha_exi($fechahoy); // $expisadg->setExp_mesi(''); $expisadg->setExp_anioi($fechainicial); $expisadg->setExp_fecha_exf($fechahoy); // $expisadg->setExp_mesf(''); $expisadg->setExp_aniof($fechafinal); $expisadg->setExp_nivdes('EXPEDIENTE'); // $expisadg->setExp_volsop(''); $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_hisins(''); // $expisadg->setExp_hisarc(''); $expisadg->setExp_foring('TRANSFERENCIA'); // $expisadg->setExp_alccon(''); // $expisadg->setExp_vaseel(''); // $expisadg->setExp_nueing(''); $expisadg->setExp_org('LOS DOCUMENTOS DEL PROYECTO FUERON IDENTIFICADOS, CLASIFICADOS Y ORDENADOS EN LAS CAJAS DE ACUERDO AL CHECK LIST DE LA SERIE A LA QUE CORRESPONDEN.'); $expisadg->setExp_conacc('EL ACCESO ESTA SUJETO A LO QUE ESTABLECE LA CONSTITUCION POLITICA DEL ESTADO Y EL ARTICULO 18 DE LA LEY 2341 SOBRE PROCESOS ADMINISTRATIVOS.'); // $expisadg->setExp_conrep(''); $expisadg->setIdi_id(1); $expisadg->setExp_carfis('BUENO'); // $expisadg->setExp_insdes(''); // $expisadg->setExp_exloor(''); // $expisadg->setExp_exloco(''); // $expisadg->setExp_underel(''); // $expisadg->setExp_notpub(''); // $expisadg->setExp_notas(''); // $expisadg->setExp_notarc(''); $expisadg->setExp_regnor('ISAD-G, ISAAR(CPF), RCAA'); $expisadg->setExp_fecdes(date('Y-m-d')); $expisadg->setExp_estado(1); $eig_id = $expisadg->insert(); // Save expfondo data $texf = new Tab_expfondo(); $texf->setExp_id($exp_id); $usuario = new usuario(); $fon_id = $usuario->getFon_id($_SESSION['USU_ID']); $nomUsuario = $usuario->obtenerNombre($_SESSION['USU_ID']); $texf->setExf_fecha_exi($fechahoy); $texf->setFon_id($fon_id); $texf->setExf_estado('1'); $texf->insert(); // Save expusuario data $this->expusuario = new expusuario(); $this->expusuario->saveExp($exp_id, $_SESSION['USU_ID']); // // Save expcontenedor data // $con = new expcontenedor(); // $con->saveExpCont($_REQUEST['con_id'], $_REQUEST['suc_id'], $exp_id); // // Save proyecto list data (tramos) // if (isset($_REQUEST['lista_tramo'])) { // $proyectos = $_REQUEST['lista_tramo']; // foreach ($proyectos as $proyecto) { // $exp = new tab_expproyecto(); // $exp->setExp_id($exp_id); // $exp->setPry_id($proyecto); // $exp->setEpp_estado(1); // $exp->insert(); // } // } // Save data dynamic $c = 0; $caj = ""; $cnt = 0; //insert usuario serie $tab_usu_serie = new Tab_usu_serie(); $sqlususerie = "select* from tab_usu_serie\r\n where usu_id='" . $_SESSION['USU_ID'] . "'\r\n and ser_id='" . $id_serie . "'\r\n and use_estado=1"; $comprobar_usu_serie = $tab_usu_serie->dbSelectBySQL($sqlususerie); $cnt = count($comprobar_usu_serie); if ($cnt == 0) { $tab_usu_serie->setUse_id(''); $tab_usu_serie->setUsu_id($_SESSION['USU_ID']); $tab_usu_serie->setSer_id($id_serie); $tab_usu_serie->setUse_estado(1); $tab_usu_serie->insert(); } while ($i <= $cantidaddoc) { $caja = $objPHPExcel->getActiveSheet()->getCell("A" . $ct)->getValue(); $filnroejem = $objPHPExcel->getActiveSheet()->getCell("C" . $ct)->getValue(); $correlativo = $objPHPExcel->getActiveSheet()->getCell("E" . $ct)->getValue(); $titledoc = $objPHPExcel->getActiveSheet()->getCell("F" . $ct)->getValue(); $subtitledoc = $objPHPExcel->getActiveSheet()->getCell("G" . $ct)->getValue(); $productor = $objPHPExcel->getActiveSheet()->getCell("H" . $ct)->getValue(); $contrato = $objPHPExcel->getActiveSheet()->getCell("I" . $ct)->getValue(); $fecha = trim($objPHPExcel->getActiveSheet()->getCell("J" . $ct)->getValue()); $tomovol = $objPHPExcel->getActiveSheet()->getCell("K" . $ct)->getValue(); $sopfis = $objPHPExcel->getActiveSheet()->getCell("L" . $ct)->getValue(); $sala = $objPHPExcel->getActiveSheet()->getCell("M" . $ct)->getValue(); $estante = $objPHPExcel->getActiveSheet()->getCell("N" . $ct)->getValue(); $cuerpo = $objPHPExcel->getActiveSheet()->getCell("O" . $ct)->getValue(); $balda = $objPHPExcel->getActiveSheet()->getCell("P" . $ct)->getValue(); $obs = $objPHPExcel->getActiveSheet()->getCell("Q" . $ct)->getValue(); //todavia en trabajo if ($titledoc != "") { if ($fecha != "s/f") { $extfe = explode("\n", $fecha); $cantidadfecha = count($extfe); if ($cantidadfecha > 1) { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = $extfe[1]; } else { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = ""; if ($fechadocAnioInicial > 30000) { $fe = date("m-y", (int) $fechadocAnioInicial); $extraer = explode("-", $fe); $fechadocAnioInicial = $extraer[1]; $fechadocMesInicial = $extraer[0]; } } } // exit(); if ($caja == "") { } else { $extraercaj = explode(" ", trim($caja)); $caj = $extraercaj[1]; } $id_exp = $exp_id; $this->archivo = new tab_archivo(); $this->archivo->setFil_id(''); // Generation code max fil_nro $maxFil = new Tab_archivo(); $sql2 = "SELECT\r\n MAX(tab_archivo.fil_nro) AS maxnro\r\n FROM\r\n tab_expediente\r\n INNER JOIN tab_exparchivo ON tab_exparchivo.exp_id = tab_expediente.exp_id\r\n INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n WHERE\r\n tab_expediente.exp_id = {$id_exp} AND\r\n tab_expediente.exp_estado = 1"; $cant_max = $maxFil->dbSelectBySQL($sql2); foreach ($cant_max as $lismax) { $max3 = $lismax->maxnro; } if ($max3 == "") { $max3 = 0; } $max3 = $max3 + 1; $this->archivo->setFil_nro($max3); $this->archivo->setFil_titulo(strtoupper($titledoc)); $this->archivo->setFil_subtitulo(strtoupper($subtitledoc)); $this->archivo->setFil_fecha($fechahoy); $this->archivo->setIdi_id(1); $this->archivo->setFil_proc($fondo); $this->archivo->setFil_firma($nomUsuario); $this->archivo->setFil_cargo(''); $this->archivo->setFil_alccon(''); $sqlsopfis = new tab_sopfisico(); if ($sopfis != "AP" || $sopfis != "EM" || $sopfis != "LG" || $sopfis != "AN" || $sopfis != "MM" || $sopfis != "CP") { $sopfis = "LG"; } $result = $sqlsopfis->dbselectByField("sof_codigo", $sopfis); $this->archivo->setSof_id($result[0]->sof_id); $this->archivo->setFil_codigo(2); $this->archivo->setFil_nrofoj(''); $this->archivo->setFil_tomovol($tomovol); $this->archivo->setFil_nroejem($filnroejem); $this->archivo->setFil_nrocaj($caj); $this->archivo->setFil_nropaq(''); $this->archivo->setFil_sala(strtoupper($sala)); $this->archivo->setFil_estante(strtoupper($estante)); $this->archivo->setFil_cuerpo(strtoupper($cuerpo)); $this->archivo->setFil_balda(strtoupper($balda)); $this->archivo->setFil_tipoarch('TEC'); $this->archivo->setFil_mrb('BUENO'); $this->archivo->setFil_mes($fechadocMesInicial); $this->archivo->setFil_anio($fechadocAnioInicial); $this->archivo->setFil_cantpaq(''); $this->archivo->setFil_cantcaj(''); $this->archivo->setFil_confidencialidad(1); $this->archivo->setFil_obs(strtoupper($obs)); $this->archivo->setFil_estado('1'); $fil_id = $this->archivo->insert(); $this->archivo2 = new tab_archivo(); $this->archivo2->setFil_id($fil_id); $this->archivo2->setFil_codigo($fil_id); $this->archivo2->setFil_estado('1'); $this->archivo2->update(); $this->exparchivo = new tab_exparchivo(); $this->exparchivo->setExa_id(''); $this->exparchivo->setFil_id($fil_id); $this->exparchivo->setExp_id($exp_id); $archivo_digital = new tab_archivo_digital(); $archivo_digital->setFid_id(''); $archivo_digital->setFil_id($fil_id); $archivo_digital->insert(); $seriet = new Tab_serietramite(); $this->series = new series(); $ser_codigo = $this->series->obtenerCodigoSerie($id_serie); //insert grupos documentales y tipos documentales $this->tramite = new tab_tramite(); $tramitecc = new tab_tramitecuerpos(); $sqltramite = "SELECT\r\n tab_tramite.tra_descripcion,\r\n tab_tramite.tra_id\r\n FROM\r\n tab_series\r\n INNER JOIN tab_serietramite ON tab_series.ser_id = tab_serietramite.ser_id\r\n INNER JOIN tab_tramite ON tab_tramite.tra_id = tab_serietramite.tra_id\r\n WHERE\r\n tab_series.ser_id = {$id_serie}"; $rows = $seriet->dbSelectBySQL($sqltramite); $v = 0; foreach ($rows as $row) { if ($row->tra_descripcion == 'GRUPO DOCUMENTAL COMPUESTA') { $v++; $tra_id = $row->tra_id; $obtenerColumnCueId = $tramitecc->dbselectByField("tra_id", $tra_id); $cue_id = $obtenerColumnCueId[0]->cue_id; } } if ($v == 0) { $this->tramite->setTra_orden(1); $this->tramite->setTra_codigo(1); $this->tramite->setTra_descripcion("GRUPO DOCUMENTAL COMPUESTA"); $this->tramite->setTra_fecha_crea(date("Y-m-d")); $this->tramite->setTra_usuario_crea($_SESSION['USU_ID']); $this->tramite->setTra_estado(1); $tra_id = $this->tramite->insert(); $seriet->setSer_id($id_serie); $seriet->setTra_id($tra_id); $seriet->setSts_fecha_crea(date("Y-m-d")); $seriet->setSts_fecha_reg(date("Y-m-d")); $seriet->setSts_usuario_crea($_SESSION['USU_ID']); $seriet->setSts_usu_reg($_SESSION['USU_ID']); $seriet->setVer_id('0'); $seriet->setSts_estado(1); $seriet->insert(); $this->tramite = new tramite(); $tra_codigo = $this->tramite->obtenerCodigoTramite($tra_id); $tcuerpos = new tab_cuerpos(); $tcuerpos->setCue_id(''); $tcuerpos->setCue_orden(1); $tcuerpos->setCue_codigo(1); $tcuerpos->setCue_descripcion("UNIDAD DOCUMENTAL SIMPLE"); $tcuerpos->setCue_fecha_crea(date("Y-m-d")); $tcuerpos->setCue_usuario_crea($_SESSION['USU_ID']); $tcuerpos->setCue_estado(1); $cue_id = $tcuerpos->insert(); // Last code //$tramitecc = new tab_tramitecuerpos(); $tramitecc->setCue_id($cue_id); $tramitecc->setTra_id($tra_id); $tramitecc->setTrc_estado(1); $tramitecc->insert(); } //insert $this->exparchivo->setTra_id($tra_id); $this->exparchivo->setCue_id($cue_id); $this->exparchivo->setExa_condicion('1'); $this->exparchivo->setExa_estado(1); $this->exparchivo->insert(); //Fin del archivo } $i++; $ct++; } } else { $msg = "<font color='red'>FORMATO GNT - SCT NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } $msg .= "<b style='color:green'>SE GUARDO CORRECTAMENTE</b><br>"; $msg .= "<a href='" . PATH_DOMAIN . "/nuevoExpediente/index/'>Ver registro</a>"; unlink($Dir); $this->index($msg); exit; } else { $msg = "<font color='red'>FORMATO GNT - SCT NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } } else { if ($tipoformato == 2) { //GNT-SCV // $msg= $highestColumn; exit(); $cantidaddoc = $highestRow - 18; $fondo = $objPHPExcel->getActiveSheet()->getCell("F8")->getValue(); $subfondo = $objPHPExcel->getActiveSheet()->getCell("F9")->getValue(); $seccion = $objPHPExcel->getActiveSheet()->getCell("F10")->getValue(); $subseccion = $objPHPExcel->getActiveSheet()->getCell("F11")->getValue(); $serie = $objPHPExcel->getActiveSheet()->getCell("F13")->getValue(); $tituloexpediente = $objPHPExcel->getActiveSheet()->getCell("F14")->getValue(); $fechasExtremas = $objPHPExcel->getActiveSheet()->getCell("S13")->getValue(); $ml = $objPHPExcel->getActiveSheet()->getCell("D17")->getValue(); $objHoja = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); $objWorksheet = $objPHPExcel->getActiveSheet(); //if(trim($subseccion)=="SUBGERENCIA DE CONSERVACION VIAL"){ // $subseccion="PROYECTOS DE CONSERVACION VIAL"; //} $tituloserie = explode("\n", $serie); $cantidaserie = count($tituloserie); if ($cantidaserie > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea del Título de la Serie</font><br>"; unlink($Dir); $this->index($msg); exit; } $tituloexp = explode("\n", $tituloexpediente); $cantidaexpediente = count($tituloexp); if ($cantidaexpediente > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea en Título de Expediente </font><br>"; unlink($Dir); $this->index($msg); exit; } if ($highestColumn != "U") { $msg = "<font color='red'>FORMATO GNT - SCV NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } // //$msg= $fondo."<br>"; //$msg= $subfondo."<br>"; //$msg= $seccion."<br>"; //$msg= $subseccion."<br>"; //$msg= $serie."<br>"; //$msg= $tituloexpediente."<br>"; //$msg= $fechasExtremas."<br>"; //$msg= $ml."<br>"; // //$msg= '<table border="1">' . "\n"; //foreach ($objWorksheet->getRowIterator() as $row) { //$msg= '<tr>' . "\n"; // //$cellIterator = $row->getCellIterator(); //$cellIterator->setIterateOnlyExistingCells(false); // This loops all cells, //foreach ($cellIterator as $cell) { //$msg= '<td>' . htmlentities($cell->getValue(), ENT_IGNORE, 'utf-8') . '</td>' . "\n"; //} //$msg= '</tr>' . "\n"; //} //$msg= '</table>' . "\n"; // // exit(); $tab_fondo = new Tab_fondo(); $tab_unidad = new Tab_unidad(); $tab_series = new Tab_series(); //obtener fondo y subfondo $sql = "select* from tab_fondo where fon_descripcion LIKE '%{$fondo}%'"; $sql2 = "select* from tab_fondo where fon_descripcion LIKE '%{$subfondo}%'"; $resultado = $tab_fondo->dbSelectBySQL($sql); $resultado2 = $tab_fondo->dbSelectBySQL($sql2); $id_fondo = $resultado[0]->fon_id; $id_subfondo = $resultado2[0]->fon_id; $ubicacion = $resultado2[0]->fon_codigo; switch ($ubicacion) { case "ON": $ubicacion = "LA PAZ"; break; case "LP": $ubicacion = "LA PAZ"; break; case "SC": $ubicacion = "SANTA CRUZ"; break; case "PT": $ubicacion = "POTOSI"; break; case "BN": $ubicacion = "BENI"; break; case "PN": $ubicacion = "PANDO"; break; case "CB": $ubicacion = "COCHABAMBA"; break; case "OR": $ubicacion = "ORURO"; break; case "CH": $ubicacion = "CHUQUISACA"; break; case "TJ": $ubicacion = "TARIJA"; break; } if ($seccion == "DIRECCION GENERAL TECNICA") { if ($id_subfondo == 3) { $seccion = "TECNICA-OPERATIVA"; } else { $seccion = "AREA TECNICA"; } } //obtener el fon_id $subseccion = trim($subseccion); if ($subseccion == "") { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$seccion}%'"; } else { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$subseccion}%'"; } $resultado3 = $tab_unidad->dbSelectBySQL($sql3); foreach ($resultado3 as $rowseccion) { $id_seccion = $rowseccion->uni_id; } //obtengo la serie $sql4 = "SELECT\r\ntab_series.ser_categoria,\r\ntab_series.ser_id\r\nFROM\r\ntab_fondo\r\nINNER JOIN tab_unidad ON tab_fondo.fon_id = tab_unidad.fon_id\r\nINNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\nWHERE\r\ntab_fondo.fon_id = {$id_subfondo} AND tab_series.ser_categoria LIKE '%{$serie}%'"; $resultado4 = $tab_series->dbSelectBySQL($sql4); foreach ($resultado4 as $rowserie) { $id_serie = $rowserie->ser_id; } $ml = $objPHPExcel->getActiveSheet()->getCell("D17")->getValue(); //$msg= $id_serie."<br>"; //$msg= $id_fondo."<br>"; //$msg= $id_subfondo."<br>"; //$msg= $id_seccion."<br>"; if ($id_serie == "") { $msg = "<font color='red'>Error, No existe la Serie Asignada</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_subfondo == "") { $msg = "<font color='red'>Error, No existe el Subfondo</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_seccion == "") { $msg = "<font color='red'>Error, No existe la Sección</font><br>"; unlink($Dir); $this->index($msg); exit; } } } if ($highestColumn == "U") { if ($ml == "ML") { $i = 1; $ct = 18; $t = 0; $expsadg = new Tab_expisadg(); $resulall = $expsadg->dbselectByField("exp_titulo", strtoupper($tituloexpediente)); foreach ($resulall as $list) { $t++; } $fechafinal = ''; $fechainicial = ''; $exp_fechas = explode("-", $fechasExtremas); if (!empty($exp_fechas[1])) { $fechafinal = trim($exp_fechas[1]); } if (!empty($exp_fechas[0])) { $fechainicial = trim($exp_fechas[0]); } if ($t > 0) { $msg = "<font color='red'>Error! existe otro nombre duplicado</font>"; unlink($Dir); $this->index($msg); exit; } $expediente = new expediente(); $hoy = date("Y-m-d"); $this->expediente = new tab_expediente(); // $this->expediente->setRequest2Object($_REQUEST); $this->expediente->setExp_id(''); $this->expediente->setSer_id($id_serie); // Generation code $this->expediente->setExp_codigo($expediente->generaCodigo($id_serie)); $this->expediente->setExp_lugar($ubicacion); $this->expediente->setSof_id(1); $this->expediente->setExp_ori(0); $this->expediente->setExp_cop(0); $this->expediente->setExp_fot(0); $this->expediente->setExp_obs(''); $this->expediente->setExp_corr('AUTO'); $this->expediente->setExp_estado(1); $this->expediente->setExp_migrarexcel(1); $exp_id = $this->expediente->insert2(); // Update count // if ($_REQUEST['ser_corr'] == 'AUTO') { // // Auto // $tseries = new tab_series(); // $row2 = $tseries->dbselectByField("ser_id", $_REQUEST['ser_id']); // $row2 = $row2[0]; // $tseries->setSer_id($_REQUEST['ser_id']); // $ser_exp = $row2->ser_exp + 1; // $tseries->setSer_exp($ser_exp); // $tseries->update(); // } else { // // Manual // $tseries = new tab_series(); // $tseries->setSer_id($_REQUEST['ser_id']); // $tseries->setSer_exp($_REQUEST['exp_codigo']); // $tseries->update(); // } //$this->expisadg->setTrm_id(1); // $expisadg = new tab_expisadg(); // $expisadg->setExp_id($exp_id); // $expisadg->setExp_titulo($expediente); // $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_fecha_exi(date('Y-m-d')); // $expisadg->setExp_fecha_exf(date('Y-m-d')); // $expisadg->setExp_anioi($fechainicial); // $expisadg->setExp_aniof($fechafinal); // $expisadg->setIdi_id(1); // $expisadg->setExp_estado(1); // $eig_id = $expisadg->insert(); $fechahoy = date('Y-m-d'); $expisadg = new tab_expisadg(); $expisadg->setExp_id($exp_id); $expisadg->setExp_titulo($tituloexpediente); $expisadg->setExp_fecha_exi($fechahoy); // $expisadg->setExp_mesi(''); $expisadg->setExp_anioi($fechainicial); $expisadg->setExp_fecha_exf($fechahoy); // $expisadg->setExp_mesf(''); $expisadg->setExp_aniof($fechafinal); $expisadg->setExp_nivdes('EXPEDIENTE'); // $expisadg->setExp_volsop(''); $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_hisins(''); // $expisadg->setExp_hisarc(''); $expisadg->setExp_foring('TRANSFERENCIA'); // $expisadg->setExp_alccon(''); // $expisadg->setExp_vaseel(''); // $expisadg->setExp_nueing(''); $expisadg->setExp_org('LOS DOCUMENTOS DEL PROYECTO FUERON IDENTIFICADOS, CLASIFICADOS Y ORDENADOS EN LAS CAJAS DE ACUERDO AL CHECK LIST DE LA SERIE A LA QUE CORRESPONDEN.'); $expisadg->setExp_conacc('EL ACCESO ESTA SUJETO A LO QUE ESTABLECE LA CONSTITUCION POLITICA DEL ESTADO Y EL ARTICULO 18 DE LA LEY 2341 SOBRE PROCESOS ADMINISTRATIVOS.'); // $expisadg->setExp_conrep(''); $expisadg->setIdi_id(1); $expisadg->setExp_carfis('BUENO'); // $expisadg->setExp_insdes(''); // $expisadg->setExp_exloor(''); // $expisadg->setExp_exloco(''); // $expisadg->setExp_underel(''); // $expisadg->setExp_notpub(''); // $expisadg->setExp_notas(''); // $expisadg->setExp_notarc(''); $expisadg->setExp_regnor('ISAD-G, ISAAR(CPF), RCAA'); $expisadg->setExp_fecdes(date('Y-m-d')); $expisadg->setExp_estado(1); $eig_id = $expisadg->insert(); // Save expfondo data $texf = new Tab_expfondo(); $texf->setExp_id($exp_id); $usuario = new usuario(); $fon_id = $usuario->getFon_id($_SESSION['USU_ID']); $nomUsuario = $usuario->obtenerNombre($_SESSION['USU_ID']); $texf->setExf_fecha_exi($fechahoy); $texf->setFon_id($fon_id); $texf->setExf_estado('1'); $texf->insert(); // Save expusuario data $this->expusuario = new expusuario(); $this->expusuario->saveExp($exp_id, $_SESSION['USU_ID']); // // Save expcontenedor data // $con = new expcontenedor(); // $con->saveExpCont($_REQUEST['con_id'], $_REQUEST['suc_id'], $exp_id); // // Save proyecto list data (tramos) // if (isset($_REQUEST['lista_tramo'])) { // $proyectos = $_REQUEST['lista_tramo']; // foreach ($proyectos as $proyecto) { // $exp = new tab_expproyecto(); // $exp->setExp_id($exp_id); // $exp->setPry_id($proyecto); // $exp->setEpp_estado(1); // $exp->insert(); // } // } // Save data dynamic $c = 0; $caj = ""; $cnt = 0; //insert usuario serie $tab_usu_serie = new Tab_usu_serie(); $sqlususerie = "select* from tab_usu_serie\r\n where usu_id='" . $_SESSION['USU_ID'] . "'\r\n and ser_id='" . $id_serie . "'\r\n and use_estado=1"; $comprobar_usu_serie = $tab_usu_serie->dbSelectBySQL($sqlususerie); $cnt = count($comprobar_usu_serie); if ($cnt == 0) { $tab_usu_serie->setUse_id(''); $tab_usu_serie->setUsu_id($_SESSION['USU_ID']); $tab_usu_serie->setSer_id($id_serie); $tab_usu_serie->setUse_estado(1); $tab_usu_serie->insert(); } while ($i <= $cantidaddoc) { $caja = $objPHPExcel->getActiveSheet()->getCell("A" . $ct)->getValue(); $filnroejem = $objPHPExcel->getActiveSheet()->getCell("C" . $ct)->getValue(); $correlativo = $objPHPExcel->getActiveSheet()->getCell("E" . $ct)->getValue(); $titledoc = $objPHPExcel->getActiveSheet()->getCell("H" . $ct)->getValue(); $subtitledoc = $objPHPExcel->getActiveSheet()->getCell("I" . $ct)->getValue(); // $productor=$objPHPExcel->getActiveSheet()->getCell("J".$ct)->getValue(); $contrato = $objPHPExcel->getActiveSheet()->getCell("K" . $ct)->getValue(); $fecha = trim($objPHPExcel->getActiveSheet()->getCell("N" . $ct)->getValue()); $tomovol = $objPHPExcel->getActiveSheet()->getCell("O" . $ct)->getValue(); $sopfis = $objPHPExcel->getActiveSheet()->getCell("P" . $ct)->getValue(); $sala = $objPHPExcel->getActiveSheet()->getCell("Q" . $ct)->getValue(); $estante = $objPHPExcel->getActiveSheet()->getCell("R" . $ct)->getValue(); $cuerpo = $objPHPExcel->getActiveSheet()->getCell("S" . $ct)->getValue(); $balda = $objPHPExcel->getActiveSheet()->getCell("T" . $ct)->getValue(); $obs = $objPHPExcel->getActiveSheet()->getCell("U" . $ct)->getValue(); //todavia en trabajo if ($titledoc != "") { if ($fecha != "s/f") { $extfe = explode("\n", $fecha); $cantidadfecha = count($extfe); if ($cantidadfecha > 1) { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = $extfe[1]; } else { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = ""; if ($fechadocAnioInicial > 30000) { $fe = date("m-y", (int) $fechadocAnioInicial); $extraer = explode("-", $fe); $fechadocAnioInicial = $extraer[1]; $fechadocMesInicial = $extraer[0]; } } } // exit(); if ($caja == "") { } else { $extraercaj = explode(" ", trim($caja)); $caj = $extraercaj[1]; } $id_exp = $exp_id; $this->archivo = new tab_archivo(); $this->archivo->setFil_id(''); // Generation code max fil_nro $maxFil = new Tab_archivo(); $sql2 = "SELECT\r\n MAX(tab_archivo.fil_nro) AS maxnro\r\n FROM\r\n tab_expediente\r\n INNER JOIN tab_exparchivo ON tab_exparchivo.exp_id = tab_expediente.exp_id\r\n INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n WHERE\r\n tab_expediente.exp_id = {$id_exp} AND\r\n tab_expediente.exp_estado = 1"; $cant_max = $maxFil->dbSelectBySQL($sql2); foreach ($cant_max as $lismax) { $max3 = $lismax->maxnro; } if ($max3 == "") { $max3 = 0; } $max3 = $max3 + 1; $this->archivo->setFil_nro($max3); $this->archivo->setFil_titulo(strtoupper($titledoc)); $this->archivo->setFil_codigo(2); $this->archivo->setFil_subtitulo(strtoupper($subtitledoc)); $this->archivo->setFil_fecha($fechahoy); $this->archivo->setIdi_id(1); $this->archivo->setFil_proc($fondo); $this->archivo->setFil_firma($nomUsuario); $this->archivo->setFil_cargo(''); $this->archivo->setFil_alccon(''); $sqlsopfis = new tab_sopfisico(); if ($sopfis != "AP" || $sopfis != "EM" || $sopfis != "LG" || $sopfis != "AN" || $sopfis != "MM" || $sopfis != "CP") { $sopfis = "LG"; } $result = $sqlsopfis->dbselectByField("sof_codigo", $sopfis); $this->archivo->setSof_id($result[0]->sof_id); $this->archivo->setFil_nrofoj(''); $this->archivo->setFil_tomovol($tomovol); $this->archivo->setFil_nroejem($filnroejem); $this->archivo->setFil_nrocaj($caj); $this->archivo->setFil_nropaq(''); $this->archivo->setFil_sala(strtoupper($sala)); $this->archivo->setFil_estante(strtoupper($estante)); $this->archivo->setFil_cuerpo(strtoupper($cuerpo)); $this->archivo->setFil_balda(strtoupper($balda)); $this->archivo->setFil_tipoarch('TEC'); $this->archivo->setFil_mrb('BUENO'); $this->archivo->setFil_mes($fechadocMesInicial); $this->archivo->setFil_anio($fechadocAnioInicial); $this->archivo->setFil_cantpaq(''); $this->archivo->setFil_cantcaj(''); $this->archivo->setFil_confidencialidad(1); $this->archivo->setFil_obs(strtoupper($obs)); $this->archivo->setFil_estado('1'); $fil_id = $this->archivo->insert(); $this->archivo2 = new tab_archivo(); $this->archivo2->setFil_id($fil_id); $this->archivo2->setFil_codigo($fil_id); $this->archivo2->setFil_estado('1'); $this->archivo2->update(); $this->exparchivo = new tab_exparchivo(); $this->exparchivo->setExa_id(''); $this->exparchivo->setFil_id($fil_id); $this->exparchivo->setExp_id($exp_id); $archivo_digital = new tab_archivo_digital(); $archivo_digital->setFid_id(''); $archivo_digital->setFil_id($fil_id); $archivo_digital->insert(); $seriet = new Tab_serietramite(); $this->series = new series(); $ser_codigo = $this->series->obtenerCodigoSerie($id_serie); //insert grupos documentales y tipos documentales $this->tramite = new tab_tramite(); $tramitecc = new tab_tramitecuerpos(); $sqltramite = "SELECT\r\n tab_tramite.tra_descripcion,\r\n tab_tramite.tra_id\r\n FROM\r\n tab_series\r\n INNER JOIN tab_serietramite ON tab_series.ser_id = tab_serietramite.ser_id\r\n INNER JOIN tab_tramite ON tab_tramite.tra_id = tab_serietramite.tra_id\r\n WHERE\r\n tab_series.ser_id = {$id_serie}"; $rows = $seriet->dbSelectBySQL($sqltramite); $v = 0; foreach ($rows as $row) { if ($row->tra_descripcion == 'GRUPO DOCUMENTAL COMPUESTA') { $v++; $tra_id = $row->tra_id; $obtenerColumnCueId = $tramitecc->dbselectByField("tra_id", $tra_id); $cue_id = $obtenerColumnCueId[0]->cue_id; } } if ($v == 0) { $this->tramite->setTra_orden(1); $this->tramite->setTra_codigo(1); $this->tramite->setTra_descripcion("GRUPO DOCUMENTAL COMPUESTA"); $this->tramite->setTra_fecha_crea(date("Y-m-d")); $this->tramite->setTra_usuario_crea($_SESSION['USU_ID']); $this->tramite->setTra_estado(1); $tra_id = $this->tramite->insert(); $seriet->setSer_id($id_serie); $seriet->setTra_id($tra_id); $seriet->setSts_fecha_crea(date("Y-m-d")); $seriet->setSts_fecha_reg(date("Y-m-d")); $seriet->setSts_usuario_crea($_SESSION['USU_ID']); $seriet->setSts_usu_reg($_SESSION['USU_ID']); $seriet->setVer_id('0'); $seriet->setSts_estado(1); $seriet->insert(); $this->tramite = new tramite(); $tra_codigo = $this->tramite->obtenerCodigoTramite($tra_id); $tcuerpos = new tab_cuerpos(); $tcuerpos->setCue_id(''); $tcuerpos->setCue_orden(1); $tcuerpos->setCue_codigo(1); $tcuerpos->setCue_descripcion("UNIDAD DOCUMENTAL SIMPLE"); $tcuerpos->setCue_fecha_crea(date("Y-m-d")); $tcuerpos->setCue_usuario_crea($_SESSION['USU_ID']); $tcuerpos->setCue_estado(1); $cue_id = $tcuerpos->insert(); // Last code //$tramitecc = new tab_tramitecuerpos(); $tramitecc->setCue_id($cue_id); $tramitecc->setTra_id($tra_id); $tramitecc->setTrc_estado(1); $tramitecc->insert(); } //insert $this->exparchivo->setTra_id($tra_id); $this->exparchivo->setCue_id($cue_id); $this->exparchivo->setExa_condicion('1'); $this->exparchivo->setExa_estado(1); $this->exparchivo->insert(); //Fin del archivo } $i++; $ct++; } } else { $msg = "<font color='red'>FORMATO GNT - SCV NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } $msg .= "<b style='color:green'>SE GUARDO CORRECTAMENTE</b><br>"; $msg .= "<a href='" . PATH_DOMAIN . "/nuevoExpediente/index/'>Ver registro</a>"; unlink($Dir); $this->index($msg); exit; } else { $msg = "<font color='red'>FORMATO GNT - SCV NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); } } else { if ($tipoformato == 3) { //GNT-SSA $cantidaddoc = $highestRow - 38; $fondo = $objPHPExcel->getActiveSheet()->getCell("E8")->getValue(); $subfondo = $objPHPExcel->getActiveSheet()->getCell("E9")->getValue(); $seccion = $objPHPExcel->getActiveSheet()->getCell("E10")->getValue(); $subseccion = $objPHPExcel->getActiveSheet()->getCell("E11")->getValue(); $serie = $objPHPExcel->getActiveSheet()->getCell("E13")->getValue(); $tituloexpediente = $objPHPExcel->getActiveSheet()->getCell("E14")->getValue(); $fechasExtremas = $objPHPExcel->getActiveSheet()->getCell("P13")->getValue(); //if(trim($subseccion)=="SUBGERENCIA DE CONSERVACION VIAL"){ // $subseccion="PROYECTOS DE CONSERVACION VIAL"; //} $tituloserie = explode("\n", $serie); $cantidaserie = count($tituloserie); if ($cantidaserie > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea del Título de la Serie</font><br>"; unlink($Dir); $this->index($msg); exit; } $tituloexp = explode("\n", $tituloexpediente); $cantidaexpediente = count($tituloexp); if ($cantidaexpediente > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea en Título de Expediente </font><br>"; unlink($Dir); $this->index($msg); exit; } $ml = $objPHPExcel->getActiveSheet()->getCell("D16")->getValue(); if ($highestColumn != "Q") { $msg = "<font color='red'>FORMATO GNT - SSA NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } $tab_fondo = new Tab_fondo(); $tab_unidad = new Tab_unidad(); $tab_series = new Tab_series(); //obtener fondo y subfondo $sql = "select* from tab_fondo where fon_descripcion LIKE '%{$fondo}%'"; $sql2 = "select* from tab_fondo where fon_descripcion LIKE '%{$subfondo}%'"; $resultado = $tab_fondo->dbSelectBySQL($sql); $resultado2 = $tab_fondo->dbSelectBySQL($sql2); $id_fondo = $resultado[0]->fon_id; $id_subfondo = $resultado2[0]->fon_id; $ubicacion = $resultado2[0]->fon_codigo; switch ($ubicacion) { case "ON": $ubicacion = "LA PAZ"; break; case "LP": $ubicacion = "LA PAZ"; break; case "SC": $ubicacion = "SANTA CRUZ"; break; case "PT": $ubicacion = "POTOSI"; break; case "BN": $ubicacion = "BENI"; break; case "PN": $ubicacion = "PANDO"; break; case "CB": $ubicacion = "COCHABAMBA"; break; case "OR": $ubicacion = "ORURO"; break; case "CH": $ubicacion = "CHUQUISACA"; break; case "TJ": $ubicacion = "TARIJA"; break; } if ($seccion == "DIRECCION GENERAL TECNICA") { if ($id_subfondo == 3) { $seccion = "TECNICA-OPERATIVA"; } else { $seccion = "AREA TECNICA"; } } //obtener el fon_id $subseccion = trim($subseccion); if ($subseccion == "") { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$seccion}%'"; } else { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$subseccion}%'"; } $resultado3 = $tab_unidad->dbSelectBySQL($sql3); foreach ($resultado3 as $rowseccion) { $id_seccion = $rowseccion->uni_id; } //obtengo la serie $sql4 = "SELECT\r\ntab_series.ser_categoria,\r\ntab_series.ser_id\r\nFROM\r\ntab_fondo\r\nINNER JOIN tab_unidad ON tab_fondo.fon_id = tab_unidad.fon_id\r\nINNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\nWHERE\r\ntab_fondo.fon_id = {$id_subfondo} AND tab_series.ser_categoria LIKE '%{$serie}%'"; $resultado4 = $tab_series->dbSelectBySQL($sql4); foreach ($resultado4 as $rowserie) { $id_serie = $rowserie->ser_id; } if ($id_serie == "") { $msg = "<font color='red'>Error, No existe la Serie Asignada</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_subfondo == "") { $msg = "<font color='red'>Error, No existe el Subfondo</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_seccion == "") { $msg = "<font color='red'>Error, No existe la Sección</font><br>"; unlink($Dir); $this->index($msg); exit; } } } if ($highestColumn == "Q") { if ($ml == "ML") { $i = 1; $ct = 18; $t = 0; $expsadg = new Tab_expisadg(); $resulall = $expsadg->dbselectByField("exp_titulo", strtoupper($tituloexpediente)); foreach ($resulall as $list) { $t++; } $fechafinal = ''; $fechainicial = ''; $exp_fechas = explode("-", $fechasExtremas); if (!empty($exp_fechas[1])) { $fechafinal = trim($exp_fechas[1]); } if (!empty($exp_fechas[0])) { $fechainicial = trim($exp_fechas[0]); } if ($t > 0) { $msg = "<font color='red'>Error! existe otro nombre duplicado</font>"; unlink($Dir); $this->index($msg); exit; } $expediente = new expediente(); $hoy = date("Y-m-d"); $this->expediente = new tab_expediente(); // $this->expediente->setRequest2Object($_REQUEST); $this->expediente->setExp_id(''); $this->expediente->setSer_id($id_serie); // Generation code $this->expediente->setExp_codigo($expediente->generaCodigo($id_serie)); $this->expediente->setExp_lugar($ubicacion); $this->expediente->setSof_id(1); $this->expediente->setExp_ori(0); $this->expediente->setExp_cop(0); $this->expediente->setExp_fot(0); $this->expediente->setExp_obs(''); $this->expediente->setExp_corr('AUTO'); $this->expediente->setExp_estado(1); $this->expediente->setExp_migrarexcel(1); $exp_id = $this->expediente->insert2(); // Update count // if ($_REQUEST['ser_corr'] == 'AUTO') { // // Auto // $tseries = new tab_series(); // $row2 = $tseries->dbselectByField("ser_id", $_REQUEST['ser_id']); // $row2 = $row2[0]; // $tseries->setSer_id($_REQUEST['ser_id']); // $ser_exp = $row2->ser_exp + 1; // $tseries->setSer_exp($ser_exp); // $tseries->update(); // } else { // // Manual // $tseries = new tab_series(); // $tseries->setSer_id($_REQUEST['ser_id']); // $tseries->setSer_exp($_REQUEST['exp_codigo']); // $tseries->update(); // } //$this->expisadg->setTrm_id(1); // $expisadg = new tab_expisadg(); // $expisadg->setExp_id($exp_id); // $expisadg->setExp_titulo($expediente); // $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_fecha_exi(date('Y-m-d')); // $expisadg->setExp_fecha_exf(date('Y-m-d')); // $expisadg->setExp_anioi($fechainicial); // $expisadg->setExp_aniof($fechafinal); // $expisadg->setIdi_id(1); // $expisadg->setExp_estado(1); // $eig_id = $expisadg->insert(); $fechahoy = date('Y-m-d'); $expisadg = new tab_expisadg(); $expisadg->setExp_id($exp_id); $expisadg->setExp_titulo($tituloexpediente); $expisadg->setExp_fecha_exi($fechahoy); // $expisadg->setExp_mesi(''); $expisadg->setExp_anioi($fechainicial); $expisadg->setExp_fecha_exf($fechahoy); // $expisadg->setExp_mesf(''); $expisadg->setExp_aniof($fechafinal); $expisadg->setExp_nivdes('EXPEDIENTE'); // $expisadg->setExp_volsop(''); $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_hisins(''); // $expisadg->setExp_hisarc(''); $expisadg->setExp_foring('TRANSFERENCIA'); // $expisadg->setExp_alccon(''); // $expisadg->setExp_vaseel(''); // $expisadg->setExp_nueing(''); $expisadg->setExp_org('LOS DOCUMENTOS DEL PROYECTO FUERON IDENTIFICADOS, CLASIFICADOS Y ORDENADOS EN LAS CAJAS DE ACUERDO AL CHECK LIST DE LA SERIE A LA QUE CORRESPONDEN.'); $expisadg->setExp_conacc('EL ACCESO ESTA SUJETO A LO QUE ESTABLECE LA CONSTITUCION POLITICA DEL ESTADO Y EL ARTICULO 18 DE LA LEY 2341 SOBRE PROCESOS ADMINISTRATIVOS.'); // $expisadg->setExp_conrep(''); $expisadg->setIdi_id(1); $expisadg->setExp_carfis('BUENO'); $expisadg->setExp_regnor('ISAD-G, ISAAR(CPF), RCAA'); $expisadg->setExp_fecdes(date('Y-m-d')); $expisadg->setExp_estado(1); $eig_id = $expisadg->insert(); // Save expfondo data $texf = new Tab_expfondo(); $texf->setExp_id($exp_id); $usuario = new usuario(); $fon_id = $usuario->getFon_id($_SESSION['USU_ID']); $nomUsuario = $usuario->obtenerNombre($_SESSION['USU_ID']); $texf->setExf_fecha_exi($fechahoy); $texf->setFon_id($fon_id); $texf->setExf_estado('1'); $texf->insert(); // Save expusuario data $this->expusuario = new expusuario(); $this->expusuario->saveExp($exp_id, $_SESSION['USU_ID']); // // Save expcontenedor data // $con = new expcontenedor(); // $con->saveExpCont($_REQUEST['con_id'], $_REQUEST['suc_id'], $exp_id); // // Save proyecto list data (tramos) // if (isset($_REQUEST['lista_tramo'])) { // $proyectos = $_REQUEST['lista_tramo']; // foreach ($proyectos as $proyecto) { // $exp = new tab_expproyecto(); // $exp->setExp_id($exp_id); // $exp->setPry_id($proyecto); // $exp->setEpp_estado(1); // $exp->insert(); // } // } // Save data dynamic $c = 0; $caj = ""; $cnt = 0; //insert usuario serie $tab_usu_serie = new Tab_usu_serie(); $sqlususerie = "select* from tab_usu_serie\r\n where usu_id='" . $_SESSION['USU_ID'] . "'\r\n and ser_id='" . $id_serie . "'\r\n and use_estado=1"; $comprobar_usu_serie = $tab_usu_serie->dbSelectBySQL($sqlususerie); $cnt = count($comprobar_usu_serie); if ($cnt == 0) { $tab_usu_serie->setUse_id(''); $tab_usu_serie->setUsu_id($_SESSION['USU_ID']); $tab_usu_serie->setSer_id($id_serie); $tab_usu_serie->setUse_estado(1); $tab_usu_serie->insert(); } while ($i <= $cantidaddoc) { $caja = $objPHPExcel->getActiveSheet()->getCell("A" . $ct)->getValue(); $filnroejem = $objPHPExcel->getActiveSheet()->getCell("C" . $ct)->getValue(); $correlativo = $objPHPExcel->getActiveSheet()->getCell("E" . $ct)->getValue(); $titledoc = $objPHPExcel->getActiveSheet()->getCell("F" . $ct)->getValue(); $subtitledoc = $objPHPExcel->getActiveSheet()->getCell("G" . $ct)->getValue(); $productor = $objPHPExcel->getActiveSheet()->getCell("H" . $ct)->getValue(); $contrato = $objPHPExcel->getActiveSheet()->getCell("I" . $ct)->getValue(); $fecha = trim($objPHPExcel->getActiveSheet()->getCell("J" . $ct)->getValue()); $tomovol = $objPHPExcel->getActiveSheet()->getCell("K" . $ct)->getValue(); $sopfis = $objPHPExcel->getActiveSheet()->getCell("L" . $ct)->getValue(); $sala = $objPHPExcel->getActiveSheet()->getCell("M" . $ct)->getValue(); $estante = $objPHPExcel->getActiveSheet()->getCell("N" . $ct)->getValue(); $cuerpo = $objPHPExcel->getActiveSheet()->getCell("O" . $ct)->getValue(); $balda = $objPHPExcel->getActiveSheet()->getCell("P" . $ct)->getValue(); $obs = $objPHPExcel->getActiveSheet()->getCell("Q" . $ct)->getValue(); //todavia en trabajo if ($titledoc != "") { if ($fecha != "s/f") { $extfe = explode("\n", $fecha); $cantidadfecha = count($extfe); if ($cantidadfecha > 1) { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = $extfe[1]; } else { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = ""; if ($fechadocAnioInicial > 30000) { $fe = date("m-y", (int) $fechadocAnioInicial); $extraer = explode("-", $fe); $fechadocAnioInicial = $extraer[1]; $fechadocMesInicial = $extraer[0]; } } } if ($caja == "") { } else { $extraercaj = explode(" ", trim($caja)); $caj = $extraercaj[1]; } $id_exp = $exp_id; $this->archivo = new tab_archivo(); $this->archivo->setFil_id(''); // Generation code max fil_nro $maxFil = new Tab_archivo(); $sql2 = "SELECT\r\n MAX(tab_archivo.fil_nro) AS maxnro\r\n FROM\r\n tab_expediente\r\n INNER JOIN tab_exparchivo ON tab_exparchivo.exp_id = tab_expediente.exp_id\r\n INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n WHERE\r\n tab_expediente.exp_id = {$id_exp} AND\r\n tab_expediente.exp_estado = 1"; $cant_max = $maxFil->dbSelectBySQL($sql2); foreach ($cant_max as $lismax) { $max3 = $lismax->maxnro; } if ($max3 == "") { $max3 = 0; } $max3 = $max3 + 1; $this->archivo->setFil_nro($max3); $this->archivo->setFil_titulo(strtoupper($titledoc)); $this->archivo->setFil_codigo(2); $this->archivo->setFil_subtitulo(strtoupper($subtitledoc)); $this->archivo->setFil_fecha($fechahoy); $this->archivo->setIdi_id(1); $this->archivo->setFil_proc($fondo); $this->archivo->setFil_firma($nomUsuario); $this->archivo->setFil_cargo(''); $this->archivo->setFil_alccon(''); $sqlsopfis = new tab_sopfisico(); if ($sopfis != "AP" || $sopfis != "EM" || $sopfis != "LG" || $sopfis != "AN" || $sopfis != "MM" || $sopfis != "CP") { $sopfis = "LG"; } $result = $sqlsopfis->dbselectByField("sof_codigo", $sopfis); $this->archivo->setSof_id($result[0]->sof_id); $this->archivo->setFil_nrofoj(''); $this->archivo->setFil_tomovol($tomovol); $this->archivo->setFil_nroejem($filnroejem); $this->archivo->setFil_nrocaj($caj); $this->archivo->setFil_nropaq(''); $this->archivo->setFil_sala(strtoupper($sala)); $this->archivo->setFil_estante(strtoupper($estante)); $this->archivo->setFil_cuerpo(strtoupper($cuerpo)); $this->archivo->setFil_balda(strtoupper($balda)); $this->archivo->setFil_tipoarch('TEC'); $this->archivo->setFil_mrb('BUENO'); $this->archivo->setFil_mes($fechadocMesInicial); $this->archivo->setFil_anio($fechadocAnioInicial); $this->archivo->setFil_cantpaq(''); $this->archivo->setFil_cantcaj(''); $this->archivo->setFil_confidencialidad(1); $this->archivo->setFil_obs(strtoupper($obs)); $this->archivo->setFil_estado('1'); $fil_id = $this->archivo->insert(); $this->archivo2 = new tab_archivo(); $this->archivo2->setFil_id($fil_id); $this->archivo2->setFil_codigo($fil_id); $this->archivo2->setFil_estado('1'); $this->archivo2->update(); $this->exparchivo = new tab_exparchivo(); $this->exparchivo->setExa_id(''); $this->exparchivo->setFil_id($fil_id); $this->exparchivo->setExp_id($exp_id); $archivo_digital = new tab_archivo_digital(); $archivo_digital->setFid_id(''); $archivo_digital->setFil_id($fil_id); $archivo_digital->insert(); $seriet = new Tab_serietramite(); $this->series = new series(); $ser_codigo = $this->series->obtenerCodigoSerie($id_serie); //insert grupos documentales y tipos documentales $this->tramite = new tab_tramite(); $tramitecc = new tab_tramitecuerpos(); $sqltramite = "SELECT\r\n tab_tramite.tra_descripcion,\r\n tab_tramite.tra_id\r\n FROM\r\n tab_series\r\n INNER JOIN tab_serietramite ON tab_series.ser_id = tab_serietramite.ser_id\r\n INNER JOIN tab_tramite ON tab_tramite.tra_id = tab_serietramite.tra_id\r\n WHERE\r\n tab_series.ser_id = {$id_serie}"; $rows = $seriet->dbSelectBySQL($sqltramite); $v = 0; foreach ($rows as $row) { if ($row->tra_descripcion == 'GRUPO DOCUMENTAL COMPUESTA') { $v++; $tra_id = $row->tra_id; $obtenerColumnCueId = $tramitecc->dbselectByField("tra_id", $tra_id); $cue_id = $obtenerColumnCueId[0]->cue_id; } } if ($v == 0) { $this->tramite->setTra_orden(1); $this->tramite->setTra_codigo(1); $this->tramite->setTra_descripcion("GRUPO DOCUMENTAL COMPUESTA"); $this->tramite->setTra_fecha_crea(date("Y-m-d")); $this->tramite->setTra_usuario_crea($_SESSION['USU_ID']); $this->tramite->setTra_estado(1); $tra_id = $this->tramite->insert(); $seriet->setSer_id($id_serie); $seriet->setTra_id($tra_id); $seriet->setSts_fecha_crea(date("Y-m-d")); $seriet->setSts_fecha_reg(date("Y-m-d")); $seriet->setSts_usuario_crea($_SESSION['USU_ID']); $seriet->setSts_usu_reg($_SESSION['USU_ID']); $seriet->setVer_id('0'); $seriet->setSts_estado(1); $seriet->insert(); $this->tramite = new tramite(); $tra_codigo = $this->tramite->obtenerCodigoTramite($tra_id); $tcuerpos = new tab_cuerpos(); $tcuerpos->setCue_id(''); $tcuerpos->setCue_orden(1); $tcuerpos->setCue_codigo(1); $tcuerpos->setCue_descripcion("UNIDAD DOCUMENTAL SIMPLE"); $tcuerpos->setCue_fecha_crea(date("Y-m-d")); $tcuerpos->setCue_usuario_crea($_SESSION['USU_ID']); $tcuerpos->setCue_estado(1); $cue_id = $tcuerpos->insert(); // Last code //$tramitecc = new tab_tramitecuerpos(); $tramitecc->setCue_id($cue_id); $tramitecc->setTra_id($tra_id); $tramitecc->setTrc_estado(1); $tramitecc->insert(); } //insert $this->exparchivo->setTra_id($tra_id); $this->exparchivo->setCue_id($cue_id); $this->exparchivo->setExa_condicion('1'); $this->exparchivo->setExa_estado(1); $this->exparchivo->insert(); //Fin del archivo } $i++; $ct++; } } else { $msg = "<font color='red'>FORMATO GNT - SSA NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } $msg .= "<b style='color:green'>SE GUARDO CORRECTAMENTE</b><br>"; $msg .= "<a href='" . PATH_DOMAIN . "/nuevoExpediente/index/'>Ver registro</a>"; unlink($Dir); $this->index($msg); exit; } else { $msg = "<font color='red'>FORMATO GNT - SSA NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); } //end } else { if ($tipoformato == 4) { //CONTRATACIONES $cantidaddoc = $highestRow - 38; $fondo = $objPHPExcel->getActiveSheet()->getCell("E8")->getValue(); $subfondo = $objPHPExcel->getActiveSheet()->getCell("E9")->getValue(); $seccion = $objPHPExcel->getActiveSheet()->getCell("E10")->getValue(); $subseccion = $objPHPExcel->getActiveSheet()->getCell("E11")->getValue(); $serie = $objPHPExcel->getActiveSheet()->getCell("E13")->getValue(); $tituloexpediente = $objPHPExcel->getActiveSheet()->getCell("E14")->getValue(); $fechasExtremas = $objPHPExcel->getActiveSheet()->getCell("U13")->getValue(); $ml = $objPHPExcel->getActiveSheet()->getCell("D16")->getValue(); $objHoja = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); $objWorksheet = $objPHPExcel->getActiveSheet(); $tituloserie = explode("\n", $serie); $cantidaserie = count($tituloserie); if ($cantidaserie > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea del Título de la Serie</font><br>"; unlink($Dir); $this->index($msg); exit; } $tituloexp = explode("\n", $tituloexpediente); $cantidaexpediente = count($tituloexp); if ($cantidaexpediente > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea en Título de Expediente </font><br>"; unlink($Dir); $this->index($msg); exit; } if ($highestColumn != "W") { $msg = "<font color='red'>FORMATO CONTRATACIONES NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } //$msg= $cantidaddoc; exit(); //$msg= $fondo."<br>"; //$msg= $subfondo."<br>"; //$msg= $seccion."<br>"; //$msg= $subseccion."<br>"; //$msg= $serie."<br>"; //$msg= $tituloexpediente."<br>"; //$msg= $fechasExtremas."<br>"; //$msg= $ml."<br>"; //$msg= $nrColumns; //exit(); //$l=0; //$msg= '<table border="1">' . "\n"; //foreach ($objWorksheet->getRowIterator() as $row) { //$msg= '<tr>' . "\n"; // $l++; //$cellIterator = $row->getCellIterator(); //$cellIterator->setIterateOnlyExistingCells(false); // This loops all cells, //foreach ($cellIterator as $cell) { //$msg= '<td>' . htmlentities($cell->getValue(), ENT_IGNORE, 'utf-8') . '</td>' . "\n"; //} // //$msg= '</tr>' . "\n"; // //} //$msg= '</table>' . "\n"; //$msg= "la cantidad e:".$cantidaddoc; //exit(); if (trim($subseccion) == "SUBGERENCIA DE CONSERVACION VIAL") { $subseccion = "PROYECTOS DE CONSERVACION VIAL"; } $tab_fondo = new Tab_fondo(); $tab_unidad = new Tab_unidad(); $tab_series = new Tab_series(); //obtener fondo y subfondo $sql = "select* from tab_fondo where fon_descripcion LIKE '%{$fondo}%'"; $sql2 = "select* from tab_fondo where fon_descripcion LIKE '%{$subfondo}%'"; $resultado = $tab_fondo->dbSelectBySQL($sql); $resultado2 = $tab_fondo->dbSelectBySQL($sql2); $id_fondo = $resultado[0]->fon_id; $id_subfondo = $resultado2[0]->fon_id; $ubicacion = $resultado2[0]->fon_codigo; switch ($ubicacion) { case "ON": $ubicacion = "LA PAZ"; break; case "LP": $ubicacion = "LA PAZ"; break; case "SC": $ubicacion = "SANTA CRUZ"; break; case "PT": $ubicacion = "POTOSI"; break; case "BN": $ubicacion = "BENI"; break; case "PN": $ubicacion = "PANDO"; break; case "CB": $ubicacion = "COCHABAMBA"; break; case "OR": $ubicacion = "ORURO"; break; case "CH": $ubicacion = "CHUQUISACA"; break; case "TJ": $ubicacion = "TARIJA"; break; } if ($seccion == "DIRECCION GENERAL TECNICA") { if ($id_subfondo == 3) { $seccion = "TECNICA-OPERATIVA"; } else { $seccion = "AREA TECNICA"; } } //obtener el fon_id $subseccion = trim($subseccion); if ($subseccion == "") { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$seccion}%'"; } else { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$subseccion}%'"; } $resultado3 = $tab_unidad->dbSelectBySQL($sql3); foreach ($resultado3 as $rowseccion) { $id_seccion = $rowseccion->uni_id; } //obtengo la serie $sql4 = "SELECT\r\ntab_series.ser_categoria,\r\ntab_series.ser_id\r\nFROM\r\ntab_fondo\r\nINNER JOIN tab_unidad ON tab_fondo.fon_id = tab_unidad.fon_id\r\nINNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\nWHERE\r\ntab_fondo.fon_id = {$id_subfondo} AND tab_series.ser_categoria LIKE '%{$serie}%'"; $resultado4 = $tab_series->dbSelectBySQL($sql4); foreach ($resultado4 as $rowserie) { $id_serie = $rowserie->ser_id; } //$ml=$objPHPExcel->getActiveSheet()->getCell("D16")->getValue(); if ($id_serie == "") { $msg = "<font color='red'>Error, No existe la Serie Asignada</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_subfondo == "") { $msg = "<font color='red'>Error, No existe el Subfondo</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_seccion == "") { $msg = "<font color='red'>Error, No existe la Sección</font><br>"; unlink($Dir); $this->index($msg); exit; } } } //$msg= $nrColumns; //exit(); if ($highestColumn == "W") { if ($ml == "ML") { $i = 1; $ct = 19; $t = 0; $expsadg = new Tab_expisadg(); $resulall = $expsadg->dbselectByField("exp_titulo", strtoupper($tituloexpediente)); foreach ($resulall as $list) { $t++; } $fechafinal = ''; $fechainicial = ''; $exp_fechas = explode("-", $fechasExtremas); if (!empty($exp_fechas[1])) { $fechafinal = trim($exp_fechas[1]); } if (!empty($exp_fechas[0])) { $fechainicial = trim($exp_fechas[0]); } if ($t > 0) { $msg = "<font color='red'>Error! existe otro nombre duplicado</font>"; unlink($Dir); $this->index($msg); exit; } $expediente = new expediente(); $hoy = date("Y-m-d"); $this->expediente = new tab_expediente(); // $this->expediente->setRequest2Object($_REQUEST); $this->expediente->setExp_id(''); $this->expediente->setSer_id($id_serie); // Generation code $this->expediente->setExp_codigo($expediente->generaCodigo($id_serie)); $this->expediente->setExp_lugar($ubicacion); $this->expediente->setSof_id(1); $this->expediente->setExp_ori(0); $this->expediente->setExp_cop(0); $this->expediente->setExp_fot(0); $this->expediente->setExp_obs(''); $this->expediente->setExp_corr('AUTO'); $this->expediente->setExp_estado(1); $this->expediente->setExp_migrarexcel(1); $exp_id = $this->expediente->insert2(); // Update count // if ($_REQUEST['ser_corr'] == 'AUTO') { // // Auto // $tseries = new tab_series(); // $row2 = $tseries->dbselectByField("ser_id", $_REQUEST['ser_id']); // $row2 = $row2[0]; // $tseries->setSer_id($_REQUEST['ser_id']); // $ser_exp = $row2->ser_exp + 1; // $tseries->setSer_exp($ser_exp); // $tseries->update(); // } else { // // Manual // $tseries = new tab_series(); // $tseries->setSer_id($_REQUEST['ser_id']); // $tseries->setSer_exp($_REQUEST['exp_codigo']); // $tseries->update(); // } //$this->expisadg->setTrm_id(1); // $expisadg = new tab_expisadg(); // $expisadg->setExp_id($exp_id); // $expisadg->setExp_titulo($expediente); // $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_fecha_exi(date('Y-m-d')); // $expisadg->setExp_fecha_exf(date('Y-m-d')); // $expisadg->setExp_anioi($fechainicial); // $expisadg->setExp_aniof($fechafinal); // $expisadg->setIdi_id(1); // $expisadg->setExp_estado(1); // $eig_id = $expisadg->insert(); $fechahoy = date('Y-m-d'); $expisadg = new tab_expisadg(); $expisadg->setExp_id($exp_id); $expisadg->setExp_titulo($tituloexpediente); $expisadg->setExp_fecha_exi($fechahoy); // $expisadg->setExp_mesi(''); $expisadg->setExp_anioi($fechainicial); $expisadg->setExp_fecha_exf($fechahoy); // $expisadg->setExp_mesf(''); $expisadg->setExp_aniof($fechafinal); $expisadg->setExp_nivdes('EXPEDIENTE'); // $expisadg->setExp_volsop(''); $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_hisins(''); // $expisadg->setExp_hisarc(''); $expisadg->setExp_foring('TRANSFERENCIA'); // $expisadg->setExp_alccon(''); // $expisadg->setExp_vaseel(''); // $expisadg->setExp_nueing(''); $expisadg->setExp_org('LOS DOCUMENTOS DEL PROYECTO FUERON IDENTIFICADOS, CLASIFICADOS Y ORDENADOS EN LAS CAJAS DE ACUERDO AL CHECK LIST DE LA SERIE A LA QUE CORRESPONDEN.'); $expisadg->setExp_conacc('EL ACCESO ESTA SUJETO A LO QUE ESTABLECE LA CONSTITUCION POLITICA DEL ESTADO Y EL ARTICULO 18 DE LA LEY 2341 SOBRE PROCESOS ADMINISTRATIVOS.'); // $expisadg->setExp_conrep(''); $expisadg->setIdi_id(1); $expisadg->setExp_carfis('BUENO'); // $expisadg->setExp_insdes(''); // $expisadg->setExp_exloor(''); // $expisadg->setExp_exloco(''); // $expisadg->setExp_underel(''); // $expisadg->setExp_notpub(''); // $expisadg->setExp_notas(''); // $expisadg->setExp_notarc(''); $expisadg->setExp_regnor('ISAD-G, ISAAR(CPF), RCAA'); $expisadg->setExp_fecdes(date('Y-m-d')); $expisadg->setExp_estado(1); $eig_id = $expisadg->insert(); // Save expfondo data $texf = new Tab_expfondo(); $texf->setExp_id($exp_id); $usuario = new usuario(); $fon_id = $usuario->getFon_id($_SESSION['USU_ID']); $nomUsuario = $usuario->obtenerNombre($_SESSION['USU_ID']); $texf->setExf_fecha_exi($fechahoy); $texf->setFon_id($fon_id); $texf->setExf_estado('1'); $texf->insert(); // Save expusuario data $this->expusuario = new expusuario(); $this->expusuario->saveExp($exp_id, $_SESSION['USU_ID']); // // Save expcontenedor data // $con = new expcontenedor(); // $con->saveExpCont($_REQUEST['con_id'], $_REQUEST['suc_id'], $exp_id); // // Save proyecto list data (tramos) // if (isset($_REQUEST['lista_tramo'])) { // $proyectos = $_REQUEST['lista_tramo']; // foreach ($proyectos as $proyecto) { // $exp = new tab_expproyecto(); // $exp->setExp_id($exp_id); // $exp->setPry_id($proyecto); // $exp->setEpp_estado(1); // $exp->insert(); // } // } // Save data dynamic $c = 0; $caj = ""; $cnt = 0; //insert usuario serie $tab_usu_serie = new Tab_usu_serie(); $sqlususerie = "select* from tab_usu_serie\r\n where usu_id='" . $_SESSION['USU_ID'] . "'\r\n and ser_id='" . $id_serie . "'\r\n and use_estado=1"; $comprobar_usu_serie = $tab_usu_serie->dbSelectBySQL($sqlususerie); $cnt = count($comprobar_usu_serie); if ($cnt == 0) { $tab_usu_serie->setUse_id(''); $tab_usu_serie->setUsu_id($_SESSION['USU_ID']); $tab_usu_serie->setSer_id($id_serie); $tab_usu_serie->setUse_estado(1); $tab_usu_serie->insert(); } while ($i <= $cantidaddoc) { $caja = $objPHPExcel->getActiveSheet()->getCell("A" . $ct)->getValue(); $filnroejem = $objPHPExcel->getActiveSheet()->getCell("C" . $ct)->getValue(); $correlativo = $objPHPExcel->getActiveSheet()->getCell("E" . $ct)->getValue(); $subtitledoc = $objPHPExcel->getActiveSheet()->getCell("F" . $ct)->getValue(); $subtitledoc2 = $objPHPExcel->getActiveSheet()->getCell("I" . $ct)->getValue(); $unidadsolicitante = $objPHPExcel->getActiveSheet()->getCell("J" . $ct)->getValue(); $titledoc = $objPHPExcel->getActiveSheet()->getCell("H" . $ct)->getValue(); $financiamiento = $objPHPExcel->getActiveSheet()->getCell("L" . $ct)->getValue(); $contrato = $objPHPExcel->getActiveSheet()->getCell("N" . $ct)->getValue(); $nrofojas = $objPHPExcel->getActiveSheet()->getCell("Q" . $ct)->getValue(); $fecha = trim($objPHPExcel->getActiveSheet()->getCell("O" . $ct)->getValue()); $tomovol = $objPHPExcel->getActiveSheet()->getCell("P" . $ct)->getValue(); $sopfis = $objPHPExcel->getActiveSheet()->getCell("R" . $ct)->getValue(); $sala = $objPHPExcel->getActiveSheet()->getCell("S" . $ct)->getValue(); $estante = $objPHPExcel->getActiveSheet()->getCell("T" . $ct)->getValue(); $cuerpo = $objPHPExcel->getActiveSheet()->getCell("U" . $ct)->getValue(); $balda = $objPHPExcel->getActiveSheet()->getCell("V" . $ct)->getValue(); $obs = $objPHPExcel->getActiveSheet()->getCell("W" . $ct)->getValue(); //todavia en trabajo $subtitledoc = $subtitledoc . " " . $subtitledoc2; if ($titledoc != "") { //$msg= $caja."<br>"; //$msg= $filnroejem."<br>"; //$msg= $correlativo."<br>"; //$msg= $titledoc."<br>"; //$msg= $subtitledoc."<br>"; ////$msg= $productor."<br>"; //$msg= $contrato."<br>"; //$msg= $fecha."<br>"; //$msg= $tomovol."<br>"; //$msg= $sopfis."<br>"; //$msg= $sala."<br>"; //$msg= $estante."<br>"; //$msg= $cuerpo."<br>"; //$msg= $balda."<br>"; //$msg= $obs."<br>"; //exit(); if ($fecha != "s/f") { $extfe = explode("\n", $fecha); $cantidadfecha = count($extfe); if ($cantidadfecha > 1) { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = $extfe[1]; } else { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = ""; if ($fechadocAnioInicial > 30000) { $fe = date("m-y", (int) $fechadocAnioInicial); $extraer = explode("-", $fe); $fechadocAnioInicial = $extraer[1]; $fechadocMesInicial = $extraer[0]; } } } //exit(); if ($caja == "") { } else { $extraercaj = explode(" ", trim($caja)); $caj = $extraercaj[1]; } $id_exp = $exp_id; $this->archivo = new tab_archivo(); $this->archivo->setFil_id(''); // Generation code max fil_nro $maxFil = new Tab_archivo(); $sql2 = "SELECT\r\n MAX(tab_archivo.fil_nro) AS maxnro\r\n FROM\r\n tab_expediente\r\n INNER JOIN tab_exparchivo ON tab_exparchivo.exp_id = tab_expediente.exp_id\r\n INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n WHERE\r\n tab_expediente.exp_id = {$id_exp} AND\r\n tab_expediente.exp_estado = 1"; $cant_max = $maxFil->dbSelectBySQL($sql2); foreach ($cant_max as $lismax) { $max3 = $lismax->maxnro; } if ($max3 == "") { $max3 = 0; } $max3 = $max3 + 1; $this->archivo->setFil_nro($max3); $this->archivo->setFil_codigo(2); $this->archivo->setFil_titulo(strtoupper($titledoc)); $this->archivo->setFil_subtitulo(strtoupper($subtitledoc)); $this->archivo->setFil_fecha($fechahoy); $this->archivo->setIdi_id(1); $this->archivo->setFil_proc($fondo); $this->archivo->setFil_firma($nomUsuario); $this->archivo->setFil_cargo($unidadsolicitante); $this->archivo->setFil_alccon($financiamiento); $sqlsopfis = new tab_sopfisico(); if ($sopfis != "AP" || $sopfis != "EM" || $sopfis != "LG" || $sopfis != "AN" || $sopfis != "MM" || $sopfis != "CP") { $sopfis = "LG"; } $result = $sqlsopfis->dbselectByField("sof_codigo", $sopfis); $this->archivo->setSof_id($result[0]->sof_id); $this->archivo->setFil_nrofoj($nrofojas); $this->archivo->setFil_tomovol($tomovol); $this->archivo->setFil_nroejem($filnroejem); $this->archivo->setFil_nrocaj($caj); $this->archivo->setFil_nropaq(''); $this->archivo->setFil_sala(strtoupper($sala)); $this->archivo->setFil_estante(strtoupper($estante)); $this->archivo->setFil_cuerpo(strtoupper($cuerpo)); $this->archivo->setFil_balda(strtoupper($balda)); $this->archivo->setFil_tipoarch('TEC'); $this->archivo->setFil_mrb('BUENO'); $this->archivo->setFil_mes($fechadocMesInicial); $this->archivo->setFil_anio($fechadocAnioInicial); $this->archivo->setFil_cantpaq(''); $this->archivo->setFil_cantcaj(''); $this->archivo->setFil_confidencialidad(1); $this->archivo->setFil_obs(strtoupper($obs)); $this->archivo->setFil_estado('1'); $fil_id = $this->archivo->insert(); $this->archivo2 = new tab_archivo(); $this->archivo2->setFil_id($fil_id); $this->archivo2->setFil_codigo($fil_id); $this->archivo2->setFil_estado('1'); $this->archivo2->update(); $this->exparchivo = new tab_exparchivo(); $this->exparchivo->setExa_id(''); $this->exparchivo->setFil_id($fil_id); $this->exparchivo->setExp_id($exp_id); $archivo_digital = new tab_archivo_digital(); $archivo_digital->setFid_id(''); $archivo_digital->setFil_id($fil_id); $archivo_digital->insert(); $seriet = new Tab_serietramite(); $this->series = new series(); $ser_codigo = $this->series->obtenerCodigoSerie($id_serie); //insert grupos documentales y tipos documentales $this->tramite = new tab_tramite(); $tramitecc = new tab_tramitecuerpos(); $sqltramite = "SELECT\r\n tab_tramite.tra_descripcion,\r\n tab_tramite.tra_id\r\n FROM\r\n tab_series\r\n INNER JOIN tab_serietramite ON tab_series.ser_id = tab_serietramite.ser_id\r\n INNER JOIN tab_tramite ON tab_tramite.tra_id = tab_serietramite.tra_id\r\n WHERE\r\n tab_series.ser_id = {$id_serie}"; $rows = $seriet->dbSelectBySQL($sqltramite); $v = 0; foreach ($rows as $row) { if ($row->tra_descripcion == 'GRUPO DOCUMENTAL COMPUESTA') { $v++; $tra_id = $row->tra_id; $obtenerColumnCueId = $tramitecc->dbselectByField("tra_id", $tra_id); $cue_id = $obtenerColumnCueId[0]->cue_id; } } if ($v == 0) { $this->tramite->setTra_orden(1); $this->tramite->setTra_codigo(1); $this->tramite->setTra_descripcion("GRUPO DOCUMENTAL COMPUESTA"); $this->tramite->setTra_fecha_crea(date("Y-m-d")); $this->tramite->setTra_usuario_crea($_SESSION['USU_ID']); $this->tramite->setTra_estado(1); $tra_id = $this->tramite->insert(); $seriet->setSer_id($id_serie); $seriet->setTra_id($tra_id); $seriet->setSts_fecha_crea(date("Y-m-d")); $seriet->setSts_fecha_reg(date("Y-m-d")); $seriet->setSts_usuario_crea($_SESSION['USU_ID']); $seriet->setSts_usu_reg($_SESSION['USU_ID']); $seriet->setVer_id('0'); $seriet->setSts_estado(1); $seriet->insert(); $this->tramite = new tramite(); $tra_codigo = $this->tramite->obtenerCodigoTramite($tra_id); $tcuerpos = new tab_cuerpos(); $tcuerpos->setCue_id(''); $tcuerpos->setCue_orden(1); $tcuerpos->setCue_codigo(1); $tcuerpos->setCue_descripcion("UNIDAD DOCUMENTAL SIMPLE"); $tcuerpos->setCue_fecha_crea(date("Y-m-d")); $tcuerpos->setCue_usuario_crea($_SESSION['USU_ID']); $tcuerpos->setCue_estado(1); $cue_id = $tcuerpos->insert(); // Last code //$tramitecc = new tab_tramitecuerpos(); $tramitecc->setCue_id($cue_id); $tramitecc->setTra_id($tra_id); $tramitecc->setTrc_estado(1); $tramitecc->insert(); } //insert $this->exparchivo->setTra_id($tra_id); $this->exparchivo->setCue_id($cue_id); $this->exparchivo->setExa_condicion('1'); $this->exparchivo->setExa_estado(1); $this->exparchivo->insert(); //Fin del archivo } $i++; $ct++; } } else { $msg = "<font color='red'>EL FORMATO CONTRATACIONES NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } $msg .= "<b style='color:green'>SE GUARDO CORRECTAMENTE</b><br>"; $msg .= "<a href='" . PATH_DOMAIN . "/nuevoExpediente/index/'>Ver registro</a>"; unlink($Dir); $this->index($msg); exit; } else { $msg = "<font color='red'>FORMATO CONTRATACIONES No ES CORRECTO</font>"; unlink($Dir); $this->index($msg); } } else { if ($tipoformato == 5) { //CORRESPONDENCIA $cantidaddoc = $highestRow - 34; $fondo = $objPHPExcel->getActiveSheet()->getCell("E8")->getValue(); $subfondo = $objPHPExcel->getActiveSheet()->getCell("E9")->getValue(); $seccion = $objPHPExcel->getActiveSheet()->getCell("E10")->getValue(); $subseccion = $objPHPExcel->getActiveSheet()->getCell("E11")->getValue(); $serie = $objPHPExcel->getActiveSheet()->getCell("E13")->getValue(); $tituloexpediente = $objPHPExcel->getActiveSheet()->getCell("E14")->getValue(); $fechasExtremas = $objPHPExcel->getActiveSheet()->getCell("M13")->getValue(); $ml = $objPHPExcel->getActiveSheet()->getCell("D16")->getValue(); $objHoja = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); $objWorksheet = $objPHPExcel->getActiveSheet(); $tituloserie = explode("\n", $serie); $cantidaserie = count($tituloserie); if ($cantidaserie > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea del Título de la Serie</font><br>"; unlink($Dir); $this->index($msg); exit; } $tituloexp = explode("\n", $tituloexpediente); $cantidaexpediente = count($tituloexp); if ($cantidaexpediente > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea en Título de Expediente </font><br>"; unlink($Dir); $this->index($msg); exit; } //$msg= $fondo."<br>"; //$msg= $subfondo."<br>"; //$msg= $seccion."<br>"; //$msg= $subseccion."<br>"; //$msg= $serie."<br>"; //$msg= $tituloexpediente."<br>"; //$msg= $fechasExtremas."<br>"; //$msg= $ml."<br>"; //exit(); //$msg= '<table border="1">' . "\n"; //foreach ($objWorksheet->getRowIterator() as $row) { //$msg= '<tr>' . "\n"; //$cellIterator = $row->getCellIterator(); //$cellIterator->setIterateOnlyExistingCells(false); // This loops all cells, //foreach ($cellIterator as $cell) { //$msg= '<td>' . htmlentities($cell->getValue(), ENT_IGNORE, 'utf-8') . '</td>' . "\n"; //} //$msg= '</tr>' . "\n"; //} //$msg= '</table>' . "\n"; if ($highestColumn != "O") { $msg = "<font color='red'>EL FORMATO DE CORRESPONDENCIA NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } $tab_fondo = new Tab_fondo(); $tab_unidad = new Tab_unidad(); $tab_series = new Tab_series(); //obtener fondo y subfondo $sql = "select* from tab_fondo where fon_descripcion LIKE '%{$fondo}%'"; $sql2 = "select* from tab_fondo where fon_descripcion LIKE '%{$subfondo}%'"; $resultado = $tab_fondo->dbSelectBySQL($sql); $resultado2 = $tab_fondo->dbSelectBySQL($sql2); $id_fondo = $resultado[0]->fon_id; $id_subfondo = $resultado2[0]->fon_id; $ubicacion = $resultado2[0]->fon_codigo; switch ($ubicacion) { case "ON": $ubicacion = "LA PAZ"; break; case "LP": $ubicacion = "LA PAZ"; break; case "SC": $ubicacion = "SANTA CRUZ"; break; case "PT": $ubicacion = "POTOSI"; break; case "BN": $ubicacion = "BENI"; break; case "PN": $ubicacion = "PANDO"; break; case "CB": $ubicacion = "COCHABAMBA"; break; case "OR": $ubicacion = "ORURO"; break; case "CH": $ubicacion = "CHUQUISACA"; break; case "TJ": $ubicacion = "TARIJA"; break; } if ($seccion == "DIRECCION GENERAL TECNICA") { if ($id_subfondo == 3) { $seccion = "TECNICA-OPERATIVA"; } else { $seccion = "AREA TECNICA"; } } //obtener el fon_id $subseccion = trim($subseccion); if ($subseccion == "") { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$seccion}%'"; } else { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$subseccion}%'"; } $resultado3 = $tab_unidad->dbSelectBySQL($sql3); foreach ($resultado3 as $rowseccion) { $id_seccion = $rowseccion->uni_id; } //obtengo la serie $sql4 = "SELECT\r\ntab_series.ser_categoria,\r\ntab_series.ser_id\r\nFROM\r\ntab_fondo\r\nINNER JOIN tab_unidad ON tab_fondo.fon_id = tab_unidad.fon_id\r\nINNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\nWHERE\r\ntab_fondo.fon_id = {$id_subfondo} AND tab_series.ser_categoria LIKE '%{$serie}%'"; $resultado4 = $tab_series->dbSelectBySQL($sql4); foreach ($resultado4 as $rowserie) { $id_serie = $rowserie->ser_id; } $ml = $objPHPExcel->getActiveSheet()->getCell("D16")->getValue(); if ($id_serie == "") { $msg = "<font color='red'>Error, No existe la Serie Asignada</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_subfondo == "") { $msg = "<font color='red'>Error, No existe el Subfondo</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_seccion == "") { $msg = "<font color='red'>Error, No existe la Sección</font><br>"; unlink($Dir); $this->index($msg); exit; } } } //$msg= $id_seccion."<br>"; //$msg= $id_subfondo."<br>"; //$msg= $nrColumns."<br>"; //exit(); if ($highestColumn == "O") { if ($ml == "ML") { $i = 1; $ct = 18; $t = 0; $expsadg = new Tab_expisadg(); $resulall = $expsadg->dbselectByField("exp_titulo", strtoupper($tituloexpediente)); foreach ($resulall as $list) { $t++; } $fechafinal = ''; $fechainicial = ''; $exp_fechas = explode("-", $fechasExtremas); if (!empty($exp_fechas[1])) { $fechafinal = trim($exp_fechas[1]); } if (!empty($exp_fechas[0])) { $fechainicial = trim($exp_fechas[0]); } if ($t > 0) { $msg = "<font color='red'>Error! existe otro nombre duplicado</font>"; unlink($Dir); $this->index($msg); exit; } $expediente = new expediente(); $hoy = date("Y-m-d"); $this->expediente = new tab_expediente(); // $this->expediente->setRequest2Object($_REQUEST); $this->expediente->setExp_id(''); $this->expediente->setSer_id($id_serie); // Generation code $this->expediente->setExp_codigo($expediente->generaCodigo($id_serie)); $this->expediente->setExp_lugar($ubicacion); $this->expediente->setSof_id(1); $this->expediente->setExp_ori(0); $this->expediente->setExp_cop(0); $this->expediente->setExp_fot(0); $this->expediente->setExp_obs(''); $this->expediente->setExp_corr('AUTO'); $this->expediente->setExp_estado(1); $this->expediente->setExp_migrarexcel(1); $exp_id = $this->expediente->insert2(); // Update count // if ($_REQUEST['ser_corr'] == 'AUTO') { // // Auto // $tseries = new tab_series(); // $row2 = $tseries->dbselectByField("ser_id", $_REQUEST['ser_id']); // $row2 = $row2[0]; // $tseries->setSer_id($_REQUEST['ser_id']); // $ser_exp = $row2->ser_exp + 1; // $tseries->setSer_exp($ser_exp); // $tseries->update(); // } else { // // Manual // $tseries = new tab_series(); // $tseries->setSer_id($_REQUEST['ser_id']); // $tseries->setSer_exp($_REQUEST['exp_codigo']); // $tseries->update(); // } //$this->expisadg->setTrm_id(1); // $expisadg = new tab_expisadg(); // $expisadg->setExp_id($exp_id); // $expisadg->setExp_titulo($expediente); // $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_fecha_exi(date('Y-m-d')); // $expisadg->setExp_fecha_exf(date('Y-m-d')); // $expisadg->setExp_anioi($fechainicial); // $expisadg->setExp_aniof($fechafinal); // $expisadg->setIdi_id(1); // $expisadg->setExp_estado(1); // $eig_id = $expisadg->insert(); $fechahoy = date('Y-m-d'); $expisadg = new tab_expisadg(); $expisadg->setExp_id($exp_id); $expisadg->setExp_titulo($tituloexpediente); $expisadg->setExp_fecha_exi($fechahoy); // $expisadg->setExp_mesi(''); $expisadg->setExp_anioi($fechainicial); $expisadg->setExp_fecha_exf($fechahoy); // $expisadg->setExp_mesf(''); $expisadg->setExp_aniof($fechafinal); $expisadg->setExp_nivdes('EXPEDIENTE'); // $expisadg->setExp_volsop(''); $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_hisins(''); // $expisadg->setExp_hisarc(''); $expisadg->setExp_foring('TRANSFERENCIA'); // $expisadg->setExp_alccon(''); // $expisadg->setExp_vaseel(''); // $expisadg->setExp_nueing(''); $expisadg->setExp_org('LOS DOCUMENTOS DEL PROYECTO FUERON IDENTIFICADOS, CLASIFICADOS Y ORDENADOS EN LAS CAJAS DE ACUERDO AL CHECK LIST DE LA SERIE A LA QUE CORRESPONDEN.'); $expisadg->setExp_conacc('EL ACCESO ESTA SUJETO A LO QUE ESTABLECE LA CONSTITUCION POLITICA DEL ESTADO Y EL ARTICULO 18 DE LA LEY 2341 SOBRE PROCESOS ADMINISTRATIVOS.'); // $expisadg->setExp_conrep(''); $expisadg->setIdi_id(1); $expisadg->setExp_carfis('BUENO'); // $expisadg->setExp_insdes(''); // $expisadg->setExp_exloor(''); // $expisadg->setExp_exloco(''); // $expisadg->setExp_underel(''); // $expisadg->setExp_notpub(''); // $expisadg->setExp_notas(''); // $expisadg->setExp_notarc(''); $expisadg->setExp_regnor('ISAD-G, ISAAR(CPF), RCAA'); $expisadg->setExp_fecdes(date('Y-m-d')); $expisadg->setExp_estado(1); $eig_id = $expisadg->insert(); // Save expfondo data $texf = new Tab_expfondo(); $texf->setExp_id($exp_id); $usuario = new usuario(); $fon_id = $usuario->getFon_id($_SESSION['USU_ID']); $nomUsuario = $usuario->obtenerNombre($_SESSION['USU_ID']); $texf->setExf_fecha_exi($fechahoy); $texf->setFon_id($fon_id); $texf->setExf_estado('1'); $texf->insert(); // Save expusuario data $this->expusuario = new expusuario(); $this->expusuario->saveExp($exp_id, $_SESSION['USU_ID']); // // Save expcontenedor data // $con = new expcontenedor(); // $con->saveExpCont($_REQUEST['con_id'], $_REQUEST['suc_id'], $exp_id); // // Save proyecto list data (tramos) // if (isset($_REQUEST['lista_tramo'])) { // $proyectos = $_REQUEST['lista_tramo']; // foreach ($proyectos as $proyecto) { // $exp = new tab_expproyecto(); // $exp->setExp_id($exp_id); // $exp->setPry_id($proyecto); // $exp->setEpp_estado(1); // $exp->insert(); // } // } // Save data dynamic $c = 0; $caj = ""; $cnt = 0; // insert usuario serie $tab_usu_serie = new Tab_usu_serie(); $sqlususerie = "select* from tab_usu_serie\r\n where usu_id='" . $_SESSION['USU_ID'] . "'\r\n and ser_id='" . $id_serie . "'\r\n and use_estado=1"; $comprobar_usu_serie = $tab_usu_serie->dbSelectBySQL($sqlususerie); $cnt = count($comprobar_usu_serie); if ($cnt == 0) { $tab_usu_serie->setUse_id(''); $tab_usu_serie->setUsu_id($_SESSION['USU_ID']); $tab_usu_serie->setSer_id($id_serie); $tab_usu_serie->setUse_estado(1); $tab_usu_serie->insert(); } $y = 1; while ($i <= $cantidaddoc) { $caja = $objPHPExcel->getActiveSheet()->getCell("A" . $ct)->getValue(); $filnroejem = $objPHPExcel->getActiveSheet()->getCell("C" . $ct)->getValue(); $correlativo = $objPHPExcel->getActiveSheet()->getCell("E" . $ct)->getValue(); $titledoc = $objPHPExcel->getActiveSheet()->getCell("F" . $ct)->getValue(); $subtitledoc = $objPHPExcel->getActiveSheet()->getCell("G" . $ct)->getValue(); // $productor=$objPHPExcel->getActiveSheet()->getCell("H".$ct)->getValue(); // $contrato=$objPHPExcel->getActiveSheet()->getCell("I".$ct)->getValue(); $fecha = trim($objPHPExcel->getActiveSheet()->getCell("H" . $ct)->getValue()); $tomovol = $objPHPExcel->getActiveSheet()->getCell("I" . $ct)->getValue(); $sopfis = $objPHPExcel->getActiveSheet()->getCell("J" . $ct)->getValue(); $sala = $objPHPExcel->getActiveSheet()->getCell("K" . $ct)->getValue(); $estante = $objPHPExcel->getActiveSheet()->getCell("L" . $ct)->getValue(); $cuerpo = $objPHPExcel->getActiveSheet()->getCell("M" . $ct)->getValue(); $balda = $objPHPExcel->getActiveSheet()->getCell("N" . $ct)->getValue(); $obs = $objPHPExcel->getActiveSheet()->getCell("O" . $ct)->getValue(); //todavia en trabajo if ($titledoc != "") { $vector[$i] = $titledoc; if ($i > 1) { if ($vector[$i - 1] == $titledoc) { $y++; } else { $y = 1; } } if ($y > 1) { $titledoc = "{$titledoc} Nro" . $y; } // //$msg= $caja."<br>"; //$msg= $filnroejem."<br>"; //$msg= $correlativo."<br>"; //$msg= $titledoc."<br>"; //$msg= $subtitledoc."<br>"; // //$msg= $fecha."<br>"; //$msg= $tomovol."<br>"; //$msg= $sopfis."<br>"; //$msg= $sala."<br>"; //$msg= $estante."<br>"; //$msg= $cuerpo."<br>"; //$msg= $balda."<br>"; //$msg= $obs."<br>"; //exit(); if ($fecha != "s/f") { $extfe = explode("\n", $fecha); $cantidadfecha = count($extfe); if ($cantidadfecha > 1) { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = $extfe[1]; } else { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = ""; if ($fechadocAnioInicial > 30000) { $fe = date("m-y", (int) $fechadocAnioInicial); $extraer = explode("-", $fe); $fechadocAnioInicial = $extraer[1]; $fechadocMesInicial = $extraer[0]; } } } // exit(); if ($caja == "") { } else { $extraercaj = explode(" ", trim($caja)); $caj = $extraercaj[1]; } $id_exp = $exp_id; $this->archivo = new tab_archivo(); $this->archivo->setFil_id(''); // Generation code max fil_nro $maxFil = new Tab_archivo(); $sql2 = "SELECT\r\n MAX(tab_archivo.fil_nro) AS maxnro\r\n FROM\r\n tab_expediente\r\n INNER JOIN tab_exparchivo ON tab_exparchivo.exp_id = tab_expediente.exp_id\r\n INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n WHERE\r\n tab_expediente.exp_id = {$id_exp} AND\r\n tab_expediente.exp_estado = 1"; $cant_max = $maxFil->dbSelectBySQL($sql2); foreach ($cant_max as $lismax) { $max3 = $lismax->maxnro; } if ($max3 == "") { $max3 = 0; } $max3 = $max3 + 1; // $titledoc="$titledoc Nro ".$i; $this->archivo->setFil_nro($max3); $this->archivo->setFil_titulo(strtoupper($titledoc)); $this->archivo->setFil_subtitulo(strtoupper($subtitledoc)); $this->archivo->setFil_fecha($fechahoy); $this->archivo->setIdi_id(1); $this->archivo->setFil_proc($fondo); $this->archivo->setFil_firma($nomUsuario); $this->archivo->setFil_cargo(''); $this->archivo->setFil_alccon(''); $sqlsopfis = new tab_sopfisico(); if ($sopfis != "AP" || $sopfis != "EM" || $sopfis != "LG" || $sopfis != "AN" || $sopfis != "MM" || $sopfis != "CP") { $sopfis = "LG"; } $result = $sqlsopfis->dbselectByField("sof_codigo", $sopfis); $this->archivo->setSof_id($result[0]->sof_id); $this->archivo->setFil_nrofoj(''); $this->archivo->setFil_codigo(2); $this->archivo->setFil_tomovol($tomovol); $this->archivo->setFil_nroejem($filnroejem); $this->archivo->setFil_nrocaj($caj); $this->archivo->setFil_nropaq(''); $this->archivo->setFil_sala(strtoupper($sala)); $this->archivo->setFil_estante(strtoupper($estante)); $this->archivo->setFil_cuerpo(strtoupper($cuerpo)); $this->archivo->setFil_balda(strtoupper($balda)); $this->archivo->setFil_tipoarch('TEC'); $this->archivo->setFil_mrb('BUENO'); $this->archivo->setFil_mes($fechadocMesInicial); $this->archivo->setFil_anio($fechadocAnioInicial); $this->archivo->setFil_cantpaq(''); $this->archivo->setFil_cantcaj(''); $this->archivo->setFil_confidencialidad(1); $this->archivo->setFil_obs(strtoupper($obs)); $this->archivo->setFil_estado('1'); $fil_id = $this->archivo->insert(); $this->archivo2 = new tab_archivo(); $this->archivo2->setFil_id($fil_id); $this->archivo2->setFil_codigo($fil_id); $this->archivo2->setFil_estado('1'); $this->archivo2->update(); $this->exparchivo = new tab_exparchivo(); $this->exparchivo->setExa_id(''); $this->exparchivo->setFil_id($fil_id); $this->exparchivo->setExp_id($exp_id); $archivo_digital = new tab_archivo_digital(); $archivo_digital->setFid_id(''); $archivo_digital->setFil_id($fil_id); $archivo_digital->insert(); $seriet = new Tab_serietramite(); $this->series = new series(); $ser_codigo = $this->series->obtenerCodigoSerie($id_serie); //insert grupos documentales y tipos documentales $this->tramite = new tab_tramite(); $tramitecc = new tab_tramitecuerpos(); $sqltramite = "SELECT\r\n tab_tramite.tra_descripcion,\r\n tab_tramite.tra_id\r\n FROM\r\n tab_series\r\n INNER JOIN tab_serietramite ON tab_series.ser_id = tab_serietramite.ser_id\r\n INNER JOIN tab_tramite ON tab_tramite.tra_id = tab_serietramite.tra_id\r\n WHERE\r\n tab_series.ser_id = {$id_serie}"; $rows = $seriet->dbSelectBySQL($sqltramite); $v = 0; foreach ($rows as $row) { if ($row->tra_descripcion == 'GRUPO DOCUMENTAL COMPUESTA') { $v++; $tra_id = $row->tra_id; $obtenerColumnCueId = $tramitecc->dbselectByField("tra_id", $tra_id); $cue_id = $obtenerColumnCueId[0]->cue_id; } } if ($v == 0) { $this->tramite->setTra_orden(1); $this->tramite->setTra_codigo(1); $this->tramite->setTra_descripcion("GRUPO DOCUMENTAL COMPUESTA"); $this->tramite->setTra_fecha_crea(date("Y-m-d")); $this->tramite->setTra_usuario_crea($_SESSION['USU_ID']); $this->tramite->setTra_estado(1); $tra_id = $this->tramite->insert(); $seriet->setSer_id($id_serie); $seriet->setTra_id($tra_id); $seriet->setSts_fecha_crea(date("Y-m-d")); $seriet->setSts_fecha_reg(date("Y-m-d")); $seriet->setSts_usuario_crea($_SESSION['USU_ID']); $seriet->setSts_usu_reg($_SESSION['USU_ID']); $seriet->setVer_id('0'); $seriet->setSts_estado(1); $seriet->insert(); $this->tramite = new tramite(); $tra_codigo = $this->tramite->obtenerCodigoTramite($tra_id); $tcuerpos = new tab_cuerpos(); $tcuerpos->setCue_id(''); $tcuerpos->setCue_orden(1); $tcuerpos->setCue_codigo(1); $tcuerpos->setCue_descripcion("UNIDAD DOCUMENTAL SIMPLE"); $tcuerpos->setCue_fecha_crea(date("Y-m-d")); $tcuerpos->setCue_usuario_crea($_SESSION['USU_ID']); $tcuerpos->setCue_estado(1); $cue_id = $tcuerpos->insert(); // Last code //$tramitecc = new tab_tramitecuerpos(); $tramitecc->setCue_id($cue_id); $tramitecc->setTra_id($tra_id); $tramitecc->setTrc_estado(1); $tramitecc->insert(); } //insert $this->exparchivo->setTra_id($tra_id); $this->exparchivo->setCue_id($cue_id); $this->exparchivo->setExa_condicion('1'); $this->exparchivo->setExa_estado(1); $this->exparchivo->insert(); //Fin del archivo } $i++; $ct++; } } else { $msg = "<font color='red'>EL FORMATO CORRESPONDENCIA NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } $msg .= "<b style='color:green'>SE GUARDO CORRECTAMENTE</b><br>"; $msg .= "<a href='" . PATH_DOMAIN . "/nuevoExpediente/index/'>Ver registro</a>"; unlink($Dir); $this->index($msg); exit; } else { $msg = "<font color='red'>EL FORMATO CORRESPONDENCIA NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); } } else { if ($tipoformato == 6) { //CONTABILIDAD $cantidaddoc = $highestRow - 30; $fondo = $objPHPExcel->getActiveSheet()->getCell("E8")->getValue(); $subfondo = $objPHPExcel->getActiveSheet()->getCell("E9")->getValue(); $seccion = $objPHPExcel->getActiveSheet()->getCell("E10")->getValue(); $subseccion = $objPHPExcel->getActiveSheet()->getCell("E11")->getValue(); $serie = $objPHPExcel->getActiveSheet()->getCell("E12")->getValue(); $tituloexpediente = $objPHPExcel->getActiveSheet()->getCell("E13")->getValue(); $fechasExtremas = $objPHPExcel->getActiveSheet()->getCell("N12")->getValue(); $ml = $objPHPExcel->getActiveSheet()->getCell("D15")->getValue(); $objHoja = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); $objWorksheet = $objPHPExcel->getActiveSheet(); $tituloserie = explode("\n", $serie); $cantidaserie = count($tituloserie); if ($cantidaserie > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea del Título de la Serie</font><br>"; unlink($Dir); $this->index($msg); exit; } $tituloexp = explode("\n", $tituloexpediente); $cantidaexpediente = count($tituloexp); if ($cantidaexpediente > 1) { $msg = "<font color='red'>Error, Elimine los saltos de linea en Título de Expediente </font><br>"; unlink($Dir); $this->index($msg); exit; } //$msg= $fondo."<br>"; //$msg= $subfondo."<br>"; //$msg= $seccion."<br>"; //$msg= $subseccion."<br>"; //$msg= $serie."<br>"; //$msg= $tituloexpediente."<br>"; //$msg= $fechasExtremas."<br>"; //$msg= $ml."<br>"; //exit(); //$msg= '<table border="1">' . "\n"; //foreach ($objWorksheet->getRowIterator() as $row) { //$msg= '<tr>' . "\n"; // //$cellIterator = $row->getCellIterator(); //$cellIterator->setIterateOnlyExistingCells(false); //foreach ($cellIterator as $cell) { //$msg= '<td>' . htmlentities($cell->getValue(), ENT_IGNORE, 'utf-8') . '</td>' . "\n"; //} //$msg= '</tr>' . "\n"; //} //$msg= '</table>' . "\n"; //$msg= "la cantidad es:"; exit(); if ($highestColumn != "O") { $msg = "<font color='red'>EL FORMATO DE CONTABILIDAD NO ES CORRECTO!</font>"; unlink($Dir); $this->index($msg); exit; } //15-1-17 $tab_fondo = new Tab_fondo(); $tab_unidad = new Tab_unidad(); $tab_series = new Tab_series(); //obtener fondo y subfondo $sql = "select* from tab_fondo where fon_descripcion LIKE '%{$fondo}%'"; $sql2 = "select* from tab_fondo where fon_descripcion LIKE '%{$subfondo}%'"; $resultado = $tab_fondo->dbSelectBySQL($sql); $resultado2 = $tab_fondo->dbSelectBySQL($sql2); $id_fondo = $resultado[0]->fon_id; $id_subfondo = $resultado2[0]->fon_id; $ubicacion = $resultado2[0]->fon_codigo; switch ($ubicacion) { case "ON": $ubicacion = "LA PAZ"; break; case "LP": $ubicacion = "LA PAZ"; break; case "SC": $ubicacion = "SANTA CRUZ"; break; case "PT": $ubicacion = "POTOSI"; break; case "BN": $ubicacion = "BENI"; break; case "PN": $ubicacion = "PANDO"; break; case "CB": $ubicacion = "COCHABAMBA"; break; case "OR": $ubicacion = "ORURO"; break; case "CH": $ubicacion = "CHUQUISACA"; break; case "TJ": $ubicacion = "TARIJA"; break; } if ($seccion == "DIRECCION GENERAL TECNICA") { if ($id_subfondo == 3) { $seccion = "TECNICA-OPERATIVA"; } else { $seccion = "AREA TECNICA"; } } //obtener el fon_id $subseccion = trim($subseccion); if ($subseccion == "") { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$seccion}%'"; } else { $sql3 = "SELECT\r\ntab_unidad.uni_id,\r\nf.fon_id,\r\ntab_unidad.uni_descripcion\r\nFROM tab_fondo as f\r\nINNER JOIN tab_unidad ON f.fon_id = tab_unidad.fon_id\r\nWHERE\r\nf.fon_id = {$id_subfondo} and tab_unidad.uni_descripcion LIKE'%{$subseccion}%'"; } $resultado3 = $tab_unidad->dbSelectBySQL($sql3); foreach ($resultado3 as $rowseccion) { $id_seccion = $rowseccion->uni_id; } //obtengo la serie $sql4 = "SELECT\r\ntab_series.ser_categoria,\r\ntab_series.ser_id\r\nFROM\r\ntab_fondo\r\nINNER JOIN tab_unidad ON tab_fondo.fon_id = tab_unidad.fon_id\r\nINNER JOIN tab_series ON tab_unidad.uni_id = tab_series.uni_id\r\nWHERE\r\ntab_fondo.fon_id = {$id_subfondo} AND (tab_series.ser_categoria LIKE '%{$serie}%' or tab_series.ser_categoria LIKE '{$serie}%' )"; $resultado4 = $tab_series->dbSelectBySQL($sql4); foreach ($resultado4 as $rowserie) { $id_serie = $rowserie->ser_id; } if ($id_serie == "") { $msg = "<font color='red'>Error, No existe la Serie Asignada</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_subfondo == "") { $msg = "<font color='red'>Error, No existe el Subfondo</font><br>"; unlink($Dir); $this->index($msg); exit; } else { if ($id_seccion == "") { $msg = "<font color='red'>Error, No existe la Sección</font><br>"; unlink($Dir); $this->index($msg); exit; } } } //$msg= $id_seccion."<br>"; //$msg= $id_subfondo."<br>"; //$msg= $id_serie."<br>"; //exit(); if ($highestColumn == "O") { if ($ml == "ML") { $i = 1; $ct = 17; $t = 0; $expsadg = new Tab_expisadg(); $resulall = $expsadg->dbselectByField("exp_titulo", strtoupper($tituloexpediente)); foreach ($resulall as $list) { $t++; } $fechafinal = ''; $fechainicial = ''; $exp_fechas = explode("-", $fechasExtremas); if (!empty($exp_fechas[1])) { $fechafinal = trim($exp_fechas[1]); } if (!empty($exp_fechas[0])) { $fechainicial = trim($exp_fechas[0]); } if ($t > 0) { $msg = "<font color='red'>Error! existe otro nombre duplicado</font>"; unlink($Dir); $this->index($msg); exit; } $expediente = new expediente(); $hoy = date("Y-m-d"); $this->expediente = new tab_expediente(); // $this->expediente->setRequest2Object($_REQUEST); $this->expediente->setExp_id(''); $this->expediente->setSer_id($id_serie); // Generation code $this->expediente->setExp_codigo($expediente->generaCodigo($id_serie)); $this->expediente->setExp_lugar($ubicacion); $this->expediente->setSof_id(1); $this->expediente->setExp_ori(0); $this->expediente->setExp_cop(0); $this->expediente->setExp_fot(0); $this->expediente->setExp_obs(''); $this->expediente->setExp_corr('AUTO'); $this->expediente->setExp_estado(1); $this->expediente->setExp_migrarexcel(1); $exp_id = $this->expediente->insert2(); // Update count // if ($_REQUEST['ser_corr'] == 'AUTO') { // // Auto // $tseries = new tab_series(); // $row2 = $tseries->dbselectByField("ser_id", $_REQUEST['ser_id']); // $row2 = $row2[0]; // $tseries->setSer_id($_REQUEST['ser_id']); // $ser_exp = $row2->ser_exp + 1; // $tseries->setSer_exp($ser_exp); // $tseries->update(); // } else { // // Manual // $tseries = new tab_series(); // $tseries->setSer_id($_REQUEST['ser_id']); // $tseries->setSer_exp($_REQUEST['exp_codigo']); // $tseries->update(); // } //$this->expisadg->setTrm_id(1); // $expisadg = new tab_expisadg(); // $expisadg->setExp_id($exp_id); // $expisadg->setExp_titulo($expediente); // $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_fecha_exi(date('Y-m-d')); // $expisadg->setExp_fecha_exf(date('Y-m-d')); // $expisadg->setExp_anioi($fechainicial); // $expisadg->setExp_aniof($fechafinal); // $expisadg->setIdi_id(1); // $expisadg->setExp_estado(1); // $eig_id = $expisadg->insert(); $fechahoy = date('Y-m-d'); $expisadg = new tab_expisadg(); $expisadg->setExp_id($exp_id); $expisadg->setExp_titulo($tituloexpediente); $expisadg->setExp_fecha_exi($fechahoy); // $expisadg->setExp_mesi(''); $expisadg->setExp_anioi($fechainicial); $expisadg->setExp_fecha_exf($fechahoy); // $expisadg->setExp_mesf(''); $expisadg->setExp_aniof($fechafinal); $expisadg->setExp_nivdes('EXPEDIENTE'); // $expisadg->setExp_volsop(''); $expisadg->setExp_nomprod($fondo); // $expisadg->setExp_hisins(''); // $expisadg->setExp_hisarc(''); $expisadg->setExp_foring('TRANSFERENCIA'); // $expisadg->setExp_alccon(''); // $expisadg->setExp_vaseel(''); // $expisadg->setExp_nueing(''); $expisadg->setExp_org('LOS DOCUMENTOS DEL PROYECTO FUERON IDENTIFICADOS, CLASIFICADOS Y ORDENADOS EN LAS CAJAS DE ACUERDO AL CHECK LIST DE LA SERIE A LA QUE CORRESPONDEN.'); $expisadg->setExp_conacc('EL ACCESO ESTA SUJETO A LO QUE ESTABLECE LA CONSTITUCION POLITICA DEL ESTADO Y EL ARTICULO 18 DE LA LEY 2341 SOBRE PROCESOS ADMINISTRATIVOS.'); // $expisadg->setExp_conrep(''); $expisadg->setIdi_id(1); $expisadg->setExp_carfis('BUENO'); // $expisadg->setExp_insdes(''); // $expisadg->setExp_exloor(''); // $expisadg->setExp_exloco(''); // $expisadg->setExp_underel(''); // $expisadg->setExp_notpub(''); // $expisadg->setExp_notas(''); // $expisadg->setExp_notarc(''); $expisadg->setExp_regnor('ISAD-G, ISAAR(CPF), RCAA'); $expisadg->setExp_fecdes(date('Y-m-d')); $expisadg->setExp_estado(1); $eig_id = $expisadg->insert(); // Save expfondo data $texf = new Tab_expfondo(); $texf->setExp_id($exp_id); $usuario = new usuario(); $fon_id = $usuario->getFon_id($_SESSION['USU_ID']); $nomUsuario = $usuario->obtenerNombre($_SESSION['USU_ID']); $texf->setExf_fecha_exi($fechahoy); $texf->setFon_id($fon_id); $texf->setExf_estado('1'); $texf->insert(); // Save expusuario data $this->expusuario = new expusuario(); $this->expusuario->saveExp($exp_id, $_SESSION['USU_ID']); // // Save expcontenedor data // $con = new expcontenedor(); // $con->saveExpCont($_REQUEST['con_id'], $_REQUEST['suc_id'], $exp_id); // // Save proyecto list data (tramos) // if (isset($_REQUEST['lista_tramo'])) { // $proyectos = $_REQUEST['lista_tramo']; // foreach ($proyectos as $proyecto) { // $exp = new tab_expproyecto(); // $exp->setExp_id($exp_id); // $exp->setPry_id($proyecto); // $exp->setEpp_estado(1); // $exp->insert(); // } // } // Save data dynamic $c = 0; $caj = ""; $cnt = 0; // insert usuario serie $tab_usu_serie = new Tab_usu_serie(); $sqlususerie = "select* from tab_usu_serie\r\n where usu_id='" . $_SESSION['USU_ID'] . "'\r\n and ser_id='" . $id_serie . "'\r\n and use_estado=1"; $comprobar_usu_serie = $tab_usu_serie->dbSelectBySQL($sqlususerie); $cnt = count($comprobar_usu_serie); if ($cnt == 0) { $tab_usu_serie->setUse_id(''); $tab_usu_serie->setUsu_id($_SESSION['USU_ID']); $tab_usu_serie->setSer_id($id_serie); $tab_usu_serie->setUse_estado(1); $tab_usu_serie->insert(); } $y = 1; while ($i <= $cantidaddoc) { $caja = $objPHPExcel->getActiveSheet()->getCell("A" . $ct)->getValue(); $filnroejem = $objPHPExcel->getActiveSheet()->getCell("C" . $ct)->getValue(); $correlativo = $objPHPExcel->getActiveSheet()->getCell("E" . $ct)->getValue(); $titledoc = $objPHPExcel->getActiveSheet()->getCell("F" . $ct)->getValue(); $subtitledoc = $objPHPExcel->getActiveSheet()->getCell("G" . $ct)->getValue(); // $productor=$objPHPExcel->getActiveSheet()->getCell("H".$ct)->getValue(); // $contrato=$objPHPExcel->getActiveSheet()->getCell("I".$ct)->getValue(); $fecha = trim($objPHPExcel->getActiveSheet()->getCell("H" . $ct)->getValue()); $tomovol = $objPHPExcel->getActiveSheet()->getCell("I" . $ct)->getValue(); $sopfis = $objPHPExcel->getActiveSheet()->getCell("J" . $ct)->getValue(); $sala = $objPHPExcel->getActiveSheet()->getCell("K" . $ct)->getValue(); $estante = $objPHPExcel->getActiveSheet()->getCell("L" . $ct)->getValue(); $cuerpo = $objPHPExcel->getActiveSheet()->getCell("M" . $ct)->getValue(); $balda = $objPHPExcel->getActiveSheet()->getCell("N" . $ct)->getValue(); $obs = $objPHPExcel->getActiveSheet()->getCell("O" . $ct)->getValue(); //todavia en trabajo if ($titledoc != "") { $vector[$i] = $titledoc; if ($i > 1) { if ($vector[$i - 1] == $titledoc) { $y++; } else { $y = 1; } } if ($y > 1) { $titledoc = "{$titledoc} Nro " . $y; } if ($fecha != "s/f") { $extfe = explode("\n", $fecha); $cantidadfecha = count($extfe); if ($cantidadfecha > 1) { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = $extfe[1]; } else { $fechadocAnioInicial = $extfe[0]; $fechadocMesInicial = ""; if ($fechadocAnioInicial > 30000) { $fe = date("m-y", (int) $fechadocAnioInicial); $extraer = explode("-", $fe); $fechadocAnioInicial = $extraer[1]; $fechadocMesInicial = $extraer[0]; } } } // exit(); if ($caja == "") { } else { $extraercaj = explode(" ", trim($caja)); $caj = $extraercaj[1]; } $id_exp = $exp_id; $this->archivo = new tab_archivo(); $this->archivo->setFil_id(''); // Generation code max fil_nro $maxFil = new Tab_archivo(); $sql2 = "SELECT\r\n MAX(tab_archivo.fil_nro) AS maxnro\r\n FROM\r\n tab_expediente\r\n INNER JOIN tab_exparchivo ON tab_exparchivo.exp_id = tab_expediente.exp_id\r\n INNER JOIN tab_archivo ON tab_archivo.fil_id = tab_exparchivo.fil_id\r\n WHERE\r\n tab_expediente.exp_id = {$id_exp} AND\r\n tab_expediente.exp_estado = 1"; $cant_max = $maxFil->dbSelectBySQL($sql2); foreach ($cant_max as $lismax) { $max3 = $lismax->maxnro; } if ($max3 == "") { $max3 = 0; } $max3 = $max3 + 1; // $titledoc="$titledoc Nro ".$i; $this->archivo->setFil_nro($max3); $this->archivo->setFil_titulo(strtoupper($titledoc)); $this->archivo->setFil_codigo(2); $this->archivo->setFil_subtitulo(strtoupper($subtitledoc)); $this->archivo->setFil_fecha($fechahoy); $this->archivo->setIdi_id(1); $this->archivo->setFil_proc($fondo); $this->archivo->setFil_firma($nomUsuario); $this->archivo->setFil_cargo(''); $this->archivo->setFil_alccon(''); $sqlsopfis = new tab_sopfisico(); if ($sopfis != "AP" || $sopfis != "EM" || $sopfis != "LG" || $sopfis != "AN" || $sopfis != "MM" || $sopfis != "CP") { $sopfis = "LG"; } $result = $sqlsopfis->dbselectByField("sof_codigo", $sopfis); $this->archivo->setSof_id($result[0]->sof_id); $this->archivo->setFil_nrofoj(''); $this->archivo->setFil_tomovol($tomovol); $this->archivo->setFil_nroejem($filnroejem); $this->archivo->setFil_nrocaj($caj); $this->archivo->setFil_nropaq(''); $this->archivo->setFil_sala(strtoupper($sala)); $this->archivo->setFil_estante(strtoupper($estante)); $this->archivo->setFil_cuerpo(strtoupper($cuerpo)); $this->archivo->setFil_balda(strtoupper($balda)); $this->archivo->setFil_tipoarch('TEC'); $this->archivo->setFil_mrb('BUENO'); $this->archivo->setFil_mes($fechadocMesInicial); $this->archivo->setFil_anio($fechadocAnioInicial); $this->archivo->setFil_cantpaq(''); $this->archivo->setFil_cantcaj(''); $this->archivo->setFil_confidencialidad(1); $this->archivo->setFil_obs(strtoupper($obs)); $this->archivo->setFil_estado('1'); $fil_id = $this->archivo->insert(); $this->archivo2 = new tab_archivo(); $this->archivo2->setFil_id($fil_id); $this->archivo2->setFil_codigo($fil_id); $this->archivo2->setFil_estado('1'); $this->archivo2->update(); $this->exparchivo = new tab_exparchivo(); $this->exparchivo->setExa_id(''); $this->exparchivo->setFil_id($fil_id); $this->exparchivo->setExp_id($exp_id); $archivo_digital = new tab_archivo_digital(); $archivo_digital->setFid_id(''); $archivo_digital->setFil_id($fil_id); $archivo_digital->insert(); $seriet = new Tab_serietramite(); $this->series = new series(); $ser_codigo = $this->series->obtenerCodigoSerie($id_serie); //insert grupos documentales y tipos documentales $this->tramite = new tab_tramite(); $tramitecc = new tab_tramitecuerpos(); $sqltramite = "SELECT\r\n tab_tramite.tra_descripcion,\r\n tab_tramite.tra_id\r\n FROM\r\n tab_series\r\n INNER JOIN tab_serietramite ON tab_series.ser_id = tab_serietramite.ser_id\r\n INNER JOIN tab_tramite ON tab_tramite.tra_id = tab_serietramite.tra_id\r\n WHERE\r\n tab_series.ser_id = {$id_serie}"; $rows = $seriet->dbSelectBySQL($sqltramite); $v = 0; foreach ($rows as $row) { if ($row->tra_descripcion == 'GRUPO DOCUMENTAL COMPUESTA') { $v++; $tra_id = $row->tra_id; $obtenerColumnCueId = $tramitecc->dbselectByField("tra_id", $tra_id); $cue_id = $obtenerColumnCueId[0]->cue_id; } } if ($v == 0) { $this->tramite->setTra_orden(1); $this->tramite->setTra_codigo(1); $this->tramite->setTra_descripcion("GRUPO DOCUMENTAL COMPUESTA"); $this->tramite->setTra_fecha_crea(date("Y-m-d")); $this->tramite->setTra_usuario_crea($_SESSION['USU_ID']); $this->tramite->setTra_estado(1); $tra_id = $this->tramite->insert(); $seriet->setSer_id($id_serie); $seriet->setTra_id($tra_id); $seriet->setSts_fecha_crea(date("Y-m-d")); $seriet->setSts_fecha_reg(date("Y-m-d")); $seriet->setSts_usuario_crea($_SESSION['USU_ID']); $seriet->setSts_usu_reg($_SESSION['USU_ID']); $seriet->setVer_id('0'); $seriet->setSts_estado(1); $seriet->insert(); $this->tramite = new tramite(); $tra_codigo = $this->tramite->obtenerCodigoTramite($tra_id); $tcuerpos = new tab_cuerpos(); $tcuerpos->setCue_id(''); $tcuerpos->setCue_orden(1); $tcuerpos->setCue_codigo(1); $tcuerpos->setCue_descripcion("UNIDAD DOCUMENTAL SIMPLE"); $tcuerpos->setCue_fecha_crea(date("Y-m-d")); $tcuerpos->setCue_usuario_crea($_SESSION['USU_ID']); $tcuerpos->setCue_estado(1); $cue_id = $tcuerpos->insert(); // Last code //$tramitecc = new tab_tramitecuerpos(); $tramitecc->setCue_id($cue_id); $tramitecc->setTra_id($tra_id); $tramitecc->setTrc_estado(1); $tramitecc->insert(); } //insert $this->exparchivo->setTra_id($tra_id); $this->exparchivo->setCue_id($cue_id); $this->exparchivo->setExa_condicion('1'); $this->exparchivo->setExa_estado(1); $this->exparchivo->insert(); //Fin del archivo } $i++; $ct++; } } else { $msg = "<font color='red'>EL FORMATO DE CONTABILIDAD NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); exit; } $msg .= "<b style='color:green'>SE GUARDO CORRECTAMENTE</b><br>"; $msg .= "<a href='" . PATH_DOMAIN . "/nuevoExpediente/index/'>Ver registro</a>"; unlink($Dir); $this->index($msg); exit; } else { $msg = "<font color='red'>EL FORMATO DE CONTABILIDAD NO ES CORRECTO</font>"; unlink($Dir); $this->index($msg); } } } } } } } //otro modelo //$objHoja=$objPHPExcel->getActiveSheet()->toArray(null,true,true,true); // //foreach($objHoja as $iIndice=>$objCelda) { //$msg= $objCelda['A'].$objCelda['B']; //} //$objWorksheet = $objPHPExcel->getActiveSheet(); // //$msg= '<table border="1">' . "\n"; //foreach ($objWorksheet->getRowIterator() as $row) { //$msg= '<tr>' . "\n"; // //$cellIterator = $row->getCellIterator(); //$cellIterator->setIterateOnlyExistingCells(false); // This loops all cells, //foreach ($cellIterator as $cell) { //$msg= '<td>' . htmlentities($cell->getValue(), ENT_IGNORE, 'utf-8') . '</td>' . "\n"; //} // //$msg= '</tr>' . "\n"; //} //$msg= '</table>' . "\n"; //foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { //$worksheetTitle = $worksheet->getTitle(); //$highestRow = $worksheet->getHighestRow(); // e.g. 10 //$highestColumn = $worksheet->getHighestColumn(); // e.g 'F' //$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); //$nrColumns = ord($highestColumn) - 64; ////$msg= "<br>The worksheet ".$worksheetTitle." has "; ////$msg= $nrColumns . ' columns (A-' . $highestColumn . ') '; ////$msg= ' and ' . $highestRow . ' row.'; //$msg= '<br><table border="1"><tr>'; //for ($row = 1; $row <= $highestRow; ++ $row) { //$msg= '<tr>'; //for ($col = 0; $col < $highestColumnIndex; ++ $col) { //$cell = $worksheet->getCellByColumnAndRow($col, $row); //$val = $cell->getValue(); //$dataType = PHPExcel_Cell_DataType::dataTypeForValue($val); //$msg= '<td>' . $val . '</td>'; //} //$msg= '</tr>'; //} //$msg= '</table>'; //} unlink($Dir); exit; // //if( !isset($_FILES['archivo']) ){ // $msg= 'Ha habido un error, tienes que elegir un archivo<br/>'; // $msg= '<a href="index.html">Subir archivo</a>'; //}else{ // // $nombre = $_FILES['archivo']['name']; // $nombre_tmp = $_FILES['archivo']['tmp_name']; // $tipo = $_FILES['archivo']['type']; // $tamano = $_FILES['archivo']['size']; // // $ext_permitidas = array('xls','jpeg','xlsx','png'); // $partes_nombre = explode('.', $nombre); // $extension = end( $partes_nombre ); // $ext_correcta = in_array($extension, $ext_permitidas); // // $tipo_correcto = preg_match('/^image\/(pjpeg|jpeg|gif|png|xls|xlsx)$/', $tipo); // // $limite = 500 * 1024; // // if( $ext_correcta && $tamano <= $limite ){ // if( $_FILES['archivo']['error'] > 0 ){ // $msg= 'Error: ' . $_FILES['archivo']['error'] . '<br/>'; // }else{ // $msg= 'Nombre: ' . $nombre . '<br/>'; // $msg= 'Tipo: ' . $tipo . '<br/>'; // $msg= 'Tamaño: ' . ($tamano / 1024) . ' Kb<br/>'; // $msg= 'Guardado en: ' . $nombre_tmp; // // $nombreDirectorio = ""; // $tsistema = new tab_sistema (); // $sql = "SELECT * // FROM tab_sistema"; // $rows2 = $tsistema->dbselectBySQL($sql); // if (count($rows2) >= 1) { // $sis_tipcarga = $rows2 [0]->sis_tipcarga; // $sis_tammax = $rows2 [0]->sis_tammax; // $nombreDirectorio = $rows2 [0]->sis_ruta; // } // // if( file_exists( 'subidas/'.$nombre) ){ // $msg= '<br/>El archivo ya existe: ' . $nombre; // }else{ // move_uploaded_file($nombre_tmp, // "subidas/" . $nombre); // // $msg= "<br/>Guardado en: " . "subidas/" . $nombre; // } // } // }else{ // $msg= 'Archivo inválido'; // } //} exit; }
function download() { /* * *************************************************** */ /* TYPE SAVE */ /* * *************************************************** */ $sis_tipcarga = 1; // $archivo_digital = new tab_archivo_digital(); // // A BD if ($sis_tipcarga == 2) { $error = ""; /* if (isset ( $_COOKIE [session_name ()] )) { if (session_is_registered ( 'USU_ID' )) { */ if (isset($_POST['fil_id_open'])) { $fil_id = $_POST['fil_id_open']; } else { $fil_id = VAR3; } if ($fil_id != '') { $archivo = new tab_archivo(); $rowe = $archivo->dbSelectBySQL("SELECT * FROM tab_archivo WHERE fil_id = '" . $fil_id . "'"); if ($rowe[0]->fil_confidencialidad != '3') { $rowa = $archivo->dbSelectBySQL("SELECT * FROM tab_archivo WHERE fil_id = '" . $fil_id . "'"); $archivobin = new tab_archivobin(); $row = $archivobin->dbSelectBySQLField("SELECT fil_contenido FROM tab_archivobin WHERE fil_id = '" . $fil_id . "'"); if (count($row) == 1 || count($rowa) == 1) { $sql = "SELECT\r\n\t\t\t\t\t\t\ttab_archivo.fil_id,\r\n\t\t\t\t\t\t\ttab_archivo.fil_nomoriginal,\r\n\t\t\t\t\t\t\ttab_archivo.fil_nomcifrado,\r\n\t\t\t\t\t\t\ttab_archivo.fil_tamano,\r\n\t\t\t\t\t\t\ttab_archivo.fil_extension,\r\n\t\t\t\t\t\t\ttab_archivo.fil_tipo,\r\n\t\t\t\t\t\t\tcoalesce(tab_archivobin.fil_contenido,'-1') as fil_contenido\r\n\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\ttab_archivo\r\n\t\t\t\t\t\t\tInner Join tab_archivobin ON tab_archivo.fil_id = tab_archivobin.fil_id WHERE tab_archivobin.fil_id = '" . $fil_id . "'"; $r_files = $archivo->dbSelectBySQLArchive($sql); // $link = $archivo_digital->connect(); $sql = "select fil_id, nombre, mime, size, coalesce(archivo_oid,'-1') as archivo_oid, coalesce(archivo_bytea,'-1') as archivo_bytea from tab_archivo_digital where fil_id={$fil_id}"; $result = pg_query($link, $sql); if (!$result || pg_num_rows($result) < 1) { header("Location: index.php"); exit; } $row = pg_fetch_array($result, 0); pg_free_result($result); if ($row['archivo_bytea'] == -1 && $row['archivo_oid'] == -1) { die('No existe el archivo para mostrar o bajar'); } pg_query($link, "begin"); $file = pg_lo_open($link, $row['archivo_oid'], "r"); header("Cache-control: private"); header("Content-type: {$row['mime']}"); //if($f==1) header("Content-Disposition: attachment; filename=\"$row[nombre]\""); header("Content-length: {$row['size']}"); header("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"))) . " GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); pg_lo_read_all($file); pg_lo_close($file); pg_query($link, "commit"); pg_close($link); } else { $error = "No existe el archivo."; } } else { if (isset($_POST['pass_open']) && $_POST['pass_open'] != '') { $usuario = new tab_usuario(); $row_usu = $usuario->dbselectByField("usu_id", $_SESSION['USU_ID']); $usuario = $row_usu[0]; if ($usuario->getUsu_leer_doc() == '1' && $usuario->getUsu_pass_leer() == md5($_POST['pass_open'])) { $archivo = new tab_archivo(); $rowa = $archivo->dbSelectBySQLField("SELECT * FROM tab_archivo WHERE fil_id = '" . $fil_id . "'"); $archivobin = new tab_archivobin(); $row = $archivobin->dbSelectBySQLField("SELECT fil_contenido FROM tab_archivobin WHERE fil_id = '" . $fil_id . "'"); if (count($row) == 1 || count($rowa) == 1) { $sql = "SELECT\r\n\t\t\t\t\t\t\t\t\ttab_archivo.fil_id,\r\n\t\t\t\t\t\t\t\t\ttab_archivo.fil_nomoriginal,\r\n\t\t\t\t\t\t\t\t\ttab_archivo.fil_nomcifrado,\r\n\t\t\t\t\t\t\t\t\ttab_archivo.fil_tamano,\r\n\t\t\t\t\t\t\t\t\ttab_archivo.fil_extension,\r\n\t\t\t\t\t\t\t\t\ttab_archivo.fil_tipo,\r\n\t\t\t\t\t\t\t\t\ttab_archivobin.fil_contenido\r\n\t\t\t\t\t\t\t\t\tFROM\r\n\t\t\t\t\t\t\t\t\ttab_archivo\r\n\t\t\t\t\t\t\t\t\tInner Join tab_archivobin ON tab_archivo.fil_id = tab_archivobin.fil_id WHERE tab_archivobin.fil_id = '" . $fil_id . "'"; $r_files = $archivo->dbSelectBySQLArchive($sql); header('Content-type:' . $r_files[0]->fil_tipo); echo $r_files[0]->fil_contenido; } else { $error = "No existe el archivo."; } } else { $error = 'Password incorrecto.'; } } else { $error = 'No tiene permisos para ver este archivo.'; } } } else { $error = 'No existe el archivo.'; } } else { // A SERVER $error = ""; if (isset($_POST['fil_id_open'])) { $fil_id = $_POST['fil_id_open']; } else { $fil_id = VAR3; } if ($fil_id != '') { // $link = $archivo_digital->connect(); $sql = "select fil_id, nombre, mime, size, coalesce(archivo_oid,'-1') as archivo_oid, coalesce(archivo_bytea,'-1') as archivo_bytea from tab_archivo_digital where fil_id={$fil_id}"; $result = pg_query($link, $sql); if (!$result || pg_num_rows($result) < 1) { header("Location: index.php"); exit; } $row = pg_fetch_array($result, 0); // Data Parameters $nombreDirectorio = ""; $tsistema = new tab_sistema(); $sql = "SELECT *\r\n FROM tab_sistema"; $rows2 = $tsistema->dbselectBySQL($sql); if (count($rows2) >= 1) { $sis_tipcarga = $rows2[0]->sis_tipcarga; $sis_tammax = $rows2[0]->sis_tammax; $nombreDirectorio = $rows2[0]->sis_ruta; } $archivopdf = $nombreDirectorio . $row[1]; $len = filesize($archivopdf); //$archivopdf = PATH_DOMAIN ."/". $nombreDirectorio . $row[1]; //$len = filesize($archivopdf); header("Cache-control: private"); //header("Content-type: $row[mime]"); header("Content-type: {$row['2']}"); //header("Content-Disposition: attachment; filename='".$archivopdf."'"); header("Content-length: {$len}"); header("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"))) . " GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); readfile($archivopdf); pg_free_result($result); pg_close($link); } } if ($error != '') { echo $error; } }