feat: print data
This commit is contained in:
parent
f05407b0ef
commit
64f0eae22e
@ -2294,6 +2294,8 @@ public function mediaMonitoring(Request $request){
|
|||||||
->addColumn('action', function ($data) {
|
->addColumn('action', function ($data) {
|
||||||
$showUrl = route('dashboard.media.monitorings.show', ['id' => encrypt_id($data->id)]);
|
$showUrl = route('dashboard.media.monitorings.show', ['id' => encrypt_id($data->id)]);
|
||||||
|
|
||||||
|
$printUrl = route('dashboard.media.monitorings.print', ['id' => encrypt_id($data->id)]);
|
||||||
|
|
||||||
$addIssueUrl = route('dashboard.issue.managements.create', ['media_monitoring' => encrypt_id($data->id)]);
|
$addIssueUrl = route('dashboard.issue.managements.create', ['media_monitoring' => encrypt_id($data->id)]);
|
||||||
|
|
||||||
$editUrl = route('dashboard.media.monitorings.edit', ['id' => encrypt_id($data->id)]);
|
$editUrl = route('dashboard.media.monitorings.edit', ['id' => encrypt_id($data->id)]);
|
||||||
@ -2306,6 +2308,10 @@ public function mediaMonitoring(Request $request){
|
|||||||
<ul class="link-list-opt">
|
<ul class="link-list-opt">
|
||||||
<li><a href="'.$showUrl.'"><em class="icon ni ni-eye"></em><span>Detail</span></a></li>';
|
<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','2']) && !$data->issue) {
|
if (is_role(['1','2']) && !$data->issue) {
|
||||||
$dropdown .= '<li><a href="'.$addIssueUrl.'"><em class="icon ni ni-plus"></em><span>Tambah Manajemen Isu</span></a></li>';
|
$dropdown .= '<li><a href="'.$addIssueUrl.'"><em class="icon ni ni-plus"></em><span>Tambah Manajemen Isu</span></a></li>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\MediaMonitoringRequest;
|
use App\Http\Requests\MediaMonitoringRequest;
|
||||||
use App\Models\MediaMonitoring;
|
use App\Models\MediaMonitoring;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
@ -153,4 +154,14 @@ public function export(Request $request)
|
|||||||
|
|
||||||
return Excel::download(new MediaMonitoringExport($news_title, $channel, $issue_status, $input_year, $input_month, $input_date, $release_year, $release_month, $release_date), 'media-monitoring-'.$formattedNow.'.xlsx');
|
return Excel::download(new MediaMonitoringExport($news_title, $channel, $issue_status, $input_year, $input_month, $input_date, $release_year, $release_month, $release_date), 'media-monitoring-'.$formattedNow.'.xlsx');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function printData($id){
|
||||||
|
|
||||||
|
$mediaMonitoring = MediaMonitoring::with(['enhancer', 'issue'])->findOrFail(decrypt_id($id));
|
||||||
|
|
||||||
|
|
||||||
|
$pdf = Pdf::loadView('dashboard.media-monitorings.print', compact('mediaMonitoring'));
|
||||||
|
|
||||||
|
return $pdf->stream(slugify('monitoring media '. $mediaMonitoring->code).'.pdf');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
228
resources/views/dashboard/media-monitorings/print.blade.php
Normal file
228
resources/views/dashboard/media-monitorings/print.blade.php
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="id">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Data Monitoring Media</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: #3A59D1;
|
||||||
|
}
|
||||||
|
.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 .content {
|
||||||
|
background-color: rgba(241, 237, 237, 0.363);
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center; /* ini yang bikin vertikal align tengah */
|
||||||
|
text-align: center;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.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>Monitoring Media</h2>
|
||||||
|
{{-- <h3>{{ $mediaMonitoring->content_theme }}</h3> --}}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section">
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Kode</div>
|
||||||
|
<div class="value">{{ $mediaMonitoring->code }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Nama Media</div>
|
||||||
|
<div class="value">{{ $mediaMonitoring->media_name }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Judul</div>
|
||||||
|
<div class="value">{{ $mediaMonitoring->title }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Kanal</div>
|
||||||
|
<div class="value">{{ ucfirst($mediaMonitoring->channel) }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Tema</div>
|
||||||
|
<div class="value">{{ $mediaMonitoring->theme }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Penulis</div>
|
||||||
|
<div class="value">{{ $mediaMonitoring->writter }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Link</div>
|
||||||
|
<div class="value">
|
||||||
|
@if (filled(($mediaMonitoring->link)))
|
||||||
|
<a href="{{$mediaMonitoring->link}}" target="_blank">{{$mediaMonitoring->link}}</a>
|
||||||
|
@else
|
||||||
|
<i>Tidak ada link</i>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Halaman Berita</div>
|
||||||
|
<div class="value">{{ $mediaMonitoring->news_page }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Influencer</div>
|
||||||
|
<div class="value">{{ $mediaMonitoring->influencer }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Keyword</div>
|
||||||
|
<div class="value">{{ $mediaMonitoring->keyword }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Status Isu</div>
|
||||||
|
<div class="value">{{ $mediaMonitoring->issue ? 'Sudah ' : 'Belum ' }} Ditambahkan</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Tanggal Rilis</div>
|
||||||
|
<div class="value">{{ idn_date($mediaMonitoring->release_date, format: 'l, d F Y') }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Tanggal Input</div>
|
||||||
|
<div class="value">{{ idn_date($mediaMonitoring->created_at, 'l, d F Y') }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="label">Diinput Oleh</div>
|
||||||
|
<div class="value">{{ $mediaMonitoring->enhancer?->name ?? 'Admin' }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{-- Dokumen --}}
|
||||||
|
<div class="section">
|
||||||
|
|
||||||
|
@php
|
||||||
|
$documents = [
|
||||||
|
'Gambar' => $mediaMonitoring->image,
|
||||||
|
];
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
@foreach($documents as $label => $doc)
|
||||||
|
<div class="document">
|
||||||
|
<strong>{{ $label }}</strong><br>
|
||||||
|
<div class="content">
|
||||||
|
@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/media-monitorings/' . $doc) }}" alt="{{ "Tidak ada " . $label }}">
|
||||||
|
@elseif(strtolower($ext) === 'pdf')
|
||||||
|
<a href="{{ asset('storage/uploads/media-monitorings/' . $doc) }}" target="_blank">Lihat Dokumen PDF</a>
|
||||||
|
@else
|
||||||
|
File tidak dikenali.
|
||||||
|
@endif
|
||||||
|
@else
|
||||||
|
Tidak Ada Dokumen
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="footer">
|
||||||
|
Dicetak pada {{ now()->format('d-m-Y H:i') . ' - ' . $app->app_title }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -1076,7 +1076,7 @@
|
|||||||
language: datatableLanguage,
|
language: datatableLanguage,
|
||||||
// responsive: true,
|
// responsive: true,
|
||||||
autoWidth: false,
|
autoWidth: false,
|
||||||
order: [[11, 'desc']],
|
order: [[13, 'desc']],
|
||||||
pagingType: "simple",
|
pagingType: "simple",
|
||||||
lengthMenu: [[10, 25, 50, 100, -1], ['Tampilkan 10 data', 'Tampilkan 25 data', 'Tampilkan 50 data', 'Tampilkan 100 data', 'Tampilkan semua']],
|
lengthMenu: [[10, 25, 50, 100, -1], ['Tampilkan 10 data', 'Tampilkan 25 data', 'Tampilkan 50 data', 'Tampilkan 100 data', 'Tampilkan semua']],
|
||||||
scrollX: true
|
scrollX: true
|
||||||
|
|||||||
@ -520,6 +520,7 @@
|
|||||||
|
|
||||||
Route::post('/export', 'export')->name('export');
|
Route::post('/export', 'export')->name('export');
|
||||||
Route::post('/filter', 'filter')->name('filter');
|
Route::post('/filter', 'filter')->name('filter');
|
||||||
|
Route::get('/print/{id}', 'printData')->name('print');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::get('/data', [DatatableController::class, 'mediaMonitoring'])->name('data');
|
Route::get('/data', [DatatableController::class, 'mediaMonitoring'])->name('data');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user