From fda9c62684818a0666786fcbda991953fd143657 Mon Sep 17 00:00:00 2001 From: Vitor FERNANDES Date: Tue, 27 Nov 2012 12:42:18 +0000 Subject: [PATCH] BUG 9151 - Renewal notice according to patron alert preferences Modifications on AddRenewals and SendCirculationAlert in order to send a renewal notice to the patron according to the patron checkout alert preference. Added a new notice template for renewals notices. Signed-off-by: Kyle M Hall --- C4/Circulation.pm | 22 +++++++++++++++++++++- installer/data/mysql/updatedatabase.pl | 10 ++++++++++ 2 files changed, 31 insertions(+), 1 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index afe7a6a..4154786 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2581,6 +2581,25 @@ sub AddRenewal { "Renewal of Rental Item $item->{'title'} $item->{'barcode'}", 'Rent', $charge, $itemnumber ); } + + # Send a renewal slip according to checkout alert preference + my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ); + my $circulation_alert = 'C4::ItemCirculationAlertPreference'; + my %conditions = ( + branchcode => $branch, + categorycode => $borrower->{categorycode}, + item_type => $item->{itype}, + notification => 'CHECKOUT', + ); + if ($circulation_alert->is_enabled_for(\%conditions)) { + SendCirculationAlert({ + type => 'RENEWAL', + item => $item, + borrower => $borrower, + branch => $branch, + }); + } + # Log the renewal UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber, undef, $item->{'ccode'}); return $datedue; @@ -2902,12 +2921,13 @@ sub SendCirculationAlert { my %message_name = ( CHECKIN => 'Item_Check_in', CHECKOUT => 'Item_Checkout', + RENEWAL => 'Item_Checkout', ); my $borrower_preferences = C4::Members::Messaging::GetMessagingPreferences({ borrowernumber => $borrower->{borrowernumber}, message_name => $message_name{$type}, }); - my $issues_table = ( $type eq 'CHECKOUT' ) ? 'issues' : 'old_issues'; + my $issues_table = ( $type eq 'CHECKOUT' || $type eq 'RENEWAL' ) ? 'issues' : 'old_issues'; my $letter = C4::Letters::GetPreparedLetter ( module => 'circulation', letter_code => $type, diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 6080ff2..9260262 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6134,6 +6134,16 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +$DBversion = "XXXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do(q{ + INSERT INTO `letter` (`module`, `code`, `name`, `title`, `content`) VALUES + ('circulation','RENEWAL','Item Renewal','Renewals','The following items have been renew:\r\n----\r\n<>\r\n----\r\nThank you for visiting <>.'); + }); + print "Upgrade to $DBversion done (Bug 9151 - Renewal notice according to patron alert preferences)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) -- 1.7.2.5