Bugzilla – Attachment 85852 Details for
Bug 14576
Allow automatic update of location on checkin
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14576: Update to use get_yaml_pref_hash
Bug-14576-Update-to-use-getyamlprefhash.patch (text/plain), 4.04 KB, created by
Nick Clemens (kidclamp)
on 2019-02-28 11:55:31 UTC
(
hide
)
Description:
Bug 14576: Update to use get_yaml_pref_hash
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-02-28 11:55:31 UTC
Size:
4.04 KB
patch
obsolete
>From 1017fb222a65b8df7836bc215004dbe961c3e9e9 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 12 Dec 2018 13:30:11 +0000 >Subject: [PATCH] Bug 14576: Update to use get_yaml_pref_hash > >--- > C4/Circulation.pm | 42 ++++++++++++++++++------------------------ > 1 file changed, 18 insertions(+), 24 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index e8a84af107..de52be1aa8 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -59,6 +59,7 @@ use Koha::RefundLostItemFeeRules; > use Koha::Account::Lines; > use Koha::Account::Offsets; > use Koha::Config::SysPrefs; >+use Koha::Util::SystemPreferences; > use Carp; > use List::MoreUtils qw( uniq any ); > use Scalar::Util qw( looks_like_number ); >@@ -1851,32 +1852,25 @@ sub AddReturn { > my $borrowernumber = $patron ? $patron->borrowernumber : undef; # we don't know if we had a borrower or not > my $patron_unblessed = $patron ? $patron->unblessed : {}; > >- my $yaml_loc = C4::Context->preference('UpdateItemLocationOnCheckin'); >- if ($yaml_loc) { >- $yaml_loc = "$yaml_loc\n\n"; # YAML is strict on ending \n. Surplus does not hurt >- my $rules; >- eval { $rules = YAML::Load($yaml_loc); }; >- if ($@) { >- warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@"; >+ my $update_loc_rules = get_yaml_pref_hash('UpdateItemLocationOnCheckin'); >+ map { $update_loc_rules->{$_} = $update_loc_rules->{$_}[0] } keys %$update_loc_rules; #We can only move to one location so we flatten the arrays >+ if ($update_loc_rules) { >+ if (defined $update_loc_rules->{_ALL_}) { >+ if ($update_loc_rules->{_ALL_} eq '_PERM_') { $update_loc_rules->{_ALL_} = $item->{permanent_location}; } >+ if ($update_loc_rules->{_ALL_} eq '_BLANK_') { $update_loc_rules->{_ALL_} = ''; } >+ if ( $item->{location} ne $update_loc_rules->{_ALL_}) { >+ $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $update_loc_rules->{_ALL_} }; >+ ModItem( { location => $update_loc_rules->{_ALL_} }, undef, $itemnumber ); >+ } > } > else { >- if (defined $rules->{_ALL_}) { >- if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; } >- if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; } >- if ( $item->{location} ne $rules->{_ALL_}) { >- $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} }; >- ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber ); >- } >- } >- else { >- foreach my $key ( keys %$rules ) { >- if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; } >- if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;} >- if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) { >- $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} }; >- ModItem( { location => $rules->{$key} }, undef, $itemnumber ); >- last; >- } >+ foreach my $key ( keys %$update_loc_rules ) { >+ if ( $update_loc_rules->{$key} eq '_PERM_' ) { $update_loc_rules->{$key} = $item->{permanent_location}; } >+ if ( $update_loc_rules->{$key} eq '_BLANK_') { $update_loc_rules->{$key} = '' ;} >+ if ( ($item->{location} eq $key && $item->{location} ne $update_loc_rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $update_loc_rules->{$key} ne '') ) { >+ $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $update_loc_rules->{$key} }; >+ ModItem( { location => $update_loc_rules->{$key} }, undef, $itemnumber ); >+ last; > } > } > } >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14576
:
46454
|
46455
|
46456
|
48258
|
48259
|
50662
|
50663
|
52195
|
52196
|
52197
|
52204
|
52205
|
52206
|
52222
|
52223
|
52224
|
52365
|
53112
|
53113
|
53114
|
53115
|
54281
|
54644
|
54645
|
54646
|
54647
|
54648
|
54654
|
55587
|
60658
|
60659
|
60660
|
60661
|
60662
|
60663
|
60747
|
60748
|
60751
|
61940
|
61941
|
61942
|
61944
|
61945
|
61946
|
61947
|
61948
|
61949
|
61950
|
64656
|
64657
|
64658
|
67610
|
67611
|
68297
|
70795
|
70796
|
70797
|
72032
|
72033
|
72034
|
75661
|
75662
|
75663
|
79245
|
79246
|
79995
|
79996
|
83113
|
83114
|
83115
|
83696
|
83697
|
83698
|
85406
|
85850
|
85851
|
85852
|
85853
|
86812
|
86813
|
86814
|
86815
|
86816
|
87040
|
87061
|
87144
|
87145
|
87146
|
87147
|
87148
|
87149
|
87150
|
87151
|
87925
|
88451
|
88452
|
88453
|
88454
|
88455
|
88456
|
88457
|
88458
|
88459
|
88646
|
88647
|
88648
|
88649
|
88650
|
88651
|
88652
|
88653
|
88654