update reports

This commit is contained in:
Flatlogic Bot 2026-03-21 18:14:03 +00:00
parent 66038df9e4
commit d96399430d
2 changed files with 128 additions and 7 deletions

View File

@ -65,7 +65,11 @@ $site_favicon = !empty($site_settings['company_favicon']) ? $site_settings['comp
<style>
body { font-family: 'Inter', 'Tajawal', sans-serif; background-color: #f4f7f6; }
.sidebar { min-height: 100vh; width: 250px; background-color: #002D62; color: white; transition: all 0.3s; flex-shrink: 0; }
.sidebar { height: 100vh; width: 250px; background-color: #002D62; color: white; transition: all 0.3s; flex-shrink: 0; overflow-y: auto; position: sticky; top: 0; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background-color: rgba(255, 255, 255, 0.2); border-radius: 3px; }
.sidebar::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.4); }
.sidebar-link { color: #cfd8dc; text-decoration: none; padding: 12px 20px; display: block; border-left: 4px solid transparent; }
.sidebar-link:hover, .sidebar-link.active { background-color: #003a80; color: white; border-left-color: #4fc3f7; }
.sidebar-submenu { background-color: #001f44; padding-left: 20px; }

View File

@ -94,9 +94,126 @@ if ($report_type === 'low_stock') {
}
}
// Fetch site settings if not already set (fallback)
if (!isset($site_name)) {
$stmt = $db->query("SELECT setting_key, setting_value FROM settings WHERE setting_key IN ('company_name', 'company_logo')");
$settings = $stmt->fetchAll(PDO::FETCH_KEY_PAIR);
$site_name = $settings['company_name'] ?? 'Hospital Management';
$site_logo = $settings['company_logo'] ?? '';
}
?>
<div class="d-flex justify-content-between align-items-center mb-4">
<style>
@media print {
@page {
size: A4;
margin: 1cm;
}
body {
background-color: #fff !important;
color: #000 !important;
font-family: 'Times New Roman', serif;
}
/* Hide everything by default */
.sidebar, .navbar, .btn-group, form, .btn, .no-print, header, footer {
display: none !important;
}
/* Layout resets */
.main-content, .content-wrapper, .container, .container-fluid {
margin: 0 !important;
padding: 0 !important;
width: 100% !important;
max-width: 100% !important;
box-shadow: none !important;
border: none !important;
}
.card {
border: none !important;
box-shadow: none !important;
}
.card-header {
display: none !important; /* We use custom print header */
}
.card-body {
padding: 0 !important;
}
/* Visible elements */
.print-only {
display: block !important;
}
/* Table Styling for Print */
.table {
width: 100% !important;
border-collapse: collapse !important;
border: 1px solid #000 !important;
font-size: 12pt;
}
.table th, .table td {
border: 1px solid #000 !important;
padding: 8px !important;
text-align: left;
}
.table th {
background-color: #f0f0f0 !important;
font-weight: bold;
-webkit-print-color-adjust: exact;
}
/* Badge handling - simplified for print */
.badge {
border: 1px solid #000;
color: #000 !important;
background: none !important;
font-weight: normal;
padding: 2px 5px;
}
}
.print-only {
display: none;
}
</style>
<!-- Print Header -->
<div class="print-only mb-4">
<div class="row align-items-center border-bottom pb-3 mb-3">
<div class="col-8">
<h1 class="h3 fw-bold mb-1"><?php echo htmlspecialchars($site_name); ?></h1>
<h2 class="h5 text-uppercase text-secondary mb-0"><?php echo htmlspecialchars($title); ?></h2>
</div>
<div class="col-4 text-end">
<?php if (!empty($site_logo)): ?>
<img src="<?php echo htmlspecialchars($site_logo); ?>" alt="Logo" style="max-height: 60px;">
<?php endif; ?>
</div>
</div>
<div class="row mb-4">
<div class="col-6">
<p class="mb-1"><strong><?php echo __('report_date'); ?>:</strong> <?php echo date('Y-m-d H:i'); ?></p>
<p class="mb-1"><strong><?php echo __('generated_by'); ?>:</strong> <?php echo htmlspecialchars($_SESSION['username'] ?? 'System'); ?></p>
</div>
<?php if ($report_type === 'consumption'): ?>
<div class="col-6 text-end">
<?php if ($filter_start || $filter_end): ?>
<p class="mb-1"><strong><?php echo __('period'); ?>:</strong>
<?php echo ($filter_start ? $filter_start : 'Begining') . ' - ' . ($filter_end ? $filter_end : 'Now'); ?>
</p>
<?php endif; ?>
<?php if ($filter_department):
$dept_name = '';
foreach($departments as $d) { if($d['id'] == $filter_department) $dept_name = $d['name_en']; }
?>
<p class="mb-1"><strong><?php echo __('department'); ?>:</strong> <?php echo htmlspecialchars($dept_name); ?></p>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>
<!-- Screen Header (Hidden on Print) -->
<div class="d-flex justify-content-between align-items-center mb-4 no-print">
<h2 class="mb-0 fw-bold text-dark"><?php echo __('inventory_reports'); ?></h2>
<div class="btn-group">
<a href="?report=low_stock" class="btn btn-outline-primary <?php echo $report_type === 'low_stock' ? 'active' : ''; ?>"><?php echo __('low_stock'); ?></a>
@ -107,13 +224,13 @@ if ($report_type === 'low_stock') {
</div>
<div class="card shadow-sm border-0">
<div class="card-header bg-white">
<div class="card-header bg-white no-print">
<h5 class="mb-0 fw-bold"><?php echo htmlspecialchars($title); ?></h5>
</div>
<div class="card-body">
<?php if ($report_type === 'consumption'): ?>
<form method="GET" class="row g-3 mb-4 border-bottom pb-4">
<form method="GET" class="row g-3 mb-4 border-bottom pb-4 no-print">
<input type="hidden" name="report" value="consumption">
<div class="col-md-3">
@ -169,7 +286,7 @@ if ($report_type === 'low_stock') {
if ($col === 'current_stock' || $col === 'total_quantity') {
echo number_format($row[$col]);
} elseif ($col === 'total_value' || $col === 'avg_cost' || $col === 'total_cost') {
echo formatCurrency($row[$col]);
echo format_currency($row[$col]);
} elseif ($col === 'status') {
if ($row['current_stock'] == 0) echo '<span class="badge bg-danger">Out of Stock</span>';
else echo '<span class="badge bg-warning text-dark">Low Stock</span>';
@ -193,14 +310,14 @@ if ($report_type === 'low_stock') {
<tr>
<td colspan="2" class="text-end"><?php echo __('total'); ?>:</td>
<td><?php echo number_format($grand_total_qty); ?></td>
<td><?php echo formatCurrency($grand_total_cost); ?></td>
<td><?php echo format_currency($grand_total_cost); ?></td>
</tr>
</tfoot>
<?php endif; ?>
</table>
</div>
<div class="mt-3 text-end">
<div class="mt-3 text-end no-print">
<button onclick="window.print()" class="btn btn-outline-secondary"><i class="bi bi-printer me-2"></i> <?php echo __('print_report'); ?></button>
</div>
</div>