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

(-)a/C4/Circulation.pm (-14 / +40 lines)
Lines 1441-1446 sub AddIssue { Link Here
1441
                }
1441
                }
1442
              );
1442
              );
1443
1443
1444
        if ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART'  ) {
1445
        ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
1446
          CartToShelf( $item->{'itemnumber'} );
1447
        }
1448
        $item->{'issues'}++;
1449
        if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) {
1450
            UpdateTotalIssues($item->{'biblionumber'}, 1);
1451
        }
1452
1444
            if ( C4::Context->preference('ReturnToShelvingCart') ) {
1453
            if ( C4::Context->preference('ReturnToShelvingCart') ) {
1445
                # ReturnToShelvingCart is on, anything issued should be taken off the cart.
1454
                # ReturnToShelvingCart is on, anything issued should be taken off the cart.
1446
                CartToShelf( $item->{'itemnumber'} );
1455
                CartToShelf( $item->{'itemnumber'} );
Lines 1945-1961 sub AddReturn { Link Here
1945
1954
1946
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1955
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1947
1956
1948
    if ( $item->{'location'} eq 'PROC' ) {
1949
        if ( C4::Context->preference("InProcessingToShelvingCart") ) {
1950
            $item->{'location'} = 'CART';
1951
        }
1952
        else {
1953
            $item->{location} = $item->{permanent_location};
1954
        }
1955
1956
        ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
1957
    }
1958
1959
        # full item data, but no borrowernumber or checkout info (no issue)
1957
        # full item data, but no borrowernumber or checkout info (no issue)
1960
        # we know GetItem should work because GetItemnumberFromBarcode worked
1958
        # we know GetItem should work because GetItemnumberFromBarcode worked
1961
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1959
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
Lines 1965-1970 sub AddReturn { Link Here
1965
1963
1966
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1964
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1967
1965
1966
    my $yaml = C4::Context->preference('UpdateItemLocationOnCheckin');
1967
    if ($yaml) {
1968
        $yaml = "$yaml\n\n";  # YAML is strict on ending \n. Surplus does not hurt
1969
        my $rules;
1970
        eval { $rules = YAML::Load($yaml); };
1971
        if ($@) {
1972
            warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@";
1973
        }
1974
        else {
1975
            if (defined $rules->{_ALL_}) {
1976
                if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; }
1977
                if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; }
1978
                if ( $item->{location} ne $rules->{_ALL_}) {
1979
                    $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} };
1980
                    ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber );
1981
                }
1982
            }
1983
            else {
1984
                foreach my $key ( keys %$rules ) {
1985
                    if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; }
1986
                    if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;}
1987
                    if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) {
1988
                        $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} };
1989
                        ModItem( { location => $rules->{$key} }, undef, $itemnumber );
1990
                        last;
1991
                    }
1992
                }
1993
            }
1994
        }
1995
    }
1996
1968
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1997
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1969
    if ($yaml) {
1998
    if ($yaml) {
1970
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
1999
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
Lines 2116-2130 sub AddReturn { Link Here
2116
            );
2145
            );
2117
            $sth->execute( $item->{'itemnumber'} );
2146
            $sth->execute( $item->{'itemnumber'} );
2118
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2147
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2119
            ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
2120
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2148
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2121
        } else {
2149
        } else {
2122
            $messages->{'WrongTransfer'}     = $tobranch;
2150
            $messages->{'WrongTransfer'}     = $tobranch;
2123
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2151
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2124
        }
2152
        }
2125
        $validTransfert = 1;
2153
        $validTransfert = 1;
2126
    } else {
2127
        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
2128
    }
2154
    }
2129
2155
2130
    # fix up the accounts.....
2156
    # 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 502-507 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
502
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
502
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
503
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
503
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
504
('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'),
504
('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'),
505
('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'),
505
('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'),
506
('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'),
506
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
507
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
507
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
508
('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 478-483 $(document).ready(function () { Link Here
478
                            [% END %]
478
                            [% END %]
479
                        </p>
479
                        </p>
480
                    [% END %]
480
                    [% END %]
481
                    [% IF ( errmsgloo.ItemLocationUpdated ) %]
482
                        <p class="problem">
483
                            Item shelving location updated
484
                            from
485
                            [% IF errmsgloo.ItemLocationUpdated.from %]
486
                                [% IF errmsgloo.ItemLocationUpdated.from == '' %]
487
                                 empty
488
                                [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) == '' %]
489
                                    [% errmsgloo.ItemLocationUpdated.from %] (No description available)
490
                                [% ELSE %]
491
                                    [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) %]
492
                                [% END %]
493
                            [% ELSE %]
494
                                "Blank"
495
                            [% END %]
496
                            to
497
                            [% IF errmsgloo.ItemLocationUpdated.to %]
498
                                [% IF errmsgloo.ItemLocationUpdated.to == '' %]
499
                                   empty
500
                                [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) == '' %]
501
                                    [% errmsgloo.ItemLocationUpdated.to %] (Not an authorized value)
502
                                [% ELSE %]
503
                                    [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) %]
504
                                [% END %]
505
                            [% ELSE %]
506
                                "Blank"
507
                            [% END %]
508
                        </p>
509
                    [% END %]
481
                    [% IF ( errmsgloo.badbarcode ) %]
510
                    [% IF ( errmsgloo.badbarcode ) %]
482
                        <p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
511
                        <p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
483
                    [% END %]
512
                    [% 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