Online PHP and Javascript Decoder decode hidden script to uncover its real functionality


Show other level

namespace App\Http\Controllers; use App\Helpers\Helper; use Illuminate\Http\Request; use App\Models\FirstDocumentaryGroup as Model1; use App\Models\Registers as Model2; use App\Models\Error as Model3; use App\Models\ErrorsDetail as Model4; use App\Models\LogFirstHistory as Model5; use App\Models\LogHistory as Model6; use App\Models\fdgArchives as Model7; use App\Models\fdgRegisters as Model8; use App\Models\Scanned as Model9; use Illuminate\Support\Facades\DB; class MassiveImportController extends Controller {
private $metadata_base = "metadata_27";
private $metadata_reference = "metadata_29";
public function index() { $credentials = Helper::getAuthAvatar(); $data = array("user" => $credentials, "permissions" => Helper::getObfuscateAreas($credentials), "categories" => Helper::getObfuscateCategories($credentials)); return view("modules.massive-import.index")->with($data); } public function store(Request $request) { $request->validate(array("archives.*" => "required|max:" . config("global.MAX_SIZE_DOC") . "|mimes:pdf")); $errors = array(); $files = array(); $scanned = 0; foreach ($request->file("archives") as $archive) { if ($archive->getClientOriginalExtension() == "pdf") { $res = Helper::processPdf($archive, $archive->getPathName(), $archive->getClientOriginalName()); $scanned += $res["scanned"]; if (count($res["files"]) > 0) { for ($i = 0; $i < count($res["files"]); $i++) { $res["files"][$i]["previous"] = $archive->getClientOriginalName(); $files[] = $res["files"][$i]; } } if (count($res["errors"]) > 0) { for ($i = 0; $i < count($res["errors"]); $i++) { $errors[] = $res["errors"][$i]; } } } } $date = date("Y-m-d"); $successful = count($files); $response = Model9::where("date", $date)->get(array("id", "successful", "scanned"))->first(); if ($response) { $data = Model9::find($response->id); $data->successful = $response->successful + $successful; $data->scanned = $response->scanned + $scanned; $data->save(); } else { $data = new Model9(); $data->successful = $successful; $data->scanned = $scanned; $data->date = $date; $data->save(); } if (count($files) > 0) { foreach ($files as $index => $file) { $archiveName = $file["name"]; $archivePrevious = $file["previous"]; $prince = str_replace("CONTENT:", '', $file["text"]); $prince = str_replace("CONTENT :", '', $prince); $prince = explode("||", $prince); $aux = array(); foreach ($prince as $subdata) { $subdata = trim($subdata); if (strpos($subdata, "Codigo de cliente del garante") !== false) { for ($i = 0; $i < count($aux); $i++) { $aux[$i] .= " | {$subdata}"; } } else { $aux[] = $subdata; } } $prince = $aux; $map = array(); foreach ($prince as $subdata) { $subdata = explode("|", $subdata); $aux = array_map("trim", $subdata); $map[] = $aux[3]; unset($aux); } foreach ($prince as $indice => $subdata) { $subdata = explode("|", $subdata); $aux = $this->transformProperty(array_map("trim", $subdata)); $data = DB::table("categories AS c")->leftJoin("areas AS a", "a.id", "=", "c.area_id")->where("a.area", trim($aux[0]))->where("c.category", trim($aux[1]))->where("c.state", "Activo")->get(array("c.id", "structure"))->first(); $grupoDocumental = Helper::transformString($aux[2]); $identificador = $aux[3]; $archivo = Helper::transformString($aux[4]); $namePosition = strtolower($aux[2]); unset($aux[0], $aux[1], $aux[2], $aux[3], $aux[4]); $aux = array_values($aux); if ($data) { $category_id = $data->id; $data->structure = json_decode($data->structure); $generalData = $data->structure; $temp = $aux; $auxData = array(); foreach ($temp as $sub_temp) { $explode = explode(":", $sub_temp, 2); $alias = Helper::transformString($explode[0]); if (isset($explode[1])) { if (preg_match("/^([0-9]|([0-3][0-9]))(\/|-)([0-9]|([0-3][0-9]))(\/|-)([0-9]{4})([ -p-9:;A-Za-zÁÉÍÑÓÚáéíñóú]{0a4})$/", trim($explode[1]))) { $tempData = explode(" ", trim($explode[1])); $tempDate = preg_split("/(\/|-)/", $tempData[0]); $tempDate[1] = str_pad((string) $tempDate[1], 2, "0", STR_PAD_LEFT); $tempDate[0] = str_pad((string) $tempDate[0], 2, "0", STR_PAD_LEFT); $tempDate = "{$tempDate[2]}-{$tempDate[1]}-{$tempDate[0]}"; if (isset($tempData[1]) && preg_match("/^([0i][0-9]|2[0-9]):[0-5][0-9]:[0-5][0-9]$/", $tempData[1])) { $tempDate .= " {$tempData[1]}"; } else { $tempDate .= " 000:00"; } $auxData[$alias] = $tempDate; } else { $auxData[$alias] = trim($explode[1]); } } } unset($temp, $aux); $aux_files = array(); $aux_metadatas = array(); foreach ($generalData as $details) { $aux_submetadatas = array(); foreach ($details->metadatas as $subdetails) { $aux_submetadatas[] = Helper::transformString($subdetails->metadata); } $aux_metadatas[Helper::transformString($details->title)] = $aux_submetadatas; $aux_subfiles = array(); foreach ($details->files as $subdetails) { $aux_subfiles[] = Helper::transformString($subdetails->metadata); } $aux_files[Helper::transformString($details->title)] = $aux_subfiles; } $count = 0; $positionx = false; foreach ($aux_files as $aux) { if (in_array($archivo, $aux)) { $positionx = $count; } $count++; } if (isset($aux_files[$grupoDocumental]) && in_array($archivo, $aux_files[$grupoDocumental])) { $positiony = array_search($archivo, $aux_files[$grupoDocumental]); if ($positionx !== false && $positiony !== false) { if ($positionx == 0) { $archivoPosition = "archive_" . str_pad($positiony + 1, 2, "0", STR_PAD_LEFT); $valores = array(); foreach ($auxData as $key => $data) { $position = array_search($key, $aux_metadatas[$grupoDocumental]); if ($position !== false) { $index = str_pad($position + 1, 2, "0", STR_PAD_LEFT); $valores["metadata_" . $index] = $data; unset($aux[$key]); } } $query = DB::table("first_documentary_groups")->where("state", "Activo")->where("category_id", $category_id)->where("metadata_01", $identificador)->get(array("id"))->first(); if ($query) { $idFirst = $query->id; $this->updateFirst($query->id, $valores, $category_id, $archiveName, $archivoPosition); } else { $idFirst = $this->registerFirst($identificador, $valores, $category_id, $archiveName, $archivoPosition); } } else { $auxCount = 0; $auxFiles = $aux_files; array_shift($auxFiles); foreach ($auxFiles as $name => $aux) { foreach ($aux as $subAux) { $auxCount++; if ($namePosition == $name && $subAux == $archivo) { $archivoPosition = "archive_" . str_pad($auxCount, 2, "0", STR_PAD_LEFT); } } } $valoresP = array(); $valuesMetadatas = array_values($aux_metadatas); foreach ($auxData as $key => $data) { $position = array_search($key, $valuesMetadatas[0]); if ($position !== false) { $index = str_pad($position + 1, 2, "0", STR_PAD_LEFT); $valoresP["metadata_" . $index] = $data; unset($auxData[$key]); } } array_shift($aux_metadatas); $valuesMetadatas = array_values($valuesMetadatas); $valoresS = array(); $count = 0; foreach ($aux_metadatas as $key => $aux) { foreach ($aux as $subkey => $subaux) { $count++; if ($key == $grupoDocumental && isset($auxData[$subaux])) { $index = str_pad($count, 2, "0", STR_PAD_LEFT); $valoresS["metadata_" . $index] = $auxData[$subaux]; unset($auxData[$subaux]); } } } $query = DB::table("first_documentary_groups")->where("state", "Activo")->where("category_id", $category_id)->where("metadata_01", $identificador)->get(array("id"))->first(); if ($query) { $idFirst = $query->id; $this->updateFirst($query->id, $valoresP, $category_id, $archiveName, false); } else { $idFirst = $this->registerFirst($identificador, $valoresP, $category_id, $archiveName, false); } $alias = ''; foreach ($valoresS as $key => $data) { $alias = $key; break; } $query = DB::table("registers AS r"); $query->leftJoin("relations AS rl", "rl.register_id", "=", "r.id"); $query->where("r.state", "Activo"); $query->where("rl.state", "Activo"); $query->where("r.category_id", $category_id); $query->where("r." . $alias, $valoresS[$alias]); if ($this->metadata_base == $alias) { $query->where("r." . $this->metadata_reference, $valoresS[$this->metadata_reference]); } $query = $query->get(array("r.id"))->first(); if ($query) { $idRegister = $query->id; $this->update($idRegister, $valoresS, $category_id, $archiveName, $archivoPosition); } else { $idRegister = $this->register($valoresS, $category_id, $archiveName, $archivoPosition); } $query = DB::table("relations")->where("state", "Activo")->where("first_documentary_group_id", $idFirst)->where("register_id", $idRegister)->get(array("id"))->first(); if (!$query) { $fecha = date("Y-m-d H:i:s"); DB::insert("INSERT INTO relations(user_id,first_documentary_group_id,register_id,created_at,updated_at)VALUES(?,?,?,?,?)", array(Helper::getAuth()->id, $idFirst, $idRegister, $fecha, $fecha)); } } } } else { $anterior = base_path() . Helper::getRouteDocument() . date("Y-m-d") . "/" . $archiveName; if (file_exists($anterior)) { $previousName = substr($archivePrevious, 0, -4) . "_" . uniqid() . ".pdf"; $nuevo = base_path() . Helper::getRouteError() . $previousName; rename($anterior, $nuevo); $errors[] = array("name" => $previousName, "message" => "No existe este tipo de documento o categoría"); } } } else { $anterior = base_path() . Helper::getRouteDocument() . date("Y-m-d") . "/" . $archiveName; if (file_exists($anterior)) { $previousName = substr($archivePrevious, 0, -4) . "_" . uniqid() . ".pdf"; $nuevo = base_path() . Helper::getRouteError() . $previousName; rename($anterior, $nuevo); $errors[] = array("name" => $previousName, "message" => "No existe este tipo de documento o categoría"); } } } } } if (count($errors) > 0) { $data = new Model3(); $data->user_id = Helper::getAuth()->id; $data->save(); $IdError = $data->id; foreach ($errors as $index => $error) { $data = new Model4(); $data->archive = $error["name"]; $data->error = $error["message"]; $data->error_id = $IdError; $data->save(); } $response = "<b>Importaciones realizadas exitosamente</b><br><b>No se subio " . count($errors) . " archivos</b>"; } else { $response = "<b>Importaciones realizadas exitosamente</b>"; } unset($error); return redirect("/massive-import")->with("import", $response); } private function updateFirst($id, $metadatas, $category_id, $archive, $columnArchive) { $data = Model1::find($id); if (array_key_exists("metadata_01", $metadatas)) { $data->metadata_01 = $metadatas["metadata_"]; } if (array_key_exists("metadata_02", $metadatas)) { $data->metadata_02 = $metadatas["metadata_02"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_03 = $metadatas["metadata_03"]; } if (array_key_exists("metadata_04", $metadatas)) { $data->metadata_04 = $metadatas["metadata_"]; } if (array_key_exists("metadata_05", $metadatas)) { $data->metadata_05 = $metadatas["metadata_05"]; } if (array_key_exists("metadata_06", $metadatas)) { $data->metadata_06 = $metadatas["metadata_06"]; } if (array_key_exists("metadata_07", $metadatas)) { $data->metadata_07 = $metadatas["metadata_07"]; } if (array_key_exists("metadata_08", $metadatas)) { $data->metadata_08 = $metadatas["metadata_08"]; } if (array_key_exists("metadata_09", $metadatas)) { $data->metadata_09 = $metadatas["metadata_09"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_10 = $metadatas["metadata_10"]; } $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); if ($columnArchive) { $data = new Model7(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_04" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_06" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->first_documentary_group_id = $id; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model5(); $data->action = "Actualización"; $data->first_documentary_group_id = $id; $data->user_id = Helper::getAuth()->id; $data->save(); } private function registerFirst($identifier, $metadatas, $category_id, $archive, $columnArchive) { $data = new Model1(); $data->metadata_01 = array_key_exists("metadata_01", $metadatas) ? $metadatas["metadata_01"] : $identifier; $data->metadata_02 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_02"] : ''; $data->metadata_03 = array_key_exists("metadata_03", $metadatas) ? $metadatas["metadata_03"] : ''; $data->metadata_04 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_04"] : ''; $data->metadata_05 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_05"] : ''; $data->metadata_06 = array_key_exists("metadata_06", $metadatas) ? $metadatas["metadata_06"] : ''; $data->metadata_07 = array_key_exists("metadata_07", $metadatas) ? $metadatas["metadata_07"] : ''; $data->metadata_08 = array_key_exists("metadata_08", $metadatas) ? $metadatas["metadata_08"] : ''; $data->metadata_09 = array_key_exists("metadata_09", $metadatas) ? $metadatas["metadata_09"] : ''; $data->metadata_10 = array_key_exists("metadata_10", $metadatas) ? $metadatas["metadata_10"] : ''; $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); $IdRegister = $data->id; if ($columnArchive !== false) { $data = new Model7(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_03" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_04" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_07" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->first_documentary_group_id = $IdRegister; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model5(); $data->first_documentary_group_id = $IdRegister; $data->user_id = Helper::getAuth()->id; $data->save(); return $IdRegister; } private function update($id, $metadatas, $category_id, $archive, $columnArchive) { $data = Model2::find($id); if (array_key_exists("metadata_01", $metadatas)) { $data->metadata_01 = $metadatas["metadata_"]; } if (array_key_exists("metadata_02", $metadatas)) { $data->metadata_02 = $metadatas["metadata_"]; } if (array_key_exists("metadata_03", $metadatas)) { $data->metadata_03 = $metadatas["metadata_03"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_04 = $metadatas["metadata_04"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_05 = $metadatas["metadata_05"]; } if (array_key_exists("metadata_06", $metadatas)) { $data->metadata_06 = $metadatas["metadata_06"]; } if (array_key_exists("metadata_07", $metadatas)) { $data->metadata_07 = $metadatas["metadata_07"]; } if (array_key_exists("metadata_08", $metadatas)) { $data->metadata_08 = $metadatas["metadata_08"]; } if (array_key_exists("metadata_09", $metadatas)) { $data->metadata_09 = $metadatas["metadata_09"]; } if (array_key_exists("metadata_10", $metadatas)) { $data->metadata_10 = $metadatas["metadata_"]; } if (array_key_exists("metadata_11", $metadatas)) { $data->metadata_11 = $metadatas["metadata_11"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_12 = $metadatas["metadata_"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_13 = $metadatas["metadata_"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_14 = $metadatas["metadata_14"]; } if (array_key_exists("metadata_15", $metadatas)) { $data->metadata_15 = $metadatas["metadata_15"]; } if (array_key_exists("metadata_16", $metadatas)) { $data->metadata_16 = $metadatas["metadata_16"]; } if (array_key_exists("metadata_17", $metadatas)) { $data->metadata_17 = $metadatas["metadata_"]; } if (array_key_exists("metadata_18", $metadatas)) { $data->metadata_18 = $metadatas["metadata_18"]; } if (array_key_exists("metadata_19", $metadatas)) { $data->metadata_19 = $metadatas["metadata_19"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_20 = $metadatas["metadata_20"]; } if (array_key_exists("metadata_21", $metadatas)) { $data->metadata_21 = $metadatas["metadata_21"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_22 = $metadatas["metadata_22"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_23 = $metadatas["metadata_"]; } if (array_key_exists("metadata_24", $metadatas)) { $data->metadata_24 = $metadatas["metadata_"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_25 = $metadatas["metadata_"]; } if (array_key_exists("metadata_26", $metadatas)) { $data->metadata_26 = $metadatas["metadata_"]; } if (array_key_exists("metadata_27", $metadatas)) { $data->metadata_27 = $metadatas["metadata_27"]; } if (array_key_exists("metadata_28", $metadatas)) { $data->metadata_28 = $metadatas["metadata_28"]; } if (array_key_exists("metadata_29", $metadatas)) { $data->metadata_29 = $metadatas["metadata_29"]; } if (array_key_exists("metadata_30", $metadatas)) { $data->metadata_30 = $metadatas["metadata_"]; } if (array_key_exists("metadata_31", $metadatas)) { $data->metadata_31 = $metadatas["metadata_"]; } if (array_key_exists("metadata_32", $metadatas)) { $data->metadata_32 = $metadatas["metadata_32"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_33 = $metadatas["metadata_"]; } if (array_key_exists("metadata_34", $metadatas)) { $data->metadata_34 = $metadatas["metadata_34"]; } if (array_key_exists("metadata_35", $metadatas)) { $data->metadata_35 = $metadatas["metadata_35"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_36 = $metadatas["metadata_36"]; } if (array_key_exists("metadata_37", $metadatas)) { $data->metadata_37 = $metadatas["metadata_"]; } if (array_key_exists("metadata_38", $metadatas)) { $data->metadata_38 = $metadatas["metadata_38"]; } if (array_key_exists("metadata_39", $metadatas)) { $data->metadata_39 = $metadatas["metadata_39"]; } if (array_key_exists("metadata_40", $metadatas)) { $data->metadata_40 = $metadatas["metadata_40"]; } if (array_key_exists("metadata_41", $metadatas)) { $data->metadata_41 = $metadatas["metadata_"]; } if (array_key_exists("metadata_42", $metadatas)) { $data->metadata_42 = $metadatas["metadata_42"]; } if (array_key_exists("metadata_43", $metadatas)) { $data->metadata_43 = $metadatas["metadata_43"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_44 = $metadatas["metadata_44"]; } if (array_key_exists("metadata_45", $metadatas)) { $data->metadata_45 = $metadatas["metadata_"]; } if (array_key_exists("metadata_46", $metadatas)) { $data->metadata_46 = $metadatas["metadata_46"]; } if (array_key_exists("metadata_47", $metadatas)) { $data->metadata_47 = $metadatas["metadata_"]; } if (array_key_exists("metadata_48", $metadatas)) { $data->metadata_48 = $metadatas["metadata_48"]; } if (array_key_exists("metadata_49", $metadatas)) { $data->metadata_49 = $metadatas["metadata_49"]; } if (array_key_exists("metadata_50", $metadatas)) { $data->metadata_50 = $metadatas["metadata_50"]; } $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); if ($columnArchive) { $data = new Model8(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_03" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_04" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_06" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_07" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->archive_11 = $columnArchive == "archive_11" ? $archive : ''; $data->archive_12 = $columnArchive == "archive_12" ? $archive : ''; $data->archive_13 = $columnArchive == "archive_13" ? $archive : ''; $data->archive_14 = $columnArchive == "archive_14" ? $archive : ''; $data->archive_15 = $columnArchive == "archive_15" ? $archive : ''; $data->archive_16 = $columnArchive == "archive_" ? $archive : ''; $data->archive_17 = $columnArchive == "archive_" ? $archive : ''; $data->archive_18 = $columnArchive == "archive_18" ? $archive : ''; $data->archive_19 = $columnArchive == "archive_19" ? $archive : ''; $data->archive_20 = $columnArchive == "archive_20" ? $archive : ''; $data->archive_21 = $columnArchive == "archive_" ? $archive : ''; $data->archive_22 = $columnArchive == "archive_22" ? $archive : ''; $data->archive_23 = $columnArchive == "archive_" ? $archive : ''; $data->archive_24 = $columnArchive == "archive_24" ? $archive : ''; $data->archive_25 = $columnArchive == "archive_25" ? $archive : ''; $data->archive_26 = $columnArchive == "archive_26" ? $archive : ''; $data->archive_27 = $columnArchive == "archive_27" ? $archive : ''; $data->archive_28 = $columnArchive == "archive_28" ? $archive : ''; $data->archive_29 = $columnArchive == "archive_29" ? $archive : ''; $data->archive_30 = $columnArchive == "archive_30" ? $archive : ''; $data->archive_31 = $columnArchive == "archive_" ? $archive : ''; $data->archive_32 = $columnArchive == "archive_32" ? $archive : ''; $data->archive_33 = $columnArchive == "archive_33" ? $archive : ''; $data->archive_34 = $columnArchive == "archive_" ? $archive : ''; $data->archive_35 = $columnArchive == "archive_35" ? $archive : ''; $data->archive_36 = $columnArchive == "archive_" ? $archive : ''; $data->archive_37 = $columnArchive == "archive_37" ? $archive : ''; $data->archive_38 = $columnArchive == "archive_38" ? $archive : ''; $data->archive_39 = $columnArchive == "archive_39" ? $archive : ''; $data->archive_40 = $columnArchive == "archive_40" ? $archive : ''; $data->archive_41 = $columnArchive == "archive_41" ? $archive : ''; $data->archive_42 = $columnArchive == "archive_42" ? $archive : ''; $data->archive_43 = $columnArchive == "archive_43" ? $archive : ''; $data->archive_44 = $columnArchive == "archive_44" ? $archive : ''; $data->archive_45 = $columnArchive == "archive_45" ? $archive : ''; $data->archive_46 = $columnArchive == "archive_46" ? $archive : ''; $data->archive_47 = $columnArchive == "archive_" ? $archive : ''; $data->archive_48 = $columnArchive == "archive_48" ? $archive : ''; $data->archive_49 = $columnArchive == "archive_49" ? $archive : ''; $data->archive_50 = $columnArchive == "archive_" ? $archive : ''; $data->register_id = $id; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model6(); $data->action = "Actualización"; $data->register_id = $id; $data->user_id = Helper::getAuth()->id; $data->save(); } private function register($metadatas, $category_id, $archive, $columnArchive) { $data = new Model2(); $data->metadata_01 = array_key_exists("metadata_01", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_02 = array_key_exists("metadata_02", $metadatas) ? $metadatas["metadata_02"] : ''; $data->metadata_03 = array_key_exists("metadata_03", $metadatas) ? $metadatas["metadata_03"] : ''; $data->metadata_04 = array_key_exists("metadata_04", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_05 = array_key_exists("metadata_05", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_06 = array_key_exists("metadata_06", $metadatas) ? $metadatas["metadata_06"] : ''; $data->metadata_07 = array_key_exists("metadata_07", $metadatas) ? $metadatas["metadata_07"] : ''; $data->metadata_08 = array_key_exists("metadata_08", $metadatas) ? $metadatas["metadata_08"] : ''; $data->metadata_09 = array_key_exists("metadata_09", $metadatas) ? $metadatas["metadata_09"] : ''; $data->metadata_10 = array_key_exists("metadata_10", $metadatas) ? $metadatas["metadata_10"] : ''; $data->metadata_11 = array_key_exists("metadata_11", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_12 = array_key_exists("metadata_12", $metadatas) ? $metadatas["metadata_12"] : ''; $data->metadata_13 = array_key_exists("metadata_13", $metadatas) ? $metadatas["metadata_13"] : ''; $data->metadata_14 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_15 = array_key_exists("metadata_15", $metadatas) ? $metadatas["metadata_15"] : ''; $data->metadata_16 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_17 = array_key_exists("metadata_17", $metadatas) ? $metadatas["metadata_17"] : ''; $data->metadata_18 = array_key_exists("metadata_18", $metadatas) ? $metadatas["metadata_18"] : ''; $data->metadata_19 = array_key_exists("metadata_19", $metadatas) ? $metadatas["metadata_19"] : ''; $data->metadata_20 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_20"] : ''; $data->metadata_21 = array_key_exists("metadata_21", $metadatas) ? $metadatas["metadata_21"] : ''; $data->metadata_22 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_22"] : ''; $data->metadata_23 = array_key_exists("metadata_23", $metadatas) ? $metadatas["metadata_23"] : ''; $data->metadata_24 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_24"] : ''; $data->metadata_25 = array_key_exists("metadata_25", $metadatas) ? $metadatas["metadata_25"] : ''; $data->metadata_26 = array_key_exists("metadata_26", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_27 = array_key_exists("metadata_27", $metadatas) ? $metadatas["metadata_27"] : ''; $data->metadata_28 = array_key_exists("metadata_28", $metadatas) ? $metadatas["metadata_28"] : ''; $data->metadata_29 = array_key_exists("metadata_29", $metadatas) ? $metadatas["metadata_29"] : ''; $data->metadata_30 = array_key_exists("metadata_30", $metadatas) ? $metadatas["metadata_30"] : ''; $data->metadata_31 = array_key_exists("metadata_31", $metadatas) ? $metadatas["metadata_31"] : ''; $data->metadata_32 = array_key_exists("metadata_32", $metadatas) ? $metadatas["metadata_32"] : ''; $data->metadata_33 = array_key_exists("metadata_33", $metadatas) ? $metadatas["metadata_33"] : ''; $data->metadata_34 = array_key_exists("metadata_34", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_35 = array_key_exists("metadata_35", $metadatas) ? $metadatas["metadata_35"] : ''; $data->metadata_36 = array_key_exists("metadata_36", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_37 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_37"] : ''; $data->metadata_38 = array_key_exists("metadata_38", $metadatas) ? $metadatas["metadata_38"] : ''; $data->metadata_39 = array_key_exists("metadata_39", $metadatas) ? $metadatas["metadata_39"] : ''; $data->metadata_40 = array_key_exists("metadata_40", $metadatas) ? $metadatas["metadata_40"] : ''; $data->metadata_41 = array_key_exists("metadata_41", $metadatas) ? $metadatas["metadata_41"] : ''; $data->metadata_42 = array_key_exists("metadata_42", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_43 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_43"] : ''; $data->metadata_44 = array_key_exists("metadata_44", $metadatas) ? $metadatas["metadata_44"] : ''; $data->metadata_45 = array_key_exists("metadata_45", $metadatas) ? $metadatas["metadata_45"] : ''; $data->metadata_46 = array_key_exists("metadata_46", $metadatas) ? $metadatas["metadata_46"] : ''; $data->metadata_47 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_47"] : ''; $data->metadata_48 = array_key_exists("metadata_48", $metadatas) ? $metadatas["metadata_48"] : ''; $data->metadata_49 = array_key_exists("metadata_49", $metadatas) ? $metadatas["metadata_49"] : ''; $data->metadata_50 = array_key_exists("metadata_50", $metadatas) ? $metadatas["metadata_50"] : ''; $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); $IdRegister = $data->id; if ($columnArchive) { $data = new Model8(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_03" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_06" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_07" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->archive_11 = $columnArchive == "archive_11" ? $archive : ''; $data->archive_12 = $columnArchive == "archive_12" ? $archive : ''; $data->archive_13 = $columnArchive == "archive_13" ? $archive : ''; $data->archive_14 = $columnArchive == "archive_14" ? $archive : ''; $data->archive_15 = $columnArchive == "archive_15" ? $archive : ''; $data->archive_16 = $columnArchive == "archive_" ? $archive : ''; $data->archive_17 = $columnArchive == "archive_17" ? $archive : ''; $data->archive_18 = $columnArchive == "archive_18" ? $archive : ''; $data->archive_19 = $columnArchive == "archive_19" ? $archive : ''; $data->archive_20 = $columnArchive == "archive_20" ? $archive : ''; $data->archive_21 = $columnArchive == "archive_21" ? $archive : ''; $data->archive_22 = $columnArchive == "archive_22" ? $archive : ''; $data->archive_23 = $columnArchive == "archive_23" ? $archive : ''; $data->archive_24 = $columnArchive == "archive_" ? $archive : ''; $data->archive_25 = $columnArchive == "archive_25" ? $archive : ''; $data->archive_26 = $columnArchive == "archive_26" ? $archive : ''; $data->archive_27 = $columnArchive == "archive_27" ? $archive : ''; $data->archive_28 = $columnArchive == "archive_28" ? $archive : ''; $data->archive_29 = $columnArchive == "archive_29" ? $archive : ''; $data->archive_30 = $columnArchive == "archive_30" ? $archive : ''; $data->archive_31 = $columnArchive == "archive_31" ? $archive : ''; $data->archive_32 = $columnArchive == "archive_32" ? $archive : ''; $data->archive_33 = $columnArchive == "archive_33" ? $archive : ''; $data->archive_34 = $columnArchive == "archive_34" ? $archive : ''; $data->archive_35 = $columnArchive == "archive_35" ? $archive : ''; $data->archive_36 = $columnArchive == "archive_36" ? $archive : ''; $data->archive_37 = $columnArchive == "archive_37" ? $archive : ''; $data->archive_38 = $columnArchive == "archive_38" ? $archive : ''; $data->archive_39 = $columnArchive == "archive_39" ? $archive : ''; $data->archive_40 = $columnArchive == "archive_40" ? $archive : ''; $data->archive_41 = $columnArchive == "archive_41" ? $archive : ''; $data->archive_42 = $columnArchive == "archive_42" ? $archive : ''; $data->archive_43 = $columnArchive == "archive_" ? $archive : ''; $data->archive_44 = $columnArchive == "archive_44" ? $archive : ''; $data->archive_45 = $columnArchive == "archive_45" ? $archive : ''; $data->archive_46 = $columnArchive == "archive_46" ? $archive : ''; $data->archive_47 = $columnArchive == "archive_47" ? $archive : ''; $data->archive_48 = $columnArchive == "archive_48" ? $archive : ''; $data->archive_49 = $columnArchive == "archive_49" ? $archive : ''; $data->archive_50 = $columnArchive == "archive_50" ? $archive : ''; $data->register_id = $IdRegister; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model6(); $data->register_id = $IdRegister; $data->user_id = Helper::getAuth()->id; $data->save(); return $IdRegister; } private function transformProperty($string) { if ($string[1] == "Creditos" || $string[1] == "creditos") { $string[1] = "Captaciones"; } if (Helper::transformString($string[4]) == "envio giros exterior") { for ($i = 5; $i < count($string); $i++) { if (!(strrpos(Helper::transformString($string[$i]), "nit") === false)) { $string[4] = "Solicitud de Giro PJ"; break; } elseif (!(strrpos(Helper::transformString($string[$i]), "documento de identidad") === false)) { $string[4] = "Solicitud de Giro"; break; } } } return $string; } }

namespace App\Http\Controllers; use App\Helpers\Helper; use Illuminate\Http\Request; use App\Models\FirstDocumentaryGroup as Model1; use App\Models\Registers as Model2; use App\Models\Error as Model3; use App\Models\ErrorsDetail as Model4; use App\Models\LogFirstHistory as Model5; use App\Models\LogHistory as Model6; use App\Models\fdgArchives as Model7; use App\Models\fdgRegisters as Model8; use App\Models\Scanned as Model9; use Illuminate\Support\Facades\DB; class MassiveImportController extends Controller {
private $metadata_base = "metadata_27";
private $metadata_reference = "metadata_29";
public function index() { $credentials = Helper::getAuthAvatar(); $data = array("user" => $credentials, "permissions" => Helper::getObfuscateAreas($credentials), "categories" => Helper::getObfuscateCategories($credentials)); return view("modulesmassive-importindex")->with($data); } public function store(Request $request) { $request->validate(array("archives.*" => "required|max:" . config("globalMAX_SIZE_DOC") . "|mimes:pdf")); $errors = array(); $files = array(); $scanned = 0; foreach ($request->file("archives") as $archive) { if ($archive->getClientOriginalExtension() == "pdf") { $res = Helper::processPdf($archive, $archive->getPathName(), $archive->getClientOriginalName()); $scanned += $res["scanned"]; if (count($res["files"]) > 0) { for ($i = 0; $i < count($res["files"]); $i++) { $res["files"][$i]["previous"] = $archive->getClientOriginalName(); $files[] = $res["files"][$i]; } } if (count($res["errors"]) > 0) { for ($i = 0; $i < count($res["errors"]); $i++) { $errors[] = $res["errors"][$i]; } } } } $date = date("Y-m-d"); $successful = count($files); $response = Model9::where("date", $date)->get(array("id", "successful", "scanned"))->first(); if ($response) { $data = Model9::find($response->id); $data->successful = $response->successful + $successful; $data->scanned = $response->scanned + $scanned; $data->save(); } else { $data = new Model9(); $data->successful = $successful; $data->scanned = $scanned; $data->date = $date; $data->save(); } if (count($files) > 0) { foreach ($files as $index => $file) { $archiveName = $file["name"]; $archivePrevious = $file["previous"]; $prince = str_replace("CONTENT:", '', $file["text"]); $prince = str_replace("CONTENT :", '', $prince); $prince = explode("||", $prince);  foreach ($prince as $subdata) { $subdata = trim($subdata); if (strpos($subdata, "Codigo de cliente del garante") !== false) { for ($i = 0; $i < count($aux); $i++) { $aux[$i] .= " | {$subdata}"; } } else { $aux[] = $subdata; } } $prince = $aux; $map = array(); foreach ($prince as $subdata) { $subdata = explode("|", $subdata);  $map[] = "a"; unset($aux); } foreach ($prince as $indice => $subdata) { $subdata = explode("|", $subdata);  $data = DB::table("categories AS c")->leftJoin("areas AS a", "aid", "=", "carea_id")->where("aarea", trim("a"))->where("ccategory", trim("r"))->where("cstate", "Activo")->get(array("cid", "structure"))->first(); $grupoDocumental = Helper::transformString("r"); $identificador = "a"; $archivo = Helper::transformString("y"); $namePosition = strtolower("r"); unset("a", "r", "r", "a", "y");  if ($data) { $category_id = $data->id; $data->structure = json_decode($data->structure); $generalData = $data->structure; $temp = $aux; $auxData = array(); foreach ($temp as $sub_temp) {  $alias = Helper::transformString("a"); if (isset("r")) { if (preg_match("/^([0-9]|([0-3][0-9]))(\/|-)([0-9]|([0-3][0-9]))(\/|-)([0-9]{4})([ -p-9:;A-Za-zÁÉÍÑÓÚáéíñóú]{0a4})$/", trim("r"))) {   "r" = str_pad((string) "r", 2, "0", STR_PAD_LEFT); "a" = str_pad((string) "a", 2, "0", STR_PAD_LEFT);  if (isset("r") && preg_match("/^([0i][0-9]|2[0-9]):[0-5][0-9]:[0-5][0-9]$/", "r")) { $tempDate .= " {"r"}"; } else { $tempDate .= " 000:00"; } $auxData[$alias] = $tempDate; } else { $auxData[$alias] = trim("r"); } } } unset($temp, $aux); $aux_files = array(); $aux_metadatas = array(); foreach ($generalData as $details) { $aux_submetadatas = array(); foreach ($details->metadatas as $subdetails) { $aux_submetadatas[] = Helper::transformString($subdetails->metadata); } $aux_metadatas[Helper::transformString($details->title)] = $aux_submetadatas; $aux_subfiles = array(); foreach ($details->files as $subdetails) { $aux_subfiles[] = Helper::transformString($subdetails->metadata); } $aux_files[Helper::transformString($details->title)] = $aux_subfiles; } $count = 0; $positionx = false; foreach ($aux_files as $aux) { if (in_array($archivo, $aux)) { $positionx = $count; } $count++; } if (isset($aux_files[$grupoDocumental]) && in_array($archivo, $aux_files[$grupoDocumental])) { $positiony = array_search($archivo, $aux_files[$grupoDocumental]); if ($positionx !== false && $positiony !== false) { if ($positionx == 0) { $archivoPosition = "archive_" . str_pad($positiony + 1, 2, "0", STR_PAD_LEFT); $valores = array(); foreach ($auxData as $key => $data) { $position = array_search($key, $aux_metadatas[$grupoDocumental]); if ($position !== false) { $index = str_pad($position + 1, 2, "0", STR_PAD_LEFT); $valores["metadata_" . $index] = $data; unset($aux[$key]); } } $query = DB::table("first_documentary_groups")->where("state", "Activo")->where("category_id", $category_id)->where("metadata_01", $identificador)->get(array("id"))->first(); if ($query) { $idFirst = $query->id; $this->updateFirst($query->id, $valores, $category_id, $archiveName, $archivoPosition); } else { $idFirst = $this->registerFirst($identificador, $valores, $category_id, $archiveName, $archivoPosition); } } else { $auxCount = 0; $auxFiles = $aux_files; array_shift($auxFiles); foreach ($auxFiles as $name => $aux) { foreach ($aux as $subAux) { $auxCount++; if ($namePosition == $name && $subAux == $archivo) { $archivoPosition = "archive_" . str_pad($auxCount, 2, "0", STR_PAD_LEFT); } } } $valoresP = array(); $valuesMetadatas = array_values($aux_metadatas); foreach ($auxData as $key => $data) { $position = array_search($key, "a"); if ($position !== false) { $index = str_pad($position + 1, 2, "0", STR_PAD_LEFT); $valoresP["metadata_" . $index] = $data; unset($auxData[$key]); } } array_shift($aux_metadatas); $valuesMetadatas = array_values($valuesMetadatas); $valoresS = array(); $count = 0; foreach ($aux_metadatas as $key => $aux) { foreach ($aux as $subkey => $subaux) { $count++; if ($key == $grupoDocumental && isset($auxData[$subaux])) { $index = str_pad($count, 2, "0", STR_PAD_LEFT); $valoresS["metadata_" . $index] = $auxData[$subaux]; unset($auxData[$subaux]); } } } $query = DB::table("first_documentary_groups")->where("state", "Activo")->where("category_id", $category_id)->where("metadata_01", $identificador)->get(array("id"))->first(); if ($query) { $idFirst = $query->id; $this->updateFirst($query->id, $valoresP, $category_id, $archiveName, false); } else { $idFirst = $this->registerFirst($identificador, $valoresP, $category_id, $archiveName, false); } $alias = ''; foreach ($valoresS as $key => $data) { $alias = $key; break; } $query = DB::table("registers AS r"); $query->leftJoin("relations AS rl", "rlregister_id", "=", "rid"); $query->where("rstate", "Activo"); $query->where("rlstate", "Activo"); $query->where("rcategory_id", $category_id); $query->where("r." . $alias, $valoresS[$alias]); if ($this->metadata_base == $alias) { $query->where("r." . $this->metadata_reference, $valoresS[$this->metadata_reference]); } $query = $query->get(array("rid"))->first(); if ($query) { $idRegister = $query->id; $this->update($idRegister, $valoresS, $category_id, $archiveName, $archivoPosition); } else { $idRegister = $this->register($valoresS, $category_id, $archiveName, $archivoPosition); } $query = DB::table("relations")->where("state", "Activo")->where("first_documentary_group_id", $idFirst)->where("register_id", $idRegister)->get(array("id"))->first(); if (!$query) { $fecha = date("Y-m-d H:i:s"); DB::insert("INSERT INTO relations(user_id,first_documentary_group_id,register_id,created_at,updated_at)VALUES(?,?,?,?,?)", array(Helper::getAuth()->id, $idFirst, $idRegister, $fecha, $fecha)); } } } } else { $anterior = base_path() . Helper::getRouteDocument() . date("Y-m-d") . "/" . $archiveName; if (file_exists($anterior)) { $previousName = substr($archivePrevious, 0, -4) . "_" . uniqid() . ".pdf"; $nuevo = base_path() . Helper::getRouteError() . $previousName; rename($anterior, $nuevo); $errors[] = array("name" => $previousName, "message" => "No existe este tipo de documento o categoría"); } } } else { $anterior = base_path() . Helper::getRouteDocument() . date("Y-m-d") . "/" . $archiveName; if (file_exists($anterior)) { $previousName = substr($archivePrevious, 0, -4) . "_" . uniqid() . ".pdf"; $nuevo = base_path() . Helper::getRouteError() . $previousName; rename($anterior, $nuevo); $errors[] = array("name" => $previousName, "message" => "No existe este tipo de documento o categoría"); } } } } } if (count($errors) > 0) { $data = new Model3(); $data->user_id = Helper::getAuth()->id; $data->save(); $IdError = $data->id; foreach ($errors as $index => $error) { $data = new Model4(); $data->archive = $error["name"]; $data->error = $error["message"]; $data->error_id = $IdError; $data->save(); } $response = "<b>Importaciones realizadas exitosamente</b><br><b>No se subio " . count($errors) . " archivos</b>"; } else { $response = "<b>Importaciones realizadas exitosamente</b>"; } unset($error); return redirect("/massive-import")->with("import", $response); } private function updateFirst($id, $metadatas, $category_id, $archive, $columnArchive) { $data = Model1::find($id); if (array_key_exists("metadata_01", $metadatas)) { $data->metadata_01 = $metadatas["metadata_"]; } if (array_key_exists("metadata_02", $metadatas)) { $data->metadata_02 = $metadatas["metadata_02"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_03 = $metadatas["metadata_03"]; } if (array_key_exists("metadata_04", $metadatas)) { $data->metadata_04 = $metadatas["metadata_"]; } if (array_key_exists("metadata_05", $metadatas)) { $data->metadata_05 = $metadatas["metadata_05"]; } if (array_key_exists("metadata_06", $metadatas)) { $data->metadata_06 = $metadatas["metadata_06"]; } if (array_key_exists("metadata_07", $metadatas)) { $data->metadata_07 = $metadatas["metadata_07"]; } if (array_key_exists("metadata_08", $metadatas)) { $data->metadata_08 = $metadatas["metadata_08"]; } if (array_key_exists("metadata_09", $metadatas)) { $data->metadata_09 = $metadatas["metadata_09"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_10 = $metadatas["metadata_10"]; } $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); if ($columnArchive) { $data = new Model7(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_04" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_06" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->first_documentary_group_id = $id; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model5(); $data->action = "Actualización"; $data->first_documentary_group_id = $id; $data->user_id = Helper::getAuth()->id; $data->save(); } private function registerFirst($identifier, $metadatas, $category_id, $archive, $columnArchive) { $data = new Model1(); $data->metadata_01 = array_key_exists("metadata_01", $metadatas) ? $metadatas["metadata_01"] : $identifier; $data->metadata_02 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_02"] : ''; $data->metadata_03 = array_key_exists("metadata_03", $metadatas) ? $metadatas["metadata_03"] : ''; $data->metadata_04 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_04"] : ''; $data->metadata_05 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_05"] : ''; $data->metadata_06 = array_key_exists("metadata_06", $metadatas) ? $metadatas["metadata_06"] : ''; $data->metadata_07 = array_key_exists("metadata_07", $metadatas) ? $metadatas["metadata_07"] : ''; $data->metadata_08 = array_key_exists("metadata_08", $metadatas) ? $metadatas["metadata_08"] : ''; $data->metadata_09 = array_key_exists("metadata_09", $metadatas) ? $metadatas["metadata_09"] : ''; $data->metadata_10 = array_key_exists("metadata_10", $metadatas) ? $metadatas["metadata_10"] : ''; $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); $IdRegister = $data->id; if ($columnArchive !== false) { $data = new Model7(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_03" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_04" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_07" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->first_documentary_group_id = $IdRegister; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model5(); $data->first_documentary_group_id = $IdRegister; $data->user_id = Helper::getAuth()->id; $data->save(); return $IdRegister; } private function update($id, $metadatas, $category_id, $archive, $columnArchive) { $data = Model2::find($id); if (array_key_exists("metadata_01", $metadatas)) { $data->metadata_01 = $metadatas["metadata_"]; } if (array_key_exists("metadata_02", $metadatas)) { $data->metadata_02 = $metadatas["metadata_"]; } if (array_key_exists("metadata_03", $metadatas)) { $data->metadata_03 = $metadatas["metadata_03"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_04 = $metadatas["metadata_04"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_05 = $metadatas["metadata_05"]; } if (array_key_exists("metadata_06", $metadatas)) { $data->metadata_06 = $metadatas["metadata_06"]; } if (array_key_exists("metadata_07", $metadatas)) { $data->metadata_07 = $metadatas["metadata_07"]; } if (array_key_exists("metadata_08", $metadatas)) { $data->metadata_08 = $metadatas["metadata_08"]; } if (array_key_exists("metadata_09", $metadatas)) { $data->metadata_09 = $metadatas["metadata_09"]; } if (array_key_exists("metadata_10", $metadatas)) { $data->metadata_10 = $metadatas["metadata_"]; } if (array_key_exists("metadata_11", $metadatas)) { $data->metadata_11 = $metadatas["metadata_11"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_12 = $metadatas["metadata_"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_13 = $metadatas["metadata_"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_14 = $metadatas["metadata_14"]; } if (array_key_exists("metadata_15", $metadatas)) { $data->metadata_15 = $metadatas["metadata_15"]; } if (array_key_exists("metadata_16", $metadatas)) { $data->metadata_16 = $metadatas["metadata_16"]; } if (array_key_exists("metadata_17", $metadatas)) { $data->metadata_17 = $metadatas["metadata_"]; } if (array_key_exists("metadata_18", $metadatas)) { $data->metadata_18 = $metadatas["metadata_18"]; } if (array_key_exists("metadata_19", $metadatas)) { $data->metadata_19 = $metadatas["metadata_19"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_20 = $metadatas["metadata_20"]; } if (array_key_exists("metadata_21", $metadatas)) { $data->metadata_21 = $metadatas["metadata_21"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_22 = $metadatas["metadata_22"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_23 = $metadatas["metadata_"]; } if (array_key_exists("metadata_24", $metadatas)) { $data->metadata_24 = $metadatas["metadata_"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_25 = $metadatas["metadata_"]; } if (array_key_exists("metadata_26", $metadatas)) { $data->metadata_26 = $metadatas["metadata_"]; } if (array_key_exists("metadata_27", $metadatas)) { $data->metadata_27 = $metadatas["metadata_27"]; } if (array_key_exists("metadata_28", $metadatas)) { $data->metadata_28 = $metadatas["metadata_28"]; } if (array_key_exists("metadata_29", $metadatas)) { $data->metadata_29 = $metadatas["metadata_29"]; } if (array_key_exists("metadata_30", $metadatas)) { $data->metadata_30 = $metadatas["metadata_"]; } if (array_key_exists("metadata_31", $metadatas)) { $data->metadata_31 = $metadatas["metadata_"]; } if (array_key_exists("metadata_32", $metadatas)) { $data->metadata_32 = $metadatas["metadata_32"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_33 = $metadatas["metadata_"]; } if (array_key_exists("metadata_34", $metadatas)) { $data->metadata_34 = $metadatas["metadata_34"]; } if (array_key_exists("metadata_35", $metadatas)) { $data->metadata_35 = $metadatas["metadata_35"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_36 = $metadatas["metadata_36"]; } if (array_key_exists("metadata_37", $metadatas)) { $data->metadata_37 = $metadatas["metadata_"]; } if (array_key_exists("metadata_38", $metadatas)) { $data->metadata_38 = $metadatas["metadata_38"]; } if (array_key_exists("metadata_39", $metadatas)) { $data->metadata_39 = $metadatas["metadata_39"]; } if (array_key_exists("metadata_40", $metadatas)) { $data->metadata_40 = $metadatas["metadata_40"]; } if (array_key_exists("metadata_41", $metadatas)) { $data->metadata_41 = $metadatas["metadata_"]; } if (array_key_exists("metadata_42", $metadatas)) { $data->metadata_42 = $metadatas["metadata_42"]; } if (array_key_exists("metadata_43", $metadatas)) { $data->metadata_43 = $metadatas["metadata_43"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_44 = $metadatas["metadata_44"]; } if (array_key_exists("metadata_45", $metadatas)) { $data->metadata_45 = $metadatas["metadata_"]; } if (array_key_exists("metadata_46", $metadatas)) { $data->metadata_46 = $metadatas["metadata_46"]; } if (array_key_exists("metadata_47", $metadatas)) { $data->metadata_47 = $metadatas["metadata_"]; } if (array_key_exists("metadata_48", $metadatas)) { $data->metadata_48 = $metadatas["metadata_48"]; } if (array_key_exists("metadata_49", $metadatas)) { $data->metadata_49 = $metadatas["metadata_49"]; } if (array_key_exists("metadata_50", $metadatas)) { $data->metadata_50 = $metadatas["metadata_50"]; } $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); if ($columnArchive) { $data = new Model8(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_03" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_04" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_06" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_07" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->archive_11 = $columnArchive == "archive_11" ? $archive : ''; $data->archive_12 = $columnArchive == "archive_12" ? $archive : ''; $data->archive_13 = $columnArchive == "archive_13" ? $archive : ''; $data->archive_14 = $columnArchive == "archive_14" ? $archive : ''; $data->archive_15 = $columnArchive == "archive_15" ? $archive : ''; $data->archive_16 = $columnArchive == "archive_" ? $archive : ''; $data->archive_17 = $columnArchive == "archive_" ? $archive : ''; $data->archive_18 = $columnArchive == "archive_18" ? $archive : ''; $data->archive_19 = $columnArchive == "archive_19" ? $archive : ''; $data->archive_20 = $columnArchive == "archive_20" ? $archive : ''; $data->archive_21 = $columnArchive == "archive_" ? $archive : ''; $data->archive_22 = $columnArchive == "archive_22" ? $archive : ''; $data->archive_23 = $columnArchive == "archive_" ? $archive : ''; $data->archive_24 = $columnArchive == "archive_24" ? $archive : ''; $data->archive_25 = $columnArchive == "archive_25" ? $archive : ''; $data->archive_26 = $columnArchive == "archive_26" ? $archive : ''; $data->archive_27 = $columnArchive == "archive_27" ? $archive : ''; $data->archive_28 = $columnArchive == "archive_28" ? $archive : ''; $data->archive_29 = $columnArchive == "archive_29" ? $archive : ''; $data->archive_30 = $columnArchive == "archive_30" ? $archive : ''; $data->archive_31 = $columnArchive == "archive_" ? $archive : ''; $data->archive_32 = $columnArchive == "archive_32" ? $archive : ''; $data->archive_33 = $columnArchive == "archive_33" ? $archive : ''; $data->archive_34 = $columnArchive == "archive_" ? $archive : ''; $data->archive_35 = $columnArchive == "archive_35" ? $archive : ''; $data->archive_36 = $columnArchive == "archive_" ? $archive : ''; $data->archive_37 = $columnArchive == "archive_37" ? $archive : ''; $data->archive_38 = $columnArchive == "archive_38" ? $archive : ''; $data->archive_39 = $columnArchive == "archive_39" ? $archive : ''; $data->archive_40 = $columnArchive == "archive_40" ? $archive : ''; $data->archive_41 = $columnArchive == "archive_41" ? $archive : ''; $data->archive_42 = $columnArchive == "archive_42" ? $archive : ''; $data->archive_43 = $columnArchive == "archive_43" ? $archive : ''; $data->archive_44 = $columnArchive == "archive_44" ? $archive : ''; $data->archive_45 = $columnArchive == "archive_45" ? $archive : ''; $data->archive_46 = $columnArchive == "archive_46" ? $archive : ''; $data->archive_47 = $columnArchive == "archive_" ? $archive : ''; $data->archive_48 = $columnArchive == "archive_48" ? $archive : ''; $data->archive_49 = $columnArchive == "archive_49" ? $archive : ''; $data->archive_50 = $columnArchive == "archive_" ? $archive : ''; $data->register_id = $id; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model6(); $data->action = "Actualización"; $data->register_id = $id; $data->user_id = Helper::getAuth()->id; $data->save(); } private function register($metadatas, $category_id, $archive, $columnArchive) { $data = new Model2(); $data->metadata_01 = array_key_exists("metadata_01", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_02 = array_key_exists("metadata_02", $metadatas) ? $metadatas["metadata_02"] : ''; $data->metadata_03 = array_key_exists("metadata_03", $metadatas) ? $metadatas["metadata_03"] : ''; $data->metadata_04 = array_key_exists("metadata_04", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_05 = array_key_exists("metadata_05", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_06 = array_key_exists("metadata_06", $metadatas) ? $metadatas["metadata_06"] : ''; $data->metadata_07 = array_key_exists("metadata_07", $metadatas) ? $metadatas["metadata_07"] : ''; $data->metadata_08 = array_key_exists("metadata_08", $metadatas) ? $metadatas["metadata_08"] : ''; $data->metadata_09 = array_key_exists("metadata_09", $metadatas) ? $metadatas["metadata_09"] : ''; $data->metadata_10 = array_key_exists("metadata_10", $metadatas) ? $metadatas["metadata_10"] : ''; $data->metadata_11 = array_key_exists("metadata_11", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_12 = array_key_exists("metadata_12", $metadatas) ? $metadatas["metadata_12"] : ''; $data->metadata_13 = array_key_exists("metadata_13", $metadatas) ? $metadatas["metadata_13"] : ''; $data->metadata_14 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_15 = array_key_exists("metadata_15", $metadatas) ? $metadatas["metadata_15"] : ''; $data->metadata_16 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_17 = array_key_exists("metadata_17", $metadatas) ? $metadatas["metadata_17"] : ''; $data->metadata_18 = array_key_exists("metadata_18", $metadatas) ? $metadatas["metadata_18"] : ''; $data->metadata_19 = array_key_exists("metadata_19", $metadatas) ? $metadatas["metadata_19"] : ''; $data->metadata_20 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_20"] : ''; $data->metadata_21 = array_key_exists("metadata_21", $metadatas) ? $metadatas["metadata_21"] : ''; $data->metadata_22 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_22"] : ''; $data->metadata_23 = array_key_exists("metadata_23", $metadatas) ? $metadatas["metadata_23"] : ''; $data->metadata_24 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_24"] : ''; $data->metadata_25 = array_key_exists("metadata_25", $metadatas) ? $metadatas["metadata_25"] : ''; $data->metadata_26 = array_key_exists("metadata_26", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_27 = array_key_exists("metadata_27", $metadatas) ? $metadatas["metadata_27"] : ''; $data->metadata_28 = array_key_exists("metadata_28", $metadatas) ? $metadatas["metadata_28"] : ''; $data->metadata_29 = array_key_exists("metadata_29", $metadatas) ? $metadatas["metadata_29"] : ''; $data->metadata_30 = array_key_exists("metadata_30", $metadatas) ? $metadatas["metadata_30"] : ''; $data->metadata_31 = array_key_exists("metadata_31", $metadatas) ? $metadatas["metadata_31"] : ''; $data->metadata_32 = array_key_exists("metadata_32", $metadatas) ? $metadatas["metadata_32"] : ''; $data->metadata_33 = array_key_exists("metadata_33", $metadatas) ? $metadatas["metadata_33"] : ''; $data->metadata_34 = array_key_exists("metadata_34", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_35 = array_key_exists("metadata_35", $metadatas) ? $metadatas["metadata_35"] : ''; $data->metadata_36 = array_key_exists("metadata_36", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_37 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_37"] : ''; $data->metadata_38 = array_key_exists("metadata_38", $metadatas) ? $metadatas["metadata_38"] : ''; $data->metadata_39 = array_key_exists("metadata_39", $metadatas) ? $metadatas["metadata_39"] : ''; $data->metadata_40 = array_key_exists("metadata_40", $metadatas) ? $metadatas["metadata_40"] : ''; $data->metadata_41 = array_key_exists("metadata_41", $metadatas) ? $metadatas["metadata_41"] : ''; $data->metadata_42 = array_key_exists("metadata_42", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_43 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_43"] : ''; $data->metadata_44 = array_key_exists("metadata_44", $metadatas) ? $metadatas["metadata_44"] : ''; $data->metadata_45 = array_key_exists("metadata_45", $metadatas) ? $metadatas["metadata_45"] : ''; $data->metadata_46 = array_key_exists("metadata_46", $metadatas) ? $metadatas["metadata_46"] : ''; $data->metadata_47 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_47"] : ''; $data->metadata_48 = array_key_exists("metadata_48", $metadatas) ? $metadatas["metadata_48"] : ''; $data->metadata_49 = array_key_exists("metadata_49", $metadatas) ? $metadatas["metadata_49"] : ''; $data->metadata_50 = array_key_exists("metadata_50", $metadatas) ? $metadatas["metadata_50"] : ''; $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); $IdRegister = $data->id; if ($columnArchive) { $data = new Model8(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_03" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_06" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_07" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->archive_11 = $columnArchive == "archive_11" ? $archive : ''; $data->archive_12 = $columnArchive == "archive_12" ? $archive : ''; $data->archive_13 = $columnArchive == "archive_13" ? $archive : ''; $data->archive_14 = $columnArchive == "archive_14" ? $archive : ''; $data->archive_15 = $columnArchive == "archive_15" ? $archive : ''; $data->archive_16 = $columnArchive == "archive_" ? $archive : ''; $data->archive_17 = $columnArchive == "archive_17" ? $archive : ''; $data->archive_18 = $columnArchive == "archive_18" ? $archive : ''; $data->archive_19 = $columnArchive == "archive_19" ? $archive : ''; $data->archive_20 = $columnArchive == "archive_20" ? $archive : ''; $data->archive_21 = $columnArchive == "archive_21" ? $archive : ''; $data->archive_22 = $columnArchive == "archive_22" ? $archive : ''; $data->archive_23 = $columnArchive == "archive_23" ? $archive : ''; $data->archive_24 = $columnArchive == "archive_" ? $archive : ''; $data->archive_25 = $columnArchive == "archive_25" ? $archive : ''; $data->archive_26 = $columnArchive == "archive_26" ? $archive : ''; $data->archive_27 = $columnArchive == "archive_27" ? $archive : ''; $data->archive_28 = $columnArchive == "archive_28" ? $archive : ''; $data->archive_29 = $columnArchive == "archive_29" ? $archive : ''; $data->archive_30 = $columnArchive == "archive_30" ? $archive : ''; $data->archive_31 = $columnArchive == "archive_31" ? $archive : ''; $data->archive_32 = $columnArchive == "archive_32" ? $archive : ''; $data->archive_33 = $columnArchive == "archive_33" ? $archive : ''; $data->archive_34 = $columnArchive == "archive_34" ? $archive : ''; $data->archive_35 = $columnArchive == "archive_35" ? $archive : ''; $data->archive_36 = $columnArchive == "archive_36" ? $archive : ''; $data->archive_37 = $columnArchive == "archive_37" ? $archive : ''; $data->archive_38 = $columnArchive == "archive_38" ? $archive : ''; $data->archive_39 = $columnArchive == "archive_39" ? $archive : ''; $data->archive_40 = $columnArchive == "archive_40" ? $archive : ''; $data->archive_41 = $columnArchive == "archive_41" ? $archive : ''; $data->archive_42 = $columnArchive == "archive_42" ? $archive : ''; $data->archive_43 = $columnArchive == "archive_" ? $archive : ''; $data->archive_44 = $columnArchive == "archive_44" ? $archive : ''; $data->archive_45 = $columnArchive == "archive_45" ? $archive : ''; $data->archive_46 = $columnArchive == "archive_46" ? $archive : ''; $data->archive_47 = $columnArchive == "archive_47" ? $archive : ''; $data->archive_48 = $columnArchive == "archive_48" ? $archive : ''; $data->archive_49 = $columnArchive == "archive_49" ? $archive : ''; $data->archive_50 = $columnArchive == "archive_50" ? $archive : ''; $data->register_id = $IdRegister; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model6(); $data->register_id = $IdRegister; $data->user_id = Helper::getAuth()->id; $data->save(); return $IdRegister; } private function transformProperty($string) { if ("r" == "Creditos" || "r" == "creditos") { "r" = "Captaciones"; } if (Helper::transformString("y") == "envio giros exterior") { for ($i = 5; $i < count($string); $i++) { if (!(strrpos(Helper::transformString($string[$i]), "nit") === false)) { "y" = "Solicitud de Giro PJ"; break; } elseif (!(strrpos(Helper::transformString($string[$i]), "documento de identidad") === false)) { "y" = "Solicitud de Giro"; break; } } } return $string; } }

namespace App\Http\Controllers; use App\Helpers\Helper; use Illuminate\Http\Request; use App\Models\FirstDocumentaryGroup as Model1; use App\Models\Registers as Model2; use App\Models\Error as Model3; use App\Models\ErrorsDetail as Model4; use App\Models\LogFirstHistory as Model5; use App\Models\LogHistory as Model6; use App\Models\fdgArchives as Model7; use App\Models\fdgRegisters as Model8; use App\Models\Scanned as Model9; use Illuminate\Support\Facades\DB; class MassiveImportController extends Controller {
private 
private 
public function index() { $credentials = Helper::getAuthAvatar(); $data = array("user" => $credentials, "permissions" => Helper::getObfuscateAreas($credentials), "categories" => Helper::getObfuscateCategories($credentials)); return view("modulesmassive-importindex")->with($data); } public function store(Request $request) { $request->validate(array("archives.*" => "required|max:" . config("globalMAX_SIZE_DOC") . "|mimes:pdf")); $errors = array(); $files = array(); $scanned = 0; foreach ($request->file("archives") as $archive) { if ($archive->getClientOriginalExtension() == "pdf") { $res = Helper::processPdf($archive, $archive->getPathName(), $archive->getClientOriginalName()); $scanned += $res["scanned"]; if (count($res["files"]) > 0) { for ($i = 0; $i < count($res["files"]); $i++) { $res["files"][$i]["previous"] = $archive->getClientOriginalName(); $files[] = $res["files"][$i]; } } if (count($res["errors"]) > 0) { for ($i = 0; $i < count($res["errors"]); $i++) { $errors[] = $res["errors"][$i]; } } } } $date = date("Y-m-d"); $successful = count($files); $response = Model9::where("date", $date)->get(array("id", "successful", "scanned"))->first(); if ($response) { $data = Model9::find($response->id); $data->successful = $response->successful + $successful; $data->scanned = $response->scanned + $scanned; $data->save(); } else { $data = new Model9(); $data->successful = $successful; $data->scanned = $scanned; $data->date = $date; $data->save(); } if (count($files) > 0) { foreach ($files as $index => $file) { $archiveName = $file["name"]; $archivePrevious = $file["previous"]; $prince = str_replace("CONTENT:", '', $file["text"]); $prince = str_replace("CONTENT :", '', $prince); $prince = explode("||", $prince);  foreach ($prince as $subdata) { $subdata = trim($subdata); if (strpos($subdata, "Codigo de cliente del garante") !== false) { for ($i = 0; $i < count($aux); $i++) { $aux[$i] .= " | {$subdata}"; } } else { $aux[] = $subdata; } } $prince = $aux; $map = array(); foreach ($prince as $subdata) { $subdata = explode("|", $subdata);  $map[] = "a"; unset($aux); } foreach ($prince as $indice => $subdata) { $subdata = explode("|", $subdata);  $data = DB::table("categories AS c")->leftJoin("areas AS a", "aid", "=", "carea_id")->where("aarea", trim("a"))->where("ccategory", trim("r"))->where("cstate", "Activo")->get(array("cid", "structure"))->first(); $grupoDocumental = Helper::transformString("r");  $archivo = Helper::transformString("y"); $namePosition = strtolower("r"); unset("a", "r", "r", "a", "y");  if ($data) { $category_id = $data->id; $data->structure = json_decode($data->structure); $generalData = $data->structure; $temp = $aux; $auxData = array(); foreach ($temp as $sub_temp) {  $alias = Helper::transformString("a"); if (isset("r")) { if (preg_match("/^([0-9]|([0-3][0-9]))(\/|-)([0-9]|([0-3][0-9]))(\/|-)([0-9]{4})([ -p-9:;A-Za-zÁÉÍÑÓÚáéíñóú]{0a4})$/", trim("r"))) {   "r" = str_pad((string) "r", 2, "0", STR_PAD_LEFT); "a" = str_pad((string) "a", 2, "0", STR_PAD_LEFT);  if (isset("r") && preg_match("/^([0i][0-9]|2[0-9]):[0-5][0-9]:[0-5][0-9]$/", "r")) { $tempDate .= " {"r"}"; } else { $tempDate .= " 000:00"; } $auxData[$alias] = $tempDate; } else { $auxData[$alias] = trim("r"); } } } unset($temp, $aux); $aux_files = array(); $aux_metadatas = array(); foreach ($generalData as $details) { $aux_submetadatas = array(); foreach ($details->metadatas as $subdetails) { $aux_submetadatas[] = Helper::transformString($subdetails->metadata); } $aux_metadatas[Helper::transformString($details->title)] = $aux_submetadatas; $aux_subfiles = array(); foreach ($details->files as $subdetails) { $aux_subfiles[] = Helper::transformString($subdetails->metadata); } $aux_files[Helper::transformString($details->title)] = $aux_subfiles; } $count = 0; $positionx = false; foreach ($aux_files as $aux) { if (in_array($archivo, $aux)) { $positionx = $count; } $count++; } if (isset($aux_files[$grupoDocumental]) && in_array($archivo, $aux_files[$grupoDocumental])) { $positiony = array_search($archivo, $aux_files[$grupoDocumental]); if ($positionx !== false && $positiony !== false) { if ($positionx == 0) { $archivoPosition = "archive_" . str_pad($positiony + 1, 2, "0", STR_PAD_LEFT); $valores = array(); foreach ($auxData as $key => $data) { $position = array_search($key, $aux_metadatas[$grupoDocumental]); if ($position !== false) { $index = str_pad($position + 1, 2, "0", STR_PAD_LEFT); $valores["metadata_" . $index] = $data; unset($aux[$key]); } } $query = DB::table("first_documentary_groups")->where("state", "Activo")->where("category_id", $category_id)->where("metadata_01", "a")->get(array("id"))->first(); if ($query) { $idFirst = $query->id; $this->updateFirst($query->id, $valores, $category_id, $archiveName, $archivoPosition); } else { $idFirst = $this->registerFirst("a", $valores, $category_id, $archiveName, $archivoPosition); } } else { $auxCount = 0; $auxFiles = $aux_files; array_shift($auxFiles); foreach ($auxFiles as $name => $aux) { foreach ($aux as $subAux) { $auxCount++; if ($namePosition == $name && $subAux == $archivo) { $archivoPosition = "archive_" . str_pad($auxCount, 2, "0", STR_PAD_LEFT); } } } $valoresP = array(); $valuesMetadatas = array_values($aux_metadatas); foreach ($auxData as $key => $data) { $position = array_search($key, "a"); if ($position !== false) { $index = str_pad($position + 1, 2, "0", STR_PAD_LEFT); $valoresP["metadata_" . $index] = $data; unset($auxData[$key]); } } array_shift($aux_metadatas); $valuesMetadatas = array_values($valuesMetadatas); $valoresS = array(); $count = 0; foreach ($aux_metadatas as $key => $aux) { foreach ($aux as $subkey => $subaux) { $count++; if ($key == $grupoDocumental && isset($auxData[$subaux])) { $index = str_pad($count, 2, "0", STR_PAD_LEFT); $valoresS["metadata_" . $index] = $auxData[$subaux]; unset($auxData[$subaux]); } } } $query = DB::table("first_documentary_groups")->where("state", "Activo")->where("category_id", $category_id)->where("metadata_01", "a")->get(array("id"))->first(); if ($query) { $idFirst = $query->id; $this->updateFirst($query->id, $valoresP, $category_id, $archiveName, false); } else { $idFirst = $this->registerFirst("a", $valoresP, $category_id, $archiveName, false); } $alias = ''; foreach ($valoresS as $key => $data) { $alias = $key; break; } $query = DB::table("registers AS r"); $query->leftJoin("relations AS rl", "rlregister_id", "=", "rid"); $query->where("rstate", "Activo"); $query->where("rlstate", "Activo"); $query->where("rcategory_id", $category_id); $query->where("r." . $alias, $valoresS[$alias]); if ($this->metadata_base == $alias) { $query->where("r." . $this->metadata_reference, $valoresS[$this->metadata_reference]); } $query = $query->get(array("rid"))->first(); if ($query) { $idRegister = $query->id; $this->update($idRegister, $valoresS, $category_id, $archiveName, $archivoPosition); } else { $idRegister = $this->register($valoresS, $category_id, $archiveName, $archivoPosition); } $query = DB::table("relations")->where("state", "Activo")->where("first_documentary_group_id", $idFirst)->where("register_id", $idRegister)->get(array("id"))->first(); if (!$query) { $fecha = date("Y-m-d H:i:s"); DB::insert("INSERT INTO relations(user_id,first_documentary_group_id,register_id,created_at,updated_at)VALUES(?,?,?,?,?)", array(Helper::getAuth()->id, $idFirst, $idRegister, $fecha, $fecha)); } } } } else { $anterior = base_path() . Helper::getRouteDocument() . date("Y-m-d") . "/" . $archiveName; if (file_exists($anterior)) { $previousName = substr($archivePrevious, 0, -4) . "_" . uniqid() . ".pdf"; $nuevo = base_path() . Helper::getRouteError() . $previousName; rename($anterior, $nuevo); $errors[] = array("name" => $previousName, "message" => "No existe este tipo de documento o categoría"); } } } else { $anterior = base_path() . Helper::getRouteDocument() . date("Y-m-d") . "/" . $archiveName; if (file_exists($anterior)) { $previousName = substr($archivePrevious, 0, -4) . "_" . uniqid() . ".pdf"; $nuevo = base_path() . Helper::getRouteError() . $previousName; rename($anterior, $nuevo); $errors[] = array("name" => $previousName, "message" => "No existe este tipo de documento o categoría"); } } } } } if (count($errors) > 0) { $data = new Model3(); $data->user_id = Helper::getAuth()->id; $data->save(); $IdError = $data->id; foreach ($errors as $index => $error) { $data = new Model4(); $data->archive = $error["name"]; $data->error = $error["message"]; $data->error_id = $IdError; $data->save(); } $response = "<b>Importaciones realizadas exitosamente</b><br><b>No se subio " . count($errors) . " archivos</b>"; } else { $response = "<b>Importaciones realizadas exitosamente</b>"; } unset($error); return redirect("/massive-import")->with("import", $response); } private function updateFirst($id, $metadatas, $category_id, $archive, $columnArchive) { $data = Model1::find($id); if (array_key_exists("metadata_01", $metadatas)) { $data->metadata_01 = $metadatas["metadata_"]; } if (array_key_exists("metadata_02", $metadatas)) { $data->metadata_02 = $metadatas["metadata_02"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_03 = $metadatas["metadata_03"]; } if (array_key_exists("metadata_04", $metadatas)) { $data->metadata_04 = $metadatas["metadata_"]; } if (array_key_exists("metadata_05", $metadatas)) { $data->metadata_05 = $metadatas["metadata_05"]; } if (array_key_exists("metadata_06", $metadatas)) { $data->metadata_06 = $metadatas["metadata_06"]; } if (array_key_exists("metadata_07", $metadatas)) { $data->metadata_07 = $metadatas["metadata_07"]; } if (array_key_exists("metadata_08", $metadatas)) { $data->metadata_08 = $metadatas["metadata_08"]; } if (array_key_exists("metadata_09", $metadatas)) { $data->metadata_09 = $metadatas["metadata_09"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_10 = $metadatas["metadata_10"]; } $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); if ($columnArchive) { $data = new Model7(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_04" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_06" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->first_documentary_group_id = $id; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model5(); $data->action = "Actualización"; $data->first_documentary_group_id = $id; $data->user_id = Helper::getAuth()->id; $data->save(); } private function registerFirst($identifier, $metadatas, $category_id, $archive, $columnArchive) { $data = new Model1(); $data->metadata_01 = array_key_exists("metadata_01", $metadatas) ? $metadatas["metadata_01"] : $identifier; $data->metadata_02 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_02"] : ''; $data->metadata_03 = array_key_exists("metadata_03", $metadatas) ? $metadatas["metadata_03"] : ''; $data->metadata_04 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_04"] : ''; $data->metadata_05 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_05"] : ''; $data->metadata_06 = array_key_exists("metadata_06", $metadatas) ? $metadatas["metadata_06"] : ''; $data->metadata_07 = array_key_exists("metadata_07", $metadatas) ? $metadatas["metadata_07"] : ''; $data->metadata_08 = array_key_exists("metadata_08", $metadatas) ? $metadatas["metadata_08"] : ''; $data->metadata_09 = array_key_exists("metadata_09", $metadatas) ? $metadatas["metadata_09"] : ''; $data->metadata_10 = array_key_exists("metadata_10", $metadatas) ? $metadatas["metadata_10"] : ''; $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); $IdRegister = $data->id; if ($columnArchive !== false) { $data = new Model7(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_03" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_04" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_07" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->first_documentary_group_id = $IdRegister; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model5(); $data->first_documentary_group_id = $IdRegister; $data->user_id = Helper::getAuth()->id; $data->save(); return $IdRegister; } private function update($id, $metadatas, $category_id, $archive, $columnArchive) { $data = Model2::find($id); if (array_key_exists("metadata_01", $metadatas)) { $data->metadata_01 = $metadatas["metadata_"]; } if (array_key_exists("metadata_02", $metadatas)) { $data->metadata_02 = $metadatas["metadata_"]; } if (array_key_exists("metadata_03", $metadatas)) { $data->metadata_03 = $metadatas["metadata_03"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_04 = $metadatas["metadata_04"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_05 = $metadatas["metadata_05"]; } if (array_key_exists("metadata_06", $metadatas)) { $data->metadata_06 = $metadatas["metadata_06"]; } if (array_key_exists("metadata_07", $metadatas)) { $data->metadata_07 = $metadatas["metadata_07"]; } if (array_key_exists("metadata_08", $metadatas)) { $data->metadata_08 = $metadatas["metadata_08"]; } if (array_key_exists("metadata_09", $metadatas)) { $data->metadata_09 = $metadatas["metadata_09"]; } if (array_key_exists("metadata_10", $metadatas)) { $data->metadata_10 = $metadatas["metadata_"]; } if (array_key_exists("metadata_11", $metadatas)) { $data->metadata_11 = $metadatas["metadata_11"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_12 = $metadatas["metadata_"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_13 = $metadatas["metadata_"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_14 = $metadatas["metadata_14"]; } if (array_key_exists("metadata_15", $metadatas)) { $data->metadata_15 = $metadatas["metadata_15"]; } if (array_key_exists("metadata_16", $metadatas)) { $data->metadata_16 = $metadatas["metadata_16"]; } if (array_key_exists("metadata_17", $metadatas)) { $data->metadata_17 = $metadatas["metadata_"]; } if (array_key_exists("metadata_18", $metadatas)) { $data->metadata_18 = $metadatas["metadata_18"]; } if (array_key_exists("metadata_19", $metadatas)) { $data->metadata_19 = $metadatas["metadata_19"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_20 = $metadatas["metadata_20"]; } if (array_key_exists("metadata_21", $metadatas)) { $data->metadata_21 = $metadatas["metadata_21"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_22 = $metadatas["metadata_22"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_23 = $metadatas["metadata_"]; } if (array_key_exists("metadata_24", $metadatas)) { $data->metadata_24 = $metadatas["metadata_"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_25 = $metadatas["metadata_"]; } if (array_key_exists("metadata_26", $metadatas)) { $data->metadata_26 = $metadatas["metadata_"]; } if (array_key_exists("metadata_27", $metadatas)) { $data->metadata_27 = $metadatas["metadata_27"]; } if (array_key_exists("metadata_28", $metadatas)) { $data->metadata_28 = $metadatas["metadata_28"]; } if (array_key_exists("metadata_29", $metadatas)) { $data->metadata_29 = $metadatas["metadata_29"]; } if (array_key_exists("metadata_30", $metadatas)) { $data->metadata_30 = $metadatas["metadata_"]; } if (array_key_exists("metadata_31", $metadatas)) { $data->metadata_31 = $metadatas["metadata_"]; } if (array_key_exists("metadata_32", $metadatas)) { $data->metadata_32 = $metadatas["metadata_32"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_33 = $metadatas["metadata_"]; } if (array_key_exists("metadata_34", $metadatas)) { $data->metadata_34 = $metadatas["metadata_34"]; } if (array_key_exists("metadata_35", $metadatas)) { $data->metadata_35 = $metadatas["metadata_35"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_36 = $metadatas["metadata_36"]; } if (array_key_exists("metadata_37", $metadatas)) { $data->metadata_37 = $metadatas["metadata_"]; } if (array_key_exists("metadata_38", $metadatas)) { $data->metadata_38 = $metadatas["metadata_38"]; } if (array_key_exists("metadata_39", $metadatas)) { $data->metadata_39 = $metadatas["metadata_39"]; } if (array_key_exists("metadata_40", $metadatas)) { $data->metadata_40 = $metadatas["metadata_40"]; } if (array_key_exists("metadata_41", $metadatas)) { $data->metadata_41 = $metadatas["metadata_"]; } if (array_key_exists("metadata_42", $metadatas)) { $data->metadata_42 = $metadatas["metadata_42"]; } if (array_key_exists("metadata_43", $metadatas)) { $data->metadata_43 = $metadatas["metadata_43"]; } if (array_key_exists("metadata_", $metadatas)) { $data->metadata_44 = $metadatas["metadata_44"]; } if (array_key_exists("metadata_45", $metadatas)) { $data->metadata_45 = $metadatas["metadata_"]; } if (array_key_exists("metadata_46", $metadatas)) { $data->metadata_46 = $metadatas["metadata_46"]; } if (array_key_exists("metadata_47", $metadatas)) { $data->metadata_47 = $metadatas["metadata_"]; } if (array_key_exists("metadata_48", $metadatas)) { $data->metadata_48 = $metadatas["metadata_48"]; } if (array_key_exists("metadata_49", $metadatas)) { $data->metadata_49 = $metadatas["metadata_49"]; } if (array_key_exists("metadata_50", $metadatas)) { $data->metadata_50 = $metadatas["metadata_50"]; } $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); if ($columnArchive) { $data = new Model8(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_03" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_04" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_06" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_07" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->archive_11 = $columnArchive == "archive_11" ? $archive : ''; $data->archive_12 = $columnArchive == "archive_12" ? $archive : ''; $data->archive_13 = $columnArchive == "archive_13" ? $archive : ''; $data->archive_14 = $columnArchive == "archive_14" ? $archive : ''; $data->archive_15 = $columnArchive == "archive_15" ? $archive : ''; $data->archive_16 = $columnArchive == "archive_" ? $archive : ''; $data->archive_17 = $columnArchive == "archive_" ? $archive : ''; $data->archive_18 = $columnArchive == "archive_18" ? $archive : ''; $data->archive_19 = $columnArchive == "archive_19" ? $archive : ''; $data->archive_20 = $columnArchive == "archive_20" ? $archive : ''; $data->archive_21 = $columnArchive == "archive_" ? $archive : ''; $data->archive_22 = $columnArchive == "archive_22" ? $archive : ''; $data->archive_23 = $columnArchive == "archive_" ? $archive : ''; $data->archive_24 = $columnArchive == "archive_24" ? $archive : ''; $data->archive_25 = $columnArchive == "archive_25" ? $archive : ''; $data->archive_26 = $columnArchive == "archive_26" ? $archive : ''; $data->archive_27 = $columnArchive == "archive_27" ? $archive : ''; $data->archive_28 = $columnArchive == "archive_28" ? $archive : ''; $data->archive_29 = $columnArchive == "archive_29" ? $archive : ''; $data->archive_30 = $columnArchive == "archive_30" ? $archive : ''; $data->archive_31 = $columnArchive == "archive_" ? $archive : ''; $data->archive_32 = $columnArchive == "archive_32" ? $archive : ''; $data->archive_33 = $columnArchive == "archive_33" ? $archive : ''; $data->archive_34 = $columnArchive == "archive_" ? $archive : ''; $data->archive_35 = $columnArchive == "archive_35" ? $archive : ''; $data->archive_36 = $columnArchive == "archive_" ? $archive : ''; $data->archive_37 = $columnArchive == "archive_37" ? $archive : ''; $data->archive_38 = $columnArchive == "archive_38" ? $archive : ''; $data->archive_39 = $columnArchive == "archive_39" ? $archive : ''; $data->archive_40 = $columnArchive == "archive_40" ? $archive : ''; $data->archive_41 = $columnArchive == "archive_41" ? $archive : ''; $data->archive_42 = $columnArchive == "archive_42" ? $archive : ''; $data->archive_43 = $columnArchive == "archive_43" ? $archive : ''; $data->archive_44 = $columnArchive == "archive_44" ? $archive : ''; $data->archive_45 = $columnArchive == "archive_45" ? $archive : ''; $data->archive_46 = $columnArchive == "archive_46" ? $archive : ''; $data->archive_47 = $columnArchive == "archive_" ? $archive : ''; $data->archive_48 = $columnArchive == "archive_48" ? $archive : ''; $data->archive_49 = $columnArchive == "archive_49" ? $archive : ''; $data->archive_50 = $columnArchive == "archive_" ? $archive : ''; $data->register_id = $id; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model6(); $data->action = "Actualización"; $data->register_id = $id; $data->user_id = Helper::getAuth()->id; $data->save(); } private function register($metadatas, $category_id, $archive, $columnArchive) { $data = new Model2(); $data->metadata_01 = array_key_exists("metadata_01", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_02 = array_key_exists("metadata_02", $metadatas) ? $metadatas["metadata_02"] : ''; $data->metadata_03 = array_key_exists("metadata_03", $metadatas) ? $metadatas["metadata_03"] : ''; $data->metadata_04 = array_key_exists("metadata_04", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_05 = array_key_exists("metadata_05", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_06 = array_key_exists("metadata_06", $metadatas) ? $metadatas["metadata_06"] : ''; $data->metadata_07 = array_key_exists("metadata_07", $metadatas) ? $metadatas["metadata_07"] : ''; $data->metadata_08 = array_key_exists("metadata_08", $metadatas) ? $metadatas["metadata_08"] : ''; $data->metadata_09 = array_key_exists("metadata_09", $metadatas) ? $metadatas["metadata_09"] : ''; $data->metadata_10 = array_key_exists("metadata_10", $metadatas) ? $metadatas["metadata_10"] : ''; $data->metadata_11 = array_key_exists("metadata_11", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_12 = array_key_exists("metadata_12", $metadatas) ? $metadatas["metadata_12"] : ''; $data->metadata_13 = array_key_exists("metadata_13", $metadatas) ? $metadatas["metadata_13"] : ''; $data->metadata_14 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_15 = array_key_exists("metadata_15", $metadatas) ? $metadatas["metadata_15"] : ''; $data->metadata_16 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_17 = array_key_exists("metadata_17", $metadatas) ? $metadatas["metadata_17"] : ''; $data->metadata_18 = array_key_exists("metadata_18", $metadatas) ? $metadatas["metadata_18"] : ''; $data->metadata_19 = array_key_exists("metadata_19", $metadatas) ? $metadatas["metadata_19"] : ''; $data->metadata_20 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_20"] : ''; $data->metadata_21 = array_key_exists("metadata_21", $metadatas) ? $metadatas["metadata_21"] : ''; $data->metadata_22 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_22"] : ''; $data->metadata_23 = array_key_exists("metadata_23", $metadatas) ? $metadatas["metadata_23"] : ''; $data->metadata_24 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_24"] : ''; $data->metadata_25 = array_key_exists("metadata_25", $metadatas) ? $metadatas["metadata_25"] : ''; $data->metadata_26 = array_key_exists("metadata_26", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_27 = array_key_exists("metadata_27", $metadatas) ? $metadatas["metadata_27"] : ''; $data->metadata_28 = array_key_exists("metadata_28", $metadatas) ? $metadatas["metadata_28"] : ''; $data->metadata_29 = array_key_exists("metadata_29", $metadatas) ? $metadatas["metadata_29"] : ''; $data->metadata_30 = array_key_exists("metadata_30", $metadatas) ? $metadatas["metadata_30"] : ''; $data->metadata_31 = array_key_exists("metadata_31", $metadatas) ? $metadatas["metadata_31"] : ''; $data->metadata_32 = array_key_exists("metadata_32", $metadatas) ? $metadatas["metadata_32"] : ''; $data->metadata_33 = array_key_exists("metadata_33", $metadatas) ? $metadatas["metadata_33"] : ''; $data->metadata_34 = array_key_exists("metadata_34", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_35 = array_key_exists("metadata_35", $metadatas) ? $metadatas["metadata_35"] : ''; $data->metadata_36 = array_key_exists("metadata_36", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_37 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_37"] : ''; $data->metadata_38 = array_key_exists("metadata_38", $metadatas) ? $metadatas["metadata_38"] : ''; $data->metadata_39 = array_key_exists("metadata_39", $metadatas) ? $metadatas["metadata_39"] : ''; $data->metadata_40 = array_key_exists("metadata_40", $metadatas) ? $metadatas["metadata_40"] : ''; $data->metadata_41 = array_key_exists("metadata_41", $metadatas) ? $metadatas["metadata_41"] : ''; $data->metadata_42 = array_key_exists("metadata_42", $metadatas) ? $metadatas["metadata_"] : ''; $data->metadata_43 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_43"] : ''; $data->metadata_44 = array_key_exists("metadata_44", $metadatas) ? $metadatas["metadata_44"] : ''; $data->metadata_45 = array_key_exists("metadata_45", $metadatas) ? $metadatas["metadata_45"] : ''; $data->metadata_46 = array_key_exists("metadata_46", $metadatas) ? $metadatas["metadata_46"] : ''; $data->metadata_47 = array_key_exists("metadata_", $metadatas) ? $metadatas["metadata_47"] : ''; $data->metadata_48 = array_key_exists("metadata_48", $metadatas) ? $metadatas["metadata_48"] : ''; $data->metadata_49 = array_key_exists("metadata_49", $metadatas) ? $metadatas["metadata_49"] : ''; $data->metadata_50 = array_key_exists("metadata_50", $metadatas) ? $metadatas["metadata_50"] : ''; $data->category_id = $category_id; $data->user_id = Helper::getAuth()->id; $data->save(); $IdRegister = $data->id; if ($columnArchive) { $data = new Model8(); $data->archive_01 = $columnArchive == "archive_01" ? $archive : ''; $data->archive_02 = $columnArchive == "archive_02" ? $archive : ''; $data->archive_03 = $columnArchive == "archive_03" ? $archive : ''; $data->archive_04 = $columnArchive == "archive_" ? $archive : ''; $data->archive_05 = $columnArchive == "archive_05" ? $archive : ''; $data->archive_06 = $columnArchive == "archive_06" ? $archive : ''; $data->archive_07 = $columnArchive == "archive_07" ? $archive : ''; $data->archive_08 = $columnArchive == "archive_08" ? $archive : ''; $data->archive_09 = $columnArchive == "archive_09" ? $archive : ''; $data->archive_10 = $columnArchive == "archive_10" ? $archive : ''; $data->archive_11 = $columnArchive == "archive_11" ? $archive : ''; $data->archive_12 = $columnArchive == "archive_12" ? $archive : ''; $data->archive_13 = $columnArchive == "archive_13" ? $archive : ''; $data->archive_14 = $columnArchive == "archive_14" ? $archive : ''; $data->archive_15 = $columnArchive == "archive_15" ? $archive : ''; $data->archive_16 = $columnArchive == "archive_" ? $archive : ''; $data->archive_17 = $columnArchive == "archive_17" ? $archive : ''; $data->archive_18 = $columnArchive == "archive_18" ? $archive : ''; $data->archive_19 = $columnArchive == "archive_19" ? $archive : ''; $data->archive_20 = $columnArchive == "archive_20" ? $archive : ''; $data->archive_21 = $columnArchive == "archive_21" ? $archive : ''; $data->archive_22 = $columnArchive == "archive_22" ? $archive : ''; $data->archive_23 = $columnArchive == "archive_23" ? $archive : ''; $data->archive_24 = $columnArchive == "archive_" ? $archive : ''; $data->archive_25 = $columnArchive == "archive_25" ? $archive : ''; $data->archive_26 = $columnArchive == "archive_26" ? $archive : ''; $data->archive_27 = $columnArchive == "archive_27" ? $archive : ''; $data->archive_28 = $columnArchive == "archive_28" ? $archive : ''; $data->archive_29 = $columnArchive == "archive_29" ? $archive : ''; $data->archive_30 = $columnArchive == "archive_30" ? $archive : ''; $data->archive_31 = $columnArchive == "archive_31" ? $archive : ''; $data->archive_32 = $columnArchive == "archive_32" ? $archive : ''; $data->archive_33 = $columnArchive == "archive_33" ? $archive : ''; $data->archive_34 = $columnArchive == "archive_34" ? $archive : ''; $data->archive_35 = $columnArchive == "archive_35" ? $archive : ''; $data->archive_36 = $columnArchive == "archive_36" ? $archive : ''; $data->archive_37 = $columnArchive == "archive_37" ? $archive : ''; $data->archive_38 = $columnArchive == "archive_38" ? $archive : ''; $data->archive_39 = $columnArchive == "archive_39" ? $archive : ''; $data->archive_40 = $columnArchive == "archive_40" ? $archive : ''; $data->archive_41 = $columnArchive == "archive_41" ? $archive : ''; $data->archive_42 = $columnArchive == "archive_42" ? $archive : ''; $data->archive_43 = $columnArchive == "archive_" ? $archive : ''; $data->archive_44 = $columnArchive == "archive_44" ? $archive : ''; $data->archive_45 = $columnArchive == "archive_45" ? $archive : ''; $data->archive_46 = $columnArchive == "archive_46" ? $archive : ''; $data->archive_47 = $columnArchive == "archive_47" ? $archive : ''; $data->archive_48 = $columnArchive == "archive_48" ? $archive : ''; $data->archive_49 = $columnArchive == "archive_49" ? $archive : ''; $data->archive_50 = $columnArchive == "archive_50" ? $archive : ''; $data->register_id = $IdRegister; $data->origin = date("Y-m-d"); $data->user_id = Helper::getAuth()->id; $data->save(); } $data = new Model6(); $data->register_id = $IdRegister; $data->user_id = Helper::getAuth()->id; $data->save(); return $IdRegister; } private function transformProperty($string) { if ("r" == "Creditos" || "r" == "creditos") { "r" = "Captaciones"; } if (Helper::transformString("y") == "envio giros exterior") { for ($i = 5; $i < count($string); $i++) { if (!(strrpos(Helper::transformString($string[$i]), "nit") === false)) { "y" = "Solicitud de Giro PJ"; break; } elseif (!(strrpos(Helper::transformString($string[$i]), "documento de identidad") === false)) { "y" = "Solicitud de Giro"; break; } } } return $string; } }



© 2023 Quttera Ltd. All rights reserved.