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

(-)a/C4/Circulation.pm (-15 / +33 lines)
Lines 1386-1392 sub AddIssue { Link Here
1386
            }
1386
            }
1387
        );
1387
        );
1388
1388
1389
        if ( C4::Context->preference('ReturnToShelvingCart') ) { ## ReturnToShelvingCart is on, anything issued should be taken off the cart.
1389
        if ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART'  ) {
1390
        ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
1390
          CartToShelf( $item->{'itemnumber'} );
1391
          CartToShelf( $item->{'itemnumber'} );
1391
        }
1392
        }
1392
        $item->{'issues'}++;
1393
        $item->{'issues'}++;
Lines 1881-1897 sub AddReturn { Link Here
1881
1882
1882
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1883
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1883
1884
1884
    if ( $item->{'location'} eq 'PROC' ) {
1885
        if ( C4::Context->preference("InProcessingToShelvingCart") ) {
1886
            $item->{'location'} = 'CART';
1887
        }
1888
        else {
1889
            $item->{location} = $item->{permanent_location};
1890
        }
1891
1892
        ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
1893
    }
1894
1895
        # full item data, but no borrowernumber or checkout info (no issue)
1885
        # full item data, but no borrowernumber or checkout info (no issue)
1896
        # we know GetItem should work because GetItemnumberFromBarcode worked
1886
        # we know GetItem should work because GetItemnumberFromBarcode worked
1897
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1887
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
Lines 1901-1906 sub AddReturn { Link Here
1901
1891
1902
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1892
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1903
1893
1894
    my $yaml = C4::Context->preference('UpdateItemLocationOnCheckin');
1895
    if ($yaml) {
1896
        $yaml = "$yaml\n\n";  # YAML is strict on ending \n. Surplus does not hurt
1897
        my $rules;
1898
        eval { $rules = YAML::Load($yaml); };
1899
        if ($@) {
1900
            warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@";
1901
        }
1902
        else {
1903
            if (defined $rules->{_ALL_}) {
1904
                if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; }
1905
                if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; }
1906
                if ( $item->{location} ne $rules->{_ALL_}) {
1907
                    $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} };
1908
                    ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber );
1909
                }
1910
            }
1911
            else {
1912
                foreach my $key ( keys %$rules ) {
1913
                    if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; }
1914
                    if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;}
1915
                    if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) {
1916
                        $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} };
1917
                        ModItem( { location => $rules->{$key} }, undef, $itemnumber );
1918
                        last;
1919
                    }
1920
                }
1921
            }
1922
        }
1923
    }
1924
1904
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1925
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1905
    if ($yaml) {
1926
    if ($yaml) {
1906
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
1927
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
Lines 2052-2066 sub AddReturn { Link Here
2052
            );
2073
            );
2053
            $sth->execute( $item->{'itemnumber'} );
2074
            $sth->execute( $item->{'itemnumber'} );
2054
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2075
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2055
            ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
2056
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2076
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2057
        } else {
2077
        } else {
2058
            $messages->{'WrongTransfer'}     = $tobranch;
2078
            $messages->{'WrongTransfer'}     = $tobranch;
2059
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2079
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2060
        }
2080
        }
2061
        $validTransfert = 1;
2081
        $validTransfert = 1;
2062
    } else {
2063
        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
2064
    }
2082
    }
2065
2083
2066
    # fix up the accounts.....
2084
    # fix up the accounts.....
(-)a/circ/returns.pl (+3 lines)
Lines 536-541 foreach my $code ( keys %$messages ) { Link Here
536
    elsif ( $code eq 'ForeverDebarred' ) {
536
    elsif ( $code eq 'ForeverDebarred' ) {
537
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
537
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
538
    }
538
    }
539
    elsif ( $code eq 'ItemLocationUpdated' ) {
540
        $err{ItemLocationUpdated} = $messages->{ItemLocationUpdated};
541
    }
539
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
542
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
540
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
543
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
541
    }
544
    }
(-)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 498-503 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
498
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
498
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
499
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
499
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
500
('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'),
500
('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'),
501
('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'),
501
('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'),
502
('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'),
502
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
503
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
503
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
504
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js (+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
} );
(-)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 436-441 Circulation: Link Here
436
            - calculate and update overdue charges when an item is returned.
424
            - calculate and update overdue charges when an item is returned.
437
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
425
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
438
        -
426
        -
427
            - pref: UpdateItemLocationOnCheckin
428
              type: textarea
429
              class: code
430
            - This is is a list of value pairs, the first value is followed immediately by colon space then the second value i.e.:<br/>
431
            - "PROC: FIC"
432
            - <br/> When an item is checked in, if the location value on the left matches the items location value
433
            - "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." 
434
            - <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.  
435
            - <br/>Items in the CART location will be returned to their permanent location on checkout
436
            - <br/>You can use the special term _BLANK_ on either side of a pair to update/remove items with no location assigned
437
            - <br>You can use the special term _ALL_ on the left side to affect all items 
438
            - and the special term _PERM_ on the right side to return items to their permanent location
439
            - <br>**Use of an _ALL_ rule will override/ignore any other values**
440
            - <br>Each pair of values should be on a separate line.
441
        -
439
            - pref: UpdateNotForLoanStatusOnCheckin
442
            - pref: UpdateNotForLoanStatusOnCheckin
440
              type: textarea
443
              type: textarea
441
              class: code
444
              class: code
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-1 / +29 lines)
Lines 458-463 $(document).ready(function () { Link Here
458
                            [% END %]
458
                            [% END %]
459
                        </p>
459
                        </p>
460
                    [% END %]
460
                    [% END %]
461
                    [% IF ( errmsgloo.ItemLocationUpdated ) %]
462
                        <p class="problem">
463
                            Item shelving location updated
464
                            from
465
                            [% IF errmsgloo.ItemLocationUpdated.from %]
466
                                [% IF errmsgloo.ItemLocationUpdated.from == '' %]
467
                                 empty
468
                                [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) == '' %]
469
                                    [% errmsgloo.ItemLocationUpdated.from %] (No description available)
470
                                [% ELSE %]
471
                                    [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) %]
472
                                [% END %]
473
                            [% ELSE %]
474
                                "Blank"
475
                            [% END %]
476
                            to
477
                            [% IF errmsgloo.ItemLocationUpdated.to %]
478
                                [% IF errmsgloo.ItemLocationUpdated.to == '' %]
479
                                   empty
480
                                [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) == '' %]
481
                                    [% errmsgloo.ItemLocationUpdated.to %] (Not an authorized value)
482
                                [% ELSE %]
483
                                    [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) %]
484
                                [% END %]
485
                            [% ELSE %]
486
                                "Blank"
487
                            [% END %]
488
                        </p>
489
                    [% END %]
461
                    [% IF ( errmsgloo.badbarcode ) %]
490
                    [% IF ( errmsgloo.badbarcode ) %]
462
                        <p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
491
                        <p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
463
                    [% END %]
492
                    [% END %]
464
- 

Return to bug 14576