perbaikan url query param surveyor dan perbaikan tampilan team activity
This commit is contained in:
@@ -47,7 +47,6 @@
|
||||
<h3 class="card-title">Team Activity</h3>
|
||||
</div>
|
||||
<div data-accordion="true">
|
||||
|
||||
@php
|
||||
$sortedTeamsActivity = $teamsActivity->sortBy(function ($item) {
|
||||
return $item->team->regions->penilaiTeam
|
||||
@@ -60,6 +59,9 @@
|
||||
@endphp
|
||||
|
||||
@foreach ($sortedTeamsActivity as $index => $item)
|
||||
@php
|
||||
$totalTask = countPermohonanForUser($item->user->id);
|
||||
@endphp
|
||||
<div class="accordion-item [&:not(:last-child)]:border-b border-b-gray-200" data-accordion-item="true"
|
||||
id="accordion_{{ $index }}">
|
||||
<button class="accordion-toggle py-4 group mx-8"
|
||||
@@ -69,18 +71,28 @@
|
||||
<tr>
|
||||
<th class="min-w-[150px]" style="width: 600px">
|
||||
<span
|
||||
class="text-base text-gray-900 font-normal break-words">{{ $item->user->name }}</span>
|
||||
class="text-base text-gray-900 font-medium break-words">{{ $item->user->name }}</span>
|
||||
</th>
|
||||
<th class="min-w-[150px]">
|
||||
<span class="text-base text-gray-900 font-normal">
|
||||
<p>Total Task: {{ countPermohonanForUser($item->user->id) }}</p>
|
||||
|
||||
@if ($totalTask >= 0 && $totalTask < 5)
|
||||
<span class="badge badge-outline badge-success rounded-full">Total Task
|
||||
{{ $totalTask }}</span>
|
||||
@elseif ($totalTask >= 5 && $totalTask < 10)
|
||||
<span class="badge badge-outline badge-warning rounded-full">Total Task
|
||||
{{ $totalTask }}</span>
|
||||
@else
|
||||
<span class="badge badge-outline badge-danger rounded-full">Total Task
|
||||
{{ $totalTask }}</span>
|
||||
@endif
|
||||
</span>
|
||||
</th>
|
||||
<th>
|
||||
<i
|
||||
class="ki-outline ki-plus text-gray-600 text-2sm accordion-active:hidden block"></i>
|
||||
class="ki-outline ki-plus text-gray-600 text-2sm font-medium accordion-active:hidden block"></i>
|
||||
<i
|
||||
class="ki-outline ki-minus text-gray-600 text-2sm accordion-active:block hidden"></i>
|
||||
class="ki-outline ki-minus text-gray-600 text-2sm font-medium accordion-active:block hidden"></i>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
@@ -144,13 +156,6 @@
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
function jadwal(id) {
|
||||
document.getElementById('ids').value = id;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script type="module">
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const accordions = document.querySelectorAll('[data-accordion-item]');
|
||||
@@ -241,7 +246,7 @@
|
||||
title: 'Due Date',
|
||||
render: (item, data) => {
|
||||
if (!data.due_date_sla) {
|
||||
return `<span class="badge badge-sm badge-danger uppercase flex justify-center">Sudah melewati batas</span>`;
|
||||
return `<span class="badge badge-sm badge-outline badge-danger uppercase flex justify-center">Sudah melewati batas</span>`;
|
||||
}
|
||||
return `${window.formatTanggalIndonesia(data.due_date_sla)}`;
|
||||
}
|
||||
@@ -251,7 +256,7 @@
|
||||
title: 'Paparan',
|
||||
render: (item, data) => {
|
||||
if (!data.due_date_sla) {
|
||||
return `<span class="badge badge-sm badge-danger uppercase flex justify-center">Sudah melewati batas</span>`;
|
||||
return `<span class="badge badge-sm badge-outline badge-danger uppercase flex justify-center">Sudah melewati batas</span>`;
|
||||
}
|
||||
return `${window.formatTanggalIndonesia(data.due_date_sla)}`;
|
||||
}
|
||||
@@ -311,110 +316,115 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function updateTeam(penilaaniId, permohonanId, userId, teamId) {
|
||||
const selectCategory = () => {
|
||||
Swal.fire({
|
||||
title: 'Pilih Kategori',
|
||||
input: 'select',
|
||||
inputOptions: {
|
||||
team: 'Pilih dari Team',
|
||||
region: 'Pilih dari Wilayah'
|
||||
},
|
||||
inputPlaceholder: 'Pilih kategori Pengganti',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Lanjut',
|
||||
cancelButtonText: 'Batal',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const selectedCategory = result.value;
|
||||
let subOptions = {};
|
||||
<script type="text/javascript">
|
||||
function updateTeam(penilaaniId, permohonanId, userId, teamId) {
|
||||
const selectCategory = () => {
|
||||
Swal.fire({
|
||||
title: 'Pilih Kategori',
|
||||
input: 'select',
|
||||
inputOptions: {
|
||||
team: 'Pilih dari Team',
|
||||
region: 'Pilih dari Wilayah'
|
||||
},
|
||||
inputPlaceholder: 'Pilih kategori Pengganti',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Lanjut',
|
||||
cancelButtonText: 'Batal',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const selectedCategory = result.value;
|
||||
let subOptions = {};
|
||||
|
||||
if (selectedCategory === 'team') {
|
||||
subOptions = {
|
||||
@foreach ($teamsActivity as $item)
|
||||
{{ $item->user->id }}: '{{ $item->user->name }}',
|
||||
@endforeach
|
||||
};
|
||||
} else if (selectedCategory === 'region') {
|
||||
subOptions = {
|
||||
@foreach ($teamPenilai as $item)
|
||||
{{ $item->regions->id }}: '{{ $item->regions->name }}',
|
||||
@endforeach
|
||||
};
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Pilih ' + (selectedCategory === 'team' ? 'Anggota Tim' : 'Wilayah'),
|
||||
input: 'select',
|
||||
inputOptions: subOptions,
|
||||
inputPlaceholder: 'Pilih salah satu ' + (selectedCategory === 'team' ? 'Anggota Tim' : 'Wilayah'),
|
||||
icon: 'info',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Ya',
|
||||
cancelButtonText: 'Kembali',
|
||||
}).then((subResult) => {
|
||||
if (subResult.dismiss === Swal.DismissReason.cancel) {
|
||||
// Kembali ke tahap pemilihan kategori
|
||||
selectCategory();
|
||||
} else if (subResult.isConfirmed) {
|
||||
if (!subResult.value) {
|
||||
Swal.fire('Error!', 'Anda harus memilih opsi sebelum melanjutkan.', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Define variables
|
||||
let token = "{{ csrf_token() }}";
|
||||
let useURL = "{{ URL::to('/activity/update-team') }}";
|
||||
|
||||
// Tentukan tipe parameter berdasarkan kategori
|
||||
const paramKey = selectedCategory === 'team' ? 'team_member_id' : 'region_id';
|
||||
|
||||
// Prepare input data
|
||||
let input_data = {
|
||||
_token: token,
|
||||
id: penilaaniId,
|
||||
[paramKey]: subResult.value,
|
||||
permohonan_id: permohonanId,
|
||||
user_id: userId,
|
||||
team_id: teamId,
|
||||
if (selectedCategory === 'team') {
|
||||
subOptions = {
|
||||
@foreach ($teamsActivity as $item)
|
||||
{{ $item->user->id }}: '{{ $item->user->name }}',
|
||||
@endforeach
|
||||
};
|
||||
} else if (selectedCategory === 'region') {
|
||||
subOptions = {
|
||||
@foreach ($teamPenilai as $item)
|
||||
{{ $item->regions->id }}: '{{ $item->regions->name }}',
|
||||
@endforeach
|
||||
};
|
||||
|
||||
// AJAX request
|
||||
$.ajax({
|
||||
url: useURL,
|
||||
type: "PUT",
|
||||
cache: false,
|
||||
data: input_data,
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
if (response.status === 'success') {
|
||||
Swal.fire('Sukses!', response.message, 'success').then(() => {
|
||||
location.reload(true);
|
||||
});
|
||||
} else {
|
||||
Swal.fire('Error!', response.message, 'error');
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
console.error(xhr);
|
||||
Swal.fire('Error!', 'Terjadi kesalahan saat memproses permintaan.', 'error');
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Mulai dari pemilihan kategori
|
||||
selectCategory();
|
||||
}
|
||||
</script>
|
||||
Swal.fire({
|
||||
title: 'Pilih ' + (selectedCategory === 'team' ? 'Anggota Tim' : 'Wilayah'),
|
||||
input: 'select',
|
||||
inputOptions: subOptions,
|
||||
inputPlaceholder: 'Pilih salah satu ' + (selectedCategory === 'team' ?
|
||||
'Anggota Tim' : 'Wilayah'),
|
||||
icon: 'info',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Ya',
|
||||
cancelButtonText: 'Kembali',
|
||||
}).then((subResult) => {
|
||||
if (subResult.dismiss === Swal.DismissReason.cancel) {
|
||||
// Kembali ke tahap pemilihan kategori
|
||||
selectCategory();
|
||||
} else if (subResult.isConfirmed) {
|
||||
if (!subResult.value) {
|
||||
Swal.fire('Error!', 'Anda harus memilih opsi sebelum melanjutkan.',
|
||||
'error');
|
||||
return;
|
||||
}
|
||||
|
||||
// Define variables
|
||||
let token = "{{ csrf_token() }}";
|
||||
let useURL = "{{ URL::to('/activity/update-team') }}";
|
||||
|
||||
// Tentukan tipe parameter berdasarkan kategori
|
||||
const paramKey = selectedCategory === 'team' ? 'team_member_id' :
|
||||
'region_id';
|
||||
|
||||
// Prepare input data
|
||||
let input_data = {
|
||||
_token: token,
|
||||
id: penilaaniId,
|
||||
[paramKey]: subResult.value,
|
||||
permohonan_id: permohonanId,
|
||||
user_id: userId,
|
||||
team_id: teamId,
|
||||
};
|
||||
|
||||
// AJAX request
|
||||
$.ajax({
|
||||
url: useURL,
|
||||
type: "PUT",
|
||||
cache: false,
|
||||
data: input_data,
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
if (response.status === 'success') {
|
||||
Swal.fire('Sukses!', response.message,
|
||||
'success').then(() => {
|
||||
location.reload(true);
|
||||
});
|
||||
} else {
|
||||
Swal.fire('Error!', response.message, 'error');
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
console.error(xhr);
|
||||
Swal.fire('Error!',
|
||||
'Terjadi kesalahan saat memproses permintaan.',
|
||||
'error');
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// Mulai dari pemilihan kategori
|
||||
selectCategory();
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
Reference in New Issue
Block a user