Cpone-BUG-00024 - fix sinkronisasi status aktif & total peserta project #1
@@ -14,6 +14,7 @@ type ResultRow struct {
|
||||
Tests string
|
||||
FileUrl string
|
||||
ReportDate string
|
||||
ReportVersion string
|
||||
}
|
||||
|
||||
type ResultSummary struct {
|
||||
@@ -49,7 +50,13 @@ func GetResultRows(mcuID int) ([]ResultRow, error) {
|
||||
AND p.Published_McuDasboardFileUrl != ''
|
||||
THEN COALESCE(CAST(p.Published_McuDasboardLastUpdated AS CHAR), '')
|
||||
ELSE ''
|
||||
END AS report_date
|
||||
END AS report_date,
|
||||
CASE
|
||||
WHEN p.Published_McuDasboardFileUrl IS NOT NULL
|
||||
AND p.Published_McuDasboardFileUrl != ''
|
||||
THEN COALESCE(CAST(UNIX_TIMESTAMP(p.Published_McuDasboardLastUpdated) AS CHAR), '')
|
||||
ELSE ''
|
||||
END AS report_version
|
||||
FROM mcu_patient mp
|
||||
LEFT JOIN published_mcu_dashboard_sync p
|
||||
ON p.Published_McuDasboardT_OrderHeaderID = mp.Mcu_PatientOrderID
|
||||
@@ -67,7 +74,7 @@ func GetResultRows(mcuID int) ([]ResultRow, error) {
|
||||
var result []ResultRow
|
||||
for rows.Next() {
|
||||
var r ResultRow
|
||||
if err := rows.Scan(&r.NIP, &r.Name, &r.Posisi, &r.PacketCode, &r.PacketName, &r.Tests, &r.FileUrl, &r.ReportDate); err != nil {
|
||||
if err := rows.Scan(&r.NIP, &r.Name, &r.Posisi, &r.PacketCode, &r.PacketName, &r.Tests, &r.FileUrl, &r.ReportDate, &r.ReportVersion); err != nil {
|
||||
continue
|
||||
}
|
||||
result = append(result, r)
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
{{if .FileUrl}}
|
||||
<button onclick="openPDFModal('{{$.PDFBaseURL}}{{.FileUrl}}', '{{.Name}}')"
|
||||
<button onclick="openPDFModal('{{$.PDFBaseURL}}{{.FileUrl}}', '{{.Name}}', '{{.ReportVersion}}')"
|
||||
class="inline-flex items-center gap-1.5 rounded-lg bg-brand-500 px-3 py-1.5 text-xs font-semibold text-white transition hover:bg-brand-600">
|
||||
View PDF
|
||||
</button>
|
||||
@@ -134,7 +134,7 @@
|
||||
{{if .ReportDate}}<p class="mt-0.5 num text-xs text-slate-400">{{.ReportDate | fmtDate}}</p>{{end}}
|
||||
</div>
|
||||
{{if .FileUrl}}
|
||||
<button onclick="openPDFModal('{{$.PDFBaseURL}}{{.FileUrl}}', '{{.Name}}')"
|
||||
<button onclick="openPDFModal('{{$.PDFBaseURL}}{{.FileUrl}}', '{{.Name}}', '{{.ReportVersion}}')"
|
||||
class="shrink-0 rounded-lg bg-brand-500 px-3 py-1.5 text-xs font-semibold text-white transition hover:bg-brand-600">
|
||||
View PDF
|
||||
</button>
|
||||
@@ -145,17 +145,39 @@
|
||||
</article>
|
||||
{{end}}
|
||||
</div>
|
||||
<div id="result-load-more" class="px-4 pb-4">
|
||||
<div class="hidden items-center justify-between gap-2 border-t border-slate-100 px-4 py-3 md:flex">
|
||||
<div class="text-xs text-slate-400">Page {{.Page}} of {{.TotalPages}}</div>
|
||||
<div class="flex items-center gap-2">
|
||||
{{if .HasPrev}}
|
||||
<a href='{{b "/result"}}?search={{urlquery .Search}}&filter={{urlquery .Filter}}&packet={{urlquery .Packet}}&page={{.PrevPage}}'
|
||||
class="rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-xs font-medium text-slate-600 transition hover:border-brand-300 hover:text-brand-600">
|
||||
Previous
|
||||
</a>
|
||||
{{else}}
|
||||
<span class="rounded-lg border border-slate-100 bg-slate-50 px-3 py-1.5 text-xs font-medium text-slate-300">Previous</span>
|
||||
{{end}}
|
||||
{{if .HasMore}}
|
||||
<a href='{{b "/result"}}?search={{urlquery .Search}}&filter={{urlquery .Filter}}&packet={{urlquery .Packet}}&page={{.NextPage}}'
|
||||
class="rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-xs font-medium text-slate-600 transition hover:border-brand-300 hover:text-brand-600">
|
||||
Next
|
||||
</a>
|
||||
{{else}}
|
||||
<span class="rounded-lg border border-slate-100 bg-slate-50 px-3 py-1.5 text-xs font-medium text-slate-300">Next</span>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="result-load-more" class="px-4 pb-4 md:hidden">
|
||||
{{if .HasMore}}
|
||||
<div
|
||||
hx-get='{{b "/result/list"}}?search={{urlquery .Search}}&filter={{urlquery .Filter}}&packet={{urlquery .Packet}}&page={{.NextPage}}'
|
||||
hx-trigger="revealed"
|
||||
hx-swap="outerHTML"
|
||||
hx-trigger="revealed, click"
|
||||
hx-swap="none"
|
||||
class="rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-center text-xs font-medium text-slate-500">
|
||||
Memuat data berikutnya...
|
||||
Load next data...
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="text-center text-xs text-slate-400">Semua data sudah ditampilkan</div>
|
||||
<div class="text-center text-xs text-slate-400">All data is displayed</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
@@ -202,11 +224,24 @@ function normalizePdfUrl(rawUrl) {
|
||||
}
|
||||
}
|
||||
|
||||
function openPDFModal(url, name) {
|
||||
const safeUrl = normalizePdfUrl(url);
|
||||
document.getElementById('pdf-modal-frame').src = safeUrl;
|
||||
function buildPdfUrl(rawUrl, version) {
|
||||
const safeUrl = normalizePdfUrl(rawUrl);
|
||||
if (!version) return safeUrl;
|
||||
try {
|
||||
const u = new URL(safeUrl, window.location.origin);
|
||||
u.searchParams.set('v', version);
|
||||
return u.toString();
|
||||
} catch (_) {
|
||||
const joiner = safeUrl.includes('?') ? '&' : '?';
|
||||
return safeUrl + joiner + 'v=' + encodeURIComponent(version);
|
||||
}
|
||||
}
|
||||
|
||||
function openPDFModal(url, name, version) {
|
||||
const finalUrl = buildPdfUrl(url, version);
|
||||
document.getElementById('pdf-modal-frame').src = finalUrl;
|
||||
document.getElementById('pdf-modal-title').textContent = name;
|
||||
document.getElementById('pdf-modal-link').href = safeUrl;
|
||||
document.getElementById('pdf-modal-link').href = finalUrl;
|
||||
const modal = document.getElementById('pdf-modal');
|
||||
modal.classList.remove('hidden');
|
||||
modal.classList.add('flex');
|
||||
@@ -240,7 +275,7 @@ document.addEventListener('keydown', function(e) {
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
{{if .FileUrl}}
|
||||
<button onclick="openPDFModal('{{$.PDFBaseURL}}{{.FileUrl}}', '{{.Name}}')"
|
||||
<button onclick="openPDFModal('{{$.PDFBaseURL}}{{.FileUrl}}', '{{.Name}}', '{{.ReportVersion}}')"
|
||||
class="inline-flex items-center gap-1.5 rounded-lg bg-brand-500 px-3 py-1.5 text-xs font-semibold text-white transition hover:bg-brand-600">
|
||||
View PDF
|
||||
</button>
|
||||
@@ -263,7 +298,7 @@ document.addEventListener('keydown', function(e) {
|
||||
{{if .ReportDate}}<p class="mt-0.5 num text-xs text-slate-400">{{.ReportDate | fmtDate}}</p>{{end}}
|
||||
</div>
|
||||
{{if .FileUrl}}
|
||||
<button onclick="openPDFModal('{{$.PDFBaseURL}}{{.FileUrl}}', '{{.Name}}')"
|
||||
<button onclick="openPDFModal('{{$.PDFBaseURL}}{{.FileUrl}}', '{{.Name}}', '{{.ReportVersion}}')"
|
||||
class="shrink-0 rounded-lg bg-brand-500 px-3 py-1.5 text-xs font-semibold text-white transition hover:bg-brand-600">
|
||||
View PDF
|
||||
</button>
|
||||
@@ -275,17 +310,17 @@ document.addEventListener('keydown', function(e) {
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<div id="result-load-more" hx-swap-oob="outerHTML">
|
||||
<div id="result-load-more" hx-swap-oob="outerHTML" class="md:hidden">
|
||||
{{if .HasMore}}
|
||||
<div
|
||||
hx-get='{{b "/result/list"}}?search={{urlquery .Search}}&filter={{urlquery .Filter}}&packet={{urlquery .Packet}}&page={{.NextPage}}'
|
||||
hx-trigger="revealed"
|
||||
hx-swap="outerHTML"
|
||||
hx-trigger="revealed, click"
|
||||
hx-swap="none"
|
||||
class="rounded-lg border border-slate-200 bg-slate-50 px-3 py-2 text-center text-xs font-medium text-slate-500">
|
||||
Memuat data berikutnya...
|
||||
Load next data...
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="text-center text-xs text-slate-400">Semua data sudah ditampilkan</div>
|
||||
<div class="text-center text-xs text-slate-400">All data is displayed</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
Reference in New Issue
Block a user