2021-10-29 21:44:23 +02:00
< ? php
namespace App\Pdf ;
use App\Member\Member ;
use App\Payment\Payment ;
use Illuminate\Support\Collection ;
2022-03-20 16:33:56 +01:00
class RememberType extends Repository implements LetterRepository
2021-10-29 21:44:23 +02:00
{
public string $filename ;
public function getPayments ( Member $member ) : Collection
{
return $member -> payments () -> whereNeedsRemember () -> get ();
}
public function linkLabel () : string
{
return 'Erinnerung erstellen' ;
}
public function getSubject () : string
{
return 'Zahlungserinnerung' ;
}
2022-03-20 16:33:56 +01:00
public function setFilename ( string $filename ) : static
2021-10-29 21:44:23 +02:00
{
$this -> filename = $filename ;
return $this ;
}
public function getFilename () : string
{
return $this -> filename ;
}
2022-03-20 16:33:56 +01:00
public function getScript () : EnvType
{
return EnvType :: XELATEX ;
}
2021-10-29 21:44:23 +02:00
public function getView () : string
{
return 'tex.remember' ;
}
public function getTemplate () : string
{
return 'default' ;
}
public function getPositions ( Collection $page ) : array
{
$memberIds = $page -> pluck ( 'id' ) -> toArray ();
$payments = Payment :: whereIn ( 'member_id' , $memberIds )
-> orderByRaw ( 'nr, member_id' ) -> whereNeedsRemember () -> get ();
return $payments -> mapWithKeys ( function ( Payment $payment ) {
$key = " Beitrag { $payment -> nr } für { $payment -> member -> firstname } { $payment -> member -> lastname } ( { $payment -> subscription -> name } ) " ;
return [ $key => $this -> number ( $payment -> subscription -> amount )];
}) -> toArray ();
}
public function getFamilyName ( Collection $page ) : string
{
return $page -> first () -> lastname ;
}
public function getAddress ( Collection $page ) : string
{
return $page -> first () -> address ;
}
public function getZip ( Collection $page ) : string
{
return $page -> first () -> zip ;
}
public function getEmail ( Collection $page ) : string
{
return $page -> first () -> email_parents ? : $page -> first () -> email ;
}
public function getLocation ( Collection $page ) : string
{
return $page -> first () -> location ;
}
public function getUsage ( Collection $page ) : string
{
return " Mitgliedsbeitrag für { $this -> getFamilyName ( $page ) } " ;
}
2021-10-29 22:02:21 +02:00
public function allLabel () : string
2021-10-29 21:44:23 +02:00
{
return 'Erinnerungen versenden' ;
}
/**
2022-03-11 20:19:17 +01:00
* Get Descriptions for sendpayment page .
2021-10-29 21:44:23 +02:00
*
* @ return array < int , string >
*/
2022-03-11 20:19:17 +01:00
public function getDescription () : array
2021-10-29 21:44:23 +02:00
{
return [
'Diese Funktion erstellt Erinnerungs-PDFs mit allen versendeten aber noch nich bezahlten Rechnungen bei den Mitgliedern die Post als Versandweg haben.' ,
'Das zuletzt erinnerte Datum wird auf heute gesetzt.' ,
];
}
public function afterSingle ( Payment $payment ) : void
{
$payment -> update ([ 'last_remembered_at' => now ()]);
}
2021-10-29 22:02:21 +02:00
public function getMailSubject () : string
{
return 'Zahlungserinnerung' ;
}
2021-10-29 21:44:23 +02:00
}