feat: print single journalist data
This commit is contained in:
parent
d70e778a86
commit
c55e66eb13
@ -1137,6 +1137,8 @@ public function journalist(Request $request){
|
||||
->addColumn('action', function ($data) {
|
||||
$showUrl = route('dashboard.journalists.show', ['id' => encrypt_id($data->id)]);
|
||||
|
||||
$printUrl = route('dashboard.journalists.data.print', ['id' => encrypt_id($data->id)]);
|
||||
|
||||
$editUrl = route('dashboard.journalists.edit', ['id' => encrypt_id($data->id)]);
|
||||
|
||||
$deleteUrl = route('dashboard.journalists.destroy', ['id' => encrypt_id($data->id)]);
|
||||
@ -1149,6 +1151,10 @@ public function journalist(Request $request){
|
||||
<ul class="link-list-opt">
|
||||
<li><a href="'.$showUrl.'"><em class="icon ni ni-eye"></em><span>Detail</span></a></li>';
|
||||
|
||||
if (is_role([1])) {
|
||||
$dropdown .= '<li><a href="'.$printUrl.'" target="_blank"><em class="icon ni ni-printer"></em><span>Cetak</span></a></li>';
|
||||
}
|
||||
|
||||
if (is_role([1]) && $data->edit_status === '1' && $data->media->company->user->status === '1') {
|
||||
$dropdown .= '<li><a href="'.$processEditRequestCompanyUrl.'"><em class="icon ni ni-loader"></em><span>Proses peremohonan Edit</span></a></li>';
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
use App\Models\Journalist;
|
||||
use App\Models\Media;
|
||||
use App\Models\User;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@ -340,4 +341,14 @@ public function filter(Request $request)
|
||||
return redirect()->route('dashboard.journalists.index', $filterField);
|
||||
}
|
||||
|
||||
public function printData($id){
|
||||
|
||||
$journalist = Journalist::with(['media.company'])->findOrFail(decrypt_id($id));
|
||||
|
||||
|
||||
$pdf = Pdf::loadView('dashboard.journalists.print', compact('journalist'));
|
||||
|
||||
return $pdf->stream('perusahaan-'.slugify($journalist->name).'.pdf');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
183
resources/views/dashboard/journalists/print.blade.php
Normal file
183
resources/views/dashboard/journalists/print.blade.php
Normal file
@ -0,0 +1,183 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Data Jurnalis - {{ $journalist->name }}</title>
|
||||
<style>
|
||||
/* Styling tetap sama seperti sebelumnya */
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
body::before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-image: url('assets/defaults/simedkom-logo-circle.png');
|
||||
background-size: 300px auto;
|
||||
background-repeat: no-repeat;
|
||||
background-position: center center;
|
||||
opacity: 0.05;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
header .icon {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
header .icon img {
|
||||
width: 20% !important;
|
||||
max-width: 200px;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 80%;
|
||||
margin: 20px auto;
|
||||
padding: 20px;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.header {
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 2px solid #e0e0e0;
|
||||
}
|
||||
.header h2 {
|
||||
font-size: 24px;
|
||||
color: #007bff;
|
||||
}
|
||||
.header h3 {
|
||||
font-size: 20px;
|
||||
color: #555;
|
||||
}
|
||||
.row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 15px;
|
||||
padding: 5px 0;
|
||||
border-bottom: 1px solid #f1f1f1;
|
||||
}
|
||||
.row:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
.label {
|
||||
font-weight: bold;
|
||||
width: 35%;
|
||||
color: #444;
|
||||
}
|
||||
.value {
|
||||
width: 60%;
|
||||
color: #555;
|
||||
}
|
||||
.section {
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
.document {
|
||||
margin-top: 10px;
|
||||
padding: 5px 0;
|
||||
}
|
||||
.document img {
|
||||
max-width: 300px;
|
||||
margin-bottom: 10px;
|
||||
display: block;
|
||||
}
|
||||
.document a {
|
||||
color: #007bff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
.footer {
|
||||
text-align: right;
|
||||
font-size: 12px;
|
||||
color: #aaa;
|
||||
margin-top: 30px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div class="icon">
|
||||
<img src="{{ public_path('assets/defaults/simedkom-logo-full.png') }}" alt="">
|
||||
</div>
|
||||
</header>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h2>Data Jurnalis</h2>
|
||||
<h3>{{ $journalist->name }}</h3>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="row">
|
||||
<div class="label">Perusahaan</div>
|
||||
<div class="value">{{ $journalist->media->company->name }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">Media</div>
|
||||
<div class="value">{{ $journalist->media->name }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">Email</div>
|
||||
<div class="value">{{ $journalist->email }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">Nomor HP</div>
|
||||
<div class="value">{{ $journalist->phone_number }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">Kartu Pers</div>
|
||||
<div class="value">{{ $journalist->press_card ?? 'Tidak Ada' }}</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="label">Sertifikat UKW</div>
|
||||
<div class="value">{{ $journalist->ukw_certificate ?? 'Tidak Ada' }}</div>
|
||||
</div>
|
||||
@if ($journalist->edit_status == 3 && $journalist->edit_rejection_reason)
|
||||
<div class="row">
|
||||
<div class="label">Alasan Penolakan</div>
|
||||
<div class="value">{{ $journalist->edit_rejection_reason }}</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
{{-- Dokumen --}}
|
||||
<div class="section">
|
||||
<h4>Dokumen</h4>
|
||||
|
||||
@php
|
||||
$documents = [
|
||||
'Kartu Pers' => $journalist->press_card_doc,
|
||||
'Sertifikat UKW' => $journalist->ukw_certificate_doc,
|
||||
];
|
||||
@endphp
|
||||
|
||||
@foreach($documents as $label => $doc)
|
||||
<div class="document">
|
||||
<strong>{{ $label }}</strong><br>
|
||||
@if($doc)
|
||||
@php
|
||||
$ext = pathinfo($doc, PATHINFO_EXTENSION);
|
||||
@endphp
|
||||
@if(in_array(strtolower($ext), ['jpg', 'jpeg', 'png', 'gif', 'webp']))
|
||||
<img src="{{ public_path('storage/uploads/journalists/' . $doc) }}" alt="{{ "Tidak ada " . $label }}">
|
||||
@elseif(strtolower($ext) === 'pdf')
|
||||
<a href="{{ asset('storage/uploads/journalists/' . $doc) }}" target="_blank">Lihat Dokumen PDF</a>
|
||||
@else
|
||||
File tidak dikenali.
|
||||
@endif
|
||||
@else
|
||||
Tidak Ada Dokumen
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<div class="footer">
|
||||
Dicetak pada {{ now()->format('d-m-Y H:i') . ' - ' . $app->app_title }}
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -325,6 +325,7 @@
|
||||
|
||||
Route::post('/export', 'export')->name('export');
|
||||
Route::post('/filter', 'filter')->name('filter');
|
||||
Route::get('/{id}/print', 'printData')->name('data.print');
|
||||
});
|
||||
|
||||
Route::get('/data', [DatatableController::class, 'journalist'])->name('data');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user