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

(-)a/C4/Members.pm (-2 / +22 lines)
Lines 323-333 sub GetMemberDetails { Link Here
323
    my $query;
323
    my $query;
324
    my $sth;
324
    my $sth;
325
    if ($borrowernumber) {
325
    if ($borrowernumber) {
326
        $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee,enrolmentperiod FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE  borrowernumber=?");
326
        $sth = $dbh->prepare("
327
            SELECT borrowers.*,
328
                   category_type,
329
                   categories.description,
330
                   categories.BlockExpiredPatronOpacActions,
331
                   reservefee,
332
                   enrolmentperiod
333
            FROM borrowers
334
            LEFT JOIN categories ON borrowers.categorycode=categories.categorycode
335
            WHERE borrowernumber = ?
336
        ");
327
        $sth->execute($borrowernumber);
337
        $sth->execute($borrowernumber);
328
    }
338
    }
329
    elsif ($cardnumber) {
339
    elsif ($cardnumber) {
330
        $sth = $dbh->prepare("SELECT borrowers.*,category_type,categories.description,reservefee,enrolmentperiod FROM borrowers LEFT JOIN categories ON borrowers.categorycode=categories.categorycode WHERE cardnumber=?");
340
        $sth = $dbh->prepare("
341
            SELECT borrowers.*,
342
                   category_type,
343
                   categories.description,
344
                   categories.BlockExpiredPatronOpacActions,
345
                   reservefee,
346
                   enrolmentperiod
347
            FROM borrowers
348
            LEFT JOIN categories ON borrowers.categorycode = categories.categorycode
349
            WHERE cardnumber = ?
350
        ");
331
        $sth->execute($cardnumber);
351
        $sth->execute($cardnumber);
332
    }
352
    }
333
    else {
353
    else {
(-)a/admin/categorie.pl (-9 / +72 lines)
Lines 70-75 my $searchfield=$input->param('description'); Link Here
70
my $script_name="/cgi-bin/koha/admin/categorie.pl";
70
my $script_name="/cgi-bin/koha/admin/categorie.pl";
71
my $categorycode=$input->param('categorycode');
71
my $categorycode=$input->param('categorycode');
72
my $op = $input->param('op') // '';
72
my $op = $input->param('op') // '';
73
my $block_expired = $input->param("block_expired");
73
74
74
my ($template, $loggedinuser, $cookie)
75
my ($template, $loggedinuser, $cookie)
75
    = get_template_and_user({template_name => "admin/categorie.tmpl",
76
    = get_template_and_user({template_name => "admin/categorie.tmpl",
Lines 96-102 if ($op eq 'add_form') { Link Here
96
    my @selected_branches;
97
    my @selected_branches;
97
	if ($categorycode) {
98
	if ($categorycode) {
98
		my $dbh = C4::Context->dbh;
99
		my $dbh = C4::Context->dbh;
99
		my $sth=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?");
100
         my $sth=$dbh->prepare("SELECT * FROM categories WHERE categorycode=?");
100
		$sth->execute($categorycode);
101
		$sth->execute($categorycode);
101
		$data=$sth->fetchrow_hashref;
102
		$data=$sth->fetchrow_hashref;
102
103
Lines 139-144 if ($op eq 'add_form') { Link Here
139
                TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"),
140
                TalkingTechItivaPhone => C4::Context->preference("TalkingTechItivaPhoneNotification"),
140
				"type_".$data->{'category_type'} => 1,
141
				"type_".$data->{'category_type'} => 1,
141
                branches_loop           => \@branches_loop,
142
                branches_loop           => \@branches_loop,
143
                BlockExpiredPatronOpacActions => $data->{'BlockExpiredPatronOpacActions'},
142
				);
144
				);
143
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
145
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
144
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
146
        C4::Form::MessagingPreferences::set_form_values({ categorycode => $categorycode } , $template);
Lines 155-162 if ($op eq 'add_form') { Link Here
155
	}
157
	}
156
	
158
	
157
	if ($is_a_modif) {
159
	if ($is_a_modif) {
158
            my $sth=$dbh->prepare("UPDATE categories SET description=?,enrolmentperiod=?, enrolmentperioddate=?,upperagelimit=?,dateofbirthrequired=?,enrolmentfee=?,reservefee=?,hidelostitems=?,overduenoticerequired=?,category_type=? WHERE categorycode=?");
160
            my $sth=$dbh->prepare("
159
            $sth->execute(map { $input->param($_) } ('description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type','categorycode'));
161
                UPDATE categories
162
                SET description=?,
163
                    enrolmentperiod=?,
164
                    enrolmentperioddate=?,
165
                    upperagelimit=?,
166
                    dateofbirthrequired=?,
167
                    enrolmentfee=?,
168
                    reservefee=?,
169
                    hidelostitems=?,
170
                    overduenoticerequired=?,
171
                    category_type=?,
172
                    BlockExpiredPatronOpacActions=?
173
                WHERE categorycode=?"
174
            );
175
            $sth->execute(
176
                map { $input->param($_) } (
177
                    'description',
178
                    'enrolmentperiod',
179
                    'enrolmentperioddate',
180
                    'upperagelimit',
181
                    'dateofbirthrequired',
182
                    'enrolmentfee',
183
                    'reservefee',
184
                    'hidelostitems',
185
                    'overduenoticerequired',
186
                    'category_type',
187
                    'block_expired',
188
                    'categorycode'
189
                )
190
            );
160
            my @branches = $input->param("branches");
191
            my @branches = $input->param("branches");
161
            if ( @branches ) {
192
            if ( @branches ) {
162
                $sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?");
193
                $sth = $dbh->prepare("DELETE FROM categories_branches WHERE categorycode = ?");
Lines 174-184 if ($op eq 'add_form') { Link Here
174
                }
205
                }
175
            }
206
            }
176
            $sth->finish;
207
            $sth->finish;
177
        } else {
208
    } else {
178
            my $sth=$dbh->prepare("INSERT INTO categories  (categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,reservefee,hidelostitems,overduenoticerequired,category_type) values (?,?,?,?,?,?,?,?,?,?,?)");
209
        my $sth=$dbh->prepare("
179
            $sth->execute(map { $input->param($_) } ('categorycode','description','enrolmentperiod','enrolmentperioddate','upperagelimit','dateofbirthrequired','enrolmentfee','reservefee','hidelostitems','overduenoticerequired','category_type'));
210
            INSERT INTO categories (
180
            $sth->finish;
211
                categorycode,
181
        }
212
                description,
213
                enrolmentperiod,
214
                enrolmentperioddate,
215
                upperagelimit,
216
                dateofbirthrequired,
217
                enrolmentfee,
218
                reservefee,
219
                hidelostitems,
220
                overduenoticerequired,
221
                category_type,
222
                BlockExpiredPatronOpacActions
223
            )
224
            VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
225
        $sth->execute(
226
            map { $input->param($_) } (
227
                'categorycode',
228
                'description',
229
                'enrolmentperiod',
230
                'enrolmentperioddate',
231
                'upperagelimit',
232
                'dateofbirthrequired',
233
                'enrolmentfee',
234
                'reservefee',
235
                'hidelostitems',
236
                'overduenoticerequired',
237
                'category_type',
238
                'block_expired'
239
            )
240
        );
241
        $sth->finish;
242
    }
243
182
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
244
    if (C4::Context->preference('EnhancedMessagingPreferences')) {
183
        C4::Form::MessagingPreferences::handle_form_action($input, 
245
        C4::Form::MessagingPreferences::handle_form_action($input, 
184
                                                           { categorycode => $input->param('categorycode') }, $template);
246
                                                           { categorycode => $input->param('categorycode') }, $template);
Lines 199-205 if ($op eq 'add_form') { Link Here
199
	$sth->finish;
261
	$sth->finish;
200
	$template->param(total => $total->{'total'});
262
	$template->param(total => $total->{'total'});
201
	
263
	
202
	my $sth2=$dbh->prepare("select categorycode,description,enrolmentperiod,enrolmentperioddate,upperagelimit,dateofbirthrequired,enrolmentfee,issuelimit,reservefee,hidelostitems,overduenoticerequired,category_type from categories where categorycode=?");
264
        my $sth2=$dbh->prepare("SELECT * FROM categories WHERE categorycode=?");
203
	$sth2->execute($categorycode);
265
	$sth2->execute($categorycode);
204
	my $data=$sth2->fetchrow_hashref;
266
	my $data=$sth2->fetchrow_hashref;
205
	$sth2->finish;
267
	$sth2->finish;
Lines 221-226 if ($op eq 'add_form') { Link Here
221
                                reservefee              =>  sprintf("%.2f",$data->{'reservefee'} || 0),
283
                                reservefee              =>  sprintf("%.2f",$data->{'reservefee'} || 0),
222
                                hidelostitems           => $data->{'hidelostitems'},
284
                                hidelostitems           => $data->{'hidelostitems'},
223
                                category_type           => $data->{'category_type'},
285
                                category_type           => $data->{'category_type'},
286
                                BlockExpiredPatronOpacActions => $data->{'BlockExpiredPatronOpacActions'},
224
                                );
287
                                );
225
													# END $OP eq DELETE_CONFIRM
288
													# END $OP eq DELETE_CONFIRM
226
################## DELETE_CONFIRMED ##################################
289
################## DELETE_CONFIRMED ##################################
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 466-471 CREATE TABLE `categories` ( -- this table shows information related to Koha patr Link Here
466
  `reservefee` decimal(28,6) default NULL, -- cost to place holds
466
  `reservefee` decimal(28,6) default NULL, -- cost to place holds
467
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
467
  `hidelostitems` tinyint(1) NOT NULL default '0', -- are lost items shown to this category (1 for yes, 0 for no)
468
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
468
  `category_type` varchar(1) NOT NULL default 'A', -- type of Koha patron (Adult, Child, Professional, Organizational, Statistical, Staff)
469
  `BlockExpiredPatronOpacActions` tinyint(1) NOT NULL default '-1', -- wheither or not a patron of this categori can renew books or place holds once their card has expired. 0 means they can, 1 means they cannot, -1 means use syspref BLockExpiredPAtronOpacACtions
469
  PRIMARY KEY  (`categorycode`),
470
  PRIMARY KEY  (`categorycode`),
470
  UNIQUE KEY `categorycode` (`categorycode`)
471
  UNIQUE KEY `categorycode` (`categorycode`)
471
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
472
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 60-65 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
60
('BasketConfirmations','1','always ask for confirmation.|do not ask for confirmation.','When closing or reopening a basket,','Choice'),
60
('BasketConfirmations','1','always ask for confirmation.|do not ask for confirmation.','When closing or reopening a basket,','Choice'),
61
('BiblioAddsAuthorities','0',NULL,'If ON, adding a new biblio will check for an existing authority record and create one on the fly if one doesn\'t exist','YesNo'),
61
('BiblioAddsAuthorities','0',NULL,'If ON, adding a new biblio will check for an existing authority record and create one on the fly if one doesn\'t exist','YesNo'),
62
('BiblioDefaultView','normal','normal|marc|isbd','Choose the default detail view in the catalog; choose between normal, marc or isbd','Choice'),
62
('BiblioDefaultView','normal','normal|marc|isbd','Choose the default detail view in the catalog; choose between normal, marc or isbd','Choice'),
63
('BlockExpiredPatronOpacActions','yes',NULL,'Set whether an expired patron can perform opac actions such as placing a hold or reserve, can be overridden on a per patron-type basis','YesNo'),
63
('BlockReturnOfWithdrawnItems','1','0','If enabled, items that are marked as withdrawn cannot be returned.','YesNo'),
64
('BlockReturnOfWithdrawnItems','1','0','If enabled, items that are marked as withdrawn cannot be returned.','YesNo'),
64
('BorrowerMandatoryField','surname|cardnumber',NULL,'Choose the mandatory fields for a patron\'s account','free'),
65
('BorrowerMandatoryField','surname|cardnumber',NULL,'Choose the mandatory fields for a patron\'s account','free'),
65
('borrowerRelationship','father|mother','','Define valid relationships between a guarantor & a guarantee (separated by | or ,)','free'),
66
('borrowerRelationship','father|mother','','Define valid relationships between a guarantor & a guarantee (separated by | or ,)','free'),
(-)a/installer/data/mysql/updatedatabase.pl (+18 lines)
Lines 7136-7141 if ( CheckVersion($DBversion) ) { Link Here
7136
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostForgiveFine','0',NULL,'If ON, Forgives the fines on an item when it is lost.','YesNo')");
7136
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostForgiveFine','0',NULL,'If ON, Forgives the fines on an item when it is lost.','YesNo')");
7137
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostChargeReplacementFee','1',NULL,'If ON, Charge the replacement price when a patron loses an item.','YesNo')");
7137
    $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('WhenLostChargeReplacementFee','1',NULL,'If ON, Charge the replacement price when a patron loses an item.','YesNo')");
7138
    print "Upgrade to $DBversion done (Bug 7639: system preferences to forgive fines on lost items)\n";
7138
    print "Upgrade to $DBversion done (Bug 7639: system preferences to forgive fines on lost items)\n";
7139
    SetVersion($DBversion);
7140
}
7141
7142
7143
$DBversion = "3.13.00.XXX";
7144
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7145
    $dbh->do("
7146
        INSERT INTO systempreferences (variable,value,explanation,options,type)
7147
        VALUES (
7148
            'BlockExpiredPatronOpacActions',
7149
            'yes',
7150
            'Set whether an expired patron can perform opac actions such as placing a hold or reserve, can be overridden on a per patron-type basis',
7151
            NULL,
7152
            'YesNo'
7153
        )
7154
    ");
7155
    $dbh->do("ALTER TABLE `categories` ADD COLUMN `BlockExpiredPatronOpacActions` TINYINT(1) DEFAULT 0 NOT NULL");
7156
    print "Upgraded to $DBversion done (Bug 6739 - expired patrons not blocked from opac actions)\n";
7139
    SetVersion ($DBversion);
7157
    SetVersion ($DBversion);
7140
}
7158
}
7141
7159
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt (+8 lines)
Lines 189-194 Link Here
189
        <span>Select All if this category type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
189
        <span>Select All if this category type must to be displayed all the time. Otherwise select librairies you want to associate with this value.
190
        </span>
190
        </span>
191
    </li>
191
    </li>
192
    <li><label for="block_expired">Block expired patrons</label>
193
        <select name="block_expired" id="block_expired">
194
            <option value="-1" [% IF ( BlockExpiredPatronOpacActions == -1  ) %] selected="selected" [% END %]> Follow system preference BlockExpiredPatronOpacActions </option>
195
            <option value="1"  [% IF ( BlockExpiredPatronOpacActions == 1   ) %] selected="selected" [% END %]> Block </option>
196
            <option value="0"  [% IF ( BlockExpiredPatronOpacActions == 0   ) %] selected="selected" [% END %]> Don't block </option>
197
        </select>
198
        Should patrons of this category be blocked from opac actions such as renew and reserve when their cards have expired.
199
    </li>
192
    </ol>
200
    </ol>
193
</fieldset>
201
</fieldset>
194
202
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+6 lines)
Lines 522-527 OPAC: Link Here
522
                  no: "Don't allow"
522
                  no: "Don't allow"
523
                  yes: Allow
523
                  yes: Allow
524
            - opac users to share private lists with other patrons. This feature is not active yet but will be released soon
524
            - opac users to share private lists with other patrons. This feature is not active yet but will be released soon
525
        -
526
            - pref: BlockExpiredPatronOpacActions
527
              choices:
528
                yes: "Block"
529
                no: "Don't Block"
530
            - expired patrons from opac actions such as placing a hold or renew, the setting for a patron category takes priority over this
525
531
526
    Privacy:
532
    Privacy:
527
        -
533
        -
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (-1 / +1 lines)
Lines 85-91 Patrons: Link Here
85
           class: integer
85
           class: integer
86
         - characters long.
86
         - characters long.
87
     -
87
     -
88
         - Show a notice that a patron is about to expire
88
         - Show a notice if the patron is about to expire or has expired
89
         - pref: NotifyBorrowerDeparture
89
         - pref: NotifyBorrowerDeparture
90
           class: integer
90
           class: integer
91
         - days beforehand.
91
         - days beforehand.
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tt (+3 lines)
Lines 270-275 Link Here
270
            [% IF ( bad_data ) %]
270
            [% IF ( bad_data ) %]
271
              <div id="bad_data" class="dialog alert">ERROR: Internal error: incomplete hold request.</div>
271
              <div id="bad_data" class="dialog alert">ERROR: Internal error: incomplete hold request.</div>
272
            [% END %]
272
            [% END %]
273
            [% IF ( expired_patron ) %]
274
                <div id="expired_patron" class="dialog alert"><p><strong>Sorry</strong>, you cannot place holds because your library card has expired.<p><p>Please contact your librarian if you wish to renew your card</p></div>
275
            [% END %]
273
          [% ELSE %]
276
          [% ELSE %]
274
            [% IF ( none_available ) %]
277
            [% IF ( none_available ) %]
275
                <div id="none_available" class="dialog alert"><strong>Sorry</strong>, none of these items can be placed on hold.
278
                <div id="none_available" class="dialog alert"><strong>Sorry</strong>, none of these items can be placed on hold.
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt (+10 lines)
Lines 94-99 var MSG_CONFIRM_RESUME_HOLDS = _("Are you sure you want to resume all suspended Link Here
94
        <div class="dialog alert" id="warnexpired">
94
        <div class="dialog alert" id="warnexpired">
95
            <strong>Please note:</strong><span> Your card has expired. Please contact the library for more information.</span>
95
            <strong>Please note:</strong><span> Your card has expired. Please contact the library for more information.</span>
96
        </div>
96
        </div>
97
        [% ELSIF ( BORROWER_INF.warnexpired ) %]
98
        <div class="dialog alert">
99
                <string>Please note:</string><span> You card has expired as of [% BORROWER_INF.warnexpired %]. Please contact the library if you wish to renew your subscription.</span>
100
        </div>
101
        [% END %]
102
103
        [% IF ( RENEW_ERROR ) %]
104
        <div class="dialog alert">
105
                <string>Please note:</string><span> You're renew failed with the following error: [% RENEW_ERROR %]</span>
106
        </div>
97
        [% END %]
107
        [% END %]
98
108
99
        [% IF ( patron_flagged ) %]
109
        [% IF ( patron_flagged ) %]
(-)a/opac/opac-renew.pl (-27 / +35 lines)
Lines 29-34 use C4::Circulation; Link Here
29
use C4::Auth;
29
use C4::Auth;
30
use C4::Items;
30
use C4::Items;
31
use C4::Members;
31
use C4::Members;
32
use Date::Calc qw( Today Date_to_Days );
32
my $query = new CGI;
33
my $query = new CGI;
33
34
34
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
35
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Lines 46-78 my @items = $query->param('item'); Link Here
46
my $opacrenew = C4::Context->preference("OpacRenewalAllowed");
47
my $opacrenew = C4::Context->preference("OpacRenewalAllowed");
47
48
48
my $errorstring='';
49
my $errorstring='';
49
for my $itemnumber ( @items ) {
50
my $member_details = GetMemberDetails($borrowernumber);
50
    my ($status,$error) = CanBookBeRenewed( $borrowernumber, $itemnumber );
51
# BlockExpiredPatronOpacActions syspref 0 is false, 1 is true. BlockExpiredPatronOpacActions for categories (from GetMemberDetails) -1 means use syspref, 0 is false, 1 is true (where false means dont block, true means block)
51
    if ( $status == 1 && $opacrenew == 1 ) {
52
if( ($member_details->{'BlockExpiredPatronOpacActions'} == -1 ? C4::Conext->preference('BlockExpiredPatronOpacActions') : $member_details->{'BlockExpiredPatronOpacActions'})
52
	my $renewalbranch = C4::Context->preference('OpacRenewalBranch');
53
    && Date_to_Days( Today() ) > Date_to_Days( split /-/, $member_details->{'dateexpiry'} ) ){
53
	my $branchcode;
54
   $errorstring='unable to renew as your card has expired';
54
	if ($renewalbranch eq 'itemhomebranch'){
55
} else {
55
	    my $item = GetItem($itemnumber);
56
    for my $itemnumber ( @items ) {
56
	    $branchcode=$item->{'homebranch'};
57
        my ($status,$error) = CanBookBeRenewed( $borrowernumber, $itemnumber );
57
	}
58
        if ( $status == 1 && $opacrenew == 1 ) {
58
	elsif ($renewalbranch eq 'patronhomebranch'){
59
            my $renewalbranch = C4::Context->preference('OpacRenewalBranch');
59
	    my $borrower = GetMemberDetails($borrowernumber);
60
            my $branchcode;
60
	    $branchcode = $borrower->{'branchcode'};
61
            if ($renewalbranch eq 'itemhomebranch'){
61
	}
62
                my $item = GetItem($itemnumber);
62
	elsif ($renewalbranch eq 'checkoutbranch'){
63
                $branchcode=$item->{'homebranch'};
63
	    my $issue = GetOpenIssue($itemnumber);
64
            }
64
	    $branchcode = $issue->{'branchcode'};
65
            elsif ($renewalbranch eq 'patronhomebranch'){
65
	}
66
                my $borrower = GetMemberDetails($borrowernumber);
66
	elsif ($renewalbranch eq 'NULL'){
67
                $branchcode = $borrower->{'branchcode'};
67
	    $branchcode='';
68
            }
68
	}
69
            elsif ($renewalbranch eq 'checkoutbranch'){
69
	else {
70
                my $issue = GetOpenIssue($itemnumber);
70
	    $branchcode='OPACRenew'
71
                $branchcode = $issue->{'branchcode'};
71
	}
72
            }
72
        AddRenewal( $borrowernumber, $itemnumber, $branchcode);
73
            elsif ($renewalbranch eq 'NULL'){
73
    }
74
                $branchcode='';
74
    else {
75
            }
75
	$errorstring .= $error ."|";
76
            else {
77
                $branchcode='OPACRenew'
78
            }
79
            AddRenewal( $borrowernumber, $itemnumber, $branchcode);
80
        }
81
        else {
82
            $errorstring .= $error ."|";
83
        }
76
    }
84
    }
77
}
85
}
78
86
(-)a/opac/opac-reserve.pl (+11 lines)
Lines 35-40 use C4::Branch; # GetBranches Link Here
35
use C4::Overdues;
35
use C4::Overdues;
36
use C4::Debug;
36
use C4::Debug;
37
use Koha::DateUtils;
37
use Koha::DateUtils;
38
use Date::Calc qw/Today Date_to_Days/;
38
# use Data::Dumper;
39
# use Data::Dumper;
39
40
40
my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves");
41
my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves");
Lines 65-70 sub get_out { Link Here
65
# get borrower information ....
66
# get borrower information ....
66
my ( $borr ) = GetMemberDetails( $borrowernumber );
67
my ( $borr ) = GetMemberDetails( $borrowernumber );
67
68
69
# check if this user can place a reserve, -1 means use sys pref, 0 means dont block, 1 means block
70
if( $borr->{'BlockExpiredPatronOpacActions'} == -1 ? C4::Context->preference("BlockExpiredPatronOpacActions") : $borr->{'BlockExpiredPatronOpacActions'} ) {
71
72
    if( Date_to_Days( Today() ) > Date_to_Days( split /-/, $borr->{'dateexpiry'} ) ){
73
        # cannot reserve, their card has expired and the rules set mean this is not allowed
74
        $template->param( message=>1, expired_patron=>1 );
75
        get_out($query, $cookie, $template->output);
76
    }
77
}
78
68
# Pass through any reserve charge
79
# Pass through any reserve charge
69
if ($borr->{reservefee} > 0){
80
if ($borr->{reservefee} > 0){
70
    $template->param( RESERVE_CHARGE => sprintf("%.2f",$borr->{reservefee}));
81
    $template->param( RESERVE_CHARGE => sprintf("%.2f",$borr->{reservefee}));
(-)a/opac/opac-user.pl (-18 / +15 lines)
Lines 64-73 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
64
    }
64
    }
65
);
65
);
66
66
67
my $show_priority;
67
my $OPACDisplayRequestPriority = (C4::Context->preference("OPACDisplayRequestPriority")) ? 1 : 0;
68
for ( C4::Context->preference("OPACShowHoldQueueDetails") ) {
69
    m/priority/ and $show_priority = 1;
70
}
71
my $patronupdate = $query->param('patronupdate');
68
my $patronupdate = $query->param('patronupdate');
72
my $canrenew = 1;
69
my $canrenew = 1;
73
70
Lines 109-115 if ( C4::Context->preference( 'OpacRenewalAllowed' ) && $borr->{amountoutstandi Link Here
109
    $canrenew = 0;
106
    $canrenew = 0;
110
    $template->param(
107
    $template->param(
111
        renewal_blocked_fines => sprintf( '%.02f', $no_renewal_amt ),
108
        renewal_blocked_fines => sprintf( '%.02f', $no_renewal_amt ),
112
        renewal_blocked_fines_amountoutstanding => sprintf( '%.02f', $borr->{amountoutstanding} ),
113
    );
109
    );
114
}
110
}
115
111
Lines 124-142 my @bordat; Link Here
124
$bordat[0] = $borr;
120
$bordat[0] = $borr;
125
121
126
# Warningdate is the date that the warning starts appearing
122
# Warningdate is the date that the warning starts appearing
127
if ( $borr->{dateexpiry} && Date_to_Days( $today_year, $today_month, $today_day ) > Date_to_Days( $warning_year, $warning_month, $warning_day ) ) {
123
if ( $borr->{'dateexpiry'} && C4::Context->preference('NotifyBorrowerDeparture') ) {
128
    $borr->{'warnexpired'} = 1;
124
    my $days_to_expiry = Date_to_Days( $warning_year, $warning_month, $warning_day ) - Date_to_Days( $today_year, $today_month, $today_day );
129
}
125
    if ( $days_to_expiry < 0 ) {
130
elsif ( $borr->{dateexpiry} && C4::Context->preference('NotifyBorrowerDeparture') &&
126
        #borrower card has expired, warn the borrower
131
        Date_to_Days(Add_Delta_Days($warning_year, $warning_month, $warning_day,- C4::Context->preference('NotifyBorrowerDeparture'))) <
127
        $borr->{'warnexpired'} = $borr->{'dateexpiry'};
132
        Date_to_Days( $today_year, $today_month, $today_day ) ) {
128
    } elsif ( $days_to_expiry < C4::Context->preference('NotifyBorrowerDeparture') ) {
133
        # borrower card soon to expire, warn the borrower
129
        # borrower card soon to expire, warn the borrower
134
        $borr->{'warndeparture'} = $borr->{dateexpiry};
130
        $borr->{'warndeparture'} = $borr->{dateexpiry};
135
        if (C4::Context->preference('ReturnBeforeExpiry')){
131
        if (C4::Context->preference('ReturnBeforeExpiry')){
136
            $borr->{'returnbeforeexpiry'} = 1;
132
            $borr->{'returnbeforeexpiry'} = 1;
137
        }
133
        }
134
    }
138
}
135
}
139
136
137
# pass on any renew errors to the template for displaying
138
$template->param( RENEW_ERROR => $query->param('renew_error') ) if $query->param('renew_error');
140
139
141
$template->param(   BORROWER_INFO     => \@bordat,
140
$template->param(   BORROWER_INFO     => \@bordat,
142
                    borrowernumber    => $borrowernumber,
141
                    borrowernumber    => $borrowernumber,
Lines 157-163 my $issues = GetPendingIssues($borrowernumber); Link Here
157
if ($issues){
156
if ($issues){
158
    foreach my $issue ( sort { $b->{date_due}->datetime() cmp $a->{date_due}->datetime() } @{$issues} ) {
157
    foreach my $issue ( sort { $b->{date_due}->datetime() cmp $a->{date_due}->datetime() } @{$issues} ) {
159
        # check for reserves
158
        # check for reserves
160
        my $restype = GetReserveStatus( $issue->{'itemnumber'} );
159
        my ( $restype, $res, undef ) = CheckReserves( $issue->{'itemnumber'} );
161
        if ( $restype ) {
160
        if ( $restype ) {
162
            $issue->{'reserved'} = 1;
161
            $issue->{'reserved'} = 1;
163
        }
162
        }
Lines 169-176 if ($issues){ Link Here
169
                $charges += $ac->{'amountoutstanding'}
168
                $charges += $ac->{'amountoutstanding'}
170
                  if $ac->{'accounttype'} eq 'F';
169
                  if $ac->{'accounttype'} eq 'F';
171
                $charges += $ac->{'amountoutstanding'}
170
                $charges += $ac->{'amountoutstanding'}
172
                  if $ac->{'accounttype'} eq 'FU';
173
                $charges += $ac->{'amountoutstanding'}
174
                  if $ac->{'accounttype'} eq 'L';
171
                  if $ac->{'accounttype'} eq 'L';
175
            }
172
            }
176
        }
173
        }
Lines 260-267 foreach my $res (@reserves) { Link Here
260
    $res->{'branch'} = $branches->{ $res->{'branchcode'} }->{'branchname'};
257
    $res->{'branch'} = $branches->{ $res->{'branchcode'} }->{'branchname'};
261
    my $biblioData = GetBiblioData($res->{'biblionumber'});
258
    my $biblioData = GetBiblioData($res->{'biblionumber'});
262
    $res->{'reserves_title'} = $biblioData->{'title'};
259
    $res->{'reserves_title'} = $biblioData->{'title'};
263
    if ($show_priority) {
260
    if ($OPACDisplayRequestPriority) {
264
        $res->{'priority'} ||= '';
261
        $res->{'priority'} = '' if $res->{'priority'} eq '0';
265
    }
262
    }
266
    $res->{'suspend_until'} = C4::Dates->new( $res->{'suspend_until'}, "iso")->output("syspref") if ( $res->{'suspend_until'} );
263
    $res->{'suspend_until'} = C4::Dates->new( $res->{'suspend_until'}, "iso")->output("syspref") if ( $res->{'suspend_until'} );
267
}
264
}
Lines 271-277 foreach my $res (@reserves) { Link Here
271
268
272
$template->param( RESERVES       => \@reserves );
269
$template->param( RESERVES       => \@reserves );
273
$template->param( reserves_count => $#reserves+1 );
270
$template->param( reserves_count => $#reserves+1 );
274
$template->param( showpriority=>$show_priority );
271
$template->param( showpriority=>1 ) if $OPACDisplayRequestPriority;
275
272
276
my @waiting;
273
my @waiting;
277
my $wcount = 0;
274
my $wcount = 0;
Lines 358-363 $template->param( Link Here
358
    patronupdate => $patronupdate,
355
    patronupdate => $patronupdate,
359
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
356
    OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"),
360
    userview => 1,
357
    userview => 1,
358
    dateformat => C4::Context->preference("dateformat"),
361
);
359
);
362
360
363
$template->param(
361
$template->param(
364
- 

Return to bug 6739