Commit 6dc508e0 authored by Sarun Mungthanya's avatar Sarun Mungthanya
Browse files

add new file master file patch , download manual response

parent 5f039424
......@@ -2,108 +2,265 @@
namespace App\Http\Controllers;
use App\Models\ConfFormatFile;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
class MasterFileController extends Controller
{
public function index()
{
$menu = 'MasterFile';
$currentContent = 'MasterFile';
return view('home', compact('menu', 'currentContent'));
}
public function processFile(Request $request)
public function createPatch(Request $request)
{
// Ensure the file is uploaded
if (!$request->hasFile('data') || !$request->file('data')->isValid()) {
return redirect()->back()->with('error', 'Invalid file upload.');
}
// Get file details
// Get file details
$file = $request->file('data');
// $request->validate([
// 'format_file_id' => 'required|exists:conf_format_file,formatservice_ID',
// 'file' => 'required|file|max:12209752',
// 'limit' => 'nullable|integer',
// 'noLimit' => 'nullable|boolean',
// 'genWithSmartUpdate' => 'nullable|boolean',
// 'createPatch' => 'nullable|boolean',
// 'sendToEec' => 'nullable|boolean',
// ]);
$file = $request->file('file');
$filePath = $file->getRealPath();
$filename = $file->getClientOriginalName();
// Get file details
$timestampEEC = now()->format('Y-m-d');
$actDateTime = now()->format('Y-m-d H:i:s');
// Fetch format name
$format = $request->input('format');
$config = DB::table('conf_format_file')
->where('file', $format)
->whereNotNull('ac')
->first();
if (!$config) {
return redirect()->back()->with('error', 'MasterFile Not config to EEC');
}
// Get file details
$typeEEC = $config->ac;
// eval('asdasd');
// Send file to EEC if applicable
if ($request->input('sendtoeec') === 'on' && !empty($typeEEC)) {
$response = Http::attach('file', fopen($filePath, 'r'), $filename)
->post(env('URL_MASTERFILE_EEC'), [
'type' => $typeEEC,
'timestamp' => $timestampEEC,
$fileFormat = ConfFormatFile::where('formatservice_ID', $request->format_file_id)->first();
$jsonFilePath = storage_path(str_replace(".inc", ".json", $fileFormat->file));
if (!file_exists($jsonFilePath)) {
return redirect()->back()->withErrors(['error' => 'Format JSON file not found.']);
}
$formatData = json_decode(file_get_contents($jsonFilePath), true);
$message = '';
if ($request->createPatch) {
$sqlPackAll = $this->readTxt($filePath, $formatData, $fileFormat, $request->limit, $request->noLimit);
$this->processPatches($sqlPackAll, $fileFormat, $request->genWithSmartUpdate);
$message .= 'Patch master file created successfully. ';
}
if ($request->sendToEec && !empty($fileFormat->ac)) {
$timestamp = Carbon::now()->toDateString();
$response = $this->sendMasterFileToEcc(config('services.eec.url'), [
'type' => $fileFormat->ac,
'file' => fopen($filePath, 'r'),
'timestamp' => $timestamp,
]);
$respStatus = $response->status();
$respData = $response->body();
DB::table('ecc_transactions')->insert([
'uid' => $request->input('UID'),
'type_eec' => $typeEEC,
'filename' => $filename,
'request_data' => json_encode([
'type' => $typeEEC,
'file' => $filename,
'timestamp' => $timestampEEC,
]),
'act_datetime' => $actDateTime,
'response_status' => $respStatus,
'response_data' => $respData,
$responseStatus = $response->status();
$responseData = $response->json();
$this->keepTransactionToEcc(auth()->id(), $fileFormat->ac, $file->getClientOriginalName(), json_encode([
'type' => $fileFormat->ac,
'timestamp' => $timestamp,
]), Carbon::now(), $responseStatus, json_encode($responseData));
$message .= 'Send to EEC successfully.';
}
return redirect()->route('patch.index')->with('message', $message);
}
private function sendMasterFileToEcc($url, $postData)
{
return Http::attach('file', $postData['file'])
->asMultipart()
->post($url, [
'type' => $postData['type'],
'timestamp' => $postData['timestamp'],
]);
}
if ($respStatus === 200) {
return redirect()->back()->with('success', 'Send MasterFile To EEC');
} else {
return redirect()->back()->with('error', 'Cannot Send MasterFile To EEC');
private function keepTransactionToEcc($uid, $type, $filename, $requestData, $datetime, $responseStatus, $responseData)
{
DB::table('log_send_master2eec')->insert([
'UID' => $uid,
'TYPE' => $type,
'FILENAME' => $filename,
'REQDATA' => $requestData,
'ACTDATETIME' => $datetime,
'RESPSTATUS' => $responseStatus,
'RESPDATA' => $responseData,
]);
}
private function processPatches($sqlPackAll, $fileFormat, $genWithSmartUpdate)
{
$uid = auth()->id();
$nameFormat = $fileFormat->name ?? 'Unknown Format';
$level = "Critical";
$date = Carbon::now();
foreach ($sqlPackAll as $index => $sqlPack) {
$patchCode = $this->generatePatchCode($sqlPack, $genWithSmartUpdate);
$this->savePatch($patchCode, $nameFormat, $level, $uid, $date);
}
}
// Process file and create patches
if ($request->input('createpatch') === 'on') {
$data = $this->readTxt($filePath, $format, $request->input('ac'), $request->input('sizerow'), $request->input('notsplit'));
private function generatePatchCode($sqlPack, $genWithSmartUpdate)
{
$all64 = base64_encode(gzcompress(iconv('UTF-8', 'TIS-620', var_export($sqlPack, true))));
$patchCode = "\$ALL64=\"{$all64}\";\n";
if ($genWithSmartUpdate) {
$patchCode .= "\$ALLVAR=gzuncompress(spnsmartupdatedecode(\$ALL64));\n";
} else {
$patchCode .= "\$ALLVAR=gzuncompress(base64_decode(\$ALL64));\n";
}
foreach ($data as $key => $sqlPack) {
$patchCode = $this->generatePatchCode($sqlPack);
return $patchCode;
}
private function savePatch($patchCode, $nameFormat, $level, $uid, $date)
{
DB::table('conf_smartupdate')->insert([
'patchname' => "Update Master File {$config->name} วันที่ " . now()->format('j') . ' เดือน ' . now()->format('n') . ' ปี ' . now()->format('Y') . ' Part ' . ($key + 1),
'pdate' => now(),
'plevel' => 'Critical',
'pcode' => 'SHIPPINGNET',
'major_version' => 'ALL',
'pdesc' => $config->name,
'powner' => $request->input('UID'),
'ptype' => 'UPDATE MASTER',
'papprovedate' => now(),
'patchcode' => $patchCode,
'uninstall' => 'DONE=1;',
'patchcode_server' => 'DONE=1;',
'PATCHNAME' => "Update Master File {$nameFormat} " . $date->toFormattedDateString(),
'PDATE' => $date,
'PLEVEL' => $level,
'PCODE' => 'SHIPPINGNET',
'PDESC' => $nameFormat,
'POWNER' => $uid,
'PTYPE' => 'UPDATE MASTER',
'PATCHCODE' => iconv("UTF-8", "TIS-620", $patchCode),
]);
}
return redirect()->back()->with('success', 'Successful Created Patch.');
private function readTxt($filePath, $formatData, $ac, $limit = 10000 , $noLimit = false)
{
ini_set('memory_limit', '-1');
$sqlPackAll = [];
$count = 0;
$fileHandle = fopen($filePath, "r");
while (!feof($fileHandle)) {
$sqlPack = [];
$text = fgets($fileHandle);
try {
$text = iconv('TIS-620', 'UTF-8', $text);
} catch (\Throwable $th) {
$encoding = mb_detect_encoding($text, ['UTF-8', 'ISO-8859-1', 'ASCII'], true);
$text = iconv($encoding, 'UTF-8', $text);
}
$X = $Y = $Z = 0;
$primaryKeyConditions = [];
foreach ($formatData['primary_key'] as $keyIndex => $primaryKey) {
$fieldFormat = $formatData['format'][$keyIndex];
$type = $fieldFormat['TYPE'];
if (strpos($type, 'DE') !== false) {
$type = str_replace('DE', '', $type);
$type = (int) $type + 1;
}
$type = (int) filter_var($type, FILTER_SANITIZE_NUMBER_INT);
$fieldValue = mb_substr($text, $Y, $type, 'UTF-8');
$Y += $type;
if ($fieldFormat['FORMAT'] === 'date') {
$fieldValue = $this->convertDate($fieldValue);
}
$primaryKeyConditions[] = $primaryKey['FILD'] . " = '" . trim($fieldValue) . "'";
}
$select2[] = " WHERE ".implode(' AND ', $primaryKeyConditions);
$select[] = "SELECT * FROM " . $formatData['database'] . " ". " WHERE ".implode(' AND ', $primaryKeyConditions);
$insertFields = [];
$insertValues = [];
foreach ($formatData['format'] as $fieldFormat) {
$type = $fieldFormat['TYPE'];
if (strpos($type, 'DE') !== false) {
$type = str_replace('DE', '', $type);
$type = (int) $type + 1;
}
$type = (int) filter_var($type, FILTER_SANITIZE_NUMBER_INT);
$fieldValue = mb_substr($text, $X, $type, 'UTF-8');
$X += $type;
if ($fieldFormat['FORMAT'] === 'date') {
$fieldValue = $this->convertDate($fieldValue);
}
$insertFields[] = "`" . $fieldFormat['FILD'] . "`";
$insertValues[] = "'" . str_replace("'", "''", trim($fieldValue)) . "'";
}
$insert[] = "INSERT INTO " . $formatData['database'] . " (". implode(',', $insertFields) . ") VALUES (" . implode(',', $insertValues) . ")";
$update[] = $this->generateUpdateQuery($formatData['format'], $text, $Z, $formatData['primary_key']);
$sqlPack = [
'insert' => $insert,
'update' => $update,
'select' => $select,
'select2' => $select2,
'DATABASE' => $formatData['database'],
'counter' => $count+=1
];
if ($count > $limit) {
$sqlPackAll[]=$sqlPack;
$count = 0;
unset($sqlPack);
}
}
fclose($fileHandle);
return $sqlPackAll;
}
private function generateUpdateQuery($formatData, $text, &$Z, $primaryKeys)
{
$update = "";
foreach ($formatData as $index => $fieldFormat) {
$type = $fieldFormat['TYPE'];
if (strpos($type, 'DE') !== false) {
$type = str_replace('DE', '', $type);
$type = (int) $type + 1;
}
$type = (int) filter_var($type, FILTER_SANITIZE_NUMBER_INT);
$fieldValue = mb_substr($text, $Z, $type, 'UTF-8');
$Z += $type;
if ($fieldFormat['FORMAT'] === 'date') {
$fieldValue = $this->convertDate($fieldValue);
}
if (!in_array($fieldFormat['FILD'], array_column($primaryKeys, 'FILD'))) {
if ($update != "") {
$update .= ", ";
}
$update .= "`" . $fieldFormat['FILD'] . "` = '" . str_replace("'", "''", trim($fieldValue)) . "'";
}
}
return redirect()->back()->with('error', 'File processing failed.');
return $update;
}
}
......@@ -13,13 +13,14 @@ use App\Models\ManualResponse\MasterResponseTemplates;
use App\Models\ManualResponse\MasterDocTypes;
use App\Models\ManualResponse\TabManualResponseLog;
use App\Models\ManualResponse\UsersConnectSpn;
use App\Models\MasterResponseMessageType;
use Carbon\Carbon;
use CURLFile;
class ManualResponse extends Component
{
public $displayCustomizeDiv = false;
public $masterMsg , $showSearch;
public $messageTypes = [];
public $messageId;
public $responseTemplates = [];
......@@ -307,4 +308,40 @@ class ManualResponse extends Component
}
return true;
}
public function downloadXML(){
$tempCode = MasterResponseTemplates::find($this->templateId);
$fileName = $this->xmlData['DeclarationNumber']??''.'-'.$tempCode->code.'-'.str_replace("/","-",$this->xmlData['Message']).'.xml';
$xmlContent = $this->xmlContent;
\Storage::disk('public')->put($fileName, $xmlContent);
$this->emit('fileManualDownload', asset('storage/' . $fileName));
}
public function selectMessage($masterMsgId) {
$message = MasterResponseMessageType::where('id', $masterMsgId)->first();
$this->xmlData["Message"] = $message->message;
$this->reGenerateXML();
$this->showSearch = false;
}
public function updatedXmlData($value, $key)
{
if ($key === 'Message') {
$this->showSearch = true;
$tempCode = MasterResponseTemplates::find($this->templateId);
$tempDoc = MasterMessages::find($this->messageId);
if ($tempCode && $tempDoc) {
$message = MasterResponseMessageType::where('doctype', strtoupper($tempDoc->name))
->where('codestatus', $tempCode->code)
->where('message', 'like', '%' . $value . '%')
->get();
} else {
$message = collect(); // Return an empty collection if no data is found
}
$this->masterMsg = $message;
}
}
}
......@@ -9,21 +9,26 @@ use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Http;
use Livewire\WithFileUploads;
use Illuminate\Http\UploadedFile;
use Facades\Livewire\GenerateSignedUploadUrl;
use Illuminate\Validation\ValidationException;
use Livewire\Exceptions\S3DoesntSupportMultipleFileUploads;
use Livewire\FileUploadConfiguration;
use Illuminate\Support\Facades\Storage;
use Livewire\TemporaryUploadedFile;
use App\Traits\CustomTemporaryFileUpload;
class PatchMasterFile extends Component
{
use WithFileUploads;
use CustomTemporaryFileUpload;
public $file, $format_file_id, $messages, $formatFile, $limit, $noLimit, $genPatch, $createPatch = false, $sendToEec = false, $genWithSmartUpdate = false;
protected $formatFiles;
protected $rules = [
'name' => 'required|string|max:255',
// 'files.*' => 'required|file|max:100000',
'files.*' => 'required|file|max:12209752',
];
public function mount() {
}
public function createPatch()
{
......
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class MasterResponseMessageType extends Model
{
use HasFactory;
protected $connection = 'localhost';
protected $table = 'master_responsemessagetype';
}
......@@ -64,6 +64,27 @@ return [
]) : [],
],
'localhost' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL_LOCAL'),
'host' => env('DB_HOST_LOCAL', '127.0.0.1'),
'port' => env('DB_PORT_LOCAL', '3306'),
'database' => env('DB_DATABASE_LOCAL', 'forge'),
'username' => env('DB_USERNAME_LOCAL', 'forge'),
'password' => env('DB_PASSWORD_LOCAL', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => false,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
PDO::ATTR_PERSISTENT => true,
]) : [],
],
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
......
......@@ -62,6 +62,12 @@
{{ $script }}
@endisset
@yield('script')
<script>
console.log("ddd")
Livewire.on('fileDownloaded', (url) => {
window.location.href = url;
});
</script>
</body>
</html>
......@@ -31,7 +31,7 @@
x-transition:enter-start="opacity-0 -translate-x-full" x-transition:enter-end="opacity-100 translate-x-0"
x-transition:leave="transition ease-in duration-300 transform"
x-transition:leave-start="opacity-100 translate-x-0" x-transition:leave-end="opacity-0 -translate-x-full">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="black" viewBox="0 0 24 24" stroke="black">
<svg xmlns="http://www.w3.org/2000/svg" x-show="!sidebarOpen" class="h-6 w-6" fill="black" viewBox="0 0 24 24" stroke="black">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16m-7 6h7" />
</svg>
</button>
......
<div class="bg-main-container mt-1 z-0 w-full">
<div class="bg-main-container mt-1 z-0 "
:class="sidebarOpen
?
(window.innerWidth < 1500 ? (window.innerWidth < 1300 ? 'w-[90%] justify-self-end' :
'w-[95%] justify-self-end') : 'w-full') :
'w-full'">
<link href="{{ asset('css/pages/patch.css') }}" rel="stylesheet">
<div wire:loading.delay wire:loading.class.remove="hidden"
......@@ -10,7 +15,6 @@
</div>
</div>
{{-- end loading --}}
<div wire:loading.remove class="bg-main-container">
@switch($currentContent)
......@@ -71,7 +75,8 @@
@break
@case('MasterFile')
<livewire:pages.patch.patch-master-file wire:init />
@include('patch.patch-master-file')
{{-- <livewire:pages.patch.patch-master-file wire:init /> --}}
@break
@case('FormatFileMaster')
......@@ -83,17 +88,14 @@
@break
@case('ManualResponse')
<livewire:pages.manual-response.manual-response/>
<livewire:pages.manual-response.manual-response />
@break
@default
@livewire('code-comparer')
@endswitch
<x-modals.alert-modal name="alert-modal"></x-modals.alert-modal>
</div>
<script>
// document.addEventListener('livewire:load', function () {
// $(".card").html("dddd")
// });
</script>
</div>
......@@ -96,16 +96,41 @@
<div class="w-4/12">
<div class="w-12/12 py-1">
@foreach ($xmlData as $key => $value)
@if ($key == 'Message')
<label class="block">
<span class="text-sm font-medium text-slate-700">{{ $key }}</span>
<span class="relative mt-1.5 mb-1.5 flex">
<input
class="form-input peer w-full rounded-lg border border-slate-300 px-3 py-2 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
type="text" id="{{ $key }}"
wire:model="xmlData.{{ $key }}" value="{{ $value }}"
type="text" id="{{ $key }}" wire:model="xmlData.{{ $key }}" value="{{ $value }}"
autocomplete="off" />
@if (!empty($masterMsg) && $showSearch)
<ul
class="z-50 border border-gray-200 top-8 rounded-md max-h-64 w-full overflow-auto absolute bg-white mt-1">
@forelse ($masterMsg as $m)
<li class="p-2 hover:bg-gray-100 cursor-pointer"
wire:click="selectMessage('{{ $m->id }}')"> {{ $m->message }}
</li>
@empty
<li class="p-2 text-gray-500">No results found</li>
@endforelse
</ul>
@endif
</span>
</label>
@else
<label class="block">
<span class="text-sm font-medium text-slate-700">{{ $key }}</span>
<span class="relative mt-1.5 mb-1.5 flex">
<input
class="form-input peer w-full rounded-lg border border-slate-300 px-3 py-2 placeholder:text-slate-400/70 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:hover:border-navy-400 dark:focus:border-accent"
type="text" id="{{ $key }}" wire:model="xmlData.{{ $key }}" value="{{ $value }}"
autocomplete="off" />
</span>
</label>
@endif
@endforeach
</div>
</div>
......@@ -115,13 +140,14 @@
</div>
<div class="bg-gray-100 p-4 rounded-lg">
<!-- Highlight.js Code Block -->
<pre class="is-scrollbar-hidden max-h-96 overflow-auto rounded-lg" x-data x-init="hljs.highlightElement($el);"><code class="xml">{{ $xmlContent }}</code></pre>
<pre class="is-scrollbar-hidden max-h-96 overflow-auto rounded-lg p-4" x-data x-init="hljs.highlightElement($el);"><code class="xml">{{ $xmlContent }}</code></pre>
</div>
<div class="flex justify-center items-center pt-1">
<button
class="bg-slate-150 font-medium text-slate-800 hover:bg-slate-200 focus:bg-slate-200 active:bg-slate-200/80 rounded-md border border-[#e5e7eb] py-2 px-4 mr-1"
wire:click="reGenerateXML">
<i class="fa-solid fa-rotate mr-1"></i>Reload XML</button>
<button class="bg-slate-150 font-medium text-slate-800 hover:bg-slate-200 focus:bg-slate-200 active:bg-slate-200/80 rounded-md border border-[#e5e7eb] py-2 px-4 mr-1" wire:click="downloadXML" ><i class="fa fa-download mr-1" aria-hidden="true"></i>Download File</button>
</div>
</div>
</div>
......@@ -133,4 +159,16 @@
@endif
@include('livewire.loading-component', ['action' => 'generateAndUploadXml, messageId'])
</div>
<script>
document.addEventListener('livewire:load', () => {
Livewire.on('fileManualDownload', (url) => {
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', '');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
});
</script>
</div>
......@@ -65,7 +65,7 @@
<div class="mx-3 mt-3">
<div class="is-scrollbar-hidden min-w-full table-responsive" x-data="pages.tables.initExample1">
<table aria-describedby="mydesc" class="is-hoverable table w-full text-left border-b">
<table aria-describedby="mydesc" class="is-hoverable table w-full text-left border-b text-black">
<thead>
<tr>
<th scope="col"
......
<div class="bg-main-container">
<div class="max-w-full mx-auto p-5 ">
{{-- <div class="flex flex-wrap items-center"> --}}
<h2 class="text-2xl text-black ">
Server License Management
</h2>
<a type="button" href="/server-license"
class="btn m-3 text-white bg-primary px-3 py-2 hover:bg-primary-focus">Back</a>
......
@php
$formatFiles = App\Models\ConfFormatFile::all();
@endphp
<div class="bg-main-container" x-data="{ notLimit: false }">
<div class="max-w-full mx-auto p-6">
<div class="flex justify-between items-center mb-6">
<h2 class="text-3xl font-semibold text-gray-800">Patch Master File</h2>
<a href="/patch" class="btn text-white bg-primary px-4 py-2 rounded hover:bg-primary-focus">
Back
</a>
</div>
<form action="{{ route('patch.master-file.create') }}" method="POST" enctype="multipart/form-data">
@csrf
<div class="bg-white p-6 rounded-lg shadow-md">
<div class="mb-4">
<label for="format_file_id" class="block text-gray-700 font-medium">Choose Format File</label>
<select id="format_file_id" name="format_file_id"
class="w-full mt-2 p-3 border border-gray-300 rounded-lg focus:ring-primary focus:border-primary">
@foreach ($formatFiles as $format)
<option value="{{ $format->formatservice_ID }}">{{ $format->name }}</option>
@endforeach
</select>
</div>
<div class="mb-4">
<label for="upload_file" class="block text-gray-700 font-medium">Upload File Data</label>
<div class="flex items-center mt-2">
<!-- Loading Spinner -->
<span id="loading-spinner" class="hidden">
<svg class="animate-spin h-5 w-5 text-primary m-3" xmlns="http://www.w3.org/2000/svg"
fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor"
stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.964 7.964 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z">
</path>
</svg>
</span>
<label for="file-upload"
class="btn bg-gray-200 text-gray-800 hover:bg-gray-300 focus:bg-gray-300 active:bg-gray-300 dark:bg-gray-500 dark:text-gray-50 dark:hover:bg-gray-450 dark:focus:bg-gray-450 dark:active:bg-gray-450/90 relative">
<input tabindex="-1" id="file-upload" type="file" name="file"
class="absolute inset-0 h-full w-full opacity-0 cursor-pointer"
onchange="handleFileUpload(event)" />
<div class="flex items-center space-x-2">
<svg xmlns="http://www.w3.org/2000/svg" class="w-5 h-5" fill="none"
viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L8 8m4-4v12" />
</svg>
<span>Choose File</span>
</div>
</label>
<span id="file-name" class="ml-4 text-gray-600"></span>
<button id="remove-file" type="button" class="ml-4 text-red-500 hover:text-red-700 hidden"
onclick="removeFile()">
<i class="fa fa-remove"></i> Remove File
</button>
</div>
@error('file')
<span class="text-red-600 text-sm mt-2">{{ $message }}</span>
@enderror
</div>
<div class="mb-4">
<label for="limit_data" class="block text-gray-700 font-medium">Limit Data per Patch</label>
<select id="limit_data"
class="w-full mt-2 p-3 border border-gray-300 rounded-lg focus:ring-primary focus:border-primary"
:disabled="notLimit" name="limit">
<option value="10000">10,000</option>
<option value="5000">5,000</option>
<option value="3000">3,000</option>
<option value="1000">1,000</option>
</select>
<div class="mt-3">
<label class="inline-flex items-center">
<input
class="form-checkbox is-basic h-4 w-4 rounded border-slate-400/70 checked:bg-primary checked:border-primary focus:bordark:bg-navy-900 dark:border-navy-500 dark:checked:bg-accent dark:checked:border-accent dark:hover:border-accent dark:focus:border-accent"
type="checkbox" name="noLimit" />
<span class="ml-2">Not Limit</span>
</label>
</div>
</div>
<div class="mb-4">
<label class="inline-flex items-center">
<input name="genWithSmartUpdate"
class="form-checkbox is-basic h-4 w-4 rounded border-slate-400/70 checked:bg-primary checked:border-primary focus:border-primary dark:bg-navy-900 dark:border-navy-500 dark:checked:bg-accent dark:checked:border-accent dark:hover:border-accent dark:focus:border-accent"
type="checkbox" value="checked">
<span class="ml-2">Gen patch วย function spnsmartupdatedecode</span>
</label>
</div>
<div class="mb-4 flex items-center space-x-4">
<label class="inline-flex items-center">
<input name="createPatch"
class="form-checkbox is-basic h-4 w-4 rounded border-slate-400/70 checked:bg-primary checked:border-primary focus:border-primary dark:bg-navy-900 dark:border-navy-500 dark:checked:bg-accent dark:checked:border-accent dark:hover:border-accent dark:focus:border-accent"
type="checkbox" value="checked">
<span class="ml-2">Create Patch</span>
</label>
<label class="inline-flex items-center">
<input name="sendToEec"
class="form-checkbox is-basic h-4 w-4 rounded border-slate-400/70 checked:bg-primary checked:border-primary focus:border-primary dark:bg-navy-900 dark:border-navy-500 dark:checked:bg-accent dark:checked:border-accent dark:hover:border-accent dark:focus:border-accent"
type="checkbox" value="checked">
<span class="ml-2">Send To EEC</span>
</label>
</div>
<div class="text-right">
<button
class="bg-primary text-white px-4 py-2 rounded-md hover:bg-primary-focus focus:outline-none focus:ring-2 focus:ring-primary focus:ring-opacity-50"
type="submit">
Create Patch
</button>
</div>
</div>
</form>
</div>
</div>
<script>
function handleFileUpload(event) {
const fileInput = event.target;
const fileNameDisplay = document.getElementById('file-name');
const removeButton = document.getElementById('remove-file');
const loadingSpinner = document.getElementById('loading-spinner');
loadingSpinner.classList.remove('hidden');
if (fileInput.files.length > 0) {
const fileName = fileInput.files[0].name;
fileNameDisplay.textContent = `Selected File: ${fileName}`;
removeButton.classList.remove('hidden');
} else {
fileNameDisplay.textContent = '';
removeButton.classList.add('hidden');
}
setTimeout(() => {
loadingSpinner.classList.add('hidden');
}, 1000);
}
function removeFile() {
const fileInput = document.getElementById('file-upload');
const fileNameDisplay = document.getElementById('file-name');
const removeButton = document.getElementById('remove-file');
fileInput.value = '';
fileNameDisplay.textContent = '';
removeButton.classList.add('hidden');
}
</script>
......@@ -63,6 +63,9 @@ Route::middleware(['auth' ])->group(function () {
Route::get('/master-file', [MasterFileController::class, 'index'])->name('master-file.index');
Route::post('/masterfile/create', [MasterFileController::class, 'createPatch'])->name('patch.master-file.create');
Route::get('/format-file-master', [FormatFileMasterContrller::class, 'index'])->name('format-file-master.index');
Route::get('/send-patch', [SendPatchController::class, 'index']);
Route::get('/send-multi-patch', [SendPatchController::class, 'indexMulti']);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment