perhitungan
This commit is contained in:
parent
d2cf7e62d7
commit
2de02742a4
|
@ -15,7 +15,7 @@ class DataAlternatifController extends Controller
|
||||||
$fetchAll = DataTables::of($data_alternatif)
|
$fetchAll = DataTables::of($data_alternatif)
|
||||||
->addIndexColumn()
|
->addIndexColumn()
|
||||||
->addColumn('nama_alternatif', function ($data) {
|
->addColumn('nama_alternatif', function ($data) {
|
||||||
return $data->alternatif['nama_guru'];
|
return $data->guru['nama_guru'];
|
||||||
})
|
})
|
||||||
->addColumn('action', function ($data) {
|
->addColumn('action', function ($data) {
|
||||||
return'
|
return'
|
||||||
|
|
|
@ -11,12 +11,12 @@ use App\Models\SubKriteria;
|
||||||
class PenilaianAlternatifController extends Controller
|
class PenilaianAlternatifController extends Controller
|
||||||
{
|
{
|
||||||
function index() {
|
function index() {
|
||||||
$penilaian = Penilaian::with(['guru','kriteria','subKriteria'])->get();
|
$penilaian = Penilaian::with(['alternatif','kriteria','subKriteria'])->get();
|
||||||
return view('pages.penilaian.index',compact('penilaian'));
|
return view('pages.penilaian.index',compact('penilaian'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function create() {
|
function create() {
|
||||||
$alternatif = Alternatif::with('alternatif')->get();
|
$alternatif = Alternatif::with('guru')->get();
|
||||||
$kriteria = Kriteria::get();
|
$kriteria = Kriteria::get();
|
||||||
$subKriteria = SubKriteria::get();
|
$subKriteria = SubKriteria::get();
|
||||||
return view('pages.penilaian.form', compact(['alternatif','kriteria','subKriteria']));
|
return view('pages.penilaian.form', compact(['alternatif','kriteria','subKriteria']));
|
||||||
|
|
|
@ -3,10 +3,56 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use App\Models\Kriteria;
|
||||||
|
use App\Models\Alternatif;
|
||||||
|
use App\Models\Penilaian;
|
||||||
|
|
||||||
class PerhitunganController extends Controller
|
class PerhitunganController extends Controller
|
||||||
{
|
{
|
||||||
function index() {
|
function index() {
|
||||||
return view('pages.proses_penilaian.index');
|
$alternatif = Alternatif::with('penilaian.kriteria')->orderBy('kode_alternatif','ASC')->get();
|
||||||
|
$kriteria = Kriteria::get();
|
||||||
|
$penilaian = Penilaian::with('subKriteria')->get();
|
||||||
|
// return response()->json($alternatif);
|
||||||
|
|
||||||
|
// mencari min max
|
||||||
|
foreach ($kriteria as $key => $vkriteria) {
|
||||||
|
foreach ($penilaian as $key_1 => $vpenilaian) {
|
||||||
|
if ($vkriteria->id == $vpenilaian->id_kriteria) {
|
||||||
|
if ($vkriteria->sifat == "benefit") {
|
||||||
|
$minMax[$vkriteria->id][] = $vpenilaian->subKriteria['bobot'];
|
||||||
|
}elseif ($vkriteria->sifat == "cost") {
|
||||||
|
$minMax[$vkriteria->id][] = $vpenilaian->subKriteria['bobot'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// normalisasi
|
||||||
|
foreach ($penilaian as $key_1 => $vpenilaian) {
|
||||||
|
foreach ($kriteria as $key => $vkriteria) {
|
||||||
|
if ($vkriteria->id == $vpenilaian->id_kriteria) {
|
||||||
|
if ($vkriteria->sifat == "benefit") { //nilai sub_kriteria : nilai maksimal
|
||||||
|
$normalisasi[$vpenilaian->alternatif->guru['nama_guru']][$vkriteria->id] = $vpenilaian->subKriteria['bobot'] / max($minMax[$vkriteria->id]);
|
||||||
|
}elseif ($vkriteria->sifat == "cost") { //nilai minimal : nilai sub_kriteria
|
||||||
|
$normalisasi[$vpenilaian->alternatif->guru['nama_guru']][$vkriteria->id] = min($minMax[$vkriteria->id]) / $vpenilaian->subKriteria['bobot'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// perangkingan
|
||||||
|
foreach ($normalisasi as $key => $vnormalisasi) {
|
||||||
|
foreach ($kriteria as $key_1 => $vkriteria) { //hasil normalisasi x bobot_kriteria
|
||||||
|
$rank[$key][] = $vnormalisasi[$vkriteria->id] * $vkriteria->bobot_kriteria;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ($normalisasi as $key => $value){ //total hasil perangkingan
|
||||||
|
$rank[$key][] = array_sum($rank[$key]);
|
||||||
|
}
|
||||||
|
asort($rank); //sortir $rank
|
||||||
|
|
||||||
|
// dd($minMax);
|
||||||
|
return view('pages.proses_penilaian.index', compact(['kriteria','alternatif','penilaian','minMax','normalisasi','rank']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,16 @@ class Alternatif extends Model
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'kode_alternatif', 'id_guru',
|
'kode_alternatif', 'id_guru',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function penilaian() {
|
||||||
|
return $this->hasMany(Penilaian::class, 'id_alternatif');
|
||||||
|
}
|
||||||
|
|
||||||
public function alternatif(){
|
public function guru(){
|
||||||
return $this->hasOne(Guru::class, 'id', 'id_guru');
|
return $this->hasOne(Guru::class, 'id', 'id_guru');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function kriteria() {
|
||||||
|
return $this->hasMany(Penilaian::class, 'id_alternatif', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,13 @@ class Penilaian extends Model
|
||||||
'periode', 'id_alternatif', 'id_kriteria', 'id_sub',
|
'periode', 'id_alternatif', 'id_kriteria', 'id_sub',
|
||||||
];
|
];
|
||||||
|
|
||||||
public function guru(){
|
public function alternatif(){
|
||||||
return $this->hasOne(Alternatif::class, 'id', 'id_alternatif');
|
return $this->belongsTo(Alternatif::class, 'id_alternatif');
|
||||||
}
|
}
|
||||||
public function kriteria(){
|
public function kriteria(){
|
||||||
return $this->hasOne(Kriteria::class, 'id', 'id_kriteria');
|
return $this->belongsTo(Kriteria::class, 'id_kriteria');
|
||||||
}
|
}
|
||||||
public function subKriteria(){
|
public function subKriteria(){
|
||||||
return $this->hasOne(SubKriteria::class, 'id', 'id_sub');
|
return $this->belongsTo(SubKriteria::class, 'id_sub');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,8 +62,8 @@
|
||||||
<span>Proses Perhitungan</span>
|
<span>Proses Perhitungan</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item {{ request()->segment(1) == 'proses-saw' ? 'active' : ''}}">
|
<li class="nav-item {{ request()->segment(1) == 'laporan-hasil' ? 'active' : ''}}">
|
||||||
<a class="nav-link" href="{{ route('hapus_hasil') }}">
|
<a class="nav-link" href="{{ route('laporan_hasil') }}">
|
||||||
<i class="fas fa-fw fa-arrow-right"></i>
|
<i class="fas fa-fw fa-arrow-right"></i>
|
||||||
<span>Data Hasil Keputusan</span>
|
<span>Data Hasil Keputusan</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<select name="id_alternatif" class="form-control">
|
<select name="id_alternatif" class="form-control">
|
||||||
<option value="">Pilih</option>
|
<option value="">Pilih</option>
|
||||||
@foreach ($alternatif as $alt)
|
@foreach ($alternatif as $alt)
|
||||||
<option value="{{ $alt->id }}">{{ $alt->alternatif['nama_guru'] }}</option>
|
<option value="{{ $alt->id }}">{{ $alt->guru['nama_guru'] }}</option>
|
||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
@foreach ($penilaian as $item)
|
@foreach ($penilaian as $item)
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-center">{{ $loop->iteration }}</td>
|
<td class="text-center">{{ $loop->iteration }}</td>
|
||||||
<td>{{ $item->guru->alternatif['nama_guru'] }}</td>
|
<td>{{ $item->alternatif->guru['nama_guru'] }}</td>
|
||||||
<td>{{ $item->kriteria['nama_kriteria'] }}</td>
|
<td>{{ $item->kriteria['nama_kriteria'] }}</td>
|
||||||
<td class="text-center">{{ $item->subKriteria['sub_kriteria'] }}</td>
|
<td class="text-center">{{ $item->subKriteria['sub_kriteria'] }}</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
|
|
|
@ -10,41 +10,63 @@
|
||||||
<div class="card-body pt-3">
|
<div class="card-body pt-3">
|
||||||
<h4 class="text-gray-900">1. Data Masing Masing Guru Terhadap Kriteria</h4>
|
<h4 class="text-gray-900">1. Data Masing Masing Guru Terhadap Kriteria</h4>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped text-center" width="100%">
|
<table class="table table-striped table-sm" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>No</th>
|
<th class="text-center" rowspan="2" style="vertical-align: middle">Kode (Ai)</th>
|
||||||
<th>Alternatif</th>
|
<th class="text-center" rowspan="2" style="vertical-align: middle">Keterangan</th>
|
||||||
<th>Daya Tahan</th>
|
<th class="text-center" colspan="{{ count($kriteria) }}">Kode Kriteria</th>
|
||||||
<th>Umur</th>
|
</tr>
|
||||||
<th>Harga</th>
|
<tr>
|
||||||
<th>Layanan Purna Jual</th>
|
@foreach ($kriteria as $item)
|
||||||
|
<th class="text-center">{{ $item->kode_kriteria }}</th>
|
||||||
|
@endforeach
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
{{-- <tbody>
|
||||||
|
|
||||||
|
@foreach ($alternatif as $alt)
|
||||||
<tr>
|
<tr>
|
||||||
<td>1</td>
|
<td class="text-center">{{ $alt->kode_alternatif }}</td>
|
||||||
<td class="text-left">Guru 1</td>
|
<td>{{ $alt->guru['nama_guru'] }}</td>
|
||||||
<td>4</td>
|
@foreach ($alt->penilaian as $nilai)
|
||||||
<td>5</td>
|
<td class="text-center">{{ $nilai->id_sub }}</td>
|
||||||
<td>3</td>
|
<?php
|
||||||
<td>7</td>
|
$minMaxKriteria[$nilai->kriteria->kode_kriteria]['min'] > $nilai->id_sub && $minMaxKriteria[$nilai->kriteria->kode_kriteria]['min'] = $nilai->id_sub;
|
||||||
|
$minMaxKriteria[$nilai->kriteria->kode_kriteria]['max'] < $nilai->id_sub && $minMaxKriteria[$nilai->kriteria->kode_kriteria]['max'] = $nilai->id_sub
|
||||||
|
?>
|
||||||
|
@endforeach
|
||||||
</tr>
|
</tr>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
</tbody> --}}
|
||||||
|
<tbody>
|
||||||
|
@forelse ($alternatif as $alt => $valt)
|
||||||
|
<tr>
|
||||||
|
<td class="text-center">{{ $valt->kode_alternatif }}</td>
|
||||||
|
<td>{{ $valt->guru['nama_guru'] }}</td>
|
||||||
|
@foreach ($valt->penilaian as $nilai)
|
||||||
|
<td class="text-center">{{ $nilai->subKriteria['bobot'] }}</td>
|
||||||
|
@endforeach
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td class="text-center" colspan="{{ count($kriteria) +2 }}">Data Kosong</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr class="text-center">
|
||||||
<th colspan="2">Nilai Maks</th>
|
<th colspan="2">Nilai Maks</th>
|
||||||
<th class="bg-secondary text-white">5</th>
|
@foreach ($kriteria as $key => $vkriteria)
|
||||||
<th class="bg-secondary text-white">5</th>
|
<th class="bg-secondary text-white">{{ max($minMax[$vkriteria->id]) }}</th>
|
||||||
<th class="bg-secondary text-white">4</th>
|
@endforeach
|
||||||
<th class="bg-secondary text-white">7</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr class="text-center">
|
||||||
<th colspan="2">Nilai Min</th>
|
<th colspan="2">Nilai Min</th>
|
||||||
<th class="bg-secondary text-white">2</th>
|
@foreach ($kriteria as $key => $vkriteria)
|
||||||
<th class="bg-secondary text-white">3</th>
|
<th class="bg-secondary text-white">{{ min($minMax[$vkriteria->id]) }}</th>
|
||||||
<th class="bg-secondary text-white">3</th>
|
@endforeach
|
||||||
<th class="bg-secondary text-white">3</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
|
@ -52,163 +74,60 @@
|
||||||
|
|
||||||
<h4 class="text-gray-900 mt-4">2. Menghitung Nilai Normalisasi</h4>
|
<h4 class="text-gray-900 mt-4">2. Menghitung Nilai Normalisasi</h4>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped text-center" width="100%">
|
<table class="table table-striped" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>No</th>
|
<th class="text-center" rowspan="2" style="vertical-align: middle;">Alternatif</th>
|
||||||
<th>Alternatif</th>
|
<th class="text-center" colspan="{{ count($kriteria) }}">Kode Kriteria</th>
|
||||||
<th>Daya Tahan</th>
|
</tr>
|
||||||
<th>Umur</th>
|
<tr>
|
||||||
<th>Harga</th>
|
@foreach ($kriteria as $item)
|
||||||
<th>Layanan Purna Jual</th>
|
<th class="text-center">{{ $item->kode_kriteria }}</th>
|
||||||
|
@endforeach
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
@foreach ($normalisasi as $key => $value)
|
||||||
<td>1</td>
|
<tr>
|
||||||
<td class="text-left">Guru 1</td>
|
<td width="20%">{{ $key }}</td>
|
||||||
<td>4/5</td>
|
@foreach ($value as $key_1 => $value_1)
|
||||||
<td>5/5</td>
|
<td class="text-center">{{ number_format($value_1 ,2) }}</td>
|
||||||
<td>3/4</td>
|
@endforeach
|
||||||
<td>7/7</td>
|
</tr>
|
||||||
</tr>
|
@endforeach
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h4 class="text-gray-900 mt-4">3. Hasil Normalisasi</h4>
|
<h4 class="text-gray-900 mt-4">3. Perankingan</h4>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-striped text-center" width="100%">
|
<table class="table table-striped text-center" width="100%">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>No</th>
|
<th>Kode Kriteria</th>
|
||||||
<th>Alternatif</th>
|
@foreach ($kriteria as $item)
|
||||||
<th>Daya Tahan</th>
|
<th class="text-center">{{ $item->kode_kriteria }}</th>
|
||||||
<th>Umur</th>
|
@endforeach
|
||||||
<th>Harga</th>
|
<th rowspan="2" style="vertical-align: middle">Total</th>
|
||||||
<th>Layanan Purna Jual</th>
|
<th rowspan="2" style="vertical-align: middle">Rank</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Bobot</th>
|
||||||
|
@foreach ($kriteria as $item)
|
||||||
|
<th class="text-center">{{ $item->bobot_kriteria }}</th>
|
||||||
|
@endforeach
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
@foreach ($rank as $key => $value)
|
||||||
<td>1</td>
|
<tr>
|
||||||
<td class="text-left">Guru 1</td>
|
<td width="20%">{{ $key }}</td>
|
||||||
<td>0.8</td>
|
@foreach ($value as $key_1 => $value_1)
|
||||||
<td>1</td>
|
<td class="text-center">{{ number_format($value_1 ,2) }}</td>
|
||||||
<td>0.8</td>
|
@endforeach
|
||||||
<td>1</td>
|
<td>{{ $loop->iteration }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
@endforeach
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4 class="text-gray-900 mt-4">4. Menghitung Nilai Refrensi</h4>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-striped text-center" width="100%">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>No</th>
|
|
||||||
<th>Alternatif</th>
|
|
||||||
<th>Daya Tahan</th>
|
|
||||||
<th>Umur</th>
|
|
||||||
<th>Harga</th>
|
|
||||||
<th>Layanan Purna Jual</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>1</td>
|
|
||||||
<td class="text-left">Guru 1</td>
|
|
||||||
<td>0.8 x 0.2</td>
|
|
||||||
<td>1 x 0.3</td>
|
|
||||||
<td>0.8 x 0.35</td>
|
|
||||||
<td>1 x 0.15</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<th colspan="2">Bobot Kriteria</th>
|
|
||||||
<th class="bg-secondary text-white">0.2</th>
|
|
||||||
<th class="bg-secondary text-white">0.3</th>
|
|
||||||
<th class="bg-secondary text-white">0.35</th>
|
|
||||||
<th class="bg-secondary text-white">0.15</th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4 class="text-gray-900 mt-4">5. Hasil Prefrensi</h4>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-striped text-center" width="100%">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>No</th>
|
|
||||||
<th>Alternatif</th>
|
|
||||||
<th>Daya Tahan</th>
|
|
||||||
<th>Umur</th>
|
|
||||||
<th>Harga</th>
|
|
||||||
<th>Layanan Purna Jual</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>1</td>
|
|
||||||
<td class="text-left">Guru 1</td>
|
|
||||||
<td>0.16</td>
|
|
||||||
<td>0.3</td>
|
|
||||||
<td>0.28</td>
|
|
||||||
<td>0.15</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4 class="text-gray-900 mt-4">6. Menghitung Total Nilai Prefrensi</h4>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-striped text-center" width="100%">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>No</th>
|
|
||||||
<th>Nama Alternatif</th>
|
|
||||||
<th>Daya Tahan</th>
|
|
||||||
<th>Umur</th>
|
|
||||||
<th>Harga</th>
|
|
||||||
<th>Layanan Purna Jual</th>
|
|
||||||
<th>Total Nilai Prefrensi</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>1</td>
|
|
||||||
<td class="text-left">Guru 1</td>
|
|
||||||
<td>0.16</td>
|
|
||||||
<td>0.3</td>
|
|
||||||
<td>0.28</td>
|
|
||||||
<td>0.15</td>
|
|
||||||
<td class="bg-secondary text-white">0.89</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h4 class="text-gray-900 mt-4">7. Perankingan</h4>
|
|
||||||
<div class="table-responsive">
|
|
||||||
<table class="table table-striped text-center" width="100%">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>No</th>
|
|
||||||
<th>Nama Alternatif</th>
|
|
||||||
<th>Nilai Prefrensi</th>
|
|
||||||
<th>Ranking</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>1</td>
|
|
||||||
<td class="text-left">Guru 1</td>
|
|
||||||
<td>0.89</td>
|
|
||||||
<td class="bg-secondary text-white">1</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue