Compare commits
10 Commits
83850273a8
...
2e52155eda
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e52155eda | ||
|
|
6abea3a826 | ||
|
|
58672dada3 | ||
|
|
f8c6452bcf | ||
|
|
0891e11051 | ||
|
|
9efafa6921 | ||
|
|
ecdca382c4 | ||
|
|
8ff24e84c8 | ||
|
|
ed97ab4b5d | ||
|
|
2120b3d079 |
@@ -6,7 +6,7 @@
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
use Modules\Basicdata\Models\Branch;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
|
||||
class BranchExport implements WithColumnFormatting, WithHeadings, FromCollection, withMapping
|
||||
|
||||
@@ -82,6 +82,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteMultiple(Request $request)
|
||||
{
|
||||
$ids = $request->input('ids');
|
||||
Branch::whereIn('id', $ids)->delete();
|
||||
return response()->json(['message' => 'Branches deleted successfully']);
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('branch.view')) {
|
||||
|
||||
@@ -82,6 +82,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteMultiple(Request $request)
|
||||
{
|
||||
$ids = $request->input('ids');
|
||||
Currency::whereIn('id', $ids)->delete();
|
||||
return response()->json(['message' => 'Currencies deleted successfully']);
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('currency.view')) {
|
||||
|
||||
@@ -88,6 +88,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteMultiple(Request $request)
|
||||
{
|
||||
$ids = $request->input('ids');
|
||||
HolidayCalendar::whereIn('id', $ids)->delete();
|
||||
return response()->json(['message' => 'Holidays deleted successfully']);
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('currency.view')) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Modules\Basicdata\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class BranchRequest extends FormRequest
|
||||
{
|
||||
@@ -21,9 +22,23 @@
|
||||
];
|
||||
|
||||
if ($this->method() == 'PUT') {
|
||||
$rules['code'] = 'required|string|max:3|unique:branches,code,' . $this->id;
|
||||
$rules['code'] = [
|
||||
'required',
|
||||
'string',
|
||||
'max:10',
|
||||
Rule::unique('branches')->ignore($this->id)->where(function ($query) {
|
||||
return $query->whereNull('deleted_at');
|
||||
}),
|
||||
];
|
||||
} else {
|
||||
$rules['code'] = 'required|string|max:3|unique:branches,code';
|
||||
$rules['code'] = [
|
||||
'required',
|
||||
'string',
|
||||
'max:10',
|
||||
Rule::unique('branches')->where(function ($query) {
|
||||
return $query->whereNull('deleted_at');
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
|
||||
16
module.json
16
module.json
@@ -15,16 +15,13 @@
|
||||
{
|
||||
"title": "Basic Data",
|
||||
"path": "basicdata",
|
||||
"icon": "ki-filled ki-category text-lg",
|
||||
"icon": "ki-filled ki-category text-lg text-primary",
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": [
|
||||
"administrator",
|
||||
"pemohon-ao",
|
||||
"pemohon-eo",
|
||||
"admin",
|
||||
"surveyor"
|
||||
"admin"
|
||||
],
|
||||
"sub": [
|
||||
{
|
||||
@@ -35,8 +32,7 @@
|
||||
"permission": "",
|
||||
"roles": [
|
||||
"administrator",
|
||||
"pemohon-ao",
|
||||
"pemohon-eo"
|
||||
"admin"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -47,8 +43,7 @@
|
||||
"permission": "",
|
||||
"roles": [
|
||||
"administrator",
|
||||
"pemohon-ao",
|
||||
"pemohon-eo"
|
||||
"admin"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -58,7 +53,8 @@
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": [
|
||||
"administrator"
|
||||
"administrator",
|
||||
"admin"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="5" data-datatable-state-save="false" id="branch-table" data-api-url="{{ route('basicdata.branch.datatables') }}">
|
||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="10" data-datatable-state-save="false" id="branch-table" data-api-url="{{ route('basicdata.branch.datatables') }}">
|
||||
<div class="card-header py-5 flex-wrap">
|
||||
<h3 class="card-title">
|
||||
Daftar Cabang
|
||||
@@ -21,6 +21,7 @@
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<a class="btn btn-sm btn-light" href="{{ route('basicdata.branch.export') }}"> Export to Excel </a>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('basicdata.branch.create') }}"> Tambah Cabang </a>
|
||||
<button class="btn btn-sm btn-danger hidden" id="deleteSelected" onclick="deleteSelectedRows()">Delete Selected</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -83,7 +84,7 @@
|
||||
$.ajax(`basic-data/cabang/${data}`, {
|
||||
type: 'DELETE'
|
||||
}).then((response) => {
|
||||
swal.fire('Deleted!', 'User has been deleted.', 'success').then(() => {
|
||||
swal.fire('Deleted!', 'Branch has been deleted.', 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}).catch((error) => {
|
||||
@@ -93,10 +94,52 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function deleteSelectedRows() {
|
||||
const selectedCheckboxes = document.querySelectorAll('input[data-datatable-row-check="true"]:checked');
|
||||
if (selectedCheckboxes.length === 0) {
|
||||
Swal.fire('Warning', 'Please select at least one row to delete.', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: `You are about to delete ${selectedCheckboxes.length} selected row(s). This action cannot be undone!`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete them!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const ids = Array.from(selectedCheckboxes).map(checkbox => checkbox.value);
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax('{{ route("basicdata.branch.deleteMultiple") }}', {
|
||||
type: 'POST',
|
||||
data: { ids: ids }
|
||||
}).then((response) => {
|
||||
Swal.fire('Deleted!', 'Selected rows have been deleted.', 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Error!', 'An error occurred while deleting the rows.', 'error');
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="module">
|
||||
const element = document.querySelector('#branch-table');
|
||||
const searchInput = document.getElementById('search');
|
||||
const deleteSelectedButton = document.getElementById('deleteSelected');
|
||||
|
||||
const apiUrl = element.getAttribute('data-api-url');
|
||||
const dataTableOptions = {
|
||||
@@ -140,8 +183,34 @@
|
||||
searchInput.addEventListener('input', function () {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
|
||||
});
|
||||
|
||||
function updateDeleteButtonVisibility() {
|
||||
const selectedCheckboxes = document.querySelectorAll('input[data-datatable-row-check="true"]:checked');
|
||||
if (selectedCheckboxes.length > 0) {
|
||||
deleteSelectedButton.classList.remove('hidden');
|
||||
} else {
|
||||
deleteSelectedButton.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
// Initial call to set button visibility
|
||||
updateDeleteButtonVisibility();
|
||||
|
||||
// Add event listener to the table for checkbox changes
|
||||
element.addEventListener('change', function(event) {
|
||||
if (event.target.matches('input[data-datatable-row-check="true"]')) {
|
||||
updateDeleteButtonVisibility();
|
||||
}
|
||||
});
|
||||
|
||||
// Add event listener for the "select all" checkbox
|
||||
const selectAllCheckbox = element.querySelector('input[data-datatable-check="true"]');
|
||||
if (selectAllCheckbox) {
|
||||
selectAllCheckbox.addEventListener('change', updateDeleteButtonVisibility);
|
||||
}
|
||||
|
||||
window.dataTable = dataTable;
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="5" data-datatable-state-save="false" id="currency-table" data-api-url="{{ route('basicdata.currency.datatables') }}">
|
||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="10" data-datatable-state-save="false" id="currency-table" data-api-url="{{ route('basicdata.currency.datatables') }}">
|
||||
<div class="card-header py-5 flex-wrap">
|
||||
<h3 class="card-title">
|
||||
Daftar Mata Uang
|
||||
@@ -21,6 +21,7 @@
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<a class="btn btn-sm btn-light" href="{{ route('basicdata.currency.export') }}"> Export to Excel </a>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('basicdata.currency.create') }}"> Tambah Mata Uang </a>
|
||||
<button class="btn btn-sm btn-danger hidden" id="deleteSelected" onclick="deleteSelectedRows()">Delete Selected</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -97,10 +98,51 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function deleteSelectedRows() {
|
||||
const selectedCheckboxes = document.querySelectorAll('input[data-datatable-row-check="true"]:checked');
|
||||
if (selectedCheckboxes.length === 0) {
|
||||
Swal.fire('Warning', 'Please select at least one row to delete.', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: `You are about to delete ${selectedCheckboxes.length} selected row(s). This action cannot be undone!`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete them!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const ids = Array.from(selectedCheckboxes).map(checkbox => checkbox.value);
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax('{{ route("basicdata.currency.deleteMultiple") }}', {
|
||||
type: 'POST',
|
||||
data: { ids: ids }
|
||||
}).then((response) => {
|
||||
Swal.fire('Deleted!', 'Selected rows have been deleted.', 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Error!', 'An error occurred while deleting the rows.', 'error');
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<script type="module">
|
||||
const element = document.querySelector('#currency-table');
|
||||
const searchInput = document.getElementById('search');
|
||||
const deleteSelectedButton = document.getElementById('deleteSelected');
|
||||
|
||||
const apiUrl = element.getAttribute('data-api-url');
|
||||
const dataTableOptions = {
|
||||
@@ -147,8 +189,34 @@
|
||||
searchInput.addEventListener('input', function () {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
|
||||
});
|
||||
|
||||
function updateDeleteButtonVisibility() {
|
||||
const selectedCheckboxes = document.querySelectorAll('input[data-datatable-row-check="true"]:checked');
|
||||
if (selectedCheckboxes.length > 0) {
|
||||
deleteSelectedButton.classList.remove('hidden');
|
||||
} else {
|
||||
deleteSelectedButton.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
// Initial call to set button visibility
|
||||
updateDeleteButtonVisibility();
|
||||
|
||||
// Add event listener to the table for checkbox changes
|
||||
element.addEventListener('change', function(event) {
|
||||
if (event.target.matches('input[data-datatable-row-check="true"]')) {
|
||||
updateDeleteButtonVisibility();
|
||||
}
|
||||
});
|
||||
|
||||
// Add event listener for the "select all" checkbox
|
||||
const selectAllCheckbox = element.querySelector('input[data-datatable-check="true"]');
|
||||
if (selectAllCheckbox) {
|
||||
selectAllCheckbox.addEventListener('change', updateDeleteButtonVisibility);
|
||||
}
|
||||
|
||||
window.dataTable = dataTable;
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
|
||||
@@ -6,68 +6,71 @@
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
@if(isset($holidayCalendar->id))
|
||||
<form action="{{ route('basicdata.holidaycalendar.update', $holidayCalendar->id) }}" method="POST">
|
||||
<input type="hidden" name="id" value="{{ $holidayCalendar->id }}">
|
||||
@if(isset($holiday->id))
|
||||
<form action="{{ route('basicdata.holidaycalendar.update', $holiday->id) }}" method="POST">
|
||||
<input type="hidden" name="id" value="{{ $holiday->id }}">
|
||||
@method('PUT')
|
||||
@else
|
||||
<form method="POST" action="{{ route('basicdata.holidaycalendar.store') }}">
|
||||
@endif
|
||||
@csrf
|
||||
<div class="card pb-2.5">
|
||||
<div class="card-header" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
{{ isset($holidayCalendar->id) ? 'Edit' : 'Tambah' }} Hari Libur
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('basicdata.holidaycalendar.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Tanggal
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('date') border-danger bg-danger-light @enderror" type="date" name="date" value="{{ $holidayCalendar->date ?? '' }}">
|
||||
@error('date')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
@else
|
||||
<form method="POST" action="{{ route('basicdata.holidaycalendar.store') }}">
|
||||
@endif
|
||||
@csrf
|
||||
<div class="card pb-2.5">
|
||||
<div class="card-header" id="basic_settings">
|
||||
<h3 class="card-title">
|
||||
{{ isset($holiday->id) ? 'Edit' : 'Tambah' }} Hari Libur
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('basicdata.holidaycalendar.index') }}" class="btn btn-xs btn-info"><i class="ki-filled ki-exit-left"></i> Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Tanggal
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('date') border-danger bg-danger-light @enderror" type="date" name="date" value="{{ old('date', isset($holiday) ? $holiday->date->format('Y-m-d') : '') }}">
|
||||
@error('date')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Deskripsi
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('description') border-danger bg-danger-light @enderror"
|
||||
type="text"
|
||||
name="description"
|
||||
value="{{ old('description', $holiday->description ?? '') }}">
|
||||
@error('description')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Tipe
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select class="select @error('type') border-danger bg-danger-light @enderror" name="type">
|
||||
<option value="">Pilih Tipe</option>
|
||||
<option value="national_holiday" {{ old('type', $holiday->type ?? '') == 'national_holiday' ? 'selected' : '' }}>Nasional</option>
|
||||
<option value="collective_leave" {{ old('type', $holiday->type ?? '') == 'collective_leave' ? 'selected' : '' }}>Cuti Bersama</option>
|
||||
</select>
|
||||
@error('type')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Deskripsi
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('description') border-danger bg-danger-light @enderror" type="text" name="description" value="{{ $holidayCalendar->description ?? '' }}">
|
||||
@error('description')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">
|
||||
Tipe
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select class="select @error('type') border-danger bg-danger-light @enderror" name="type">
|
||||
<option value="">Pilih Tipe</option>
|
||||
<option value="national_holiday" {{ (isset($holidayCalendar) && $holidayCalendar->type == 'national_holiday') ? 'selected' : '' }}>Nasional</option>
|
||||
<option value="collective_leave" {{ (isset($holidayCalendar) && $holidayCalendar->type == 'collective_leave') ? 'selected' : '' }}>Cuti Bersama</option>
|
||||
</select>
|
||||
@error('type')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
Save
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="5" data-datatable-state-save="false" id="holiday-calendar-table" data-api-url="{{ route('basicdata.holidaycalendar.datatables') }}">
|
||||
<div class="card card-grid min-w-full" data-datatable="false" data-datatable-page-size="10" data-datatable-state-save="false" id="holiday-calendar-table" data-api-url="{{ route('basicdata.holidaycalendar.datatables') }}">
|
||||
<div class="card-header py-5 flex-wrap">
|
||||
<h3 class="card-title">
|
||||
Daftar Hari Libur
|
||||
@@ -21,6 +21,7 @@
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<a class="btn btn-sm btn-light" href="{{ route('basicdata.holidaycalendar.export') }}"> Export to Excel </a>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('basicdata.holidaycalendar.create') }}"> Tambah Hari Libur </a>
|
||||
<button class="btn btn-sm btn-danger hidden" id="deleteSelected" onclick="deleteSelectedRows()">Delete Selected</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -97,10 +98,51 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function deleteSelectedRows() {
|
||||
const selectedCheckboxes = document.querySelectorAll('input[data-datatable-row-check="true"]:checked');
|
||||
if (selectedCheckboxes.length === 0) {
|
||||
Swal.fire('Warning', 'Please select at least one row to delete.', 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: `You are about to delete ${selectedCheckboxes.length} selected row(s). This action cannot be undone!`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Yes, delete them!'
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const ids = Array.from(selectedCheckboxes).map(checkbox => checkbox.value);
|
||||
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax('{{ route("basicdata.holidaycalendar.deleteMultiple") }}', {
|
||||
type: 'POST',
|
||||
data: { ids: ids }
|
||||
}).then((response) => {
|
||||
Swal.fire('Deleted!', 'Selected rows have been deleted.', 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}).catch((error) => {
|
||||
console.error('Error:', error);
|
||||
Swal.fire('Error!', 'An error occurred while deleting the rows.', 'error');
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
<script type="module">
|
||||
const element = document.querySelector('#holiday-calendar-table');
|
||||
const searchInput = document.getElementById('search');
|
||||
const deleteSelectedButton = document.getElementById('deleteSelected');
|
||||
|
||||
const apiUrl = element.getAttribute('data-api-url');
|
||||
const dataTableOptions = {
|
||||
@@ -136,7 +178,7 @@
|
||||
title: 'Action',
|
||||
render: (item, data) => {
|
||||
return `<div class="flex flex-nowrap justify-center">
|
||||
<a class="btn btn-sm btn-icon btn-clear btn-info" href="basic-data/holiday-calendar/${data.id}/edit">
|
||||
<a class="btn btn-sm btn-icon btn-clear btn-info" href="basic-data/holidaycalendar/${data.id}/edit">
|
||||
<i class="ki-outline ki-notepad-edit"></i>
|
||||
</a>
|
||||
<a onclick="deleteData(${data.id})" class="delete btn btn-sm btn-icon btn-clear btn-danger">
|
||||
@@ -154,5 +196,32 @@
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
});
|
||||
|
||||
function updateDeleteButtonVisibility() {
|
||||
const selectedCheckboxes = document.querySelectorAll('input[data-datatable-row-check="true"]:checked');
|
||||
if (selectedCheckboxes.length > 0) {
|
||||
deleteSelectedButton.classList.remove('hidden');
|
||||
} else {
|
||||
deleteSelectedButton.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
// Initial call to set button visibility
|
||||
updateDeleteButtonVisibility();
|
||||
|
||||
// Add event listener to the table for checkbox changes
|
||||
element.addEventListener('change', function(event) {
|
||||
if (event.target.matches('input[data-datatable-row-check="true"]')) {
|
||||
updateDeleteButtonVisibility();
|
||||
}
|
||||
});
|
||||
|
||||
// Add event listener for the "select all" checkbox
|
||||
const selectAllCheckbox = element.querySelector('input[data-datatable-check="true"]');
|
||||
if (selectAllCheckbox) {
|
||||
selectAllCheckbox.addEventListener('change', updateDeleteButtonVisibility);
|
||||
}
|
||||
|
||||
window.dataTable = dataTable;
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
Route::get('restore/{id}', [CurrencyController::class, 'restore'])->name('restore');
|
||||
Route::get('datatables', [CurrencyController::class, 'dataForDatatables'])->name('datatables');
|
||||
Route::get('export', [CurrencyController::class, 'export'])->name('export');
|
||||
Route::post('delete-multiple', [CurrencyController::class, 'deleteMultiple'])->name('deleteMultiple');
|
||||
});
|
||||
|
||||
Route::resource('mata-uang', CurrencyController::class, [
|
||||
@@ -41,6 +42,7 @@
|
||||
Route::get('restore/{id}', [BranchController::class, 'restore'])->name('restore');
|
||||
Route::get('datatables', [BranchController::class, 'dataForDatatables'])->name('datatables');
|
||||
Route::get('export', [BranchController::class, 'export'])->name('export');
|
||||
Route::post('delete-multiple', [BranchController::class, 'deleteMultiple'])->name('deleteMultiple');
|
||||
});
|
||||
|
||||
Route::resource('cabang', BranchController::class, [
|
||||
@@ -64,6 +66,7 @@
|
||||
Route::delete('/{id}', [HolidayCalendarController::class, 'destroy'])->name('destroy');
|
||||
Route::get('/datatables', [HolidayCalendarController::class, 'dataForDatatables'])->name('datatables');
|
||||
Route::get('/export', [HolidayCalendarController::class, 'export'])->name('export');
|
||||
Route::post('delete-multiple', [HolidayCalendarController::class, 'deleteMultiple'])->name('deleteMultiple');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user