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

(-)a/C4/Circulation.pm (-4 / +21 lines)
Lines 2744-2749 sub CanBookBeRenewed { Link Here
2744
    }
2744
    }
2745
2745
2746
    return ( 0, "auto_renew" ) if $itemissue->{auto_renew};
2746
    return ( 0, "auto_renew" ) if $itemissue->{auto_renew};
2747
2748
    if ( $item->{itemlost} ) {
2749
        my $schema = Koha::Database->new()->schema();
2750
        my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => $branchcode } );
2751
        $rule ||= $schema->resultset('DefaultCircRule')->single();
2752
        return ( 0, "item_lost" ) unless $rule->{renew_lost_allowed};
2753
    }
2754
2747
    return ( 1, undef );
2755
    return ( 1, undef );
2748
}
2756
}
2749
2757
Lines 2825-2834 sub AddRenewal { Link Here
2825
    # Update the renewal count on the item, and tell zebra to reindex
2833
    # Update the renewal count on the item, and tell zebra to reindex
2826
    $renews = $biblio->{'renewals'} + 1;
2834
    $renews = $biblio->{'renewals'} + 1;
2827
2835
2836
    my $schema = Koha::Database->new()->schema();
2837
    my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => _GetCircControlBranch( $item, $borrower ) } );
2838
    $rule ||= $schema->resultset('DefaultCircRule')->single();
2839
2828
    # If item was lost, it has now been found, reverse any list item charges if neccessary.
2840
    # If item was lost, it has now been found, reverse any list item charges if neccessary.
2829
    if ( $item->{'itemlost'} ) {
2841
    my $itemlost = 0;
2830
        if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) {
2842
    if ( $item->{itemlost} ) {
2831
            _FixAccountForLostAndReturned( $item->{'itemnumber'}, undef, $item->{'barcode'} );
2843
        $itemlost = 1;
2844
        if ( $rule->renew_lost_found ) {
2845
            $itemlost = 0;
2846
            if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) {
2847
                _FixAccountForLostAndReturned( $item->{itemnumber}, undef, $item->{barcode} );
2848
            }
2832
        }
2849
        }
2833
    }
2850
    }
2834
2851
Lines 2836-2842 sub AddRenewal { Link Here
2836
        {
2853
        {
2837
            renewals => $renews,
2854
            renewals => $renews,
2838
            onloan => $datedue->strftime('%Y-%m-%d %H:%M'),
2855
            onloan => $datedue->strftime('%Y-%m-%d %H:%M'),
2839
            itemlost => 0,
2856
            itemlost => $itemlost,
2840
        },
2857
        },
2841
        $biblio->{'biblionumber'},
2858
        $biblio->{'biblionumber'},
2842
        $itemnumber
2859
        $itemnumber
(-)a/admin/smart-rules.pl (-19 / +24 lines)
Lines 162-171 elsif ($op eq 'add') { Link Here
162
162
163
}
163
}
164
elsif ($op eq "set-branch-defaults") {
164
elsif ($op eq "set-branch-defaults") {
165
    my $categorycode  = $input->param('categorycode');
165
    my $categorycode       = $input->param('categorycode');
166
    my $maxissueqty   = $input->param('maxissueqty');
166
    my $maxissueqty        = $input->param('maxissueqty');
167
    my $holdallowed   = $input->param('holdallowed');
167
    my $holdallowed        = $input->param('holdallowed');
168
    my $returnbranch  = $input->param('returnbranch');
168
    my $returnbranch       = $input->param('returnbranch');
169
    my $renew_lost_allowed = $input->param('renew_lost_allowed');
170
    my $renew_lost_found   = $input->param('renew_lost_found');
171
169
    $maxissueqty =~ s/\s//g;
172
    $maxissueqty =~ s/\s//g;
170
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
173
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
171
    $holdallowed =~ s/\s//g;
174
    $holdallowed =~ s/\s//g;
Lines 175-208 elsif ($op eq "set-branch-defaults") { Link Here
175
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
178
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
176
                                        FROM default_circ_rules");
179
                                        FROM default_circ_rules");
177
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
180
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
178
                                        (maxissueqty, holdallowed, returnbranch)
181
                                        (maxissueqty, holdallowed, returnbranch, renew_lost_allowed, renew_lost_found)
179
                                        VALUES (?, ?, ?)");
182
                                        VALUES (?, ?, ?, ?, ?)");
180
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
183
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
181
                                        SET maxissueqty = ?, holdallowed = ?, returnbranch = ?");
184
                                        SET maxissueqty = ?, holdallowed = ?, returnbranch = ?, renew_lost_allowed = ?, renew_lost_found = ?");
182
185
183
        $sth_search->execute();
186
        $sth_search->execute();
184
        my $res = $sth_search->fetchrow_hashref();
187
        my $res = $sth_search->fetchrow_hashref();
185
        if ($res->{total}) {
188
        if ($res->{total}) {
186
            $sth_update->execute($maxissueqty, $holdallowed, $returnbranch);
189
            $sth_update->execute( $maxissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
187
        } else {
190
        } else {
188
            $sth_insert->execute($maxissueqty, $holdallowed, $returnbranch);
191
            $sth_insert->execute( $maxissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
189
        }
192
        }
190
    } else {
193
    } else {
191
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
194
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
192
                                        FROM default_branch_circ_rules
195
                                        FROM default_branch_circ_rules
193
                                        WHERE branchcode = ?");
196
                                        WHERE branchcode = ?");
194
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
197
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
195
                                        (branchcode, maxissueqty, holdallowed, returnbranch)
198
                                        (branchcode, maxissueqty, holdallowed, returnbranch, renew_lost_allowed, renew_lost_found)
196
                                        VALUES (?, ?, ?, ?)");
199
                                        VALUES (?, ?, ?, ?, ?, ?)");
197
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
200
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
198
                                        SET maxissueqty = ?, holdallowed = ?, returnbranch = ?
201
                                        SET maxissueqty = ?, holdallowed = ?, returnbranch = ?, renew_lost_allowed = ?, renew_lost_found = ?
199
                                        WHERE branchcode = ?");
202
                                        WHERE branchcode = ?");
200
        $sth_search->execute($branch);
203
        $sth_search->execute($branch);
201
        my $res = $sth_search->fetchrow_hashref();
204
        my $res = $sth_search->fetchrow_hashref();
202
        if ($res->{total}) {
205
        if ($res->{total}) {
203
            $sth_update->execute($maxissueqty, $holdallowed, $returnbranch, $branch);
206
            $sth_update->execute( $maxissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found, $branch );
204
        } else {
207
        } else {
205
            $sth_insert->execute($branch, $maxissueqty, $holdallowed, $returnbranch);
208
            $sth_insert->execute( $branch, $maxissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
206
        }
209
        }
207
    }
210
    }
208
}
211
}
Lines 512-522 if ($branch eq "*") { Link Here
512
my $defaults = $sth_defaults->fetchrow_hashref;
515
my $defaults = $sth_defaults->fetchrow_hashref;
513
516
514
if ($defaults) {
517
if ($defaults) {
515
    $template->param(default_holdallowed_none => 1) if($defaults->{holdallowed} == 0);
518
    $template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 );
516
    $template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1);
519
    $template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 );
517
    $template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2);
520
    $template->param( default_holdallowed_any  => 1 ) if ( $defaults->{holdallowed} == 2 );
518
    $template->param(default_maxissueqty => $defaults->{maxissueqty});
521
    $template->param( default_maxissueqty      => $defaults->{maxissueqty} );
519
    $template->param(default_returnbranch => $defaults->{returnbranch});
522
    $template->param( default_returnbranch     => $defaults->{returnbranch} );
523
    $template->param( default_renew_lost_allowed => $defaults->{renew_lost_allowed} );
524
    $template->param( default_renew_lost_found   => $defaults->{renew_lost_found} );
520
}
525
}
521
526
522
$template->param(default_rules => ($defaults ? 1 : 0));
527
$template->param(default_rules => ($defaults ? 1 : 0));
(-)a/installer/data/mysql/updatedatabase.pl (+18 lines)
Lines 10183-10188 if( CheckVersion($DBversion) ) { Link Here
10183
    SetVersion($DBversion);
10183
    SetVersion($DBversion);
10184
}
10184
}
10185
10185
10186
$DBversion = "XXX";
10187
if ( CheckVersion($DBversion) ) {
10188
    $dbh->do(q|
10189
        ALTER TABLE default_circ_rules
10190
            ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
10191
            ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0'
10192
    |);
10193
10194
    $dbh->do(q|
10195
        ALTER TABLE default_branch_circ_rules
10196
            ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
10197
            ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0'
10198
    |);
10199
10200
    print "Upgrade to $DBversion done (Bug 9805 - Lost items are un-lost if returned, but not if renewed.)\n";
10201
    SetVersion($DBversion);
10202
}
10203
10186
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10204
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10187
# SEE bug 13068
10205
# SEE bug 13068
10188
# if there is anything in the atomicupdate, read and execute it.
10206
# if there is anything in the atomicupdate, read and execute it.
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc (+1 lines)
Lines 16-21 Link Here
16
    var NOT_RENEWABLE_TOO_SOON = _("No renewal before %s");
16
    var NOT_RENEWABLE_TOO_SOON = _("No renewal before %s");
17
    var NOT_RENEWABLE_AUTO_TOO_SOON = _("Scheduled for automatic renewal");
17
    var NOT_RENEWABLE_AUTO_TOO_SOON = _("Scheduled for automatic renewal");
18
    var NOT_RENEWABLE_AUTO_RENEW = _("Scheduled for automatic renewal");
18
    var NOT_RENEWABLE_AUTO_RENEW = _("Scheduled for automatic renewal");
19
    var ITEM_LOST = _("Item lost");
19
    var RENEWALS_REMAINING = _("%s of %s renewals remaining");
20
    var RENEWALS_REMAINING = _("%s of %s renewals remaining");
20
    var HOLD_IS_SUSPENDED = _("Hold is <strong>suspended</strong>");
21
    var HOLD_IS_SUSPENDED = _("Hold is <strong>suspended</strong>");
21
    var UNTIL = _("until %s");
22
    var UNTIL = _("until %s");
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-1 / +41 lines)
Lines 304-310 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
304
        </form>
304
        </form>
305
    </div>
305
    </div>
306
    <div id="defaults-for-this-library" class="container">
306
    <div id="defaults-for-this-library" class="container">
307
    <h3>Default checkout, hold and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
307
    <h3>Default checkout, hold, renewal and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
308
        <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>
308
        <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>
309
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
309
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
310
            <input type="hidden" name="op" value="set-branch-defaults" />
310
            <input type="hidden" name="op" value="set-branch-defaults" />
Lines 315-320 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
315
                    <th>Total current checkouts allowed</th>
315
                    <th>Total current checkouts allowed</th>
316
                    <th>Hold policy</th>
316
                    <th>Hold policy</th>
317
                    <th>Return policy</th>
317
                    <th>Return policy</th>
318
                    <th>Renew lost?</th>
319
                    <th>Renewal marks lost found</tH>
318
                    <th>&nbsp;</th>
320
                    <th>&nbsp;</th>
319
                    <th>&nbsp;</th>
321
                    <th>&nbsp;</th>
320
                </tr>
322
                </tr>
Lines 371-376 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
371
                            </option>
373
                            </option>
372
                        </select>
374
                        </select>
373
                    </td>
375
                    </td>
376
                    <td>
377
                        <select name="renew_lost_allowed">
378
                            [% IF ( default_renew_lost_allowed == '1' ) %]
379
                            <option value="1" selected="selected">
380
                            [% ELSE %]
381
                            <option value="1">
382
                            [% END %]
383
                                Allow renewal
384
                            </option>
385
386
                            [% IF ( default_renew_lost_allowed == '0' ) %]
387
                            <option value="0" selected="selected">
388
                            [% ELSE %]
389
                            <option value="0">
390
                            [% END %]
391
                                Disallow renewal
392
                            </option>
393
                        </select>
394
                    </td>
395
                    <td>
396
                        <select name="renew_lost_found">
397
                            [% IF ( default_renew_lost_found == '1' ) %]
398
                            <option value="1" selected="selected">
399
                            [% ELSE %]
400
                            <option value="1">
401
                            [% END %]
402
                                marks item found
403
                            </option>
404
405
                            [% IF ( default_renew_lost_found == '0' ) %]
406
                            <option value="0" selected="selected">
407
                            [% ELSE %]
408
                            <option value="0">
409
                            [% END %]
410
                                makes no change
411
                            </option>
412
                        </select>
413
                    </td>
374
                    <td><input type="submit" value="Save" class="submit" /></td>
414
                    <td><input type="submit" value="Save" class="submit" /></td>
375
                    <td>
415
                    <td>
376
                        <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]">Unset</a>
416
                        <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 238-243 Link Here
238
                                                        <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
238
                                                        <span class="renewals">([% ISSUE.renewsleft %] of [% ISSUE.renewsallowed %] renewals remaining)</span>
239
                                                    [% ELSIF ( ISSUE.on_reserve ) %]
239
                                                    [% ELSIF ( ISSUE.on_reserve ) %]
240
                                                        <span class="renewals">(On hold)</span>
240
                                                        <span class="renewals">(On hold)</span>
241
                                                    [% ELSIF ( ISSUE.item_lost ) %]
242
                                                        <span class="renewals">(Item is lost)</span>
241
                                                    [% END %]
243
                                                    [% END %]
242
                                                    </td>
244
                                                    </td>
243
                                                [% END %]
245
                                                [% END %]
244
- 

Return to bug 9805