Add BDKJ-Hesse to contribution generator
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
349d821638
commit
554e1af245
|
@ -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,
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
<?php
|
||||
|
||||
namespace App\Contribution\Documents;
|
||||
|
||||
use App\Contribution\Data\MemberData;
|
||||
use App\Country;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
use Zoomyboy\Tex\Engine;
|
||||
use Zoomyboy\Tex\Template;
|
||||
|
||||
class BdkjHesse extends ContributionDocument
|
||||
{
|
||||
/**
|
||||
* @param Collection<int, Collection<int, MemberData>> $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<int, MemberData> $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<string, mixed>
|
||||
*/
|
||||
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',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -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' : '';
|
||||
|
|
|
@ -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{<<<!!$zipLocation!!>>>, <<<!!$countryName!!>>>}}};
|
||||
\node[anchor=base west, text width=25.4mm, align=center] at (185.0mm,29.4mm) {\bfseries{\large{<<<!!$dateFrom()!!>>>}}};
|
||||
\node[anchor=base west, text width=25.4mm, align=center] at (218.8mm,29.4mm) {\bfseries{\large{<<<!!$dateUntil()!!>>>}}};
|
||||
\node[anchor=base west, text width=8.5mm, align=center] at (253.0mm,29.4mm) {\bfseries{\large{<<<!!$durationDays!!>>>}}};
|
||||
|
||||
@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) {<<<!!$i + 1!!>>>};
|
||||
\node[anchor=base west, text width=6.4mm, align=center] at (273.6mm,191.3mm) {<<<!!$pages!!>>>};
|
||||
|
||||
\end{tikzpicture}
|
||||
|
||||
\pagebreak
|
||||
@endforeach
|
||||
|
||||
\end{document}
|
||||
|
|
@ -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{<<<!!$zipLocation!!>>>, <<<!!$countryName!!>>>}}};
|
||||
\node[anchor=base west] at (171.0mm,47.0mm) {\bfseries{\large{<<<!!$dateFromHuman!!>>>}}};
|
||||
\node[anchor=base west] at (220.0mm,47.0mm) {\bfseries{\large{<<<!!$dateUntilHuman!!>>>}}};
|
||||
@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{<<<!!$zipLocation!!>>>, <<<!!$countryName!!>>>}}};
|
||||
\node[anchor=base west, text width=41.3mm, align=center] at (170.7mm,47.0mm) {\bfseries{\large{<<<!!$dateFromHuman()!!>>>}}};
|
||||
\node[anchor=base west, text width=38.4mm, align=center] at (219.9mm,47.0mm) {\bfseries{\large{<<<!!$dateUntilHuman()!!>>>}}};
|
||||
|
||||
@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 <<<!!$i + 1!!>>> von <<<!!$pages!!>>>};
|
||||
|
||||
\pagebreak
|
||||
\end{tikzpicture}
|
||||
|
||||
@endforeach
|
||||
\pagebreak
|
||||
|
||||
@endforeach
|
||||
\end{document}
|
||||
|
||||
|
|
Binary file not shown.
|
@ -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<int, string> $bodyChecks
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue