Skip to content

Commit

Permalink
RegisterOf: pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
dpslwk committed Aug 24, 2024
1 parent 403fa28 commit f68272b
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 53 deletions.
15 changes: 15 additions & 0 deletions app/Http/Controllers/Governance/RegisterOfDirectorsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,24 @@ public function pdf()
{
$registerOfDirectors = $this->registerOfDirectorsRepository->findAll();

$serviceAddress = str(config('branding.company_name'))->append('<br>')
->append(config('branding.space_address_1'))->append('<br>')
->append(config('branding.space_address_2'))->append('<br>');

if (config('branding.space_address_3')) {
$serviceAddress->append(config('branding.space_address_3'))->append('<br>');
}
$serviceAddress->append(config('branding.space_city'))->append('<br>');

if (config('branding.space_county')) {
$serviceAddress->append(config('branding.space_county'))->append('<br>');
}
$serviceAddress->append(config('branding.space_postcode'));

$viewVars = [
'registerOfDirectors' => $registerOfDirectors,
'numPagesTotal' => 999,
'serviceAddress' => $serviceAddress,
];

// ini_set('memory_limit', '-1');
Expand Down
30 changes: 28 additions & 2 deletions app/Http/Controllers/Governance/RegisterOfMembersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,42 @@ public function pdf()
{
$registerOfMembers = $this->registerOfMembersRepository->findAll();

$records = collect($registerOfMembers)->map(fn ($record) => [
'fullname' => $record->getFullname(),
'startedAt' => $record->getStartedAt()->toDateString(),
'endedAt' => $record->getEndedAt()?->toDateString(),
]);

unset($registerOfMembers);
gc_collect_cycles();

$serviceAddress = str(config('branding.company_name'))->append('<br>')
->append(config('branding.space_address_1'))->append('<br>')
->append(config('branding.space_address_2'))->append('<br>');

if (config('branding.space_address_3')) {
$serviceAddress->append(config('branding.space_address_3'))->append('<br>');
}
$serviceAddress->append(config('branding.space_city'))->append('<br>');

if (config('branding.space_county')) {
$serviceAddress->append(config('branding.space_county'))->append('<br>');
}
$serviceAddress->append(config('branding.space_postcode'));

$viewVars = [
'registerOfMembers' => $registerOfMembers,
'registerOfMembers' => $records,
'numPagesTotal' => 999,
'serviceAddress' => $serviceAddress,
];

// ini_set('memory_limit', '-1');
ini_set('memory_limit', '-1');
$pdf = Pdf::setPaper('a4')
->loadView('pdfs.governance.registerOfMembers', $viewVars);
$pdf->render();
$viewVars['numPagesTotal'] = $pdf->getCanvas()->get_page_count();
unset($pdf);
gc_collect_cycles();

$pdf = Pdf::setPaper('a4')
->loadView('pdfs.governance.registerOfMembers', $viewVars);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
</div>
</div>
@endcan --}}
<div class="row mb-2">
<div class="col">
<a href="{{ route('governance.registerOfDirectors.pdf') }}" class="btn btn-primary">View PDF</a>
</div>
</div>
<div class="row">
<div class="col">
<div class="pagination-links">
Expand Down
5 changes: 5 additions & 0 deletions resources/views/governance/registerOfMembers/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
</div>
</div>
@endcan --}}
<div class="row mb-2">
<div class="col">
<a href="{{ route('governance.registerOfMembers.pdf') }}" class="btn btn-primary">View PDF</a>
</div>
</div>
<div class="row">
<div class="col">
<div class="pagination-links">
Expand Down
46 changes: 16 additions & 30 deletions resources/views/pdfs/governance/registerOfDirectors.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#footer {
position: fixed;
left: -50px; bottom: 0px; right: -50px; height: 50px;
left: -50px; bottom: -10px; right: -50px; height: 50px;
/*background-color: orange;*/
}
Expand Down Expand Up @@ -124,36 +124,22 @@
@foreach ($registerOfDirectors as $record)
<tr>
<td>{{ $record->getFullname() }}</td>
<td><small>{!! $serviceAddress !!}</small></td>
<td>
{{ config('branding.company_name') }}<br>
{{ config('branding.space_address_1') }}<br>
{{ config('branding.space_address_2') }}<br>

@if (config('branding.space_address_3'))
{{ config('branding.space_address_3') }}<br>
@endif

{{ config('branding.space_city') }}<br>

@if (config('branding.space_county'))
{{ config('branding.space_county') }}<br>
@endif

{{ config('branding.space_postcode') }}<br>
</td>
<td>
{{ $record->getAddress1() }}<br>
@if ($record->getAddress2())
{{ $record->getAddress2() }}<br>
@endif
@if ($record->getAddress3())
{{ $record->getAddress3() }}<br>
@endif
{{ $record->getAddressCity() }}<br>
@if ($record->getAddressCounty())
{{ $record->getAddressCounty() }}<br>
@endif
{{ $record->getAddressPostCode() }}
<small>
{{ $record->getAddress1() }}<br>
@if ($record->getAddress2())
{{ $record->getAddress2() }}<br>
@endif
@if ($record->getAddress3())
{{ $record->getAddress3() }}<br>
@endif
{{ $record->getAddressCity() }}<br>
@if ($record->getAddressCounty())
{{ $record->getAddressCounty() }}<br>
@endif
{{ $record->getAddressPostCode() }}
</small>
</td>
<td>{{ $record->getStartedAt()->toDateString() }}</td>
<td>{{ $record->getEndedAt()?->toDateString() }}</td>
Expand Down
26 changes: 5 additions & 21 deletions resources/views/pdfs/governance/registerOfMembers.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#footer {
position: fixed;
left: -50px; bottom: 0px; right: -50px; height: 50px;
left: -50px; bottom: -10px; right: -50px; height: 50px;
/*background-color: orange;*/
}
Expand Down Expand Up @@ -123,27 +123,11 @@
<tbody>
@foreach ($registerOfMembers as $record)
<tr>
<td>{{ $record->getFullname() }}</td>
<td>
{{ config('branding.company_name') }}<br>
{{ config('branding.space_address_1') }}<br>
{{ config('branding.space_address_2') }}<br>

@if (config('branding.space_address_3'))
{{ config('branding.space_address_3') }}<br>
@endif

{{ config('branding.space_city') }}<br>

@if (config('branding.space_county'))
{{ config('branding.space_county') }}<br>
@endif

{{ config('branding.space_postcode') }}<br>
</td>
<td>{{ $record['fullname'] }}</td>
<td><small>{!! $serviceAddress !!}</small></td>
<td>£1</td>
<td>{{ $record->getStartedAt()->toDateString() }}</td>
<td>{{ $record->getEndedAt()?->toDateString() }}</td>
<td>{{ $record['startedAt'] }}</td>
<td>{{ $record['endedAt'] }}</td>
</tr>
@endforeach
</tbody>
Expand Down

0 comments on commit f68272b

Please sign in to comment.