|
Lines 7-23
package C4::SIP::ILS;
Link Here
|
| 7 |
use warnings; |
7 |
use warnings; |
| 8 |
use strict; |
8 |
use strict; |
| 9 |
use Sys::Syslog qw(syslog); |
9 |
use Sys::Syslog qw(syslog); |
|
|
10 |
use YAML qw(LoadFile Dump); |
| 11 |
use MARC::Record; |
| 12 |
use MARC::Transform; |
| 10 |
use Data::Dumper; |
13 |
use Data::Dumper; |
| 11 |
|
14 |
|
| 12 |
use C4::SIP::ILS::Item; |
15 |
use ILS::Item; |
| 13 |
use C4::SIP::ILS::Patron; |
16 |
use ILS::Patron; |
| 14 |
use C4::SIP::ILS::Transaction; |
17 |
use ILS::Transaction; |
| 15 |
use C4::SIP::ILS::Transaction::Checkout; |
18 |
use ILS::Transaction::Checkout; |
| 16 |
use C4::SIP::ILS::Transaction::Checkin; |
19 |
use ILS::Transaction::Checkin; |
| 17 |
use C4::SIP::ILS::Transaction::FeePayment; |
20 |
use ILS::Transaction::FeePayment; |
| 18 |
use C4::SIP::ILS::Transaction::Hold; |
21 |
use ILS::Transaction::Hold; |
| 19 |
use C4::SIP::ILS::Transaction::Renew; |
22 |
use ILS::Transaction::Renew; |
| 20 |
use C4::SIP::ILS::Transaction::RenewAll; |
23 |
use ILS::Transaction::RenewAll; |
|
|
24 |
use C4::Biblio qw(GetMarcBiblio); |
| 21 |
|
25 |
|
| 22 |
my $debug = 0; |
26 |
my $debug = 0; |
| 23 |
|
27 |
|
|
Lines 206-211
sub checkin {
Link Here
|
| 206 |
$circ->item( $item = C4::SIP::ILS::Item->new($item_id) ); |
210 |
$circ->item( $item = C4::SIP::ILS::Item->new($item_id) ); |
| 207 |
|
211 |
|
| 208 |
if ($item) { |
212 |
if ($item) { |
|
|
213 |
$self->_sortbin_checkin($item); # Call sorting robot handling |
| 209 |
$circ->do_checkin( $current_loc, $return_date ); |
214 |
$circ->do_checkin( $current_loc, $return_date ); |
| 210 |
} |
215 |
} |
| 211 |
else { |
216 |
else { |
|
Lines 243-248
sub checkin {
Link Here
|
| 243 |
return $circ; |
248 |
return $circ; |
| 244 |
} |
249 |
} |
| 245 |
|
250 |
|
|
|
251 |
# "SORTING ROBOT" HANDLING |
| 252 |
sub _sortbin_checkin { |
| 253 |
my ( $self, $item ) = @_; |
| 254 |
return unless defined $item; |
| 255 |
|
| 256 |
# to activate this code, it is necessary to add a few parameters in SIPconfig.xml |
| 257 |
# For the institution which will use the robot, add the following parameters |
| 258 |
# in the "sortbin" tag: |
| 259 |
# status="1" -> 1 to activate the module |
| 260 |
# subfield="995z" -> subfield which contains the value of the destination bin |
| 261 |
# transform="1" -> useful if the destination subfield has to be constructed |
| 262 |
# by checking the values of other fields, this way you can create a virtual subfield |
| 263 |
# which doesn't need to be configured in the MARC biblio framework. |
| 264 |
# transform_config_file="/home/koha/etc/sortbin_transform.yaml" -> absolute path to the sortbin config file. |
| 265 |
# reserve_config_file="/home/koha/etc/sortbin_reserves.yaml" -> absolute path to the reserve sortbin config file. |
| 266 |
|
| 267 |
my $sortbin_status; |
| 268 |
my $sortbin_subfield; |
| 269 |
my $sortbin_transform; |
| 270 |
my $sortbin_transform_path; |
| 271 |
my $sortbin_reserve_path; |
| 272 |
|
| 273 |
if ( defined $self->{institution}->{sortbin} ) { |
| 274 |
$sortbin_status = $self->{institution}->{sortbin}->{status} |
| 275 |
if ( defined $self->{institution}->{sortbin}->{status} ); |
| 276 |
$sortbin_subfield = $self->{institution}->{sortbin}->{subfield} |
| 277 |
if ( defined $self->{institution}->{sortbin}->{subfield} ); |
| 278 |
$sortbin_transform = $self->{institution}->{sortbin}->{transform} |
| 279 |
if ( defined $self->{institution}->{sortbin}->{transform} ); |
| 280 |
$sortbin_transform_path = $self->{institution}->{sortbin}->{transform_config_file} |
| 281 |
if ( defined $self->{institution}->{sortbin}->{transform_config_file} ); |
| 282 |
$sortbin_reserve_path = $self->{institution}->{sortbin}->{reserve_config_file} |
| 283 |
if ( defined $self->{institution}->{sortbin}->{reserve_config_file} ); |
| 284 |
} |
| 285 |
|
| 286 |
# Test feature is turned on |
| 287 |
unless ( $sortbin_status == 1 ) { |
| 288 |
return; |
| 289 |
} |
| 290 |
|
| 291 |
unless ( defined $sortbin_subfield ) { |
| 292 |
syslog( "LOG_ERR", "sortbin subfield must be defined" ); |
| 293 |
return; |
| 294 |
} |
| 295 |
my $marc_record_obj = C4::Biblio::GetMarcBiblio($item->{'biblionumber'}); |
| 296 |
unless ( defined $marc_record_obj ) { |
| 297 |
syslog( "LOG_ERR", "sortbin error calling GetMarcBiblio on biblionumber=%s", $item->{'biblionumber'} ); |
| 298 |
return; |
| 299 |
} |
| 300 |
|
| 301 |
# We add the 995 field related to the item, to run marctransform with only this one. |
| 302 |
my @itemnumbers = ( $item->{'itemnumber'} ); |
| 303 |
C4::Biblio::EmbedItemsInMarcBiblio($marc_record_obj, $item->{'biblionumber'}, \@itemnumbers); |
| 304 |
|
| 305 |
# We look for the sortbin number |
| 306 |
$item->{'sort_bin'} = undef; |
| 307 |
|
| 308 |
# priority to holds |
| 309 |
# if the document is reserved |
| 310 |
# and if the yaml file dedicated to holds contains something else than 0 in "sortbin_reserves" |
| 311 |
# then the document goes to the reserves bin |
| 312 |
my @reserves = @{ $item->{'hold_queue'} }; |
| 313 |
if ( scalar @reserves > 0 ) { |
| 314 |
my $sortbin_reserves_config = LoadFile($sortbin_reserve_path); |
| 315 |
if ( $sortbin_reserves_config->{'sortbin_reserves'} != 0 ) { |
| 316 |
$item->{'sort_bin'} = $sortbin_reserves_config->{'sortbin_reserves'}; |
| 317 |
} |
| 318 |
} |
| 319 |
|
| 320 |
# if the item is not reserved, proceed to the standard sort |
| 321 |
if ( !defined $item->{'sort_bin'} ) { |
| 322 |
if ( $sortbin_transform == 1 ) { |
| 323 |
|
| 324 |
# In Transform mode, we create a virtuel MARC field, |
| 325 |
# based on the values of other fields |
| 326 |
# The conversion is defined in a yaml file, |
| 327 |
# check the MARC::Transform doc for more information |
| 328 |
# The goal is to obtain a single MARC subfield containing the |
| 329 |
# value the bin where the document will have to be redirected, |
| 330 |
# with MARC::Transform you can create this subfield by checking |
| 331 |
# the values of several other MARC fields |
| 332 |
MARC::Transform->new( $marc_record_obj, $sortbin_transform_path ); |
| 333 |
} |
| 334 |
|
| 335 |
# obtained through Transform mode or already available in DB, |
| 336 |
# the MARC subfield containing the destination bin value is now available |
| 337 |
my $field = substr( $sortbin_subfield, 0, 3 ); |
| 338 |
my $subfield = substr( $sortbin_subfield, 3, 1 ); |
| 339 |
if ( defined $marc_record_obj->subfield( $field, $subfield ) ) { |
| 340 |
$item->{'sort_bin'} = $marc_record_obj->subfield( $field, $subfield ); |
| 341 |
} |
| 342 |
else { |
| 343 |
syslog( "LOG_ERR", "sortbin undefined value in subfield %s", $sortbin_subfield ); |
| 344 |
return; |
| 345 |
} |
| 346 |
} |
| 347 |
} |
| 348 |
|
| 246 |
# If the ILS caches patron information, this lets it free |
349 |
# If the ILS caches patron information, this lets it free |
| 247 |
# it up |
350 |
# it up |
| 248 |
sub end_patron_session { |
351 |
sub end_patron_session { |