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

(-)a/C4/Circulation.pm (-15 / +33 lines)
Lines 1427-1433 sub AddIssue { Link Here
1427
            }
1427
            }
1428
        );
1428
        );
1429
1429
1430
        if ( C4::Context->preference('ReturnToShelvingCart') ) { ## ReturnToShelvingCart is on, anything issued should be taken off the cart.
1430
        if ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART'  ) {
1431
        ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
1431
          CartToShelf( $item->{'itemnumber'} );
1432
          CartToShelf( $item->{'itemnumber'} );
1432
        }
1433
        }
1433
        $item->{'issues'}++;
1434
        $item->{'issues'}++;
Lines 1924-1940 sub AddReturn { Link Here
1924
1925
1925
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1926
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1926
1927
1927
    if ( $item->{'location'} eq 'PROC' ) {
1928
        if ( C4::Context->preference("InProcessingToShelvingCart") ) {
1929
            $item->{'location'} = 'CART';
1930
        }
1931
        else {
1932
            $item->{location} = $item->{permanent_location};
1933
        }
1934
1935
        ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
1936
    }
1937
1938
        # full item data, but no borrowernumber or checkout info (no issue)
1928
        # full item data, but no borrowernumber or checkout info (no issue)
1939
        # we know GetItem should work because GetItemnumberFromBarcode worked
1929
        # we know GetItem should work because GetItemnumberFromBarcode worked
1940
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1930
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
Lines 1944-1949 sub AddReturn { Link Here
1944
1934
1945
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1935
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1946
1936
1937
    my $yaml = C4::Context->preference('UpdateItemLocationOnCheckin');
1938
    if ($yaml) {
1939
        $yaml = "$yaml\n\n";  # YAML is strict on ending \n. Surplus does not hurt
1940
        my $rules;
1941
        eval { $rules = YAML::Load($yaml); };
1942
        if ($@) {
1943
            warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@";
1944
        }
1945
        else {
1946
            if (defined $rules->{_ALL_}) {
1947
                if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; }
1948
                if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; }
1949
                if ( $item->{location} ne $rules->{_ALL_}) {
1950
                    $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} };
1951
                    ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber );
1952
                }
1953
            }
1954
            else {
1955
                foreach my $key ( keys %$rules ) {
1956
                    if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; }
1957
                    if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;}
1958
                    if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) {
1959
                        $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} };
1960
                        ModItem( { location => $rules->{$key} }, undef, $itemnumber );
1961
                        last;
1962
                    }
1963
                }
1964
            }
1965
        }
1966
    }
1967
1947
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1968
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1948
    if ($yaml) {
1969
    if ($yaml) {
1949
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
1970
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
Lines 2095-2109 sub AddReturn { Link Here
2095
            );
2116
            );
2096
            $sth->execute( $item->{'itemnumber'} );
2117
            $sth->execute( $item->{'itemnumber'} );
2097
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2118
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2098
            ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
2099
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2119
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2100
        } else {
2120
        } else {
2101
            $messages->{'WrongTransfer'}     = $tobranch;
2121
            $messages->{'WrongTransfer'}     = $tobranch;
2102
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2122
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2103
        }
2123
        }
2104
        $validTransfert = 1;
2124
        $validTransfert = 1;
2105
    } else {
2106
        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
2107
    }
2125
    }
2108
2126
2109
    # fix up the accounts.....
2127
    # 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 500-505 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
500
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
500
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
501
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
501
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
502
('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'),
502
('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'),
503
('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'),
503
('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'),
504
('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'),
504
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
505
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
505
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
506
('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