View | Details | Raw Unified | Return to bug 19855
Collapse All | Expand All

(-)a/C4/Letters.pm (-32 / +1 lines)
Lines 46-52 BEGIN { Link Here
46
    require Exporter;
46
    require Exporter;
47
    @ISA = qw(Exporter);
47
    @ISA = qw(Exporter);
48
    @EXPORT = qw(
48
    @EXPORT = qw(
49
        &GetLetters &GetLettersAvailableForALibrary &GetLetterTemplates &DelLetter &GetPreparedLetter &GetWrappedLetter &addalert &getalert &delalert &findrelatedto &SendAlerts &GetPrintMessages &GetMessageTransportTypes
49
        &GetLetters &GetLettersAvailableForALibrary &GetLetterTemplates &DelLetter &GetPreparedLetter &GetWrappedLetter &addalert &getalert &delalert &SendAlerts &GetPrintMessages &GetMessageTransportTypes
50
    );
50
    );
51
}
51
}
52
52
Lines 337-373 sub getalert { Link Here
337
    return $sth->fetchall_arrayref({});
337
    return $sth->fetchall_arrayref({});
338
}
338
}
339
339
340
=head2 findrelatedto($type, $externalid)
341
342
    parameters :
343
    - $type : the type of alert
344
    - $externalid : the id of the "object" to query
345
346
    In the table alert, a "id" is stored in the externalid field. This "id" is related to another table, depending on the type of the alert.
347
    When type=issue, the id is related to a subscriptionid and this sub returns the name of the biblio.
348
349
=cut
350
    
351
# outmoded POD:
352
# When type=virtual, the id is related to a virtual shelf and this sub returns the name of the sub
353
354
sub findrelatedto {
355
    my $type       = shift or return;
356
    my $externalid = shift or return;
357
    my $q = ($type eq 'issue'   ) ?
358
"select title as result from subscription left join biblio on subscription.biblionumber=biblio.biblionumber where subscriptionid=?" :
359
            ($type eq 'borrower') ?
360
"select concat(firstname,' ',surname) from borrowers where borrowernumber=?" : undef;
361
    unless ($q) {
362
        warn "findrelatedto(): Illegal type '$type'";
363
        return;
364
    }
365
    my $sth = C4::Context->dbh->prepare($q);
366
    $sth->execute($externalid);
367
    my ($result) = $sth->fetchrow;
368
    return $result;
369
}
370
371
=head2 SendAlerts
340
=head2 SendAlerts
372
341
373
    my $err = &SendAlerts($type, $externalid, $letter_code);
342
    my $err = &SendAlerts($type, $externalid, $letter_code);
(-)a/serials/viewalerts.pl (-3 / +4 lines)
Lines 46-53 my $subscriptionid=$input->param('subscriptionid'); Link Here
46
my $borrowers = getalert('','issue',$subscriptionid);
46
my $borrowers = getalert('','issue',$subscriptionid);
47
my $subscription = GetSubscription($subscriptionid);
47
my $subscription = GetSubscription($subscriptionid);
48
48
49
foreach (@$borrowers) {
49
for my $borrowernumber (@$borrowers) {
50
    $_->{name} = findrelatedto('borrower',$_->{borrowernumber});
50
    my $patron = Koha::Patrons->find( $borrowernumber );
51
    next unless $borrowernumber; # Just in case...
52
    $borrowers->{name} = join( ' ', $patron->firstname, $patron->surname );
51
}
53
}
52
$template->param(alertloop => $borrowers,
54
$template->param(alertloop => $borrowers,
53
                bibliotitle => $subscription->{bibliotitle},
55
                bibliotitle => $subscription->{bibliotitle},
54
- 

Return to bug 19855