Commit 4f0b5c36 authored by Sarun Mungthanya's avatar Sarun Mungthanya
Browse files

update master file RFPMG & fix issue pageinate & send patch

parent 657b13e4
......@@ -33,6 +33,11 @@ class MasterFileController extends Controller
$file = $request->file('file');
$filePath = $file->getRealPath();
if(isset($request->truncateGoods) && ($request->format_file_id == 196)) {
$truncateGoods = true ;
}
$fileFormat = ConfFormatFile::where('formatservice_ID', $request->format_file_id)->first();
$jsonFilePath = storage_path(str_replace(".inc", ".json", $fileFormat->file));
......@@ -46,7 +51,7 @@ class MasterFileController extends Controller
if ($request->createPatch) {
$sqlPackAll = $this->readTxt($filePath, $formatData, $fileFormat, $request->limit, $request->noLimit);
$this->processPatches($sqlPackAll, $fileFormat, $request->genWithSmartUpdate, $request->noLimit);
$this->processPatches($sqlPackAll, $fileFormat, $request->genWithSmartUpdate, $request->noLimit , $truncateGoods);
$message .= 'Patch master file created successfully. ';
}
......@@ -95,7 +100,7 @@ class MasterFileController extends Controller
]);
}
function processPatches($sqlPackAll, $fileFormat, $genSpnSmartUpdateDecode, $noLimit)
function processPatches($sqlPackAll, $fileFormat, $genSpnSmartUpdateDecode, $noLimit , $truncateGoods)
{
$uid = auth()->user()->id;
$pLevel = "Critical";
......@@ -121,10 +126,27 @@ class MasterFileController extends Controller
$tis620_encoded = iconv('UTF-8', 'Windows-874',var_export($sqlPack, true));
// $tis620_encoded = var_export($sqlPack, true);
// dd($tis620_encoded);
$patchCode = '';
if($truncateGoods) {
$patchCode .= '$sql = "truncate table master_permissiongoods";
exec_query($sql);
if ($DBTYPE == "MSSQL") {
$Count_CONSTRAINT = Query2ArrayVarPack("SELECT COUNT(TC.CONSTRAINT_NAME) AS count_CONSTRAINT,TC.CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC
INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KU ON TC.CONSTRAINT_TYPE = "PRIMARY KEY"
AND TC.CONSTRAINT_NAME = KU.CONSTRAINT_NAME
and ku.table_name="master_permissiongoods"
GROUP BY TC.CONSTRAINT_NAME");
if ($Count_CONSTRAINT["count_CONSTRAINT"][0] != 5) {
exec_query("ALTER TABLE [master_permissiongoods] DROP CONSTRAINT [" . $Count_CONSTRAINT["CONSTRAINT_NAME"][0] . "]");
exec_query("ALTER TABLE [master_permissiongoods] ADD CONSTRAINT [" . $Count_CONSTRAINT["CONSTRAINT_NAME"][0] . "] PRIMARY KEY([tariffClass],[tariffStat],[startDate],[permissionGoodsType],[companyTaxNo])");
}
}';
}
$ALL64 = base64_encode(gzcompress($tis620_encoded));
$patchCode = '$ALL64="' . $ALL64 . '";' . "\n";
$patchCode .= '$ALL64="' . $ALL64 . '";' . "\n";
if ($genSpnSmartUpdateDecode) {
$updatedecode = '$ALLVAR=gzuncompress(spnsmartupdatedecode($ALL64));' . "\n";
......
......@@ -22,7 +22,7 @@ class SendPatchEdit extends Component
public $selectedPenddings = [];
public $serverkey = '', $showSearch = false, $searchInProgress = false, $resultsServerkey = [];
public $serverKeyWaitingSend = [], $serverKeySuccess = [];
protected $listeners = ['deletePatch', 'refreshComponent' => '$refresh'];
protected $listeners = ['deletePatch', 'refreshComponent' => '$refresh' , 'sendPatch'];
public function mount($editPid)
{
$this->PID = $editPid;
......@@ -139,15 +139,11 @@ class SendPatchEdit extends Component
public function sendPatch()
public function sendPatch($serverKeyWaitingSend)
{
$arr_server_lists = $this->serverKeyWaitingSend;
if (isset($arr_server_lists)) {
if (isset($serverKeyWaitingSend)) {
foreach ($arr_server_lists as $server) {
foreach ($serverKeyWaitingSend as $server) {
$serverPedding = new ConfServerPendding;
$serverPedding->ServerID = $server["id"];
$serverPedding->PatchID = $this->PID;
......@@ -162,7 +158,7 @@ class SendPatchEdit extends Component
$this->emit('patchSent', $server);
}
}
$this->serverKeyWaitingSend = [];
// $this->serverKeyWaitingSend = [];
}
public function resendPatch($serverId)
......
<div class="border-0 shadow-none" x-data="{ open: @entangle('showSearch'), serverKeySuccess: [] ,serverKeyWaitingSend: @entangle('serverKeyWaitingSend').defer }">
<div class="border-0 shadow-none" x-data="{
open: @entangle('showSearch'),
serverKeySuccess: [],
serverKeyWaitingSend: [],
loading: false,
serverKeySelect(id, value) {
this.serverKeyWaitingSend.push({ id, value });
},
removeServerKey(id) {
this.serverKeyWaitingSend = this.serverKeyWaitingSend.filter(item => item.id !== id);
},
sendPatch() {
this.loading = true;
Livewire.emit('sendPatch', this.serverKeyWaitingSend);
this.serverKeyWaitingSend = [];
}
}">
<div wire:loading.class="" wire:loading.class.remove="hidden" wire:target="save"
class="absolute inset-0 items-center justify-center z-50 bg-slate-50 dark:bg-navy-900 hidden">
<div class="flex justify-center items-center ">
......@@ -8,7 +24,7 @@
</div>
</div>
<div class="mt-5 mb-2 flex h-8 place-content-center px-4 " x-data="{serverKeyWaitingSend2: @entangle('serverKeyWaitingSend')}">
<div class="mt-5 mb-2 flex h-8 place-content-center px-4 " x-data="{ serverKeyWaitingSend2: @entangle('serverKeyWaitingSend') }">
<h2 class="text-xl text-slate-800">
Send Patch to Customer
</h2>
......@@ -16,15 +32,14 @@
class="ml-3 text-xl text-slate-800 font-semibold underline underline-offset-4 cursor-pointer">
Send
</h2>
<h2
class="ml-3 text-xl text-slate-800 font-semibold underline underline-offset-4 cursor-pointer">
<a href="{{ route('patch.edit', ['editPid' => $PID]) }}" target="_blank">
{{ $patchName }}
</a>
</h2>
<h2 class="ml-3 text-xl text-slate-800 font-semibold underline underline-offset-4 cursor-pointer">
<a href="{{ route('patch.edit', ['editPid' => $PID]) }}" target="_blank">
{{ $patchName }}
</a>
</h2>
</div>
<a href="/send-patch" type="button" class="btn ml-1 my-3 text-white bg-primary px-3 py-2">Back</a>
<div class="rounded-md" >
<div class="rounded-md">
<div class="" x-data="{ tomGReady: false }" x-show="true">
<div class="mb-4">
<div class="grid grid-cols-12 gap-2 ">
......@@ -37,7 +52,7 @@
<div class="relative flex items-center w-full">
<input type="text"
class="form-input h-9 peer w-full rounded-lg border border-slate-300 bg-transparent 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"
wire:model.debounce.500ms="serverkey" placeholder="Search for a server key">
wire:model.debounce.100ms="serverkey" placeholder="Search for a server key">
<span wire:loading
wire:target="serverkey, selectedOwnerType, company, db_type, cur_ver, selectAllResults"
class="absolute right-3">
......@@ -53,15 +68,16 @@
</div>
@if ($showSearch)
<ul x-show="open" @click.away="open = false"
class="absolute left-0 right-0 mt-2 border border-gray-200 rounded-md max-h-64 overflow-auto z-50 bg-white">
<ul x-show="open" @click.away="open = false"
class="absolute left-0 right-0 border border-gray-200 rounded-md max-h-64 overflow-auto z-50 bg-white">
<li class="p-2 bg-gray-200 hover:bg-gray-300 cursor-pointer font-semibold"
wire:click="selectAllResults">
Select All
</li>
@forelse($resultsServerkey as $result)
<li class="p-2 hover:bg-gray-100 cursor-pointer"
wire:click="selectResult('{{ $result->SNKEY }}')">
<li class="p-2 hover:bg-gray-100 cursor-pointer active:bg-[#065f46]"
@click="serverKeySelect('{{ $result->ID }}', '{{ $result->SNKEY }}')"
value="{{ $result->SNKEY }}">
{{ $result->SNKEY }}
</li>
@empty
......@@ -81,7 +97,8 @@
class="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
<option value="">Please Select</option>
@foreach ($ownerType as $type)
<option value="{{ $type->owntype_code }}">{{ $type->owntype_description }}
<option value="{{ $type->owntype_code }}">
{{ $type->owntype_description }}
</option>
@endforeach
</select>
......@@ -116,52 +133,51 @@
</div>
</div>
</div>
<!-- Company Select Group -->
{{-- <div>
<h3 class="text-lg font-medium text-gray-900 mb-2">Company Selection</h3>
<div>
<label for="company_select"
class="block text-sm font-medium text-gray-700">Company</label>
<select id="company_select" name="company_select"
class="mt-1 block w-full py-2 px-3 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
<option>Please select company</option>
<!-- Options -->
</select>
</div>
</div> --}}
</div>
<div class="card p-6 rounded-lg shadow-md col-span-4">
<h3 class="text-lg font-medium text-gray-900 mb-2">Server key waiting to send</h3>
<div id="serverkey-list" class="overflow-y-auto max-h-[70vh]">
<div class="bg-gray m-3">
@foreach ($serverKeyWaitingSend as $key => $serverkey)
<div class="flex items-center bg-blue-500 text-white w-full px-4 py-2 rounded m-1">
<span class="flex-grow">{{ $serverkey['key'] }}</span>
<button wire:click="removeServerKey('{{ $serverkey['key'] }}')" class="ml-2">
<template x-for="(serverkey, index) in serverKeyWaitingSend" :key="index">
<div class="flex items-center bg-[#3d6a4d] text-white w-full px-4 py-2 rounded m-1">
<span class="flex-grow" x-text="serverkey.value"></span>
<button @click="removeServerKey(serverkey.id)" class="ml-2">
<i aria-hidden="true" class="fas fa-trash-alt"></i>
</button>
</div>
@endforeach
</template>
</div>
</div>
</div>
<div class="grid grid-cols-1 place-items-center">
<div class="rounded-lg">
<div class="flex justify-center items-center mb-4 space-x-2">
<button type="button" wire:click="sendPatch"
<button type="button" @click="sendPatch" x-show="!loading"
class="bg-primary text-white px-4 py-2 rounded hover:bg-primary-focus">Send</button>
<span x-show="loading" class="relative ">
<svg class="animate-spin h-8 w-8 text-black" 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="#1B4332" stroke-width="4"></circle>
<path class="opacity-75" fill="#1B4332"
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>
</div>
</div>
</div>
<div class="card p-6 rounded-lg shadow-md col-span-4">
<h3 class="text-lg font-medium text-gray-900 mb-2">Server key send success</h3>
<div x-init="Livewire.on('patchSent', server => {
<div x-init="Livewire.on('patchSent', server => {
loading = false;
serverKeySuccess.push(server);
});">
<template x-for="server in serverKeySuccess" :key="server.id">
<div class="bg-green-100 text-green-700 p-2 rounded mb-2">
Patch Sent: <span x-text="server.key"></span>
<div class="bg-[##009332] text-white p-2 rounded mb-2">
Success: <span x-text="server.value"></span>
</div>
</template>
</div>
......@@ -171,15 +187,16 @@
<div class="mb-1">
<h3 class="text-xl font-medium leading-6 text-black my-3"><i aria-hidden="true" aria-hidden="true" class="fa fa-server mr-3"></i>Server list</h3>
<h3 class="text-xl font-medium leading-6 text-black my-3"><i aria-hidden="true" aria-hidden="true"
class="fa fa-server mr-3"></i>Server list</h3>
</div>
<div class="is-scrollbar-hidden min-w-full table-responsive card p-4 mb-4">
<div class="flex px-5 items-center justify-end mb-3" x-data="{ isInputActive: false }">
<button @click="isInputActive = !isInputActive"
class="btn h-8 w-14 rounded-full p-0 hover:bg-slate-300/20 focus:bg-slate-300/20 active:bg-slate-300/25 dark:hover:bg-navy-300/20 dark:focus:bg-navy-300/20 dark:active:bg-navy-300/25">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4.5 w-4.5" fill="none" viewBox="0 0 24 24"
stroke="black">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4.5 w-4.5" fill="none"
viewBox="0 0 24 24" stroke="black">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"
d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
......@@ -197,28 +214,29 @@
</select>
</span>
</div>
<table aria-describedby="mydesc" class="min-w-full is-hoverable table w-full divide-y divide-gray-200">
<table aria-describedby="mydesc"
class="min-w-full is-hoverable table w-full divide-y divide-gray-200">
<thead>
<tr>
<th scope="col"
<th scope="col"
class="px-6 py-3 bg-slate-300 text-left text-xs font-medium text-black uppercase tracking-wider">
Choose</th>
<th scope="col"
<th scope="col"
class="px-6 py-3 bg-slate-300 text-left text-xs font-medium text-black uppercase tracking-wider">
Server ID</th>
<th scope="col"
<th scope="col"
class="px-6 py-3 bg-slate-300 text-left text-xs font-medium text-black uppercase tracking-wider">
Company</th>
<th scope="col"
<th scope="col"
class="px-6 py-3 bg-slate-300 text-left text-xs font-medium text-black uppercase tracking-wider">
Serverkey</th>
<th scope="col"
<th scope="col"
class="px-6 py-3 bg-slate-300 text-left text-xs font-medium text-black uppercase tracking-wider">
Status</th>
<th scope="col"
<th scope="col"
class="px-6 py-3 bg-slate-300 text-left text-xs font-medium text-black uppercase tracking-wider">
Task Date</th>
<th scope="col"
<th scope="col"
class="px-6 py-3 bg-slate-300 text-left text-xs font-medium text-black uppercase tracking-wider">
Action</th>
</tr>
......@@ -236,7 +254,8 @@
{{ $server->COMPANY }}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $server->SNKEY }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">{{ $server->STATUS }}
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $server->STATUS }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $server->TaskDate }}</td>
......@@ -246,7 +265,7 @@
class="btn h-8 w-8 p-0 hover:text-main-container active:text-main-container hover:primary-focus focus:primary-focus active:bg-info/25"><i
class="fa fa-repeat" aria-hidden="true"></i></button>
@else
<button type="button" wire:click="deletePatch({{ $server->ServerID }})"
<button type="button" wire:click="deletePatch({{ $server->ServerID }})"
class="btn h-8 w-8 p-0 hover:text-main-container active:text-main-container hover:primary-focus focus:primary-focus active:bg-info/25"><i
class="fa fa-trash" aria-hidden="true"></i></button>
@endif
......@@ -260,9 +279,9 @@
{{ $results->links('livewire.paginate-custom') }}
</div>
</div>
<div>
&nbsp;
</div>
<div>
&nbsp;
</div>
</div>
</div>
</div>
@php
$paginate_master = config('masterfile.defaultPagination') ?: [];
// dd($paginator);
@endphp
<div class="flex flex-col flex-wrap justify-between space-y-4 px-4 py-4 sm:flex-row sm:items-center sm:space-y-0 sm:px-5">
<div class="flex items-center space-x-2 text-xs+">
......@@ -61,6 +62,6 @@
@endif
</span>
</div>
<div class="text-xs+">{{ $paginator->currentPage() }} - {{ $paginator->lastPage() }} of {{ $paginator->lastPage() }}
<div class="text-xs+">{{ (($paginator->perPage() * $paginator->currentPage() )-$paginator->perPage())+1 }} - {{ ($paginator->perPage() * $paginator->currentPage() > $paginator->total()) ? $paginator->total(): $paginator->perPage() * $paginator->currentPage() }} of {{ $paginator->total() }}
entries</div>
</div>
<x-guest-layout title="Login">
<style>
input:-webkit-autofill ,input:-webkit-autofill:focus {
input:-webkit-autofill,
input:-webkit-autofill:focus {
-webkit-box-shadow: 0 0 0px 1000px transparent inset;
-webkit-text-fill-color: inherit;
transition: background-color 5000s ease-in-out 0s;
}
.background-image {
background-image: url('images/login-background.jpg');
/* Replace with your image URL */
......@@ -93,14 +95,20 @@
<input type="text" id="username" name="username" autocomplete="off"
class="w-full bg-transparent border-b-2 border-white text-black text-md p-3 active:border-none focus:outline-none active:outline-none focus:border-b-indigo-500 focus:transform focus:translate-y-1 focus:duration-300 focus:text-xl"
placeholder="Enter your username">
@error('username')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<div class="w-full mb-6">
<label for="password" class="block text-white mb-2">Password</label>
<input type="password" id="password" name="password" autocomplete="off"
class="w-full bg-transparent border-b-2 border-white text-black text-md p-3 focus:outline-none active:outline-none focus:border-b-indigo-500 focus:transform focus:translate-y-1 focus:duration-300 focus:text-xl">
@error('password')
<span class="text-tiny+ text-error">{{ $message }}</span>
@enderror
</div>
<button type="submit"
class="w-full bg-indigo-600 text-white py-2 rounded-lg hover:bg-indigo-700 transition duration-300">Sign
class="w-full bg-[#db6e46] text-white py-2 rounded-lg hover:bg-[#d94400] transition duration-300">Sign
In</button>
</form>
......
@php
$formatFiles = App\Models\ConfFormatFile::all();
$used = [
'REFTRC - Tariff',
'REFTRS - Tariff stat code',
'REFEDR - Export Tariff Duty',
'REFDRT - Seq Duty Rate',
'REFPVC - Privilege',
'REFUNT - Unit',
'RFICC - Country',
'RFARS - Port',
'RFECS2013',
'REFCTC - Container Type',
'RFIPC - Discharge Port New',
'RFPMG - PERMISSION GOODS NEW',
];
$formatFiles = App\Models\ConfFormatFile::whereIn('name', $used)->get();
@endphp
<div class="bg-main-container" x-data="{ notLimit: false }">
<div class="bg-main-container" x-data="{
notLimit: false,
permissionGoods: false,
checkSelect(event) {
if (event.target.value == 196) {
this.permissionGoods = true
} else {
this.permissionGoods = 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>
......@@ -14,7 +38,7 @@
<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"
<select id="format_file_id" name="format_file_id" @click="checkSelect(event)"
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>
......@@ -84,12 +108,12 @@
</div>
</div>
<div class="mb-4">
<div class="mb-4" x-show="permissionGoods">
<label class="inline-flex items-center">
<input name="genWithSmartUpdate"
<input name="truncateGoods"
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>
type="checkbox" value="checked" x-bind:checked="permissionGoods">
<span class="ml-2 text-red-500">Truncate Table "master_permissiongoods"</span>
</label>
</div>
......@@ -97,7 +121,7 @@
<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">
type="checkbox" value="checked" checked>
<span class="ml-2">Create Patch</span>
</label>
<label class="inline-flex items-center">
......
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