715 lines
42 KiB
PHP
715 lines
42 KiB
PHP
@extends('admin.layouts.app')
|
|
|
|
@section('title', 'Cek Duplikasi Siswa')
|
|
|
|
@push('style')
|
|
<style>
|
|
.card-compare {
|
|
cursor: pointer;
|
|
transition: all .2s;
|
|
border: 1px solid #e0e0e0;
|
|
}
|
|
.card-compare:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0,0,0,.08);
|
|
border-color: #6777ef;
|
|
}
|
|
.card-compare.active {
|
|
border: 2px solid #6777ef;
|
|
background-color: #f7f9ff;
|
|
}
|
|
.card-compare.active:after{
|
|
content: "\ed31"; /* contoh unicode */
|
|
font-family: "boxicons";
|
|
font-size: 30px;
|
|
color: #6777ef;
|
|
position: absolute;
|
|
top: 0;
|
|
right: 6px;
|
|
}
|
|
.card-compare {
|
|
position: relative;
|
|
}
|
|
.card-compare .select-hint {
|
|
position: absolute;
|
|
top: 8px;
|
|
right: 8px;
|
|
font-size: 0.75rem;
|
|
background: #f0f0f0;
|
|
color: #666;
|
|
padding: 3px 6px;
|
|
border-radius: 3px;
|
|
opacity: 1;
|
|
transition: opacity .2s;
|
|
}
|
|
.card-compare:hover .select-hint {
|
|
opacity: 1;
|
|
}
|
|
.card-compare.active .select-hint {
|
|
display: none;
|
|
}
|
|
|
|
/* selectable data baru card */
|
|
.card-siswa-baru {
|
|
cursor: pointer;
|
|
transition: all .2s;
|
|
border: 1px solid #e0e0e0;
|
|
}
|
|
.card-siswa-baru:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0,0,0,.08);
|
|
border-color: #6777ef;
|
|
}
|
|
.card-siswa-baru.active {
|
|
border: 2px solid #6777ef!important;
|
|
background-color: #f7f9ff;
|
|
}
|
|
.card-siswa-baru.active:after{
|
|
content: "\ed31"; /* contoh unicode */
|
|
font-family: "boxicons";
|
|
font-size: 30px;
|
|
color: #6777ef;
|
|
position: absolute;
|
|
top: 0;
|
|
right: 6px;
|
|
}
|
|
.card-siswa-baru {
|
|
position: relative;
|
|
}
|
|
.card-siswa-baru .select-hint {
|
|
position: absolute;
|
|
top: 8px;
|
|
right: 8px;
|
|
font-size: 0.75rem;
|
|
background: #f0f0f0;
|
|
color: #666;
|
|
padding: 3px 6px;
|
|
border-radius: 3px;
|
|
opacity: 1;
|
|
transition: opacity .2s;
|
|
}
|
|
.card-siswa-baru:hover .select-hint {
|
|
opacity: 1;
|
|
}
|
|
.card-siswa-baru.active .select-hint {
|
|
display: none;
|
|
}
|
|
|
|
.checkbox-wrapper-46 input[type="checkbox"] {
|
|
display: none;
|
|
visibility: hidden;
|
|
}
|
|
|
|
.checkbox-wrapper-46 .cbx {
|
|
margin: auto;
|
|
-webkit-user-select: none;
|
|
user-select: none;
|
|
cursor: pointer;
|
|
}
|
|
.checkbox-wrapper-46 .cbx span {
|
|
display: inline-block;
|
|
vertical-align: middle;
|
|
transform: translate3d(0, 0, 0);
|
|
}
|
|
.checkbox-wrapper-46 .cbx span:first-child {
|
|
position: relative;
|
|
width: 18px;
|
|
height: 18px;
|
|
border-radius: 3px;
|
|
transform: scale(1);
|
|
vertical-align: middle;
|
|
border: 1px solid #9098A9;
|
|
transition: all 0.2s ease;
|
|
}
|
|
.checkbox-wrapper-46 .cbx span:first-child svg {
|
|
position: absolute;
|
|
top: 3px;
|
|
left: 2px;
|
|
fill: none;
|
|
stroke: #FFFFFF;
|
|
stroke-width: 2;
|
|
stroke-linecap: round;
|
|
stroke-linejoin: round;
|
|
stroke-dasharray: 16px;
|
|
stroke-dashoffset: 16px;
|
|
transition: all 0.3s ease;
|
|
transition-delay: 0.1s;
|
|
transform: translate3d(0, 0, 0);
|
|
}
|
|
.checkbox-wrapper-46 .cbx span:first-child:before {
|
|
content: "";
|
|
width: 150%;
|
|
height: 75%;
|
|
background: #506EEC;
|
|
display: block;
|
|
transform: scale(0);
|
|
opacity: 1;
|
|
border-radius: 50%;
|
|
}
|
|
.checkbox-wrapper-46 .cbx span:last-child {
|
|
padding-left: 8px;
|
|
}
|
|
.checkbox-wrapper-46 .cbx:hover span:first-child {
|
|
border-color: #506EEC;
|
|
}
|
|
|
|
.checkbox-wrapper-46 .inp-cbx:checked + .cbx span:first-child {
|
|
background: #506EEC;
|
|
border-color: #506EEC;
|
|
animation: wave-46 0.4s ease;
|
|
}
|
|
.checkbox-wrapper-46 .inp-cbx:checked + .cbx span:first-child svg {
|
|
stroke-dashoffset: 0;
|
|
}
|
|
.checkbox-wrapper-46 .inp-cbx:checked + .cbx span:first-child:before {
|
|
transform: scale(3.5);
|
|
opacity: 0;
|
|
transition: all 0.6s ease;
|
|
margin-left: -6px;
|
|
margin-top: 2px;
|
|
}
|
|
|
|
|
|
@keyframes wave-46 {
|
|
50% {
|
|
transform: scale(0.9);
|
|
}
|
|
}
|
|
|
|
#merge-fields.card{
|
|
border: 1px solid #ffa800;
|
|
border-radius: 10px;
|
|
box-shadow: none;
|
|
background-color: rgba(255, 244, 222, 0.44);
|
|
}
|
|
|
|
/* area merge option */
|
|
/*.merge-options {*/
|
|
/* margin-top: 1rem;*/
|
|
/*}*/
|
|
/*.merge-options h6 {*/
|
|
/* font-size: 1rem;*/
|
|
/* margin-bottom: .75rem;*/
|
|
/*}*/
|
|
/*.merge-options .form-check {*/
|
|
/* margin-bottom: .5rem;*/
|
|
/*}*/
|
|
|
|
/* responsive adjustments */
|
|
@media (max-width: 767px) {
|
|
/*.merge-options {*/
|
|
/* margin-top: 1.5rem;*/
|
|
/*}*/
|
|
/*.card-compare::before,*/
|
|
/*.card-siswa-baru::before {*/
|
|
/* width: 18px;*/
|
|
/* height: 18px;*/
|
|
/*}*/
|
|
/*.card-compare::after,*/
|
|
/*.card-siswa-baru::after {*/
|
|
/* font-size: 0.7rem;*/
|
|
/* top: 10px;*/
|
|
/* left: 10px;*/
|
|
/*}*/
|
|
}
|
|
</style>
|
|
@endpush
|
|
|
|
@section('main')
|
|
<div class="main-content">
|
|
<section class="section">
|
|
<div class="section-header">
|
|
<h1>Cek Duplikasi Siswa</h1>
|
|
<div class="section-header-breadcrumb">
|
|
<div class="breadcrumb-item"><a href="/admin/">Admin</a></div>
|
|
<div class="breadcrumb-item"><a href="/admin/siswa">Siswa</a></div>
|
|
<div class="breadcrumb-item active">Cek Duplikasi</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section-body">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-md-6 mb-3">
|
|
<h5 class="fw-bold"><i class="bi bi-person-badge me-2"></i>Data Siswa Baru</h5>
|
|
<div class="card shadow-sm border-0 card-siswa-baru" id="card-siswa-baru">
|
|
<span class="select-hint">Klik untuk memilih</span>
|
|
<div class="card-body">
|
|
<div class="mb-3" style="display: flex; align-items: center; gap: 10px">
|
|
<img src="{{ $baru->foto ? asset('storage/'.$baru->foto) : ($baru->jenis_kelamin=='P' ? asset('img/kid-woman.png') : asset('img/kid-man.png')) }}"
|
|
alt="Foto" class="rounded-circle" width="60" height="60" style="object-fit:cover;">
|
|
<div class="ms-3">
|
|
<h6 class="mb-0">{{ $baru->nama_anak }}</h6>
|
|
<small class="text-muted">{{ $baru->kelas ? 'Kelas '.$baru->kelas : '-' }}</small>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<label class="mb-1">Orangtua</label>
|
|
<h6>{{ $baru->nama_orangtua ?? '-' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">No HP Orangtua</label>
|
|
<h6>{{ $baru->no_hp_orangtua ? '+62' . $baru->no_hp_orangtua : '-' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">Asal Sekolah</label>
|
|
<h6>{{ $baru->asal_sekolah ?? optional($baru->sekolah)->nama_sekolah ?? '-' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">Tempat / Tanggal Lahir</label>
|
|
<h6>{{ $baru->tempat_lahir ?? '-' }} / {{ $baru->tanggal_lahir ?? '-' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">Jenis Kelamin</label>
|
|
<h6>{{ $baru->jenis_kelamin ?? '-' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">Email</label>
|
|
<h6>{{ $baru->email ?? '-' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">Program</label>
|
|
<h6>Program ({{ optional($baru->Programs)->level ? 'Level '.optional($baru->Programs)->level.' ('.optional($baru->Programs)->kelas.')' : '-' }})</h6>
|
|
</div>
|
|
<div class="col-12 mt-2">
|
|
<hr>
|
|
<a type="button" class="btn-link toggle-history">Tampilkan histori</a>
|
|
<div class="history-section d-none mt-2">
|
|
<h6 class="mb-1">Histori Kelas</h6>
|
|
<ul class="list-unstyled mb-0">
|
|
@forelse($baru->kelasHistory as $k)
|
|
<li>{{ $k['nama_kelas'] }} ({{ $k['tanggal_bergabung'] }}) - {{ $k['status'] }}</li>
|
|
@empty
|
|
<li>-</li>
|
|
@endforelse
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="merge-fields" class="merge-options d-none card ">
|
|
<div class="card-body">
|
|
<h6>Pilih data yang ingin disalin ke siswa lama</h6>
|
|
<div class="row">
|
|
<div class="col-12 d-flex align-items-center mb-2">
|
|
<div class="checkbox-wrapper-46 d-flex justify-content-center">
|
|
<input class="inp-cbx d-none select-logbook-item" type="checkbox" name="merge_fields[]" value="nama_orangtua" id="merge_nama_orangtua" form="form-compare"/>
|
|
<label class="cbx" for="merge_nama_orangtua">
|
|
<span>
|
|
<svg width="12px" height="10px" viewBox="0 0 12 10">
|
|
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<label style="cursor: pointer" class="form-check-label ml-2" for="merge_nama_orangtua">Nama Orangtua ({{ $baru->nama_orangtua ?? '-' }})</label>
|
|
</div>
|
|
<div class="col-12 d-flex align-items-center mb-2">
|
|
<div class="checkbox-wrapper-46 d-flex justify-content-center">
|
|
<input class="inp-cbx d-none select-logbook-item" type="checkbox" name="merge_fields[]" value="no_hp_orangtua" id="merge_no_hp_orangtua" form="form-compare"/>
|
|
<label class="cbx" for="merge_nama_orangtua">
|
|
<span>
|
|
<svg width="12px" height="10px" viewBox="0 0 12 10">
|
|
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<label style="cursor: pointer" class="form-check-label ml-2" for="merge_no_hp_orangtua">No HP Orangtua ({{ $baru->no_hp_orangtua ? '+62' . $baru->no_hp_orangtua : '-' }})</label>
|
|
</div>
|
|
<div class="col-12 d-flex align-items-center mb-2">
|
|
<div class="checkbox-wrapper-46">
|
|
<input class="inp-cbx d-none" type="checkbox"
|
|
name="merge_fields[]"
|
|
value="asal_sekolah"
|
|
id="merge_asal_sekolah" form="form-compare"/>
|
|
<label class="cbx" for="merge_asal_sekolah">
|
|
<span>
|
|
<svg width="12px" height="10px" viewBox="0 0 12 10">
|
|
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<label class="ml-2 mb-0" style="cursor:pointer" for="merge_asal_sekolah">
|
|
Asal Sekolah ({{ $baru->asal_sekolah ?? optional($baru->sekolah)->nama_sekolah }})
|
|
</label>
|
|
</div>
|
|
<div class="col-12 d-flex align-items-center mb-2">
|
|
<div class="checkbox-wrapper-46">
|
|
<input class="inp-cbx d-none" type="checkbox"
|
|
name="merge_fields[]"
|
|
value="kelas"
|
|
id="merge_kelas" form="form-compare"/>
|
|
<label class="cbx" for="merge_kelas">
|
|
<span>
|
|
<svg width="12px" height="10px" viewBox="0 0 12 10">
|
|
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<label class="ml-2 mb-0" style="cursor:pointer" for="merge_kelas">
|
|
Kelas ({{ $baru->kelas ?? '-' }})
|
|
</label>
|
|
</div>
|
|
<div class="col-12 d-flex align-items-center mb-2">
|
|
<div class="checkbox-wrapper-46">
|
|
<input class="inp-cbx d-none" type="checkbox"
|
|
name="merge_fields[]"
|
|
value="tempat_lahir"
|
|
id="merge_tempat_lahir" form="form-compare"/>
|
|
<label class="cbx" for="merge_tempat_lahir">
|
|
<span>
|
|
<svg width="12px" height="10px" viewBox="0 0 12 10">
|
|
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<label class="ml-2 mb-0" style="cursor:pointer" for="merge_tempat_lahir">
|
|
Tempat Lahir ({{ $baru->tempat_lahir ?? '-' }})
|
|
</label>
|
|
</div>
|
|
<div class="col-12 d-flex align-items-center mb-2">
|
|
<div class="checkbox-wrapper-46">
|
|
<input class="inp-cbx d-none" type="checkbox"
|
|
name="merge_fields[]"
|
|
value="tanggal_lahir"
|
|
id="merge_tanggal_lahir" form="form-compare"/>
|
|
<label class="cbx" for="merge_tanggal_lahir">
|
|
<span>
|
|
<svg width="12px" height="10px" viewBox="0 0 12 10">
|
|
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<label class="ml-2 mb-0" style="cursor:pointer" for="merge_tanggal_lahir">
|
|
Tanggal Lahir ({{ $baru->tanggal_lahir ?? '-' }})
|
|
</label>
|
|
</div>
|
|
<div class="col-12 d-flex align-items-center mb-2">
|
|
<div class="checkbox-wrapper-46">
|
|
<input class="inp-cbx d-none" type="checkbox"
|
|
name="merge_fields[]"
|
|
value="jenis_kelamin"
|
|
id="merge_jenis_kelamin" form="form-compare"/>
|
|
<label class="cbx" for="merge_jenis_kelamin">
|
|
<span>
|
|
<svg width="12px" height="10px" viewBox="0 0 12 10">
|
|
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<label class="ml-2 mb-0" style="cursor:pointer" for="merge_jenis_kelamin">
|
|
Jenis Kelamin ({{ $baru->jenis_kelamin ?? '-' }})
|
|
</label>
|
|
</div>
|
|
<div class="col-12 d-flex align-items-center mb-2">
|
|
<div class="checkbox-wrapper-46">
|
|
<input class="inp-cbx d-none" type="checkbox"
|
|
name="merge_fields[]"
|
|
value="email"
|
|
id="merge_email" form="form-compare"/>
|
|
<label class="cbx" for="merge_email">
|
|
<span>
|
|
<svg width="12px" height="10px" viewBox="0 0 12 10">
|
|
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<label class="ml-2 mb-0" style="cursor:pointer" for="merge_email">
|
|
Email ({{ $baru->email ?? '-' }})
|
|
</label>
|
|
</div>
|
|
{{-- <div class="col-12 col-md-6 d-flex align-items-center mb-2">--}}
|
|
{{-- <div class="checkbox-wrapper-46">--}}
|
|
{{-- <input class="inp-cbx d-none" type="checkbox"--}}
|
|
{{-- name="merge_fields[]"--}}
|
|
{{-- value="status"--}}
|
|
{{-- id="merge_status" />--}}
|
|
{{-- <label class="cbx" for="merge_status">--}}
|
|
{{-- <span>--}}
|
|
{{-- <svg width="12px" height="10px" viewBox="0 0 12 10">--}}
|
|
{{-- <polyline points="1.5 6 4.5 9 10.5 1"></polyline>--}}
|
|
{{-- </svg>--}}
|
|
{{-- </span>--}}
|
|
{{-- </label>--}}
|
|
{{-- </div>--}}
|
|
{{-- <label class="ml-2 mb-0" style="cursor:pointer" for="merge_status">--}}
|
|
{{-- Status ({{ $baru->status }})--}}
|
|
{{-- </label>--}}
|
|
{{-- </div>--}}
|
|
<div class="col-12 d-flex align-items-center mb-2">
|
|
<div class="checkbox-wrapper-46">
|
|
<input class="inp-cbx d-none" type="checkbox"
|
|
name="merge_fields[]"
|
|
value="program_id"
|
|
id="merge_program_id" form="form-compare"/>
|
|
<label class="cbx" for="merge_program_id">
|
|
<span>
|
|
<svg width="12px" height="10px" viewBox="0 0 12 10">
|
|
<polyline points="1.5 6 4.5 9 10.5 1"></polyline>
|
|
</svg>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
<label class="ml-2 mb-0" style="cursor:pointer" for="merge_program_id">
|
|
Program ({{ optional($baru->Programs)->level ? 'Level '.optional($baru->Programs)->level.' ('.optional($baru->Programs)->kelas.')' : '-' }})
|
|
</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="selection-note" class="" role="status">
|
|
Pilih tindakan: <strong>Simpan sebagai siswa baru</strong> atau <strong>Gabungkan</strong> ke data siswa lama.
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-6">
|
|
<h5 class="fw-bold"><i class="bi bi-check-circle me-2"></i>Data Kemungkinan Sama</h5>
|
|
@if($mirip->count() > 0)
|
|
@foreach($mirip as $s)
|
|
<div class="card mb-2 card-compare" data-id="{{ $s->id }}">
|
|
<span class="select-hint">Klik untuk memilih</span>
|
|
<div class="card-body">
|
|
<div class="mb-3" style="display: flex; align-items: center; gap: 10px">
|
|
<img src="{{ $s->foto ? asset('storage/'.$s->foto) : ($s->jenis_kelamin=='P' ? asset('img/kid-woman.png') : asset('img/kid-man.png')) }}"
|
|
alt="Foto" class="rounded-circle" width="55" height="55" style="object-fit:cover;">
|
|
<div class="ms-3">
|
|
<h6 class="mb-0">{{ $s->nama_anak }}</h6>
|
|
<small class="text-muted">{{ $s->kelas ? 'Kelas '.$s->kelas : '-' }}</small>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<label class="mb-1">Orangtua</label>
|
|
<h6>{{ $s->nama_orangtua ?? 'undifined' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">No HP Orangtua</label>
|
|
<h6>{{ $s->no_hp_orangtua ? '+62' . $s->no_hp_orangtua : '-' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">Asal Sekolah</label>
|
|
<h6>{{ $s->asal_sekolah ?? optional($s->sekolah)->nama_sekolah }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">Tempat / Tanggal Lahir</label>
|
|
<h6>{{ $s->tempat_lahir ?? '-' }} / {{ $s->tanggal_lahir ?? '-' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">Jenis Kelamin</label>
|
|
<h6>{{ $s->jenis_kelamin ?? '-' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">Email</label>
|
|
<h6>{{ $s->email ?? '-' }}</h6>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="mb-1">Program</label>
|
|
<h6>Program ({{ optional($s->Programs)->level ? 'Level '.optional($s->Programs)->level.' ('.optional($s->Programs)->kelas.')' : '-' }})</h6>
|
|
</div>
|
|
<div class="col-12 mt-2">
|
|
<hr>
|
|
<a type="button" class=" p-0 btn-link toggle-history">Tampilkan histori Siswa</a>
|
|
<div class="history-section d-none mt-2">
|
|
<h6 class="mb-1">Histori Kelas</h6>
|
|
<ul class="list-unstyled mb-0">
|
|
@forelse($s->kelasHistory as $k)
|
|
<li>{{ $k['nama_kelas'] }} ({{ $k['tanggal_bergabung'] }}) - {{ $k['status'] }}</li>
|
|
@empty
|
|
<li>-</li>
|
|
@endforelse
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
@else
|
|
<p class="text-muted">Tidak ditemukan data lain yang mirip.</p>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-footer">
|
|
<form id="form-compare" method="POST" action="{{ url('/admin/siswa/approve') }}">
|
|
@csrf
|
|
<input type="hidden" name="siswa_baru_id" value="{{ $baru->id }}">
|
|
<input type="hidden" name="duplicate_id" id="duplicate_id" value="">
|
|
|
|
<div class="d-flex justify-content-between mt-4">
|
|
<button type="button" class="btn btn-secondary" id="btn-back">Kembali</button>
|
|
<div id="button-container">
|
|
<button type="button" class="btn btn-outline-primary d-none" id="btn-new">Simpan sebagai siswa baru</button>
|
|
<button type="submit" class="btn btn-primary d-none" id="submitBtn">Gabungkan</button>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
@endsection
|
|
|
|
@push('scripts')
|
|
<script>
|
|
$(document).ready(function() {
|
|
const siswaBaruId = $('input[name="siswa_baru_id"]').val();
|
|
|
|
// click pada card data siswa baru (left side)
|
|
$('#card-siswa-baru').on('click', function(e) {
|
|
if ($(e.target).closest('.form-check, label').length) return; // skip jika klik checkbox
|
|
|
|
selectSiswaBaru();
|
|
});
|
|
|
|
// click pada card data mirip (right side)
|
|
$('.card-compare').on('click', function(e) {
|
|
if ($(e.target).closest('.form-check, label').length) return; // skip jika klik checkbox
|
|
|
|
$('.card-compare').removeClass('active');
|
|
$(this).addClass('active');
|
|
const id = $(this).data('id');
|
|
const name = $(this).find('h6').first().text().trim();
|
|
$('#duplicate_id').val(id);
|
|
selectedMirip(id, name);
|
|
});
|
|
|
|
// helper: set selection note text/html
|
|
function setSelectionNote(html) {
|
|
if (!html) {
|
|
$('#selection-note').addClass('d-none');
|
|
} else {
|
|
$('#selection-note').removeClass('d-none').html(html);
|
|
}
|
|
}
|
|
|
|
// select siswa baru (show button simpan sebagai siswa baru)
|
|
function selectSiswaBaru() {
|
|
$('#card-siswa-baru').addClass('active');
|
|
$('.card-compare').removeClass('active');
|
|
$('#duplicate_id').val('');
|
|
$('#merge-fields').addClass('d-none');
|
|
$('#btn-new').removeClass('d-none');
|
|
$('#submitBtn').addClass('d-none');
|
|
|
|
const name = $('#card-siswa-baru').find('h6').first().text().trim();
|
|
setSelectionNote('<strong>Menyimpan sebagai siswa baru</strong>: data baru untuk <em>' + name + '</em> akan disimpan sebagai entri terpisah. Data kelas tidak akan dipindahkan ke siswa lain.');
|
|
}
|
|
|
|
// select dari data mirip (show button gabungkan dan merge fields)
|
|
function selectedMirip(id, name) {
|
|
$('#card-siswa-baru').removeClass('active');
|
|
$('#duplicate_id').val(id);
|
|
$('#merge-fields').removeClass('d-none');
|
|
$('#btn-new').addClass('d-none');
|
|
$('#submitBtn').removeClass('d-none');
|
|
|
|
setSelectionNote('<strong>Gabungkan ke:</strong> <em>' + (name || 'siswa terpilih') + '</em>. Data kelas dari entri baru akan dipindahkan ke siswa ini. Centang field di bawah untuk menyalin data tertentu dari entri baru ke siswa lama sebelum penggabungan.');
|
|
}
|
|
|
|
function submitComparison() {
|
|
const duplicateId = $('#duplicate_id').val();
|
|
|
|
// jika dipilih siswa baru
|
|
if (!duplicateId || duplicateId === siswaBaruId) {
|
|
submitNewStudent();
|
|
} else {
|
|
submitMerge();
|
|
}
|
|
}
|
|
|
|
function submitNewStudent() {
|
|
const btn = $('#btn-new');
|
|
btn.prop('disabled', true);
|
|
btn.html('<i class="bx bx-loader bx-spin"></i> Menyimpan...');
|
|
|
|
$('#duplicate_id').val(siswaBaruId);
|
|
$('#merge-fields input[type="checkbox"]').prop('checked', false);
|
|
|
|
$.ajax({
|
|
url: $('#form-compare').attr('action'),
|
|
method: 'POST',
|
|
data: $('#form-compare').serialize(),
|
|
success: function(res) {
|
|
iziToastCustom('success', res.message || 'Siswa berhasil disimpan sebagai data baru');
|
|
setTimeout(() => {
|
|
window.location.href = '/admin/siswa/approved-list';
|
|
}, 1000);
|
|
},
|
|
error: function(xhr) {
|
|
iziToastCustom('fail', 'Terjadi kesalahan saat menyimpan');
|
|
btn.prop('disabled', false);
|
|
btn.html('Simpan sebagai siswa baru');
|
|
}
|
|
});
|
|
}
|
|
|
|
function submitMerge() {
|
|
const btn = $('#submitBtn');
|
|
btn.prop('disabled', true);
|
|
btn.html('<i class="bx bx-loader bx-spin"></i> Menyimpan...');
|
|
|
|
$.ajax({
|
|
url: $('#form-compare').attr('action'),
|
|
method: 'POST',
|
|
data: $('#form-compare').serialize(),
|
|
success: function(res) {
|
|
iziToastCustom('success', res.message || 'Data siswa berhasil digabungkan');
|
|
setTimeout(() => {
|
|
window.location.href = '/admin/siswa/approved-list';
|
|
}, 1000);
|
|
},
|
|
error: function(xhr) {
|
|
iziToastCustom('fail', 'Terjadi kesalahan saat menyimpan');
|
|
btn.prop('disabled', false);
|
|
btn.html('Gabungkan');
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#btn-new').on('click', function() {
|
|
submitComparison();
|
|
});
|
|
|
|
$('#form-compare').on('submit', function(e) {
|
|
e.preventDefault();
|
|
submitComparison();
|
|
});
|
|
|
|
$('#btn-back').on('click', function() {
|
|
window.history.back();
|
|
});
|
|
|
|
// toggle history sections inside cards
|
|
$(document).on('click', '.toggle-history', function(e) {
|
|
// prevent card click from firing
|
|
e.stopPropagation();
|
|
const $btn = $(this);
|
|
const $section = $btn.next('.history-section');
|
|
$section.toggleClass('d-none');
|
|
$btn.text($section.hasClass('d-none') ? 'Tampilkan histori' : 'Sembunyikan histori');
|
|
});
|
|
|
|
// default select siswa baru
|
|
selectSiswaBaru();
|
|
});
|
|
</script>
|
|
@endpush
|