Commit fa570b82 authored by Thidaporn Laisan's avatar Thidaporn Laisan
Browse files

update master file xml

parent c2410d6e
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class MasterFileXmlController extends Controller
{
public function index() {
$menu = 'MasterFileXml';
$currentContent = 'MasterFileXml';
return view('home' ,compact('menu', 'currentContent'));
}
}
<?php
namespace App\Http\Livewire\Pages\MasterFileXml;
use App\Models\MasterMapfieldXml;
use Livewire\Component;
use App\Models\User;
use Livewire\WithFileUploads;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Storage;
use Str;
class MasterFileXmlCreate extends Component
{
use WithFileUploads;
public $xml_type, $description, $tag_xml, $type_field, $format_field, $name, $thai_name, $authorDate, $pre_tag_xml;
public $image ,$imag;
public $uploadFilePathName1;
protected $rules = [
'xml_type' => 'required',
'pre_tag_xml' => 'required',
'tag_xml' => 'required',
'type_field'=> 'required',
'format_field' => 'required|string',
'name' => 'required',
'thai_name' => 'required',
'description' => 'required',
'uploadFilePathName1' => 'nullable|file|max:10240',
];
public function mount()
{
}
public function uploadImage()
{
$this->validate([
'img' => 'image|max:2048',
]);
if (!Storage::disk('public')->exists('images/error-tran')) {
Storage::disk('public')->makeDirectory('images/error-tran', 0755, true);
}
$imagePath = $this->imageTmp->store('images/error-tran', 'public');
$uploadedImageUrl = asset('storage/' . $imagePath);
$this->emit('imageUploaded', $uploadedImageUrl);
}
public function submitForm()
{
$this->validate();
// if (!Storage::disk('public')->exists('runtime/error-tran')) {
// Storage::disk('public')->makeDirectory('runtime/error-tran', 0755, true);
// }
if ($this->uploadFilePathName1) {
$originalName = $this->uploadFilePathName1->getClientOriginalName(); // ดึงชื่อไฟล์เดิม
$filePath1 = $this->uploadFilePathName1->storeAs('images/error-tran', $originalName, 'public'); // เก็บด้วยชื่อเดิม
if (!$filePath1) {
session()->flash('error', 'File upload failed.');
return;
}
}
MasterMapfieldXml::create([
'xml_type' => $this->xml_type,
'pre_tag_xml' => $this->pre_tag_xml,
'tag_xml' => $this->tag_xml,
'type_field' => $this->type_field,
'format_field' => $this->format_field,
'name' => $this->name,
'thai_name' => $this->thai_name,
'description' => $this->description,
'img' => $filePath1 ?? '',
]);
$this->resetForm();
return auth()->guest() ? redirect()->route('login') : $this->emit('showList', 'Successfully created.');
}
public function removeFile($fileName)
{
$this->$fileName = null;
}
public function resetForm()
{
$this->reset([
'xml_type',
'pre_tag_xml',
'tag_xml',
'type_field',
'format_field',
'name',
'thai_name',
'description',
'uploadFilePathName1'
]);
}
public function goBack()
{
if (auth()->guest()) {
return redirect()->route('login');
}
$this->emit('showList');
}
public function render()
{
return view('livewire.pages.master-file-xml.master-file-create');
}
}
<?php
namespace App\Http\Livewire\Pages\MasterFileXml;
use App\Models\MasterMapfieldXml;
use Livewire\Component;
use Livewire\WithFileUploads;
use Illuminate\Support\Facades\Storage;
class MasterFileXmlEdit extends Component
{
use WithFileUploads;
public $recordId, $xml_type, $description, $tag_xml, $type_field, $format_field, $name, $thai_name, $authorDate, $pre_tag_xml;
public $uploadFilePathName1;
protected $rules = [
'xml_type' => 'nullable|string',
'pre_tag_xml' => 'nullable|string',
'tag_xml' => 'nullable|string',
'type_field' => 'nullable|string',
'format_field' => 'nullable|string',
'name' => 'nullable|string',
'thai_name' => 'nullable|string',
'description' => 'nullable|string',
'uploadFilePathName1' => 'nullable|file|max:10240',
];
public function mount($editId)
{
$master = MasterMapfieldXml::find($editId);
$this->recordId = $editId;
$this->xml_type = $master->xml_type;
$this->pre_tag_xml = $master->pre_tag_xml;
$this->tag_xml = $master->tag_xml;
$this->type_field = $master->type_field;
$this->format_field = $master->format_field;
$this->name = $master->name;
$this->thai_name = $master->thai_name;
$this->description = $master->description;
$this->uploadFilePathName1 = $master->img;
}
public function uploadImage($file)
{
$originalName = $file->getClientOriginalName();
$path = $file->storeAs('images/error-tran', $originalName, 'public');
return asset('storage/' . $path);
}
public function submitForm()
{
$this->validate();
if ($this->uploadFilePathName1 instanceof \Illuminate\Http\UploadedFile) {
$originalName = $this->uploadFilePathName1->getClientOriginalName();
$filePath1 = $this->uploadFilePathName1->storeAs('images/error-tran', $originalName, 'public');
$this->uploadFilePathName1 = $filePath1;
}
MasterMapfieldXml::updateOrCreate(
['id' => $this->recordId],
[
'xml_type' => $this->xml_type,
'pre_tag_xml' => $this->pre_tag_xml,
'tag_xml' => $this->tag_xml,
'type_field' => $this->type_field,
'format_field' => $this->format_field,
'name' => $this->name,
'thai_name' => $this->thai_name,
'description' => $this->description,
'img' => $this->uploadFilePathName1,
]
);
$this->resetForm();
$this->emit('showList', 'Successfully updated.');
}
public function removeFile($fileName)
{
if ($this->$fileName) {
if ($this->$fileName instanceof \Illuminate\Http\UploadedFile) {
$this->$fileName = null;
} else {
Storage::disk('public')->delete($this->$fileName);
$this->$fileName = null;
}
}
}
public function resetForm()
{
$this->mount($this->recordId);
}
public function goBack()
{
$this->emit('showList');
}
public function render()
{
return view('livewire.pages.master-file-xml.master-file-edit');
}
}
<?php
namespace App\Http\Livewire\Pages\MasterFileXml;
use Livewire\Component;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use App\Models\MasterMapfieldXml;
use Illuminate\Support\Facades\Cache;
use Livewire\WithPagination;
class MasterFileXmlIndex extends Component
{
use WithPagination;
protected $paginationTheme = 'bootstrap';
public $perPage = 10;
public $url;
public $searchSelected = 'topic';
public $searchCateSelected;
public $searchTypeSelected;
public $editId;
public $deleteId;
public $keyword = '';
public $selectedOption = 'topic';
public $searchBy;
public $action = 'list';
public $message;
public $selectedMasterFile = [];
public $searchCategory = [];
public $searchType = [];
public $showDeleteListModal = false;
public $showNoPermissionModal = false;
public $showMessage = false;
public $totalItems;
protected $listeners = ['showList', 'deleteItem', 'deleteSelected', 'setShowMessageFalse'];
public function mount()
{
$this->searchBy = [
'xml_type' => 'Xml Type',
'pre_tag_xml' => 'Pre Tag Xml',
'tag_xml' => 'Tag Xml',
'name' => 'Name',
'thai_name' => 'Thai Name',
];
}
public function search()
{
$this->resetPage();
$this->action = 'list';
}
public function updatedPerPage($value)
{
$this->adjustPageForNewPerPage();
}
public function adjustPageForNewPerPage()
{
$lastPage = ceil($this->totalItems / $this->perPage);
if ($this->page > $lastPage) {
$this->setPage($lastPage);
}
}
public function showAddForm()
{
$this->action = 'create';
}
public function showEditForm($id)
{
$this->action = 'edit';
$this->editId = $id;
}
public function hideMessage()
{
$this->showMessage = false;
}
public function showList($message = null)
{
$this->action = 'list';
$this->resetPage();
$this->message = $message;
if ($this->message) {
$this->dispatchBrowserEvent('show-message', ['message' => $this->message]);
}
}
public function paginationView()
{
return 'paginate-custom';
}
public function deleteItem($deleteId)
{
$masterfileXml = MasterMapfieldXml::find($deleteId);
if ($masterfileXml) {
$masterfileXml->delete();
$message = "Deleted Successfully";
} else {
$message = "Record not found.";
}
$this->message = $message;
$this->dispatchBrowserEvent('show-message', ['message' => $this->message]);
}
public function deleteSelected($selectedMasterFile)
{
if (!Auth::user()->hasPermissions(['delete-master-file-xml'])) {
$this->showNoPermissionModal = true;
return;
}
$masterFileDeleted = MasterMapfieldXml::whereIn("id", $selectedMasterFile)->pluck('topic')->toArray();
$newsStr = implode(",", $masterFileDeleted);
MasterMapfieldXml::destroy($selectedMasterFile);
$message = sprintf("Deleted: (%s) Successfully", $newsStr);
$this->message = $message;
$this->selectedMasterFile = [];
if ($this->message) {
$this->dispatchBrowserEvent('show-message', ['message' => $this->message]);
}
}
public function render()
{
$query = MasterMapfieldXml::query();
if (!empty($this->keyword)) {
$query->where($this->searchSelected, 'LIKE', '%' . $this->keyword . '%');
}
$query->orderBy('id', 'DESC');
$results = $query->paginate($this->perPage);
$this->totalItems = $results->total();
return view('livewire.pages.master-file-xml.master-file-index', [
'results' => $results,
'selectedMasterFile' => $this->selectedMasterFile,
'showDeleteListModal' => $this->showDeleteListModal
]);
}
}
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class MasterMapfieldXml extends Model
{
public $timestamps = false;
protected $table = 'master_mapfield_xml';
protected $fillable = [
'id',
'xml_type',
'pre_tag_xml',
'tag_xml',
'type_field',
'format_field',
'name',
'thai_name',
'description',
'img'
];
}
......@@ -97,6 +97,16 @@
</li>
</ul>
</div>
<div class="rounded-2xl p-3 bg-white w-full mb-2">
<ul >
<li class="mb-1">
<a href="/master-file-xml" :class="activeLink === '/master-file-xml' ? 'bg-primary-focus text-white rounded-xl' : 'text-black'"
class="block py-2 px-4 rounded text-black flex items-center">
<i aria-hidden="true" class="fa fa-laptop-code mr-2"></i> Masterfile Map Field XML
</a>
</li>
</ul>
</div>
<div class="rounded-2xl p-3 bg-white w-full mb-2">
<ul >
<li class="mb-1">
......
......@@ -58,6 +58,10 @@
<livewire:pages.parameter.parameter-index wire:init />
@break
@case('MasterFileXml')
<livewire:pages.master-file-xml.master-file-xml-index wire:init />
@break
@case('News')
<livewire:pages.news.news-index wire:init />
@break
......
<div class=" p-6 bg-white shadow-lg rounded-lg">
<style>
.ql-container {
height: 15rem;
}
</style>
<form wire:submit.prevent="submitForm" x-data x-init="">
@csrf
<div class="mb-6">
<h2
class="font-medium flex items-center tracking-wide text-slate-700 line-clamp-1 dark:text-navy-100 lg:text-base">
<i aria-hidden="true" class="fa-solid fa-edit text-primary"></i> Create Masterfile Map Field XML
</h2>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="mb-2">
<label for="xml_type" class="block text-sm font-medium text-gray-700">Xml Type :</label>
<select id="xml_type" wire:model.defer="xml_type" class="mt-1 block w-full p-2 border border-gray-300 rounded-md">
<option value="">Please Select</option>
<option value="import">IMPORT</option>
<option value="export">EXPORT</option>
</select>
@error('xml_type')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="pre_tag_xml" class="block text-sm font-medium text-gray-700">Pre Tag Xml : <i class="fa fa-info-circle" aria-hidden="true" title="ตำแหน่งของ Field"></i></label>
<input type="text" wire:model.defer="pre_tag_xml" id="pre_tag_xml"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Pre Tag Xml">
@error('pre_tag_xml')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="tag_xml" class="block text-sm font-medium text-gray-700">Tag Xml : <i class="fa fa-info-circle" aria-hidden="true" title="ชื่อ Field ใน XML"></i></label>
<input type="text" wire:model.defer="tag_xml" id="tag_xml"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Tag Xml">
@error('tag_xml')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="type_field" class="block text-sm font-medium text-gray-700">Type :</label>
<select id="type_field" wire:model.defer="type_field" class="mt-1 block w-full p-2 border border-gray-300 rounded-md">
<option value="">Please Select</option>
<option value="text">ตัวอักษร</option>
<option value="textornumber">ตัวอักษรหรือตัวเลข</option>
<option value="number">ตัวเลข</option>
</select>
@error('type_field')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="format_field" class="block text-sm font-medium text-gray-700">Format :</label>
<input type="text" wire:model.defer="format_field" id="format_field"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Format">
@error('format_field')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="name" class="block text-sm font-medium text-gray-700">Name :</label>
<input type="text" wire:model.defer="name" id="name"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Name">
@error('name')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="thai_name" class="block text-sm font-medium text-gray-700">Thai Name :</label>
<input type="text" wire:model.defer="thai_name" id="thai_name"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Thai Name">
@error('thai_name')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="md:col-span-2 mb-2">
<label for="description" class="block text-sm font-medium text-gray-700">Description:</label>
<textarea wire:model.defer="description" id="description" rows="3"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Description"></textarea>
@error('description')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
@if ($uploadFilePathName1)
<div class="mt-2 text-sm text-slate-600 dark:text-slate-300 mr-4 flex items-center">
Uploaded File 1: {{ $uploadFilePathName1->getClientOriginalName() }}
<button wire:click.prevent="removeFile('uploadFilePathName1')"
class="ml-1 text-red-600 hover:text-red-800">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</div>
@else
<div class="mt-2 text-sm text-slate-600 dark:text-slate-300 mr-4">
Uploaded File
</div>
@endif
<span wire:loading wire:target="uploadFilePathName1">
<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-1"
class="btn bg-slate-150 font-medium text-slate-800 hover:bg-slate-200 focus:bg-slate-200 active:bg-slate-200/80 dark:bg-navy-500 dark:text-navy-50 dark:hover:bg-navy-450 dark:focus:bg-navy-450 dark:active:bg-navy-450/90"
aria-label="Upload File 1">
<input tabindex="-1" id="file-upload-1" type="file" wire:model="uploadFilePathName1"
class="pointer-events-none absolute inset-0 h-full w-full opacity-0" />
<div class="flex items-center space-x-2">
<svg xmlns="http://www.w3.org/2000/svg" class="size-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>
@error('uploadFilePathName1')
<span class="error">{{ $message }}</span>
@enderror
</label>
</div>
</div>
<div class="flex justify-end space-x-4 mt-4">
<a href="/master-file-xml" type="button"
class="px-4 py-2 bg-gray-200 text-gray-700 rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400">Cancel</a>
<button type="submit" x-ref="submitButton"
class="px-4 py-2 bg-primary text-white rounded-md shadow-sm hover:bg-primary-dark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">Save</button>
</div>
</form>
</div>
<div class=" p-6 bg-white shadow-lg rounded-lg">
<form wire:submit.prevent="submitForm" x-data x-init="">
@csrf
<div class="mb-6">
<h2
class="font-medium flex items-center tracking-wide text-slate-700 line-clamp-1 dark:text-navy-100 lg:text-base">
<i aria-hidden="true" class="fa-solid fa-edit text-primary"></i> Edit Masterfile Map Field XML
</h2>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="mb-2">
<label for="xml_type" class="block text-sm font-medium text-gray-700">Xml Type :</label>
<select id="xml_type" wire:model.defer="xml_type" class="mt-1 block w-full p-2 border border-gray-300 rounded-md">
<option value="">Please Select</option>
<option value="import">IMPORT</option>
<option value="export">EXPORT</option>
</select>
@error('xml_type')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="pre_tag_xml" class="block text-sm font-medium text-gray-700">Pre Tag Xml : <i class="fa fa-info-circle" aria-hidden="true" title="ตำแหน่งของ Field"></i></label>
<input type="text" wire:model.defer="pre_tag_xml" id="pre_tag_xml"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Pre Tag Xml">
@error('pre_tag_xml')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="tag_xml" class="block text-sm font-medium text-gray-700">Tag Xml : <i class="fa fa-info-circle" aria-hidden="true" title="ชื่อ Field ใน XML"></i></label>
<input type="text" wire:model.defer="tag_xml" id="tag_xml"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Tag Xml">
@error('tag_xml')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="type_field" class="block text-sm font-medium text-gray-700">Type :</label>
<select id="type_field" wire:model.defer="type_field" class="mt-1 block w-full p-2 border border-gray-300 rounded-md">
<option value="">Please Select</option>
<option value="text">ตัวอักษร</option>
<option value="textornumber">ตัวอักษรหรือตัวเลข</option>
<option value="number">ตัวเลข</option>
</select>
@error('type_field')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="format_field" class="block text-sm font-medium text-gray-700">Format :</label>
<input type="text" wire:model.defer="format_field" id="format_field"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Format">
@error('format_field')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="name" class="block text-sm font-medium text-gray-700">Name :</label>
<input type="text" wire:model.defer="name" id="name"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Name">
@error('name')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-2">
<label for="thai_name" class="block text-sm font-medium text-gray-700">Thai Name :</label>
<input type="text" wire:model.defer="thai_name" id="thai_name"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Thai Name">
@error('thai_name')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="md:col-span-2 mb-2">
<label for="description" class="block text-sm font-medium text-gray-700">Description:</label>
<textarea wire:model.defer="description" id="description" rows="3"
class="mt-1 block w-full px-4 py-2 border border-gray-300 rounded-md shadow-sm focus:ring-primary focus:border-primary sm:text-sm"
placeholder="Enter Description"></textarea>
@error('description')
<span class="text-red-500 text-md self-center ml-4">{{ $message }}</span>
@enderror
</div>
<div class="mb-6">
<label for="uploadFilePathName1" class="block text-lg font-semibold text-gray-800 mb-2">Uploaded File :</label>
@if ($uploadFilePathName1)
<div class="mt-4 relative inline-block rounded-lg overflow-hidden shadow-lg border border-gray-300">
@if ($uploadFilePathName1 instanceof \Illuminate\Http\UploadedFile)
<img src="{{ $uploadFilePathName1->temporaryUrl() }}" alt="Uploaded Image" class="w-200 h-200 object-cover">
@else
<img src="{{ asset('storage/' . $uploadFilePathName1) }}" alt="Uploaded Image" class="w-200 h-200">
@endif
<button wire:click.prevent="removeFile('uploadFilePathName1')" class="absolute top-2 right-2 bg-red-600 text-white rounded-full p-1 shadow-md hover:bg-red-700 transition duration-300">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 9l-5 5-1-1 5-5-5-5 1-1 5 5 5-5 1 1-5 5 5 5-1 1-5-5z" clip-rule="evenodd" />
</svg>
</button>
</div>
@else
<div class="mt-4 text-sm text-gray-500 italic">
No file uploaded
</div>
@endif
<div class="mt-4">
<label for="file-upload-1" class="btn bg-slate-150 font-medium text-slate-800 hover:bg-slate-200">
<input type="file" id="file-upload-1" wire:model="uploadFilePathName1" class="hidden">
<span>Choose File</span>
</label>
</div>
@error('uploadFilePathName1')
<span class="text-red-500 text-sm mt-2 block">{{ $message }}</span>
@enderror
</div>
</div>
<div class="flex justify-end space-x-4 mt-4">
<a href="/master-file-xml" type="button"
class="px-4 py-2 bg-gray-200 text-gray-700 rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-400">Cancel</a>
<button type="submit" x-ref="submitButton"
class="px-4 py-2 bg-primary text-white rounded-md shadow-sm hover:bg-primary-dark focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary">Save</button>
</div>
</form>
</div>
<div class="border-0 shadow-none">
<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 ">
<div class="items-center h-100vh" style="align-content: center;">
<div class="animate-spin rounded-full h-32 w-32 border-t-2 border-b-2 border-blue-500"></div>
</div>
</div>
</div>
<div class="my-5 flex h-8 place-content-center px-4 ">
<h2 class="text-xl text-slate-800">
Masterfile Map Field XML
</h2>
<h2 class="ml-3 text-xl text-slate-800 font-semibold underline underline-offset-4">
{{ $action === 'create'? 'Create' :(($action === 'edit')? 'Edit':'') }}
</h2>
</div>
<div class="m-2">
@if ($action === 'list')
@if ($message)
<div class="alert alert-success">
<div wire:ignore x-data="{ show: true }" x-init="setTimeout(() => show = false, 3000)"
x-show.transition.duration.500ms="show"
class="fixed top-5 right-5 z-50 bg-green-500 text-white py-2 px-4 rounded-md shadow-lg">
{{ $message }}
</div>
</div>
@endif
<div class="grid grid-cols-1 gap-4 sm:gap-5 lg:gap-6 bg-main-container rounded-md"
x-data="{
showDeleteListModal: @entangle('showDeleteListModal'),
showAlert: false,
toggleGroup(event) {
const groupId = event.target.value;
if (event.target.checked) {
if (!this.selectedNewsAlpine.includes(groupId)) {
this.selectedNewsAlpine.push(groupId);
}
} else {
this.selectedNewsAlpine = this.selectedNewsAlpine.filter(id => id !== groupId);
}
},
selectedNewsAlpine: [],
selectedMasterFile: @entangle('selectedMasterFile')
}"
>
<div class="pb-4 pt-5 bg-white rounded-lg shadow-lg">
<div class="flex justify-between">
<div class="px-2 ml-4">
<button type="button"
class="py-2 px-3 bg-primary rounded-md text-white hover:bg-primary-focus"
wire:click="showAddForm">Add</button>
</div>
<div class="inline-flex flex-initial">
<div x-data="{ isInputActive: true }">
<div class="flex flex-wrap gap-4 px-5 items-center">
<button @click="isInputActive = !isInputActive"
class="btn h-8 w-10 rounded-full p-0 hover:bg-primary-focus hover:text-main-container active:text-main-container focus:text-main-container primary-focus hover:text-main-container active:text-main-container focus:text-main-container 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">
<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>
</button>
<span class="w-64" x-show="isInputActive === true">
<input
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"
placeholder="Search Keyword" type="text" wire:model.defer="keyword" />
</span>
<span class="w-52" x-show="isInputActive === true">
<select wire:model.defer="searchSelected"
class="form-select h-9 w-full rounded-lg border border-slate-300 bg-main-container px-3 py-2 hover:border-slate-400 focus:border-primary dark:border-navy-450 dark:bg-navy-700 dark:hover:border-navy-400 dark:focus:border-accent">
@foreach ($searchBy as $key => $by)
<option value="{{ $key }}">{{ $by }}</option>
@endforeach
</select>
</span>
<button type="button"
class="bg-primary text-white px-4 py-2 rounded hover:bg-primary-focus"
wire:click="search">Search</button>
</div>
</div>
</div>
</div>
<div class="mx-3 mt-3 px-4">
<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">
<thead>
<tr>
<th scope="col"
class="whitespace-nowrap rounded-tl-lg bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5">
#
</th>
<th scope="col"
class="whitespace-nowrap bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5">
Xml Type
</th>
<th scope="col"
class="whitespace-nowrap bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5">
Pre Tag xml
</th>
<th scope="col"
class="whitespace-nowrap bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5">
Tag Xml
</th>
<th scope="col"
class="whitespace-nowrap bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5">
Name
</th>
<th scope="col"
class="whitespace-nowrap bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5">
Thai Name
</th>
<th scope="col"
class="whitespace-nowrap rounded-tr-lg bg-slate-300 px-4 py-3 font-semibold uppercase text-black dark:bg-navy-800 dark:text-navy-100 lg:px-5">
Action
</th>
</tr>
</thead>
<tbody>
@foreach ($results as $item)
<tr
class="border-y border-transparent border-b-slate-200 dark:border-b-navy-500">
<td class="whitespace-nowrap px-4 py-3 sm:px-5">
<div class="inline-flex items-center space-x-2">
<input @change="toggleGroup($event)"
class="form-checkbox is-basic h-4 w-4 rounded border-slate-400/70 checked:bg-primary checked:border-primary hover: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" wire:model.defer="selectedMasterFile"
value="{{ $item->id }}" />
</div>
</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">{{ $item->xml_type??"" }}</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">{{ $item->pre_tag_xml??"" }}</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">{{ $item->tag_xml }}
</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">
{{ \Illuminate\Support\Str::limit($item->name, 50) }}</td>
<td class="whitespace-nowrap px-4 py-3 sm:px-5">
{{ \Illuminate\Support\Str::limit($item->thai_name, 50) }}</td>
</td>
<td class="whitespace-nowrap px-1 py-3 sm:px-2">
<div class="flex justify-center space-x-2">
<a wire:click="showEditForm({{ $item->id }})"
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 aria-hidden="true" class="fa fa-edit"></i>
</a>
<a @click="$wire.emit('showDeleteModal', {{ $item->id }})"
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 aria-hidden="true" class="fa fa-trash"></i>
</a>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<template x-if="showDeleteListModal">
<div class="fixed inset-0 z-[100] flex flex-col items-center justify-center overflow-hidden px-4 py-6 sm:px-5"
@keydown.window.escape="showDeleteListModal = false">
<div class="absolute inset-0 bg-slate-900/60 transition-opacity duration-300"
@click="showDeleteListModal = false"></div>
<div
class="relative p-4 max-w-lg rounded-lg bg-white px-4 py-10 text-center transition-opacity duration-300 dark:bg-navy-700 sm:px-5">
<svg xmlns="http://www.w3.org/2000/svg" class="inline h-28 w-28 text-error"
fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z">
</path>
</svg>
<div class="mt-4 mx-5">
<h2 class="text-2xl text-slate-700 dark:text-navy-100">
Are you sure <br> you want to delete <span
x-text="selectedUsersAlpine.length"></span> users?
</h2>
<p class="mt-2"></p>
<button @click="showDeleteListModal = false"
class="btn mt-6 bg-[#6a6e69] font-medium text-white hover:bg-[#313430] focus:bg-[#313430]-focus active:bg-[#313430]-focus/90">
Close
</button>
<button
@click="$wire.emitSelf('deleteSelected', selectedUsers ); showDeleteListModal = false"
class="btn mt-6 bg-error font-medium text-white hover:bg-error-focus focus:bg-error-focus active:bg-error-focus/90">
Confirm
</button>
</div>
</div>
</div>
</template>
<livewire:delete-modal />
{{ $results->links('livewire.paginate-custom' ) }}
</div>
</div>
</div>
@elseif($action === 'create')
<livewire:pages.master-file-xml.master-file-xml-create wire:key="master-file-create" />
@elseif($action === 'edit')
<livewire:pages.master-file-xml.master-file-xml-edit :editId="$editId" wire:key="master-file-edit" />
@else
<div></div>
@endif
</div>
</div>
......@@ -18,6 +18,7 @@ use App\Http\Controllers\DeletePatchController;
use App\Http\Controllers\DischargePortController;
use App\Http\Controllers\FormatFileMasterContrller;
use App\Http\Controllers\MasterFileController;
use App\Http\Controllers\MasterFileXmlController;
use App\Http\Controllers\NewsController;
use App\Http\Controllers\ParameterController;
use App\Http\Controllers\PatchController;
......@@ -71,6 +72,7 @@ Route::middleware(['auth' ])->group(function () {
Route::get('/send-multi-patch', [SendPatchController::class, 'indexMulti']);
Route::get('/delete-multi-patch', [DeletePatchController::class, 'indexMulti']);
Route::get('/server-license', [ServerLicenseController::class, 'index'])->name('server-license.index');
Route::get('/master-file-xml', [MasterFileXmlController::class, 'index'])->name('master-file-xml.index');
Route::get('/user', [UserController::class, 'index'])->name('user.index');
Route::get('/company', [CompanyController::class, 'index'])->name('company.index');
......
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