+ # Catch the result of the template and split on newline
+ my ($summary,$description) = split /\n/, $template->output;
+ my $datestart;
+ if ($issue->{'overdue'} && $issue->{'overdue'} == 1) {
+ # Not much use adding an event in the past for a book that is overdue
+ # so we set datestart = now
+ $datestart = $timestamp;
+ } else {
+ $datestart = dt_from_string($issue->{'date_due'});
+ $datestart->set_time_zone('UTC');
+ }
+ # Create a UID that includes the issue number and the domain
+ my $domain = '';
+ my $baseurl = C4::Context->preference('OPACBaseURL');
+ if ( $baseurl ne '' ) {
+ my $url = URI->new($baseurl);
+ $domain = $url->host;
+ } else {
+ warn "Make sure the systempreference OPACBaseURL is set!";
+ }
+ my $uid = 'issue-' . $issue->{'issue_id'} . '@' . $domain;
+ # Create the event