Lines 59-64
use Koha::RefundLostItemFeeRules;
Link Here
|
59 |
use Koha::Account::Lines; |
59 |
use Koha::Account::Lines; |
60 |
use Koha::Account::Offsets; |
60 |
use Koha::Account::Offsets; |
61 |
use Koha::Config::SysPrefs; |
61 |
use Koha::Config::SysPrefs; |
|
|
62 |
use Koha::Util::SystemPreferences; |
62 |
use Carp; |
63 |
use Carp; |
63 |
use List::MoreUtils qw( uniq any ); |
64 |
use List::MoreUtils qw( uniq any ); |
64 |
use Scalar::Util qw( looks_like_number ); |
65 |
use Scalar::Util qw( looks_like_number ); |
Lines 1840-1871
sub AddReturn {
Link Here
|
1840 |
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not |
1841 |
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not |
1841 |
my $patron_unblessed = $patron ? $patron->unblessed : {}; |
1842 |
my $patron_unblessed = $patron ? $patron->unblessed : {}; |
1842 |
|
1843 |
|
1843 |
my $yaml_loc = C4::Context->preference('UpdateItemLocationOnCheckin'); |
1844 |
my $update_loc_rules = get_yaml_pref_hash('UpdateItemLocationOnCheckin'); |
1844 |
if ($yaml_loc) { |
1845 |
map { $update_loc_rules->{$_} = $update_loc_rules->{$_}[0] } keys %$update_loc_rules; #We can only move to one location so we flatten the arrays |
1845 |
$yaml_loc = "$yaml_loc\n\n"; # YAML is strict on ending \n. Surplus does not hurt |
1846 |
if ($update_loc_rules) { |
1846 |
my $rules; |
1847 |
if (defined $update_loc_rules->{_ALL_}) { |
1847 |
eval { $rules = YAML::Load($yaml_loc); }; |
1848 |
if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->{permanent_location}; } |
1848 |
if ($@) { |
1849 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
1849 |
warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@"; |
1850 |
if ( $item->{location} ne $update_loc_rules->{_ALL_}) { |
|
|
1851 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $update_loc_rules->{_ALL_} }; |
1852 |
ModItem( { location => $update_loc_rules->{_ALL_} }, undef, $itemnumber ); |
1853 |
} |
1850 |
} |
1854 |
} |
1851 |
else { |
1855 |
else { |
1852 |
if (defined $rules->{_ALL_}) { |
1856 |
foreach my $key ( keys %$update_loc_rules ) { |
1853 |
if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; } |
1857 |
if ( $update_loc_rules->{$key} eq '_PERM_' ) { $update_loc_rules->{$key} = $item->{permanent_location}; } |
1854 |
if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; } |
1858 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
1855 |
if ( $item->{location} ne $rules->{_ALL_}) { |
1859 |
if ( ($item->{location} eq $key && $item->{location} ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $update_loc_rules->{$key} ne '') ) { |
1856 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} }; |
1860 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $update_loc_rules->{$key} }; |
1857 |
ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber ); |
1861 |
ModItem( { location => $update_loc_rules->{$key} }, undef, $itemnumber ); |
1858 |
} |
1862 |
last; |
1859 |
} |
|
|
1860 |
else { |
1861 |
foreach my $key ( keys %$rules ) { |
1862 |
if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; } |
1863 |
if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;} |
1864 |
if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) { |
1865 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} }; |
1866 |
ModItem( { location => $rules->{$key} }, undef, $itemnumber ); |
1867 |
last; |
1868 |
} |
1869 |
} |
1863 |
} |
1870 |
} |
1864 |
} |
1871 |
} |
1865 |
} |
1872 |
- |
|
|