3 # Copyright 2007 Liblime Ltd
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 # This script builds an ICalendar file (rfc 2445) for use in programs such as Ical
27 use Data
::ICal
::Entry
::Event
;
29 use DateTime
::Format
::ICal
;
30 use Date
::Calc qw
(Parse_Date
);
32 use DateTime
::Event
::ICal
;
41 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
43 template_name
=> "opac-user.tt",
51 # get borrower information ....
52 my ( $borr ) = GetMemberDetails
( $borrowernumber );
55 my $calendar = Data
::ICal
->new();
57 # get issued items ....
58 my $issues = GetPendingIssues
($borrowernumber);
60 foreach my $issue ( @
$issues ) {
61 my $vevent = Data
::ICal
::Entry
::Event
->new();
62 my ($year,$month,$day)=Parse_Date
($issue->{'date_due'});
63 ($year,$month,$day)=split /-|\/|\
.|:/,$issue->{'date_due'} unless ($year && $month);
64 # Decode_Date_EU2($string))
65 my $datestart = DateTime
->new(
73 my $dateend = DateTime
->new(
81 $vevent->add_properties(
82 summary
=> "$issue->{'title'} Due",
84 "Your copy of $issue->{'title'} barcode $issue->{'barcode'} is due back at the library today",
85 dtstart
=> DateTime
::Format
::ICal
->format_datetime($datestart),
86 dtend
=> DateTime
::Format
::ICal
->format_datetime($dateend),
88 $calendar->add_entry($vevent);
92 -type
=> 'application/octet-stream',
93 -attachment
=> 'koha.ics'
97 print $calendar->as_string;