1 package Koha::Illbatch;
3 # Copyright PTFS Europe 2022
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Koha::Illrequest::Logger;
23 use Koha::IllbatchStatus;
24 use JSON qw( to_json );
25 use base qw(Koha::Object);
29 Koha::Illbatch - Koha Illbatch Object class
35 my $status = Koha::Illbatch->status;
37 Return the status object associated with this batch
43 return Koha::IllbatchStatus->_new_from_dbic(
44 scalar $self->_result->statuscode
50 my $patron = Koha::Illbatch->patron;
52 Return the patron object associated with this batch
58 return Koha::Patron->_new_from_dbic(
59 scalar $self->_result->borrowernumber
65 my $branch = Koha::Illbatch->branch;
67 Return the branch object associated with this batch
73 return Koha::Library->_new_from_dbic(
74 scalar $self->_result->branchcode
80 my $requests_count = Koha::Illbatch->requests_count;
82 Return the number of requests associated with this batch
88 return Koha::Illrequests->search({
95 $batch->create_and_log;
97 Log batch creation following storage
106 my $logger = Koha::Illrequest::Logger->new;
108 $logger->log_something({
110 actionname => 'batch_create',
111 objectnumber => $self->id,
116 =head3 update_and_log
118 $batch->update_and_log;
120 Log batch update following storage
125 my ( $self, $params ) = @_;
129 branchcode => $self->branchcode
132 $self->set( $params );
133 my $update = $self->store;
137 branchcode => $self->branchcode
140 my $logger = Koha::Illrequest::Logger->new;
142 $logger->log_something({
144 actionname => 'batch_update',
145 objectnumber => $self->id,
153 =head3 delete_and_log
155 $batch->delete_and_log;
164 my $logger = Koha::Illrequest::Logger->new;
166 $logger->log_something({
168 actionname => 'batch_delete',
169 objectnumber => $self->id,
176 =head2 Internal methods
180 my $type = Koha::Illbatch->_type;
182 Return this object's type
192 Andrew Isherwood <andrew.isherwood@ptfs-europe.com>