Skip to content
Browse files

Merge pull request #243 from dlbptfs/PT14882213_4

Pt14882213 4
  • Loading branch information...
2 parents 0927cd2 + a280fb4 commit 42ad61f795c178fa934639070360092ed5fac3df @ctfliblime ctfliblime committed Oct 29, 2011
View
2 C4/Context.pm
@@ -32,7 +32,7 @@ use POSIX ();
use JSON qw(from_json);
use Koha;
-$VERSION = '4.09.02.010';
+$VERSION = '4.09.02.011';
if ($ENV{'HTTP_USER_AGENT'}) {
require CGI::Carp;
View
16 C4/Letters.pm
@@ -831,10 +831,12 @@ sub GPOnotification {
my ($branch_details,$borrowernumber,$messagingprefs);
my ($letter,$regional_email,$selective_email);
my $match = 0;
- my %message_name = ( 'OFFER' => 'Offer Placed',
- 'NEED' => 'Need Requested',
- 'OFFER_PAUSED' => 'Offer Paused',
- 'OFFER_PASSED' => 'Offer Passed',
+ my %message_name = ( 'OFFER' => 'Offer Placed',
+ 'NEED' => 'Need Requested',
+ 'OFFER_PAUSED' => 'Offer Paused',
+ 'OFFER_PASSED' => 'Offer Passed',
+ 'OFFER_DELETED' => 'Offer Deleted',
+ 'OFFER_EXPIRED' => 'Offer Expired',
);
my $dbh = C4::Context->dbh;
if ($letter_code ~~ 'OFFER') {
@@ -904,9 +906,7 @@ sub GPOnotification {
}
}
}
- elsif (($letter_code ~~ 'NEED') ||
- ($letter_code ~~ 'OFFER_PAUSED') ||
- ($letter_code ~~ 'OFFER_PASSED')) {
+ elsif (($letter_code ~~ 'NEED') || ($letter_code =~ 'OFFER_')) {
my @selectives = C4::Branch::GetBranchSelectives($branchcode);
if ($targets) {
foreach my $selective (@selectives) {
@@ -932,7 +932,7 @@ sub GPOnotification {
if ($letter_code ~~ 'NEED') {
$letter = C4::Letters::getletter('reserves',$letter_code);
}
- elsif ($letter_code ~~ 'OFFER_PAUSED') {
+ elsif ($letter_code =~ 'OFFER_') {
$letter = C4::Letters::getletter('catalogue',$letter_code);
}
C4::Letters::parseletter($letter,'biblio',$biblionumber);
View
6 installer/data/mysql/en/mandatory/sample_notices.sql
@@ -16,5 +16,7 @@ VALUES ('circulation','ODUE','Overdue Notice','Item Overdue','Dear <<borrowers.f
('reserves','HOLD_EXPIRED','Hold Expired','Hold Expired','The hold on the following item has expired.\r\n\r\n<<biblio.title>>\r\n\r\n'),
('catalogue','OFFER','Offer available','Offer available','The following item(s) have been offered:\r\n\r\n<<biblio.title>>\r\n\r\n'),
('reserves','NEED','Need placed','Need placed','The following item(s) are needed:\r\n\r\n<<biblio.title>>\r\n\r\n'),
-('catalogue','OFFER_PAUSED','Offer paused','Offer paused','The following item(s) have been paused:\r\n\r\n<<biblio.title>>\r\n\r\n'),
-('catalogue','OFFER_PASSED','Offer passed','Offer passed','The following item(s) have been passed:\r\n\r\n<<biblio.title>>\r\n\r\n');
+('catalogue','OFFER_PAUSED','Offer paused','Offer paused','The following offer(s) have been paused:\r\n\r\n<<biblio.title>>\r\n\r\n'),
+('catalogue','OFFER_PASSED','Offer passed','Offer passed','The following offer(s) have been passed:\r\n\r\n<<biblio.title>>\r\n\r\n'),
+('catalogue','OFFER_DELETED','Offer deleted','Offer deleted','The following offer(s) have been deleted:\r\n\r\n<<biblio.title>>\r\n\r\n'),
+('catalogue','OFFER_EXPIRED','Offer expired','Offer expired','The following offer(s) have expired:\r\n\r\n<<biblio.title>>\r\n\r\n');
View
4 installer/data/mysql/en/optional/sample_notices_message_attributes.sql
@@ -11,4 +11,6 @@ values
(9, 'Offer Placed', 0),
(10, 'Need Requested', 0),
(11, 'Offer Paused', 0),
-(12, 'Offer Passed', 0);
+(12, 'Offer Passed', 0),
+(13, 'Offer Deleted', 0),
+(14, 'Offer Expired', 0);
View
6 installer/data/mysql/en/optional/sample_notices_message_transports.sql
@@ -26,4 +26,8 @@ values
(11, 'email', 1, 'catalogue', 'OFFER_PAUSED'),
(11, 'sms', 1, 'catalogue', 'OFFER_PAUSED'),
(12, 'email', 1, 'catalogue', 'OFFER_PASSED'),
-(12, 'sms', 1, 'catalogue', 'OFFER_PASSED');
+(12, 'sms', 1, 'catalogue', 'OFFER_PASSED'),
+(13, 'email', 1, 'catalogue', 'OFFER_DELETED'),
+(13, 'sms', 1, 'catalogue', 'OFFER_DELETED'),
+(14, 'email', 1, 'catalogue', 'OFFER_EXPIRED'),
+(14, 'sms', 1, 'catalogue', 'OFFER_EXPIRED');
View
18 installer/data/mysql/updatedatabase.pl
@@ -4908,6 +4908,24 @@
SetVersion ($DBversion);
}
+$DBversion = '4.09.02.011';
+if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
+ $dbh->do(qq/
+ INSERT INTO letter (module,code,name,title,content) VALUES ('catalogue','OFFER_DELETED','Offer deleted','Offer deleted','The following offer(s) have been deleted:\r\n\r\n<<biblio.title>>\r\n\r\n');
+ /);
+ $dbh->do(qq/
+ INSERT INTO letter (module,code,name,title,content) VALUES ('catalogue','OFFER_EXPIRED','Offer expired','Offer expired','The following offers(s) have expired.\r\n\r\n<<biblio.title>>\r\n\r\n');
+ /);
+ $dbh->do(qq/
+ INSERT INTO message_attributes (message_attribute_id, message_name, takes_days) VALUES (13, 'Offer Deleted', 0), (14, 'Offer Expired', 0);
+ /);
+ $dbh->do(qq/
+ INSERT INTO message_transports (message_attribute_id, message_transport_type, is_digest, letter_module, letter_code) VALUES (13, 'email', 1, 'catalogue', 'OFFER_DELETED'), (13, 'sms', 1, 'catalogue', 'OFFER_DELETED'), (14, 'email', 1, 'catalogue', 'OFFER_EXPIRED'), (14, 'sms', 1, 'catalogue', 'OFFER_EXPIRED');
+ /);
+ print "Update to $DBversion done ( Inserted new message transports, attributes, and letters for deleted and expired offers )\n";
+ SetVersion ($DBversion);
+}
+
printf "Database schema now up to date at version %s as of %s.\n", $DBversion, scalar localtime;
=item DropAllForeignKeys($table)
View
2 kohaversion.pl
@@ -10,7 +10,7 @@
use strict;
sub kohaversion {
- our $VERSION = '4.09.02.010';
+ our $VERSION = '4.09.02.011';
# version needs to be set this way
# so that it can be picked up by Makefile.PL
# during install
View
14 misc/cronjobs/expireoffers.pl
@@ -6,6 +6,7 @@
use C4::Items;
use DateTime;
use DateTime::Format::DateParse;
+use List::MoreUtils qw(uniq);
# pull in all the branch expiry times
my $branches = C4::Branch::GetAllBranches();
@@ -30,11 +31,16 @@
if ($deletable) {
C4::Items::DelItem($item->{itemnumber});
- #TODO
- #C4::Letters::GPOnotification($item, $bib, 'OFFER_DELETED');
+ my $offered_items = C4::Items::GetItemsByBiblionumber($item->{biblionumber});
+ my @to_branches = map { $_->{homebranch} } @{$offered_items};
+ my @to_branches_uniq = uniq(@to_branches);
+ C4::Letters::GPOnotification($region_code, $item->{biblionumber}, 'OFFER_DELETED',\@to_branches_uniq);
}
elsif ($expired) {
- #TODO
- #C4::Letters::GPOnotification($item, $bib, 'OFFER_EXPIRED');
+ my $offered_items = C4::Items::GetItemsByBiblionumber($item->{biblionumber});
+ my @to_branches = map { $_->{homebranch} } @{$offered_items};
+ my @to_branches_uniq = uniq(@to_branches);
+ use Data::Dumper; warn Dumper(@to_branches_uniq);
+ C4::Letters::GPOnotification($region_code, $item->{biblionumber}, 'OFFER_EXPIRED',\@to_branches_uniq);
}
}

0 comments on commit 42ad61f

Please sign in to comment.
Something went wrong with that request. Please try again.