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 under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
20 # This script builds an ICalendar file (rfc 2445) for use in programs such as Ical
25 use Data
::ICal
::Entry
::Event
;
27 use Date
::Calc qw
(Parse_Date
);
36 my ( $template, $borrowernumber, $cookie ) = get_template_and_user
(
38 template_name
=> "opac-user.tmpl",
42 flagsrequired
=> { borrow
=> 1 },
47 # get borrower information ....
48 my ( $borr, $flags ) = GetMemberDetails
( $borrowernumber );
51 my $calendar = Data
::ICal
->new();
53 # get issued items ....
54 my ($countissues,$issues) = GetPendingIssues
($borrowernumber);
56 foreach my $issue ( @
$issues ) {
57 my $vevent = Data
::ICal
::Entry
::Event
->new();
58 my ($year,$month,$day)=Parse_Date
($issue->{'date_due'});
59 ($year,$month,$day)=split /-|\/|\
.|:/,$issue->{'date_due'} unless ($year && $month);
60 # Decode_Date_EU2($string))
61 my $datestart = Date
::ICal
->new(
69 my $dateend = Date
::ICal
->new(
77 $vevent->add_properties(
78 summary
=> "$issue->{'title'} Due",
80 "Your copy of $issue->{'title'} barcode $issue->{'barcode'} is due back at the library today",
81 dtstart
=> $datestart,
84 $calendar->add_entry($vevent);
88 -type
=> 'application/octet-stream',
89 -attachment
=> 'koha.ics'
93 print $calendar->as_string;