feat: print single company data

This commit is contained in:
myuqinurrohman 2025-04-15 09:36:29 +07:00
parent cea6399724
commit 3e90480179
6 changed files with 264 additions and 16 deletions

View File

@ -10,6 +10,7 @@
use App\Models\LoginHistory;
use App\Models\Role;
use App\Models\User;
use Barryvdh\DomPDF\Facade\Pdf;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
@ -303,4 +304,14 @@ public function filter(Request $request){
return redirect()->route('dashboard.companies.index', $filterField);
}
public function printData($id){
$company = Company::with(['user.role'])->findOrFail(decrypt_id($id));
$pdf = Pdf::loadView('dashboard.companies.print', compact('company'));
return $pdf->stream('perusahaan-'.slugify($company->name).'.pdf');
}
}

View File

@ -789,6 +789,8 @@ public function company(Request $request){
->addColumn('action', function ($data) {
$showUrl = route('dashboard.companies.show', ['id' => encrypt_id($data->user->id), 'type' => 'company']);
$printUrl = route('dashboard.companies.data.print', ['id' => encrypt_id($data->id)]);
$deleteUrl = route('dashboard.companies.destroy', ['id' => encrypt_id($data->id)]);
$processAccountCompanyUrl = route('dashboard.companies.process', ['id' => encrypt_id($data->user->id), 'type' => 'company', 'category' => 'account-status']);
@ -801,6 +803,10 @@ public function company(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->user->status === '0') {
$dropdown .= '<li><a href="'.$processAccountCompanyUrl.'"><em class="icon ni ni-loader"></em><span>Proses Perusahaan</span></a></li>';
}

View File

@ -28,21 +28,21 @@ public function rules(): array
'company_address' => ['required'],
'company_director_name' => ['required', 'max:100'],
'company_director_nik' => ['required', 'max:100'],
'company_director_nik_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
'company_director_nik_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
'company_deed_incorporation' => ['nullable', 'max:100'],
'company_deed_incorporation_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
'company_deed_incorporation_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
'company_trade_license' => ['nullable', 'max:100'],
'company_trade_license_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
'company_trade_license_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
'company_tax_id_number' => ['nullable', 'max:100'],
'company_tax_id_number_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
'company_tax_id_number_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
'company_taxable_enterprise' => ['nullable', 'max:100'],
'company_taxable_enterprise_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
'company_taxable_enterprise_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
'company_annual_tax_return' => ['nullable', 'max:100'],
'company_annual_tax_return_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
'company_annual_tax_return_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
'company_domicile_certificate' => ['nullable', 'max:100'],
'company_domicile_certificate_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
'company_domicile_certificate_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
'company_profile' => ['nullable', 'max:100'],
'company_profile_doc' => ['nullable', 'file', 'mimes:pdf', 'max:2048'],
'company_profile_doc' => ['nullable', 'file', 'mimes:pdf,jpeg,png,jpg,gif', 'max:2048'],
];
}

View File

@ -138,7 +138,7 @@
</label>
<div class="form-control-wrap">
<div class="form-file">
<input type="file" accept="application/pdf" class="form-file-input" id="company_director_nik_doc" name="company_director_nik_doc">
<input type="file" accept="application/pdf,image/*" class="form-file-input" id="company_director_nik_doc" name="company_director_nik_doc">
<label class="form-file-label {{!filled($user->company->director_nik_doc) ? 'text-danger' : ''}}" for="company_director_nik_doc">{{$user->company->director_nik_doc ?? 'Belum ditambahkan'}}</label>
</div>
</div>
@ -160,7 +160,7 @@
</label>
<div class="form-control-wrap">
<div class="form-file">
<input type="file" accept="application/pdf" class="form-file-input" id="company_deed_incorporation_doc" name="company_deed_incorporation_doc">
<input type="file" accept="application/pdf,image/*" class="form-file-input" id="company_deed_incorporation_doc" name="company_deed_incorporation_doc">
<label class="form-file-label {{!filled($user->company->deed_incorporation_doc) ? 'text-danger' : ''}}" for="company_deed_incorporation_doc">{{$user->company->deed_incorporation_doc ?? 'Belum ditambahkan'}}</label>
</div>
</div>
@ -182,7 +182,7 @@
</label>
<div class="form-control-wrap">
<div class="form-file">
<input type="file" accept="application/pdf" class="form-file-input" id="company_annual_tax_return_doc" name="company_annual_tax_return_doc">
<input type="file" accept="application/pdf,image/*" class="form-file-input" id="company_annual_tax_return_doc" name="company_annual_tax_return_doc">
<label class="form-file-label {{!filled($user->company->annual_tax_return_doc) ? 'text-danger' : ''}}" for="company_annual_tax_return_doc">{{$user->company->annual_tax_return_doc ?? 'Belum ditambahkan'}}</label>
</div>
</div>
@ -204,7 +204,7 @@
</label>
<div class="form-control-wrap">
<div class="form-file">
<input type="file" accept="application/pdf" class="form-file-input" id="company_tax_id_number_doc" name="company_tax_id_number_doc">
<input type="file" accept="application/pdf,image/*" class="form-file-input" id="company_tax_id_number_doc" name="company_tax_id_number_doc">
<label class="form-file-label {{!filled($user->company->tax_id_number_doc) ? 'text-danger' : ''}}" for="company_tax_id_number_doc">{{$user->company->tax_id_number_doc ?? 'Belum ditambahkan'}}</label>
</div>
</div>
@ -226,7 +226,7 @@
</label>
<div class="form-control-wrap">
<div class="form-file">
<input type="file" accept="application/pdf" class="form-file-input" id="company_taxable_enterprise_doc" name="company_taxable_enterprise_doc">
<input type="file" accept="application/pdf,image/*" class="form-file-input" id="company_taxable_enterprise_doc" name="company_taxable_enterprise_doc">
<label class="form-file-label {{!filled($user->company->taxable_enterprise_doc) ? 'text-danger' : ''}}" for="company_taxable_enterprise_doc">{{$user->company->taxable_enterprise_doc ?? 'Belum ditambahkan'}}</label>
</div>
</div>
@ -248,7 +248,7 @@
</label>
<div class="form-control-wrap">
<div class="form-file">
<input type="file" accept="application/pdf" class="form-file-input" id="company_domicile_certificate_doc" name="company_domicile_certificate_doc">
<input type="file" accept="application/pdf,image/*" class="form-file-input" id="company_domicile_certificate_doc" name="company_domicile_certificate_doc">
<label class="form-file-label {{!filled($user->company->domicile_certificate_doc) ? 'text-danger' : ''}}" for="company_domicile_certificate_doc">{{$user->company->domicile_certificate_doc ?? 'Belum ditambahkan'}}</label>
</div>
</div>
@ -270,7 +270,7 @@
</label>
<div class="form-control-wrap">
<div class="form-file">
<input type="file" accept="application/pdf" class="form-file-input" id="company_trade_license_doc" name="company_trade_license_doc">
<input type="file" accept="application/pdf,image/*" class="form-file-input" id="company_trade_license_doc" name="company_trade_license_doc">
<label class="form-file-label {{!filled($user->company->trade_license_doc) ? 'text-danger' : ''}}" for="company_trade_license_doc">{{$user->company->trade_license_doc ?? 'Belum ditambahkan'}}</label>
</div>
</div>
@ -292,7 +292,7 @@
</label>
<div class="form-control-wrap">
<div class="form-file">
<input type="file" accept="application/pdf" class="form-file-input" id="company_profile_doc" name="company_profile_doc">
<input type="file" accept="application/pdf,image/*" class="form-file-input" id="company_profile_doc" name="company_profile_doc">
<label class="form-file-label {{!filled($user->company->profile_doc) ? 'text-danger' : ''}}" for="company_profile_doc">{{$user->company->profile_doc ?? 'Belum ditambahkan'}}</label>
</div>
</div>

View File

@ -0,0 +1,229 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<title>Data Perusahaan - {{ $company->name }}</title>
<style>
/* body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
font-size: 14px;
color: #333;
margin: 0;
padding: 0;
background-image: url('assets/defaults/simedkom-logo-circle.png');
background-size: contain;
background-position: center;
background-repeat: no-repeat;
} */
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;
}
.value span {
color: #007bff;
}
.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;
}
.footer a {
color: #007bff;
text-decoration: none;
}
</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 Perusahaan</h2>
<h3>{{ $company->name }}</h3>
</div>
<div class="section">
<div class="row">
<div class="label">Media</div>
<div class="value">{{ $company->media->name }}</div>
</div>
<div class="row">
<div class="label">Direktur</div>
<div class="value">{{ $company->director_name }}</div>
</div>
<div class="row">
<div class="label">NIK Direktur</div>
<div class="value">{{ $company->director_nik }}</div>
</div>
<div class="row">
<div class="label">Alamat</div>
<div class="value">{{ $company->address }}</div>
</div>
<div class="row">
<div class="label">Email</div>
<div class="value">{{ $company->email }}</div>
</div>
<div class="row">
<div class="label">NPWP</div>
<div class="value">{{ $company->tax_id_number }}</div>
</div>
<div class="row">
<div class="label">SIUP</div>
<div class="value">{{ $company->trade_license }}</div>
</div>
<div class="row">
<div class="label">PKP</div>
<div class="value">{{ $company->taxable_enterprise ?? 'Tidak Ada' }}</div>
</div>
<div class="row">
<div class="label">SPT Tahunan</div>
<div class="value">{{ $company->annual_tax_return ?? 'Tidak Ada' }}</div>
</div>
<div class="row">
<div class="label">Suket Domisili</div>
<div class="value">{{ $company->domicile_certificate ?? 'Tidak Ada' }}</div>
</div>
<div class="row">
<div class="label">Profile</div>
<div class="value">{{ $company->profile ?? 'Tidak Ada' }}</div>
</div>
<div class="row">
<div class="label">Status</div>
<div class="value">{{ get_user_status($company->user->status) }}</div>
</div>
<div class="row">
<div class="label">Status Edit</div>
<div class="value">{{ get_edit_status($company->edit_status) }}</div>
</div>
</div>
{{-- Dokumen --}}
<div class="section">
<h4>Dokumen</h4>
@php
$documents = [
'NIK Direktur' => $company->director_nik_doc,
'Akta Pendirian' => $company->deed_incorporation_doc,
'SIUP' => $company->trade_license_doc,
'NPWP' => $company->tax_id_number_doc,
'PKP' => $company->taxable_enterprise_doc,
'SPT Tahunan' => $company->annual_tax_return_doc,
'Suket Domisili' => $company->domicile_certificate_doc,
'Profile' => $company->profile_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/companies/' . $doc) }}" alt="{{ "Tidak ada " .$label }}">
@elseif(strtolower($ext) === 'pdf')
<a href="{{ asset('storage/uploads/companies/' . $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>

View File

@ -252,6 +252,7 @@
Route::get('/{id}/{type}/show', 'show')->name('show');
Route::get('/create', 'create')->name('create');
Route::post('/', 'store')->name('store');
Route::get('/edit/request', 'editRequest')->name('edit.request');
Route::put('/edit/request', 'editRequestAction')->name('edit.request.action');
Route::get('/edit', 'edit')->name('edit');
@ -264,6 +265,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, 'company'])->name('data');