View | Details | Raw Unified | Return to bug 30927
Collapse All | Expand All

(-)a/opac/opac-ics.pl (-4 / +16 lines)
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;
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
    # Checkouts due at 23:59 are "all day events"
89
    if ( $datestart_local->hour eq '23' && $datestart_local->minute eq '59' ) {
90
        $dtstart = $datestart->subtract(days => 1)->ymd(q{});
91
    }
92
    else { # Checkouts due any other time are instantaneous events at the date and time due
93
        $dtstart = DateTime::Format::ICal->format_datetime($datestart);
94
    }
95
83
    $vevent->add_properties(
96
    $vevent->add_properties(
84
        summary     => $summary,
97
        summary     => $summary,
85
        description => $description,
98
        description => $description,
86
        dtstamp     => DateTime::Format::ICal->format_datetime($timestamp),
99
        dtstamp     => DateTime::Format::ICal->format_datetime($timestamp),
87
        dtstart     => DateTime::Format::ICal->format_datetime($datestart),
100
        dtstart     => $dtstart,
88
        uid         => $uid,
101
        uid         => $uid,
89
    );
102
    );
90
    # Add it to the calendar
103
    # Add it to the calendar
91
- 

Return to bug 30927