Commit b592db66 by Alfiro Pratama

Re-approve Kelompok mhs, Filter data kelompok view dosen

parent 502b8df9
......@@ -32,7 +32,11 @@ class KelompokController extends Controller
$year = !is_null($request->year) ? $request->year : now()->year;
$kelompok = Kelompok::with(['rAnggota'])
->where('nidn_dosen', $bio->noidentitas)
// ->where('nidn_dosen', $bio->noidentitas)
->when($bio->noidentitas !== null, function ($query) use ($bio) {
return $query->where('nidn_dosen', $bio->noidentitas);
})
->whereRaw('LOWER(nama_dosen) = ?', [strtolower($bio->name)])
->where('kirim', '1')
->whereYear('created_at', $year)
->orderBy('kode')
......
......@@ -121,8 +121,16 @@ class AnggotaController extends Controller
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
public function destroy($anggotum)
{
//
$anggota = KelompokDetail::find($anggotum);
if ($anggota && $anggota->status_ketua != 1) {
$anggota->delete();
return redirect()->back()->with('success', 'Anggota berhasil dihapus.');
} else {
return redirect()->back()->with('error', 'Tidak dapat menghapus ketua atau anggota tidak ditemukan.');
}
}
}
......@@ -97,17 +97,17 @@ class KelompokController extends Controller
if($status == '1')
{
$keterangan = '<span class="badge bg-success">Disetujui</span>';
$aksi = '';
$aksi = '<a class="btn btn-warning btn-sm waves-effect waves-light aksi" role="button" data-ket="Kelompok yang sudah disetujui dan dibatalkan statusnya, dapat mengubah anggota kelompok serta harus melakukan verifikasi mandiri kembali." data-id="'.Crypt::encrypt($kelompok_id.'#0').'"><i class="fas fa-undo"></i></a>';
}
elseif($status == '2')
{
$keterangan = '<span class="badge bg-danger">Ditolak</span>';
$aksi = '<a class="btn btn-warning btn-sm waves-effect waves-light aksi" role="button" data-ket="Kelompok yang di dibatalkan status tolak akan menunggu di verifikasi kembali oleh dosen pembimbing." data-id="'.Crypt::encrypt($kelompok_id.'#0').'"><i class="fas fa-undo"></i></a>';
$aksi = '<a class="btn btn-warning btn-sm waves-effect waves-light aksi" role="button" data-ket="Kelompok yang dibatalkan status tolak akan menunggu di verifikasi kembali oleh dosen pembimbing." data-id="'.Crypt::encrypt($kelompok_id.'#0').'"><i class="fas fa-undo"></i></a>';
}
else
{
$keterangan = '<span class="badge bg-warning">Menunngu Persetujuan</span>';
$aksi = '<a class="btn btn-success btn-sm waves-effect waves-light aksi" role="button" data-ket="Kelompok yang di setujui akan di teruskan untuk upload proposal" data-id="'.Crypt::encrypt($kelompok_id.'#1').'"><i class="fas fa-check"></i></a> <a class="btn btn-danger btn-sm waves-effect waves-light aksi" role="button" data-ket="Kelompok yang tidak di setujui tidak bisa untuk upload proposal" data-id="'.Crypt::encrypt($kelompok_id.'#2').'"><i class="fas fa-times"></i></a>';
$aksi = '<a class="btn btn-success btn-sm waves-effect waves-light aksi" role="button" data-ket="Kelompok yang disetujui akan diteruskan untuk upload proposal" data-id="'.Crypt::encrypt($kelompok_id.'#1').'"><i class="fas fa-check"></i></a> <a class="btn btn-danger btn-sm waves-effect waves-light aksi" role="button" data-ket="Kelompok yang tidak di setujui tidak bisa untuk upload proposal" data-id="'.Crypt::encrypt($kelompok_id.'#2').'"><i class="fas fa-times"></i></a>';
}
$aksi .= ' <a class="btn btn-primary btn-sm waves-effect waves-light viewdetails" role="button" data-id="'.Crypt::encrypt($kelompok_id).'"><i class="fas fa-eye"></i></a>';
......
......@@ -81,8 +81,25 @@
// scrolling can be used
params.page = params.page || 1;
// return {
// results: data.items,
// pagination: {
// more: (params.page * 30) < data.total_count
// }
// };
// },
const modifiedItems = data.items.map(item => {
return {
results: data.items,
id: item.id,
text: item.full_name,
full_name: item.full_name,
description: item.description,
disabled: item.disabled || false,
};
});
return {
results: modifiedItems,
pagination: {
more: (params.page * 30) < data.total_count
}
......@@ -106,13 +123,13 @@
"<div class='select2-result-repository clearfix'>" +
"<div class='select2-result-repository__meta'>" +
"<div class='select2-result-repository__title'></div>" +
"<div class='select2-result-repository__description'></div>" +
"<div class='select2-result-repository__description text-muted'></div>" +
"</div>" +
"</div>"
);
$container.find(".select2-result-repository__title").text(repo.full_name);
$container.find(".select2-result-repository__description").text(repo.description);
$container.find(".select2-result-repository__description").html(repo.description);
return $container;
}
......
......@@ -55,9 +55,14 @@
<div class="col-10">
<h4 class="card-title">Anggota Kelompok</h4>
</div>
{{-- <div class="col-2">
<a href="{{ URL::to('mahasiswa/anggota/create') }}" class="btn btn-info btn-sm">Tambah Anggota</a>
</div> --}}
@if($kelompok->rAnggota->count() < 5)
<div class="col-2">
<a href="{{ URL::to('mahasiswa/anggota/create') }}" class="btn btn-info btn-sm">Tambah Anggota</a>
</div>
@endif
</div>
<br/>
<div class="table-responsive">
......@@ -70,7 +75,7 @@
<td>Fakultas</td>
<td>Program Studi</td>
<td>Keterangan</td>
<td></td>
<td>#</td>
</tr>
<thead>
<tbody>
......@@ -88,7 +93,16 @@
Anggota {{ $loop->iteration-1 }}
@endif
</td>
<td></td>
<td>
@if($item->status_ketua != 1)
{{-- <form action="{{ route('mahasiswa.anggota.destroy', $item->kelompok_detil_id) }}" method="POST" onsubmit="return confirm('Yakin ingin menghapus anggota ini?');"> --}}
<form action="{{ route('mahasiswa.anggota.destroy', $item->kelompok_detil_id) }}" method="POST" class="delete-form">
@csrf
@method('DELETE')
<button type="submit" class="btn btn-danger btn-sm" id="deleteButton"><i class="fas fa-trash-alt"></i></button>
</form>
@endif
</td>
</tr>
@endforeach
</tbody>
......@@ -110,7 +124,7 @@
<strong>Informasi!</strong> Anggota kelompok minimal 3 dan maksimal 5 </strong>
</div>
<div class="mb-0">
@if($kelompok->rAnggota->count() >= 3)
@if($kelompok->rAnggota->count() >= 3 && $kelompok->rAnggota->count() <= 5)
<button type="submit" class="btn btn-primary waves-effect waves-light me-1 btnSimpanKelompok" id="btnSimpanKelompok"> Submit </button>
@endif
<a href="{{ URL::to('mahasiswa/kelompok') }}" type="reset" class="btn btn-secondary waves-effect"> Kembali </a>
......@@ -133,4 +147,29 @@
$("#addKelompok").submit();
});
</script>
<script>
// Menambahkan SweetAlert untuk konfirmasi penghapusan
document.querySelectorAll('.delete-form').forEach((form) => {
form.addEventListener('submit', function (e) {
e.preventDefault(); // Mencegah form untuk submit langsung
Swal.fire({
title: 'Yakin ingin menghapus anggota ini?',
text: "Data ini tidak bisa dikembalikan lagi!",
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Ya, hapus!',
cancelButtonText: 'Batal',
reverseButtons: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#28a745'
}).then((result) => {
if (result.isConfirmed) {
// Jika user memilih "Ya", form akan disubmit
form.submit();
}
});
});
});
</script>
@endsection
......@@ -186,6 +186,51 @@
}
});
// $('#example').on('click','.aksi',function(){
// var kelId = $(this).attr('data-id');
// var ket = $(this).attr('data-ket');
// if(kelId != null || kelId != ''){
// Swal.fire({
// title: "Apakah Anda Yakin?",
// text: ket,
// icon: "warning",
// showCancelButton: !0,
// confirmButtonText: "Ya!",
// cancelButtonText: "Tidak, Kembali!",
// confirmButtonClass: "btn btn-success mt-2",
// cancelButtonClass: "btn btn-danger ms-2 mt-2",
// buttonsStyling: !1,
// allowOutsideClick: !1,
// showLoaderOnConfirm: true
// }).then((result) => {
// if (result.value){
// $.ajax({
// url:'{{url("/operator/proses-kelompok")}}',
// type:'POST',
// data:{
// "_token": "{{ csrf_token() }}",
// "kelompokId": kelId
// },
// dataType: "JSON",
// })
// .done(function(response){
// swal.fire(response.status, response.message, response.status).then(function(){
// oTable.ajax.reload();
// });
// })
// .fail(function(){
// swal.fire('Oops...', 'Something went wrong with ajax !', 'error');
// });
// }
// else
// {
// swal.fire('Batal!', 'Data batal diproses.', 'error');
// }
// })
// }
// });
$('#example').on('click','.aksi',function(){
var kelId = $(this).attr('data-id');
var ket = $(this).attr('data-ket');
......@@ -195,39 +240,44 @@
title: "Apakah Anda Yakin?",
text: ket,
icon: "warning",
showCancelButton: !0,
showCancelButton: true,
confirmButtonText: "Ya!",
cancelButtonText: "Tidak, Kembali!",
confirmButtonClass: "btn btn-success mt-2",
cancelButtonClass: "btn btn-danger ms-2 mt-2",
buttonsStyling: !1,
allowOutsideClick: !1,
showLoaderOnConfirm: true
}).then((result) => {
if (result.value){
$.ajax({
url:'{{url("/operator/proses-kelompok")}}',
type:'POST',
data:{
confirmButtonColor: "#d33", // Merah
cancelButtonColor: "#3085d6", // Biru
showLoaderOnConfirm: true,
allowOutsideClick: false,
preConfirm: () => {
return $.ajax({
url: '{{ url("/operator/proses-kelompok") }}',
type: 'POST',
data: {
"_token": "{{ csrf_token() }}",
"kelompokId": kelId
},
dataType: "JSON",
})
.done(function(response){
swal.fire(response.status, response.message, response.status).then(function(){
oTable.ajax.reload();
});
})
.fail(function(){
swal.fire('Oops...', 'Something went wrong with ajax !', 'error');
dataType: "json"
}).then(response => {
return response;
}).catch(error => {
Swal.showValidationMessage(
`Request gagal: ${error.statusText}`
);
});
}
else
{
swal.fire('Batal!', 'Data batal diproses.', 'error');
}).then((result) => {
if (result.isConfirmed) {
Swal.fire({
title: 'Berhasil!',
text: result.value.message,
icon: result.value.status,
confirmButtonText: 'OK'
}).then(() => {
oTable.ajax.reload();
});
} else if (result.dismiss === Swal.DismissReason.cancel) {
Swal.fire('Dibatalkan', 'Tidak jadi memproses data.', 'info');
}
})
});
}
});
......
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