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

(-)a/C4/Circulation.pm (-13 / +41 lines)
Lines 1383-1388 sub AddIssue { Link Here
1383
                }
1383
                }
1384
              );
1384
              );
1385
1385
1386
        if ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART'  ) {
1387
        ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
1388
          CartToShelf( $item->{'itemnumber'} );
1389
        }
1390
        $item->{'issues'}++;
1391
        if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) {
1392
            UpdateTotalIssues($item->{'biblionumber'}, 1);
1393
        }
1394
1386
            if ( C4::Context->preference('ReturnToShelvingCart') ) {
1395
            if ( C4::Context->preference('ReturnToShelvingCart') ) {
1387
                # ReturnToShelvingCart is on, anything issued should be taken off the cart.
1396
                # ReturnToShelvingCart is on, anything issued should be taken off the cart.
1388
                CartToShelf( $item->{'itemnumber'} );
1397
                CartToShelf( $item->{'itemnumber'} );
Lines 1852-1867 sub AddReturn { Link Here
1852
        }
1861
        }
1853
    }
1862
    }
1854
1863
1855
    if ( $item->{'location'} eq 'PROC' ) {
1864
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1856
        if ( C4::Context->preference("InProcessingToShelvingCart") ) {
1857
            $item->{'location'} = 'CART';
1858
        }
1859
        else {
1860
            $item->{location} = $item->{permanent_location};
1861
        }
1862
1863
        ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
1864
    }
1865
1865
1866
        # full item data, but no borrowernumber or checkout info (no issue)
1866
        # full item data, but no borrowernumber or checkout info (no issue)
1867
        # we know GetItem should work because GetItemnumberFromBarcode worked
1867
        # we know GetItem should work because GetItemnumberFromBarcode worked
Lines 1872-1877 sub AddReturn { Link Here
1872
1872
1873
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1873
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1874
1874
1875
    my $yaml = C4::Context->preference('UpdateItemLocationOnCheckin');
1876
    if ($yaml) {
1877
        $yaml = "$yaml\n\n";  # YAML is strict on ending \n. Surplus does not hurt
1878
        my $rules;
1879
        eval { $rules = YAML::Load($yaml); };
1880
        if ($@) {
1881
            warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@";
1882
        }
1883
        else {
1884
            if (defined $rules->{_ALL_}) {
1885
                if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; }
1886
                if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; }
1887
                if ( $item->{location} ne $rules->{_ALL_}) {
1888
                    $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} };
1889
                    ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber );
1890
                }
1891
            }
1892
            else {
1893
                foreach my $key ( keys %$rules ) {
1894
                    if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; }
1895
                    if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;}
1896
                    if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) {
1897
                        $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} };
1898
                        ModItem( { location => $rules->{$key} }, undef, $itemnumber );
1899
                        last;
1900
                    }
1901
                }
1902
            }
1903
        }
1904
    }
1905
1875
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1906
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1876
    if ($yaml) {
1907
    if ($yaml) {
1877
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
1908
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
Lines 1981-1995 sub AddReturn { Link Here
1981
            );
2012
            );
1982
            $sth->execute( $item->{'itemnumber'} );
2013
            $sth->execute( $item->{'itemnumber'} );
1983
            # 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'
1984
            ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
1985
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2015
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
1986
        } else {
2016
        } else {
1987
            $messages->{'WrongTransfer'}     = $tobranch;
2017
            $messages->{'WrongTransfer'}     = $tobranch;
1988
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2018
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
1989
        }
2019
        }
1990
        $validTransfert = 1;
2020
        $validTransfert = 1;
1991
    } else {
1992
        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
1993
    }
2021
    }
1994
2022
1995
    # fix up the accounts.....
2023
    # fix up the accounts.....
(-)a/circ/returns.pl (+3 lines)
Lines 547-552 foreach my $code ( keys %$messages ) { Link Here
547
    elsif ( $code eq 'ForeverDebarred' ) {
547
    elsif ( $code eq 'ForeverDebarred' ) {
548
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
548
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
549
    }
549
    }
550
    elsif ( $code eq 'ItemLocationUpdated' ) {
551
        $err{ItemLocationUpdated} = $messages->{ItemLocationUpdated};
552
    }
550
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
553
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
551
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
554
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
552
    }
555
    }
(-)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 545-550 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
545
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
545
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
546
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
546
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
547
('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'),
547
('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'),
548
('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'),
548
('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'),
549
('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'),
549
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
550
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
550
('UploadPurgeTemporaryFilesDays','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer'),
551
('UploadPurgeTemporaryFilesDays','',NULL,'If not empty, number of days used when automatically deleting temporary uploads','integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-12 / +15 lines)
Lines 201-218 Circulation: Link Here
201
                  no: "Don't allow"
201
                  no: "Don't allow"
202
            - staff to manually override and check out items to patrons who have more than noissuescharge in fines.
202
            - staff to manually override and check out items to patrons who have more than noissuescharge in fines.
203
        -
203
        -
204
            - pref: InProcessingToShelvingCart
205
              choices:
206
                  yes: Move
207
                  no: "Don't move"
208
            - items that have the location PROC to the location CART when they are checked in.
209
        -
210
            - pref: ReturnToShelvingCart
211
              choices:
212
                  yes: Move
213
                  no: "Don't move"
214
            - all items to the location CART when they are checked in.
215
        -
216
            - pref: AutomaticItemReturn
204
            - pref: AutomaticItemReturn
217
              choices:
205
              choices:
218
                  yes: Do
206
                  yes: Do
Lines 474-479 Circulation: Link Here
474
            - calculate and update overdue charges when an item is returned.
462
            - calculate and update overdue charges when an item is returned.
475
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
463
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
476
        -
464
        -
465
            - pref: UpdateItemLocationOnCheckin
466
              type: textarea
467
              class: code
468
            - This is is a list of value pairs, the first value is followed immediately by colon space then the second value i.e.:<br/>
469
            - "PROC: FIC"
470
            - <br/> When an item is checked in, if the location value on the left matches the items location value
471
            - "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."
472
            - <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.
473
            - <br/>Items in the CART location will be returned to their permanent location on checkout
474
            - <br/>You can use the special term _BLANK_ on either side of a pair to update/remove items with no location assigned
475
            - <br>You can use the special term _ALL_ on the left side to affect all items
476
            - and the special term _PERM_ on the right side to return items to their permanent location
477
            - <br>**Use of an _ALL_ rule will override/ignore any other values**
478
            - <br>Each pair of values should be on a separate line.
479
        -
477
            - pref: UpdateNotForLoanStatusOnCheckin
480
            - pref: UpdateNotForLoanStatusOnCheckin
478
              type: textarea
481
              type: textarea
479
              class: code
482
              class: code
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-13 / +76 lines)
Lines 588-606 $(document).ready(function () { Link Here
588
            [% IF ( errmsgloo.NotForLoanStatusUpdated ) %]
588
            [% IF ( errmsgloo.NotForLoanStatusUpdated ) %]
589
                <p class="problem">
589
                <p class="problem">
590
                    Not for loan status updated.
590
                    Not for loan status updated.
591
                    <br />Old value:
591
                <br />Old value:
592
                    [% IF errmsgloo.NotForLoanStatusUpdated.from %]
592
                 [% IF errmsgloo.NotForLoanStatusUpdated.from %]
593
                        [% AuthorisedValues.GetByCode( 'NOT_LOAN', errmsgloo.NotForLoanStatusUpdated.from ) %].
593
                     [% AuthorisedValues.GetByCode( 'NOT_LOAN', errmsgloo.NotForLoanStatusUpdated.from ) %].
594
                    [% ELSE %]
594
                 [% ELSE %]
595
                        Available for loan.
595
                     Available for loan.
596
                    [% END %]
596
                 [% END %]
597
                    <br />New value:
597
                     <br />New value:
598
                    [% IF errmsgloo.NotForLoanStatusUpdated.to %]
598
                 [% IF errmsgloo.NotForLoanStatusUpdated.to %]
599
                        [% AuthorisedValues.GetByCode( 'NOT_LOAN', errmsgloo.NotForLoanStatusUpdated.to ) %].
599
                     [% AuthorisedValues.GetByCode( 'NOT_LOAN', errmsgloo.NotForLoanStatusUpdated.to ) %].
600
                    [% ELSE %]
600
                 [% ELSE %]
601
                        Available for loan.
601
                     Available for loan.
602
                    [% END %]
602
                 [% END %]
603
                </p>
603
                     </p>
604
            [% END %]
605
            [% IF ( errmsgloo.ItemLocationUpdated ) %]
606
                 <p class="problem">
607
                     Item shelving location updated from
608
                 [% IF errmsgloo.ItemLocationUpdated.from %]
609
                     [% IF errmsgloo.ItemLocationUpdated.from == '' %]
610
                         empty
611
                     [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) == '' %]
612
                         [% errmsgloo.ItemLocationUpdated.from %] (No description available)
613
                     [% ELSE %]
614
                         [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) %]
615
                     [% END %]
616
                 [% ELSE %]
617
                     "Blank"
618
                 [% END %]
619
                 to
620
                 [% IF errmsgloo.ItemLocationUpdated.to %]
621
                     [% IF errmsgloo.ItemLocationUpdated.to == '' %]
622
                         empty
623
                     [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) == '' %]
624
                         [% errmsgloo.ItemLocationUpdated.to %] (Not an authorized value)
625
                     [% ELSE %]
626
                         [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) %]
627
                     [% END %]
628
                 [% ELSE %]
629
                     "Blank"
630
                 [% END %]
631
                 </p>
632
            [% END %]
633
            [% IF ( errmsgloo.badbarcode ) %]
634
                <p class="problem">No item with barcode: [% errmsgloo.msg | html %]</p>
635
            [% END %]
636
            [% IF ( errmsgloo.ispermanent ) %]
637
                <p class="problem">Please return item to: [% Branches.GetName( errmsgloo.msg ) %]</p>
638
            [% END %]
639
            [% IF ( errmsgloo.notissued ) %]
640
                <p class="problem">Not checked out.</p>
641
            [% END %]
642
            [% IF ( errmsgloo.localuse) %]
643
                <p class="problem">Local use recorded</p>
644
            [% END %]
645
            [% IF ( errmsgloo.waslost ) %]
646
                <p class="problem">Item was lost, now found.</p>
647
                [% IF ( LostItemFeeRefunded ) %]
648
                    <p class="problem">A refund has been applied to the borrowing patron's account.</p>
649
                [% ELSE %]
650
                    <p class="problem">Any lost item fees for this item will remain on the patron's account.</p>
651
                [% END %]
652
            [% END %]
653
            [% IF ( errmsgloo.withdrawn ) %]
654
                [% IF BlockReturnOfWithdrawnItems %]
655
                    <h5>Cannot check in</h5>
656
                    <p><strong>NOT CHECKED IN</strong></p>
657
                    <p class="problem">Item is withdrawn.</p>
658
                [% ELSE %]
659
                    <p class="problem">Item is withdrawn.</p>
660
                [% END %]
661
            [% END %]
662
            [% IF ( errmsgloo.debarred ) %]
663
                <p class="problem"><a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% errmsgloo.debarborrowernumber %]">[% errmsgloo.debarname %]([% errmsgloo.debarcardnumber %])</a> is now debarred until [% errmsgloo.debarred | $KohaDates %].</p>
664
            [% END %]
665
            [% IF ( errmsgloo.prevdebarred ) %]
666
                <p class="problem"><b>Reminder: </b>Patron was earlier restricted until [% errmsgloo.prevdebarred | $KohaDates %].</p>
604
            [% END %]
667
            [% END %]
605
            [% IF ( errmsgloo.badbarcode ) %]
668
            [% IF ( errmsgloo.badbarcode ) %]
606
                <p class="problem">No item with barcode: [% errmsgloo.msg | html %]</p>
669
                <p class="problem">No item with barcode: [% errmsgloo.msg | html %]</p>
(-)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