parent
9109721d4a
commit
f1f24ff337
app/Contribution
packages
resources/views/tex
tests/Feature/Contribution
|
@ -4,6 +4,7 @@ namespace App\Contribution;
|
|||
|
||||
use App\Contribution\Documents\ContributionDocument;
|
||||
use App\Contribution\Documents\DvDocument;
|
||||
use App\Contribution\Documents\RemscheidDocument;
|
||||
use App\Contribution\Documents\SolingenDocument;
|
||||
|
||||
class ContributionFactory
|
||||
|
@ -14,6 +15,7 @@ class ContributionFactory
|
|||
private array $documents = [
|
||||
DvDocument::class,
|
||||
SolingenDocument::class,
|
||||
RemscheidDocument::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,6 +17,7 @@ class DvDocument extends ContributionDocument
|
|||
public string $dateUntil,
|
||||
public string $zipLocation,
|
||||
public ?Country $country,
|
||||
/* @var Collection<int, Collection<int, Member>> */
|
||||
public Collection $members,
|
||||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Country;
|
||||
use App\Member\Member;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Http\Request;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
class RemscheidDocument extends ContributionDocument
|
||||
{
|
||||
public function __construct(
|
||||
public string $dateFrom,
|
||||
public string $dateUntil,
|
||||
public string $zipLocation,
|
||||
public ?Country $country,
|
||||
/* @var Collection<int, Collection<int, Member>> */
|
||||
public Collection $leaders,
|
||||
/* @var Collection<int, Collection<int, Member>> */
|
||||
public Collection $children,
|
||||
public ?string $filename = '',
|
||||
public string $type = 'F',
|
||||
) {
|
||||
}
|
||||
|
||||
public function niceDateFrom(): string
|
||||
{
|
||||
return Carbon::parse($this->dateFrom)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public function niceDateUntil(): string
|
||||
{
|
||||
return Carbon::parse($this->dateUntil)->format('d.m.Y');
|
||||
}
|
||||
|
||||
public static function fromRequest(Request $request): self
|
||||
{
|
||||
[$leaders, $children] = Member::whereIn('id', $request->members)->orderByRaw('lastname, firstname')->get()->partition(fn ($member) => $member->isLeader());
|
||||
|
||||
return new self(
|
||||
dateFrom: $request->dateFrom,
|
||||
dateUntil: $request->dateUntil,
|
||||
zipLocation: $request->zipLocation,
|
||||
country: Country::where('id', $request->country)->firstOrFail(),
|
||||
leaders: $leaders->values()->chunk(6),
|
||||
children: $children->values()->chunk(20),
|
||||
);
|
||||
}
|
||||
|
||||
public function basename(): string
|
||||
{
|
||||
return 'zuschuesse-remscheid';
|
||||
}
|
||||
|
||||
public function view(): string
|
||||
{
|
||||
return 'tex.zuschuss-remscheid';
|
||||
}
|
||||
|
||||
public function template(): Template
|
||||
{
|
||||
return Template::make('tex.templates.contribution');
|
||||
}
|
||||
|
||||
public function setFilename(string $filename): static
|
||||
{
|
||||
$this->filename = $filename;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEngine(): Engine
|
||||
{
|
||||
return Engine::PDFLATEX;
|
||||
}
|
||||
|
||||
public static function getName(): string
|
||||
{
|
||||
return 'Für Remscheid erstellen';
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
Subproject commit 5d6339c1ad21307bc93d3fd30b0be773da4e05a4
|
||||
Subproject commit 68d4f38e319da9d1353d59a614723f3de14bc50f
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,55 @@
|
|||
\documentclass[a4paper,landscape]{article}
|
||||
|
||||
\usepackage[landscape,top=0cm,left=0cm,bottom=0cm,right=0cm]{geometry}
|
||||
\usepackage{tikz}
|
||||
\usepackage{background}
|
||||
\usepackage{blindtext}
|
||||
\usetikzlibrary{matrix, shapes.misc, calc}
|
||||
|
||||
\pagestyle{empty}
|
||||
\setlength{\parindent}{0cm}
|
||||
|
||||
\begin{document}
|
||||
|
||||
@foreach($children as $chunk)
|
||||
\backgroundsetup{scale = 1, angle = 0, opacity = 1, color=black, contents = {\includegraphics[width = \paperwidth, height = \paperheight] {tn.pdf}}}
|
||||
\noindent \sffamily
|
||||
\begin{tikzpicture}[remember picture,overlay,yscale=-1]
|
||||
\fill[white] (19mm,30mm) rectangle (80mm,36mm);
|
||||
\node[anchor=base west,fill=white] at (18.8mm,34mm) {\large{In \textbf{<<<$zipLocation>>>} vom \textbf{<<<$niceDateFrom>>>} bis \textbf{<<<$niceDateUntil>>>}}};
|
||||
|
||||
@foreach($chunk as $i => $member)
|
||||
\node[anchor=base, text width=7.75mm, align=center] at ($(18.35mm, 61.3mm + 5.91mm * <<<$i % 20>>>)$) {<<<$i+1>>>};
|
||||
\node[anchor=base, text width=29mm, align=center] at ($(43.7mm, 61.3mm + 5.91mm * <<<$i % 20>>>)$) {<<<$member->lastname>>>};
|
||||
\node[anchor=base, text width=29mm, align=center] at ($(76.2mm, 61.3mm + 5.91mm * <<<$i % 20>>>)$) {<<<$member->firstname>>>};
|
||||
\node[anchor=base, text width=84mm, align=center] at ($(136.2mm, 61.3mm + 5.91mm * <<<$i % 20>>>)$) {<<<$member->fullAddress>>>};
|
||||
\node[anchor=base, text width=19mm, align=center] at ($(191.2mm, 61.3mm + 5.91mm * <<<$i % 20>>>)$) {<<<$member->birthday->format('d.m.Y')>>>};
|
||||
@endforeach
|
||||
\end{tikzpicture}
|
||||
|
||||
\pagebreak
|
||||
@endforeach
|
||||
|
||||
@foreach($leaders as $chunk)
|
||||
\backgroundsetup{scale = 1, angle = 0, opacity = 1, color=black, contents = {\includegraphics[width = \paperwidth, height = \paperheight] {leader.pdf}}}
|
||||
\noindent \sffamily
|
||||
\begin{tikzpicture}[remember picture,overlay,yscale=-1]
|
||||
\fill[white] (17mm,27mm) rectangle (284mm,34mm);
|
||||
\node[anchor=base west,fill=white] at (18.8mm,32mm) {\large{In \textbf{<<<$zipLocation>>>} vom \textbf{<<<$niceDateFrom>>>} bis \textbf{<<<$niceDateUntil>>>}}};
|
||||
|
||||
@foreach($chunk as $i => $member)
|
||||
\node[anchor=base, text width=7.75mm, align=center] at ($(18.35mm, 78.3mm + 5.91mm * <<<$i % 6>>>)$) {<<<$i+1>>>};
|
||||
\node[anchor=base, text width=29mm, align=center] at ($(43.7mm, 78.3mm + 5.91mm * <<<$i % 6>>>)$) {<<<$member->lastname>>>};
|
||||
\node[anchor=base, text width=29mm, align=center] at ($(76.2mm, 78.3mm + 5.91mm * <<<$i % 6>>>)$) {<<<$member->firstname>>>};
|
||||
\node[anchor=base, text width=84mm, align=center] at ($(136.2mm, 78.3mm + 5.91mm * <<<$i % 6>>>)$) {<<<$member->fullAddress>>>};
|
||||
\node[anchor=base, text width=19mm, align=center] at ($(190.2mm, 78.3mm + 5.91mm * <<<$i % 6>>>)$) {<<<$member->birthday->format('d.m.Y')>>>};
|
||||
@endforeach
|
||||
\end{tikzpicture}
|
||||
|
||||
\pagebreak
|
||||
@endforeach
|
||||
|
||||
\end{document}
|
||||
|
||||
|
||||
|
|
@ -15,6 +15,7 @@ class StoreTest extends TestCase
|
|||
/**
|
||||
* @testWith ["App\\Contribution\\Documents\\SolingenDocument", ["Super tolles Lager", "Max Muster", "Jane Muster", "15.06.1991"]]
|
||||
* ["App\\Contribution\\Documents\\DvDocument", ["Muster, Max", "Muster, Jane", "15.06.1991", "42777 SG"]]
|
||||
* ["App\\Contribution\\Documents\\RemscheidDocument", ["Max", "Muster", "Jane", "15.06.1991", "Maxstr 44, 42719 SG"]]
|
||||
*
|
||||
* @param array<int, string> $bodyChecks
|
||||
*/
|
||||
|
@ -24,8 +25,8 @@ class StoreTest extends TestCase
|
|||
Tex::spy();
|
||||
$this->login()->loginNami();
|
||||
$country = Country::factory()->create();
|
||||
$member1 = Member::factory()->defaults()->create(['firstname' => 'Max', 'lastname' => 'Muster']);
|
||||
$member2 = Member::factory()->defaults()->create(['firstname' => 'Jane', 'lastname' => 'Muster']);
|
||||
$member1 = Member::factory()->defaults()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Max', 'lastname' => 'Muster']);
|
||||
$member2 = Member::factory()->defaults()->create(['address' => 'Maxstr 44', 'zip' => '42719', 'firstname' => 'Jane', 'lastname' => 'Muster']);
|
||||
|
||||
$response = $this->call('GET', '/contribution/generate', [
|
||||
'country' => $country->id,
|
||||
|
|
Loading…
Reference in New Issue