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

(-)a/C4/Circulation.pm (-13 / +41 lines)
Lines 1385-1390 sub AddIssue { Link Here
1385
                }
1385
                }
1386
              );
1386
              );
1387
1387
1388
        if ( $item->{'location'} eq 'CART' && $item->{'permanent_location'} ne 'CART'  ) {
1389
        ## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
1390
          CartToShelf( $item->{'itemnumber'} );
1391
        }
1392
        $item->{'issues'}++;
1393
        if ( C4::Context->preference('UpdateTotalIssuesOnCirc') ) {
1394
            UpdateTotalIssues($item->{'biblionumber'}, 1);
1395
        }
1396
1388
            if ( C4::Context->preference('ReturnToShelvingCart') ) {
1397
            if ( C4::Context->preference('ReturnToShelvingCart') ) {
1389
                # ReturnToShelvingCart is on, anything issued should be taken off the cart.
1398
                # ReturnToShelvingCart is on, anything issued should be taken off the cart.
1390
                CartToShelf( $item->{'itemnumber'} );
1399
                CartToShelf( $item->{'itemnumber'} );
Lines 1854-1869 sub AddReturn { Link Here
1854
        }
1863
        }
1855
    }
1864
    }
1856
1865
1857
    if ( $item->{'location'} eq 'PROC' ) {
1866
    my $item = GetItem($itemnumber) or die "GetItem($itemnumber) failed";
1858
        if ( C4::Context->preference("InProcessingToShelvingCart") ) {
1859
            $item->{'location'} = 'CART';
1860
        }
1861
        else {
1862
            $item->{location} = $item->{permanent_location};
1863
        }
1864
1865
        ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
1866
    }
1867
1867
1868
        # full item data, but no borrowernumber or checkout info (no issue)
1868
        # full item data, but no borrowernumber or checkout info (no issue)
1869
        # we know GetItem should work because GetItemnumberFromBarcode worked
1869
        # we know GetItem should work because GetItemnumberFromBarcode worked
Lines 1874-1879 sub AddReturn { Link Here
1874
1874
1875
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1875
    my $borrowernumber = $borrower->{'borrowernumber'} || undef;    # we don't know if we had a borrower or not
1876
1876
1877
    my $yaml = C4::Context->preference('UpdateItemLocationOnCheckin');
1878
    if ($yaml) {
1879
        $yaml = "$yaml\n\n";  # YAML is strict on ending \n. Surplus does not hurt
1880
        my $rules;
1881
        eval { $rules = YAML::Load($yaml); };
1882
        if ($@) {
1883
            warn "Unable to parse UpdateItemLocationOnCheckin syspref : $@";
1884
        }
1885
        else {
1886
            if (defined $rules->{_ALL_}) {
1887
                if ($rules->{_ALL_} eq '_PERM_') { $rules->{_ALL_} = $item->{permanent_location}; }
1888
                if ($rules->{_ALL_} eq '_BLANK_') { $rules->{_ALL_} = ''; }
1889
                if ( $item->{location} ne $rules->{_ALL_}) {
1890
                    $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{_ALL_} };
1891
                    ModItem( { location => $rules->{_ALL_} }, undef, $itemnumber );
1892
                }
1893
            }
1894
            else {
1895
                foreach my $key ( keys %$rules ) {
1896
                    if ( $rules->{$key} eq '_PERM_' ) { $rules->{$key} = $item->{permanent_location}; }
1897
                    if ( $rules->{$key} eq '_BLANK_') { $rules->{$key} = '' ;}
1898
                    if ( ($item->{location} eq $key && $item->{location} ne $rules->{$key}) || ($key eq '_BLANK_' && $item->{location} eq '' && $rules->{$key} ne '') ) {
1899
                        $messages->{'ItemLocationUpdated'} = { from => $item->{location}, to => $rules->{$key} };
1900
                        ModItem( { location => $rules->{$key} }, undef, $itemnumber );
1901
                        last;
1902
                    }
1903
                }
1904
            }
1905
        }
1906
    }
1907
1877
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1908
    my $yaml = C4::Context->preference('UpdateNotForLoanStatusOnCheckin');
1878
    if ($yaml) {
1909
    if ($yaml) {
1879
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
1910
        $yaml = "$yaml\n\n";  # YAML is anal on ending \n. Surplus does not hurt
Lines 1982-1996 sub AddReturn { Link Here
1982
            );
2013
            );
1983
            $sth->execute( $item->{'itemnumber'} );
2014
            $sth->execute( $item->{'itemnumber'} );
1984
            # if we have a reservation with valid transfer, we can set it's status to 'W'
2015
            # if we have a reservation with valid transfer, we can set it's status to 'W'
1985
            ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
1986
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
2016
            C4::Reserves::ModReserveStatus($item->{'itemnumber'}, 'W');
1987
        } else {
2017
        } else {
1988
            $messages->{'WrongTransfer'}     = $tobranch;
2018
            $messages->{'WrongTransfer'}     = $tobranch;
1989
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
2019
            $messages->{'WrongTransferItem'} = $item->{'itemnumber'};
1990
        }
2020
        }
1991
        $validTransfert = 1;
2021
        $validTransfert = 1;
1992
    } else {
1993
        ShelfToCart( $item->{'itemnumber'} ) if ( C4::Context->preference("ReturnToShelvingCart") );
1994
    }
2022
    }
1995
2023
1996
    # fix up the accounts.....
2024
    # fix up the accounts.....
(-)a/circ/returns.pl (+3 lines)
Lines 537-542 foreach my $code ( keys %$messages ) { Link Here
537
    elsif ( $code eq 'ForeverDebarred' ) {
537
    elsif ( $code eq 'ForeverDebarred' ) {
538
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
538
        $err{foreverdebarred}        = $messages->{'ForeverDebarred'};
539
    }
539
    }
540
    elsif ( $code eq 'ItemLocationUpdated' ) {
541
        $err{ItemLocationUpdated} = $messages->{ItemLocationUpdated};
542
    }
540
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
543
    elsif ( $code eq 'NotForLoanStatusUpdated' ) {
541
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
544
        $err{NotForLoanStatusUpdated} = $messages->{NotForLoanStatusUpdated};
542
    }
545
    }
(-)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 531-536 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
531
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
531
('UNIMARCAuthorsFacetsSeparator',', ',NULL,'UNIMARC authors facets separator','short'),
532
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
532
('UNIMARCField100Language','fre',NULL,'UNIMARC field 100 default language','short'),
533
('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'),
533
('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'),
534
('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'),
534
('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'),
535
('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'),
535
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
536
('UpdateTotalIssuesOnCirc','0',NULL,'Whether to update the totalissues field in the biblio on each circ.','YesNo'),
536
('uppercasesurnames','0',NULL,'If ON, surnames are converted to upper case in patron entry form','YesNo'),
537
('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 187-204 Circulation: Link Here
187
                  no: "Don't allow"
187
                  no: "Don't allow"
188
            - staff to manually override and check out items to patrons who have more than noissuescharge in fines.
188
            - staff to manually override and check out items to patrons who have more than noissuescharge in fines.
189
        -
189
        -
190
            - pref: InProcessingToShelvingCart
191
              choices:
192
                  yes: Move
193
                  no: "Don't move"
194
            - items that have the location PROC to the location CART when they are checked in.
195
        -
196
            - pref: ReturnToShelvingCart
197
              choices:
198
                  yes: Move
199
                  no: "Don't move"
200
            - all items to the location CART when they are checked in.
201
        -
202
            - pref: AutomaticItemReturn
190
            - pref: AutomaticItemReturn
203
              choices:
191
              choices:
204
                  yes: Do
192
                  yes: Do
Lines 453-458 Circulation: Link Here
453
            - calculate and update overdue charges when an item is returned.
441
            - calculate and update overdue charges when an item is returned.
454
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
442
            - <br /><b>NOTE If you are doing hourly loans then you should have this on.</b>
455
        -
443
        -
444
            - pref: UpdateItemLocationOnCheckin
445
              type: textarea
446
              class: code
447
            - This is is a list of value pairs, the first value is followed immediately by colon space then the second value i.e.:<br/>
448
            - "PROC: FIC"
449
            - <br/> When an item is checked in, if the location value on the left matches the items location value
450
            - "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."
451
            - <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.
452
            - <br/>Items in the CART location will be returned to their permanent location on checkout
453
            - <br/>You can use the special term _BLANK_ on either side of a pair to update/remove items with no location assigned
454
            - <br>You can use the special term _ALL_ on the left side to affect all items
455
            - and the special term _PERM_ on the right side to return items to their permanent location
456
            - <br>**Use of an _ALL_ rule will override/ignore any other values**
457
            - <br>Each pair of values should be on a separate line.
458
        -
456
            - pref: UpdateNotForLoanStatusOnCheckin
459
            - pref: UpdateNotForLoanStatusOnCheckin
457
              type: textarea
460
              type: textarea
458
              class: code
461
              class: code
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (+29 lines)
Lines 600-605 $(document).ready(function () { Link Here
600
                            [% END %]
600
                            [% END %]
601
                        </p>
601
                        </p>
602
                    [% END %]
602
                    [% END %]
603
                    [% IF ( errmsgloo.ItemLocationUpdated ) %]
604
                        <p class="problem">
605
                            Item shelving location updated
606
                            from
607
                            [% IF errmsgloo.ItemLocationUpdated.from %]
608
                                [% IF errmsgloo.ItemLocationUpdated.from == '' %]
609
                                 empty
610
                                [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) == '' %]
611
                                    [% errmsgloo.ItemLocationUpdated.from %] (No description available)
612
                                [% ELSE %]
613
                                    [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.from ) %]
614
                                [% END %]
615
                            [% ELSE %]
616
                                "Blank"
617
                            [% END %]
618
                            to
619
                            [% IF errmsgloo.ItemLocationUpdated.to %]
620
                                [% IF errmsgloo.ItemLocationUpdated.to == '' %]
621
                                   empty
622
                                [% ELSIF AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) == '' %]
623
                                    [% errmsgloo.ItemLocationUpdated.to %] (Not an authorized value)
624
                                [% ELSE %]
625
                                    [% AuthorisedValues.GetByCode( 'LOC', errmsgloo.ItemLocationUpdated.to ) %]
626
                                [% END %]
627
                            [% ELSE %]
628
                                "Blank"
629
                            [% END %]
630
                        </p>
631
                    [% END %]
603
                    [% IF ( errmsgloo.badbarcode ) %]
632
                    [% IF ( errmsgloo.badbarcode ) %]
604
                        <p class="problem">No item with barcode: [% errmsgloo.msg | html %]</p>
633
                        <p class="problem">No item with barcode: [% errmsgloo.msg | html %]</p>
605
                    [% END %]
634
                    [% 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