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 1980-1994 sub AddReturn { Link Here
1980
            );
2011
            );
1981
            $sth->execute( $item->{'itemnumber'} );
2012
            $sth->execute( $item->{'itemnumber'} );
1982
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2013
            # if we have a reservation with valid transfer, we can set it's status to 'W'
1983
            ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
1984
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2014
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
1985
        } else {
2015
        } else {
1986
            $messages->{'WrongTransfer'}     = $tobranch;
2016
            $messages->{'WrongTransfer'}     = $tobranch;
1987
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2017
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
1988
        }
2018
        }
1989
        $validTransfert = 1;
2019
        $validTransfert = 1;
1990
    } else {
1991
        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
1992
    }
2020
    }
1993
2021
1994
    # fix up the accounts.....
2022
    # fix up the accounts.....
(-)a/circ/returns.pl (+3 lines)
Lines 538-543 foreach my $code ( keys %$messages ) { Link Here
538
    elsif ( $code eq 'ForeverDebarred' ) {
538
    elsif ( $code eq 'ForeverDebarred' ) {
539
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
539
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
540
    }
540
    }
541
    elsif ( $code eq 'ItemLocationUpdated' ) {
542
        $err{ItemLocationUpdated} = $messages->{ItemLocationUpdated};
543
    }
541
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
544
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
542
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
545
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
543
    }
546
    }
(-)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 538-543 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
538
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
538
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
539
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
539
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
540
('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'),
540
('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'),
541
('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'),
541
('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'),
542
('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'),
542
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
543
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
543
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
544
('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 195-212 Circulation: Link Here
195
                  no: "Don't allow"
195
                  no: "Don't allow"
196
            - staff to manually override and check out items to patrons who have more than noissuescharge in fines.
196
            - staff to manually override and check out items to patrons who have more than noissuescharge in fines.
197
        -
197
        -
198
            - pref: InProcessingToShelvingCart
199
              choices:
200
                  yes: Move
201
                  no: "Don't move"
202
            - items that have the location PROC to the location CART when they are checked in.
203
        -
204
            - pref: ReturnToShelvingCart
205
              choices:
206
                  yes: Move
207
                  no: "Don't move"
208
            - all items to the location CART when they are checked in.
209
        -
210
            - pref: AutomaticItemReturn
198
            - pref: AutomaticItemReturn
211
              choices:
199
              choices:
212
                  yes: Do
200
                  yes: Do
Lines 461-466 Circulation: Link Here
461
            - calculate and update overdue charges when an item is returned.
449
            - calculate and update overdue charges when an item is returned.
462
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
450
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
463
        -
451
        -
452
            - pref: UpdateItemLocationOnCheckin
453
              type: textarea
454
              class: code
455
            - This is is a list of value pairs, the first value is followed immediately by colon space then the second value i.e.:<br/>
456
            - "PROC: FIC"
457
            - <br/> When an item is checked in, if the location value on the left matches the items location value
458
            - "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."
459
            - <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.
460
            - <br/>Items in the CART location will be returned to their permanent location on checkout
461
            - <br/>You can use the special term _BLANK_ on either side of a pair to update/remove items with no location assigned
462
            - <br>You can use the special term _ALL_ on the left side to affect all items
463
            - and the special term _PERM_ on the right side to return items to their permanent location
464
            - <br>**Use of an _ALL_ rule will override/ignore any other values**
465
            - <br>Each pair of values should be on a separate line.
466
        -
464
            - pref: UpdateNotForLoanStatusOnCheckin
467
            - pref: UpdateNotForLoanStatusOnCheckin
465
              type: textarea
468
              type: textarea
466
              class: code
469
              class: code
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-13 / +76 lines)
Lines 586-604 $(document).ready(function () { Link Here
586
            [% IF ( errmsgloo.NotForLoanStatusUpdated ) %]
586
            [% IF ( errmsgloo.NotForLoanStatusUpdated ) %]
587
                <p class="problem">
587
                <p class="problem">
588
                    Not for loan status updated.
588
                    Not for loan status updated.
589
                    <br />Old value:
589
                <br />Old value:
590
                    [% IF errmsgloo.NotForLoanStatusUpdated.from %]
590
                 [% IF errmsgloo.NotForLoanStatusUpdated.from %]
591
                        [% AuthorisedValues.GetByCode( 'NOT_LOAN', errmsgloo.NotForLoanStatusUpdated.from ) %].
591
                     [% AuthorisedValues.GetByCode( 'NOT_LOAN', errmsgloo.NotForLoanStatusUpdated.from ) %].
592
                    [% ELSE %]
592
                 [% ELSE %]
593
                        Available for loan.
593
                     Available for loan.
594
                    [% END %]
594
                 [% END %]
595
                    <br />New value:
595
                     <br />New value:
596
                    [% IF errmsgloo.NotForLoanStatusUpdated.to %]
596
                 [% IF errmsgloo.NotForLoanStatusUpdated.to %]
597
                        [% AuthorisedValues.GetByCode( 'NOT_LOAN', errmsgloo.NotForLoanStatusUpdated.to ) %].
597
                     [% AuthorisedValues.GetByCode( 'NOT_LOAN', errmsgloo.NotForLoanStatusUpdated.to ) %].
598
                    [% ELSE %]
598
                 [% ELSE %]
599
                        Available for loan.
599
                     Available for loan.
600
                    [% END %]
600
                 [% END %]
601
                </p>
601
                     </p>
602
            [% END %]
603
            [% IF ( errmsgloo.ItemLocationUpdated ) %]
604
                 <p class="problem">
605
                     Item shelving location updated from
606
                 [% IF errmsgloo.ItemLocationUpdated.from %]
607
                     [% IF errmsgloo.ItemLocationUpdated.from == '' %]
608
                         empty
609
                     [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) == '' %]
610
                         [% errmsgloo.ItemLocationUpdated.from %] (No description available)
611
                     [% ELSE %]
612
                         [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) %]
613
                     [% END %]
614
                 [% ELSE %]
615
                     "Blank"
616
                 [% END %]
617
                 to
618
                 [% IF errmsgloo.ItemLocationUpdated.to %]
619
                     [% IF errmsgloo.ItemLocationUpdated.to == '' %]
620
                         empty
621
                     [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) == '' %]
622
                         [% errmsgloo.ItemLocationUpdated.to %] (Not an authorized value)
623
                     [% ELSE %]
624
                         [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) %]
625
                     [% END %]
626
                 [% ELSE %]
627
                     "Blank"
628
                 [% END %]
629
                 </p>
630
            [% END %]
631
            [% IF ( errmsgloo.badbarcode ) %]
632
                <p class="problem">No item with barcode: [% errmsgloo.msg | html %]</p>
633
            [% END %]
634
            [% IF ( errmsgloo.ispermanent ) %]
635
                <p class="problem">Please return item to: [% Branches.GetName( errmsgloo.msg ) %]</p>
636
            [% END %]
637
            [% IF ( errmsgloo.notissued ) %]
638
                <p class="problem">Not checked out.</p>
639
            [% END %]
640
            [% IF ( errmsgloo.localuse) %]
641
                <p class="problem">Local use recorded</p>
642
            [% END %]
643
            [% IF ( errmsgloo.waslost ) %]
644
                <p class="problem">Item was lost, now found.</p>
645
                [% IF ( LostItemFeeRefunded ) %]
646
                    <p class="problem">A refund has been applied to the borrowing patron's account.</p>
647
                [% ELSE %]
648
                    <p class="problem">Any lost item fees for this item will remain on the patron's account.</p>
649
                [% END %]
650
            [% END %]
651
            [% IF ( errmsgloo.withdrawn ) %]
652
                [% IF BlockReturnOfWithdrawnItems %]
653
                    <h5>Cannot check in</h5>
654
                    <p><strong>NOT CHECKED IN</strong></p>
655
                    <p class="problem">Item is withdrawn.</p>
656
                [% ELSE %]
657
                    <p class="problem">Item is withdrawn.</p>
658
                [% END %]
659
            [% END %]
660
            [% IF ( errmsgloo.debarred ) %]
661
                <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>
662
            [% END %]
663
            [% IF ( errmsgloo.prevdebarred ) %]
664
                <p class="problem"><b>Reminder: </b>Patron was earlier restricted until [% errmsgloo.prevdebarred | $KohaDates %].</p>
602
            [% END %]
665
            [% END %]
603
            [% IF ( errmsgloo.badbarcode ) %]
666
            [% IF ( errmsgloo.badbarcode ) %]
604
                <p class="problem">No item with barcode: [% errmsgloo.msg | html %]</p>
667
                <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