fix(penilai): perbaikkan luas tanah, bangunan, dan print out sederhana, dan rap

This commit is contained in:
majid
2025-03-11 13:15:51 +07:00
parent 727c7a0dca
commit ef7a47ebb9
8 changed files with 101 additions and 52 deletions

View File

@@ -485,7 +485,7 @@ function calculateSLA($permohonan, $type)
* @param int $jenisLegalitas
* @return int
*/
function calculateTotalLuas($detailsArray, $key, $jenisLegalitas)
function calculateTotalLuas($detailsArray, $key, $jenisLegalitas, $defaultJenisLegalitas)
{
$total = 0;
@@ -503,7 +503,57 @@ function calculateTotalLuas($detailsArray, $key, $jenisLegalitas)
}
}
}
// Jika total masih 0, gunakan jenis jaminan ppjb
if ($total === 0) {
foreach ($detailsArray as $item) {
if (isset($item->jenis_legalitas_jaminan_id) && $item->jenis_legalitas_jaminan_id === $defaultJenisLegalitas) {
$details = json_decode($item->details, true);
if (is_array($details)) {
foreach ($details as $detail) {
if (isset($detail[$key]) && $detail[$key] !== null) {
$total += (int) $detail[$key];
}
}
}
}
}
}
// jika total masih kosong juga maka gunakan ppb
if ($total === 0 && $fallbackJenisLegalitas !== null) {
foreach ($detailsArray as $item) {
if (isset($item->jenis_legalitas_jaminan_id) && $item->jenis_legalitas_jaminan_id === $fallbackJenisLegalitas) {
$details = json_decode($item->details, true);
if (is_array($details)) {
foreach ($details as $detail) {
if (isset($detail[$key]) && $detail[$key] !== null) {
$total += (int) $detail[$key];
}
}
}
}
}
}
}
return $total;
return $total > 0 ? $total : 0;
}
function ubahNomorHp($nomorHp) {
$nomorHp = preg_replace('/\D/', '', $nomorHp);
if (strpos($nomorHp, '62') === 0) {
$nomorBaru = substr($nomorHp, 0, 5) . "xxxxx";
return '+' . $nomorBaru;
} elseif (strpos($nomorHp, '0') === 0) {
$nomorBaru = substr($nomorHp, 0, 5) . "xxxxxx";
return $nomorBaru;
} else {
return "Nomor HP tidak valid";
}
}