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

(-)a/C4/Circulation.pm (-4 / +20 lines)
Lines 2847-2852 sub CanBookBeRenewed { Link Here
2847
        return ( 0, "auto_too_soon" );
2847
        return ( 0, "auto_too_soon" );
2848
    }
2848
    }
2849
2849
2850
    if ( $item->{itemlost} ) {
2851
        my $schema = Koha::Database->new()->schema();
2852
        my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => $branchcode } );
2853
        $rule ||= $schema->resultset('DefaultCircRule')->single();
2854
        return ( 0, "item_lost" ) unless $rule->{renew_lost_allowed};
2855
    }
2856
2850
    return ( 1, undef );
2857
    return ( 1, undef );
2851
}
2858
}
2852
2859
Lines 2928-2937 sub AddRenewal { Link Here
2928
    # Update the renewal count on the item, and tell zebra to reindex
2935
    # Update the renewal count on the item, and tell zebra to reindex
2929
    $renews = $biblio->{'renewals'} + 1;
2936
    $renews = $biblio->{'renewals'} + 1;
2930
2937
2938
    my $schema = Koha::Database->new()->schema();
2939
    my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => _GetCircControlBranch( $item, $borrower ) } );
2940
    $rule ||= $schema->resultset('DefaultCircRule')->single();
2941
2931
    # If item was lost, it has now been found, reverse any list item charges if neccessary.
2942
    # If item was lost, it has now been found, reverse any list item charges if neccessary.
2932
    if ( $item->{'itemlost'} ) {
2943
    my $itemlost = 0;
2933
        if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) {
2944
    if ( $item->{itemlost} ) {
2934
            _FixAccountForLostAndReturned( $item->{'itemnumber'}, undef, $item->{'barcode'} );
2945
        $itemlost = 1;
2946
        if ( $rule->renew_lost_found ) {
2947
            $itemlost = 0;
2948
            if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) {
2949
                _FixAccountForLostAndReturned( $item->{itemnumber}, undef, $item->{barcode} );
2950
            }
2935
        }
2951
        }
2936
    }
2952
    }
2937
2953
Lines 2939-2945 sub AddRenewal { Link Here
2939
        {
2955
        {
2940
            renewals => $renews,
2956
            renewals => $renews,
2941
            onloan => $datedue->strftime('%Y-%m-%d %H:%M'),
2957
            onloan => $datedue->strftime('%Y-%m-%d %H:%M'),
2942
            itemlost => 0,
2958
            itemlost => $itemlost,
2943
        },
2959
        },
2944
        $biblio->{'biblionumber'},
2960
        $biblio->{'biblionumber'},
2945
        $itemnumber
2961
        $itemnumber
(-)a/admin/smart-rules.pl (-16 / +22 lines)
Lines 170-180 elsif ($op eq 'add') { Link Here
170
170
171
}
171
}
172
elsif ($op eq "set-branch-defaults") {
172
elsif ($op eq "set-branch-defaults") {
173
    my $categorycode  = $input->param('categorycode');
173
    my $categorycode       = $input->param('categorycode');
174
    my $maxissueqty   = $input->param('maxissueqty');
174
    my $maxissueqty        = $input->param('maxissueqty');
175
    my $maxonsiteissueqty = $input->param('maxonsiteissueqty');
175
    my $maxonsiteissueqty  = $input->param('maxonsiteissueqty');
176
    my $holdallowed   = $input->param('holdallowed');
176
    my $holdallowed        = $input->param('holdallowed');
177
    my $returnbranch  = $input->param('returnbranch');
177
    my $returnbranch       = $input->param('returnbranch');
178
    my $renew_lost_allowed = $input->param('renew_lost_allowed');
179
    my $renew_lost_found   = $input->param('renew_lost_found');
180
178
    $maxissueqty =~ s/\s//g;
181
    $maxissueqty =~ s/\s//g;
179
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
182
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
180
    $maxonsiteissueqty =~ s/\s//g;
183
    $maxonsiteissueqty =~ s/\s//g;
Lines 186-202 elsif ($op eq "set-branch-defaults") { Link Here
186
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
189
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
187
                                        FROM default_circ_rules");
190
                                        FROM default_circ_rules");
188
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
191
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
189
                                        (maxissueqty, maxonsiteissueqty, holdallowed, returnbranch)
192
                                        (maxissueqty, maxonsiteissueqty, holdallowed, returnbranch, renew_lost_allowed, renew_lost_found)
190
                                        VALUES (?, ?, ?, ?)");
193
                                        VALUES (?, ?, ?, ?, ?, ?)");
191
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
194
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
192
                                        SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ?");
195
                                        SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ?, renew_lost_allowed = ?, renew_lost_found = ?");
193
196
194
        $sth_search->execute();
197
        $sth_search->execute();
195
        my $res = $sth_search->fetchrow_hashref();
198
        my $res = $sth_search->fetchrow_hashref();
196
        if ($res->{total}) {
199
        if ($res->{total}) {
197
            $sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch);
200
            $sth_update->execute( $maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
198
        } else {
201
        } else {
199
            $sth_insert->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch);
202
            $sth_insert->execute( $maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
200
        }
203
        }
201
    } else {
204
    } else {
202
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
205
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
Lines 548-559 if ($branch eq "*") { Link Here
548
my $defaults = $sth_defaults->fetchrow_hashref;
551
my $defaults = $sth_defaults->fetchrow_hashref;
549
552
550
if ($defaults) {
553
if ($defaults) {
551
    $template->param(default_holdallowed_none => 1) if($defaults->{holdallowed} == 0);
554
    $template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 );
552
    $template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1);
555
    $template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 );
553
    $template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2);
556
    $template->param( default_holdallowed_any  => 1 ) if ( $defaults->{holdallowed} == 2 );
554
    $template->param(default_maxissueqty => $defaults->{maxissueqty});
557
555
    $template->param(default_maxonsiteissueqty => $defaults->{maxonsiteissueqty});
558
    $template->param( default_maxissueqty        => $defaults->{maxissueqty} );
556
    $template->param(default_returnbranch => $defaults->{returnbranch});
559
    $template->param( default_maxonsiteissueqty  => $defaults->{maxonsiteissueqty} );
560
    $template->param( default_returnbranch       => $defaults->{returnbranch} );
561
    $template->param( default_renew_lost_allowed => $defaults->{renew_lost_allowed} );
562
    $template->param( default_renew_lost_found   => $defaults->{renew_lost_found} );
557
}
563
}
558
564
559
$template->param(default_rules => ($defaults ? 1 : 0));
565
$template->param(default_rules => ($defaults ? 1 : 0));
(-)a/installer/data/mysql/updatedatabase.pl (+18 lines)
Lines 11390-11395 if ( CheckVersion($DBversion) ) { Link Here
11390
    SetVersion ($DBversion);
11390
    SetVersion ($DBversion);
11391
}
11391
}
11392
11392
11393
$DBversion = "XXX";
11394
if ( CheckVersion($DBversion) ) {
11395
    $dbh->do(q|
11396
        ALTER TABLE default_circ_rules
11397
            ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
11398
            ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0'
11399
    |);
11400
11401
    $dbh->do(q|
11402
        ALTER TABLE default_branch_circ_rules
11403
            ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
11404
            ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0'
11405
    |);
11406
11407
    print "Upgrade to $DBversion done (Bug 9805 - Lost items are un-lost if returned, but not if renewed.)\n";
11408
    SetVersion($DBversion);
11409
}
11410
11393
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
11411
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
11394
# SEE bug 13068
11412
# SEE bug 13068
11395
# if there is anything in the atomicupdate, read and execute it.
11413
# if there is anything in the atomicupdate, read and execute it.
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc (+1 lines)
Lines 18-23 Link Here
18
    var NOT_RENEWABLE_TOO_SOON = _("No renewal before %s");
18
    var NOT_RENEWABLE_TOO_SOON = _("No renewal before %s");
19
    var NOT_RENEWABLE_AUTO_TOO_SOON = _("Scheduled for automatic renewal");
19
    var NOT_RENEWABLE_AUTO_TOO_SOON = _("Scheduled for automatic renewal");
20
    var NOT_RENEWABLE_AUTO_RENEW = _("Scheduled for automatic renewal");
20
    var NOT_RENEWABLE_AUTO_RENEW = _("Scheduled for automatic renewal");
21
    var ITEM_LOST = _("Item lost");
21
    var RENEWALS_REMAINING = _("%s of %s renewals remaining");
22
    var RENEWALS_REMAINING = _("%s of %s renewals remaining");
22
    var HOLD_IS_SUSPENDED = _("Hold is <strong>suspended</strong>");
23
    var HOLD_IS_SUSPENDED = _("Hold is <strong>suspended</strong>");
23
    var UNTIL = _("until %s");
24
    var UNTIL = _("until %s");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +41 lines)
Lines 347-353 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
347
        </form>
347
        </form>
348
    </div>
348
    </div>
349
    <div id="defaults-for-this-library" class="container">
349
    <div id="defaults-for-this-library" class="container">
350
    <h3>Default checkout, hold and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
350
    <h3>Default checkout, hold, renewal and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
351
        <p>You can set a default maximum number of checkouts, hold policy and return policy that will be used if none is defined below for a particular item type or category.</p>
351
        <p>You can set a default maximum number of checkouts, hold policy and return policy that will be used if none is defined below for a particular item type or category.</p>
352
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
352
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
353
            <input type="hidden" name="op" value="set-branch-defaults" />
353
            <input type="hidden" name="op" value="set-branch-defaults" />
Lines 359-364 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
359
                    <th>Total current on-site checkouts allowed</th>
359
                    <th>Total current on-site checkouts allowed</th>
360
                    <th>Hold policy</th>
360
                    <th>Hold policy</th>
361
                    <th>Return policy</th>
361
                    <th>Return policy</th>
362
                    <th>Renew lost?</th>
363
                    <th>Renewal marks lost found</tH>
362
                    <th>&nbsp;</th>
364
                    <th>&nbsp;</th>
363
                    <th>&nbsp;</th>
365
                    <th>&nbsp;</th>
364
                </tr>
366
                </tr>
Lines 416-421 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
416
                            </option>
418
                            </option>
417
                        </select>
419
                        </select>
418
                    </td>
420
                    </td>
421
                    <td>
422
                        <select name="renew_lost_allowed">
423
                            [% IF ( default_renew_lost_allowed == '1' ) %]
424
                            <option value="1" selected="selected">
425
                            [% ELSE %]
426
                            <option value="1">
427
                            [% END %]
428
                                Allow renewal
429
                            </option>
430
431
                            [% IF ( default_renew_lost_allowed == '0' ) %]
432
                            <option value="0" selected="selected">
433
                            [% ELSE %]
434
                            <option value="0">
435
                            [% END %]
436
                                Disallow renewal
437
                            </option>
438
                        </select>
439
                    </td>
440
                    <td>
441
                        <select name="renew_lost_found">
442
                            [% IF ( default_renew_lost_found == '1' ) %]
443
                            <option value="1" selected="selected">
444
                            [% ELSE %]
445
                            <option value="1">
446
                            [% END %]
447
                                marks item found
448
                            </option>
449
450
                            [% IF ( default_renew_lost_found == '0' ) %]
451
                            <option value="0" selected="selected">
452
                            [% ELSE %]
453
                            <option value="0">
454
                            [% END %]
455
                                makes no change
456
                            </option>
457
                        </select>
458
                    </td>
419
                    <td><input type="submit" value="Save" class="submit" /></td>
459
                    <td><input type="submit" value="Save" class="submit" /></td>
420
                    <td>
460
                    <td>
421
                        <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]">Unset</a>
461
                        <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]">Unset</a>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt (+4 lines)
Lines 104-109 Link Here
104
104
105
                                <p>[% borrower.firstname %] [% borrower.surname %] ( <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber %]"> [% borrower.cardnumber %] </a> ) is currently restricted.</p>
105
                                <p>[% borrower.firstname %] [% borrower.surname %] ( <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber %]"> [% borrower.cardnumber %] </a> ) is currently restricted.</p>
106
106
107
                            [% ELSIF error == "item_lost" %]
108
109
                                <p>This item is lost.</p>
110
107
                            [% ELSE %]
111
                            [% ELSE %]
108
112
109
                                [% error %]
113
                                [% error %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-1 / +2 lines)
Lines 248-253 Link Here
248
                                                        <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
248
                                                        <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
249
                                                    [% ELSIF ( ISSUE.on_reserve ) %]
249
                                                    [% ELSIF ( ISSUE.on_reserve ) %]
250
                                                        <span class="renewals">(On hold)</span>
250
                                                        <span class="renewals">(On hold)</span>
251
                                                    [% ELSIF ( ISSUE.item_lost ) %]
252
                                                        <span class="renewals">(Item is lost)</span>
251
                                                    [% END %]
253
                                                    [% END %]
252
                                                    </td>
254
                                                    </td>
253
                                                [% END %]
255
                                                [% END %]
254
- 

Return to bug 9805