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

(-)a/C4/Circulation.pm (-4 / +20 lines)
Lines 2855-2860 sub CanBookBeRenewed { Link Here
2855
        return ( 0, "auto_too_soon" );
2855
        return ( 0, "auto_too_soon" );
2856
    }
2856
    }
2857
2857
2858
    if ( $item->{itemlost} ) {
2859
        my $schema = Koha::Database->new()->schema();
2860
        my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => $branchcode } );
2861
        $rule ||= $schema->resultset('DefaultCircRule')->single();
2862
        return ( 0, "item_lost" ) unless $rule->{renew_lost_allowed};
2863
    }
2864
2858
    return ( 1, undef );
2865
    return ( 1, undef );
2859
}
2866
}
2860
2867
Lines 2936-2945 sub AddRenewal { Link Here
2936
    # Update the renewal count on the item, and tell zebra to reindex
2943
    # Update the renewal count on the item, and tell zebra to reindex
2937
    $renews = $biblio->{'renewals'} + 1;
2944
    $renews = $biblio->{'renewals'} + 1;
2938
2945
2946
    my $schema = Koha::Database->new()->schema();
2947
    my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => _GetCircControlBranch( $item, $borrower ) } );
2948
    $rule ||= $schema->resultset('DefaultCircRule')->single();
2949
2939
    # If item was lost, it has now been found, reverse any list item charges if neccessary.
2950
    # If item was lost, it has now been found, reverse any list item charges if neccessary.
2940
    if ( $item->{'itemlost'} ) {
2951
    my $itemlost = 0;
2941
        if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) {
2952
    if ( $item->{itemlost} ) {
2942
            _FixAccountForLostAndReturned( $item->{'itemnumber'}, undef, $item->{'barcode'} );
2953
        $itemlost = 1;
2954
        if ( $rule->renew_lost_found ) {
2955
            $itemlost = 0;
2956
            if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) {
2957
                _FixAccountForLostAndReturned( $item->{itemnumber}, undef, $item->{barcode} );
2958
            }
2943
        }
2959
        }
2944
    }
2960
    }
2945
2961
Lines 2947-2953 sub AddRenewal { Link Here
2947
        {
2963
        {
2948
            renewals => $renews,
2964
            renewals => $renews,
2949
            onloan => $datedue->strftime('%Y-%m-%d %H:%M'),
2965
            onloan => $datedue->strftime('%Y-%m-%d %H:%M'),
2950
            itemlost => 0,
2966
            itemlost => $itemlost,
2951
        },
2967
        },
2952
        $biblio->{'biblionumber'},
2968
        $biblio->{'biblionumber'},
2953
        $itemnumber
2969
        $itemnumber
(-)a/admin/smart-rules.pl (-16 / +22 lines)
Lines 185-195 elsif ($op eq 'add') { Link Here
185
185
186
}
186
}
187
elsif ($op eq "set-branch-defaults") {
187
elsif ($op eq "set-branch-defaults") {
188
    my $categorycode  = $input->param('categorycode');
188
    my $categorycode       = $input->param('categorycode');
189
    my $maxissueqty   = $input->param('maxissueqty');
189
    my $maxissueqty        = $input->param('maxissueqty');
190
    my $maxonsiteissueqty = $input->param('maxonsiteissueqty');
190
    my $maxonsiteissueqty  = $input->param('maxonsiteissueqty');
191
    my $holdallowed   = $input->param('holdallowed');
191
    my $holdallowed        = $input->param('holdallowed');
192
    my $returnbranch  = $input->param('returnbranch');
192
    my $returnbranch       = $input->param('returnbranch');
193
    my $renew_lost_allowed = $input->param('renew_lost_allowed');
194
    my $renew_lost_found   = $input->param('renew_lost_found');
195
193
    $maxissueqty =~ s/\s//g;
196
    $maxissueqty =~ s/\s//g;
194
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
197
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
195
    $maxonsiteissueqty =~ s/\s//g;
198
    $maxonsiteissueqty =~ s/\s//g;
Lines 201-217 elsif ($op eq "set-branch-defaults") { Link Here
201
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
204
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
202
                                        FROM default_circ_rules");
205
                                        FROM default_circ_rules");
203
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
206
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
204
                                        (maxissueqty, maxonsiteissueqty, holdallowed, returnbranch)
207
                                        (maxissueqty, maxonsiteissueqty, holdallowed, returnbranch, renew_lost_allowed, renew_lost_found)
205
                                        VALUES (?, ?, ?, ?)");
208
                                        VALUES (?, ?, ?, ?, ?, ?)");
206
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
209
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
207
                                        SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ?");
210
                                        SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ?, renew_lost_allowed = ?, renew_lost_found = ?");
208
211
209
        $sth_search->execute();
212
        $sth_search->execute();
210
        my $res = $sth_search->fetchrow_hashref();
213
        my $res = $sth_search->fetchrow_hashref();
211
        if ($res->{total}) {
214
        if ($res->{total}) {
212
            $sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch);
215
            $sth_update->execute( $maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
213
        } else {
216
        } else {
214
            $sth_insert->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch);
217
            $sth_insert->execute( $maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
215
        }
218
        }
216
    } else {
219
    } else {
217
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
220
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
Lines 563-574 if ($branch eq "*") { Link Here
563
my $defaults = $sth_defaults->fetchrow_hashref;
566
my $defaults = $sth_defaults->fetchrow_hashref;
564
567
565
if ($defaults) {
568
if ($defaults) {
566
    $template->param(default_holdallowed_none => 1) if($defaults->{holdallowed} == 0);
569
    $template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 );
567
    $template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1);
570
    $template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 );
568
    $template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2);
571
    $template->param( default_holdallowed_any  => 1 ) if ( $defaults->{holdallowed} == 2 );
569
    $template->param(default_maxissueqty => $defaults->{maxissueqty});
572
570
    $template->param(default_maxonsiteissueqty => $defaults->{maxonsiteissueqty});
573
    $template->param( default_maxissueqty        => $defaults->{maxissueqty} );
571
    $template->param(default_returnbranch => $defaults->{returnbranch});
574
    $template->param( default_maxonsiteissueqty  => $defaults->{maxonsiteissueqty} );
575
    $template->param( default_returnbranch       => $defaults->{returnbranch} );
576
    $template->param( default_renew_lost_allowed => $defaults->{renew_lost_allowed} );
577
    $template->param( default_renew_lost_found   => $defaults->{renew_lost_found} );
572
}
578
}
573
579
574
$template->param(default_rules => ($defaults ? 1 : 0));
580
$template->param(default_rules => ($defaults ? 1 : 0));
(-)a/installer/data/mysql/updatedatabase.pl (+18 lines)
Lines 11669-11674 if ( CheckVersion($DBversion) ) { Link Here
11669
    SetVersion($DBversion);
11669
    SetVersion($DBversion);
11670
}
11670
}
11671
11671
11672
$DBversion = "XXX";
11673
if ( CheckVersion($DBversion) ) {
11674
    $dbh->do(q|
11675
        ALTER TABLE default_circ_rules
11676
            ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
11677
            ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0'
11678
    |);
11679
11680
    $dbh->do(q|
11681
        ALTER TABLE default_branch_circ_rules
11682
            ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
11683
            ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0'
11684
    |);
11685
11686
    print "Upgrade to $DBversion done (Bug 9805 - Lost items are un-lost if returned, but not if renewed.)\n";
11687
    SetVersion($DBversion);
11688
}
11689
11672
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
11690
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
11673
# SEE bug 13068
11691
# SEE bug 13068
11674
# if there is anything in the atomicupdate, read and execute it.
11692
# 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 368-374 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
368
        </form>
368
        </form>
369
    </div>
369
    </div>
370
    <div id="defaults-for-this-library" class="container">
370
    <div id="defaults-for-this-library" class="container">
371
    <h3>Default checkout, hold and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
371
    <h3>Default checkout, hold, renewal and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
372
        <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>
372
        <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>
373
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
373
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
374
            <input type="hidden" name="op" value="set-branch-defaults" />
374
            <input type="hidden" name="op" value="set-branch-defaults" />
Lines 380-385 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
380
                    <th>Total current on-site checkouts allowed</th>
380
                    <th>Total current on-site checkouts allowed</th>
381
                    <th>Hold policy</th>
381
                    <th>Hold policy</th>
382
                    <th>Return policy</th>
382
                    <th>Return policy</th>
383
                    <th>Renew lost?</th>
384
                    <th>Renewal marks lost found</tH>
383
                    <th>&nbsp;</th>
385
                    <th>&nbsp;</th>
384
                    <th>&nbsp;</th>
386
                    <th>&nbsp;</th>
385
                </tr>
387
                </tr>
Lines 437-442 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
437
                            </option>
439
                            </option>
438
                        </select>
440
                        </select>
439
                    </td>
441
                    </td>
442
                    <td>
443
                        <select name="renew_lost_allowed">
444
                            [% IF ( default_renew_lost_allowed == '1' ) %]
445
                            <option value="1" selected="selected">
446
                            [% ELSE %]
447
                            <option value="1">
448
                            [% END %]
449
                                Allow renewal
450
                            </option>
451
452
                            [% IF ( default_renew_lost_allowed == '0' ) %]
453
                            <option value="0" selected="selected">
454
                            [% ELSE %]
455
                            <option value="0">
456
                            [% END %]
457
                                Disallow renewal
458
                            </option>
459
                        </select>
460
                    </td>
461
                    <td>
462
                        <select name="renew_lost_found">
463
                            [% IF ( default_renew_lost_found == '1' ) %]
464
                            <option value="1" selected="selected">
465
                            [% ELSE %]
466
                            <option value="1">
467
                            [% END %]
468
                                marks item found
469
                            </option>
470
471
                            [% IF ( default_renew_lost_found == '0' ) %]
472
                            <option value="0" selected="selected">
473
                            [% ELSE %]
474
                            <option value="0">
475
                            [% END %]
476
                                makes no change
477
                            </option>
478
                        </select>
479
                    </td>
440
                    <td><input type="submit" value="Save" class="submit" /></td>
480
                    <td><input type="submit" value="Save" class="submit" /></td>
441
                    <td>
481
                    <td>
442
                        <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]">Unset</a>
482
                        <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 247-252 Link Here
247
                                                        <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
247
                                                        <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
248
                                                    [% ELSIF ( ISSUE.on_reserve ) %]
248
                                                    [% ELSIF ( ISSUE.on_reserve ) %]
249
                                                        <span class="renewals">(On hold)</span>
249
                                                        <span class="renewals">(On hold)</span>
250
                                                    [% ELSIF ( ISSUE.item_lost ) %]
251
                                                        <span class="renewals">(Item is lost)</span>
250
                                                    [% END %]
252
                                                    [% END %]
251
                                                    </td>
253
                                                    </td>
252
                                                [% END %]
254
                                                [% END %]
253
- 

Return to bug 9805