Lines 47-56
my $calendar = Data::ICal->new();
Link Here
|
47 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
47 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
48 |
my $pending_checkouts = $patron->pending_checkouts; |
48 |
my $pending_checkouts = $patron->pending_checkouts; |
49 |
|
49 |
|
|
|
50 |
my $timestamp = dt_from_string(undef,undef,"UTC"); #Get current time in UTC |
51 |
|
50 |
while ( my $c = $pending_checkouts->next ) { |
52 |
while ( my $c = $pending_checkouts->next ) { |
51 |
my $issue = $c->unblessed_all_relateds; |
53 |
my $issue = $c->unblessed_all_relateds; |
52 |
my $vevent = Data::ICal::Entry::Event->new(); |
54 |
my $vevent = Data::ICal::Entry::Event->new(); |
53 |
my $timestamp = dt_from_string(undef,undef,"UTC"); #Get current time in UTC |
|
|
54 |
# Send some values to the template to generate summary and description |
55 |
# Send some values to the template to generate summary and description |
55 |
$issue->{overdue} = $c->is_overdue; |
56 |
$issue->{overdue} = $c->is_overdue; |
56 |
$template->param( |
57 |
$template->param( |
Lines 60-72
while ( my $c = $pending_checkouts->next ) {
Link Here
|
60 |
); |
61 |
); |
61 |
# Catch the result of the template and split on newline |
62 |
# Catch the result of the template and split on newline |
62 |
my ($summary,$description) = split /\n/, $template->output; |
63 |
my ($summary,$description) = split /\n/, $template->output; |
63 |
my $datestart; |
64 |
my ( $datestart, $datestart_local ); |
64 |
if ($issue->{'overdue'} && $issue->{'overdue'} == 1) { |
65 |
if ($issue->{'overdue'} && $issue->{'overdue'} == 1) { |
65 |
# Not much use adding an event in the past for a book that is overdue |
66 |
# Not much use adding an event in the past for a book that is overdue |
66 |
# so we set datestart = now |
67 |
# so we set datestart = now |
67 |
$datestart = $timestamp; |
68 |
$datestart = $timestamp->clone(); |
|
|
69 |
$datestart_local = $datestart->clone(); |
68 |
} else { |
70 |
} else { |
69 |
$datestart = dt_from_string($issue->{'date_due'}); |
71 |
$datestart = dt_from_string($issue->{'date_due'}); |
|
|
72 |
$datestart_local = $datestart->clone(); |
70 |
$datestart->set_time_zone('UTC'); |
73 |
$datestart->set_time_zone('UTC'); |
71 |
} |
74 |
} |
72 |
# Create a UID that includes the issue number and the domain |
75 |
# Create a UID that includes the issue number and the domain |
Lines 80-90
while ( my $c = $pending_checkouts->next ) {
Link Here
|
80 |
} |
83 |
} |
81 |
my $uid = 'issue-' . $issue->{'issue_id'} . '@' . $domain; |
84 |
my $uid = 'issue-' . $issue->{'issue_id'} . '@' . $domain; |
82 |
# Create the event |
85 |
# Create the event |
|
|
86 |
|
87 |
my $dtstart; |
88 |
if ($issue->{'overdue'} && $issue->{'overdue'} == 1) { |
89 |
# It's already overdue so make it due as an all day event today |
90 |
$dtstart = [ $datestart->ymd(q{}), { VALUE => 'DATE' } ]; |
91 |
} elsif ( $datestart_local->hour eq '23' && $datestart_local->minute eq '59' ) { |
92 |
# Checkouts due at 23:59 are "all day events" |
93 |
$dtstart = [ $datestart->ymd(q{}), { VALUE => 'DATE' } ]; |
94 |
} |
95 |
else { # Checkouts due any other time are instantaneous events at the date and time due |
96 |
$dtstart = DateTime::Format::ICal->format_datetime($datestart); |
97 |
} |
98 |
|
83 |
$vevent->add_properties( |
99 |
$vevent->add_properties( |
84 |
summary => $summary, |
100 |
summary => $summary, |
85 |
description => $description, |
101 |
description => $description, |
86 |
dtstamp => DateTime::Format::ICal->format_datetime($timestamp), |
102 |
dtstamp => DateTime::Format::ICal->format_datetime($timestamp), |
87 |
dtstart => DateTime::Format::ICal->format_datetime($datestart), |
103 |
dtstart => $dtstart, |
88 |
uid => $uid, |
104 |
uid => $uid, |
89 |
); |
105 |
); |
90 |
# Add it to the calendar |
106 |
# Add it to the calendar |
91 |
- |
|
|