Compare commits
10
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21722479d0 | ||
|
|
cda9cbec03 | ||
|
|
5c682476e0 | ||
|
|
a60842b207 | ||
|
|
fb558bdce9 | ||
|
|
911064805b | ||
|
|
f06fcdda98 | ||
|
|
a6db6ba6ff | ||
|
|
8670f786ea | ||
|
|
7494e8b9b1 |
@@ -608,7 +608,7 @@ class ParentStudentController extends Controller
|
|||||||
] : null,
|
] : null,
|
||||||
'evidences' => $v->evidences->map(fn ($e) => [
|
'evidences' => $v->evidences->map(fn ($e) => [
|
||||||
'id' => $e->id,
|
'id' => $e->id,
|
||||||
'url' => url($e->file_path),
|
'url' => url('storage/' . $e->file_path),
|
||||||
'mime_type' => $e->mime_type,
|
'mime_type' => $e->mime_type,
|
||||||
])->all(),
|
])->all(),
|
||||||
];
|
];
|
||||||
@@ -653,7 +653,7 @@ class ParentStudentController extends Controller
|
|||||||
'status' => $sp->status,
|
'status' => $sp->status,
|
||||||
'total_points_at_time' => $sp->total_points_at_time,
|
'total_points_at_time' => $sp->total_points_at_time,
|
||||||
'violations_included' => $sp->violations_included,
|
'violations_included' => $sp->violations_included,
|
||||||
'file_url' => $sp->file_path ? url($sp->file_path) : null,
|
'file_url' => $sp->file_path ? url('storage/' . $sp->file_path) : null,
|
||||||
'created_at' => $sp->created_at?->toISOString(),
|
'created_at' => $sp->created_at?->toISOString(),
|
||||||
'delivered_at' => $sp->delivered_at?->toISOString(),
|
'delivered_at' => $sp->delivered_at?->toISOString(),
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class ViolationService
|
|||||||
'sp_threshold_id' => $threshold->id,
|
'sp_threshold_id' => $threshold->id,
|
||||||
'generated_by' => $userId,
|
'generated_by' => $userId,
|
||||||
'letter_number' => sprintf('%s/%s/%s/%s',
|
'letter_number' => sprintf('%s/%s/%s/%s',
|
||||||
$threshold->slug,
|
strtoupper($threshold->slug),
|
||||||
str_pad((string) $letterCount, 3, '0', STR_PAD_LEFT),
|
str_pad((string) $letterCount, 3, '0', STR_PAD_LEFT),
|
||||||
date('m'),
|
date('m'),
|
||||||
date('Y')
|
date('Y')
|
||||||
@@ -119,6 +119,12 @@ class ViolationService
|
|||||||
'status' => 'draft',
|
'status' => 'draft',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Generate PDF resmi (kop surat) agar wali bisa melihat/unduh di SiMURID
|
||||||
|
$pdfPath = \App\Support\SpLetterPdf::generate($letter);
|
||||||
|
if ($pdfPath) {
|
||||||
|
$letter->update(['file_path' => $pdfPath]);
|
||||||
|
}
|
||||||
|
|
||||||
// Notifikasi + FCM push ke wali murid (SP baru)
|
// Notifikasi + FCM push ke wali murid (SP baru)
|
||||||
$this->notifyParentsOfSp($letter);
|
$this->notifyParentsOfSp($letter);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Support;
|
||||||
|
|
||||||
|
use App\Models\Setting;
|
||||||
|
use App\Models\SpLetter;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generator PDF surat peringatan resmi (kop surat + tanda tangan).
|
||||||
|
* Dipakai saat SP dibuat agar wali murid bisa melihat/unduh lewat SiMURID.
|
||||||
|
*/
|
||||||
|
class SpLetterPdf
|
||||||
|
{
|
||||||
|
public static function generate(SpLetter $spLetter): ?string
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$spLetter->load(['student', 'spThreshold', 'generator']);
|
||||||
|
|
||||||
|
$school = [
|
||||||
|
'name' => Setting::getValue('school_name', 'SMK'),
|
||||||
|
'address' => Setting::getValue('school_address', ''),
|
||||||
|
'phone' => Setting::getValue('school_phone', ''),
|
||||||
|
'logo' => Setting::getValue('school_logo', ''),
|
||||||
|
'kop_logo' => Setting::getValue('kop_logo', ''),
|
||||||
|
'government' => Setting::getValue('school_government', 'PEMERINTAH PROVINSI JAWA TIMUR'),
|
||||||
|
'agency' => Setting::getValue('school_agency', 'DINAS PENDIDIKAN'),
|
||||||
|
'full_name' => Setting::getValue('school_full_name', Setting::getValue('school_name', 'SMK')),
|
||||||
|
'address_detail' => Setting::getValue('school_address_detail', ''),
|
||||||
|
'website_email' => Setting::getValue('school_website_email', ''),
|
||||||
|
'postal' => Setting::getValue('school_postal', ''),
|
||||||
|
'kepala_sekolah' => Setting::getValue('kepala_sekolah_name', ''),
|
||||||
|
'kepala_sekolah_nip' => Setting::getValue('kepala_sekolah_nip', ''),
|
||||||
|
'place' => Setting::getValue('school_place', 'Wonorejo'),
|
||||||
|
];
|
||||||
|
|
||||||
|
$pdf = Pdf::loadView('sp-letters.print', [
|
||||||
|
'spLetter' => $spLetter,
|
||||||
|
'school' => $school,
|
||||||
|
'forPdf' => true,
|
||||||
|
])->setPaper('folio'); // F4 = 210 x 330 mm
|
||||||
|
|
||||||
|
$path = 'sp-letters/sp-' . $spLetter->id . '.pdf';
|
||||||
|
Storage::disk('public')->put($path, $pdf->output());
|
||||||
|
|
||||||
|
return $path;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
report($e);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
.violation-table th, .violation-table td { border: 1px solid #000; padding: 6px 10px; text-align: left; font-size: 11pt; }
|
.violation-table th, .violation-table td { border: 1px solid #000; padding: 6px 10px; text-align: left; font-size: 11pt; }
|
||||||
.violation-table th { font-weight: bold; }
|
.violation-table th { font-weight: bold; }
|
||||||
.violation-table .total-row td { font-weight: bold; }
|
.violation-table .total-row td { font-weight: bold; }
|
||||||
.signature { margin-top: 50px; padding-left: 5em; }
|
.signature { margin-top: 50px; padding-left: 24em; }
|
||||||
.signature .date { text-align: left; margin-bottom: 5px; }
|
.signature .date { text-align: left; margin-bottom: 5px; }
|
||||||
.signature .title { text-align: left; margin-bottom: 60px; }
|
.signature .title { text-align: left; margin-bottom: 60px; }
|
||||||
.signature .name { text-align: left; font-weight: bold; }
|
.signature .name { text-align: left; font-weight: bold; }
|
||||||
@@ -40,9 +40,9 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td class="kop-logo">
|
<td class="kop-logo">
|
||||||
@if (! empty($school['kop_logo']) && file_exists(public_path('storage/'.$school['kop_logo'])))
|
@if (! empty($school['kop_logo']) && file_exists(public_path('storage/'.$school['kop_logo'])))
|
||||||
<img src="{{ asset('storage/'.$school['kop_logo']) }}" alt="logo">
|
<img src="{{ isset($forPdf) && $forPdf ? public_path('storage/'.$school['kop_logo']) : asset('storage/'.$school['kop_logo']) }}" alt="logo">
|
||||||
@elseif (! empty($school['logo']) && file_exists(public_path('storage/'.$school['logo'])))
|
@elseif (! empty($school['logo']) && file_exists(public_path('storage/'.$school['logo'])))
|
||||||
<img src="{{ asset('storage/'.$school['logo']) }}" alt="logo">
|
<img src="{{ isset($forPdf) && $forPdf ? public_path('storage/'.$school['logo']) : asset('storage/'.$school['logo']) }}" alt="logo">
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
<td class="kop-text">
|
<td class="kop-text">
|
||||||
@@ -60,16 +60,16 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="letter-number">
|
<div class="letter-number">
|
||||||
<p style="margin-bottom: 0;">SURAT PERINGATAN</p>
|
<p style="margin-bottom: 0;"><u>SURAT PERINGATAN</u></p>
|
||||||
<p style="margin-top: 0;">Nomor: {{ $spLetter->letter_number }}</p>
|
<p style="margin-top: 0;">Nomor: {{ $spLetter->letter_number }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="to-title">
|
<div class="to-title">
|
||||||
<p style="margin-bottom: 0;">Kepada Yth. Bapak/Ibu/Wali</p>
|
<p style="margin-bottom: 0;">Kepada Yth. Bapak/Ibu/Wali Murid</p>
|
||||||
<p style="margin-top: 0; margin-bottom: 0;"><strong>{{ strtoupper($spLetter->student->full_name) }}</strong></p>
|
<p style="margin-top: 0; margin-bottom: 0;"><strong>{{ strtoupper($spLetter->student->full_name) }}</strong></p>
|
||||||
<p style="margin-top: 0; margin-bottom: 0;">Kelas: {{ $spLetter->student->class_name ?? '-' }}</p>
|
<p style="margin-top: 0; margin-bottom: 0;">Kelas: {{ $spLetter->student->class_name ?? '-' }}</p>
|
||||||
<p style="margin-top: 0; margin-bottom: 0;">NISN: {{ $spLetter->student->nisn }}</p>
|
<p style="margin-top: 0; margin-bottom: 0;">NISN: {{ $spLetter->student->nisn }}</p>
|
||||||
<p style="margin-top: 0;">di tempat</p>
|
<p style="margin-top: 0;">di Tempat</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="body-text">
|
<div class="body-text">
|
||||||
@@ -130,8 +130,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@if (! isset($forPdf) || ! $forPdf)
|
||||||
<script>
|
<script>
|
||||||
window.onload = function() { window.print(); };
|
window.onload = function() { window.print(); };
|
||||||
</script>
|
</script>
|
||||||
|
@endif
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user