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

(-)a/C4/Circulation.pm (-15 / +35 lines)
Lines 1337-1343 sub AddIssue { Link Here
1337
            }
1337
            }
1338
        );
1338
        );
1339
1339
1340
        if ( C4::Context->preference('ReturnToShelvingCart') ) { ## ReturnToShelvingCart is on, anything issued should be taken off the cart.
1340
        if ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART'  ) { 
1341
        ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
1341
          CartToShelf( $item->{'itemnumber'} );
1342
          CartToShelf( $item->{'itemnumber'} );
1342
        }
1343
        }
1343
        $item->{'issues'}++;
1344
        $item->{'issues'}++;
Lines 1832-1848 sub AddReturn { Link Here
1832
1833
1833
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1834
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1834
1835
1835
    if ( $item->{'location'} eq 'PROC' ) {
1836
        if ( C4::Context->preference("InProcessingToShelvingCart") ) {
1837
            $item->{'location'} = 'CART';
1838
        }
1839
        else {
1840
            $item->{location} = $item->{permanent_location};
1841
        }
1842
1843
        ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
1844
    }
1845
1846
        # full item data, but no borrowernumber or checkout info (no issue)
1836
        # full item data, but no borrowernumber or checkout info (no issue)
1847
        # we know GetItem should work because GetItemnumberFromBarcode worked
1837
        # we know GetItem should work because GetItemnumberFromBarcode worked
1848
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
1838
    my $hbr = GetBranchItemRule($item->{'homebranch'}, $item->{'itype'})->{'returnbranch'} || "homebranch";
Lines 1852-1857 sub AddReturn { Link Here
1852
1842
1853
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1843
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1854
1844
1845
    my $yaml = C4::Context->preference('UpdateItemLocationOnCheckin');
1846
    if ($yaml) {
1847
        $yaml = "$yaml\n\n";  # YAML is strict on ending \n. Surplus does not hurt
1848
        my $rules;
1849
        eval { $rules = YAML::Load($yaml); };
1850
        if ($@) {
1851
            warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@";
1852
        }
1853
        else {
1854
            if (defined $rules->{_ALL_}) {
1855
                if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; }
1856
                if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; }
1857
                if ( $item->{location} ne $rules->{_ALL_}) {
1858
                    $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} };
1859
                    ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber );
1860
                }
1861
            }
1862
            else {
1863
                foreach my $key ( keys %$rules ) {
1864
                    if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; }
1865
                    if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;}
1866
#                    warn Data::Dumper::Dumper($key,$item->{location}, 
1867
                    if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) {
1868
                        warn Data::Dumper::Dumper( $key );
1869
                        $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} };
1870
                        ModItem( { location => $rules->{$key} }, undef, $itemnumber );
1871
                        last;
1872
                    } 
1873
                }
1874
            }
1875
        }
1876
    }
1877
1855
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1878
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1856
    if ($yaml) {
1879
    if ($yaml) {
1857
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
1880
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
Lines 1989-2003 sub AddReturn { Link Here
1989
            );
2012
            );
1990
            $sth->execute( $item->{'itemnumber'} );
2013
            $sth->execute( $item->{'itemnumber'} );
1991
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2014
            # if we have a reservation with valid transfer, we can set it's status to 'W'
1992
            ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
1993
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2015
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
1994
        } else {
2016
        } else {
1995
            $messages->{'WrongTransfer'}     = $tobranch;
2017
            $messages->{'WrongTransfer'}     = $tobranch;
1996
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2018
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
1997
        }
2019
        }
1998
        $validTransfert = 1;
2020
        $validTransfert = 1;
1999
    } else {
2000
        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
2001
    }
2021
    }
2002
2022
2003
    # fix up the accounts.....
2023
    # fix up the accounts.....
(-)a/circ/returns.pl (+3 lines)
Lines 525-530 foreach my $code ( keys %$messages ) { Link Here
525
    elsif ( $code eq 'ForeverDebarred' ) {
525
    elsif ( $code eq 'ForeverDebarred' ) {
526
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
526
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
527
    }
527
    }
528
    elsif ( $code eq 'ItemLocationUpdated' ) {
529
        $err{ItemLocationUpdated} = $messages->{ItemLocationUpdated};
530
    }
528
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
531
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
529
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
532
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
530
    }
533
    }
(-)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 483-488 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
483
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
483
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
484
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
484
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
485
('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'),
485
('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'),
486
('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'),
486
('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'),
487
('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'),
487
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
488
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
488
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
489
('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 / +7 lines)
Lines 175-192 Circulation: Link Here
175
                  no: "Don't allow"
175
                  no: "Don't allow"
176
            - staff to manually override and check out items to patrons who have more than noissuescharge in fines.
176
            - staff to manually override and check out items to patrons who have more than noissuescharge in fines.
177
        -
177
        -
178
            - pref: InProcessingToShelvingCart
179
              choices:
180
                  yes: Move
181
                  no: "Don't move"
182
            - items that have the location PROC to the location CART when they are checked in.
183
        -
184
            - pref: ReturnToShelvingCart
185
              choices:
186
                  yes: Move
187
                  no: "Don't move"
188
            - all items to the location CART when they are checked in.
189
        -
190
            - pref: AutomaticItemReturn
178
            - pref: AutomaticItemReturn
191
              choices:
179
              choices:
192
                  yes: Do
180
                  yes: Do
Lines 423-428 Circulation: Link Here
423
            - calculate and update overdue charges when an item is returned.
411
            - calculate and update overdue charges when an item is returned.
424
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
412
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
425
        -
413
        -
414
            - pref: UpdateItemLocationOnCheckin
415
              type: textarea
416
              class: code
417
            - 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
418
            - "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"
419
            - Each pair of values should be on a separate line.
420
        -
426
            - pref: UpdateNotForLoanStatusOnCheckin
421
            - pref: UpdateNotForLoanStatusOnCheckin
427
              type: textarea
422
              type: textarea
428
              class: code
423
              class: code
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-1 / +29 lines)
Lines 446-451 $(document).ready(function () { Link Here
446
                            [% END %]
446
                            [% END %]
447
                        </p>
447
                        </p>
448
                    [% END %]
448
                    [% END %]
449
                    [% IF ( errmsgloo.ItemLocationUpdated ) %]
450
                        <p class="problem">
451
                            Item location updated
452
                            from
453
                            [% IF errmsgloo.ItemLocationUpdated.from %]
454
                                [% IF errmsgloo.ItemLocationUpdated.from == '' %]
455
                                 empty   
456
                                [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) == '' %]
457
                                    [% errmsgloo.ItemLocationUpdated.from %] (Not an authorized value)
458
                                [% ELSE %]
459
                                    [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) %]
460
                                [% END %]
461
                            [% ELSE %]
462
                                "Blank"
463
                            [% END %]
464
                            to
465
                            [% IF errmsgloo.ItemLocationUpdated.to %]
466
                                [% IF errmsgloo.ItemLocationUpdated.to == '' %]
467
                                   empty 
468
                                [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) == '' %]
469
                                    [% errmsgloo.ItemLocationUpdated.to %] (Not an authorized value)
470
                                [% ELSE %]
471
                                    [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) %]
472
                                [% END %]
473
                            [% ELSE %]
474
                                "Blank"
475
                            [% END %]
476
                        </p>
477
                    [% END %]
449
                    [% IF ( errmsgloo.badbarcode ) %]
478
                    [% IF ( errmsgloo.badbarcode ) %]
450
                        <p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
479
                        <p class="problem">No item with barcode: [% errmsgloo.msg %]</p>
451
                    [% END %]
480
                    [% END %]
452
- 

Return to bug 14576