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

(-)a/C4/Letters.pm (-4 / +17 lines)
Lines 390-407 sub SendAlerts { Link Here
390
    if ( $type eq 'issue' ) {
390
    if ( $type eq 'issue' ) {
391
391
392
        # prepare the letter...
392
        # prepare the letter...
393
        # search the biblionumber
393
        # search the subscriptionid
394
        my $sth =
394
        my $sth =
395
          $dbh->prepare(
395
          $dbh->prepare(
396
            "SELECT biblionumber FROM subscription WHERE subscriptionid=?");
396
            "SELECT subscriptionid FROM serial WHERE serialid=?");
397
        $sth->execute($externalid);
397
        $sth->execute($externalid);
398
        my ($biblionumber) = $sth->fetchrow
398
        my ($subscriptionid) = $sth->fetchrow
399
          or warn( "No subscription for '$externalid'" ),
399
          or warn( "No subscription for '$externalid'" ),
400
             return;
400
             return;
401
401
402
        # search the biblionumber
403
        $sth =
404
          $dbh->prepare(
405
            "SELECT biblionumber FROM subscription WHERE subscriptionid=?");
406
        $sth->execute($subscriptionid);
407
        my ($biblionumber) = $sth->fetchrow
408
          or warn( "No biblionumber for '$subscriptionid'" ),
409
             return;
410
402
        my %letter;
411
        my %letter;
403
        # find the list of borrowers to alert
412
        # find the list of borrowers to alert
404
        my $alerts = getalert( '', 'issue', $externalid );
413
        my $alerts = getalert( '', 'issue', $subscriptionid );
405
        foreach (@$alerts) {
414
        foreach (@$alerts) {
406
            my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'});
415
            my $borinfo = C4::Members::GetMember('borrowernumber' => $_->{'borrowernumber'});
407
            my $email = $borinfo->{email} or next;
416
            my $email = $borinfo->{email} or next;
Lines 418-423 sub SendAlerts { Link Here
418
                    'biblio'      => $biblionumber,
427
                    'biblio'      => $biblionumber,
419
                    'biblioitems' => $biblionumber,
428
                    'biblioitems' => $biblionumber,
420
                    'borrowers'   => $borinfo,
429
                    'borrowers'   => $borinfo,
430
                    'subscription' => $subscriptionid,
431
                    'serial' => $externalid,
421
                },
432
                },
422
                want_librarian => 1,
433
                want_librarian => 1,
423
            ) or return;
434
            ) or return;
Lines 759-764 sub _parseletter_sth { Link Here
759
    ($table eq 'aqorders'     ) ? "SELECT * FROM $table WHERE    ordernumber = ?"                                  :
770
    ($table eq 'aqorders'     ) ? "SELECT * FROM $table WHERE    ordernumber = ?"                                  :
760
    ($table eq 'opac_news'    ) ? "SELECT * FROM $table WHERE          idnew = ?"                                  :
771
    ($table eq 'opac_news'    ) ? "SELECT * FROM $table WHERE          idnew = ?"                                  :
761
    ($table eq 'borrower_modifications') ? "SELECT * FROM $table WHERE verification_token = ?" :
772
    ($table eq 'borrower_modifications') ? "SELECT * FROM $table WHERE verification_token = ?" :
773
    ($table eq 'subscription') ? "SELECT * FROM $table WHERE subscriptionid = ?" :
774
    ($table eq 'serial') ? "SELECT * FROM $table WHERE serialid = ?" :
762
    undef ;
775
    undef ;
763
    unless ($query) {
776
    unless ($query) {
764
        warn "ERROR: No _parseletter_sth query for table '$table'";
777
        warn "ERROR: No _parseletter_sth query for table '$table'";
(-)a/C4/Serials.pm (-1 / +1 lines)
Lines 1149-1155 sub ModSerialStatus { Link Here
1149
        # check if an alert must be sent... (= a letter is defined & status became "arrived"
1149
        # check if an alert must be sent... (= a letter is defined & status became "arrived"
1150
        if ( $subscription->{letter} && $status == ARRIVED && $oldstatus != ARRIVED ) {
1150
        if ( $subscription->{letter} && $status == ARRIVED && $oldstatus != ARRIVED ) {
1151
            require C4::Letters;
1151
            require C4::Letters;
1152
            C4::Letters::SendAlerts( 'issue', $subscription->{subscriptionid}, $subscription->{letter} );
1152
            C4::Letters::SendAlerts( 'issue', $serialid, $subscription->{letter} );
1153
        }
1153
        }
1154
    }
1154
    }
1155
1155
(-)a/tools/letter.pl (-1 / +3 lines)
Lines 213-218 sub add_form { Link Here
213
            push @{$field_selection}, {value => "biblio.$_", text => ucfirst $_ };
213
            push @{$field_selection}, {value => "biblio.$_", text => ucfirst $_ };
214
        }
214
        }
215
    }
215
    }
216
    elsif ($module eq 'serial') {
217
        push @{$field_selection}, add_fields('branches', 'biblio', 'biblioitems', 'borrowers', 'subscription', 'serial');
218
    }
216
    elsif ($module eq 'suggestions') {
219
    elsif ($module eq 'suggestions') {
217
        push @{$field_selection}, add_fields('suggestions', 'borrowers', 'biblio');
220
        push @{$field_selection}, add_fields('suggestions', 'borrowers', 'biblio');
218
    }
221
    }
219
- 

Return to bug 13972