500 lines
26 KiB
PHP
500 lines
26 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
<link rel="apple-touch-icon" sizes="76x76" href="../img/apple-icon.png">
|
|
<link rel="icon" type="image/png" href="../img/favicon.png">
|
|
<title>
|
|
Sistem Pendukung Keputusan Penerima Bantuan
|
|
</title>
|
|
<!-- Fonts and icons -->
|
|
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet" />
|
|
<!-- Nucleo Icons -->
|
|
<link href="../css/nucleo-icons.css" rel="stylesheet" />
|
|
<link href="../css/nucleo-svg.css" rel="stylesheet" />
|
|
<!-- Font Awesome Icons -->
|
|
<script src="https://kit.fontawesome.com/42d5adcbca.js" crossorigin="anonymous"></script>
|
|
<link href="../css/nucleo-svg.css" rel="stylesheet" />
|
|
<!-- CSS Files -->
|
|
<link id="pagestyle" href="../css/argon-dashboard.css?v=2.0.4" rel="stylesheet" />
|
|
<!-- Timer Notifikasi-->
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
|
|
</head>
|
|
|
|
<body class="g-sidenav-show bg-gray-100">
|
|
<div class="min-height-300 bg-primary position-absolute w-100"></div>
|
|
<aside class="sidenav bg-white navbar navbar-vertical navbar-expand-xs border-0 border-radius-xl my-3 fixed-start ms-4 " id="sidenav-main">
|
|
<div class="sidenav-header">
|
|
<i class="fas fa-times p-3 cursor-pointer text-secondary opacity-5 position-absolute end-0 top-0 d-none d-xl-none" aria-hidden="true" id="iconSidenav"></i>
|
|
<a class="navbar-brand m-0" href=" /dashboard " target="_blank">
|
|
<img src="../img/logo-ct-dark.png" class="navbar-brand-img h-100" alt="main_logo">
|
|
<span class="ms-1 font-weight-bold">Dashboard</span>
|
|
</a>
|
|
</div>
|
|
<hr class="horizontal dark mt-0">
|
|
<ul class="navbar-nav">
|
|
<li class="nav-item">
|
|
<a class="nav-link " href="./dashboard">
|
|
<div class="icon icon-shape icon-sm border-radius-md text-center me-2 d-flex align-items-center justify-content-center">
|
|
<i class="ni ni-tv-2 text-primary text-sm opacity-10"></i>
|
|
</div>
|
|
<span class="nav-link-text ms-1">Dashboard</span>
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link " href="/daftarnama">
|
|
<div class="icon icon-shape icon-sm border-radius-md text-center me-2 d-flex align-items-center justify-content-center">
|
|
<i class="ni ni-calendar-grid-58 text-warning text-sm opacity-10"></i>
|
|
</div>
|
|
<span class="nav-link-text ms-1">Data Penduduk</span>
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link " href="/datakriteria">
|
|
<div class="icon icon-shape icon-sm border-radius-md text-center me-2 d-flex align-items-center justify-content-center">
|
|
<i class="ni ni-building text-primary text-sm opacity-10"></i>
|
|
</div>
|
|
<span class="nav-link-text ms-1">Data Kriteria</span>
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link " href="/datasubkriteria">
|
|
<div class="icon icon-shape icon-sm border-radius-md text-center me-2 d-flex align-items-center justify-content-center">
|
|
<i class="ni ni-credit-card text-success text-sm opacity-10"></i>
|
|
</div>
|
|
<span class="nav-link-text ms-1">Data Sub Kriteria</span>
|
|
</a>
|
|
</li>
|
|
|
|
<li class="nav-item">
|
|
<a class="nav-link active " href="/dataalternatif">
|
|
<div class="icon icon-shape icon-sm border-radius-md text-center me-2 d-flex align-items-center justify-content-center">
|
|
<i class="ni ni-bullet-list-67 text-warning text-sm opacity-10"></i>
|
|
</div>
|
|
<span class="nav-link-text ms-1">Data Alterinatif</span>
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link" href="/rangking">
|
|
<div class="icon icon-shape icon-sm border-radius-md text-center me-2 d-flex align-items-center justify-content-center">
|
|
<i class="ni ni-sound-wave text-success text-sm opacity-10"></i>
|
|
</div>
|
|
<span class="nav-link-text ms-1">Perangkingan</span>
|
|
</a>
|
|
</li>
|
|
|
|
|
|
<script>
|
|
function toggleSubMenu(event) {
|
|
event.preventDefault();
|
|
var submenu = document.getElementById("perhitunganSubMenu");
|
|
submenu.classList.toggle("show");
|
|
}
|
|
</script>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</aside>
|
|
<main class="main-content position-relative border-radius-lg ">
|
|
<!-- Navbar -->
|
|
<nav class="navbar navbar-main navbar-expand-lg px-0 mx-4 shadow-none border-radius-xl " id="navbarBlur" data-scroll="false">
|
|
<div class="container-fluid py-1 px-3">
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb bg-transparent mb-0 pb-0 pt-1 px-0 me-sm-6 me-5">
|
|
</ol>
|
|
<h6 class="font-weight-bolder text-white mb-0">Data Alternatif</h6>
|
|
</nav>
|
|
<div class="collapse navbar-collapse mt-sm-0 mt-2 me-md-0 me-sm-4" id="navbar">
|
|
<div class="ms-md-auto pe-md-3 d-flex align-items-center">
|
|
|
|
<ul class="navbar-nav justify-content-end">
|
|
<li class="nav-item d-flex align-items-center">
|
|
<div class="dropdown">
|
|
<a class="nav-link text-white font-weight-bold px-0 dropdown-toggle" href="#" role="button" id="userDropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
|
<i class="fa fa-user me-sm-1"></i>
|
|
<span class="d-sm-inline d-none">{{ Auth::user()->username }}</span>
|
|
</a>
|
|
|
|
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="userDropdown">
|
|
|
|
<li>
|
|
<a class="dropdown-item" href="#" data-bs-toggle="modal" data-bs-target="#logoutModal">
|
|
<i class="fa fa-sign-out me-2"></i> Logout
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Modal -->
|
|
<div class="modal fade" id="logoutModal" tabindex="-1" aria-labelledby="logoutModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="logoutModalLabel">Konfirmasi Logout</h5>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
Apakah Anda yakin ingin logout?
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Batal</button>
|
|
<form id="logout-form" action='logout' method="POST" class="d-inline">
|
|
@csrf
|
|
<button type="submit" class="btn btn-primary">Logout</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
<!-- End Navbar -->
|
|
<div class="container-fluid py-4">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card mb-4">
|
|
<div class="card-header pb-0">
|
|
<div class="d-flex justify-content-between align-items-center">
|
|
<h6></h6>
|
|
<div class="d-flex justify-content-end mb-3">
|
|
<a href="cetak3" class="btn btn-primary btn-sm" style="margin-right: 10px;">
|
|
<i class="fa fa-print"></i> Cetak
|
|
</a>
|
|
<a href="alternatifs" class="btn btn-primary btn-sm">
|
|
<i class="fa fa-plus mr-1"></i> Tambah
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-body px-4 pt-0 pb-2">
|
|
<div class="table-responsive p-0">
|
|
<table class="table table-bordered table-hover table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">No</th>
|
|
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Kode</th>
|
|
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Nama Penduduk</th>
|
|
@foreach ($datakriterias as $kriteria)
|
|
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">{{ $kriteria->nama_kriteria }}</th>
|
|
@endforeach
|
|
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="tabelkriteria">
|
|
@forelse ($alternatifs as $alternatif)
|
|
<tr>
|
|
<td class="text-center">{{ $loop->iteration }}</td>
|
|
<td class="text-center">{{ $alternatif->kode }}</td>
|
|
<td class="text-center">{{ $alternatif->nama }}</td>
|
|
@foreach (range(1, 10) as $i)
|
|
<td class="text-center">
|
|
@if (isset($alternatif["p$i"]))
|
|
@foreach ($datasubkriterias as $subkriteria)
|
|
@if ($alternatif["p$i"] == $subkriteria['id_subkriteria'])
|
|
{{ $subkriteria['nama_subkriteria'] }}
|
|
@break
|
|
@endif
|
|
@endforeach
|
|
@endif
|
|
</td>
|
|
@endforeach
|
|
<td class="text-center">
|
|
<a href="{{ route('alternatif.edit', ['id' => $alternatif->id]) }}">
|
|
<i class="fas fa-edit"></i>
|
|
</a>
|
|
<a href="{{ route('alternatif.hapus', ['id' => $alternatif->id]) }}"
|
|
onclick="confirmModal('{{ route('datakriteria.hapus', ['id' => $alternatif->id]) }}')">
|
|
<i class="fas fa-trash"></i>
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="{{ count($datakriterias) + 4 }}" class="text-center">Tidak ada data</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
|
|
|
|
</div>
|
|
<div class="d-flex justify-content-end mb-3">
|
|
|
|
<a href="#" class="btn btn-primary btn-sm kriteria-toggle">
|
|
<i class="fa fa-chevron-down mr-1 kriteria-icon"></i>
|
|
</a>
|
|
</div>
|
|
<div class="kriteria-table" style="display: none;">
|
|
<div class="col-12">
|
|
<div class="card mb-4">
|
|
<div class="card-header pb-0">
|
|
<h6>Matriks Alternatif Penduduk</h6>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="table-responsive p-0">
|
|
<form action="{{ route('simpanalternatif') }}" method="POST">
|
|
@csrf
|
|
<table class="table table-bordered table-hover table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Kode</th>
|
|
@foreach ($datakriterias as $datakriteria)
|
|
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">{{ $datakriteria->kode_kriteria }}</th>
|
|
@endforeach
|
|
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Jumlah</th>
|
|
<th class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">Keterangan</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="tabelkriteria2">
|
|
@php
|
|
$totalSemua = 0;
|
|
$jumlahData = count($alternatifs); // Menghitung banyaknya data (jumlah baris alternatif)
|
|
@endphp
|
|
<!-- Langkah 1: Hitung total semua alternatif -->
|
|
@foreach ($alternatifs as $alternatif)
|
|
@php
|
|
$total = 0;
|
|
@endphp
|
|
|
|
@foreach (range(1, 10) as $i)
|
|
@if (isset($alternatif["p$i"]))
|
|
@php
|
|
$found = false;
|
|
@endphp
|
|
@foreach ($datasubkriterias as $subkriteria)
|
|
@if ($alternatif["p$i"] == $subkriteria['id_subkriteria'])
|
|
@foreach ($prioritassubkriterias as $prioritas)
|
|
@if ($subkriteria['kode_subkriteria'] == $prioritas['kode_subkriteria'])
|
|
@php
|
|
$nilai_prioritas = $prioritas['nilai_prioritas'];
|
|
// Temukan nilai_kprioritas yang sesuai dari tabel prioritaskriterias
|
|
$nilai_kprioritas = 1; // Nilai default jika tidak ditemukan
|
|
foreach ($prioritaskriterias as $kprioritas) {
|
|
if ($datakriterias[$i - 1]->kode_kriteria == $kprioritas['kode_kriteria']) {
|
|
$nilai_kprioritas = $kprioritas['nilai_kprioritas'];
|
|
break;
|
|
}
|
|
}
|
|
$total += $nilai_prioritas * $nilai_kprioritas;
|
|
$found = true;
|
|
@endphp
|
|
@break
|
|
@endif
|
|
@endforeach
|
|
@break
|
|
@endif
|
|
@endforeach
|
|
@endif
|
|
@endforeach
|
|
|
|
@php
|
|
$totalSemua += $total; // Akumulasi total semua baris
|
|
@endphp
|
|
@endforeach
|
|
|
|
<!-- Langkah 2: Hitung rata-rata berdasarkan total yang telah dihitung -->
|
|
@php
|
|
$rataRata = $jumlahData > 0 ? $totalSemua / $jumlahData : 0; // Hitung rata-rata
|
|
@endphp
|
|
|
|
<!-- Langkah 3: Tentukan status "Layak" atau "Tidak Layak" dan tampilkan data -->
|
|
@foreach ($alternatifs as $alternatif)
|
|
@php
|
|
$total = 0;
|
|
@endphp
|
|
|
|
<tr>
|
|
<td class="text-center text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">
|
|
{{ $alternatif->kode }}
|
|
<input type="hidden" name="alternatif[{{ $alternatif->kode }}][kode]" value="{{ $alternatif->kode }}">
|
|
</td>
|
|
|
|
@foreach (range(1, 10) as $i)
|
|
<td class="text-center">
|
|
@if (isset($alternatif["p$i"]))
|
|
@php
|
|
$found = false;
|
|
@endphp
|
|
@foreach ($datasubkriterias as $subkriteria)
|
|
@if ($alternatif["p$i"] == $subkriteria['id_subkriteria'])
|
|
@foreach ($prioritassubkriterias as $prioritas)
|
|
@if ($subkriteria['kode_subkriteria'] == $prioritas['kode_subkriteria'])
|
|
@php
|
|
$nilai_prioritas = $prioritas['nilai_prioritas'];
|
|
// Temukan nilai_kprioritas yang sesuai dari tabel prioritaskriterias
|
|
$nilai_kprioritas = 1; // Nilai default jika tidak ditemukan
|
|
foreach ($prioritaskriterias as $kprioritas) {
|
|
if ($datakriterias[$i - 1]->kode_kriteria == $kprioritas['kode_kriteria']) {
|
|
$nilai_kprioritas = $kprioritas['nilai_kprioritas'];
|
|
break;
|
|
}
|
|
}
|
|
$total += $nilai_prioritas * $nilai_kprioritas;
|
|
$found = true;
|
|
@endphp
|
|
{{ $nilai_prioritas * $nilai_kprioritas }}
|
|
<input type="hidden" name="alternatif[{{ $alternatif->kode }}][p{{ $i }}]" value="{{ $alternatif["p$i"] }}">
|
|
@break
|
|
@endif
|
|
@endforeach
|
|
@break
|
|
@endif
|
|
@endforeach
|
|
@if (!$found)
|
|
{{ '' }}
|
|
@endif
|
|
@endif
|
|
</td>
|
|
@endforeach
|
|
|
|
<td class="text-center">
|
|
{{ $total }}
|
|
<input type="hidden" name="alternatif[{{ $alternatif->kode }}][total]" value="{{ $total }}">
|
|
</td>
|
|
|
|
<!-- Kolom Status -->
|
|
<td class="text-center">
|
|
@php
|
|
$status = $total >= $rataRata ? 'Layak' : 'Tidak Layak';
|
|
@endphp
|
|
{{ $status }}
|
|
<input type="hidden" name="alternatif[{{ $alternatif->kode }}][status]" value="{{ $status }}">
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
<div class="d-flex">
|
|
<button type="submit" class="btn btn-primary">Simpan Matriks</button>
|
|
</div>
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const kriteriaToggle = document.querySelector('.kriteria-toggle');
|
|
const kriteriaTable = document.querySelector('.kriteria-table');
|
|
const kriteriaIcon = document.querySelector('.kriteria-icon');
|
|
|
|
kriteriaToggle.addEventListener('click', () => {
|
|
kriteriaTable.style.display = kriteriaTable.style.display === 'none' ? 'block' : 'none';
|
|
kriteriaIcon.classList.toggle('fa-chevron-down');
|
|
kriteriaIcon.classList.toggle('fa-chevron-up');
|
|
});
|
|
|
|
</script>
|
|
|
|
<script>
|
|
function toggleDropdown(element) {
|
|
// Close all open dropdowns
|
|
document.querySelectorAll('.dropdown-menu').forEach(function(dropdown) {
|
|
dropdown.style.display = 'none';
|
|
});
|
|
|
|
// Toggle the dropdown menu next to the clicked element
|
|
var dropdownMenu = element.nextElementSibling || element.closest('td').querySelector('.dropdown-menu');
|
|
dropdownMenu.style.display = dropdownMenu.style.display === 'block' ? 'none' : 'block';
|
|
}
|
|
|
|
// Close dropdowns if clicked outside
|
|
document.addEventListener('click', function(event) {
|
|
var isClickInside = event.target.closest('.fa-plus, .dropdown-menu, .selected-subkriteria');
|
|
if (!isClickInside) {
|
|
document.querySelectorAll('.dropdown-menu').forEach(function(dropdown) {
|
|
dropdown.style.display = 'none';
|
|
});
|
|
}
|
|
});
|
|
|
|
// Function to handle subkriteria selection
|
|
function selectSubkriteria(event, element) {
|
|
event.preventDefault(); // Prevent the default link behavior
|
|
|
|
var selectedText = element.textContent;
|
|
var dropdownMenu = element.closest('.dropdown-menu');
|
|
var cell = dropdownMenu.closest('td');
|
|
var displaySpan = cell.querySelector('.selected-subkriteria');
|
|
var plusIcon = cell.querySelector('.fa-plus');
|
|
|
|
// Display the selected subkriteria in the span
|
|
displaySpan.textContent = selectedText;
|
|
|
|
// Hide the dropdown menu after selection
|
|
dropdownMenu.style.display = 'none';
|
|
|
|
// Hide the plus icon
|
|
plusIcon.style.display = 'none';
|
|
|
|
// Make the selected-subkriteria span visible and clickable
|
|
displaySpan.style.display = 'inline';
|
|
displaySpan.onclick = function() {
|
|
toggleDropdown(displaySpan);
|
|
};
|
|
}
|
|
|
|
</script>
|
|
<div class="card-body">
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
@if(session('success'))
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Berhasil!',
|
|
text: '{{ session('success') }}',
|
|
timer: 2000, // waktu dalam milidetik (2 detik)
|
|
showConfirmButton: false
|
|
});
|
|
@elseif(session('error'))
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Error!',
|
|
text: '{{ session('error') }}',
|
|
timer: 2000, // waktu dalam milidetik (2 detik)
|
|
showConfirmButton: false
|
|
});
|
|
@endif
|
|
});
|
|
</script>
|
|
|
|
<!-- Core JS Files -->
|
|
<script src="../js/core/popper.min.js"></script>
|
|
<script src="../js/core/bootstrap.min.js"></script>
|
|
<script src="../js/plugins/perfect-scrollbar.min.js"></script>
|
|
<script src="../js/plugins/smooth-scrollbar.min.js"></script>
|
|
<script>
|
|
var win = navigator.platform.indexOf('Win') > -1;
|
|
if (win && document.querySelector('#sidenav-scrollbar')) {
|
|
var options = {
|
|
damping: '0.5'
|
|
}
|
|
Scrollbar.init(document.querySelector('#sidenav-scrollbar'), options);
|
|
}
|
|
</script>
|
|
<!-- Github buttons -->
|
|
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
|
<!-- Control Center for Soft Dashboard: parallax effects, scripts for the example pages etc -->
|
|
<script src="../js/argon-dashboard.min.js?v=2.0.4"></script>
|
|
</body>
|
|
|
|
</html> |