317 lines
12 KiB
PHP
317 lines
12 KiB
PHP
<!DOCTYPE html>
|
|
<html dir="rtl" lang="fa">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>{{ $type === 'lab' ? 'آزمایش' : 'نسخه' }} - {{ $prescription->patientRecord?->full_name ?? '' }}</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: Tahoma, Arial, sans-serif;
|
|
direction: rtl;
|
|
background: #e0e0e0;
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
.print-toolbar {
|
|
background: #1f2937;
|
|
color: #fff;
|
|
padding: 10px 20px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
flex-wrap: wrap;
|
|
direction: rtl;
|
|
}
|
|
|
|
.print-toolbar span {
|
|
font-size: 14px;
|
|
color: #9ca3af;
|
|
margin-left: 6px;
|
|
}
|
|
|
|
.toolbar-btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 7px 16px;
|
|
border-radius: 6px;
|
|
font-size: 13px;
|
|
font-family: Tahoma, Arial, sans-serif;
|
|
font-weight: bold;
|
|
cursor: pointer;
|
|
text-decoration: none;
|
|
border: none;
|
|
}
|
|
|
|
.btn-print { background: #2563eb; color: #fff; }
|
|
.btn-active { background: #16a34a; color: #fff; cursor: default; }
|
|
.btn-admission{ background: #d97706; color: #fff; }
|
|
.btn-lab { background: #6b7280; color: #fff; }
|
|
.btn-back { background: #374151; color: #d1d5db; }
|
|
|
|
.toolbar-divider { flex: 1; }
|
|
.page-body {
|
|
padding: 20px;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: calc(100vh - 52px);
|
|
}
|
|
|
|
.prescription-container {
|
|
width: 210mm;
|
|
height: 148mm;
|
|
position: relative;
|
|
margin: 0 auto;
|
|
background: white;
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.prescription-bg {
|
|
width: 100%;
|
|
height: 100%;
|
|
object-fit: cover;
|
|
}
|
|
|
|
.content-overlay {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.patient-name {
|
|
position: absolute;
|
|
top: 58.7%;
|
|
right: 79%;
|
|
font-size: 12pt;
|
|
font-weight: bold;
|
|
color: #000;
|
|
direction: rtl;
|
|
white-space: nowrap;
|
|
text-align: right;
|
|
}
|
|
|
|
.patient-name.long-name { font-size: 9pt; }
|
|
.patient-name.very-long-name { font-size: 7pt; }
|
|
|
|
.patient-date {
|
|
position: absolute;
|
|
top: 68.4%;
|
|
left: 10%;
|
|
font-size: 12pt;
|
|
font-weight: normal;
|
|
color: #000;
|
|
direction: rtl;
|
|
}
|
|
|
|
.prescription-content {
|
|
position: absolute;
|
|
top: 3%;
|
|
left: 28%;
|
|
width: 73%;
|
|
height: 94%;
|
|
padding: 10px;
|
|
overflow: hidden;
|
|
pointer-events: auto;
|
|
}
|
|
|
|
@media print {
|
|
@page {
|
|
size: A5 landscape;
|
|
margin: 0;
|
|
}
|
|
|
|
* {
|
|
-webkit-print-color-adjust: exact !important;
|
|
print-color-adjust: exact !important;
|
|
color-adjust: exact !important;
|
|
}
|
|
|
|
.print-toolbar { display: none !important; }
|
|
|
|
html, body {
|
|
width: 210mm !important;
|
|
height: 148mm !important;
|
|
margin: 0 !important;
|
|
padding: 0 !important;
|
|
overflow: hidden !important;
|
|
background: white !important;
|
|
display: block !important;
|
|
}
|
|
|
|
.page-body {
|
|
display: block !important;
|
|
padding: 0 !important;
|
|
margin: 0 !important;
|
|
min-height: unset !important;
|
|
}
|
|
.prescription-container {
|
|
width: 210mm !important;
|
|
height: 148mm !important;
|
|
position: relative !important;
|
|
margin: 0 !important;
|
|
padding: 0 !important;
|
|
box-shadow: none !important;
|
|
overflow: hidden !important;
|
|
}
|
|
|
|
.prescription-bg {
|
|
width: 210mm !important;
|
|
height: 148mm !important;
|
|
object-fit: fill !important;
|
|
display: block !important;
|
|
}
|
|
|
|
.content-overlay {
|
|
width: 210mm !important;
|
|
height: 148mm !important;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="print-toolbar">
|
|
<span>نوع پرینت:</span>
|
|
|
|
@if ($type === 'prescription')
|
|
<span class="toolbar-btn btn-active">✓ پرینت نسخه</span>
|
|
<a class="toolbar-btn btn-admission"
|
|
href="{{ route('prescription.print.admission', $prescription) }}">
|
|
پرینت نسخه پذیرش
|
|
</a>
|
|
<a class="toolbar-btn btn-lab"
|
|
href="{{ route('prescription.print', ['prescription' => $prescription, 'type' => 'lab']) }}">
|
|
پرینت آزمایش
|
|
</a>
|
|
@else
|
|
<a class="toolbar-btn btn-print"
|
|
href="{{ route('prescription.print', $prescription) }}">
|
|
پرینت نسخه
|
|
</a>
|
|
<a class="toolbar-btn btn-admission"
|
|
href="{{ route('prescription.print.admission', $prescription) }}">
|
|
پرینت نسخه پذیرش
|
|
</a>
|
|
<span class="toolbar-btn btn-active">✓ پرینت آزمایش</span>
|
|
@endif
|
|
|
|
<div class="toolbar-divider"></div>
|
|
|
|
<button class="toolbar-btn btn-print" onclick="window.print()">🖨 پرینت</button>
|
|
<a class="toolbar-btn btn-back"
|
|
href="{{ route('filament.admin.resources.prescriptions.index') }}">
|
|
← بازگشت به لیست
|
|
</a>
|
|
</div>
|
|
|
|
{{-- ─── Print area ───────────────────────────────────────────── --}}
|
|
<div class="page-body">
|
|
<div class="prescription-container">
|
|
<img src="{{ asset('images/prescription_bg.jpg') }}" alt="نسخه" class="prescription-bg">
|
|
|
|
<div class="content-overlay">
|
|
@php
|
|
$patientName = $prescription->patientRecord?->full_name ?? '';
|
|
$nameLength = mb_strlen($patientName, 'UTF-8');
|
|
$nameClass = 'patient-name';
|
|
if ($nameLength > 20) {
|
|
$nameClass .= ' very-long-name';
|
|
} elseif ($nameLength > 14) {
|
|
$nameClass .= ' long-name';
|
|
}
|
|
|
|
$dateStr = $prescription->issue_date ?? '';
|
|
if ($dateStr && preg_match('/^\d{4}-\d{2}-\d{2}/', $dateStr)) {
|
|
try {
|
|
$dateStr = \Morilog\Jalali\Jalalian::fromCarbon(\Carbon\Carbon::parse($dateStr))->format('Y/m/d');
|
|
} catch (\Exception $e) {}
|
|
}
|
|
@endphp
|
|
|
|
<div class="{{ $nameClass }}">{{ $patientName }}</div>
|
|
<div class="patient-date">{{ $dateStr }}</div>
|
|
|
|
<div class="prescription-content">
|
|
@if ($type === 'lab')
|
|
<table style="width:100%;direction:ltr;font-size:20px;color:#333;table-layout:fixed;">
|
|
@foreach (['CBC','PT/PTT/INR','BS','HIV/Ab HBS/Ag Hcv/Ab'] as $test)
|
|
<tr>
|
|
<td style="padding:8px 2px 8px 0;width:3%;font-weight:bold;">-</td>
|
|
<td style="padding:8px 5px;width:97%;">{!! $test !!}</td>
|
|
</tr>
|
|
@endforeach
|
|
</table>
|
|
@else
|
|
@php
|
|
$content = $prescription->content ?? '';
|
|
preg_match_all('/<li[^>]*>(.*?)<\/li>/s', $content, $m);
|
|
$lines = $m[1] ?? [];
|
|
if (empty($lines)) {
|
|
$cleaned = preg_replace('/<br\s*\/?>/i', "\n", $content);
|
|
$lines = explode("\n", strip_tags($cleaned));
|
|
}
|
|
$lines = array_values(array_filter(
|
|
array_map(fn ($l) => html_entity_decode(trim(strip_tags($l)), ENT_QUOTES, 'UTF-8'), $lines)
|
|
));
|
|
@endphp
|
|
<table style="width:100%;direction:ltr;font-size:20px;color:#333;border-collapse:collapse;table-layout:fixed;">
|
|
@foreach ($lines as $line)
|
|
@php
|
|
$parts = preg_split('/\s+/', trim($line));
|
|
$type_str = array_shift($parts);
|
|
$freq = !empty($parts) ? array_pop($parts) : '';
|
|
$count = $dose = '';
|
|
$nameParts = [];
|
|
foreach ($parts as $p) {
|
|
if (str_starts_with($p, '#') && $count === '') { $count = $p; }
|
|
elseif (preg_match('/^\d+(mg|g|ml|mcg|iu)$/i', $p) && $dose === '') { $dose = $p; }
|
|
else { $nameParts[] = $p; }
|
|
}
|
|
$drugName = implode(' ', $nameParts);
|
|
@endphp
|
|
<tr>
|
|
<td style="padding:8px 2px 8px 10px;width:3%;font-weight:bold;">-</td>
|
|
<td style="padding:8px 10px 8px 5px;width:12%;white-space:nowrap;">{{ $type_str }}</td>
|
|
<td style="padding:8px 5px;width:33%;">{{ $drugName }}</td>
|
|
<td style="padding:8px 5px;width:18%;">{{ $dose }}</td>
|
|
<td style="padding:8px 5px;width:12%;">{{ $count }}</td>
|
|
<td style="padding:8px 0 8px 5px;width:10%;">{{ $freq }}</td>
|
|
</tr>
|
|
@endforeach
|
|
</table>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
window.onload = function () {
|
|
const userConfirmed = confirm(
|
|
'لطفاً تنظیمات پرینت را به این صورت انجام دهید:\n\n' +
|
|
'✅ Paper size: A5\n' +
|
|
'✅ Orientation: Landscape (افقی)\n' +
|
|
'✅ Margins: None (بدون حاشیه)\n' +
|
|
'✅ Scale: 100%\n' +
|
|
'✅ Background graphics: ON (فعال)\n\n' +
|
|
'آیا آماده پرینت هستید؟'
|
|
);
|
|
if (userConfirmed) {
|
|
window.print();
|
|
}
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|