diff --git a/app/Contribution/ContributionFactory.php b/app/Contribution/ContributionFactory.php index 1acfab15..25e66020 100644 --- a/app/Contribution/ContributionFactory.php +++ b/app/Contribution/ContributionFactory.php @@ -2,6 +2,7 @@ namespace App\Contribution; +use App\Contribution\Documents\BdkjHesse; use App\Contribution\Documents\ContributionDocument; use App\Contribution\Documents\RdpNrwDocument; use App\Contribution\Documents\CityRemscheidDocument; @@ -20,6 +21,7 @@ class ContributionFactory CitySolingenDocument::class, CityRemscheidDocument::class, CityFrankfurtMainDocument::class, + BdkjHesse::class, ]; /** diff --git a/app/Contribution/Data/MemberData.php b/app/Contribution/Data/MemberData.php index 734ef66e..1a24f1ba 100644 --- a/app/Contribution/Data/MemberData.php +++ b/app/Contribution/Data/MemberData.php @@ -67,8 +67,18 @@ class MemberData extends Data return $this->address.', '.$this->zip.' '.$this->location; } + public function city(): string + { + return $this->zip.' '.$this->location; + } + public function age(): string { return (string) $this->birthday->diffInYears(now()) ?: ''; } + + public function birthYear(): string + { + return (string) $this->birthday->year; + } } diff --git a/app/Contribution/Documents/BdkjHesse.php b/app/Contribution/Documents/BdkjHesse.php new file mode 100644 index 00000000..3884bf5a --- /dev/null +++ b/app/Contribution/Documents/BdkjHesse.php @@ -0,0 +1,163 @@ +> $members + */ + public function __construct( + public string $dateFrom, + public string $dateUntil, + public string $zipLocation, + public ?Country $country, + public Collection $members, + public ?string $filename = '', + public string $type = 'F', + ) { + } + + public function dateFrom(): string + { + return Carbon::parse($this->dateFrom)->format('d.m.Y'); + } + + public function dateUntil(): string + { + return Carbon::parse($this->dateUntil)->format('d.m.Y'); + } + + /** + * {@inheritdoc} + */ + public static function fromRequest(array $request): self + { + return new self( + dateFrom: $request['dateFrom'], + dateUntil: $request['dateUntil'], + zipLocation: $request['zipLocation'], + country: Country::where('id', $request['country'])->firstOrFail(), + members: MemberData::fromModels($request['members'])->chunk(20), + ); + } + + /** + * {@inheritdoc} + */ + public static function fromApiRequest(array $request): self + { + return new self( + dateFrom: $request['dateFrom'], + dateUntil: $request['dateUntil'], + zipLocation: $request['zipLocation'], + country: Country::where('id', $request['country'])->firstOrFail(), + members: MemberData::fromApi($request['member_data'])->chunk(20), + ); + } + + public function countryName(): string + { + return $this->country->name; + } + + public function durationDays(): int + { + return Carbon::parse($this->dateUntil)->diffInDays(Carbon::parse($this->dateFrom)) + 1; + } + + /** + * @param Collection $chunk + */ + public function membersDays(Collection $chunk): int + { + return $this->durationDays() * $chunk->count(); + } + + public function pages(): int + { + return count($this->members); + } + + public function memberName(MemberData $member): string + { + return $member->separatedName(); + } + + public function memberCity(MemberData $member): string + { + return $member->city(); + } + + public function memberGender(MemberData $member): string + { + if (!$member->gender) { + return ''; + } + + return strtolower(substr($member->gender->name, 0, 1)); + } + + public function memberBirthYear(MemberData $member): string + { + return $member->birthYear(); + } + + public function memberDays(MemberData $member): string + { + return $this->durationDays(); + } + + public function basename(): string + { + return 'zuschuesse-bdkj-hessen'; + } + + public function view(): string + { + return 'tex.contribution.bdkj-hesse'; + } + + 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 BDKJ Hessen erstellen'; + } + + /** + * @return array + */ + public static function rules(): array + { + return [ + 'dateFrom' => 'required|string|date_format:Y-m-d', + 'dateUntil' => 'required|string|date_format:Y-m-d', + 'country' => 'required|integer|exists:countries,id', + 'zipLocation' => 'required|string', + 'eventName' => 'required|string', + ]; + } +} diff --git a/app/Contribution/Documents/CityFrankfurtMainDocument.php b/app/Contribution/Documents/CityFrankfurtMainDocument.php index 8eae9b03..c8dd23ee 100644 --- a/app/Contribution/Documents/CityFrankfurtMainDocument.php +++ b/app/Contribution/Documents/CityFrankfurtMainDocument.php @@ -69,6 +69,11 @@ class CityFrankfurtMainDocument extends ContributionDocument return $this->country->name; } + public function pages(): int + { + return count($this->members); + } + public function memberShort(MemberData $member): string { return $member->isLeader ? 'L' : ''; diff --git a/resources/views/tex/contribution/bdkj-hesse.tex b/resources/views/tex/contribution/bdkj-hesse.tex new file mode 100644 index 00000000..6d7cb2b2 --- /dev/null +++ b/resources/views/tex/contribution/bdkj-hesse.tex @@ -0,0 +1,43 @@ +\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} +\backgroundsetup{scale = 1, angle = 0, opacity = 1, color=black, contents = {\includegraphics[width = \paperwidth, height = \paperheight] {bdkj-hesse.pdf}}} + +\begin{document} + \noindent \sffamily + + @foreach($members as $i => $chunk) + \begin{tikzpicture}[remember picture,overlay,yscale=-1] + \node[anchor=base west, text width=65.6mm] at (108.5mm,29.4mm) {\bfseries{\large{<<>>, <<>>}}}; + \node[anchor=base west, text width=25.4mm, align=center] at (185.0mm,29.4mm) {\bfseries{\large{<<>>}}}; + \node[anchor=base west, text width=25.4mm, align=center] at (218.8mm,29.4mm) {\bfseries{\large{<<>>}}}; + \node[anchor=base west, text width=8.5mm, align=center] at (253.0mm,29.4mm) {\bfseries{\large{<<>>}}}; + + @foreach($chunk as $j => $member) + \node[anchor=base, text width=12.4mm, align=center] at ($(18.6mm, 50.0mm + 6.1mm * <<<$j%20>>>)$) {<<<$j+1>>>}; + \node[anchor=base, text width=62.2mm, align=center] at ($(56.2mm, 50.0mm + 6.1mm * <<<$j%20>>>)$) {<<<$memberName($member)>>>}; + \node[anchor=base, text width=18.5mm, align=center] at ($(96.85mm, 50.0mm + 6.1mm * <<<$j%20>>>)$) {<<<$memberGender($member)>>>}; + \node[anchor=base, text width=67.2mm, align=center] at ($(140.0mm, 50.0mm + 6.1mm * <<<$j%20>>>)$) {<<<$memberCity($member)>>>}; + \node[anchor=base, text width=17.2mm, align=center] at ($(182.5mm, 50.0mm + 6.1mm * <<<$j%20>>>)$) {<<<$memberBirthYear($member)>>>}; + \node[anchor=base, text width=17.2mm, align=center] at ($(199.6mm, 50.0mm + 6.1mm * <<<$j%20>>>)$) {<<<$memberDays($member)>>>}; + @endforeach + + \node[anchor=base, text width=17.2mm, align=center] at ($(199.6mm, 50.0mm + 6.1mm * 20)$) {<<<$membersDays($chunk)>>>}; + + \node[anchor=base west, text width=6.4mm, align=center] at (258.5mm,191.3mm) {<<>>}; + \node[anchor=base west, text width=6.4mm, align=center] at (273.6mm,191.3mm) {<<>>}; + + \end{tikzpicture} + + \pagebreak + @endforeach + +\end{document} + diff --git a/resources/views/tex/contribution/city-frankfurt-main.tex b/resources/views/tex/contribution/city-frankfurt-main.tex index 1794a292..a85410af 100644 --- a/resources/views/tex/contribution/city-frankfurt-main.tex +++ b/resources/views/tex/contribution/city-frankfurt-main.tex @@ -11,28 +11,30 @@ \backgroundsetup{scale = 1, angle = 0, opacity = 1, color=black, contents = {\includegraphics[width = \paperwidth, height = \paperheight] {city-frankfurt-main.pdf}}} \begin{document} -\noindent \sffamily + \noindent \sffamily -@foreach($members as $chunk) -\begin{tikzpicture}[remember picture,overlay,yscale=-1] - \node[anchor=base west] at (53.2mm,31.0mm) {\bfseries{\large{}}}; %Feld: Jugendverband/-Gruppe - \node[anchor=base west] at (41.5mm,38.8mm) {\bfseries{\large{}}}; %Feld: Art der Maßnahme - \node[anchor=base west] at (18.0mm,47.0mm) {\bfseries{\large{<<>>, <<>>}}}; - \node[anchor=base west] at (171.0mm,47.0mm) {\bfseries{\large{<<>>}}}; - \node[anchor=base west] at (220.0mm,47.0mm) {\bfseries{\large{<<>>}}}; + @foreach($members as $i => $chunk) + \begin{tikzpicture}[remember picture,overlay,yscale=-1] + %\node[anchor=base west, text width=205.3mm] at (52.9mm,31.0mm) {\bfseries{\large{}}}; %Feld: Jugendverband/-Gruppe + %\node[anchor=base west, text width=215.9mm] at (41.3mm,38.8mm) {\bfseries{\large{}}}; %Feld: Art der Maßnahme + \node[anchor=base west, text width=104.8mm] at (17.5mm,47.0mm) {\bfseries{\large{<<>>, <<>>}}}; + \node[anchor=base west, text width=41.3mm, align=center] at (170.7mm,47.0mm) {\bfseries{\large{<<>>}}}; + \node[anchor=base west, text width=38.4mm, align=center] at (219.9mm,47.0mm) {\bfseries{\large{<<>>}}}; -@foreach($chunk as $i => $member) - \node[anchor=base, text width=4mm, align=center] at ($(8.0mm, 69.0mm + 8.05mm * <<<$i%15>>>)$) {<<<$memberShort($member)>>>}; - \node[anchor=base, text width=6mm, align=center] at ($(13.0mm, 69.0mm + 8.05mm * <<<$i%15>>>)$) {<<<$i+1>>>}; - \node[anchor=base, text width=67.5mm, align=center] at ($(50.65mm, 69.0mm + 8.05mm * <<<$i%15>>>)$) {<<<$memberName($member)>>>}; - \node[anchor=base, text width=14.6mm, align=center] at ($(92.2mm, 69.0mm + 8.05mm * <<<$i%15>>>)$) {<<<$memberAge($member)>>>}; - \node[anchor=base, text width=79.4mm, align=center] at ($(139.7mm, 69.0mm + 8.05mm * <<<$i%15>>>)$) {<<<$memberAddress($member)>>>}; -@endforeach + @foreach($chunk as $j => $member) + \node[anchor=base, text width=4mm, align=center] at ($(8.0mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$memberShort($member)>>>}; + \node[anchor=base, text width=6mm, align=center] at ($(13.0mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$j+1>>>}; + \node[anchor=base, text width=67.5mm, align=center] at ($(50.65mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$memberName($member)>>>}; + \node[anchor=base, text width=14.6mm, align=center] at ($(92.2mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$memberAge($member)>>>}; + \node[anchor=base, text width=79.4mm, align=center] at ($(139.7mm, 69.0mm + 8.05mm * <<<$j%15>>>)$) {<<<$memberAddress($member)>>>}; + @endforeach -\end{tikzpicture} + \node[anchor=base, text width=23.0mm, align=center] at (278.2mm,196.1mm) {Seite <<>> von <<>>}; -\pagebreak + \end{tikzpicture} -@endforeach + \pagebreak + + @endforeach \end{document} diff --git a/resources/views/tex/templates/contribution/bdkj-hesse.pdf b/resources/views/tex/templates/contribution/bdkj-hesse.pdf new file mode 100644 index 00000000..06c72af9 Binary files /dev/null and b/resources/views/tex/templates/contribution/bdkj-hesse.pdf differ diff --git a/tests/Feature/Contribution/StoreTest.php b/tests/Feature/Contribution/StoreTest.php index fe089336..223ab610 100644 --- a/tests/Feature/Contribution/StoreTest.php +++ b/tests/Feature/Contribution/StoreTest.php @@ -26,6 +26,7 @@ class StoreTest extends TestCase * ["App\\Contribution\\Documents\\RdpNrwDocument", ["Muster, Max", "Muster, Jane", "15.06.1991", "42777 SG"]] * ["App\\Contribution\\Documents\\CityRemscheidDocument", ["Max", "Muster", "Jane"]] * ["App\\Contribution\\Documents\\CityFrankfurtMainDocument", ["Max", "Muster", "Jane"]] + * ["App\\Contribution\\Documents\\BdkjHesse", ["Max", "Muster", "Jane"]] * * @param array $bodyChecks */