All examples

Packing list · Strict placement

Fixed-height bands placed arithmetically across pages, with a repeated grid header and page numbers.

Strict Pagination /reports/packing_list/run
PDF

What is typical here

  • Strict mode: fixed band heights and arithmetic pagination
  • A repeated grid header on every page
  • Page numbers in the page footer
  • 60 demo positions, so the report spans several pages

Module structure

app/Reports/PackingList/
├── Report.php              # strict mode, fixed band heights
├── Source.php              # 60 demo positions
└── views/
    ├── header.blade.php
    ├── grid-head.blade.php
    ├── row.blade.php
    └── footer.blade.php

Files

<?php

declare(strict_types=1);

namespace App\Reports\PackingList;

use Guggach\Reports\Definition\PageSetup;
use Guggach\Reports\Definition\ReportBuilder;
use Guggach\Reports\Definition\ReportMode;
use Guggach\Reports\Report as BaseReport;
use Guggach\Reports\Sources\ReportSource;

final class Report extends BaseReport
{
    public function key(): string
    {
        return 'packing_list';
    }

    public function name(): string
    {
        return 'Lieferschein';
    }

    public function layout(): string
    {
        return 'default';
    }

    public function source(): ReportSource
    {
        return new Source;
    }

    public function define(ReportBuilder $r): void
    {
        $r->mode(ReportMode::Strict);
        $r->pageSetup(PageSetup::a4()->portrait()->marginsMm(20, 15, 20, 15));

        // Module-relative view names resolve to app/Reports/PackingList/views/*.
        $r->pageHeader(view: 'header')->height(20);
        $r->gridHeader(view: 'grid-head')->height(8);
        $r->detail(view: 'row', height: 8);
        $r->pageFooter(view: 'footer')->height(10);
    }
}
<?php

declare(strict_types=1);

namespace App\Reports\PackingList;

use Guggach\Reports\Sources\ReportSource;

/**
 * Demo source for the packing list. Produces 60 positions so the strict
 * pagination has something to distribute across pages.
 */
final class Source extends ReportSource
{
    public function records(): iterable
    {
        $rows = [];

        for ($i = 1; $i <= 60; $i++) {
            $rows[] = [
                'pos' => $i,
                'article' => 'Artikel '.str_pad((string) $i, 3, '0', STR_PAD_LEFT),
                'qty' => ($i % 5) + 1,
            ];
        }

        return $rows;
    }
}
<style>
    .pl-title { font-size: 18px; font-weight: 700; }
    .pl-sub { color: #6b7280; font-size: 12px; }
    .pl-row { display: flex; height: 8mm; box-sizing: border-box; align-items: center; border-bottom: 1px solid #e5e7eb; }
    .pl-row > span { flex: 1 1 auto; }
    .pl-row > span:first-child { flex: 0 0 16mm; }
    .pl-row > span:last-child { flex: 0 0 20mm; text-align: right; }
    .pl-head { font-weight: 700; border-bottom: 2px solid #0f766e; }
</style>

<div class="pl-title">Lieferschein</div>
<div class="pl-sub">Acme AG · Beispielstrasse 1 · 8000 Zürich</div>
<div class="pl-row">
    <span>{{ $ctx->pos }}</span>
    <span>{{ $ctx->article }}</span>
    <span>{{ $ctx->qty }}</span>
</div>