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

(-)a/C4/Circulation.pm (-4 / +6 lines)
Lines 3366-3378 sub SendCirculationAlert { Link Here
3366
        $schema->storage->txn_begin;
3366
        $schema->storage->txn_begin;
3367
        C4::Context->dbh->do(q|LOCK TABLE message_queue READ|) unless $do_not_lock;
3367
        C4::Context->dbh->do(q|LOCK TABLE message_queue READ|) unless $do_not_lock;
3368
        C4::Context->dbh->do(q|LOCK TABLE message_queue WRITE|) unless $do_not_lock;
3368
        C4::Context->dbh->do(q|LOCK TABLE message_queue WRITE|) unless $do_not_lock;
3369
        my $message = C4::Message->find_last_message($borrower, $type, $mtt);
3369
        my @messages = C4::Message->find_last_messages($borrower, $type, $mtt);
3370
        unless ( $message ) {
3370
        unless ( @messages ) {
3371
            C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
3371
            C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
3372
            C4::Message->enqueue($letter, $borrower, $mtt);
3372
            C4::Message->enqueue($letter, $borrower, $mtt);
3373
        } else {
3373
        } else {
3374
            $message->append($letter);
3374
            foreach my $message (@messages) {
3375
            $message->update;
3375
                $message->append($letter);
3376
                $message->update;
3377
            }
3376
        }
3378
        }
3377
        C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
3379
        C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
3378
        $schema->storage->txn_commit;
3380
        $schema->storage->txn_commit;
(-)a/C4/Message.pm (-12 / +8 lines)
Lines 53-59 How to update a borrower's last checkout message: Link Here
53
53
54
  use C4::Message;
54
  use C4::Message;
55
  my $borrower = { borrowernumber => 1 };
55
  my $borrower = { borrowernumber => 1 };
56
  my $message  = C4::Message->find_last_message($borrower, 'CHECKOUT', 'email');
56
  my $message  = C4::Message->find_last_messages($borrower, 'CHECKOUT', 'email');
57
  $message->append("you also checked out some other book....");
57
  $message->append("you also checked out some other book....");
58
  $message->update;
58
  $message->update;
59
59
Lines 110-126 sub find { Link Here
110
    }
110
    }
111
}
111
}
112
112
113
=head3 C4::Message->find_last_message($borrower, $letter_code, $transport)
113
=head3 C4::Message->find_last_messages($borrower, $letter_code, $transport)
114
114
115
This method is used to get the borrower's most recent, pending, check-in or
115
This method is used to get the borrower's most recent, pending, check-in or
116
checkout message.  (This makes it possible to add more information to the
116
checkout messages.  (This makes it possible to add more information to the
117
message before it gets sent out.)
117
message before it gets sent out.)
118
118
119
=cut
119
=cut
120
120
121
# C4::Message->find_last_message($borrower, $letter_code, $transport)
121
# C4::Message->find_last_messages($borrower, $letter_code, $transport)
122
# -- get the borrower's most recent pending checkin or checkout notification
122
# -- get the borrower's most recent pending checkin or checkout notifications
123
sub find_last_message {
123
sub find_last_messages {
124
    my ($class, $borrower, $letter_code, $transport) = @_;
124
    my ($class, $borrower, $letter_code, $transport) = @_;
125
    # $type is the message_transport_type
125
    # $type is the message_transport_type
126
    $transport ||= 'email';
126
    $transport ||= 'email';
Lines 139-149 sub find_last_message { Link Here
139
        $letter_code,
139
        $letter_code,
140
        $transport,
140
        $transport,
141
    );
141
    );
142
    if (@$msgs) {
142
143
        return $class->new($msgs->[0]);
143
    return map { $class->new($_) } @$msgs;
144
    } else {
145
        return;
146
    }
147
}
144
}
148
145
149
146
150
- 

Return to bug 12802