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

(-)a/C4/Circulation.pm (-4 / +6 lines)
Lines 3362-3374 sub SendCirculationAlert { Link Here
3362
        $schema->storage->txn_begin;
3362
        $schema->storage->txn_begin;
3363
        C4::Context->dbh->do(q|LOCK TABLE message_queue READ|) unless $do_not_lock;
3363
        C4::Context->dbh->do(q|LOCK TABLE message_queue READ|) unless $do_not_lock;
3364
        C4::Context->dbh->do(q|LOCK TABLE message_queue WRITE|) unless $do_not_lock;
3364
        C4::Context->dbh->do(q|LOCK TABLE message_queue WRITE|) unless $do_not_lock;
3365
        my $message = C4::Message->find_last_message($borrower, $type, $mtt);
3365
        my @messages = C4::Message->find_last_messages($borrower, $type, $mtt);
3366
        unless ( $message ) {
3366
        unless ( @messages ) {
3367
            C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
3367
            C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
3368
            C4::Message->enqueue($letter, $borrower, $mtt);
3368
            C4::Message->enqueue($letter, $borrower, $mtt);
3369
        } else {
3369
        } else {
3370
            $message->append($letter);
3370
            foreach my $message (@messages) {
3371
            $message->update;
3371
                $message->append($letter);
3372
                $message->update;
3373
            }
3372
        }
3374
        }
3373
        C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
3375
        C4::Context->dbh->do(q|UNLOCK TABLES|) unless $do_not_lock;
3374
        $schema->storage->txn_commit;
3376
        $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