@@ -, +, @@ checkin to the following (assuming sample data): NEW: FIC FIC: GEN Arcadia Public Library (http://library.ci.arcadia.ca.us/) Middletown Township Public Library (http://www.mtpl.org/) --- C4/Circulation.pm | 19 +++++++++++++++++++ circ/returns.pl | 3 +++ ..._14576-add_UpdateItemLocationOnCheckin_syspref.sql | 1 + installer/data/mysql/sysprefs.sql | 1 + .../en/modules/admin/preferences/circulation.pref | 7 +++++++ .../intranet-tmpl/prog/en/modules/circ/returns.tt | 13 +++++++++++++ 6 files changed, 44 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_14576-add_UpdateItemLocationOnCheckin_syspref.sql --- a/C4/Circulation.pm +++ a/C4/Circulation.pm @@ -1852,6 +1852,25 @@ sub AddReturn { my $borrowernumber = $borrower->{'borrowernumber'} || undef; # we don't know if we had a borrower or not + my $yaml = C4::Context->preference('UpdateItemLocationOnCheckin'); + if ($yaml) { + $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt + my $rules; + eval { $rules = YAML::Load($yaml); }; + if ($@) { + warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@"; + } + else { + foreach my $key ( keys %$rules ) { + if ( $item->{location} eq $key ) { + $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} }; + ModItem( { location => $rules->{$key} }, undef, $itemnumber ); + last; + } + } + } + } + my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin'); if ($yaml) { $yaml = "$yaml\n\n"; # YAML is anal on ending \n. Surplus does not hurt --- a/circ/returns.pl +++ a/circ/returns.pl @@ -523,6 +523,9 @@ foreach my $code ( keys %$messages ) { elsif ( $code eq 'ForeverDebarred' ) { $err{foreverdebarred} = $messages->{'ForeverDebarred'}; } + elsif ( $code eq 'ItemLocationUpdated' ) { + $err{ItemLocationUpdated} = $messages->{ItemLocationUpdated}; + } elsif ( $code eq 'NotForLoanStatusUpdated' ) { $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated}; } --- a/installer/data/mysql/atomicupdate/bug_14576-add_UpdateItemLocationOnCheckin_syspref.sql +++ a/installer/data/mysql/atomicupdate/bug_14576-add_UpdateItemLocationOnCheckin_syspref.sql @@ -0,0 +1, @@ +INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('UpdateItemLocationOnCheckin', '', 'NULL', 'This a list of value pairs. When an item is checked in, if the location value on the left matches the items location value it will be updated to the right-hand value. E.g. ''PROC: FIC'' will cause an item that was set to ''Book Cart'' to now be in the ''Fiction'' shelving location. Each pair of values should be on a separate line.', 'Free'); --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -482,6 +482,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'), ('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'), ('UniqueItemFields','barcode','','Space-separated list of fields that should be unique (used in acquisition module for item creation). Fields must be valid SQL column names of items table','Free'), +('UpdateItemLocationOnCheckin', '', 'NULL', 'This is a list of value pairs. When an item is checked in, if the location value on the left matches the items location value it will be updated to the right-hand value. E.g. ''PROC: FIC'' will cause an item that was set to ''Book Cart'' to now be in the ''Fiction'' shelving location. Each pair of values should be on a separate line.', 'Free'), ('UpdateNotForLoanStatusOnCheckin', '', 'NULL', 'This is a list of value pairs. When an item is checked in, if the not for loan value on the left matches the items not for loan value it will be updated to the right-hand value. E.g. ''-1: 0'' will cause an item that was set to ''Ordered'' to now be available for loan. Each pair of values should be on a separate line.', 'Free'), ('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'), ('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -423,6 +423,13 @@ Circulation: - calculate and update overdue charges when an item is returned. -
NOTE If you are doing hourly loans then you should have this on. - + - pref: UpdateItemLocationOnCheckin + type: textarea + class: code + - This is is a list of value pairs. When an item is checked in, if the location value on the left matches the items location value + - "it will be updated to the right-hand value. E.g. ''PROC: FIC'' will cause an item that was set to ''Book Cart'' to now be in the ''Fiction'' shelving location. " + - Each pair of values should be on a separate line. + - - pref: UpdateNotForLoanStatusOnCheckin type: textarea class: code --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -426,6 +426,19 @@ $(document).ready(function () { [% END %]

[% END %] + [% IF ( errmsgloo.ItemLocationUpdated ) %] +

+ Item location updated + from + [% IF errmsgloo.ItemLocationUpdated.from %] + [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) %] + [% END %] + to + [% IF errmsgloo.ItemLocationUpdated.to %] + [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) %] + [% END %] +

+ [% END %] [% IF ( errmsgloo.badbarcode ) %]

No item with barcode: [% errmsgloo.msg %]

[% END %] --