--- Reserves.pm 2009-06-29 10:44:50.000000000 +0200 +++ Reserves.pm.patch 2009-06-29 10:45:13.000000000 +0200 @@ -25,6 +25,8 @@ use strict; use C4::Context; +use C4::Output; +use Mail::Sendmail; use C4::Biblio; use C4::Items; use C4::Search; @@ -191,6 +193,66 @@ $i++; } } + + # Send E-mail to admin + if ( + C4::Context->preference("emailLibrarianWhenHoldIsPlaced") && + C4::Context->preference("KohaAdminEmailAddress") + ) { + + # Get informations + my $query = " + SELECT + borrowers.surname, + borrowers.firstname, + borrowers.email, + reserves.reservedate, + biblio.title, + biblio.author + + FROM reserves + INNER JOIN biblio + ON biblio.biblionumber = reserves.biblionumber + INNER JOIN borrowers + ON borrowers.borrowernumber = reserves.borrowernumber + + WHERE + reserves.borrowernumber=? + AND + reserves.biblionumber=? + ORDER BY reservedate + "; + + my $sth = $dbh->prepare($query); + $sth->execute($borrowernumber, $biblionumber); + my $emailinfo = $sth->fetchrow_hashref; + + # if user email exists + if ( $emailinfo->{email} ){ + + my $template = gettemplate("reserve/mail_reserve.tmpl", "opac", CGI->new()); + + $template->param( + surname => $emailinfo->{surname}, + firstname => $emailinfo->{firstname}, + title => $emailinfo->{title}, + author =>$emailinfo->{author}, + reservedate =>$emailinfo->{reservedate} + ); + + my %mail = ( + To => $emailinfo->{email}, + From => C4::Context->preference("KohaAdminEmailAddress"), + Subject => 'Réservation - '.$emailinfo->{title}, + Message => "".$template->output, + 'Content-Type' => 'text/plain; charset="utf-8"', + ); + sendmail(%mail); + + } + + } + return; }