View | Details | Raw Unified | Return to bug 14576
Collapse All | Expand All

(-)a/C4/Circulation.pm (-14 / +40 lines)
Lines 1451-1456 sub AddIssue { Link Here
1451
                }
1451
                }
1452
              );
1452
              );
1453
1453
1454
        if ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART'  ) {
1455
        ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
1456
          CartToShelf( $item->{'itemnumber'} );
1457
        }
1458
        $item->{'issues'}++;
1459
        if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) {
1460
            UpdateTotalIssues($item->{'biblionumber'}, 1);
1461
        }
1462
1454
            if ( C4::Context->preference('ReturnToShelvingCart') ) {
1463
            if ( C4::Context->preference('ReturnToShelvingCart') ) {
1455
                # ReturnToShelvingCart is on, anything issued should be taken off the cart.
1464
                # ReturnToShelvingCart is on, anything issued should be taken off the cart.
1456
                CartToShelf( $item->{'itemnumber'} );
1465
                CartToShelf( $item->{'itemnumber'} );
Lines 1965-1981 sub AddReturn { Link Here
1965
1974
1966
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1975
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1967
1976
1968
    if ( $item->{'location'} eq 'PROC' ) {
1969
        if ( C4::Context->preference("InProcessingToShelvingCart") ) {
1970
            $item->{'location'} = 'CART';
1971
        }
1972
        else {
1973
            $item->{location} = $item->{permanent_location};
1974
        }
1975
1976
        ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
1977
    }
1978
1979
        # full item data, but no borrowernumber or checkout info (no issue)
1977
        # full item data, but no borrowernumber or checkout info (no issue)
1980
        # we know GetItem should work because GetItemnumberFromBarcode worked
1978
        # we know GetItem should work because GetItemnumberFromBarcode worked
1981
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1979
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
Lines 1985-1990 sub AddReturn { Link Here
1985
1983
1986
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1984
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1987
1985
1986
    my $yaml = C4::Context->preference('UpdateItemLocationOnCheckin');
1987
    if ($yaml) {
1988
        $yaml = "$yaml\n\n";  # YAML is strict on ending \n. Surplus does not hurt
1989
        my $rules;
1990
        eval { $rules = YAML::Load($yaml); };
1991
        if ($@) {
1992
            warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@";
1993
        }
1994
        else {
1995
            if (defined $rules->{_ALL_}) {
1996
                if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; }
1997
                if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; }
1998
                if ( $item->{location} ne $rules->{_ALL_}) {
1999
                    $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} };
2000
                    ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber );
2001
                }
2002
            }
2003
            else {
2004
                foreach my $key ( keys %$rules ) {
2005
                    if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; }
2006
                    if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;}
2007
                    if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) {
2008
                        $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} };
2009
                        ModItem( { location => $rules->{$key} }, undef, $itemnumber );
2010
                        last;
2011
                    }
2012
                }
2013
            }
2014
        }
2015
    }
2016
1988
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
2017
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1989
    if ($yaml) {
2018
    if ($yaml) {
1990
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
2019
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
Lines 2137-2151 sub AddReturn { Link Here
2137
            );
2166
            );
2138
            $sth->execute( $item->{'itemnumber'} );
2167
            $sth->execute( $item->{'itemnumber'} );
2139
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2168
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2140
            ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
2141
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2169
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2142
        } else {
2170
        } else {
2143
            $messages->{'WrongTransfer'}     = $tobranch;
2171
            $messages->{'WrongTransfer'}     = $tobranch;
2144
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2172
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2145
        }
2173
        }
2146
        $validTransfert = 1;
2174
        $validTransfert = 1;
2147
    } else {
2148
        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
2149
    }
2175
    }
2150
2176
2151
    # fix up the accounts.....
2177
    # fix up the accounts.....
(-)a/circ/returns.pl (+3 lines)
Lines 539-544 foreach my $code ( keys %$messages ) { Link Here
539
    elsif ( $code eq 'ForeverDebarred' ) {
539
    elsif ( $code eq 'ForeverDebarred' ) {
540
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
540
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
541
    }
541
    }
542
    elsif ( $code eq 'ItemLocationUpdated' ) {
543
        $err{ItemLocationUpdated} = $messages->{ItemLocationUpdated};
544
    }
542
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
545
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
543
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
546
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
544
    }
547
    }
(-)a/installer/data/mysql/atomicupdate/bug_14576-add_UpdateItemLocationOnCheckin_syspref.sql (+5 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES('UpdateItemLocationOnCheckin', 'PROC: _PERM_\n', '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 t 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. Note that PROC and CART are special values, for these locations only can location and permanent_location differ.  In all other cases an update will affect both.  Items in the CART location will be returned to their permanent location on checkout.  You can also use the special term _BLANK_ on either side of a pair to update/remove items with no locaiton assigned.  You can use the special term _ALL_ on the left side to affect all items and the special term _PERM_ on the right side to return items to their permanent location', 'Free');
2
UPDATE systempreferences s1, (SELECT IF(value,'PROC: CART\n','') AS p2c FROM systempreferences WHERE variable='InProcessingToShelvingCart') s2 SET s1.value= CONCAT(s2.p2c, REPLACE(s1.value,'PROC: _PERM_\n','') ) WHERE s1.variable='UpdateItemLocationOnCheckin' AND s1.value NOT LIKE '%PROC: CART%';
3
DELETE FROM systempreferences WHERE variable='InProcessingToShelvingCart';
4
UPDATE systempreferences s1, (SELECT IF(value,'_ALL_: CART\n','') AS rtc FROM systempreferences WHERE variable='ReturnToShelvingCart') s2 SET s1.value= CONCAT(s2.rtc,s1.value) WHERE s1.variable='UpdateItemLocationOnCheckin' AND s1.value NOT LIKE '%_ALL_: CART%';
5
DELETE FROM systempreferences WHERE variable='ReturnToShelvingCart';
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 510-515 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
510
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
510
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
511
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
511
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
512
('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'),
512
('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'),
513
('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. Note that PROC and CART are special values, for these locations only can location and permanent_location differ.  In all other cases an update will affect both.  Items in the CART location will be returned to their permanent location on checkout.  You can also use the special term _BLANK_ on either side of a pair to update/remove items with no locaiton assigned.  You can use the special term _ALL_ on the left side to affect all items and the special term _PERM_ on the right side to return items to their permanent location', 'Free'),
513
('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'),
514
('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'),
514
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
515
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
515
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
516
('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 (-12 / +15 lines)
Lines 181-198 Circulation: Link Here
181
                  no: "Don't allow"
181
                  no: "Don't allow"
182
            - staff to manually override and check out items to patrons who have more than noissuescharge in fines.
182
            - staff to manually override and check out items to patrons who have more than noissuescharge in fines.
183
        -
183
        -
184
            - pref: InProcessingToShelvingCart
185
              choices:
186
                  yes: Move
187
                  no: "Don't move"
188
            - items that have the location PROC to the location CART when they are checked in.
189
        -
190
            - pref: ReturnToShelvingCart
191
              choices:
192
                  yes: Move
193
                  no: "Don't move"
194
            - all items to the location CART when they are checked in.
195
        -
196
            - pref: AutomaticItemReturn
184
            - pref: AutomaticItemReturn
197
              choices:
185
              choices:
198
                  yes: Do
186
                  yes: Do
Lines 441-446 Circulation: Link Here
441
            - calculate and update overdue charges when an item is returned.
429
            - calculate and update overdue charges when an item is returned.
442
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
430
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
443
        -
431
        -
432
            - pref: UpdateItemLocationOnCheckin
433
              type: textarea
434
              class: code
435
            - This is is a list of value pairs, the first value is followed immediately by colon space then the second value i.e.:<br/>
436
            - "PROC: FIC"
437
            - <br/> When an item is checked in, if the location value on the left matches the items location value
438
            - "it will be updated to the right-hand value.<br/> E.g. ''PROC: FIC'' will cause an item that was set to ''Book Cart'' to now be in the ''Fiction'' shelving location."
439
            - <br/>Note that PROC and CART are special values, for these locations only can location and permanent_location differ.  In all other cases an update will affect both.
440
            - <br/>Items in the CART location will be returned to their permanent location on checkout
441
            - <br/>You can use the special term _BLANK_ on either side of a pair to update/remove items with no location assigned
442
            - <br>You can use the special term _ALL_ on the left side to affect all items
443
            - and the special term _PERM_ on the right side to return items to their permanent location
444
            - <br>**Use of an _ALL_ rule will override/ignore any other values**
445
            - <br>Each pair of values should be on a separate line.
446
        -
444
            - pref: UpdateNotForLoanStatusOnCheckin
447
            - pref: UpdateNotForLoanStatusOnCheckin
445
              type: textarea
448
              type: textarea
446
              class: code
449
              class: code
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (+29 lines)
Lines 483-488 $(document).ready(function () { Link Here
483
                            [% END %]
483
                            [% END %]
484
                        </p>
484
                        </p>
485
                    [% END %]
485
                    [% END %]
486
                    [% IF ( errmsgloo.ItemLocationUpdated ) %]
487
                        <p class="problem">
488
                            Item shelving location updated
489
                            from
490
                            [% IF errmsgloo.ItemLocationUpdated.from %]
491
                                [% IF errmsgloo.ItemLocationUpdated.from == '' %]
492
                                 empty
493
                                [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) == '' %]
494
                                    [% errmsgloo.ItemLocationUpdated.from %] (No description available)
495
                                [% ELSE %]
496
                                    [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) %]
497
                                [% END %]
498
                            [% ELSE %]
499
                                "Blank"
500
                            [% END %]
501
                            to
502
                            [% IF errmsgloo.ItemLocationUpdated.to %]
503
                                [% IF errmsgloo.ItemLocationUpdated.to == '' %]
504
                                   empty
505
                                [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) == '' %]
506
                                    [% errmsgloo.ItemLocationUpdated.to %] (Not an authorized value)
507
                                [% ELSE %]
508
                                    [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) %]
509
                                [% END %]
510
                            [% ELSE %]
511
                                "Blank"
512
                            [% END %]
513
                        </p>
514
                    [% END %]
486
                    [% IF ( errmsgloo.badbarcode ) %]
515
                    [% IF ( errmsgloo.badbarcode ) %]
487
                        <p class="problem">No item with barcode: [% errmsgloo.msg | html %]</p>
516
                        <p class="problem">No item with barcode: [% errmsgloo.msg | html %]</p>
488
                    [% END %]
517
                    [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js (-1 / +19 lines)
Lines 137-140 $( document ).ready( function () { Link Here
137
    if ( search_jumped ) {
137
    if ( search_jumped ) {
138
        document.location.hash = "jumped";
138
        document.location.hash = "jumped";
139
    }
139
    }
140
141
    $("#pref_UpdateItemLocationOnCheckin").change(function(){
142
        var the_text = $(this).val();
143
        var alert_text = '';
144
        if ( the_text.indexOf('_ALL_:') != -1 ) alert_text= _("Note: _ALL_ value will override all other values") + '\n';
145
        var split_text  =the_text.split("\n");
146
        var alert_issues = '';
147
        var issue_count = 0;
148
        var reg_check = /.*:\s.*/;
149
        for (var i=0; i < split_text.length; i++){
150
            if ( !split_text[i].match(reg_check) && split_text[i].length ) {
151
            alert_issues+=split_text[i]+"\n";
152
            issue_count++;
153
            }
154
        }
155
        if (issue_count) alert_text += "\n"+_("The following values are not formatted correctly:")+"\n"+alert_issues;
156
        if ( alert_text.length )  alert(alert_text);
157
    });
158
140
} );
159
} );
141
- 

Return to bug 14576