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\Support\Facades\DB; use App\Models\Area; use App\Models\Category; class QueryDeleteController extends Controller { private $credits = array("Doc. Solicitud de Credito", "Doc. Consulta BIC/ASFI", "Doc. Evaluacion", "Doc. Aprobacion", "Doc. Desembolso", "Doc_Garante Personal", "Doc_Garantia Prendaria", "Doc_Garantia Doc. Custodia", "Doc_Garantia Sujeta a Registro", "Doc_Garantia No Convencional", "Doc_Seguimiento"); private $giros = "giros al exterior"; private $garante = "doc_garante personal"; public function index() { $credentials = Helper::getAuthAvatar(); $data = array("user" => $credentials, "permissions" => Helper::getObfuscateAreas($credentials), "categories" => Helper::getObfuscateCategories($credentials), "areas" => Area::where("state", "Activo")->orderByRaw("area ASC")->get(array("id", "area"))); return view("modules.query-delete.index")->with($data); } public function getCategory($id) { $data = array("ok" => true, "data" => array(array("id" => "1-Todos", "category" => "Todos"), array("id" => "1-Registro de Cliente", "category" => "Registro de Cliente"), array("id" => "1-Cuenta de Ahorro", "category" => "Cuenta de Ahorro"), array("id" => "1-Depósito a Plazo Fijo", "category" => "Depósito a Plazo Fijo"), array("id" => "1-Tarjeta de débito", "category" => "Tarjeta de débito"), array("id" => "1-Banca Electrónica", "category" => "Banca Electrónica"), array("id" => "1-Giros al exterior", "category" => "Giros al exterior"), array("id" => "1-Créditos", "category" => "Créditos"))); echo json_encode($data); } public function getFormat($id) { $get = explode("-", $id); $output = array(); $structure = Category::where("id", $get[0])->get(array("structure"))->first(); $structure = json_decode($structure->structure, true); switch ($get[1]) { case "Registro de Cliente": case "Cuenta de Ahorro": case "Depósito a Plazo Fijo": case "Tarjeta de débito": case "Banca Electrónica": case "Giros al exterior": $content = array($get[1]); $output = $this->getDataSolid($structure, $content); break; case "Todos": $output = array(array("title" => "Todos", "data" => array("W1siUC1hcmNoaXZlXzAxIiwiUC1hcmNoaXZlXzAyIiwiUC1hcmNoaXZlXzAzIiwiUC1hcmNoaXZlXzA0IiwiUC1hcmNoaXZlXzA1IiwiUC1hcmNoaXZlXzA2IiwiUC1hcmNoaXZlXzA3Il0sWyJhcmNoaXZlXzAxIiwiYXJjaGl2ZV8wMiIsImFyY2hpdmVfMDMiXSxbImFyY2hpdmVfMDQiLCJhcmNoaXZlXzA1Il0sWyJhcmNoaXZlXzA2IiwiYXJjaGl2ZV8wNyJdLFsiYXJjaGl2ZV8wOCJdLFsiYXJjaGl2ZV8wOSIsImFyY2hpdmVfMTAiLCJhcmNoaXZlXzExIl0sWyJhcmNoaXZlXzEyIiwiYXJjaGl2ZV8xMyJdLFsiYXJjaGl2ZV8xNCIsImFyY2hpdmVfMTUiXSxbImFyY2hpdmVfMTYiLCJhcmNoaXZlXzE3Il0sWyJhcmNoaXZlXzE4Il0sWyJhcmNoaXZlXzE5IiwiYXJjaGl2ZV8yMCIsImFyY2hpdmVfMjEiXSxbImFyY2hpdmVfMjIiLCJhcmNoaXZlXzIzIiwiYXJjaGl2ZV8yNCJdLFsiYXJjaGl2ZV8yNSIsImFyY2hpdmVfMjYiXSxbImFyY2hpdmVfMjciXSxbImFyY2hpdmVfMjgiLCJhcmNoaXZlXzI5Il0sWyJhcmNoaXZlXzMwIl0sWyJhcmNoaXZlXzMxIl1d" => "Todos"), "date" => array("W1siUC1tZXRhZGF0YV8wNCIsIlAtbWV0YWRhdGFfMDUiXSxbIm1ldGFkYXRhXzAzIl0sWyJtZXRhZGF0YV8wNiJdLFsibWV0YWRhdGFfMDkiXSxbIm1ldGFkYXRhXzEyIl0sWyJtZXRhZGF0YV8xNSJdXQ==" => "Todos"))); break; case "Créditos": $content = $this->credits; $output = $this->getDataSolid($structure, $content); break; } echo json_encode(array("ok" => true, "data" => $output)); } private function getDataSolid($structure, $content) { $content = array_map(function ($value) { return Helper::transformString($value); }, $content); $init = ''; if (in_array("registro de cliente", $content)) { $init = "P-"; } $idea = "fecha"; $all = array(); $output = array(); $countM = 0; $countF = 0; $auxT = array(); foreach ($structure as $index => $data) { $aux = array(); if ($index == 1) { $countF = 0; $countM = 0; } $aux["title"] = $data["title"]; foreach ($data["files"] as $subdata) { if (in_array(Helper::transformString($data["title"]), $content)) { $metadata = $init . "archive_" . str_pad((string) ($countF + 1), 2, "0", STR_PAD_LEFT); $aux["data"][$metadata] = $subdata["metadata"]; $all[] = $metadata; $auxT[$metadata] = $subdata["metadata"]; } $countF++; } foreach ($data["metadatas"] as $subdata) { if (in_array(Helper::transformString($data["title"]), $content)) { if (strpos(strtolower($subdata["metadata"]), $idea) !== false) { $metadata = $init . "metadata_" . str_pad((string) ($countM + 1), 2, "0", STR_PAD_LEFT); $aux["date"][$metadata] = $subdata["metadata"]; } } $countM++; } if (in_array(Helper::transformString($data["title"]), $content)) { $aux["data"] = array_merge(array(base64_encode(json_encode(array($all))) => "Todos"), $aux["data"]); $output[] = $aux; } } $dataT = array(); foreach ($auxT as $index => $data) { $dataT[] = $index; } $dataT = base64_encode(json_encode(array($dataT))); $contentT = array("title" => "Todos", "data" => array("{$dataT}" => "Todos")); foreach ($auxT as $index => $data) { $contentT["data"][$index] = $data; } $output = array_merge(array($contentT), $output); return $output; } public function getData($hash, $page, $date1, $date2, $date1A, $date2A, $dateI, $dateF, $archive, $metadata, $search) { $category = explode("-", $hash); $dateRegisterInit = $date1; $dateRegisterFinal = $date2; $dateUpdatedInit = $date1A; $dateUpdatedFinal = $date2A; if (strlen($metadata) > 13) { $metadata = base64_decode($metadata); } if (substr($metadata, 0, 2) == "P-") { $metadata = array(substr($metadata, 2)); } else { if (substr($metadata, 0, 1) == "[") { $dateCondition = array(); foreach (json_decode($metadata, true) as $data) { foreach ($data as $subdata) { $dateCondition[] = substr($subdata, 0, 2) == "P-" ? substr($subdata, 2) : $subdata; } } $metadata = $dateCondition; } } $dateCondition = $metadata; $dateConditionInit = $dateI; $dateConditionFinal = $dateF; $search = base64_decode($search); if ($search == "-") { $search = ''; } $search = "%{$search}%"; if (strlen($archive) > 13) { $aux = json_decode(base64_decode($archive)); $archive = array(); foreach ($aux as $data) { foreach ($data as $subdata) { if (substr($subdata, 0, 2) == "P-") { $archive["prince"][] = substr($subdata, 2); } else { $archive["secondary"][] = $subdata; } } } } else { $archive = substr($archive, 0, 2) == "P-" ? array("prince" => array(substr($archive, 2))) : array("secondary" => array($archive)); } $structure = $this->getStructure($category[0], $category[1], $archive); $queries = array(); if (isset($structure["prince"])) { foreach ($structure["prince"][0]["files"] as $index => $file) { $queries[] = $this->primary($structure["prince"][0], array("index" => $index, "file" => $file), $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search); } } if (isset($structure["secondary"])) { foreach ($structure["secondary"] as $secondary) { foreach ($secondary["files"] as $index => $file) { $queries[] = $this->secondary($secondary, array("index" => $index, "file" => $file), $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search); } } } $data = $queries[0]; if (count($queries) > 1) { for ($i = 1; $i < count($queries); $i++) { $data->union($queries[$i]); } } $response = $data->orderBy("updated_at", "DESC")->get(); return json_decode(json_encode(array("data" => $response))); } private function getStructure($id_category, $title, $archive) { $structure = DB::table("categories")->where("id", $id_category)->get(array("structure"))->first(); $structure = json_decode($structure->structure, true); $countF = 1; $countM = 1; $newStructure = array(); foreach ($structure as $index => $data) { $auxF = array(); $auxM = array(); $sw = false; foreach ($data["files"] as $subdata) { $number = str_pad($countF, 2, "0", STR_PAD_LEFT); if ($index == 0 && isset($archive["prince"]) && in_array("archive_{$number}", $archive["prince"]) || $index > 0 && isset($archive["secondary"]) && in_array("archive_{$number}", $archive["secondary"])) { $auxF["archive_{$number}"] = $subdata["metadata"]; $sw = true; } $countF++; } foreach ($data["metadatas"] as $subindex => $subdata) { $number = str_pad($countM, 2, "0", STR_PAD_LEFT); if ($sw) { if (strpos(strtolower($subdata["metadata"]), "fecha") !== false) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } elseif (strtolower($data["title"]) == $this->giros) { if ($subindex == 1) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } } elseif (strtolower($data["title"]) == $this->garante) { if ($subindex == 0 || $subindex == 2) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } } elseif ($subindex == 0) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } } $countM++; } if ($title == "Todos" || ($this->normalize($title) == $this->normalize($data["title"]) || $title == "Créditos" && in_array($data["title"], $this->credits))) { if ($index == 0) { $newStructure["prince"][] = array("title" => $data["title"], "files" => $auxF, "metadatas" => $auxM); } else { $newStructure["secondary"][] = array("title" => $data["title"], "files" => $auxF, "metadatas" => $auxM); } } if ($index == 0) { $countF = 1; $countM = 1; } } return $newStructure; } private function normalize($string) { return strtolower(preg_replace("/[\x{03}-\x{0f}]/u", "$1", normalizer_normalize(trim($string), \Normalizer::FORM_D))); } private function primary($primary, $file, $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search) { if ($dateCondition != "-") { if (is_string($dateCondition)) { $dateCondition = array($dateCondition); } } else { $dateCondition = false; } $query = DB::table("first_documentary_groups AS fdg")->select(array("fdg.metadata_01", "fdg.metadata_03", "fdga.updated_at", "u.name", DB::raw("fdga.{$file["index"]} AS archive"), DB::raw("'{$file["file"]}' AS document")))->leftJoin("fdg_archives AS fdga", "fdga.first_documentary_group_id", "=", "fdg.id")->leftJoin("users AS u", "u.id", "=", "fdga.user_id")->where("fdg.category_id", "=", $category[0])->where("fdga.{$file["index"]}", "!=", '')->where("fdga.state", "=", "Inactivo"); if ($dateRegisterInit != "-" && $dateRegisterFinal != "-") { $query->whereBetween("fdga.created_at", array("{$dateRegisterInit} :00:00", "{$dateRegisterFinal} :59:59")); } elseif ($dateRegisterInit != "-") { $query->where("fdga.created_at", ">=", "{$dateRegisterInit} 00::00"); } elseif ($dateRegisterFinal != "-") { $query->where("fdga.created_at", "<=", "{$dateRegisterFinal} 23:59:59"); } if ($dateUpdatedInit != "-" && $dateUpdatedFinal != "-") { $query->whereBetween("fdga.updated_at", array("{$dateUpdatedInit} 000:", "{$dateUpdatedFinal} 23:59:59")); } elseif ($dateUpdatedInit != "-") { $query->where("fdga.updated_at", ">=", "{$dateUpdatedInit}0:00:00"); } elseif ($dateUpdatedFinal != "-") { $query->where("fdga.updated_at", "<=", "{$dateUpdatedFinal} :599"); } if ($dateCondition) { foreach ($dateCondition as $data) { if (in_array($data, $primary["metadatas"])) { if ($dateConditionInit != "-" && $dateConditionFinal != "-") { $query->whereBetween("fdga.{$data}", array("{$dateConditionInit} 00:0", "{$dateConditionFinal}3:59:59")); } elseif ($dateConditionInit != "-") { $query->where("fdga.{$data}", ">=", "{$dateConditionInit} 0:00"); } elseif ($dateConditionFinal != "-") { $query->where("fdga.{$data}", "<=", "{$dateConditionFinal} 23:59:59"); } } } } if (count($primary["metadatas"]) > 0) { $metadatas = $primary["metadatas"]; $query->where(function ($query) use($metadatas, $search) { $query->where("fdg.metadata_", "like", $search)->orWhere("fdg.metadata_02", "like", $search)->orWhere("fdg.metadata_03", "like", $search); foreach ($metadatas as $index => $data) { if (strpos(strtolower($data), "fecha") === false) { $query->orWhere("fdg.{$index}", "like", $search); } } }); } return $query->groupBy("fdga.id")->orderBy("fdga.updated_at", "DESC"); } private function secondary($secondary, $file, $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search) { if ($dateCondition != "-") { if (is_string($dateCondition)) { $dateCondition = array($dateCondition); } } else { $dateCondition = false; } $query = DB::table("first_documentary_groups AS fdg")->select(array("fdg.metadata_", "fdg.metadata_03", "fdgr.updated_at", "u.name", DB::raw("fdgr.{$file["index"]} AS archive"), DB::raw("'{$file["file"]}' AS document")))->leftJoin("relations AS rel", "rel.first_documentary_group_id", "=", "fdg.id")->leftJoin("registers AS r", "r.id", "=", "rel.register_id")->leftJoin("fdg_registers AS fdgr", "fdgr.register_id", "=", "r.id")->leftJoin("users AS u", "u.id", "=", "fdgr.user_id")->where("fdg.category_id", "=", $category[0])->where("fdgr.{$file["index"]}", "!=", '')->where("fdgr.state", "=", "Inactivo"); if ($dateRegisterInit != "-" && $dateRegisterFinal != "-") { $query->whereBetween("fdgr.created_at", array("{$dateRegisterInit} 00:00:00", "{$dateRegisterFinal}3:59:59")); } elseif ($dateRegisterInit != "-") { $query->where("fdgr.created_at", ">=", "{$dateRegisterInit} :00:"); } elseif ($dateRegisterFinal != "-") { $query->where("fdgr.created_at", "<=", "{$dateRegisterFinal}3:59:59"); } if ($dateUpdatedInit != "-" && $dateUpdatedFinal != "-") { $query->whereBetween("fdgr.updated_at", array("{$dateUpdatedInit} 000:", "{$dateUpdatedFinal}3:59:59")); } elseif ($dateUpdatedInit != "-") { $query->where("fdgr.updated_at", ">=", "{$dateUpdatedInit} 00:000"); } elseif ($dateUpdatedFinal != "-") { $query->where("fdgr.updated_at", "<=", "{$dateUpdatedFinal} 23:59:59"); } if ($dateCondition) { foreach ($dateCondition as $data) { if (in_array($data, $secondary["metadatas"])) { if ($dateConditionInit != "-" && $dateConditionFinal != "-") { $query->whereBetween("fdgr.{$data}", array("{$dateConditionInit} 00::", "{$dateConditionFinal} 239:59")); } elseif ($dateConditionInit != "-") { $query->where("fdgr.{$data}", ">=", "{$dateConditionInit} ::00"); } elseif ($dateConditionFinal != "-") { $query->where("fdgr.{$data}", "<=", "{$dateConditionFinal} :599"); } } } } if (count($secondary["metadatas"]) > 0) { $metadatas = $secondary["metadatas"]; $query->where(function ($query) use($metadatas, $search) { $query->where("fdg.metadata_01", "like", $search)->orWhere("fdg.metadata_02", "like", $search)->orWhere("fdg.metadata_", "like", $search); foreach ($metadatas as $index => $data) { if (strpos(strtolower($data), "fecha") === false) { $query->orWhere("r.{$index}", "like", $search); } } }); } return $query->groupBy("fdgr.id")->orderBy("fdgr.updated_at", "DESC"); } }

namespace App\Http\Controllers; use App\Helpers\Helper; use Illuminate\Support\Facades\DB; use App\Models\Area; use App\Models\Category; class QueryDeleteController extends Controller { private $credits = array("DocSolicitud de Credito", "DocConsulta BIC/ASFI", "DocEvaluacion", "DocAprobacion", "DocDesembolso", "Doc_Garante Personal", "Doc_Garantia Prendaria", "Doc_Garantia DocCustodia", "Doc_Garantia Sujeta a Registro", "Doc_Garantia No Convencional", "Doc_Seguimiento"); private $giros = "giros al exterior"; private $garante = "doc_garante personal"; public function index() { $credentials = Helper::getAuthAvatar(); $data = array("user" => $credentials, "permissions" => Helper::getObfuscateAreas($credentials), "categories" => Helper::getObfuscateCategories($credentials), "areas" => Area::where("state", "Activo")->orderByRaw("area ASC")->get(array("id", "area"))); return view("modulesquery-deleteindex")->with($data); } public function getCategory($id) { $data = array("ok" => true, "data" => array(array("id" => "1-Todos", "category" => "Todos"), array("id" => "1-Registro de Cliente", "category" => "Registro de Cliente"), array("id" => "1-Cuenta de Ahorro", "category" => "Cuenta de Ahorro"), array("id" => "1-Depósito a Plazo Fijo", "category" => "Depósito a Plazo Fijo"), array("id" => "1-Tarjeta de débito", "category" => "Tarjeta de débito"), array("id" => "1-Banca Electrónica", "category" => "Banca Electrónica"), array("id" => "1-Giros al exterior", "category" => "Giros al exterior"), array("id" => "1-Créditos", "category" => "Créditos"))); echo json_encode($data); } public function getFormat($id) {  $output = array(); $structure = Category::where("id", "e")->get(array("structure"))->first(); $structure = json_decode($structure->structure, true); switch ("x") { case "Registro de Cliente": case "Cuenta de Ahorro": case "Depósito a Plazo Fijo": case "Tarjeta de débito": case "Banca Electrónica": case "Giros al exterior": $content = array("x"); $output = $this->getDataSolid($structure, $content); break; case "Todos": $output = array(array("title" => "Todos", "data" => array("W1siUC1hcmNoaXZlXzAxIiwiUC1hcmNoaXZlXzAyIiwiUC1hcmNoaXZlXzAzIiwiUC1hcmNoaXZlXzA0IiwiUC1hcmNoaXZlXzA1IiwiUC1hcmNoaXZlXzA2IiwiUC1hcmNoaXZlXzA3Il0sWyJhcmNoaXZlXzAxIiwiYXJjaGl2ZV8wMiIsImFyY2hpdmVfMDMiXSxbImFyY2hpdmVfMDQiLCJhcmNoaXZlXzA1Il0sWyJhcmNoaXZlXzA2IiwiYXJjaGl2ZV8wNyJdLFsiYXJjaGl2ZV8wOCJdLFsiYXJjaGl2ZV8wOSIsImFyY2hpdmVfMTAiLCJhcmNoaXZlXzExIl0sWyJhcmNoaXZlXzEyIiwiYXJjaGl2ZV8xMyJdLFsiYXJjaGl2ZV8xNCIsImFyY2hpdmVfMTUiXSxbImFyY2hpdmVfMTYiLCJhcmNoaXZlXzE3Il0sWyJhcmNoaXZlXzE4Il0sWyJhcmNoaXZlXzE5IiwiYXJjaGl2ZV8yMCIsImFyY2hpdmVfMjEiXSxbImFyY2hpdmVfMjIiLCJhcmNoaXZlXzIzIiwiYXJjaGl2ZV8yNCJdLFsiYXJjaGl2ZV8yNSIsImFyY2hpdmVfMjYiXSxbImFyY2hpdmVfMjciXSxbImFyY2hpdmVfMjgiLCJhcmNoaXZlXzI5Il0sWyJhcmNoaXZlXzMwIl0sWyJhcmNoaXZlXzMxIl1d" => "Todos"), "date" => array("W1siUC1tZXRhZGF0YV8wNCIsIlAtbWV0YWRhdGFfMDUiXSxbIm1ldGFkYXRhXzAzIl0sWyJtZXRhZGF0YV8wNiJdLFsibWV0YWRhdGFfMDkiXSxbIm1ldGFkYXRhXzEyIl0sWyJtZXRhZGF0YV8xNSJdXQ==" => "Todos"))); break; case "Créditos": $content = $this->credits; $output = $this->getDataSolid($structure, $content); break; } echo json_encode(array("ok" => true, "data" => $output)); } private function getDataSolid($structure, $content) { $content = array_map(function ($value) { return Helper::transformString($value); }, $content); $init = ''; if (in_array("registro de cliente", $content)) { $init = "P-"; } $idea = "fecha"; $all = array(); $output = array(); $countM = 0; $countF = 0; $auxT = array(); foreach ($structure as $index => $data) { $aux = array(); if ($index == 1) { $countF = 0; $countM = 0; } $aux["title"] = $data["title"]; foreach ($data["files"] as $subdata) { if (in_array(Helper::transformString($data["title"]), $content)) { $metadata = $init . "archive_" . str_pad((string) ($countF + 1), 2, "0", STR_PAD_LEFT); $aux["data"][$metadata] = $subdata["metadata"]; $all[] = $metadata; $auxT[$metadata] = $subdata["metadata"]; } $countF++; } foreach ($data["metadatas"] as $subdata) { if (in_array(Helper::transformString($data["title"]), $content)) { if (strpos(strtolower($subdata["metadata"]), $idea) !== false) { $metadata = $init . "metadata_" . str_pad((string) ($countM + 1), 2, "0", STR_PAD_LEFT); $aux["date"][$metadata] = $subdata["metadata"]; } } $countM++; } if (in_array(Helper::transformString($data["title"]), $content)) { $aux["data"] = array_merge(array(base64_encode(json_encode(array($all))) => "Todos"), $aux["data"]); $output[] = $aux; } } $dataT = array(); foreach ($auxT as $index => $data) { $dataT[] = $index; } $dataT = base64_encode(json_encode(array($dataT))); $contentT = array("title" => "Todos", "data" => array("{$dataT}" => "Todos")); foreach ($auxT as $index => $data) { $contentT["data"][$index] = $data; } $output = array_merge(array($contentT), $output); return $output; } public function getData($hash, $page, $date1, $date2, $date1A, $date2A, $dateI, $dateF, $archive, $metadata, $search) {  $dateRegisterInit = $date1; $dateRegisterFinal = $date2; $dateUpdatedInit = $date1A; $dateUpdatedFinal = $date2A; if (strlen($metadata) > 13) { $metadata = base64_decode($metadata); } if (substr($metadata, 0, 2) == "P-") { $metadata = array(substr($metadata, 2)); } else { if (substr($metadata, 0, 1) == "[") { $dateCondition = array(); foreach (json_decode($metadata, true) as $data) { foreach ($data as $subdata) { $dateCondition[] = substr($subdata, 0, 2) == "P-" ? substr($subdata, 2) : $subdata; } } $metadata = $dateCondition; } } $dateCondition = $metadata; $dateConditionInit = $dateI; $dateConditionFinal = $dateF; $search = base64_decode($search); if ($search == "-") { $search = ''; } $search = "%{$search}%"; if (strlen($archive) > 13) { $aux = json_decode(base64_decode($archive)); $archive = array(); foreach ($aux as $data) { foreach ($data as $subdata) { if (substr($subdata, 0, 2) == "P-") { $archive["prince"][] = substr($subdata, 2); } else { $archive["secondary"][] = $subdata; } } } } else { $archive = substr($archive, 0, 2) == "P-" ? array("prince" => array(substr($archive, 2))) : array("secondary" => array($archive)); } $structure = $this->getStructure("e", "x", $archive); $queries = array(); if (isset($structure["prince"])) { foreach ($structure["prince"][0]["files"] as $index => $file) { $queries[] = $this->primary($structure["prince"][0], array("index" => $index, "file" => $file), $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search); } } if (isset($structure["secondary"])) { foreach ($structure["secondary"] as $secondary) { foreach ($secondary["files"] as $index => $file) { $queries[] = $this->secondary($secondary, array("index" => $index, "file" => $file), $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search); } } } $data = "e"; if (count($queries) > 1) { for ($i = 1; $i < count($queries); $i++) { $data->union($queries[$i]); } } $response = $data->orderBy("updated_at", "DESC")->get(); return json_decode(json_encode(array("data" => $response))); } private function getStructure($id_category, $title, $archive) { $structure = DB::table("categories")->where("id", $id_category)->get(array("structure"))->first(); $structure = json_decode($structure->structure, true); $countF = 1; $countM = 1; $newStructure = array(); foreach ($structure as $index => $data) { $auxF = array(); $auxM = array(); $sw = false; foreach ($data["files"] as $subdata) { $number = str_pad($countF, 2, "0", STR_PAD_LEFT); if ($index == 0 && isset($archive["prince"]) && in_array("archive_{$number}", $archive["prince"]) || $index > 0 && isset($archive["secondary"]) && in_array("archive_{$number}", $archive["secondary"])) { $auxF["archive_{$number}"] = $subdata["metadata"]; $sw = true; } $countF++; } foreach ($data["metadatas"] as $subindex => $subdata) { $number = str_pad($countM, 2, "0", STR_PAD_LEFT); if ($sw) { if (strpos(strtolower($subdata["metadata"]), "fecha") !== false) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } elseif (strtolower($data["title"]) == $this->giros) { if ($subindex == 1) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } } elseif (strtolower($data["title"]) == $this->garante) { if ($subindex == 0 || $subindex == 2) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } } elseif ($subindex == 0) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } } $countM++; } if ($title == "Todos" || ($this->normalize($title) == $this->normalize($data["title"]) || $title == "Créditos" && in_array($data["title"], $this->credits))) { if ($index == 0) { $newStructure["prince"][] = array("title" => $data["title"], "files" => $auxF, "metadatas" => $auxM); } else { $newStructure["secondary"][] = array("title" => $data["title"], "files" => $auxF, "metadatas" => $auxM); } } if ($index == 0) { $countF = 1; $countM = 1; } } return $newStructure; } private function normalize($string) { return strtolower(preg_replace("/[\x{03}-\x{0f}]/u", "$1", normalizer_normalize(trim($string), \Normalizer::FORM_D))); } private function primary($primary, $file, $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search) { if ($dateCondition != "-") { if (is_string($dateCondition)) { $dateCondition = array($dateCondition); } } else { $dateCondition = false; } $query = DB::table("first_documentary_groups AS fdg")->select(array("fdgmetadata_01", "fdgmetadata_03", "fdgaupdated_at", "uname", DB::raw("fdga.{$file["index"]} AS archive"), DB::raw("'{$file["file"]}' AS document")))->leftJoin("fdg_archives AS fdga", "fdgafirst_documentary_group_id", "=", "fdgid")->leftJoin("users AS u", "uid", "=", "fdgauser_id")->where("fdgcategory_id", "=", "e")->where("fdga.{$file["index"]}", "!=", '')->where("fdgastate", "=", "Inactivo"); if ($dateRegisterInit != "-" && $dateRegisterFinal != "-") { $query->whereBetween("fdgacreated_at", array("{$dateRegisterInit} :00:00", "{$dateRegisterFinal} :59:59")); } elseif ($dateRegisterInit != "-") { $query->where("fdgacreated_at", ">=", "{$dateRegisterInit} 00::00"); } elseif ($dateRegisterFinal != "-") { $query->where("fdgacreated_at", "<=", "{$dateRegisterFinal} 23:59:59"); } if ($dateUpdatedInit != "-" && $dateUpdatedFinal != "-") { $query->whereBetween("fdgaupdated_at", array("{$dateUpdatedInit} 000:", "{$dateUpdatedFinal} 23:59:59")); } elseif ($dateUpdatedInit != "-") { $query->where("fdgaupdated_at", ">=", "{$dateUpdatedInit}0:00:00"); } elseif ($dateUpdatedFinal != "-") { $query->where("fdgaupdated_at", "<=", "{$dateUpdatedFinal} :599"); } if ($dateCondition) { foreach ($dateCondition as $data) { if (in_array($data, $primary["metadatas"])) { if ($dateConditionInit != "-" && $dateConditionFinal != "-") { $query->whereBetween("fdga.{$data}", array("{$dateConditionInit} 00:0", "{$dateConditionFinal}3:59:59")); } elseif ($dateConditionInit != "-") { $query->where("fdga.{$data}", ">=", "{$dateConditionInit} 0:00"); } elseif ($dateConditionFinal != "-") { $query->where("fdga.{$data}", "<=", "{$dateConditionFinal} 23:59:59"); } } } } if (count($primary["metadatas"]) > 0) { $metadatas = $primary["metadatas"]; $query->where(function ($query) use($metadatas, $search) { $query->where("fdgmetadata_", "like", $search)->orWhere("fdgmetadata_02", "like", $search)->orWhere("fdgmetadata_03", "like", $search); foreach ($metadatas as $index => $data) { if (strpos(strtolower($data), "fecha") === false) { $query->orWhere("fdg.{$index}", "like", $search); } } }); } return $query->groupBy("fdgaid")->orderBy("fdgaupdated_at", "DESC"); } private function secondary($secondary, $file, $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search) { if ($dateCondition != "-") { if (is_string($dateCondition)) { $dateCondition = array($dateCondition); } } else { $dateCondition = false; } $query = DB::table("first_documentary_groups AS fdg")->select(array("fdgmetadata_", "fdgmetadata_03", "fdgrupdated_at", "uname", DB::raw("fdgr.{$file["index"]} AS archive"), DB::raw("'{$file["file"]}' AS document")))->leftJoin("relations AS rel", "relfirst_documentary_group_id", "=", "fdgid")->leftJoin("registers AS r", "rid", "=", "relregister_id")->leftJoin("fdg_registers AS fdgr", "fdgrregister_id", "=", "rid")->leftJoin("users AS u", "uid", "=", "fdgruser_id")->where("fdgcategory_id", "=", "e")->where("fdgr.{$file["index"]}", "!=", '')->where("fdgrstate", "=", "Inactivo"); if ($dateRegisterInit != "-" && $dateRegisterFinal != "-") { $query->whereBetween("fdgrcreated_at", array("{$dateRegisterInit} 00:00:00", "{$dateRegisterFinal}3:59:59")); } elseif ($dateRegisterInit != "-") { $query->where("fdgrcreated_at", ">=", "{$dateRegisterInit} :00:"); } elseif ($dateRegisterFinal != "-") { $query->where("fdgrcreated_at", "<=", "{$dateRegisterFinal}3:59:59"); } if ($dateUpdatedInit != "-" && $dateUpdatedFinal != "-") { $query->whereBetween("fdgrupdated_at", array("{$dateUpdatedInit} 000:", "{$dateUpdatedFinal}3:59:59")); } elseif ($dateUpdatedInit != "-") { $query->where("fdgrupdated_at", ">=", "{$dateUpdatedInit} 00:000"); } elseif ($dateUpdatedFinal != "-") { $query->where("fdgrupdated_at", "<=", "{$dateUpdatedFinal} 23:59:59"); } if ($dateCondition) { foreach ($dateCondition as $data) { if (in_array($data, $secondary["metadatas"])) { if ($dateConditionInit != "-" && $dateConditionFinal != "-") { $query->whereBetween("fdgr.{$data}", array("{$dateConditionInit} 00::", "{$dateConditionFinal} 239:59")); } elseif ($dateConditionInit != "-") { $query->where("fdgr.{$data}", ">=", "{$dateConditionInit} ::00"); } elseif ($dateConditionFinal != "-") { $query->where("fdgr.{$data}", "<=", "{$dateConditionFinal} :599"); } } } } if (count($secondary["metadatas"]) > 0) { $metadatas = $secondary["metadatas"]; $query->where(function ($query) use($metadatas, $search) { $query->where("fdgmetadata_01", "like", $search)->orWhere("fdgmetadata_02", "like", $search)->orWhere("fdgmetadata_", "like", $search); foreach ($metadatas as $index => $data) { if (strpos(strtolower($data), "fecha") === false) { $query->orWhere("r.{$index}", "like", $search); } } }); } return $query->groupBy("fdgrid")->orderBy("fdgrupdated_at", "DESC"); } }

namespace App\Http\Controllers; use App\Helpers\Helper; use Illuminate\Support\Facades\DB; use App\Models\Area; use App\Models\Category; class QueryDeleteController extends Controller { private $credits = array("DocSolicitud de Credito", "DocConsulta BIC/ASFI", "DocEvaluacion", "DocAprobacion", "DocDesembolso", "Doc_Garante Personal", "Doc_Garantia Prendaria", "Doc_Garantia DocCustodia", "Doc_Garantia Sujeta a Registro", "Doc_Garantia No Convencional", "Doc_Seguimiento"); private $giros = "giros al exterior"; private $garante = "doc_garante personal"; public function index() { $credentials = Helper::getAuthAvatar(); "e" = array("user" => $credentials, "permissions" => Helper::getObfuscateAreas($credentials), "categories" => Helper::getObfuscateCategories($credentials), "areas" => Area::where("state", "Activo")->orderByRaw("area ASC")->get(array("id", "area"))); return view("modulesquery-deleteindex")->with("e"); } public function getCategory($id) { "e" = array("ok" => true, "data" => array(array("id" => "1-Todos", "category" => "Todos"), array("id" => "1-Registro de Cliente", "category" => "Registro de Cliente"), array("id" => "1-Cuenta de Ahorro", "category" => "Cuenta de Ahorro"), array("id" => "1-Depósito a Plazo Fijo", "category" => "Depósito a Plazo Fijo"), array("id" => "1-Tarjeta de débito", "category" => "Tarjeta de débito"), array("id" => "1-Banca Electrónica", "category" => "Banca Electrónica"), array("id" => "1-Giros al exterior", "category" => "Giros al exterior"), array("id" => "1-Créditos", "category" => "Créditos"))); echo json_encode("e"); } public function getFormat($id) {  $output = array(); $structure = Category::where("id", "e")->get(array("structure"))->first(); $structure = json_decode($structure->structure, true); switch ("x") { case "Registro de Cliente": case "Cuenta de Ahorro": case "Depósito a Plazo Fijo": case "Tarjeta de débito": case "Banca Electrónica": case "Giros al exterior": $content = array("x"); $output = $this->getDataSolid($structure, $content); break; case "Todos": $output = array(array("title" => "Todos", "data" => array("W1siUC1hcmNoaXZlXzAxIiwiUC1hcmNoaXZlXzAyIiwiUC1hcmNoaXZlXzAzIiwiUC1hcmNoaXZlXzA0IiwiUC1hcmNoaXZlXzA1IiwiUC1hcmNoaXZlXzA2IiwiUC1hcmNoaXZlXzA3Il0sWyJhcmNoaXZlXzAxIiwiYXJjaGl2ZV8wMiIsImFyY2hpdmVfMDMiXSxbImFyY2hpdmVfMDQiLCJhcmNoaXZlXzA1Il0sWyJhcmNoaXZlXzA2IiwiYXJjaGl2ZV8wNyJdLFsiYXJjaGl2ZV8wOCJdLFsiYXJjaGl2ZV8wOSIsImFyY2hpdmVfMTAiLCJhcmNoaXZlXzExIl0sWyJhcmNoaXZlXzEyIiwiYXJjaGl2ZV8xMyJdLFsiYXJjaGl2ZV8xNCIsImFyY2hpdmVfMTUiXSxbImFyY2hpdmVfMTYiLCJhcmNoaXZlXzE3Il0sWyJhcmNoaXZlXzE4Il0sWyJhcmNoaXZlXzE5IiwiYXJjaGl2ZV8yMCIsImFyY2hpdmVfMjEiXSxbImFyY2hpdmVfMjIiLCJhcmNoaXZlXzIzIiwiYXJjaGl2ZV8yNCJdLFsiYXJjaGl2ZV8yNSIsImFyY2hpdmVfMjYiXSxbImFyY2hpdmVfMjciXSxbImFyY2hpdmVfMjgiLCJhcmNoaXZlXzI5Il0sWyJhcmNoaXZlXzMwIl0sWyJhcmNoaXZlXzMxIl1d" => "Todos"), "date" => array("W1siUC1tZXRhZGF0YV8wNCIsIlAtbWV0YWRhdGFfMDUiXSxbIm1ldGFkYXRhXzAzIl0sWyJtZXRhZGF0YV8wNiJdLFsibWV0YWRhdGFfMDkiXSxbIm1ldGFkYXRhXzEyIl0sWyJtZXRhZGF0YV8xNSJdXQ==" => "Todos"))); break; case "Créditos": $content = $this->credits; $output = $this->getDataSolid($structure, $content); break; } echo json_encode(array("ok" => true, "data" => $output)); } private function getDataSolid($structure, $content) { $content = array_map(function ($value) { return Helper::transformString($value); }, $content); $init = ''; if (in_array("registro de cliente", $content)) { $init = "P-"; }  $all = array(); $output = array(); $countM = 0; $countF = 0; $auxT = array(); foreach ($structure as $index => "e") { $aux = array(); if ($index == 1) { $countF = 0; $countM = 0; } $aux["title"] = "e"["title"]; foreach ("e"["files"] as $subdata) { if (in_array(Helper::transformString("e"["title"]), $content)) { $metadata = $init . "archive_" . str_pad((string) ($countF + 1), 2, "0", STR_PAD_LEFT); $aux["data"][$metadata] = $subdata["metadata"]; $all[] = $metadata; $auxT[$metadata] = $subdata["metadata"]; } $countF++; } foreach ("e"["metadatas"] as $subdata) { if (in_array(Helper::transformString("e"["title"]), $content)) { if (strpos(strtolower($subdata["metadata"]), "fecha") !== false) { $metadata = $init . "metadata_" . str_pad((string) ($countM + 1), 2, "0", STR_PAD_LEFT); $aux["date"][$metadata] = $subdata["metadata"]; } } $countM++; } if (in_array(Helper::transformString("e"["title"]), $content)) { $aux["data"] = array_merge(array(base64_encode(json_encode(array($all))) => "Todos"), $aux["data"]); $output[] = $aux; } } "e"T = array(); foreach ($auxT as $index => "e") { "e"T[] = $index; } "e"T = base64_encode(json_encode(array("e"T))); $contentT = array("title" => "Todos", "data" => array("{"e"T}" => "Todos")); foreach ($auxT as $index => "e") { $contentT["data"][$index] = "e"; } $output = array_merge(array($contentT), $output); return $output; } public function getData($hash, $page, $date1, $date2, $date1A, $date2A, $dateI, $dateF, $archive, $metadata, $search) {  $dateRegisterInit = $date1; $dateRegisterFinal = $date2; $dateUpdatedInit = $date1A; $dateUpdatedFinal = $date2A; if (strlen($metadata) > 13) { $metadata = base64_decode($metadata); } if (substr($metadata, 0, 2) == "P-") { $metadata = array(substr($metadata, 2)); } else { if (substr($metadata, 0, 1) == "[") { $dateCondition = array(); foreach (json_decode($metadata, true) as "e") { foreach ("e" as $subdata) { $dateCondition[] = substr($subdata, 0, 2) == "P-" ? substr($subdata, 2) : $subdata; } } $metadata = $dateCondition; } } $dateCondition = $metadata; $dateConditionInit = $dateI; $dateConditionFinal = $dateF; $search = base64_decode($search); if ($search == "-") { $search = ''; } $search = "%{$search}%"; if (strlen($archive) > 13) { $aux = json_decode(base64_decode($archive)); $archive = array(); foreach ($aux as "e") { foreach ("e" as $subdata) { if (substr($subdata, 0, 2) == "P-") { $archive["prince"][] = substr($subdata, 2); } else { $archive["secondary"][] = $subdata; } } } } else { $archive = substr($archive, 0, 2) == "P-" ? array("prince" => array(substr($archive, 2))) : array("secondary" => array($archive)); } $structure = $this->getStructure("e", "x", $archive); $queries = array(); if (isset($structure["prince"])) { foreach ($structure["prince"][0]["files"] as $index => $file) { $queries[] = $this->primary($structure["prince"][0], array("index" => $index, "file" => $file), $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search); } } if (isset($structure["secondary"])) { foreach ($structure["secondary"] as $secondary) { foreach ($secondary["files"] as $index => $file) { $queries[] = $this->secondary($secondary, array("index" => $index, "file" => $file), $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search); } } }  if (count($queries) > 1) { for ($i = 1; $i < count($queries); $i++) { "e"->union($queries[$i]); } } $response = "e"->orderBy("updated_at", "DESC")->get(); return json_decode(json_encode(array("data" => $response))); } private function getStructure($id_category, $title, $archive) { $structure = DB::table("categories")->where("id", $id_category)->get(array("structure"))->first(); $structure = json_decode($structure->structure, true); $countF = 1; $countM = 1; $newStructure = array(); foreach ($structure as $index => "e") { $auxF = array(); $auxM = array(); $sw = false; foreach ("e"["files"] as $subdata) { $number = str_pad($countF, 2, "0", STR_PAD_LEFT); if ($index == 0 && isset($archive["prince"]) && in_array("archive_{$number}", $archive["prince"]) || $index > 0 && isset($archive["secondary"]) && in_array("archive_{$number}", $archive["secondary"])) { $auxF["archive_{$number}"] = $subdata["metadata"]; $sw = true; } $countF++; } foreach ("e"["metadatas"] as $subindex => $subdata) { $number = str_pad($countM, 2, "0", STR_PAD_LEFT); if ($sw) { if (strpos(strtolower($subdata["metadata"]), "fecha") !== false) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } elseif (strtolower("e"["title"]) == $this->giros) { if ($subindex == 1) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } } elseif (strtolower("e"["title"]) == $this->garante) { if ($subindex == 0 || $subindex == 2) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } } elseif ($subindex == 0) { $auxM["metadata_{$number}"] = $subdata["metadata"]; } } $countM++; } if ($title == "Todos" || ($this->normalize($title) == $this->normalize("e"["title"]) || $title == "Créditos" && in_array("e"["title"], $this->credits))) { if ($index == 0) { $newStructure["prince"][] = array("title" => "e"["title"], "files" => $auxF, "metadatas" => $auxM); } else { $newStructure["secondary"][] = array("title" => "e"["title"], "files" => $auxF, "metadatas" => $auxM); } } if ($index == 0) { $countF = 1; $countM = 1; } } return $newStructure; } private function normalize($string) { return strtolower(preg_replace("/[\x{03}-\x{0f}]/u", "$1", normalizer_normalize(trim($string), \Normalizer::FORM_D))); } private function primary($primary, $file, $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search) { if ($dateCondition != "-") { if (is_string($dateCondition)) { $dateCondition = array($dateCondition); } } else { $dateCondition = false; } $query = DB::table("first_documentary_groups AS fdg")->select(array("fdgmetadata_01", "fdgmetadata_03", "fdgaupdated_at", "uname", DB::raw("fdga.{$file["index"]} AS archive"), DB::raw("'{$file["file"]}' AS document")))->leftJoin("fdg_archives AS fdga", "fdgafirst_documentary_group_id", "=", "fdgid")->leftJoin("users AS u", "uid", "=", "fdgauser_id")->where("fdgcategory_id", "=", "e")->where("fdga.{$file["index"]}", "!=", '')->where("fdgastate", "=", "Inactivo"); if ($dateRegisterInit != "-" && $dateRegisterFinal != "-") { $query->whereBetween("fdgacreated_at", array("{$dateRegisterInit} :00:00", "{$dateRegisterFinal} :59:59")); } elseif ($dateRegisterInit != "-") { $query->where("fdgacreated_at", ">=", "{$dateRegisterInit} 00::00"); } elseif ($dateRegisterFinal != "-") { $query->where("fdgacreated_at", "<=", "{$dateRegisterFinal} 23:59:59"); } if ($dateUpdatedInit != "-" && $dateUpdatedFinal != "-") { $query->whereBetween("fdgaupdated_at", array("{$dateUpdatedInit} 000:", "{$dateUpdatedFinal} 23:59:59")); } elseif ($dateUpdatedInit != "-") { $query->where("fdgaupdated_at", ">=", "{$dateUpdatedInit}0:00:00"); } elseif ($dateUpdatedFinal != "-") { $query->where("fdgaupdated_at", "<=", "{$dateUpdatedFinal} :599"); } if ($dateCondition) { foreach ($dateCondition as "e") { if (in_array("e", $primary["metadatas"])) { if ($dateConditionInit != "-" && $dateConditionFinal != "-") { $query->whereBetween("fdga.{"e"}", array("{$dateConditionInit} 00:0", "{$dateConditionFinal}3:59:59")); } elseif ($dateConditionInit != "-") { $query->where("fdga.{"e"}", ">=", "{$dateConditionInit} 0:00"); } elseif ($dateConditionFinal != "-") { $query->where("fdga.{"e"}", "<=", "{$dateConditionFinal} 23:59:59"); } } } } if (count($primary["metadatas"]) > 0) { $metadatas = $primary["metadatas"]; $query->where(function ($query) use($metadatas, $search) { $query->where("fdgmetadata_", "like", $search)->orWhere("fdgmetadata_02", "like", $search)->orWhere("fdgmetadata_03", "like", $search); foreach ($metadatas as $index => "e") { if (strpos(strtolower("e"), "fecha") === false) { $query->orWhere("fdg.{$index}", "like", $search); } } }); } return $query->groupBy("fdgaid")->orderBy("fdgaupdated_at", "DESC"); } private function secondary($secondary, $file, $category, $dateRegisterInit, $dateRegisterFinal, $dateUpdatedInit, $dateUpdatedFinal, $dateCondition, $dateConditionInit, $dateConditionFinal, $search) { if ($dateCondition != "-") { if (is_string($dateCondition)) { $dateCondition = array($dateCondition); } } else { $dateCondition = false; } $query = DB::table("first_documentary_groups AS fdg")->select(array("fdgmetadata_", "fdgmetadata_03", "fdgrupdated_at", "uname", DB::raw("fdgr.{$file["index"]} AS archive"), DB::raw("'{$file["file"]}' AS document")))->leftJoin("relations AS rel", "relfirst_documentary_group_id", "=", "fdgid")->leftJoin("registers AS r", "rid", "=", "relregister_id")->leftJoin("fdg_registers AS fdgr", "fdgrregister_id", "=", "rid")->leftJoin("users AS u", "uid", "=", "fdgruser_id")->where("fdgcategory_id", "=", "e")->where("fdgr.{$file["index"]}", "!=", '')->where("fdgrstate", "=", "Inactivo"); if ($dateRegisterInit != "-" && $dateRegisterFinal != "-") { $query->whereBetween("fdgrcreated_at", array("{$dateRegisterInit} 00:00:00", "{$dateRegisterFinal}3:59:59")); } elseif ($dateRegisterInit != "-") { $query->where("fdgrcreated_at", ">=", "{$dateRegisterInit} :00:"); } elseif ($dateRegisterFinal != "-") { $query->where("fdgrcreated_at", "<=", "{$dateRegisterFinal}3:59:59"); } if ($dateUpdatedInit != "-" && $dateUpdatedFinal != "-") { $query->whereBetween("fdgrupdated_at", array("{$dateUpdatedInit} 000:", "{$dateUpdatedFinal}3:59:59")); } elseif ($dateUpdatedInit != "-") { $query->where("fdgrupdated_at", ">=", "{$dateUpdatedInit} 00:000"); } elseif ($dateUpdatedFinal != "-") { $query->where("fdgrupdated_at", "<=", "{$dateUpdatedFinal} 23:59:59"); } if ($dateCondition) { foreach ($dateCondition as "e") { if (in_array("e", $secondary["metadatas"])) { if ($dateConditionInit != "-" && $dateConditionFinal != "-") { $query->whereBetween("fdgr.{"e"}", array("{$dateConditionInit} 00::", "{$dateConditionFinal} 239:59")); } elseif ($dateConditionInit != "-") { $query->where("fdgr.{"e"}", ">=", "{$dateConditionInit} ::00"); } elseif ($dateConditionFinal != "-") { $query->where("fdgr.{"e"}", "<=", "{$dateConditionFinal} :599"); } } } } if (count($secondary["metadatas"]) > 0) { $metadatas = $secondary["metadatas"]; $query->where(function ($query) use($metadatas, $search) { $query->where("fdgmetadata_01", "like", $search)->orWhere("fdgmetadata_02", "like", $search)->orWhere("fdgmetadata_", "like", $search); foreach ($metadatas as $index => "e") { if (strpos(strtolower("e"), "fecha") === false) { $query->orWhere("r.{$index}", "like", $search); } } }); } return $query->groupBy("fdgrid")->orderBy("fdgrupdated_at", "DESC"); } }



© 2023 Quttera Ltd. All rights reserved.