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

(-)a/C4/Circulation.pm (-2 / +13 lines)
Lines 3610-3618 sub ReturnLostItem{ Link Here
3610
3610
3611
3611
3612
sub LostItem{
3612
sub LostItem{
3613
    my ($itemnumber, $mark_returned) = @_;
3613
    my ($itemnumber, $mark_lost_from, $force_mark_returned) = @_;
3614
3614
3615
    $mark_returned //= C4::Context->preference('MarkLostItemsAsReturned');
3615
    unless ( $mark_lost_from ) {
3616
        # Temporary check to avoid regressions
3617
        die q|LostItem called without $mark_lost_from, check the API.|;
3618
    }
3619
3620
    my $mark_returned;
3621
    if ( $force_mark_returned ) {
3622
        $mark_returned = 1;
3623
    } else {
3624
        my $pref = C4::Context->preference('MarkLostItemsAsReturned') // q{};
3625
        $mark_returned = ( $pref =~ m|$mark_lost_from| );
3626
    }
3616
3627
3617
    my $dbh = C4::Context->dbh();
3628
    my $dbh = C4::Context->dbh();
3618
    my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title 
3629
    my $sth=$dbh->prepare("SELECT issues.*,items.*,biblio.title 
(-)a/catalogue/updateitem.pl (-1 / +1 lines)
Lines 80-85 elsif (defined $itemnotes) { # i.e., itemnotes parameter passed from form Link Here
80
80
81
ModItem($item_changes, $biblionumber, $itemnumber);
81
ModItem($item_changes, $biblionumber, $itemnumber);
82
82
83
LostItem($itemnumber) if $itemlost;
83
LostItem($itemnumber, 'moredetail') if $itemlost;
84
84
85
print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
85
print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
(-)a/cataloguing/additem.pl (-1 / +1 lines)
Lines 695-701 if ($op eq "additem") { Link Here
695
        $itemnumber = q{};
695
        $itemnumber = q{};
696
        my $olditemlost = $item->{itemlost};
696
        my $olditemlost = $item->{itemlost};
697
        my $newitemlost = $newitem->{itemlost};
697
        my $newitemlost = $newitem->{itemlost};
698
        LostItem( $item->{itemnumber} )
698
        LostItem( $item->{itemnumber}, 'additem' )
699
            if $newitemlost && $newitemlost ge '1' && !$olditemlost;
699
            if $newitemlost && $newitemlost ge '1' && !$olditemlost;
700
    }
700
    }
701
    $nextop="additem";
701
    $nextop="additem";
(-)a/installer/data/mysql/atomicupdate/bug_19974.perl (+26 lines)
Line 0 Link Here
1
$DBversion = 'XXX';  # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    my ( $original_value ) = $dbh->selectrow_array(q|
4
        SELECT value FROM systempreferences WHERE variable="MarkLostItemsAsReturned"
5
    |);
6
    if ( $original_value and $original_value eq '1' ) {
7
        $dbh->do(q{
8
            UPDATE systempreferences
9
            SET type="multiple",
10
                options="batchmod|moredetail|cronjob|additem",
11
                value="batchmod|moredetail|cronjob|additem"
12
            WHERE variable="MarkLostItemsAsReturned"
13
        });
14
    } else {
15
        $dbh->do(q{
16
            UPDATE systempreferences
17
            SET type="multiple",
18
                options="batchmod|moredetail|cronjob|additem",
19
                value=""
20
            WHERE variable="MarkLostItemsAsReturned"
21
        });
22
    }
23
24
    SetVersion( $DBversion );
25
    print "Upgrade to $DBversion done (Bug 19974 - Make MarkLostItemsAsReturned multiple)\n";
26
}
(-)a/installer/data/mysql/sysprefs.sql (-1 / +1 lines)
Lines 261-267 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
261
('MarcFieldDocURL', NULL, NULL, 'URL used for MARC field documentation. Following substitutions are available: {MARC} = marc flavour, eg. "MARC21" or "UNIMARC". {FIELD} = field number, eg. "000" or "048". {LANG} = user language, eg. "en" or "fi-FI"', 'free'),
261
('MarcFieldDocURL', NULL, NULL, 'URL used for MARC field documentation. Following substitutions are available: {MARC} = marc flavour, eg. "MARC21" or "UNIMARC". {FIELD} = field number, eg. "000" or "048". {LANG} = user language, eg. "en" or "fi-FI"', 'free'),
262
('MarcFieldsToOrder','',NULL,'Set the mapping values for a new order line created from a MARC record in a staged file. In a YAML format.','textarea'),
262
('MarcFieldsToOrder','',NULL,'Set the mapping values for a new order line created from a MARC record in a staged file. In a YAML format.','textarea'),
263
('MarcItemFieldsToOrder','',NULL,'Set the mapping values for new item records created from a MARC record in a staged file. In a YAML format.','textarea'),
263
('MarcItemFieldsToOrder','',NULL,'Set the mapping values for new item records created from a MARC record in a staged file. In a YAML format.','textarea'),
264
('MarkLostItemsAsReturned','1','','Mark items as returned when flagged as lost','YesNo'),
264
('MarkLostItemsAsReturned','batchmod|moredetail|cronjob|additem','batchmod|moredetail|cronjob|additem','Mark items as returned when flagged as lost','multiple'),
265
('MARCOrgCode','OSt','','Define MARC Organization Code for MARC21 records - http://www.loc.gov/marc/organizations/orgshome.html','free'),
265
('MARCOrgCode','OSt','','Define MARC Organization Code for MARC21 records - http://www.loc.gov/marc/organizations/orgshome.html','free'),
266
('MaxFine',NULL,'','Maximum fine a patron can have for all late returns at one moment. Single item caps are specified in the circulation rules matrix.','Integer'),
266
('MaxFine',NULL,'','Maximum fine a patron can have for all late returns at one moment. Single item caps are specified in the circulation rules matrix.','Integer'),
267
('MaxItemsToDisplayForBatchDel','1000',NULL,'Display up to a given number of items in a single item deletionbatch.','Integer'),
267
('MaxItemsToDisplayForBatchDel','1000',NULL,'Display up to a given number of items in a single item deletionbatch.','Integer'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (-4 / +7 lines)
Lines 413-423 Circulation: Link Here
413
                  nothing : "do nothing"
413
                  nothing : "do nothing"
414
            - .
414
            - .
415
        -
415
        -
416
            - "Mark items as returned when flagged as lost "
416
            - pref: MarkLostItemsAsReturned
417
            - pref: MarkLostItemsAsReturned
417
              choices:
418
              multiple:
418
                  yes: "Mark"
419
                cronjob: "from the longoverdue cronjob"
419
                  no: "Do not mark"
420
                batchmod: "from the batch item modification tool"
420
            - "items as returned when flagged as lost"
421
                additem: "when cataloguing an item"
422
                moredetail: "from the items tab of the catalog module"
423
            - .
421
        -
424
        -
422
            - pref: AllowMultipleIssuesOnABiblio
425
            - pref: AllowMultipleIssuesOnABiblio
423
              choices:
426
              choices:
(-)a/misc/cronjobs/longoverdue.pl (-1 / +1 lines)
Lines 310-316 foreach my $startrange (sort keys %$lost) { Link Here
310
            if($confirm) {
310
            if($confirm) {
311
                ModItem({ itemlost => $lostvalue }, $row->{'biblionumber'}, $row->{'itemnumber'});
311
                ModItem({ itemlost => $lostvalue }, $row->{'biblionumber'}, $row->{'itemnumber'});
312
                if ( $charge && $charge eq $lostvalue ) {
312
                if ( $charge && $charge eq $lostvalue ) {
313
                    LostItem( $row->{'itemnumber'}, $mark_returned );
313
                    LostItem( $row->{'itemnumber'}, 'cronjob', $mark_returned );
314
                } elsif ( $mark_returned ) {
314
                } elsif ( $mark_returned ) {
315
                    my $patron = Koha::Patrons->find( $row->{borrowernumber} );
315
                    my $patron = Koha::Patrons->find( $row->{borrowernumber} );
316
                    MarkIssueReturned($row->{borrowernumber},$row->{itemnumber},undef,undef,$patron->privacy)
316
                    MarkIssueReturned($row->{borrowernumber},$row->{itemnumber},undef,undef,$patron->privacy)
(-)a/t/db_dependent/Circulation.t (-3 / +6 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 114;
20
use Test::More tests => 116;
21
21
22
use DateTime;
22
use DateTime;
23
use POSIX qw( floor );
23
use POSIX qw( floor );
Lines 846-855 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
846
    t::lib::Mocks::mock_preference('WhenLostForgiveFine','0');
846
    t::lib::Mocks::mock_preference('WhenLostForgiveFine','0');
847
    t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','0');
847
    t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','0');
848
848
849
    LostItem( $itemnumber, 1 );
849
    LostItem( $itemnumber, 'test', 1 );
850
850
851
    my $item = Koha::Database->new()->schema()->resultset('Item')->find($itemnumber);
851
    my $item = Koha::Database->new()->schema()->resultset('Item')->find($itemnumber);
852
    ok( !$item->onloan(), "Lost item marked as returned has false onloan value" );
852
    ok( !$item->onloan(), "Lost item marked as returned has false onloan value" );
853
    my $checkout = Koha::Checkouts->find({ itemnumber => $itemnumber });
854
    is( $checkout, undef, 'LostItem called with forced return has checked in the item' );
853
855
854
    my $total_due = $dbh->selectrow_array(
856
    my $total_due = $dbh->selectrow_array(
855
        'SELECT SUM( amountoutstanding ) FROM accountlines WHERE borrowernumber = ?',
857
        'SELECT SUM( amountoutstanding ) FROM accountlines WHERE borrowernumber = ?',
Lines 871-880 C4::Context->dbh->do("DELETE FROM accountlines"); Link Here
871
        }
873
        }
872
    );
874
    );
873
875
874
    LostItem( $itemnumber2, 0 );
876
    LostItem( $itemnumber2, 'test', 0 );
875
877
876
    my $item2 = Koha::Database->new()->schema()->resultset('Item')->find($itemnumber2);
878
    my $item2 = Koha::Database->new()->schema()->resultset('Item')->find($itemnumber2);
877
    ok( $item2->onloan(), "Lost item *not* marked as returned has true onloan value" );
879
    ok( $item2->onloan(), "Lost item *not* marked as returned has true onloan value" );
880
    ok( Koha::Checkouts->find({ itemnumber => $itemnumber2 }), 'LostItem called without forced return has checked in the item' );
878
881
879
    $total_due = $dbh->selectrow_array(
882
    $total_due = $dbh->selectrow_array(
880
        'SELECT SUM( amountoutstanding ) FROM accountlines WHERE borrowernumber = ?',
883
        'SELECT SUM( amountoutstanding ) FROM accountlines WHERE borrowernumber = ?',
(-)a/tools/batchMod.pl (-2 / +1 lines)
Lines 207-213 if ($op eq "action") { Link Here
207
                if ( $modified ) {
207
                if ( $modified ) {
208
                    eval {
208
                    eval {
209
                        if ( my $item = ModItemFromMarc( $localmarcitem, $itemdata->{biblionumber}, $itemnumber ) ) {
209
                        if ( my $item = ModItemFromMarc( $localmarcitem, $itemdata->{biblionumber}, $itemnumber ) ) {
210
                            LostItem($itemnumber) if $item->{itemlost} and not $itemdata->{itemlost};
210
                            LostItem($itemnumber, 'batchmod') if $item->{itemlost} and not $itemdata->{itemlost};
211
                        }
211
                        }
212
                    };
212
                    };
213
                }
213
                }
214
- 

Return to bug 19974