version 1.54, 2015/12/08 02:10:43 |
version 1.55, 2020/08/02 18:52:40 |
|
|
#!/usr/bin/perl |
#!/usr/bin/perl |
# $AFresh1: rt_invoices.pl,v 1.53 2015/05/07 05:26:08 andrew Exp $ |
# $AFresh1: rt_invoices.pl,v 1.54 2015/12/08 02:10:43 andrew Exp $ |
######################################################################## |
######################################################################## |
# Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com> |
# Copyright (c) 2011 Andrew Fresh <andrew@afresh1.com> |
# |
# |
|
|
use warnings; |
use warnings; |
|
|
use 5.010; |
use 5.010; |
use experimental qw( switch smartmatch ); |
|
|
|
# Because we don't have a real cert |
# Because we don't have a real cert |
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; |
$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0; |
|
|
next unless $cust->{match}; |
next unless $cust->{match}; |
foreach my $m ( @{ $cust->{match} } ) { |
foreach my $m ( @{ $cust->{match} } ) { |
my $type = $m->{type}; |
my $type = $m->{type}; |
my $match |
my @things = map {lc} $ticket->$type; |
= exists $m->{$type} |
if ( exists $m->{$type} ) { |
? lc( $m->{$type} ) |
if ( !$m->{$type} ) { |
: qr/\Q$m->{regex}\E/; |
warn "Invalid match!"; |
my $thing = [ map {lc} $ticket->$type ]; |
next; |
|
} |
if ( !$match ) { |
my $match = lc $m->{$type}; |
warn "Invalid match!"; |
for my $thing (@things) { |
next; |
return $cust if $thing eq $match; |
|
} |
} |
} |
return $cust if ( $match ~~ $thing ); |
else { |
|
my $match = qr/\Q$m->{regex}\E/; |
|
for my $thing (@things) { |
|
return $cust if $thing =~ $match; |
|
} |
|
} |
} |
} |
} |
} |
|
|
|
|
my $per = $cust->{per} || 'week'; |
my $per = $cust->{per} || 'week'; |
my $freq = $cust->{frequency} || 1; |
my $freq = $cust->{frequency} || 1; |
|
|
my $day_method; |
my $day_method |
given ($per) { |
= $per eq 'week' ? $day_method = 'dow' |
when ('week') { $per = 'weeks'; $day_method = 'dow' } |
: $per eq 'month' ? $day_method = 'day' |
when ('month') { $per = 'months'; $day_method = 'day' } |
: die "Unknown per [$per]\n"; |
default { die "Unknown per [$per]\n" } |
|
} |
|
|
|
return DateTime::Duration->new( $per => $freq ), $day_method; |
return DateTime::Duration->new( "${per}s" => $freq ), $day_method; |
} |
} |
|
|
sub set_dates { |
sub set_dates { |