|
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 1885-1916
sub AddReturn {
Link Here
|
| 1885 |
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not |
1886 |
my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not |
| 1886 |
my $patron_unblessed = $patron ? $patron->unblessed : {}; |
1887 |
my $patron_unblessed = $patron ? $patron->unblessed : {}; |
| 1887 |
|
1888 |
|
| 1888 |
my $yaml_loc = C4::Context->preference('UpdateItemLocationOnCheckin'); |
1889 |
my $update_loc_rules = get_yaml_pref_hash('UpdateItemLocationOnCheckin'); |
| 1889 |
if ($yaml_loc) { |
1890 |
map { $update_loc_rules->{$_} = $update_loc_rules->{$_}[0] } keys %$update_loc_rules; #We can only move to one location so we flatten the arrays |
| 1890 |
$yaml_loc = "$yaml_loc\n\n"; # YAML is strict on ending \n. Surplus does not hurt |
1891 |
if ($update_loc_rules) { |
| 1891 |
my $rules; |
1892 |
if (defined $update_loc_rules->{_ALL_}) { |
| 1892 |
eval { $rules = YAML::Load($yaml_loc); }; |
1893 |
if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->{permanent_location}; } |
| 1893 |
if ($@) { |
1894 |
if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } |
| 1894 |
warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@"; |
1895 |
if ( $item->{location} ne $update_loc_rules->{_ALL_}) { |
|
|
1896 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $update_loc_rules->{_ALL_} }; |
| 1897 |
ModItem( { location => $update_loc_rules->{_ALL_} }, undef, $itemnumber ); |
| 1898 |
} |
| 1895 |
} |
1899 |
} |
| 1896 |
else { |
1900 |
else { |
| 1897 |
if (defined $rules->{_ALL_}) { |
1901 |
foreach my $key ( keys %$update_loc_rules ) { |
| 1898 |
if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; } |
1902 |
if ( $update_loc_rules->{$key} eq '_PERM_' ) { $update_loc_rules->{$key} = $item->{permanent_location}; } |
| 1899 |
if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; } |
1903 |
if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} |
| 1900 |
if ( $item->{location} ne $rules->{_ALL_}) { |
1904 |
if ( ($item->{location} eq $key && $item->{location} ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $update_loc_rules->{$key} ne '') ) { |
| 1901 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} }; |
1905 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $update_loc_rules->{$key} }; |
| 1902 |
ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber ); |
1906 |
ModItem( { location => $update_loc_rules->{$key} }, undef, $itemnumber ); |
| 1903 |
} |
1907 |
last; |
| 1904 |
} |
|
|
| 1905 |
else { |
| 1906 |
foreach my $key ( keys %$rules ) { |
| 1907 |
if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; } |
| 1908 |
if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;} |
| 1909 |
if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) { |
| 1910 |
$messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} }; |
| 1911 |
ModItem( { location => $rules->{$key} }, undef, $itemnumber ); |
| 1912 |
last; |
| 1913 |
} |
| 1914 |
} |
1908 |
} |
| 1915 |
} |
1909 |
} |
| 1916 |
} |
1910 |
} |
| 1917 |
- |
|
|