Lines 60-65
use Koha::Account::Lines;
Link Here
|
60 |
use Koha::Account::Offsets; |
60 |
use Koha::Account::Offsets; |
61 |
use Koha::Config::SysPrefs; |
61 |
use Koha::Config::SysPrefs; |
62 |
use Koha::Charges::Fees; |
62 |
use Koha::Charges::Fees; |
|
|
63 |
use Koha::Util::SystemPreferences; |
63 |
use Carp; |
64 |
use Carp; |
64 |
use List::MoreUtils qw( uniq any ); |
65 |
use List::MoreUtils qw( uniq any ); |
65 |
use Scalar::Util qw( looks_like_number ); |
66 |
use Scalar::Util qw( looks_like_number ); |
Lines 1881-1912
sub AddReturn {
Link Here
|
1881 |
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not |
1882 |
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not |
1882 |
my $patron_unblessed = $patron ? $patron->unblessed : {}; |
1883 |
my $patron_unblessed = $patron ? $patron->unblessed : {}; |
1883 |
|
1884 |
|
1884 |
my $yaml_loc = C4::Context->preference('UpdateItemLocationOnCheckin'); |
1885 |
my $update_loc_rules = get_yaml_pref_hash('UpdateItemLocationOnCheckin'); |
1885 |
if ($yaml_loc) { |
1886 |
map { $update_loc_rules->{$_} = $update_loc_rules->{$_}[0] } keys %$update_loc_rules; #We can only move to one location so we flatten the arrays |
1886 |
$yaml_loc = "$yaml_loc\n\n"; # YAML is strict on ending \n. Surplus does not hurt |
1887 |
if ($update_loc_rules) { |
1887 |
my $rules; |
1888 |
if (defined $update_loc_rules->{_ALL_}) { |
1888 |
eval { $rules = YAML::Load($yaml_loc); }; |
1889 |
if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->{permanent_location}; } |
1889 |
if ($@) { |
1890 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
1890 |
warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@"; |
1891 |
if ( $item->{location} ne $update_loc_rules->{_ALL_}) { |
|
|
1892 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $update_loc_rules->{_ALL_} }; |
1893 |
ModItem( { location => $update_loc_rules->{_ALL_} }, undef, $itemnumber ); |
1894 |
} |
1891 |
} |
1895 |
} |
1892 |
else { |
1896 |
else { |
1893 |
if (defined $rules->{_ALL_}) { |
1897 |
foreach my $key ( keys %$update_loc_rules ) { |
1894 |
if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; } |
1898 |
if ( $update_loc_rules->{$key} eq '_PERM_' ) { $update_loc_rules->{$key} = $item->{permanent_location}; } |
1895 |
if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; } |
1899 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
1896 |
if ( $item->{location} ne $rules->{_ALL_}) { |
1900 |
if ( ($item->{location} eq $key && $item->{location} ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $update_loc_rules->{$key} ne '') ) { |
1897 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} }; |
1901 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $update_loc_rules->{$key} }; |
1898 |
ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber ); |
1902 |
ModItem( { location => $update_loc_rules->{$key} }, undef, $itemnumber ); |
1899 |
} |
1903 |
last; |
1900 |
} |
|
|
1901 |
else { |
1902 |
foreach my $key ( keys %$rules ) { |
1903 |
if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; } |
1904 |
if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;} |
1905 |
if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) { |
1906 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} }; |
1907 |
ModItem( { location => $rules->{$key} }, undef, $itemnumber ); |
1908 |
last; |
1909 |
} |
1910 |
} |
1904 |
} |
1911 |
} |
1905 |
} |
1912 |
} |
1906 |
} |
1913 |
- |
|
|