MIF_E31210400/resources/views/admin/app/content/ranking/index.blade.php

129 lines
6.8 KiB
PHP

@include('components.theme.pages.header')
<section>
<div class="row mb-4">
<div class="col-md-12">
<div class="card shadow">
<div class="card-header d-flex align-items-center">
<h6 class="m-0 text-primary">Data Ranking</h6>
<a href="{{ app_url('dashboard') }}" class="ml-auto btn btn-sm btn-primary">Kembali</a>
</div>
<div class="card-body">
@if (\App\Models\BobotKriteria::count() == 0)
<div class="alert alert-danger" role="alert">
<h4 class="alert-heading">Peringatan!</h4>
<p>Data bobot kriteria masih kosong. Silahkan perbandingan kriteria terlebih dahulu atau tekan tombol "Perbandingan Kriteria" dibawah ini!</p>
<hr>
<div class="clearfix">
<a href="{{ app_url('analisa-kriteria') }}" class="btn btn-primary float-right">Perbandingan Kriteria</a>
</div>
</div>
@elseif(\App\Models\BobotAlternatif::count() == 0)
<div class="alert alert-danger " role="alert">
<h4 class="alert-heading">Peringatan!</h4>
<p>Data bobot alternatif masih kosong. Silahkan perbandingan alternatif terlebih dahulu atau tekan tombol "Perbandingan Alternatif" dibawah ini!</p>
<hr>
<div class="clearfix">
<a href="{{ app_url('analisa-alternatif-form') }}" class="btn btn-primary float-right">Perbandingan Alternatif</a>
</div>
</div>
@else
<?php
$nilai = array();
$jumlah_alternatif = \App\Models\Alternatif::count();
$jumlah_kriteria = \App\Models\Kriteria::count();
// Mendapatkan Nilai Alternatif
for ($x = 0; $x <= ($jumlah_alternatif - 1); $x++) {
// Inisialisasi
$nilai[$x] = 0;
for ($y = 0; $y <= ($jumlah_kriteria - 1); $y++) {
$id_alternatif = getAlternatifId($x);
$id_kriteria = getKriteriaId($y);
$pv_alternatif = optional(\App\Models\BobotAlternatif::where('id_alternatif', $id_alternatif)->where('id_kriteria', $id_kriteria)->first())->nilai;
$pv_kriteria = optional(\App\Models\BobotKriteria::where('id_kriteria', $id_kriteria)->first())->nilai;
$nilai[$x] += ($pv_alternatif * $pv_kriteria);
}
}
// Update Nilai Ranking
for ($i = 0; $i <= ($jumlah_alternatif - 1); $i++) {
$id_alternatif = getAlternatifId($i);
insertRanking($id_alternatif, $nilai[$i]);
}
?>
<h4 class="mb-3">Matriks Perbandingan Berpasangan</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th class="text-center">Overakll Composite Height</th>
<th class="text-center">Priority Vector (rata-rata)</th>
<?php
for ($i = 0; $i <= ($jumlah_alternatif - 1); $i++) {
echo "<th class='text-center'>" . getAlternatifNama($i) . "</th>";
}
?>
</tr>
</thead>
<tbody>
<?php
for ($x = 0; $x <= ($jumlah_kriteria - 1); $x++) {
echo "<tr>";
echo "<td class='font-weight-bold'>" . getKriteriaNama($x) . "</td>";
echo "<td class='text-center font-weight-bold'>" . round(getKriteriaPV(getKriteriaId($x)), 5) . "</td>";
for ($y = 0; $y <= ($jumlah_alternatif - 1); $y++) {
$hasil = getAlternatifPV(getAlternatifId($y), getKriteriaId($x)) * getKriteriaPV(getKriteriaId($x));
echo "<td class='text-center'>" . round($hasil, 5) . "</td>";
}
echo "</tr>";
}
?>
</tbody>
<tfoot class="thead-light">
<tr>
<th colspan="2" class="text-center">Total</th>
<?php
for ($i = 0; $i <= ($jumlah_alternatif - 1); $i++) {
echo "<th class='text-center'>" . round($nilai[$i], 5) . "</th>";
}
?>
</tr>
</tfoot>
</table>
</div>
<h4 class="mt-2 mb-3">Perangkingan</h4>
<div class="table-responsive">
<table class="table table-bordered">
<thead class="thead-light">
<tr>
<th class="text-center" width="10%">Peringkat</th>
<th class="text-center">Alternatif</th>
<th class="text-center" width="20%">Nilai</th>
</tr>
</thead>
<tbody>
<?php
$no = 1;
foreach(\App\Models\Ranking::orderBy('skor_bobot', 'desc')->get() as $rank) : ?>
<tr>
<td class="text-center">{{ $no++ }}</td>
<td>{{ $rank->account->nama_alternatif }}</td>
<td class="text-center font-weight-bold">{{ number_format($rank->skor_bobot,6) }}</td>
</tr>
<?php endforeach ?>
</tbody>
</table>
</div>
@endif
</div>
</div>
</div>
</div>
</section>
@include('components.theme.pages.footer')