feat: enhance report on-screen, PDF print layout, and Excel exports with executive styling and audit sign-off
This commit is contained in:
@@ -99,7 +99,7 @@ def build_xlsx(report_payload: dict[str, Any]) -> BytesIO:
|
|||||||
summary_text = _format_summary_echo(report_payload.get("summary", {}))
|
summary_text = _format_summary_echo(report_payload.get("summary", {}))
|
||||||
|
|
||||||
# Row 1: Hospital Title
|
# Row 1: Hospital Title
|
||||||
ws.row_dimensions[1].height = 26
|
ws.row_dimensions[1].height = 28
|
||||||
c1 = ws.cell(row=1, column=1, value=title_text)
|
c1 = ws.cell(row=1, column=1, value=title_text)
|
||||||
c1.font = _TITLE_FONT
|
c1.font = _TITLE_FONT
|
||||||
c1.alignment = Alignment(vertical="center")
|
c1.alignment = Alignment(vertical="center")
|
||||||
@@ -111,10 +111,17 @@ def build_xlsx(report_payload: dict[str, Any]) -> BytesIO:
|
|||||||
c2.alignment = Alignment(vertical="center")
|
c2.alignment = Alignment(vertical="center")
|
||||||
|
|
||||||
# Row 3: Summary KPIs strip
|
# Row 3: Summary KPIs strip
|
||||||
ws.row_dimensions[3].height = 22
|
ws.row_dimensions[3].height = 24
|
||||||
c3 = ws.cell(row=3, column=1, value=summary_text)
|
c3 = ws.cell(row=3, column=1, value=summary_text)
|
||||||
c3.font = _SUMMARY_FONT
|
c3.font = _SUMMARY_FONT
|
||||||
c3.alignment = Alignment(vertical="center")
|
c3.fill = _SUMMARY_FILL
|
||||||
|
c3.border = Border(
|
||||||
|
top=Side(style="thin", color="BFDBFE"),
|
||||||
|
bottom=Side(style="thin", color="BFDBFE"),
|
||||||
|
left=Side(style="thin", color="BFDBFE"),
|
||||||
|
right=Side(style="thin", color="BFDBFE"),
|
||||||
|
)
|
||||||
|
c3.alignment = Alignment(vertical="center", indent=1)
|
||||||
|
|
||||||
# Row 4: Spacer
|
# Row 4: Spacer
|
||||||
ws.row_dimensions[4].height = 10
|
ws.row_dimensions[4].height = 10
|
||||||
@@ -122,8 +129,20 @@ def build_xlsx(report_payload: dict[str, Any]) -> BytesIO:
|
|||||||
columns: list[dict[str, str]] = report_payload.get("columns", [])
|
columns: list[dict[str, str]] = report_payload.get("columns", [])
|
||||||
rows: list[dict[str, Any]] = report_payload.get("rows", [])
|
rows: list[dict[str, Any]] = report_payload.get("rows", [])
|
||||||
|
|
||||||
|
# Span summary strip styling across header columns
|
||||||
|
if columns and len(columns) > 1:
|
||||||
|
for c_idx in range(2, len(columns) + 1):
|
||||||
|
sc = ws.cell(row=3, column=c_idx)
|
||||||
|
sc.fill = _SUMMARY_FILL
|
||||||
|
sc.border = Border(
|
||||||
|
top=Side(style="thin", color="BFDBFE"),
|
||||||
|
bottom=Side(style="thin", color="BFDBFE"),
|
||||||
|
left=Side(style="thin", color="BFDBFE"),
|
||||||
|
right=Side(style="thin", color="BFDBFE"),
|
||||||
|
)
|
||||||
|
|
||||||
header_row = 5
|
header_row = 5
|
||||||
ws.row_dimensions[header_row].height = 26
|
ws.row_dimensions[header_row].height = 28
|
||||||
col_widths: list[int] = []
|
col_widths: list[int] = []
|
||||||
|
|
||||||
for c_idx, col in enumerate(columns, start=1):
|
for c_idx, col in enumerate(columns, start=1):
|
||||||
@@ -187,6 +206,22 @@ def build_xlsx(report_payload: dict[str, Any]) -> BytesIO:
|
|||||||
for c_idx, width in enumerate(col_widths, start=1):
|
for c_idx, width in enumerate(col_widths, start=1):
|
||||||
ws.column_dimensions[get_column_letter(c_idx)].width = min(50, max(14, width + 4))
|
ws.column_dimensions[get_column_letter(c_idx)].width = min(50, max(14, width + 4))
|
||||||
|
|
||||||
|
# Pre-configure page setup for professional A4 Landscape printing / PDF conversion from Excel
|
||||||
|
try:
|
||||||
|
ws.page_setup.orientation = ws.ORIENTATION_LANDSCAPE
|
||||||
|
ws.page_setup.paperSize = ws.PAPERSIZE_A4
|
||||||
|
ws.page_setup.fitToPage = True
|
||||||
|
ws.page_setup.fitToWidth = 1
|
||||||
|
ws.page_setup.fitToHeight = 0
|
||||||
|
ws.sheet_properties.pageSetUpPr.fitToPage = True
|
||||||
|
ws.print_title_rows = f"{header_row}:{header_row}"
|
||||||
|
ws.oddHeader.left.text = "&BPoona Hospital & Research Centre&B"
|
||||||
|
ws.oddHeader.right.text = report_payload.get("title", "Operational Report")
|
||||||
|
ws.oddFooter.left.text = "Confidential • Biomedical Asset Management System"
|
||||||
|
ws.oddFooter.right.text = "Page &P of &N"
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
buf = BytesIO()
|
buf = BytesIO()
|
||||||
wb.save(buf)
|
wb.save(buf)
|
||||||
buf.seek(0)
|
buf.seek(0)
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ export function DataTable<TData>({
|
|||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
{/* Toolbar */}
|
{/* Toolbar */}
|
||||||
<div className="flex flex-col sm:flex-row sm:items-center gap-2">
|
<div className="no-print flex flex-col sm:flex-row sm:items-center gap-2">
|
||||||
<div className="relative flex-1 min-w-0">
|
<div className="relative flex-1 min-w-0">
|
||||||
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400" />
|
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400" />
|
||||||
<input
|
<input
|
||||||
@@ -301,7 +301,7 @@ export function DataTable<TData>({
|
|||||||
value={(header.column.getFilterValue() as string) ?? ""}
|
value={(header.column.getFilterValue() as string) ?? ""}
|
||||||
onChange={(e) => header.column.setFilterValue(e.target.value)}
|
onChange={(e) => header.column.setFilterValue(e.target.value)}
|
||||||
placeholder="Filter..."
|
placeholder="Filter..."
|
||||||
className="w-full px-2 py-0.5 text-xs border border-gray-200 rounded focus:outline-none focus:ring-1 focus:ring-blue-400"
|
className="no-print w-full px-2 py-0.5 text-xs border border-gray-200 rounded focus:outline-none focus:ring-1 focus:ring-blue-400"
|
||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
@@ -357,7 +357,7 @@ export function DataTable<TData>({
|
|||||||
|
|
||||||
{/* Pagination */}
|
{/* Pagination */}
|
||||||
{!loading && visibleRows.length > 0 && (
|
{!loading && visibleRows.length > 0 && (
|
||||||
<div className="flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 px-3 sm:px-4 py-3 border-t border-gray-200 bg-gray-50 text-sm text-gray-600">
|
<div className="no-print flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 px-3 sm:px-4 py-3 border-t border-gray-200 bg-gray-50 text-sm text-gray-600">
|
||||||
<span>
|
<span>
|
||||||
{filteredRows.length} record{filteredRows.length !== 1 ? "s" : ""}
|
{filteredRows.length} record{filteredRows.length !== 1 ? "s" : ""}
|
||||||
{globalFilter || columnFilters.length ? " (filtered)" : ""}
|
{globalFilter || columnFilters.length ? " (filtered)" : ""}
|
||||||
|
|||||||
+73
-9
@@ -11,43 +11,107 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen {
|
||||||
|
.print-only {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
@page {
|
@page {
|
||||||
size: A4 landscape;
|
size: A4 landscape;
|
||||||
margin: 12mm;
|
margin: 8mm 10mm;
|
||||||
}
|
}
|
||||||
|
|
||||||
aside,
|
aside,
|
||||||
header,
|
header,
|
||||||
|
nav,
|
||||||
.no-print {
|
.no-print {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.print-only {
|
||||||
|
display: block !important;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: #ffffff !important;
|
background: #ffffff !important;
|
||||||
color: #111827 !important;
|
color: #0f172a !important;
|
||||||
-webkit-print-color-adjust: exact;
|
-webkit-print-color-adjust: exact !important;
|
||||||
print-color-adjust: exact;
|
print-color-adjust: exact !important;
|
||||||
|
font-size: 10px !important;
|
||||||
|
line-height: 1.35 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
|
margin: 0 !important;
|
||||||
overflow: visible !important;
|
overflow: visible !important;
|
||||||
|
max-width: 100% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Prevent elements from breaking across PDF pages */
|
||||||
|
.print-break-inside-avoid {
|
||||||
|
break-inside: avoid !important;
|
||||||
|
page-break-inside: avoid !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.print-break-before {
|
||||||
|
break-before: page !important;
|
||||||
|
page-break-before: always !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean up card shadows and borders for crisp PDF generation */
|
||||||
|
.shadow-sm,
|
||||||
|
.shadow,
|
||||||
|
.shadow-md,
|
||||||
|
.shadow-lg {
|
||||||
|
box-shadow: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* High-fidelity PDF Table Styling */
|
||||||
table {
|
table {
|
||||||
border-collapse: collapse !important;
|
border-collapse: collapse !important;
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
|
page-break-inside: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
thead {
|
||||||
|
display: table-header-group !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
tfoot {
|
||||||
|
display: table-footer-group !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
tr {
|
||||||
|
page-break-inside: avoid !important;
|
||||||
|
break-inside: avoid !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
background-color: #1e3a8a !important;
|
||||||
|
color: #ffffff !important;
|
||||||
|
font-weight: 600 !important;
|
||||||
|
font-size: 9.5px !important;
|
||||||
|
padding: 5px 6px !important;
|
||||||
|
border: 1px solid #1e293b !important;
|
||||||
|
text-align: center !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
th,
|
|
||||||
td {
|
td {
|
||||||
border: 1px solid #d1d5db !important;
|
border: 1px solid #cbd5e1 !important;
|
||||||
font-size: 10px !important;
|
font-size: 9px !important;
|
||||||
padding: 4px 6px !important;
|
padding: 4px 6px !important;
|
||||||
|
color: #0f172a !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.print-break-inside-avoid {
|
tbody tr:nth-child(even) td {
|
||||||
break-inside: avoid;
|
background-color: #f8fafc !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Force chart svg visibility */
|
||||||
|
.recharts-wrapper {
|
||||||
|
margin: 0 auto !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import {
|
|||||||
HelpCircle,
|
HelpCircle,
|
||||||
AlertCircle,
|
AlertCircle,
|
||||||
Lock,
|
Lock,
|
||||||
|
RotateCcw,
|
||||||
|
Filter,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import {
|
import {
|
||||||
REPORT_CATALOG,
|
REPORT_CATALOG,
|
||||||
@@ -36,6 +38,8 @@ import { useAuthStore } from "@/hooks/useAuth";
|
|||||||
import { formatDateTime } from "@/lib/format";
|
import { formatDateTime } from "@/lib/format";
|
||||||
import { DataTable } from "@/components/DataTable";
|
import { DataTable } from "@/components/DataTable";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
import { Badge } from "@/components/ui/badge";
|
||||||
|
import { cn } from "@/lib/utils";
|
||||||
import { toast } from "@/lib/toast";
|
import { toast } from "@/lib/toast";
|
||||||
|
|
||||||
function currentMonthStr(): string {
|
function currentMonthStr(): string {
|
||||||
@@ -210,6 +214,55 @@ export function ReportDetailPage() {
|
|||||||
contractType,
|
contractType,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const activeFiltersCount = useMemo(() => {
|
||||||
|
let count = 0;
|
||||||
|
if (departmentId) count++;
|
||||||
|
if (month && month !== currentMonthStr()) count++;
|
||||||
|
if (dateFrom || dateTo) count++;
|
||||||
|
if (dueFrom || dueTo) count++;
|
||||||
|
if (priority) count++;
|
||||||
|
if (callStatus) count++;
|
||||||
|
if (serviceMode) count++;
|
||||||
|
if (agencyId) count++;
|
||||||
|
if (supplierId) count++;
|
||||||
|
if (statusFilter) count++;
|
||||||
|
if (recordKind && recordKind !== "all") count++;
|
||||||
|
if (contractType) count++;
|
||||||
|
return count;
|
||||||
|
}, [
|
||||||
|
departmentId,
|
||||||
|
month,
|
||||||
|
dateFrom,
|
||||||
|
dateTo,
|
||||||
|
dueFrom,
|
||||||
|
dueTo,
|
||||||
|
priority,
|
||||||
|
callStatus,
|
||||||
|
serviceMode,
|
||||||
|
agencyId,
|
||||||
|
supplierId,
|
||||||
|
statusFilter,
|
||||||
|
recordKind,
|
||||||
|
contractType,
|
||||||
|
]);
|
||||||
|
|
||||||
|
function handleResetFilters() {
|
||||||
|
setMonth(currentMonthStr());
|
||||||
|
setDateFrom("");
|
||||||
|
setDateTo("");
|
||||||
|
setDueFrom("");
|
||||||
|
setDueTo("");
|
||||||
|
setDepartmentId("");
|
||||||
|
setPriority("");
|
||||||
|
setCallStatus("");
|
||||||
|
setServiceMode("");
|
||||||
|
setAgencyId("");
|
||||||
|
setSupplierId("");
|
||||||
|
setStatusFilter("");
|
||||||
|
setRecordKind("all");
|
||||||
|
setContractType("");
|
||||||
|
}
|
||||||
|
|
||||||
const deptsQuery = useQuery({
|
const deptsQuery = useQuery({
|
||||||
queryKey: ["departments", "active-only"],
|
queryKey: ["departments", "active-only"],
|
||||||
queryFn: () => departmentsApi.list(false),
|
queryFn: () => departmentsApi.list(false),
|
||||||
@@ -344,52 +397,126 @@ export function ReportDetailPage() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<div className="space-y-5">
|
||||||
{/* Print-Only Letterhead */}
|
{/* Print-Only Official Hospital Letterhead & Scope */}
|
||||||
<div className="hidden print:flex items-center justify-between border-b-2 border-[#1e3a8a] pb-3 mb-4">
|
<div className="hidden print:block mb-4 border-b-2 border-[#1e3a8a] pb-3">
|
||||||
<div className="flex items-center gap-3">
|
<div className="flex items-start justify-between">
|
||||||
|
<div className="flex items-center gap-3.5">
|
||||||
<img
|
<img
|
||||||
src="/logo.jpg"
|
src="/logo.jpg"
|
||||||
alt="Poona Hospital and Research Centre"
|
alt="Poona Hospital and Research Centre"
|
||||||
className="h-12 w-12 object-contain"
|
className="h-14 w-14 object-contain"
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<div className="text-base font-bold text-[#1e3a8a]">
|
<div className="text-base font-extrabold text-[#1e3a8a] tracking-tight">
|
||||||
Poona Hospital & Research Centre
|
POONA HOSPITAL & RESEARCH CENTRE
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-gray-600">
|
<div className="text-[11px] font-semibold text-gray-800">
|
||||||
Asset Management & Maintenance — {report?.title ?? meta.title}
|
NABH Accredited Tertiary Care Hospital • Department of Clinical Engineering
|
||||||
|
</div>
|
||||||
|
<div className="text-[10px] text-gray-500">
|
||||||
|
27, Sadashiv Peth, Pune, Maharashtra 411030 • Tel: +91 20 6609 6000
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-right text-[11px] text-gray-500">
|
<div className="text-right text-[10px] text-gray-600 space-y-0.5 border-l border-gray-200 pl-3">
|
||||||
<div>Printed: {formatDateTime(new Date().toISOString())} IST</div>
|
<div className="font-bold text-[#1e3a8a] uppercase tracking-wider">
|
||||||
{user?.name && <div>Generated by: {user.name}</div>}
|
Audit & Operational Record
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<strong>Ref:</strong> PHRC-BME-{key?.toUpperCase() ?? "REP"}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<strong>Date:</strong> {formatDateTime(new Date().toISOString())} IST
|
||||||
|
</div>
|
||||||
|
{user?.name && (
|
||||||
|
<div>
|
||||||
|
<strong>Generated by:</strong> {user.name} ({user.role?.replace(/_/g, " ").toUpperCase()})
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Print Filter / Scope summary bar */}
|
||||||
|
<div className="mt-2.5 pt-2 border-t border-gray-200 flex flex-wrap items-center justify-between text-[10px] text-gray-700 bg-gray-50 px-3 py-1.5 rounded">
|
||||||
|
<div className="flex items-center gap-4 flex-wrap">
|
||||||
|
<div>
|
||||||
|
<span className="text-gray-500">Report:</span>{" "}
|
||||||
|
<strong>{report?.title ?? meta.title}</strong>
|
||||||
|
</div>
|
||||||
|
{month && (
|
||||||
|
<div>
|
||||||
|
<span className="text-gray-500">Period:</span> <strong>{month}</strong>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{dateFrom && (
|
||||||
|
<div>
|
||||||
|
<span className="text-gray-500">From:</span> <strong>{dateFrom}</strong>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{dateTo && (
|
||||||
|
<div>
|
||||||
|
<span className="text-gray-500">To:</span> <strong>{dateTo}</strong>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div>
|
||||||
|
<span className="text-gray-500">Department:</span>{" "}
|
||||||
|
<strong>
|
||||||
|
{departmentId
|
||||||
|
? departments.find((d) => String(d.id) === departmentId)?.name ?? departmentId
|
||||||
|
: isDeptUser && user?.department_name
|
||||||
|
? user.department_name
|
||||||
|
: "All Departments"}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
{priority && (
|
||||||
|
<div>
|
||||||
|
<span className="text-gray-500">Priority:</span>{" "}
|
||||||
|
<strong>{priority.toUpperCase()}</strong>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{callStatus && (
|
||||||
|
<div>
|
||||||
|
<span className="text-gray-500">Status:</span>{" "}
|
||||||
|
<strong>{callStatus.toUpperCase()}</strong>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="font-semibold text-gray-900">
|
||||||
|
Total Records: {report?.rows?.length ?? 0}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Screen Header */}
|
{/* Screen Header */}
|
||||||
<div className="flex flex-wrap items-start justify-between gap-3">
|
<div className="no-print flex flex-wrap items-start justify-between gap-4 bg-white border border-gray-200 rounded-xl p-5 shadow-sm">
|
||||||
<div>
|
<div>
|
||||||
|
<div className="flex items-center gap-2 mb-2">
|
||||||
<Link
|
<Link
|
||||||
to="/reports"
|
to="/reports"
|
||||||
className="no-print inline-flex items-center gap-1.5 text-sm text-gray-500 hover:text-gray-800 mb-1"
|
className="inline-flex items-center gap-1.5 text-xs font-medium text-gray-500 hover:text-[#1e3a8a] transition-colors"
|
||||||
>
|
>
|
||||||
<ArrowLeft className="h-4 w-4" />
|
<ArrowLeft className="h-3.5 w-3.5" />
|
||||||
All Reports
|
All Reports
|
||||||
</Link>
|
</Link>
|
||||||
<h1 className="text-2xl font-bold text-gray-900">
|
<span className="text-gray-300">•</span>
|
||||||
|
<Badge variant="outline" className="text-[10px] bg-blue-50/60 text-[#1e3a8a] border-blue-200">
|
||||||
|
{meta.category}
|
||||||
|
</Badge>
|
||||||
|
</div>
|
||||||
|
<h1 className="text-2xl font-bold text-gray-900 tracking-tight">
|
||||||
{report?.title ?? meta.title}
|
{report?.title ?? meta.title}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-sm text-gray-500 mt-0.5">{meta.description}</p>
|
<p className="text-sm text-gray-500 mt-1 max-w-2xl leading-relaxed">{meta.description}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="no-print flex flex-wrap items-center gap-2">
|
<div className="flex flex-wrap items-center gap-2.5 pt-1">
|
||||||
{key === "monthly-maintenance" && report?.formula_info && (
|
{key === "monthly-maintenance" && report?.formula_info && (
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => setFormulaOpen((o) => !o)}
|
onClick={() => setFormulaOpen((o) => !o)}
|
||||||
|
className="border-blue-200 text-[#1e3a8a] hover:bg-blue-50 font-medium"
|
||||||
>
|
>
|
||||||
<HelpCircle className="h-4 w-4 mr-1.5 text-[#1e3a8a]" />
|
<HelpCircle className="h-4 w-4 mr-1.5 text-[#1e3a8a]" />
|
||||||
How this is calculated
|
How this is calculated
|
||||||
@@ -400,6 +527,7 @@ export function ReportDetailPage() {
|
|||||||
size="sm"
|
size="sm"
|
||||||
loading={exporting === "xlsx"}
|
loading={exporting === "xlsx"}
|
||||||
onClick={() => handleExport("xlsx")}
|
onClick={() => handleExport("xlsx")}
|
||||||
|
className="bg-emerald-700 hover:bg-emerald-800 text-white shadow-sm font-medium"
|
||||||
>
|
>
|
||||||
<FileSpreadsheet className="h-4 w-4 mr-1.5" />
|
<FileSpreadsheet className="h-4 w-4 mr-1.5" />
|
||||||
Export Excel (.xlsx)
|
Export Excel (.xlsx)
|
||||||
@@ -409,9 +537,11 @@ export function ReportDetailPage() {
|
|||||||
variant="outline"
|
variant="outline"
|
||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => window.print()}
|
onClick={() => window.print()}
|
||||||
|
className="border-gray-300 hover:bg-gray-50 text-gray-700 shadow-sm font-medium"
|
||||||
|
title="Generates an executive A4 landscape PDF report with official hospital sign-off"
|
||||||
>
|
>
|
||||||
<Printer className="h-4 w-4 mr-1.5" />
|
<Printer className="h-4 w-4 mr-1.5 text-[#1e3a8a]" />
|
||||||
Print A4
|
Print A4 / PDF
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -458,7 +588,32 @@ export function ReportDetailPage() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Tailored Filter Bar */}
|
{/* Tailored Filter Bar */}
|
||||||
<div className="no-print bg-white border border-gray-200 rounded-lg p-3.5 flex flex-wrap items-end gap-3">
|
<div className="no-print bg-white border border-gray-200 rounded-xl p-4 shadow-sm space-y-3">
|
||||||
|
<div className="flex items-center justify-between border-b border-gray-100 pb-2.5">
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<Filter className="h-4 w-4 text-[#1e3a8a]" />
|
||||||
|
<span className="text-xs font-semibold text-gray-800 uppercase tracking-wider">
|
||||||
|
Report Parameters & Scope
|
||||||
|
</span>
|
||||||
|
{activeFiltersCount > 0 && (
|
||||||
|
<Badge variant="info" className="text-[10px] px-2 py-0.5">
|
||||||
|
{activeFiltersCount} active filter{activeFiltersCount > 1 ? "s" : ""}
|
||||||
|
</Badge>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{activeFiltersCount > 0 && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleResetFilters}
|
||||||
|
className="text-xs text-gray-500 hover:text-red-600 flex items-center gap-1 transition-colors font-medium"
|
||||||
|
>
|
||||||
|
<RotateCcw className="h-3.5 w-3.5" />
|
||||||
|
Reset filters
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex flex-wrap items-end gap-3.5 pt-0.5">
|
||||||
{(key === "monthly-maintenance" ||
|
{(key === "monthly-maintenance" ||
|
||||||
key === "monthly-department" ||
|
key === "monthly-department" ||
|
||||||
key === "pm-compliance") && (
|
key === "pm-compliance") && (
|
||||||
@@ -743,33 +898,48 @@ export function ReportDetailPage() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* Summary Strip */}
|
{/* Summary Strip */}
|
||||||
{report && (
|
{report && (
|
||||||
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2.5 print-break-inside-avoid">
|
<div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3 print-break-inside-avoid">
|
||||||
{key === "monthly-maintenance" && (
|
{key === "monthly-maintenance" && (
|
||||||
<div className="bg-emerald-50 border border-emerald-300 rounded-lg p-3">
|
<div className="bg-white border border-emerald-300 border-t-4 border-t-emerald-600 rounded-xl p-3.5 shadow-sm">
|
||||||
<div className="text-[11px] font-semibold text-emerald-800">
|
<div className="text-[11px] font-semibold text-emerald-800 uppercase tracking-wider">
|
||||||
Uptime %
|
Uptime %
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xl font-bold text-emerald-900 mt-0.5 truncate">
|
<div className="text-2xl font-black text-emerald-900 mt-1 truncate">
|
||||||
{computeUptimePct(report.summary)}
|
{computeUptimePct(report.summary)}
|
||||||
</div>
|
</div>
|
||||||
|
<div className="text-[10px] text-emerald-700 mt-0.5">Hospital Availability</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{Object.entries(report.summary).map(([sKey, sVal]) => (
|
{Object.entries(report.summary).map(([sKey, sVal]) => {
|
||||||
|
const isNegative = sKey.includes("downtime") || sKey.includes("overdue") || sKey.includes("under_repair");
|
||||||
|
const isPositive = sKey.includes("uptime") || sKey.includes("compliance") || sKey.includes("completed");
|
||||||
|
const borderTopColor = isNegative
|
||||||
|
? "border-t-rose-500"
|
||||||
|
: isPositive
|
||||||
|
? "border-t-emerald-500"
|
||||||
|
: "border-t-[#1e3a8a]";
|
||||||
|
|
||||||
|
return (
|
||||||
<div
|
<div
|
||||||
key={sKey}
|
key={sKey}
|
||||||
className="bg-white border border-gray-200 rounded-lg p-3"
|
className={cn(
|
||||||
|
"bg-white border border-gray-200 border-t-4 rounded-xl p-3.5 shadow-sm",
|
||||||
|
borderTopColor
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
<div className="text-[11px] font-medium text-gray-500">
|
<div className="text-[11px] font-medium text-gray-500 truncate">
|
||||||
{humanizeSummaryKey(sKey)}
|
{humanizeSummaryKey(sKey)}
|
||||||
</div>
|
</div>
|
||||||
<div className="text-lg font-bold text-gray-900 mt-0.5 truncate">
|
<div className="text-xl font-bold text-gray-900 mt-1 truncate">
|
||||||
{String(sVal)}
|
{String(sVal)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@@ -788,18 +958,26 @@ export function ReportDetailPage() {
|
|||||||
<CartesianGrid strokeDasharray="3 3" stroke="#e5e7eb" />
|
<CartesianGrid strokeDasharray="3 3" stroke="#e5e7eb" />
|
||||||
<XAxis dataKey="department" tick={{ fontSize: 11 }} />
|
<XAxis dataKey="department" tick={{ fontSize: 11 }} />
|
||||||
<YAxis tick={{ fontSize: 11 }} />
|
<YAxis tick={{ fontSize: 11 }} />
|
||||||
<Tooltip />
|
<Tooltip
|
||||||
<Legend />
|
contentStyle={{
|
||||||
|
backgroundColor: "#ffffff",
|
||||||
|
borderColor: "#cbd5e1",
|
||||||
|
borderRadius: "8px",
|
||||||
|
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)",
|
||||||
|
fontSize: "12px",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Legend wrapperStyle={{ fontSize: "12px", paddingTop: "8px" }} />
|
||||||
<Bar
|
<Bar
|
||||||
dataKey="uptime_hours"
|
dataKey="uptime_hours"
|
||||||
name="Uptime (hrs)"
|
name="Uptime (hrs)"
|
||||||
fill="#22c55e"
|
fill="#10b981"
|
||||||
radius={[4, 4, 0, 0]}
|
radius={[4, 4, 0, 0]}
|
||||||
/>
|
/>
|
||||||
<Bar
|
<Bar
|
||||||
dataKey="downtime_hours"
|
dataKey="downtime_hours"
|
||||||
name="Downtime (hrs)"
|
name="Downtime (hrs)"
|
||||||
fill="#ef4444"
|
fill="#f43f5e"
|
||||||
radius={[4, 4, 0, 0]}
|
radius={[4, 4, 0, 0]}
|
||||||
/>
|
/>
|
||||||
</BarChart>
|
</BarChart>
|
||||||
@@ -827,8 +1005,16 @@ export function ReportDetailPage() {
|
|||||||
<Cell key={idx} fill={entry.color} />
|
<Cell key={idx} fill={entry.color} />
|
||||||
))}
|
))}
|
||||||
</Pie>
|
</Pie>
|
||||||
<Tooltip />
|
<Tooltip
|
||||||
<Legend />
|
contentStyle={{
|
||||||
|
backgroundColor: "#ffffff",
|
||||||
|
borderColor: "#cbd5e1",
|
||||||
|
borderRadius: "8px",
|
||||||
|
boxShadow: "0 4px 6px -1px rgb(0 0 0 / 0.1)",
|
||||||
|
fontSize: "12px",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Legend wrapperStyle={{ fontSize: "12px", paddingTop: "8px" }} />
|
||||||
</PieChart>
|
</PieChart>
|
||||||
</ResponsiveContainer>
|
</ResponsiveContainer>
|
||||||
</div>
|
</div>
|
||||||
@@ -844,6 +1030,47 @@ export function ReportDetailPage() {
|
|||||||
globalFilterPlaceholder="Quick filter report rows..."
|
globalFilterPlaceholder="Quick filter report rows..."
|
||||||
emptyMessage="No rows match the selected report filters."
|
emptyMessage="No rows match the selected report filters."
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{/* Hospital Tripartite Sign-off Block (Print / PDF Only) */}
|
||||||
|
<div className="hidden print:block mt-8 pt-4 border-t-2 border-gray-300 print-break-inside-avoid">
|
||||||
|
<div className="flex items-center justify-between text-[10px] font-bold uppercase tracking-wider text-gray-700 mb-4">
|
||||||
|
<span>Hospital Engineering Audit & Verification Sign-off (NABH Chapter FMS)</span>
|
||||||
|
<span>Poona Hospital & Research Centre</span>
|
||||||
|
</div>
|
||||||
|
<div className="grid grid-cols-3 gap-5 text-[10px]">
|
||||||
|
<div className="border border-gray-300 rounded p-3 space-y-4 bg-gray-50/50">
|
||||||
|
<div className="font-bold text-gray-800">1. PREPARED BY</div>
|
||||||
|
<div className="h-9 border-b border-dashed border-gray-400"></div>
|
||||||
|
<div className="space-y-0.5 text-gray-600">
|
||||||
|
<div>Name: {user?.name || "Biomedical Engineer"}</div>
|
||||||
|
<div>Role: {user?.role?.replace(/_/g, " ").toUpperCase() || "BIOMEDICAL"}</div>
|
||||||
|
<div>Date: {new Date().toLocaleDateString("en-IN")}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="border border-gray-300 rounded p-3 space-y-4 bg-gray-50/50">
|
||||||
|
<div className="font-bold text-gray-800">2. VERIFIED BY</div>
|
||||||
|
<div className="h-9 border-b border-dashed border-gray-400"></div>
|
||||||
|
<div className="space-y-0.5 text-gray-600">
|
||||||
|
<div>Name: __________________________</div>
|
||||||
|
<div>Role: HOD / Biomedical In-Charge</div>
|
||||||
|
<div>Date: ____ / ____ / ________</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="border border-gray-300 rounded p-3 space-y-4 bg-gray-50/50">
|
||||||
|
<div className="font-bold text-gray-800">3. APPROVED BY</div>
|
||||||
|
<div className="h-9 border-b border-dashed border-gray-400"></div>
|
||||||
|
<div className="space-y-0.5 text-gray-600">
|
||||||
|
<div>Name: __________________________</div>
|
||||||
|
<div>Role: Medical Superintendent / Director</div>
|
||||||
|
<div>Date: ____ / ____ / ________</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="mt-4 pt-2 border-t border-gray-200 text-[9px] text-gray-500 flex items-center justify-between">
|
||||||
|
<span>Official Hospital Record • Poona Hospital & Research Centre • Confidential • Retain for 7 Years</span>
|
||||||
|
<span>AMS Portal Generated • NABH Compliant</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,19 @@ export function ReportsPage() {
|
|||||||
<p className="text-xs text-gray-600 mt-1 leading-relaxed">
|
<p className="text-xs text-gray-600 mt-1 leading-relaxed">
|
||||||
{report.description}
|
{report.description}
|
||||||
</p>
|
</p>
|
||||||
|
<div className="flex items-center gap-1.5 flex-wrap pt-2.5">
|
||||||
|
<span className="inline-flex items-center text-[10px] text-emerald-700 bg-emerald-50 px-2 py-0.5 rounded font-medium border border-emerald-100">
|
||||||
|
Excel (.xlsx)
|
||||||
|
</span>
|
||||||
|
<span className="inline-flex items-center text-[10px] text-blue-700 bg-blue-50 px-2 py-0.5 rounded font-medium border border-blue-100">
|
||||||
|
A4 / PDF Print
|
||||||
|
</span>
|
||||||
|
{report.key === "monthly-maintenance" && (
|
||||||
|
<span className="inline-flex items-center text-[10px] text-purple-700 bg-purple-50 px-2 py-0.5 rounded font-medium border border-purple-100">
|
||||||
|
Interactive Charts
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user