313 lines
9.0 KiB
PHP
313 lines
9.0 KiB
PHP
@extends('admin.layouts.app')
|
|
|
|
@section('title', 'Daftar Mata Pelajaran')
|
|
|
|
@section('content')
|
|
|
|
<style>
|
|
.page-title {
|
|
font-size: 30px;
|
|
font-weight: 800;
|
|
margin-bottom: 10px;
|
|
margin-top: -20px;
|
|
}
|
|
|
|
.custom-card {
|
|
background: white;
|
|
border-radius: 20px;
|
|
border: 2px solid #e5e5e5;
|
|
padding: 25px;
|
|
}
|
|
|
|
.btn-primary-custom {
|
|
background: #2b8ef3;
|
|
color: white;
|
|
border-radius: 10px;
|
|
padding: 8px 18px;
|
|
border: none;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-size: 14px;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.table-header {
|
|
background: #a5e6ba;
|
|
}
|
|
|
|
.search-box {
|
|
background: #a5e6ba;
|
|
border-radius: 30px;
|
|
padding: 6px 15px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.search-box input {
|
|
border: none;
|
|
outline: none;
|
|
background: transparent;
|
|
width: 150px;
|
|
}
|
|
|
|
.action-icon {
|
|
width: 20px;
|
|
cursor: pointer;
|
|
margin: 0 5px;
|
|
}
|
|
|
|
.per-page-select, .filter-select {
|
|
border-radius: 10px;
|
|
padding: 5px;
|
|
border: 1px solid #ccc;
|
|
}
|
|
|
|
.modal {
|
|
left: auto !important;
|
|
right: 0;
|
|
width: calc(100% - 250px);
|
|
}
|
|
|
|
.modal-backdrop {
|
|
left: auto !important;
|
|
right: 0;
|
|
width: calc(100% - 250px);
|
|
}
|
|
|
|
.modal-dialog {
|
|
margin-right: auto;
|
|
margin-left: auto;
|
|
}
|
|
|
|
.modal-content {
|
|
border-radius: 20px;
|
|
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
|
|
}
|
|
|
|
.modal-header-pastel {
|
|
background: #FFD97D !important;
|
|
color: black !important;
|
|
border-bottom: none;
|
|
padding: 15px 20px;
|
|
border-top-left-radius: 20px;
|
|
border-top-right-radius: 20px;
|
|
}
|
|
</style>
|
|
|
|
<h3 class="page-title">DAFTAR MATA PELAJARAN</h3>
|
|
|
|
<div class="custom-card">
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
|
|
<button class="btn-primary-custom" data-bs-toggle="modal" data-bs-target="#modalTambah">
|
|
<img src="{{ asset('images/icon/main/add.png') }}" width="18">
|
|
Tambah Data
|
|
</button>
|
|
|
|
<form method="GET">
|
|
<div class="search-box">
|
|
<input type="text" name="search" placeholder="Cari" value="{{ request('search') }}">
|
|
<button style="border:none;background:none">
|
|
<img src="{{ asset('images/icon/main/search.png') }}" width="18">
|
|
</button>
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
|
|
<form method="GET" class="mb-2">
|
|
<span>Tampilkan</span>
|
|
|
|
<select name="perPage" onchange="this.form.submit()" class="per-page-select">
|
|
<option value="10" {{ request('perPage') == 10 ? 'selected' : '' }}>10</option>
|
|
<option value="25" {{ request('perPage') == 25 ? 'selected' : '' }}>25</option>
|
|
<option value="50" {{ request('perPage') == 50 ? 'selected' : '' }}>50</option>
|
|
</select>
|
|
|
|
<span>data</span>
|
|
|
|
<span class="ms-3">Filter Kelas</span>
|
|
|
|
<select name="filter_kelas" onchange="this.form.submit()" class="filter-select">
|
|
<option value="">Semua Kelas</option>
|
|
@foreach($kelass as $kelas)
|
|
<option value="{{ $kelas->id_kelas }}"
|
|
{{ request('filter_kelas') == $kelas->id_kelas ? 'selected' : '' }}>
|
|
{{ $kelas->tingkat }} - {{ $kelas->nama_kelas }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
|
|
<input type="hidden" name="search" value="{{ request('search') }}">
|
|
</form>
|
|
|
|
{{-- Alert Success --}}
|
|
@if(session('success'))
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
{{ session('success') }}
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
@endif
|
|
|
|
<table class="table text-center align-middle">
|
|
<thead class="table-header">
|
|
<tr>
|
|
<th>No</th>
|
|
<th>ID Mapel</th>
|
|
<th>Nama Mata Pelajaran</th>
|
|
<th>Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
<tbody>
|
|
@forelse($mapels as $index => $mapel)
|
|
<tr>
|
|
<td>{{ $mapels->firstItem() + $index }}</td>
|
|
<td>{{ $mapel->id_mapel }}</td>
|
|
<td>{{ $mapel->nama_mapel }}</td>
|
|
|
|
<td>
|
|
<button onclick="openEditModal(
|
|
'{{ $mapel->id_mapel }}',
|
|
'{{ $mapel->nama_mapel }}'
|
|
)" style="border:none;background:none">
|
|
<img src="{{ asset('images/icon/main/edit.png') }}" class="action-icon">
|
|
</button>
|
|
|
|
<form action="{{ route('admin.mapel.destroy', $mapel->id_mapel) }}"
|
|
method="POST" class="d-inline"
|
|
onsubmit="return confirm('Yakin ingin menghapus mata pelajaran {{ $mapel->nama_mapel }}?')">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" style="border:none;background:none">
|
|
<img src="{{ asset('images/icon/main/del.png') }}" class="action-icon">
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
|
|
@empty
|
|
<tr>
|
|
<td colspan="4">Belum ada data mata pelajaran</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
|
|
<div class="d-flex justify-content-end">
|
|
{{ $mapels->links() }}
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{-- MODAL TAMBAH --}}
|
|
<div class="modal fade" id="modalTambah">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header modal-header-pastel">
|
|
<h5 class="modal-title w-100">Tambah Mata Pelajaran</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
|
|
<form action="{{ route('admin.mapel.store') }}" method="POST">
|
|
@csrf
|
|
|
|
<div class="modal-body">
|
|
|
|
<div class="mb-3">
|
|
<label>Nama Mata Pelajaran <span class="text-danger">*</span></label>
|
|
<input type="text" name="nama_mapel" class="form-control @error('nama_mapel') is-invalid @enderror"
|
|
value="{{ old('nama_mapel') }}" placeholder="Contoh: Pemrograman Web" required>
|
|
@error('nama_mapel')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
<small class="text-muted">ID Mapel akan dibuat otomatis (MP001, MP002, ...)</small>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
|
<button class="btn btn-success">Simpan Data</button>
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{{-- MODAL EDIT --}}
|
|
<div class="modal fade" id="modalEdit">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
|
|
<div class="modal-header modal-header-pastel">
|
|
<h5 class="modal-title w-100">Edit Mata Pelajaran</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
|
|
<form id="formEdit" method="POST">
|
|
@csrf
|
|
@method('PUT')
|
|
|
|
<div class="modal-body">
|
|
|
|
<div class="mb-3">
|
|
<label>ID Mapel</label>
|
|
<input type="text" id="editIdMapel" class="form-control bg-light" disabled>
|
|
<small class="text-muted">ID Mapel tidak dapat diubah</small>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label>Nama Mata Pelajaran <span class="text-danger">*</span></label>
|
|
<input type="text" id="editNamaMapel" name="nama_mapel" class="form-control" required>
|
|
@error('nama_mapel')
|
|
<small class="text-danger">{{ $message }}</small>
|
|
@enderror
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
|
<button class="btn btn-success">Update</button>
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function openEditModal(idMapel, namaMapel) {
|
|
document.getElementById('editIdMapel').value = idMapel;
|
|
document.getElementById('editNamaMapel').value = namaMapel;
|
|
|
|
document.getElementById('formEdit').action = "{{ url('admin/mapel') }}/" + idMapel;
|
|
|
|
new bootstrap.Modal(document.getElementById('modalEdit')).show();
|
|
}
|
|
</script>
|
|
|
|
@if ($errors->any())
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
@if(session('error_from') == 'edit')
|
|
var modal = new bootstrap.Modal(document.getElementById('modalEdit'));
|
|
@else
|
|
var modal = new bootstrap.Modal(document.getElementById('modalTambah'));
|
|
@endif
|
|
|
|
modal.show();
|
|
});
|
|
</script>
|
|
@endif
|
|
|
|
@endsection |