Commit 5629fab6 by Alfiro Pratama

Edit Ketua Kelompok by Operator

parent 1e425193
......@@ -138,7 +138,10 @@ class KelompokController extends Controller
public function getDetil(Request $request)
{
$reqKelompokId = Crypt::decrypt($request->kelompok_id);
$kelompok_detil = KelompokDetail::where('kelompok_id', $reqKelompokId)->get();
$kelompok_detil = KelompokDetail::where('kelompok_id', $reqKelompokId)
->orderBy('status_ketua', 'ASC')
->orderBy('status_ketua', 'DESC')
->get();
$data = '';
$no = 1;
......@@ -151,6 +154,20 @@ class KelompokController extends Controller
$anggota++;
$keterangan = "Anggota ".$anggota?:1;
}
$select = "<div class='d-flex align-items-center'>
<select name='keterangan[]' class=''>
<option value='1' ".($value->status_ketua == '1' ? 'selected' : '').">Ketua</option>
<option value='2' ".($value->status_ketua == '2' ? 'selected' : '').">Anggota</option>
</select>
<input type='hidden' name='kelompok_detil_id[]' value='".$value->kelompok_detil_id."'>";
if ($value->status_ketua != '1') {
$select .= "<span style='margin-left: 10px;'>".$anggota."</span>";
}
$select .= "</div>";
$data .= "
<tr>
<td>".$no."</td>
......@@ -158,7 +175,7 @@ class KelompokController extends Controller
<td>".$value->nim."</td>
<td>".$value->fakultas."</td>
<td>".$value->prodi."</td>
<td>".$keterangan."</td>
<td>".$select."</td>
</tr>
";
$no++;
......@@ -187,6 +204,25 @@ class KelompokController extends Controller
}
public function updateKetua(Request $request)
{
DB::beginTransaction();
try {
foreach($request->kelompok_detil_id as $key => $kelompok_detil_id) {
$status_ketua = $request->keterangan[$key];
KelompokDetail::where('kelompok_detil_id', $kelompok_detil_id)
->update(['status_ketua' => $status_ketua]);
}
DB::commit();
return response()->json(['success' => true, 'message' => 'Data berhasil disimpan.']);
} catch (\Exception $e) {
DB::rollback();
return response()->json(['error' => true, 'message' => 'Data gagal disimpan.']);
}
}
public function destroy($id)
{
......
......@@ -24,8 +24,6 @@
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
......@@ -92,6 +90,9 @@
</div>
<div class="modal-body">
<div class="table-responsive">
<form id="form-update-ketua" method="POST" action="{{ route('operator.update-kelompok') }}">
@csrf
{{-- @method('PUT') --}}
<table class="w-100" id="tblempinfo">
<thead>
<tr>
......@@ -105,10 +106,12 @@
</thead>
<tbody></tbody>
</table>
</form>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary" form="form-update-ketua">Submit</button>
</div>
</div>
</div>
......@@ -228,6 +231,47 @@
}
});
$('#form-update-ketua').on('submit', function(e) {
e.preventDefault();
var form = $(this);
var url = form.attr('action');
$.ajax({
type: "POST",
url: url,
data: form.serialize(), // serializes the form's elements
dataType: 'json',
success: function(response) {
if (response.success) {
swal({
title: "Berhasil!",
text: response.message,
icon: "success",
button: "OK",
}).then(function() {
// Reload or redirect after success if needed
location.reload();
});
} else {
swal({
title: "Gagal!",
text: response.message,
icon: "error",
button: "OK",
});
}
},
error: function(xhr, status, error) {
swal({
title: "Gagal!",
text: "Terjadi kesalahan pada server.",
icon: "error",
button: "OK",
});
}
});
});
});
</script>
@endsection
......@@ -51,6 +51,7 @@
{{-- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> --}}
<script src="https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
{{-- <script type="text/javascript" src="{{ asset('theme/js/eModal.js') }}"></script> --}}
{{-- <script>
......
......@@ -43,9 +43,9 @@
</b>
{{-- @php dd(Auth::user()->roles->first()); @endphp --}}
@if (Auth::user()->roles->first()->name == 'mahasiswa')
<img src="{{ is_null(Auth::user()->rBiodata) ? asset('theme/images/users/user-null.jpg') : is_null(Auth::user()->rBiodata->noidentitas) ? asset('theme/images/users/user-null') : 'https://siakadu.unesa.ac.id/photo/fotomhs/'.Auth::user()->rBiodata->noidentitas }}.jpg" alt="Header Avatar" class="rounded-circle header-profile-user" >
<img src="{{ is_null(Auth::user()->rBiodata) ? asset('theme/images/users/user-null.jpg') : (is_null(Auth::user()->rBiodata->noidentitas) ? asset('theme/images/users/user-null') : 'https://siakadu.unesa.ac.id/photo/fotomhs/'.Auth::user()->rBiodata->noidentitas) }}.jpg" alt="Header Avatar" class="rounded-circle header-profile-user" >
@else
<img src="{{ is_null(Auth::user()->rBiodata) ? asset('theme/images/users/user-null.jpg') : is_null(Auth::user()->rBiodata->noidentitas) ? asset('theme/images/users/user-null') : 'https://siakadu.unesa.ac.id/photo/'.Auth::user()->rBiodata->noidentitas }}.jpg" alt="Header Avatar" class="rounded-circle header-profile-user" >
<img src="{{ is_null(Auth::user()->rBiodata) ? asset('theme/images/users/user-null.jpg') : (is_null(Auth::user()->rBiodata->noidentitas) ? asset('theme/images/users/user-null') : 'https://siakadu.unesa.ac.id/photo/'.Auth::user()->rBiodata->noidentitas) }}.jpg" alt="Header Avatar" class="rounded-circle header-profile-user" >
@endif
</button>
<div class="dropdown-menu dropdown-menu-end">
......
......@@ -156,6 +156,7 @@ Route::group(['middleware' => ['auth:sanctum', 'verified']], function () {
Route::get('getKelompok', [KelompokController::class, 'getData'])->name('getKelompok');
Route::get('getDetilKelompok', [KelompokController::class, 'getDetil'])->name('getDetilKelompok');
Route::post('proses-kelompok', [KelompokController::class, 'prosesKelompok'])->name('proses-kelompok');
Route::post('kelompok/update-kelompok', [KelompokController::class, 'updateKetua'])->name('update-kelompok');
Route::resource('proposal', ProposalController::class);
Route::get('getProposal', [ProposalController::class, 'getData'])->name('getProposal');
......
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