From 16c30c0d51b98b948ffa27606fd2ebb18f6de934 Mon Sep 17 00:00:00 2001 From: Paul POULAIN Date: Fri, 29 Feb 2008 13:38:13 +1300 Subject: [PATCH] BUGFIXING mail alert on issue arrival To make this feature work : - create a "notice" (tools/letter.pl) of the category "serials" - choose this notice in each subscription you want to enable this feature Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Letters.pm | 18 ++++---- .../prog/en/modules/opac-alert-subscribe.tmpl | 41 +++++++++++++++++++ .../prog/en/modules/opac-detail.tmpl | 1 + .../prog/en/modules/opac-serial-issues.tmpl | 12 ++++++ opac/opac-alert-subscribe.pl | 1 + opac/opac-detail.pl | 1 + opac/opac-serial-issues.pl | 32 +++++++++++---- 7 files changed, 88 insertions(+), 18 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/prog/en/modules/opac-alert-subscribe.tmpl diff --git a/C4/Letters.pm b/C4/Letters.pm index 857dc5632e..dffe2c202a 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -173,21 +173,21 @@ sub delalert { sub getalert { my ( $borrowernumber, $type, $externalid ) = @_; my $dbh = C4::Context->dbh; - my $query = "select * from alert where"; + my $query = "SELECT * FROM alert WHERE"; my @bind; if ($borrowernumber =~ /^\d+$/) { - $query .= " borrowernumber=? and"; + $query .= " borrowernumber=? AND "; push @bind, $borrowernumber; } if ($type) { - $query .= " type=? and"; + $query .= " type=? AND "; push @bind, $type; } if ($externalid) { - $query .= " externalid=? and"; + $query .= " externalid=? AND "; push @bind, $externalid; } - $query =~ s/ and$//; + $query =~ s/ AND $//; my $sth = $dbh->prepare($query); $sth->execute(@bind); my @result; @@ -252,7 +252,7 @@ sub SendAlerts { # search the biblionumber my $sth = $dbh->prepare( - "select biblionumber from subscription where subscriptionid=?"); + "SELECT biblionumber FROM subscription WHERE subscriptionid=?"); $sth->execute($externalid); my ($biblionumber) = $sth->fetchrow; @@ -280,10 +280,10 @@ sub SendAlerts { parseletter( $innerletter, 'borrowers', $_->{'borrowernumber'} ); # ... then send mail - if ( $borinfo->{emailaddress} ) { + if ( $borinfo->{email} ) { my %mail = ( - To => $borinfo->{emailaddress}, - From => $userenv->{emailaddress}, + To => $borinfo->{email}, + From => $borinfo->{email}, Subject => "" . $innerletter->{title}, Message => "" . $innerletter->{content}, ); diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-alert-subscribe.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-alert-subscribe.tmpl new file mode 100644 index 0000000000..d464832004 --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-alert-subscribe.tmpl @@ -0,0 +1,41 @@ +Koha Online Catalog › Serials + + + + + +
+
+
+
+ +

Subscribe issue recieve warning

+
+

Do you want to be mailed when a new issue for this subscription arrives at the library ?

+ () arrive ?

+ "> + + "> + + + " >No +
+
+ + +

Unsubscribe

+
+

Do you confirm you want to unsubscribe mail warning for this subscription ?

+ () ?

+ "> + + "> + + + " class="button">No +
+
+ +
+ + diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl index 36e0b9f0c9..02989bcc62 100755 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl @@ -329,6 +329,7 @@ +

">More details

diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-serial-issues.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-serial-issues.tmpl index e89da91666..05948559f6 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-serial-issues.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-serial-issues.tmpl @@ -103,6 +103,18 @@

+ + + You already follow this subscription &alerttype=issue&biblionumber=" class="button" title="Cancel alert"> + Cancel mail alert + + + &alerttype=issue&biblionumber=" class="button" title="Be alerted when an issue arrive at the library"> + Be mailed when a new issue arrives at the library + + + +
diff --git a/opac/opac-alert-subscribe.pl b/opac/opac-alert-subscribe.pl index d357af4b0c..d0b68b195f 100755 --- a/opac/opac-alert-subscribe.pl +++ b/opac/opac-alert-subscribe.pl @@ -59,6 +59,7 @@ if ( $op eq 'alert_confirmed' ) { } elsif ( $op eq 'cancel_confirmed' ) { my $alerts = getalert( $loggedinuser, $alerttype, $externalid ); + warn "CANCEL confirmed : $loggedinuser, $alerttype, $externalid".Data::Dumper::Dumper( $alerts ); foreach (@$alerts) { # we are supposed to have only 1 result, but just in case... delalert( $_->{alertid} ); diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index b424ea7b3e..2dcb22b6c6 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -68,6 +68,7 @@ foreach my $subscription (@subscriptions) { $cell{subscriptionid} = $subscription->{subscriptionid}; $cell{subscriptionnotes} = $subscription->{notes}; $cell{branchcode} = $subscription->{branchcode}; + $cell{hasalert} = $subscription->{hasalert}; #get the three latest serials. $cell{latestserials} = GetLatestSerials( $subscription->{subscriptionid}, 3 ); diff --git a/opac/opac-serial-issues.pl b/opac/opac-serial-issues.pl index 4aceed9d8c..8fabccabc9 100755 --- a/opac/opac-serial-issues.pl +++ b/opac/opac-serial-issues.pl @@ -41,13 +41,6 @@ my $sth; my ( $template, $loggedinuser, $cookie ); my $biblionumber = $query->param('biblionumber'); if ( $selectview eq "full" ) { - my $subscriptions = GetFullSubscriptionsFromBiblionumber($biblionumber); - my $subscriptioninformation=PrepareSerialsData($subscriptions); - - my $title = $subscriptions->[0]{bibliotitle}; - my $yearmin = $subscriptions->[0]{year}; - my $yearmax = $subscriptions->[ scalar(@$subscriptions) - 1 ]{year}; - ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "opac-full-serial-issues.tmpl", @@ -57,6 +50,19 @@ if ( $selectview eq "full" ) { debug => 1, } ); + my $subscriptions = GetFullSubscriptionsFromBiblionumber($biblionumber); + my $subscriptioninformation=PrepareSerialsData($subscriptions); + # now, check is there is an alert subscription for one of the subscriptions + foreach (@$subscriptions) { + if (getalert($loggedinuser,'issue',$_->{subscriptionid})) { + $_->{hasalert} = 1; + } + } + + my $title = $subscriptions->[0]{bibliotitle}; + my $yearmin = $subscriptions->[0]{year}; + my $yearmax = $subscriptions->[ scalar(@$subscriptions) - 1 ]{year}; + # replace CR by
in librarian note # $subscription->{opacnote} =~ s/\n/\/g; @@ -73,8 +79,6 @@ if ( $selectview eq "full" ) { } else { - my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber); - ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "opac-serial-issues.tmpl", @@ -85,6 +89,16 @@ else { } ); + my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber); + # now, check is there is an alert subscription for one of the subscriptions + foreach (@$subscriptions) { + my $subscription = getalert($loggedinuser,'issue',$_->{subscriptionid}); + if (@$subscription[0]) { + warn ">>>>>>>>> has alert : loggedinuser / ".$_->{subscriptionid}; + $_->{hasalert} = 1; + } + } + # replace CR by
in librarian note # $subscription->{opacnote} =~ s/\n/\/g; -- 2.20.1