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

(-)a/C4/Circulation.pm (-1 / +34 lines)
Lines 2925-2930 sub CanBookBeRenewed { Link Here
2925
        return ( 0, "auto_too_soon" );
2925
        return ( 0, "auto_too_soon" );
2926
    }
2926
    }
2927
2927
2928
    if ( $item->{itemlost} ) {
2929
        my $schema = Koha::Database->new()->schema();
2930
        my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => $branchcode } );
2931
        $rule ||= $schema->resultset('DefaultCircRule')->single();
2932
        return ( 0, "item_lost" ) unless $rule->renew_lost_allowed();
2933
    }
2934
2928
    return ( 1, undef );
2935
    return ( 1, undef );
2929
}
2936
}
2930
2937
Lines 3005-3011 sub AddRenewal { Link Here
3005
3012
3006
    # Update the renewal count on the item, and tell zebra to reindex
3013
    # Update the renewal count on the item, and tell zebra to reindex
3007
    $renews = $biblio->{'renewals'} + 1;
3014
    $renews = $biblio->{'renewals'} + 1;
3008
    ModItem({ renewals => $renews, onloan => $datedue->strftime('%Y-%m-%d %H:%M')}, $biblio->{'biblionumber'}, $itemnumber);
3015
3016
    my $borrower = C4::Members::GetMember( borrowernumber => $borrowernumber );
3017
    my $schema = Koha::Database->new()->schema();
3018
    my $rule = $schema->resultset('DefaultBranchCircRule')->single( { branchcode => _GetCircControlBranch( $item, $borrower ) } );
3019
    $rule ||= $schema->resultset('DefaultCircRule')->single();
3020
3021
    # If item was lost, it has now been found, reverse any list item charges if necessary.
3022
    my $itemlost = 0;
3023
    if ( $item->{itemlost} ) {
3024
        $itemlost = 1;
3025
        if ( $rule->renew_lost_found ) {
3026
            $itemlost = 0;
3027
            if ( C4::Context->preference('RefundLostItemFeeOnReturn') ) {
3028
                _FixAccountForLostAndReturned( $item->{itemnumber}, undef, $item->{barcode} );
3029
            }
3030
        }
3031
    }
3032
3033
    ModItem(
3034
        {
3035
            renewals => $renews,
3036
            onloan => $datedue->strftime('%Y-%m-%d %H:%M'),
3037
            itemlost => $itemlost,
3038
        },
3039
        $biblio->{'biblionumber'},
3040
        $itemnumber
3041
    );
3009
3042
3010
    # Charge a new rental fee, if applicable?
3043
    # Charge a new rental fee, if applicable?
3011
    my ( $charge, $type ) = GetIssuingCharges( $itemnumber, $borrowernumber );
3044
    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/atomicupdate/bug_9805.sql (+7 lines)
Line 0 Link Here
1
ALTER TABLE default_circ_rules
2
    ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
3
    ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0';
4
5
ALTER TABLE default_branch_circ_rules
6
    ADD renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
7
    ADD renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0';
(-)a/installer/data/mysql/kohastructure.sql (+4 lines)
Lines 684-689 CREATE TABLE `default_branch_circ_rules` ( Link Here
684
  `maxonsiteissueqty` int(4) default NULL,
684
  `maxonsiteissueqty` int(4) default NULL,
685
  `holdallowed` tinyint(1) default NULL,
685
  `holdallowed` tinyint(1) default NULL,
686
  `returnbranch` varchar(15) default NULL,
686
  `returnbranch` varchar(15) default NULL,
687
  renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
688
  renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0',
687
  PRIMARY KEY (`branchcode`),
689
  PRIMARY KEY (`branchcode`),
688
  CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
690
  CONSTRAINT `default_branch_circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`)
689
    ON DELETE CASCADE ON UPDATE CASCADE
691
    ON DELETE CASCADE ON UPDATE CASCADE
Lines 713-718 CREATE TABLE `default_circ_rules` ( Link Here
713
    `maxonsiteissueqty` int(4) default NULL,
715
    `maxonsiteissueqty` int(4) default NULL,
714
    `holdallowed` int(1) default NULL,
716
    `holdallowed` int(1) default NULL,
715
    `returnbranch` varchar(15) default NULL,
717
    `returnbranch` varchar(15) default NULL,
718
    renew_lost_allowed BOOLEAN NOT NULL DEFAULT  '1',
719
    renew_lost_found   BOOLEAN NOT NULL DEFAULT  '0',
716
    PRIMARY KEY (`singleton`)
720
    PRIMARY KEY (`singleton`)
717
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
721
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
718
722
(-)a/installer/data/mysql/updatedatabase.pl (+1 lines)
Lines 12022-12027 if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { Link Here
12022
    SetVersion($DBversion);
12022
    SetVersion($DBversion);
12023
}
12023
}
12024
12024
12025
12025
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
12026
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
12026
# SEE bug 13068
12027
# SEE bug 13068
12027
# if there is anything in the atomicupdate, read and execute it.
12028
# 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 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