From d298b87548a028b3fa1940c24045bd16ad78e297 Mon Sep 17 00:00:00 2001 From: Nahuel ANGELINETTI Date: Fri, 28 Aug 2009 15:19:26 +0200 Subject: [PATCH] [3.0.x](bug #3242) send email when hold is placed This add a new letter in database, and each time a new hold is placed, a new mail is enqueued. Signed-off-by: Henri-Damien LAURENT --- C4/Reserves.pm | 29 ++++++++++++++++++++++++ installer/data/mysql/updatedatabase30.pl | 7 ++++++ 2 files changed, 36 insertions(+) diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 52751c8795..394246f164 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -24,6 +24,7 @@ use strict; # use warnings; # FIXME: someday use C4::Context; use C4::Biblio; +use C4::Members; use C4::Items; use C4::Search; use C4::Circulation; @@ -173,6 +174,33 @@ sub AddReserve { $found, $waitingdate ); + # Send e-mail to librarian if syspref is active + if(C4::Context->preference("emailLibrarianWhenHoldIsPlaced")){ + my $borrower = GetMemberDetails($borrowernumber); + my $biblio = GetBiblioData($biblionumber); + my $letter = C4::Letters::getletter( 'reserves', 'HOLDPLACED'); + my $admin_email_address = C4::Context->preference('KohaAdminEmailAddress'); + + my %keys = (%$borrower, %$biblio); + foreach my $key (keys %keys) { + my $replacefield = "<<$key>>"; + $letter->{content} =~ s/$replacefield/$keys{$key}/g; + $letter->{title} =~ s/$replacefield/$keys{$key}/g; + } + + C4::Letters::EnqueueLetter( + { letter => $letter, + borrowernumber => $borrowernumber, + message_transport_type => 'email', + from_address => $admin_email_address, + to_address => $admin_email_address, + } + ); + + + } + + #} ($const eq "o" || $const eq "e") or return; # FIXME: why not have a useful return value? $query = qq/ @@ -185,6 +213,7 @@ sub AddReserve { foreach (@$bibitems) { $sth->execute($borrowernumber, $biblionumber, $resdate, $_); } + return; # FIXME: why not have a useful return value? } diff --git a/installer/data/mysql/updatedatabase30.pl b/installer/data/mysql/updatedatabase30.pl index 6330cbb527..171dd92278 100644 --- a/installer/data/mysql/updatedatabase30.pl +++ b/installer/data/mysql/updatedatabase30.pl @@ -338,6 +338,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = '3.00.03.001'; +if (C4::Context->preference('Version') < TransformToNum($DBversion)){ + $dbh->do(" + INSERT INTO `letter` (module, code, name, title, content) VALUES('reserves', 'HOLDPLACED', 'Hold Placed on Item', 'Hold Placed on Item','An hold has been placed on the following item : <> (<<biblionumber>>) by the user <<firstname>> <<surname>> (<<cardnumber>>).'); + "); +} + =item DropAllForeignKeys($table) Drop all foreign keys of the table $table -- 2.39.5