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( scalar $self->_result->statuscode );
48 my $patron = Koha::Illbatch->patron;
50 Return the patron object associated with this batch
56 return Koha::Patron->_new_from_dbic( scalar $self->_result->borrowernumber );
61 my $branch = Koha::Illbatch->branch;
63 Return the branch object associated with this batch
69 return Koha::Library->_new_from_dbic( scalar $self->_result->branchcode );
74 my $requests_count = Koha::Illbatch->requests_count;
76 Return the number of requests associated with this batch
82 return Koha::Illrequests->search( { batch_id => $self->id } )->count;
87 $batch->create_and_log;
89 Log batch creation following storage
98 my $logger = Koha::Illrequest::Logger->new;
100 $logger->log_something(
103 actionname => 'batch_create',
104 objectnumber => $self->id,
105 infos => to_json( {} )
110 =head3 update_and_log
112 $batch->update_and_log;
114 Log batch update following storage
119 my ( $self, $params ) = @_;
123 branchcode => $self->branchcode
127 my $update = $self->store;
131 branchcode => $self->branchcode
134 my $logger = Koha::Illrequest::Logger->new;
136 $logger->log_something(
139 actionname => 'batch_update',
140 objectnumber => $self->id,
151 =head3 delete_and_log
153 $batch->delete_and_log;
162 my $logger = Koha::Illrequest::Logger->new;
164 $logger->log_something(
167 actionname => 'batch_delete',
168 objectnumber => $self->id,
169 infos => to_json( {} )
176 =head2 Internal methods
180 my $type = Koha::Illbatch->_type;
182 Return this object's type
192 Andrew Isherwood <andrew.isherwood@ptfs-europe.com>