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

(-)a/C4/Letters.pm (-32 / +1 lines)
Lines 45-51 BEGIN { Link Here
45
    require Exporter;
45
    require Exporter;
46
    @ISA = qw(Exporter);
46
    @ISA = qw(Exporter);
47
    @EXPORT = qw(
47
    @EXPORT = qw(
48
        &GetLetters &GetLettersAvailableForALibrary &GetLetterTemplates &DelLetter &GetPreparedLetter &GetWrappedLetter &addalert &getalert &delalert &findrelatedto &SendAlerts &GetPrintMessages &GetMessageTransportTypes
48
        &GetLetters &GetLettersAvailableForALibrary &GetLetterTemplates &DelLetter &GetPreparedLetter &GetWrappedLetter &addalert &getalert &delalert &SendAlerts &GetPrintMessages &GetMessageTransportTypes
49
    );
49
    );
50
}
50
}
51
51
Lines 336-372 sub getalert { Link Here
336
    return $sth->fetchall_arrayref({});
336
    return $sth->fetchall_arrayref({});
337
}
337
}
338
338
339
=head2 findrelatedto($type, $externalid)
340
341
    parameters :
342
    - $type : the type of alert
343
    - $externalid : the id of the "object" to query
344
345
    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.
346
    When type=issue, the id is related to a subscriptionid and this sub returns the name of the biblio.
347
348
=cut
349
    
350
# outmoded POD:
351
# When type=virtual, the id is related to a virtual shelf and this sub returns the name of the sub
352
353
sub findrelatedto {
354
    my $type       = shift or return;
355
    my $externalid = shift or return;
356
    my $q = ($type eq 'issue'   ) ?
357
"select title as result from subscription left join biblio on subscription.biblionumber=biblio.biblionumber where subscriptionid=?" :
358
            ($type eq 'borrower') ?
359
"select concat(firstname,' ',surname) from borrowers where borrowernumber=?" : undef;
360
    unless ($q) {
361
        warn "findrelatedto(): Illegal type '$type'";
362
        return;
363
    }
364
    my $sth = C4::Context->dbh->prepare($q);
365
    $sth->execute($externalid);
366
    my ($result) = $sth->fetchrow;
367
    return $result;
368
}
369
370
=head2 SendAlerts
339
=head2 SendAlerts
371
340
372
    my $err = &SendAlerts($type, $externalid, $letter_code);
341
    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