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;
# 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;
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},
);
--- /dev/null
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><!-- TMPL_IF NAME="LibraryNameTitle" --><!-- TMPL_VAR NAME="LibraryNameTitle" --><!-- TMPL_ELSE -->Koha Online<!-- /TMPL_IF --> Catalog › Serials
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+</head>
+<body>
+<!-- TMPL_INCLUDE name="masthead.inc" -->
+
+<div id="doc3" class="yui-t1">
+<div id="bd">
+ <div id="yui-main">
+ <div class="yui-b"><div class="yui-g">
+ <!-- TMPL_IF name="typeissue" -->
+ <h1 class="catalogue">Subscribe issue recieve warning</h1>
+ <form action="opac-alert-subscribe.pl" method="post">
+ <p>Do you want to be mailed when a new issue for this subscription arrives at the library ?</p>
+ <!-- TMPL_VAR name="bibliotitle" --> <!-- TMPL_IF name="notes" -->(<!-- TMPL_VAR name="notes" -->)<!-- /TMPL_IF --> arrive ?</p>
+ <input type="hidden" name="externalid" value="<!-- TMPL_VAR name="externalid" -->">
+ <input type="hidden" name="alerttype" value="issue">
+ <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR name="biblionumber" -->">
+ <input type="hidden" name="op" value="alert_confirmed">
+ <input type="submit" value="Yes">
+ <a href="opac-serial-issues.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->" >No</a>
+ </form>
+ </div>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="typeissuecancel" -->
+ <h1 class="catalogue">Unsubscribe</h1>
+ <form action="opac-alert-subscribe.pl" method="post">
+ <p>Do you confirm you want to unsubscribe mail warning for this subscription ?</p>
+ <!-- TMPL_VAR name="bibliotitle" --> <!-- TMPL_IF name="notes" -->(<!-- TMPL_VAR name="notes" -->)<!-- /TMPL_IF --> ?</p>
+ <input type="hidden" name="externalid" value="<!-- TMPL_VAR name="externalid" -->">
+ <input type="hidden" name="alerttype" value="issue">
+ <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR name="biblionumber" -->">
+ <input type="hidden" name="op" value="cancel_confirmed">
+ <input type="submit" value="Yes" class="button">
+ <a href="opac-serial-issues.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->" class="button">No</a>
+ </form>
+ </div>
+ <!-- /TMPL_IF -->
+</div>
+
+<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
</table>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
+ <p><a href="opac-serial-issues.pl?biblionumber=<!-- TMPl_VAR name="biblionumber" -->">More details</a></p>
</div>
<!-- /TMPL_IF -->
<!-- TMPL_VAR name="opacnote" -->
</p>
<!-- /TMPL_IF -->
+ <!-- TMPL_IF name="letter" -->
+ <!-- TMPL_IF name="hasalert" -->
+ You already follow this subscription <a href="opac-alert-subscribe.pl?op=cancel&externalid=<!-- TMPL_VAR name="subscriptionid" -->&alerttype=issue&biblionumber=<!-- TMPL_VAR name="biblionumber" -->" class="button" title="Cancel alert">
+ Cancel mail alert
+ </a>
+ <!-- TMPL_ELSE -->
+ <a href="opac-alert-subscribe.pl?externalid=<!-- TMPL_VAR name="subscriptionid" -->&alerttype=issue&biblionumber=<!-- TMPL_VAR name="biblionumber" -->" class="button" title="Be alerted when an issue arrive at the library">
+ Be mailed when a new issue arrives at the library
+ </a>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_IF -->
+
<!-- /TMPL_LOOP -->
</div>
}
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} );
$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 );
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",
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 <br> in librarian note
# $subscription->{opacnote} =~ s/\n/\<br\/\>/g;
}
else {
- my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
-
( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "opac-serial-issues.tmpl",
}
);
+ 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 <br> in librarian note
# $subscription->{opacnote} =~ s/\n/\<br\/\>/g;