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>.
24 use Koha::Illrequests;
25 use Koha::Illrequest::Logger;
26 use Koha::IllbatchStatuses;
30 use JSON qw( to_json );
31 use base qw(Koha::Object);
35 Koha::Illbatch - Koha Illbatch Object class
41 my $status = Koha::Illbatch->status;
43 Return the status object associated with this batch
49 return Koha::IllbatchStatus->_new_from_dbic( scalar $self->_result->status_code );
54 my $patron = Koha::Illbatch->patron;
56 Return the I<Koha::Patron> object associated with this batch
62 my $patron = $self->_result->patron;
63 return unless $patron;
64 return Koha::Patron->_new_from_dbic($patron);
69 my $library = Koha::Illbatch->library;
71 Return the I<Koha::Library> object associated with this batch
77 my $library = $self->_result->library;
78 return unless $library;
79 return Koha::Library->_new_from_dbic($library);
84 Return the I<Koha::Illrequests> for this batch
90 my $requests = $self->_result->requests;
91 return Koha::Illrequests->_new_from_dbic($requests);
96 $batch->create_and_log;
98 Log batch creation following storage
107 my $logger = Koha::Illrequest::Logger->new;
109 $logger->log_something(
112 actionname => 'batch_create',
113 objectnumber => $self->id,
114 infos => to_json( {} )
119 =head3 update_and_log
121 $batch->update_and_log;
123 Log batch update following storage
128 my ( $self, $params ) = @_;
132 library_id => $self->library_id,
136 my $update = $self->store;
140 library_id => $self->library_id,
143 my $logger = Koha::Illrequest::Logger->new;
145 $logger->log_something(
148 actionname => 'batch_update',
149 objectnumber => $self->id,
160 =head3 delete_and_log
162 $batch->delete_and_log;
171 my $logger = Koha::Illrequest::Logger->new;
173 $logger->log_something(
176 actionname => 'batch_delete',
177 objectnumber => $self->id,
178 infos => to_json( {} )
185 =head2 Internal methods
190 Returns a map of column name to string representations including the string,
191 the mapping type and the mapping category where appropriate.
193 Currently handles library and ILL batch status expansions.
196 Accepts a param hashref where the I<public> key denotes whether we want the public
197 or staff client strings.
199 Note: the I<public> parameter is not currently used.
204 my ( $self, $params ) = @_;
208 if ( defined $self->status_code ) {
209 my $status = $self->status;
212 $strings->{status_code} = {
213 str => $status->name,
214 type => 'ill_batch_status',
219 if ( defined $self->library_id ) {
220 my $library = $self->library;
223 $strings->{library_id} = {
224 str => $library->branchname,
235 my $type = Koha::Illbatch->_type;
237 Return this object's type
247 Andrew Isherwood <andrew.isherwood@ptfs-europe.com>