Merge pull request #32 from arieeefajar/fix/assessment-history
fix(assessment-history): fix function show detail data
This commit is contained in:
commit
1dab513cbf
|
@ -9,14 +9,17 @@ class AssessmentHistoryController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$evaluations = Evaluation::with('land', 'evaluationDetails.indicator')->orderBy('created_at', 'desc')->get();
|
$evaluations = Evaluation::with(['land', 'evaluationDetails.indicator.rules' => function ($query) {
|
||||||
|
$query->whereHas('indicator.evaluationDetails', function ($subquery) {
|
||||||
|
$subquery->whereColumn('rule.cf', 'evaluation_details.cf_e');
|
||||||
|
});
|
||||||
|
}])->orderBy('created_at', 'desc')->get();
|
||||||
return view('assessment.index', compact('evaluations'));
|
return view('assessment.index', compact('evaluations'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function officer()
|
public function officer()
|
||||||
{
|
{
|
||||||
$evaluations = Evaluation::with('land', 'evaluationDetails.indicator.rules')->where('user_id', auth()->user()->id)->orderBy('created_at', 'desc')->get();
|
$evaluations = Evaluation::with('land', 'evaluationDetails.indicator.rules')->where('user_id', auth()->user()->id)->orderBy('created_at', 'desc')->get();
|
||||||
// dd($evaluations);
|
|
||||||
return view('assessment.officer', compact('evaluations'));
|
return view('assessment.officer', compact('evaluations'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,6 @@ public function evaluation()
|
||||||
|
|
||||||
public function indicator()
|
public function indicator()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Indicator::class);
|
return $this->belongsTo(Indicator::class, 'indicator_id', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,4 +17,9 @@ public function rules()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Rule::class, 'indicator_id', 'id');
|
return $this->hasMany(Rule::class, 'indicator_id', 'id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function evaluationDetails()
|
||||||
|
{
|
||||||
|
return $this->hasMany(EvaluationDetail::class, 'indicator_id', 'id');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,6 @@ class Rule extends Model
|
||||||
|
|
||||||
public function indicator()
|
public function indicator()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(Indicator::class);
|
return $this->belongsTo(Indicator::class, 'indicator_id', 'id');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
function detailData(data) {
|
function detailData(data) {
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
// Ambil elemen tbody tabel
|
|
||||||
let tbody = document.querySelector("#detailTable tbody");
|
let tbody = document.querySelector("#detailTable tbody");
|
||||||
|
|
||||||
// Kosongkan tabel sebelum menambahkan data baru
|
|
||||||
tbody.innerHTML = "";
|
tbody.innerHTML = "";
|
||||||
|
|
||||||
// Pastikan data adalah array atau objek iterable
|
|
||||||
if (Array.isArray(data)) {
|
if (Array.isArray(data)) {
|
||||||
data.forEach((item) => {
|
data.forEach((item) => {
|
||||||
|
const parameterTypes = item.indicator.rules
|
||||||
|
.map((rule) => rule.parameter_type)
|
||||||
|
.join(", ");
|
||||||
let row = `
|
let row = `
|
||||||
<tr>
|
<tr>
|
||||||
<td>${item.indicator.name}</td>
|
<td>${item.indicator.name}</td>
|
||||||
<td>${item.md_value.toFixed(2)}</td>
|
<td>${parameterTypes}</td>
|
||||||
</tr>
|
</tr>
|
||||||
`;
|
`;
|
||||||
tbody.innerHTML += row;
|
tbody.innerHTML += row;
|
||||||
|
@ -22,7 +20,7 @@ function detailData(data) {
|
||||||
let row = `
|
let row = `
|
||||||
<tr>
|
<tr>
|
||||||
<td>${data.indicator.name}</td>
|
<td>${data.indicator.name}</td>
|
||||||
<td>${data.md_value.toFixed(2)}</td>
|
<td>${parameterTypes}</td>
|
||||||
</tr>
|
</tr>
|
||||||
`;
|
`;
|
||||||
tbody.innerHTML += row;
|
tbody.innerHTML += row;
|
||||||
|
|
|
@ -213,7 +213,7 @@ class="fw-medium link-primary">#VZ2101</a>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Indikator</th>
|
<th>Indikator</th>
|
||||||
<th>MD Value</th>
|
<th>Nilai</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
Loading…
Reference in New Issue