45 lines
1.2 KiB
Perl
45 lines
1.2 KiB
Perl
#!perl
|
|
|
|
use POSIX qw(strftime);
|
|
|
|
sub _box(@lines) {
|
|
print(
|
|
"#" x 79, "\n",
|
|
(map { sprintf("## %-73s ##\n", $_) } @lines),
|
|
"#" x 79, "\n"
|
|
);
|
|
}
|
|
|
|
sub hook_checkout_done($class, $cart, $user, $transaction_id, @) {
|
|
defined $user or return; # hacks like 'undo' don't have an acting user
|
|
RevBank::Users::is_hidden($user) and return;
|
|
|
|
my $balance = RevBank::Users::balance($user) or return;
|
|
my $since = RevBank::Users::since($user);
|
|
|
|
if ($balance < -13.37) {
|
|
_box(
|
|
"Hoi $user,",
|
|
"",
|
|
"Je saldo is $balance en dus lager dan toegestaan. Graag meteen aanvullen!",
|
|
"Zodra je een positief saldo hebt, mag je weer producten kopen.",
|
|
"",
|
|
"Bedankt!",
|
|
"-- Het bestuur",
|
|
);
|
|
} elsif (
|
|
defined $since
|
|
and $since =~ /^-\@(.*)/
|
|
and $1 lt strftime('%Y-%m-%d_%H:%M:%S', localtime(time() - 14 * 86400))
|
|
) {
|
|
_box(
|
|
"Hoi $user,",
|
|
"",
|
|
"Je staat al sinds $1 negatief, dus meer dan 2 weken. Deelnemers",
|
|
"mogen rood staan, maar niet langdurig. Wil je je saldo even aanvullen?",
|
|
"",
|
|
"Bedankt!",
|
|
"-- Het bestuur",
|
|
);
|
|
}
|
|
}
|