Commit 92841d8e authored by Sarun Mungthanya's avatar Sarun Mungthanya
Browse files

issue news and menu create discharge port

parent 9cb59348
......@@ -8,8 +8,9 @@ use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use Maatwebsite\Excel\Concerns\WithMapping;
class ServerLicenseExport implements FromCollection, WithHeadings, WithColumnFormatting
class ServerLicenseExport implements FromCollection, WithHeadings, WithColumnFormatting, WithMapping
{ public function collection()
{
......@@ -40,5 +41,30 @@ class ServerLicenseExport implements FromCollection, WithHeadings, WithColumnFor
'A' => NumberFormat::FORMAT_TEXT,
];
}
public function map($row): array
{
return [
'`' . $row->SNKEY, // Add a backtick (`) to enforce text format in Excel
$row->COMPANY,
$row->STATUS,
$row->LICENSEDATE,
$row->BACKUP_DATE,
$row->CUR_VERSION,
$row->INSTALL_DATE,
$row->INSTALL_VERSION,
$row->DATABASETYPE,
$row->OWNERTYPE,
$row->NBTEAM,
$row->CUSTOMERSIZE,
$row->CUSTOMERTYPE,
$row->CUSTOMERBRANCH,
$row->CONTACTCUSTOMERNAME,
$row->CONTACT,
$row->CUSTOMERURL,
$row->MESSAGETYPE,
$row->PHP_VERSION_ID,
$row->JAVA_VERSION,
];
}
}
......@@ -102,11 +102,13 @@ class NewsIndex extends Component
}
public function deleteItem($deleteNewsId)
{
if (!Auth::user()->hasPermissions(['delete-news'])) {
$this->showNoPermissionModal = true;
return;
}
// if (!Auth::user()->hasPermissions(['delete-news'])) {
// $this->showNoPermissionModal = true;
// return;
// }
$news = Shippingnetnews::find($deleteNewsId);
if ($news) {
$news->delete();
$message = "Deleted Successfully";
......
......@@ -16,7 +16,8 @@ class DeleteMultiPatchList extends Component
public $searchBy, $serverId, $editPid, $message, $keyword, $perPage = 10, $searchSelected = 'PID';
public $selectedPatches = [];
protected $results;
public $totalItems;
protected $listeners = ['updateServerkey' , 'updateSelectPatchAfterDeleted', 'removePatchSelected'];
public function mount()
{
......@@ -36,7 +37,18 @@ class DeleteMultiPatchList extends Component
{
$this->resetPage();
}
public function updatedPerPage($value)
{
$this->adjustPageForNewPerPage();
}
public function adjustPageForNewPerPage()
{
$lastPage = ceil($this->totalItems / $this->perPage);
if ($this->page > $lastPage) {
$this->setPage($lastPage);
}
}
public function updateServerkey($serverkey)
{
......@@ -75,7 +87,7 @@ class DeleteMultiPatchList extends Component
}
$query->orderBy('PID', 'DESC');
$results = $query->paginate($this->perPage);
$this->totalItems = $results->total();
return view('livewire.pages.send-patch.delete-multi-patch-list', [
'results' => $results
]);
......
......@@ -13,6 +13,7 @@ class SendMultiPatchList extends Component
public $searchBy, $editPid, $message, $keyword, $perPage = 10, $searchSelected = 'PID';
public $selectedPatches = [];
public $insertedIds = [];
public $totalItems;
protected $listeners = ['deleteItem', 'deleteSelected', 'showMultiPatchList'];
......@@ -29,13 +30,25 @@ class SendMultiPatchList extends Component
$this->selectedPatches = [];
// $this->dispatchBrowserEvent('grandchild-component-loaded');
}
public function updatedPerPage($value)
{
$this->adjustPageForNewPerPage();
}
public function adjustPageForNewPerPage()
{
$lastPage = ceil($this->totalItems / $this->perPage);
if ($this->page > $lastPage) {
$this->setPage($lastPage);
}
}
public function search()
{
$this->resetPage();
}
public function showMultiPatchList() {
public function showMultiPatchList()
{
$this->render();
}
......@@ -45,7 +58,6 @@ class SendMultiPatchList extends Component
}
public function render()
{
// dd("dd");
$query = ConfSmartUpdate::select('PID', 'PATCHNAME', 'PDESC', 'PDATE', 'PLEVEL', 'Remark', 'MAJOR_VERSION');
if ($this->searchSelected && $this->keyword) {
......@@ -53,12 +65,10 @@ class SendMultiPatchList extends Component
}
$query->orderBy('PID', 'DESC');
$results = $query->paginate($this->perPage);
$this->totalItems = $results->total();
return view('livewire.pages.send-patch.send-multi-patch-list', [
'results' => $results,
'selectedPatches' => ConfSmartUpdate::whereIn('PID', $this->selectedPatches)->get()
]);
}
}
......@@ -9,7 +9,8 @@ use App\Models\ConfSmartupdate;
use App\Models\LogSendPath2customer;
use Livewire\Component;
use Livewire\WithPagination;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\DB;
class SendPatchEdit extends Component
{
use WithPagination;
......@@ -236,4 +237,55 @@ class SendPatchEdit extends Component
->paginate($this->perPage);
return view('livewire.pages.send-patch.send-patch-edit', compact('ownerType', 'results'));
}
public function export()
{
$data = DB::table('log_send_path2customer as t1')
->join('tab_user as t2', 't1.UID', '=', 't2.UID')
->join('conf_server_license as t3', 't1.SERVERKEYID', '=', 't3.ID')
->join('conf_server_pendding as cp', function ($join) {
$join->on('cp.ServerID', '=', 't3.ID')
->on('cp.PatchID', '=', 't1.PATCHID');
})
->select([
't2.USERNAME',
't3.SNKEY',
't3.COMPANY',
't1.ACTDATETIME',
't1.LOGDESC',
't1.IPACTIVE',
'cp.PatchID',
DB::raw("CASE WHEN cp.TaskStatus = 999 THEN 'Yes' ELSE 'No' END as isReceive"),
])
->where('cp.PatchID', $this->PID)
->orderBy('t1.ACTDATETIME', 'DESC')
->get();
$dataArray = $data->map(function ($item) {
return (array) $item;
})->toArray();
$filename = "patch_pendding_" . now()->format('YmdHis') . ".csv";
$headers = [
'Content-Type' => 'text/csv',
'Content-Disposition' => "attachment; filename=$filename",
];
$callback = function () use ($dataArray) {
$file = fopen('php://output', 'w');
if (!empty($dataArray)) {
fputcsv($file, array_keys($dataArray[0]));
}
foreach ($dataArray as $row) {
fputcsv($file, $row);
}
fclose($file);
};
return Response::stream($callback, 200, $headers);
}
}
......@@ -60,8 +60,9 @@ class SendPatchIndex extends Component
}
$query->orderBy('PID', 'DESC');
$results = $query->paginate($this->perPage);
$this->totalItems = $results->total();
}
$this->totalItems = $results->total();
return view('livewire.pages.send-patch.send-patch-index', compact('results'));
}
......
......@@ -7,13 +7,18 @@ use Livewire\Component;
use Livewire\WithPagination;
use App\Models\ConfSmartUpdate;
use PDO;
use App\Exports\LicenseExport;
use App\Exports\ServerLicenseExport;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\DB;
class ServerLicenseIndex extends Component
{
use WithPagination;
public $action = 'list';
public $searchBy, $editId, $message, $keyword, $perPage = 10, $searchSelected = 'COMPANY' , $selectedPatch = [] ,$totalItems;
protected $listeners = [ 'deleteItem', 'deleteSelected' ,'showpatchListForm'];
public $searchBy, $editId, $message, $keyword, $perPage = 10, $searchSelected = 'COMPANY', $selectedPatch = [], $totalItems;
protected $listeners = ['deleteItem', 'deleteSelected', 'showpatchListForm'];
public function mount()
{
$this->searchBy = [
......@@ -31,25 +36,25 @@ class ServerLicenseIndex extends Component
$query = ConfServerLicense::select('ID', 'SNKEY', 'COMPANY', 'STATUS', 'CUR_VERSION', 'DATABASETYPE', 'LICENSEDATE');
if($this->searchSelected == 'PHP_VERSION_ID') {
if($this->keyword == '32' ){
if ($this->searchSelected == 'PHP_VERSION_ID') {
if ($this->keyword == '32') {
if ($this->searchSelected && $this->keyword) {
$query->whereIn('PHP_VERSION_ID', [0,1]);
$query->whereIn('PHP_VERSION_ID', [0, 1]);
}
}elseif($this->keyword == '64' ){
} elseif ($this->keyword == '64') {
if ($this->searchSelected && $this->keyword) {
$query->whereIn('PHP_VERSION_ID', [0,2]);
$query->whereIn('PHP_VERSION_ID', [0, 2]);
}
}else{
} else {
$query->whereIn('PHP_VERSION_ID', []);
}
}else{
} else {
if ($this->searchSelected && $this->keyword) {
$query->where($this->searchSelected, 'LIKE', '%' . $this->keyword . '%');
}
}
$query->orderBy('ID', 'DESC');
$results = $query->paginate($this->perPage);
$this->totalItems = $results->total();
......@@ -90,16 +95,21 @@ class ServerLicenseIndex extends Component
public function showDeleteModal($id)
{
$this->emit('showDeleteModal' ,$id);
$this->emit('showDeleteModal', $id);
}
public function deleteItem($id) {
public function deleteItem($id)
{
$serverlicense = ConfServerLicense::where("ID", $id)->first();
$serverlicense->status = 'N';
$serverlicense->save();
$message = "Serverlicense status updated successfully";
$this->message = $message;
}
public function exportLicense()
{
return Excel::download(new ServerLicenseExport(), 'conf_server_license.xlsx');
}
}
......@@ -63,7 +63,6 @@
@endisset
@yield('script')
<script>
console.log("ddd")
Livewire.on('fileDownloaded', (url) => {
window.location.href = url;
});
......
......@@ -43,10 +43,10 @@
<a href="/patch-exchange-rate" :class="activeLink === '/patch-exchange-rate' ? 'bg-primary-focus text-white rounded-xl' : 'text-black'"
class="block py-2 px-4 rounded hover:bg-primary-focus hover:text-white"> <i aria-hidden="true" class="fa fa-file-invoice-dollar mr-2"></i>Create Patch Exchange Rate</a>
</li>
<li class="mb-1 ml-6">
{{-- <li class="mb-1 ml-6">
<a href="/discharge-port" :class="activeLink === '/discharge-port' ? 'bg-primary-focus text-white rounded-xl' : 'text-black'"
class="block py-2 px-4 rounded hover:bg-primary-focus hover:text-white"> <i aria-hidden="true" class="fa fa-anchor mr-2"></i>Create Patch Discharge Port</a>
</li>
</li> --}}
</div>
</ul>
</div>
......
......@@ -151,10 +151,5 @@
@elseif($action === 'edit')
<livewire:pages.format-file-master.file-edit :editId="$editId" />
@endif
@push('script')
<script>
console.log("ddd")
</script>
@endpush
</div>
</div>
......@@ -158,10 +158,5 @@
@elseif($action === 'edit')
<livewire:pages.patch.patch-edit :editPid="$editPid">
@endif
@push('script')
<script>
console.log("ddd")
</script>
@endpush
</div>
</div>
......@@ -192,28 +192,48 @@
</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">
<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="keyword" />
</span>
<span class="w-52" x-show="isInputActive === true">
<select wire:model="searchSelected"
class="form-select h-9 w-full rounded-lg border border-slate-300 bg-white 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">
<option value="SNKEY">Server Key</option>
<option value="COMPANY">Company</option>
</select>
</span>
<div class="flex justify-between">
<div class="flex items-center justify-start mb-3">
<span class="cursor-pointer text-black p-2 rounded-lg hover:bg-primary hover:text-white mr-3"
wire:click="deleteSelected"><i class="fa fa-trash" aria-hidden="true"></i>
Delete</span>
<span class="cursor-pointer text-black p-2 rounded-lg hover:bg-primary hover:text-white"
wire:click="export"><i class="fa fa-download" aria-hidden="true"></i> Export</span>
<span wire:loading wire:target="export,deleteSelected" class="relative ">
<svg class="animate-spin h-5 w-5 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="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>
</div>
<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">
<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="keyword" />
</span>
<span class="w-52" x-show="isInputActive === true">
<select wire:model="searchSelected"
class="form-select h-9 w-full rounded-lg border border-slate-300 bg-white 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">
<option value="SNKEY">Server Key</option>
<option value="COMPANY">Company</option>
</select>
</span>
</div>
</div>
<table aria-describedby="mydesc"
class="min-w-full is-hoverable table w-full divide-y divide-gray-200">
<thead>
......@@ -245,8 +265,13 @@
@foreach ($results as $server)
<tr>
<td class="px-6 py-4 whitespace-nowrap">
<input type="checkbox"
class="form-checkbox h-4 w-4 text-indigo-600 transition duration-150 ease-in-out">
<label class="inline-flex items-center space-x-2">
<input
class="form-checkbox individual-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" @click="deleteSelectedPatch"
value="{{ $server->ServerID }}"
data-serverId = "{{ $server->ServerID }}" />
</label>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $server->ServerID }}</td>
......@@ -265,7 +290,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
......
......@@ -35,6 +35,9 @@
<button type="button"
class="py-2 px-3 bg-primary rounded-md text-white hover:bg-primary-focus"
wire:click="showServerLicenseAddForm">Add</button>
<button type="button"
class="py-2 px-3 bg-primary rounded-md text-white hover:bg-primary-focus"
wire:click="exportLicense"><i class="fa fa-download mr-2" aria-hidden="true"></i>Export</button>
</div>
<div class="inline-flex flex-initial" >
<div x-data="{ isInputActive: true }">
......
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