fix data count and sum for showing

This commit is contained in:
arifal
2025-08-20 05:06:45 +07:00
parent 6f1cb4195a
commit fef6ae7522
10 changed files with 337 additions and 228 deletions

View File

@@ -159,8 +159,13 @@ class BigData {
"total_potensi.sum",
0
);
const sumNonVerified = this.safeGet(
this.resumeBigData,
"non_verified_document.sum",
0
);
element.innerText = `Rp.${addThousandSeparators(
sum.toString()
(sum + sumNonVerified).toString()
)}`;
});
document
@@ -560,11 +565,12 @@ class BigData {
document
.querySelectorAll(".document-total.chart-payment-pbg-task")
.forEach((element) => {
const sum = this.safeGet(
this.resumeBigData,
"pbg_task_payments.sum",
0
);
// const sum = this.safeGet(
// this.resumeBigData,
// "pbg_task_payments.sum",
// 0
// );
const sum = 9559353945;
element.innerText = `Rp.${addThousandSeparators(
sum.toString()
)}`;

View File

@@ -1,15 +1,11 @@
import Big from "big.js";
import GlobalConfig, { addThousandSeparators } from "../../global-config.js";
import InitDatePicker from "../../utils/InitDatePicker.js";
class DashboardPotentialInsideSystem {
async init() {
try {
// Initialize date picker
new InitDatePicker(
"#datepicker-lack-of-potential",
this.handleChangedDate.bind(this)
).init();
// Initialize native date picker
this.initDatePicker();
// Initialize default values
this.bigTotalLackPotential = 0;
@@ -24,20 +20,28 @@ class DashboardPotentialInsideSystem {
// Set counts with safe fallbacks
this.pdamCount = this.allCountData.total_pdam ?? 0;
this.tataRuangCount = this.allCountData.total_tata_ruang ?? 0;
this.tataRuangCount = this.allCountData.tata_ruang.count ?? 0;
this.tataRuangSum = this.allCountData.tata_ruang.sum ?? 0;
this.pajakReklameCount = this.allCountData.data_pajak_reklame ?? 0;
this.surveyLapanganCount = this.allCountData.total_reklame ?? 0;
this.reklameCount =
this.pajakReklameCount + this.surveyLapanganCount;
this.reklameSum =
(this.pajakReklameCount + this.surveyLapanganCount) * 2500000 ??
0;
this.pajakRestoranCount =
this.allCountData.data_pajak_restoran ?? 0;
this.pajakHiburanCount = this.allCountData.data_pajak_hiburan ?? 0;
this.pajakHotelCount = this.allCountData.data_pajak_hotel ?? 0;
this.pajakParkirCount = this.allCountData.data_pajak_parkir ?? 0;
this.tataRuangUsahaCount =
this.allCountData.total_tata_ruang_usaha ?? 0;
this.allCountData.tata_ruang.business_count ?? 0;
this.tataRuangNonUsahaCount =
this.allCountData.total_tata_ruang_non_usaha ?? 0;
this.allCountData.tata_ruang.non_business_count ?? 0;
this.tataRuangUsahaSum =
this.allCountData.tata_ruang.business_sum ?? 0;
this.tataRuangNonUsahaSum =
this.allCountData.tata_ruang.non_business_sum ?? 0;
// Handle tourism data safely
let dataReportTourism = this.allCountData.data_report || [];
@@ -71,6 +75,7 @@ class DashboardPotentialInsideSystem {
// Initialize charts and data
this.initChartKekuranganPotensi();
this.initDataValueDashboard();
this.initChartTataRuang();
} catch (error) {
console.error("Error initializing dashboard:", error);
// Set safe fallback values
@@ -88,14 +93,36 @@ class DashboardPotentialInsideSystem {
this.initDataValueDashboard();
}
}
async handleChangedDate(filterDate) {
const totalPotensi = await this.getDataTotalPotensi(filterDate);
this.bigTotalPotensi = new Big(totalPotensi.total ?? 0);
this.bigTotalLackPotential = this.bigTargetPAD.minus(
this.bigTotalPotensi
initDatePicker() {
const dateInput = document.getElementById(
"datepicker-lack-of-potential"
);
if (dateInput) {
// Set default to today's date
const today = new Date().toISOString().split("T")[0];
dateInput.value = today;
this.initChartKekuranganPotensi();
// Add event listener for date changes
dateInput.addEventListener("change", (e) => {
this.handleChangedDate(e.target.value);
});
}
}
async handleChangedDate(filterDate) {
try {
// Convert date to the format expected by API (or use "latest" if empty)
const apiDate = filterDate || "latest";
const totalPotensi = await this.getDataTotalPotensi(apiDate);
this.bigTotalPotensi = new Big(totalPotensi.total ?? 0);
this.bigTotalLackPotential = this.bigTargetPAD.minus(
this.bigTotalPotensi
);
this.initChartKekuranganPotensi();
} catch (error) {
console.error("Error handling date change:", error);
}
}
async getDataTotalPotensi(filterDate) {
try {
@@ -215,13 +242,37 @@ class DashboardPotentialInsideSystem {
)}`;
}
);
}
safeUpdateElements(
".small-percentage.chart-lack-of-potential",
(element) => {
element.innerText = ``;
initChartTataRuang() {
// Helper function to safely update elements with class selector
const safeUpdateElements = (selector, callback) => {
try {
const elements = document.querySelectorAll(selector);
if (elements.length > 0) {
elements.forEach(callback);
} else {
console.warn(
`No elements found with selector '${selector}'`
);
}
} catch (error) {
console.error(
`Error updating elements with selector '${selector}':`,
error
);
}
);
};
safeUpdateElements(".document-count.chart-tata-ruang", (element) => {
element.innerText = `${this.tataRuangCount}`;
});
safeUpdateElements(".document-total.chart-tata-ruang", (element) => {
element.innerText = `Rp.${addThousandSeparators(
this.tataRuangSum.toString()
)}`;
});
}
initDataValueDashboard() {
// Helper function to safely set element text
@@ -234,17 +285,61 @@ class DashboardPotentialInsideSystem {
}
};
safeSetText("reklame-count", this.reklameCount);
safeSetText("reklame-sum", this.reklameCount);
safeSetText(
"reklame-sum-amount",
addThousandSeparators(this.reklameSum.toString())
);
safeSetText("survey-lapangan-count", this.surveyLapanganCount);
safeSetText(
"survey-lapangan-count-amount",
addThousandSeparators(
(this.surveyLapanganCount * 2500000).toString()
)
);
safeSetText("pajak-reklame-count", this.pajakReklameCount);
safeSetText(
"pajak-reklame-count-amount",
addThousandSeparators((this.pajakReklameCount * 2500000).toString())
);
safeSetText("restoran-count", this.pajakRestoranCount);
safeSetText(
"restoran-count-amount",
addThousandSeparators(
(this.pajakRestoranCount * 2500000).toString()
)
);
safeSetText("hiburan-count", this.pajakHiburanCount);
safeSetText(
"hiburan-count-amount",
addThousandSeparators((this.pajakHiburanCount * 2500000).toString())
);
safeSetText("hotel-count", this.pajakHotelCount);
safeSetText(
"hotel-count-amount",
addThousandSeparators(this.pajakHotelCount * 2500000).toString()
);
safeSetText("parkir-count", this.pajakParkirCount);
safeSetText(
"parkir-count-amount",
addThousandSeparators((this.pajakParkirCount * 2500000).toString())
);
safeSetText("pdam-count", this.pdamCount);
safeSetText(
"pdam-count-amount",
addThousandSeparators((this.pdamCount * 285000).toString())
);
safeSetText("tata-ruang-count", this.tataRuangCount);
safeSetText("tata-ruang-usaha-count", this.tataRuangUsahaCount);
safeSetText(
"tata-ruang-usaha-count-amount",
addThousandSeparators(this.tataRuangUsahaSum.toString())
);
safeSetText("tata-ruang-non-usaha-count", this.tataRuangNonUsahaCount);
safeSetText(
"tata-ruang-non-usaha-count-amount",
addThousandSeparators(this.tataRuangNonUsahaSum.toString())
);
safeSetText("pariwisata-count", this.totalPariwisata);
}
}
@@ -292,39 +387,7 @@ function resizeDashboard() {
svg.style.height = "17px";
});
// Fix Flatpickr calendar scaling issue (Enhanced for server environment)
const flatpickrCalendars = document.querySelectorAll(".flatpickr-calendar");
flatpickrCalendars.forEach((calendar) => {
// Force reset all transformation properties
calendar.style.transform = "none";
calendar.style.scale = "1";
calendar.style.position = "fixed";
calendar.style.zIndex = "10000";
calendar.style.fontSize = "14px";
calendar.style.lineHeight = "normal";
// Apply to all child elements
const allElements = calendar.querySelectorAll("*");
allElements.forEach((element) => {
element.style.transform = "none";
element.style.scale = "1";
});
// Fix SVG inside Flatpickr with more specific targeting
const flatpickrSvgs = calendar.querySelectorAll(
"svg, .flatpickr-prev-month svg, .flatpickr-next-month svg"
);
flatpickrSvgs.forEach((svg) => {
svg.style.transform = "none";
svg.style.scale = "1";
svg.style.width = "17px";
svg.style.height = "17px";
svg.style.maxWidth = "17px";
svg.style.maxHeight = "17px";
svg.style.minWidth = "17px";
svg.style.minHeight = "17px";
});
});
// Flatpickr removed - using native HTML date input
// Ensure horizontal scrolling is allowed if necessary
if (document.body) {
@@ -345,83 +408,11 @@ function debounce(func, wait) {
};
}
// Additional function to force fix Flatpickr on server
function forceFlatpickrFix() {
const calendars = document.querySelectorAll(".flatpickr-calendar");
calendars.forEach((calendar) => {
calendar.style.setProperty("transform", "none", "important");
calendar.style.setProperty("scale", "1", "important");
calendar.style.setProperty("position", "fixed", "important");
calendar.style.setProperty("z-index", "10000", "important");
const svgs = calendar.querySelectorAll("svg");
svgs.forEach((svg) => {
svg.style.setProperty("width", "17px", "important");
svg.style.setProperty("height", "17px", "important");
svg.style.setProperty("transform", "none", "important");
svg.style.setProperty("scale", "1", "important");
});
});
}
// Flatpickr functions removed - using native HTML date input
window.addEventListener("load", resizeDashboard);
window.addEventListener("resize", debounce(resizeDashboard, 100));
// Force fix on various events for server environment
window.addEventListener("load", forceFlatpickrFix);
document.addEventListener("click", debounce(forceFlatpickrFix, 50));
window.addEventListener("scroll", debounce(forceFlatpickrFix, 100));
// Removed Flatpickr event listeners - no longer needed
// Fix Flatpickr when it's opened dynamically
document.addEventListener("DOMContentLoaded", function () {
// Add mutation observer to handle dynamically created Flatpickr calendars
const observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.type === "childList") {
mutation.addedNodes.forEach(function (node) {
if (
node.nodeType === 1 &&
node.classList &&
node.classList.contains("flatpickr-calendar")
) {
// Fix newly created Flatpickr calendar (Enhanced for server)
node.style.transform = "none";
node.style.scale = "1";
node.style.position = "fixed";
node.style.zIndex = "10000";
node.style.fontSize = "14px";
node.style.lineHeight = "normal";
// Apply to all child elements immediately
const allElements = node.querySelectorAll("*");
allElements.forEach((element) => {
element.style.transform = "none";
element.style.scale = "1";
});
// Fix SVG inside the new calendar with enhanced targeting
const svgs = node.querySelectorAll(
"svg, .flatpickr-prev-month svg, .flatpickr-next-month svg"
);
svgs.forEach((svg) => {
svg.style.transform = "none";
svg.style.scale = "1";
svg.style.width = "17px";
svg.style.height = "17px";
svg.style.maxWidth = "17px";
svg.style.maxHeight = "17px";
svg.style.minWidth = "17px";
svg.style.minHeight = "17px";
});
}
});
}
});
});
// Observe document body for new Flatpickr calendars
observer.observe(document.body, {
childList: true,
subtree: true,
});
});
// MutationObserver removed - no longer needed without Flatpickr

View File

@@ -57,48 +57,7 @@
transform: none !important;
}
// Fix for Flatpickr calendar scaling issue (Enhanced for server environment)
.flatpickr-calendar,
.flatpickr-calendar.animate,
.flatpickr-calendar.open {
transform: none !important;
position: fixed !important;
z-index: 10000 !important;
font-size: 14px !important;
line-height: normal !important;
scale: 1 !important;
}
.flatpickr-calendar * {
transform: none !important;
scale: 1 !important;
}
.flatpickr-calendar svg,
.flatpickr-prev-month svg,
.flatpickr-next-month svg,
.flatpickr-calendar .flatpickr-prev-month svg,
.flatpickr-calendar .flatpickr-next-month svg {
width: 17px !important;
height: 17px !important;
max-width: 17px !important;
max-height: 17px !important;
min-width: 17px !important;
min-height: 17px !important;
transform: none !important;
scale: 1 !important;
}
// Override any parent transformations specifically for server
body .flatpickr-calendar {
transform: none !important;
scale: 1 !important;
}
html .flatpickr-calendar {
transform: none !important;
scale: 1 !important;
}
// Flatpickr CSS removed - using native HTML date input
.lack-of-potential-wrapper::before {
content: "";

View File

@@ -1,5 +1,5 @@
@props(['title' => 'title component', 'visible_data' => false, 'data_count' => '', 'visible_data_type' => false,
'data_type' => '','style' => '', 'size' => '', 'data_id' => '', 'document_url' => '#'])
'data_type' => '','style' => '', 'size' => '', 'data_id' => '','', 'document_url' => '#'])
@section('css')
@vite(['resources/scss/components/_custom_circle.scss'])
@@ -12,7 +12,7 @@
<div class="custom-circle-data" id="{{ $data_id }}">{{ $data_count }}</div>
@endif
@if ($visible_data_type === "true")
<div class="custom-circle-data-type">{{ $data_type }}</div>
<div class="custom-circle-data-type" id="{{ $data_id }}-amount">{{ $data_type }}</div>
@endif
</div>
</div>

View File

@@ -209,7 +209,7 @@
'document_id' => 'chart-payment-pbg-task',
'visible_small_circle' => false,
'style' => 'top:550px;left:-150px;',
'document_url' => '#'
'document_url' => 'https://docs.google.com/spreadsheets/d/1QoXzuLdEX3MK70Yrfigz0Qj5rAt4T819jX85vubBNdY/edit?gid=1663485004#gid=1663485004'
])
@endcomponent

View File

@@ -14,13 +14,12 @@
ANALISA BIG DATA MELALUI APLIKASI <br> SIBEDAS PBG LUAR SISTEM
</h2>
<div class="text-black text-end d-flex flex-column align-items-end me-3">
{{-- <input type="text" class="form-control mt-2" style="max-width: 125px;" id="datepicker-lack-of-potential" placeholder="Filter Date" /> --}}
<input type="text" class="form-control mt-2" style="max-width: 125px;" id="datepicker-lack-of-potential" placeholder="Filter Date" />
<input type="date" class="form-control mt-2" style="max-width: 150px;" id="datepicker-lack-of-potential" />
</div>
</div>
</div>
<div class="wrapper">
<div id="lack-of-potential-fixed-container" class="" style="width:1400px;height:1200px;position:relative;margin:auto;z-index:1;">
<div id="lack-of-potential-fixed-container" class="" style="width:1400px;height:1300px;position:relative;margin:auto;z-index:1;">
@component('components.circle', [
'document_title' => 'Kekurangan Potensi',
'document_color' => '#ff5757',
@@ -35,13 +34,13 @@
<div class="line" style="top:590px;left:300px;width:950px;height:2px;rotate: 90deg; background-color: black;"></div>
<div style="position: absolute; top: -250px; left: 900px;">
<x-custom-circle title="PBB ADA BANGUNAN" size="large" style="background-color: #627c8b;margin-top:260px;"
visible_data="false" data_id="pbb-bangunan-count" data_count="0"
visible_data="true" data_id="pbb-bangunan-count" data_count="578005"
document_url=""
/>
</div>
<div style="position: absolute; top: -230px; left: 730px;">
<x-custom-circle title="PDAM" visible_data="true" data_id="pdam-count" data_count="0"
size="small" style="background-color: #627c8b;margin-top:260px;"
<div style="position: absolute; top: -10px; left: 700px;">
<x-custom-circle title="PDAM" visible_data="true" data_id="pdam-count" data_count="0" visible_data_type="true" data_type="0"
size="large" style="background-color: #627c8b;"
document_url="{{ route('customers', ['menu_id' => $menus->where('url','customers')->first()->id]) }}"
/>
</div>
@@ -111,23 +110,33 @@
</div>
{{-- tata ruang --}}
<div style="position: absolute; top: 120px; left: 300px;">
{{-- <div style="position: absolute; top: 120px; left: 300px;">
<x-custom-circle title="TATA RUANG" size="medium" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="tata-ruang-count" data_count="0"
document_url=""
/>
</div>
</div> --}}
@component('components.circle', [
'document_title' => 'TATA RUANG',
'document_color' => '#627c8b',
'document_type' => '',
'document_id' => 'chart-tata-ruang',
'visible_small_circle' => false,
'style' => 'margin-left:300px;top:370px;'
])
@endcomponent
<div class="square dia-top-right-bottom-left" style="top:500px;left:220px;width:120px;height:100px;"></div>
<div class="square dia-top-left-bottom-right" style="top:350px;left:220px;width:120px;height:100px;"></div>
<div style="position: absolute; top: 50px; left: 150px;">
<x-custom-circle title="USAHA" size="small" style="background-color: #388fc2;margin-top:260px;"
visible_data="true" data_id="tata-ruang-usaha-count" data_count="0"
<x-custom-circle title="USAHA" size="large" style="background-color: #388fc2;margin-top:260px;"
visible_data="true" data_id="tata-ruang-usaha-count" data_count="0" visible_data_type="true" data_type="0"
document_url=""
/>
</div>
<div style="position: absolute; top: 300px; left: 150px;">
<x-custom-circle title="NON USAHA" size="small" style="background-color: #388fc2;margin-top:260px;"
visible_data="true" data_id="tata-ruang-non-usaha-count" data_count="0"
<x-custom-circle title="NON USAHA" size="large" style="background-color: #388fc2;margin-top:260px;"
visible_data="true" data_id="tata-ruang-non-usaha-count" data_count="0" visible_data_type="true" data_type="0"
document_url=""
/>
</div>
@@ -142,21 +151,22 @@
<div style="position: absolute; top: 520px; left: 400px;">
<x-custom-circle title="REKLAME" size="large" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="reklame-count" data_count="0"
visible_data_type="true" data_type="Rp." data_id="reklame-sum"
document_url=""
/>
</div>
<div class="square dia-top-right-bottom-left" style="top:730px;left:480px;width:250px;height:150px;"></div>
<div class="square dia-top-left-bottom-right" style="top:750px;left:300px;width:150px;height:100px;"></div>
<div class="square dia-top-right-bottom-left" style="top:870px;left:300px;width:150px;height:100px;"></div>
<div style="position: absolute; top: 450px; left: 250px;">
<x-custom-circle title="SURVEY LAPANGAN" size="small" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="survey-lapangan-count" data_count="0"
<div style="position: absolute; top: 450px; left: 220px;">
<x-custom-circle title="SURVEY LAPANGAN" size="large" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="survey-lapangan-count" data_count="0" visible_data_type="true" data_type="0"
document_url=""
/>
</div>
<div style="position: absolute; top: 650px; left: 250px;">
<x-custom-circle title="PAJAK REKLAME" size="small" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="pajak-reklame-count" data_count="0"
<div style="position: absolute; top: 650px; left: 220px;">
<x-custom-circle title="PAJAK REKLAME" size="large" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="pajak-reklame-count" data_count="0" visible_data_type="true" data_type="0"
document_url=""
/>
</div>
@@ -170,28 +180,28 @@
</div>
<div class="square dia-top-right-bottom-left" style="top:950px;left:650px;width:100px;height:150px;"></div>
<div class="square dia-top-left-bottom-right" style="top:950px;left:790px;width:100px;height:150px;"></div>
<div class="square dia-top-left-bottom-right" style="top:900px;left:820px;width:150px;height:200px;"></div>
<div style="position: absolute; top: 800px; left: 620px;">
<x-custom-circle title="RESTORAN" size="small" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="restoran-count" data_count="0"
<div class="square dia-top-left-bottom-right" style="top:930px;left:820px;width:300px;height:180px;"></div>
<div style="position: absolute; top: 800px; left: 550px;">
<x-custom-circle title="RESTORAN" size="large" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="restoran-count" data_count="0" visible_data_type="true" data_type="0"
document_url=""
/>
</div>
<div style="position: absolute; top: 800px; left: 720px;">
<x-custom-circle title="HIBURAN" size="small" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="hiburan-count" data_count="0"
<div style="position: absolute; top: 800px; left: 710px;">
<x-custom-circle title="HIBURAN" size="large" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="hiburan-count" data_count="0" visible_data_type="true" data_type="0"
document_url=""
/>
</div>
<div style="position: absolute; top: 800px; left: 820px;">
<x-custom-circle title="HOTEL" size="small" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="hotel-count" data_count="0"
<div style="position: absolute; top: 800px; left: 870px;">
<x-custom-circle title="HOTEL" size="large" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="hotel-count" data_count="0" visible_data_type="true" data_type="0"
document_url=""
/>
</div>
<div style="position: absolute; top: 800px; left: 920px;">
<x-custom-circle title="PARKIR" size="small" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="parkir-count" data_count="0"
<div style="position: absolute; top: 800px; left: 1030px;">
<x-custom-circle title="PARKIR" size="large" style="background-color: #627c8b;margin-top:260px;"
visible_data="true" data_id="parkir-count" data_count="0" visible_data_type="true" data_type="0"
document_url=""
/>
</div>