use constant PULL_INTERVAL => 2;
use List::MoreUtils qw( uniq );
use YAML::XS;
+use Encode;
use C4::Context;
-use C4::Output;
+use C4::Output qw( output_html_with_http_headers );
use CGI qw ( -utf8 );
-use C4::Auth;
-use C4::Debug;
-use C4::Items qw( ModItemTransfer );
+use C4::Auth qw( get_template_and_user );
+use C4::Items;
use C4::Reserves qw( ModReserveCancelAll );
use Koha::Biblios;
-use Koha::DateUtils;
+use Koha::DateUtils qw( dt_from_string );
use Koha::Holds;
use DateTime::Duration;
query => $input,
type => "intranet",
flagsrequired => { circulate => "circulate_remaining_permissions" },
- debug => 1,
}
);
},
);
if ( $letter ) {
- my $admin_email_address = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress');
+ my $from_address = $library->from_email_address;
C4::Letters::EnqueueLetter(
{ letter => $letter,
borrowernumber => $patron->borrowernumber,
message_transport_type => 'email',
- from_address => $admin_email_address,
+ from_address => $from_address,
}
);
unless ( $patron->notice_email_address ) {
if ( my $yaml = C4::Context->preference('UpdateItemWhenLostFromHoldList') ) {
$yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt
my $assignments;
- eval { $assignments = YAML::XS::Load($yaml); };
+ eval { $assignments = YAML::XS::Load(Encode::encode_utf8($yaml)); };
if ($@) {
warn "Unable to parse UpdateItemWhenLostFromHoldList syspref : $@" if $@;
}
}
# get all distinct unfulfilled reserves
-my @biblionumbers = Koha::Holds->search(
+my $holds = Koha::Holds->search(
{ %where },
{ join => 'itembib', alias => 'reserve', distinct => 1, columns => qw[me.biblionumber] }
-)->get_column('biblionumber');
-
-my @branchtransfers = map { $_->itemnumber } Koha::Item::Transfers->search({ datearrived => undef }, { columns => [ 'itemnumber' ], collapse => 1 });
-my @waiting_holds = map { $_->itemnumber } Koha::Holds->search({'found' => 'W'}, { columns => [ 'itemnumber' ], collapse => 1 });
-
-my @all_items = Koha::Items->search(
- {
- biblionumber => { in => \@biblionumbers },
- itemlost => 0,
- withdrawn => 0,
- notforloan => 0,
- onloan => undef,
- itemnumber => { -not_in => [ @branchtransfers, @waiting_holds ] },
- }
);
+my @biblionumbers = $holds->get_column('biblionumber');
my $all_items;
-foreach my $item ( @all_items ) {
+foreach my $item ( $holds->get_items_that_can_fill ) {
push @{$all_items->{$item->biblionumber}}, $item;
}