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

(-)a/C4/Circulation.pm (-4 / +21 lines)
Lines 2743-2748 sub CanBookBeRenewed { Link Here
2743
    }
2743
    }
2744
2744
2745
    return ( 0, "auto_renew" ) if $itemissue->{auto_renew};
2745
    return ( 0, "auto_renew" ) if $itemissue->{auto_renew};
2746
2747
    if ( $item->{itemlost} ) {
2748
        my $schema = Koha::Database->new()->schema();
2749
        my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => $branchcode } );
2750
        $rule ||= $schema->resultset('DefaultCircRule')->single();
2751
        return ( 0, "item_lost" ) unless $rule->{renew_lost_allowed};
2752
    }
2753
2746
    return ( 1, undef );
2754
    return ( 1, undef );
2747
}
2755
}
2748
2756
Lines 2824-2833 sub AddRenewal { Link Here
2824
    # Update the renewal count on the item, and tell zebra to reindex
2832
    # Update the renewal count on the item, and tell zebra to reindex
2825
    $renews = $biblio->{'renewals'} + 1;
2833
    $renews = $biblio->{'renewals'} + 1;
2826
2834
2835
    my $schema = Koha::Database->new()->schema();
2836
    my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => _GetCircControlBranch( $item, $borrower ) } );
2837
    $rule ||= $schema->resultset('DefaultCircRule')->single();
2838
2827
    # If item was lost, it has now been found, reverse any list item charges if neccessary.
2839
    # If item was lost, it has now been found, reverse any list item charges if neccessary.
2828
    if ( $item->{'itemlost'} ) {
2840
    my $itemlost = 0;
2829
        if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) {
2841
    if ( $item->{itemlost} ) {
2830
            _FixAccountForLostAndReturned( $item->{'itemnumber'}, undef, $item->{'barcode'} );
2842
        $itemlost = 1;
2843
        if ( $rule->renew_lost_found ) {
2844
            $itemlost = 0;
2845
            if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) {
2846
                _FixAccountForLostAndReturned( $item->{itemnumber}, undef, $item->{barcode} );
2847
            }
2831
        }
2848
        }
2832
    }
2849
    }
2833
2850
Lines 2835-2841 sub AddRenewal { Link Here
2835
        {
2852
        {
2836
            renewals => $renews,
2853
            renewals => $renews,
2837
            onloan => $datedue->strftime('%Y-%m-%d %H:%M'),
2854
            onloan => $datedue->strftime('%Y-%m-%d %H:%M'),
2838
            itemlost => 0,
2855
            itemlost => $itemlost,
2839
        },
2856
        },
2840
        $biblio->{'biblionumber'},
2857
        $biblio->{'biblionumber'},
2841
        $itemnumber
2858
        $itemnumber
(-)a/admin/smart-rules.pl (-19 / +24 lines)
Lines 140-149 elsif ($op eq 'add') { Link Here
140
    }
140
    }
141
} 
141
} 
142
elsif ($op eq "set-branch-defaults") {
142
elsif ($op eq "set-branch-defaults") {
143
    my $categorycode  = $input->param('categorycode');
143
    my $categorycode       = $input->param('categorycode');
144
    my $maxissueqty   = $input->param('maxissueqty');
144
    my $maxissueqty        = $input->param('maxissueqty');
145
    my $holdallowed   = $input->param('holdallowed');
145
    my $holdallowed        = $input->param('holdallowed');
146
    my $returnbranch  = $input->param('returnbranch');
146
    my $returnbranch       = $input->param('returnbranch');
147
    my $renew_lost_allowed = $input->param('renew_lost_allowed');
148
    my $renew_lost_found   = $input->param('renew_lost_found');
149
147
    $maxissueqty =~ s/\s//g;
150
    $maxissueqty =~ s/\s//g;
148
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
151
    $maxissueqty = undef if $maxissueqty !~ /^\d+/;
149
    $holdallowed =~ s/\s//g;
152
    $holdallowed =~ s/\s//g;
Lines 153-186 elsif ($op eq "set-branch-defaults") { Link Here
153
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
156
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
154
                                        FROM default_circ_rules");
157
                                        FROM default_circ_rules");
155
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
158
        my $sth_insert = $dbh->prepare("INSERT INTO default_circ_rules
156
                                        (maxissueqty, holdallowed, returnbranch)
159
                                        (maxissueqty, holdallowed, returnbranch, renew_lost_allowed, renew_lost_found)
157
                                        VALUES (?, ?, ?)");
160
                                        VALUES (?, ?, ?, ?, ?)");
158
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
161
        my $sth_update = $dbh->prepare("UPDATE default_circ_rules
159
                                        SET maxissueqty = ?, holdallowed = ?, returnbranch = ?");
162
                                        SET maxissueqty = ?, holdallowed = ?, returnbranch = ?, renew_lost_allowed = ?, renew_lost_found = ?");
160
163
161
        $sth_search->execute();
164
        $sth_search->execute();
162
        my $res = $sth_search->fetchrow_hashref();
165
        my $res = $sth_search->fetchrow_hashref();
163
        if ($res->{total}) {
166
        if ($res->{total}) {
164
            $sth_update->execute($maxissueqty, $holdallowed, $returnbranch);
167
            $sth_update->execute( $maxissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
165
        } else {
168
        } else {
166
            $sth_insert->execute($maxissueqty, $holdallowed, $returnbranch);
169
            $sth_insert->execute( $maxissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
167
        }
170
        }
168
    } else {
171
    } else {
169
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
172
        my $sth_search = $dbh->prepare("SELECT count(*) AS total
170
                                        FROM default_branch_circ_rules
173
                                        FROM default_branch_circ_rules
171
                                        WHERE branchcode = ?");
174
                                        WHERE branchcode = ?");
172
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
175
        my $sth_insert = $dbh->prepare("INSERT INTO default_branch_circ_rules
173
                                        (branchcode, maxissueqty, holdallowed, returnbranch)
176
                                        (branchcode, maxissueqty, holdallowed, returnbranch, renew_lost_allowed, renew_lost_found)
174
                                        VALUES (?, ?, ?, ?)");
177
                                        VALUES (?, ?, ?, ?, ?, ?)");
175
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
178
        my $sth_update = $dbh->prepare("UPDATE default_branch_circ_rules
176
                                        SET maxissueqty = ?, holdallowed = ?, returnbranch = ?
179
                                        SET maxissueqty = ?, holdallowed = ?, returnbranch = ?, renew_lost_allowed = ?, renew_lost_found = ?
177
                                        WHERE branchcode = ?");
180
                                        WHERE branchcode = ?");
178
        $sth_search->execute($branch);
181
        $sth_search->execute($branch);
179
        my $res = $sth_search->fetchrow_hashref();
182
        my $res = $sth_search->fetchrow_hashref();
180
        if ($res->{total}) {
183
        if ($res->{total}) {
181
            $sth_update->execute($maxissueqty, $holdallowed, $returnbranch, $branch);
184
            $sth_update->execute( $maxissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found, $branch );
182
        } else {
185
        } else {
183
            $sth_insert->execute($branch, $maxissueqty, $holdallowed, $returnbranch);
186
            $sth_insert->execute( $branch, $maxissueqty, $holdallowed, $returnbranch, $renew_lost_allowed, $renew_lost_found );
184
        }
187
        }
185
    }
188
    }
186
}
189
}
Lines 490-500 if ($branch eq "*") { Link Here
490
my $defaults = $sth_defaults->fetchrow_hashref;
493
my $defaults = $sth_defaults->fetchrow_hashref;
491
494
492
if ($defaults) {
495
if ($defaults) {
493
    $template->param(default_holdallowed_none => 1) if($defaults->{holdallowed} == 0);
496
    $template->param( default_holdallowed_none => 1 ) if ( $defaults->{holdallowed} == 0 );
494
    $template->param(default_holdallowed_same => 1) if($defaults->{holdallowed} == 1);
497
    $template->param( default_holdallowed_same => 1 ) if ( $defaults->{holdallowed} == 1 );
495
    $template->param(default_holdallowed_any => 1) if($defaults->{holdallowed} == 2);
498
    $template->param( default_holdallowed_any  => 1 ) if ( $defaults->{holdallowed} == 2 );
496
    $template->param(default_maxissueqty => $defaults->{maxissueqty});
499
    $template->param( default_maxissueqty      => $defaults->{maxissueqty} );
497
    $template->param(default_returnbranch => $defaults->{returnbranch});
500
    $template->param( default_returnbranch     => $defaults->{returnbranch} );
501
    $template->param( default_renew_lost_allowed => $defaults->{renew_lost_allowed} );
502
    $template->param( default_renew_lost_found   => $defaults->{renew_lost_found} );
498
}
503
}
499
504
500
$template->param(default_rules => ($defaults ? 1 : 0));
505
$template->param(default_rules => ($defaults ? 1 : 0));
(-)a/installer/data/mysql/updatedatabase.pl (+18 lines)
Lines 9867-9872 if(CheckVersion($DBversion)) { Link Here
9867
    SetVersion($DBversion);
9867
    SetVersion($DBversion);
9868
}
9868
}
9869
9869
9870
$DBversion = "XXX";
9871
if ( CheckVersion($DBversion) ) {
9872
    $dbh->do(q|
9873
        ALTER TABLE default_circ_rules
9874
            ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
9875
            ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0'
9876
    |);
9877
9878
    $dbh->do(q|
9879
        ALTER TABLE default_branch_circ_rules
9880
            ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
9881
            ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0'
9882
    |);
9883
9884
    print "Upgrade to $DBversion done (Bug 9805 - Lost items are un-lost if returned, but not if renewed.)\n";
9885
    SetVersion($DBversion);
9886
}
9887
9870
=head1 FUNCTIONS
9888
=head1 FUNCTIONS
9871
9889
9872
=head2 TableExists($table)
9890
=head2 TableExists($table)
(-)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 287-293 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
287
        </form>
287
        </form>
288
    </div>
288
    </div>
289
    <div id="defaults-for-this-library" class="container">
289
    <div id="defaults-for-this-library" class="container">
290
    <h3>Default checkout, hold and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
290
    <h3>Default checkout, hold, renewal and return policy[% IF ( humanbranch ) %] for [% humanbranch %][% END %]</h3>
291
        <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>
291
        <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>
292
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
292
        <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
293
            <input type="hidden" name="op" value="set-branch-defaults" />
293
            <input type="hidden" name="op" value="set-branch-defaults" />
Lines 298-303 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
298
                    <th>Total current checkouts allowed</th>
298
                    <th>Total current checkouts allowed</th>
299
                    <th>Hold policy</th>
299
                    <th>Hold policy</th>
300
                    <th>Return policy</th>
300
                    <th>Return policy</th>
301
                    <th>Renew lost?</th>
302
                    <th>Renewal marks lost found</tH>
301
                    <th>&nbsp;</th>
303
                    <th>&nbsp;</th>
302
                    <th>&nbsp;</th>
304
                    <th>&nbsp;</th>
303
                </tr>
305
                </tr>
Lines 354-359 for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidde Link Here
354
                            </option>
356
                            </option>
355
                        </select>
357
                        </select>
356
                    </td>
358
                    </td>
359
                    <td>
360
                        <select name="renew_lost_allowed">
361
                            [% IF ( default_renew_lost_allowed == '1' ) %]
362
                            <option value="1" selected="selected">
363
                            [% ELSE %]
364
                            <option value="1">
365
                            [% END %]
366
                                Allow renewal
367
                            </option>
368
369
                            [% IF ( default_renew_lost_allowed == '0' ) %]
370
                            <option value="0" selected="selected">
371
                            [% ELSE %]
372
                            <option value="0">
373
                            [% END %]
374
                                Disallow renewal
375
                            </option>
376
                        </select>
377
                    </td>
378
                    <td>
379
                        <select name="renew_lost_found">
380
                            [% IF ( default_renew_lost_found == '1' ) %]
381
                            <option value="1" selected="selected">
382
                            [% ELSE %]
383
                            <option value="1">
384
                            [% END %]
385
                                marks item found
386
                            </option>
387
388
                            [% IF ( default_renew_lost_found == '0' ) %]
389
                            <option value="0" selected="selected">
390
                            [% ELSE %]
391
                            <option value="0">
392
                            [% END %]
393
                                makes no change
394
                            </option>
395
                        </select>
396
                    </td>
357
                    <td><input type="submit" value="Save" class="submit" /></td>
397
                    <td><input type="submit" value="Save" class="submit" /></td>
358
                    <td>
398
                    <td>
359
                        <a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete-branch-cat&amp;categorycode=*&amp;branch=[% current_branch %]">Unset</a>
399
                        <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