From a478c52e09ba6835627dd45d3a9b75120e89568f 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 Signed-off-by: Jared Camins-Esakov --- C4/Circulation.pm | 22 +++++++++++++++++++++- installer/data/mysql/updatedatabase.pl | 10 ++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index afe7a6a39e..415478631d 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 2c4b1ed7c5..36d35edd9b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -6299,6 +6299,16 @@ if (C4::Context->preference("Version") < TransformToNum($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) -- 2.39.5