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

(-)a/C4/Circulation.pm (-1 / +34 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 2935-2941 sub AddRenewal { Link Here
2935
2942
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
    ModItem({ renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $biblio->{'biblionumber'}, $itemnumber);
2945
2946
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
2947
    my $schema = Koha::Database->new()->schema();
2948
    my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => _GetCircControlBranch( $item, $borrower ) } );
2949
    $rule ||= $schema->resultset('DefaultCircRule')->single();
2950
2951
    # If item was lost, it has now been found, reverse any list item charges if necessary.
2952
    my $itemlost = 0;
2953
    if ( $item->{itemlost} ) {
2954
        $itemlost = 1;
2955
        if ( $rule->renew_lost_found ) {
2956
            $itemlost = 0;
2957
            if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) {
2958
                _FixAccountForLostAndReturned( $item->{itemnumber}, undef, $item->{barcode} );
2959
            }
2960
        }
2961
    }
2962
2963
    ModItem(
2964
        {
2965
            renewals => $renews,
2966
            onloan => $datedue->strftime('%Y-%m-%d %H:%M'),
2967
            itemlost => $itemlost,
2968
        },
2969
        $biblio->{'biblionumber'},
2970
        $itemnumber
2971
    );
2939
2972
2940
    # Charge a new rental fee, if applicable?
2973
    # Charge a new rental fee, if applicable?
2941
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
2974
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
(-)a/admin/smart-rules.pl (-16 / +22 lines)
Lines 188-198 elsif ($op eq 'add') { Link Here
188
188
189
}
189
}
190
elsif ($op eq "set-branch-defaults") {
190
elsif ($op eq "set-branch-defaults") {
191
    my $categorycode  = $input->param('categorycode');
191
    my $categorycode       = $input->param('categorycode');
192
    my $maxissueqty   = $input->param('maxissueqty');
192
    my $maxissueqty        = $input->param('maxissueqty');
193
    my $maxonsiteissueqty = $input->param('maxonsiteissueqty');
193
    my $maxonsiteissueqty  = $input->param('maxonsiteissueqty');
194
    my $holdallowed   = $input->param('holdallowed');
194
    my $holdallowed        = $input->param('holdallowed');
195
    my $returnbranch  = $input->param('returnbranch');
195
    my $returnbranch       = $input->param('returnbranch');
196
    my $renew_lost_allowed = $input->param('renew_lost_allowed');
197
    my $renew_lost_found   = $input->param('renew_lost_found');
198
196
    $maxissueqty =~ s/\s//g;
199
    $maxissueqty =~ s/\s//g;
197
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
200
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
198
    $maxonsiteissueqty =~ s/\s//g;
201
    $maxonsiteissueqty =~ s/\s//g;
Lines 204-220 elsif ($op eq "set-branch-defaults") { Link Here
204
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
207
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
205
                                        FROM default_circ_rules");
208
                                        FROM default_circ_rules");
206
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
209
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
207
                                        (maxissueqty, maxonsiteissueqty, holdallowed, returnbranch)
210
                                        (maxissueqty, maxonsiteissueqty, holdallowed, returnbranch, renew_lost_allowed, renew_lost_found)
208
                                        VALUES (?, ?, ?, ?)");
211
                                        VALUES (?, ?, ?, ?, ?, ?)");
209
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
212
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
210
                                        SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ?");
213
                                        SET maxissueqty = ?, maxonsiteissueqty = ?, holdallowed = ?, returnbranch = ?, renew_lost_allowed = ?, renew_lost_found = ?");
211
214
212
        $sth_search->execute();
215
        $sth_search->execute();
213
        my $res = $sth_search->fetchrow_hashref();
216
        my $res = $sth_search->fetchrow_hashref();
214
        if ($res->{total}) {
217
        if ($res->{total}) {
215
            $sth_update->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch);
218
            $sth_update->execute( $maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
216
        } else {
219
        } else {
217
            $sth_insert->execute($maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch);
220
            $sth_insert->execute( $maxissueqty, $maxonsiteissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
218
        }
221
        }
219
    } else {
222
    } else {
220
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
223
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
Lines 575-586 if ($branch eq "*") { Link Here
575
my $defaults = $sth_defaults->fetchrow_hashref;
578
my $defaults = $sth_defaults->fetchrow_hashref;
576
579
577
if ($defaults) {
580
if ($defaults) {
578
    $template->param(default_holdallowed_none => 1) if($defaults->{holdallowed} == 0);
581
    $template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 );
579
    $template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1);
582
    $template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 );
580
    $template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2);
583
    $template->param( default_holdallowed_any  => 1 ) if ( $defaults->{holdallowed} == 2 );
581
    $template->param(default_maxissueqty => $defaults->{maxissueqty});
584
582
    $template->param(default_maxonsiteissueqty => $defaults->{maxonsiteissueqty});
585
    $template->param( default_maxissueqty        => $defaults->{maxissueqty} );
583
    $template->param(default_returnbranch => $defaults->{returnbranch});
586
    $template->param( default_maxonsiteissueqty  => $defaults->{maxonsiteissueqty} );
587
    $template->param( default_returnbranch       => $defaults->{returnbranch} );
588
    $template->param( default_renew_lost_allowed => $defaults->{renew_lost_allowed} );
589
    $template->param( default_renew_lost_found   => $defaults->{renew_lost_found} );
584
}
590
}
585
591
586
$template->param(default_rules => ($defaults ? 1 : 0));
592
$template->param(default_rules => ($defaults ? 1 : 0));
(-)a/installer/data/mysql/updatedatabase.pl (+17 lines)
Lines 11718-11724 if ( CheckVersion($DBversion) ) { Link Here
11718
11718
11719
    print "Upgrade to $DBversion done (Bug 13618 - Prevent XSS in the Staff Client and the OPAC --  Please note the new dependency Template::Stash::AutoEscaping - pretty important to have)\n";
11719
    print "Upgrade to $DBversion done (Bug 13618 - Prevent XSS in the Staff Client and the OPAC --  Please note the new dependency Template::Stash::AutoEscaping - pretty important to have)\n";
11720
    SetVersion($DBversion);
11720
    SetVersion($DBversion);
11721
}
11722
11723
$DBversion = "XXX";
11724
if ( CheckVersion($DBversion) ) {
11725
    $dbh->do(q|
11726
        ALTER TABLE default_circ_rules
11727
            ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
11728
            ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0'
11729
    |);
11721
11730
11731
    $dbh->do(q|
11732
        ALTER TABLE default_branch_circ_rules
11733
            ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
11734
            ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0'
11735
    |);
11736
11737
    print "Upgrade to $DBversion done (Bug 9805 - Lost items are un-lost if returned, but not if renewed.)\n";
11738
    SetVersion($DBversion);
11722
}
11739
}
11723
11740
11724
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
11741
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
(-)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 246-251 Link Here
246
                                                        <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
246
                                                        <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
247
                                                    [% ELSIF ( ISSUE.on_reserve ) %]
247
                                                    [% ELSIF ( ISSUE.on_reserve ) %]
248
                                                        <span class="renewals">(On hold)</span>
248
                                                        <span class="renewals">(On hold)</span>
249
                                                    [% ELSIF ( ISSUE.item_lost ) %]
250
                                                        <span class="renewals">(Item is lost)</span>
249
                                                    [% END %]
251
                                                    [% END %]
250
                                                    </td>
252
                                                    </td>
251
                                                [% END %]
253
                                                [% END %]
252
- 

Return to bug 9805