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

(-)a/C4/Circulation.pm (-4 / +10 lines)
Lines 22-28 package C4::Circulation; Link Here
22
use strict;
22
use strict;
23
#use warnings; FIXME - Bug 2505
23
#use warnings; FIXME - Bug 2505
24
use DateTime;
24
use DateTime;
25
use Koha::DateUtils;
26
use C4::Context;
25
use C4::Context;
27
use C4::Stats;
26
use C4::Stats;
28
use C4::Reserves;
27
use C4::Reserves;
Lines 40-45 use Algorithm::CheckDigits; Link Here
40
39
41
use Data::Dumper;
40
use Data::Dumper;
42
use Koha::Account;
41
use Koha::Account;
42
use Koha::DateUtils;
43
use Koha::AuthorisedValues;
43
use Koha::AuthorisedValues;
44
use Koha::DateUtils;
44
use Koha::DateUtils;
45
use Koha::Calendar;
45
use Koha::Calendar;
Lines 1055-1068 sub CanBookBeIssued { Link Here
1055
        # Decrease loan period for item if rule exist in smart-rules.pl
1055
        # Decrease loan period for item if rule exist in smart-rules.pl
1056
        # Overrides decreaseLoanHighHoldsValue syspref
1056
        # Overrides decreaseLoanHighHoldsValue syspref
1057
        my $branch = _GetCircControlBranch($item,$borrower);
1057
        my $branch = _GetCircControlBranch($item,$borrower);
1058
        my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branch);
1058
        my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule(
1059
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1059
            {   categorycode => $borrower->{categorycode},
1060
                itemtype     => $item->{itype},
1061
                branchcode   => $branch
1062
            }
1063
        );
1064
        my $issuedate = dt_from_string();
1060
        my $calendar = Koha::Calendar->new( branchcode => $branch );
1065
        my $calendar = Koha::Calendar->new( branchcode => $branch );
1066
        $issuingrule->{decreaseloanholds} = 0 if not defined $issuingrule->{decreaseloanholds};
1061
        my $reduced_datedue = $calendar->addDate( $issuedate, $issuingrule->{decreaseloanholds} );
1067
        my $reduced_datedue = $calendar->addDate( $issuedate, $issuingrule->{decreaseloanholds} );
1062
1068
1063
        if ( defined($issuingrule->{decreaseloanholds}) ) {
1069
        if ( defined($issuingrule->{decreaseloanholds}) ) {
1064
            $needsconfirmation{HIGHHOLDS} = {
1070
            $needsconfirmation{HIGHHOLDS} = {
1065
                num_holds  => $num,
1071
                num_holds  => $issuingrule->{outstanding},
1066
                duration   => $issuingrule->{decreaseloanholds},
1072
                duration   => $issuingrule->{decreaseloanholds},
1067
                returndate => output_pref($reduced_datedue),
1073
                returndate => output_pref($reduced_datedue),
1068
            }
1074
            }
(-)a/Koha/Schema/Result/Issuingrule.pm (-2 / +9 lines)
Lines 209-214 __PACKAGE__->table("issuingrules"); Link Here
209
  extra: {list => ["no","yes","bib_only","item_only"]}
209
  extra: {list => ["no","yes","bib_only","item_only"]}
210
  is_nullable: 0
210
  is_nullable: 0
211
211
212
=head2 decreaseloanholds
213
214
  data_type: 'integer'
215
  is_nullable: 1
216
212
=cut
217
=cut
213
218
214
__PACKAGE__->add_columns(
219
__PACKAGE__->add_columns(
Lines 286-291 __PACKAGE__->add_columns( Link Here
286
    extra => { list => ["no", "yes", "bib_only", "item_only"] },
291
    extra => { list => ["no", "yes", "bib_only", "item_only"] },
287
    is_nullable => 0,
292
    is_nullable => 0,
288
  },
293
  },
294
  "decreaseloanholds",
295
  { data_type => "integer", is_nullable => 1 },
289
);
296
);
290
297
291
=head1 PRIMARY KEY
298
=head1 PRIMARY KEY
Lines 305-312 __PACKAGE__->add_columns( Link Here
305
__PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype");
312
__PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype");
306
313
307
314
308
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-11-02 10:33:37
315
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-20 01:08:00
309
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:t9AhZLbm4SE7mx25LAyhGA
316
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2kV+hezVsq+y+4OcEVg2ig
310
317
311
318
312
# You can replace this text with custom code or comments, and it will be preserved on regeneration
319
# You can replace this text with custom code or comments, and it will be preserved on regeneration
(-)a/admin/smart-rules.pl (-1 / +1 lines)
Lines 157-163 elsif ($op eq 'add') { Link Here
157
    my $article_requests = $input->param('article_requests') || 'no';
157
    my $article_requests = $input->param('article_requests') || 'no';
158
    my $overduefinescap = $input->param('overduefinescap') || undef;
158
    my $overduefinescap = $input->param('overduefinescap') || undef;
159
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
159
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
160
    my $decreaseloanholds = $input->param('decreaseloanholds');
160
    my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
161
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
161
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
162
162
163
    my $params = {
163
    my $params = {
(-)a/installer/data/mysql/atomicupdate/bug_14866-add_decreaseloanholds.sql (-1 / +1 lines)
Line 1 Link Here
1
ALTER TABLE issuingrules ADD decreaseloanholds INTEGER;
1
ALTER IGNORE TABLE issuingrules ADD decreaseloanholds INTEGER(11) DEFAULT NULL AFTER `article_requests`;
(-)a/installer/data/mysql/kohastructure.sql (-5 / +6 lines)
Lines 873-883 CREATE TABLE `issuingrules` ( -- circulation and fine rules Link Here
873
  `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
873
  `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
874
  `holds_per_record` SMALLINT(6) NOT NULL DEFAULT 1, -- How many holds a patron can have on a given bib
874
  `holds_per_record` SMALLINT(6) NOT NULL DEFAULT 1, -- How many holds a patron can have on a given bib
875
  `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
875
  `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
876
  overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine
876
  `overduefinescap` decimal(28,6) default NULL, -- the maximum amount of an overdue fine
877
  cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT  '0', -- cap the fine based on item's replacement price
877
  `cap_fine_to_replacement_price` BOOLEAN NOT NULL DEFAULT  '0', -- cap the fine based on item's replacement price
878
  onshelfholds tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf
878
  `onshelfholds` tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf
879
  opacitemholds char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold
879
  `opacitemholds` char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold
880
  article_requests enum('no','yes','bib_only','item_only') NOT NULL DEFAULT 'no', -- allow article requests to be placed,
880
  `article_requests` enum('no','yes','bib_only','item_only') NOT NULL DEFAULT 'no', -- allow article requests to be placed
881
  `decreaseloanholds` int(11) default NULL,
881
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
882
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
882
  KEY `categorycode` (`categorycode`),
883
  KEY `categorycode` (`categorycode`),
883
  KEY `itemtype` (`itemtype`)
884
  KEY `itemtype` (`itemtype`)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-100 / +58 lines)
Lines 197-301 $(document).ready(function() { Link Here
197
            </tr>
197
            </tr>
198
            </thead>
198
            </thead>
199
            <tbody>
199
            <tbody>
200
				[% FOREACH rule IN rules %]
200
            [% FOREACH rule IN rules %]
201
					<tr id="row_[% loop.count %]">
201
                <tr id="row_[% loop.count %]">
202
							<td>[% IF ( rule.default_humancategorycode ) %]
202
                    <td>[% IF ( rule.default_humancategorycode ) %]<em>All</em>[% ELSE %][% rule.humancategorycode %][% END %]</td>
203
									<em>All</em>
203
                    <td>[% IF rule.default_translated_description %]<em>All</em>[% ELSE %][% rule.translated_description %][% END %]</td>
204
								[% ELSE %]
204
                    <td>[% IF ( rule.unlimited_maxissueqty ) %]Unlimited[% ELSE %][% rule.maxissueqty %][% END %]</td>
205
									[% rule.humancategorycode %]
205
                    <td>[% IF rule.unlimited_maxonsiteissueqty %]Unlimited[% ELSE %][% rule.maxonsiteissueqty %][% END %]</td>
206
								[% END %]
206
                    <td>[% rule.issuelength %]</td>
207
							</td>
207
                    <td>[% rule.lengthunit %]</td>
208
                            <td>[% IF rule.default_translated_description %]
208
                    <td>[% IF ( rule.hardduedate ) %]
209
									<em>All</em>
209
                        [% IF ( rule.hardduedatebefore ) %]
210
								[% ELSE %]
210
                            before [% rule.hardduedate %] <input type="hidden" name="hardduedatecomparebackup" value="-1" />
211
									[% rule.translated_description %]
211
                        [% ELSIF ( rule.hardduedateexact ) %]
212
								[% END %]
212
                            on [% rule.hardduedate %] <input type="hidden" name="hardduedatecomparebackup" value="0" />
213
							</td>
213
                        [% ELSIF ( rule.hardduedateafter ) %]
214
							<td>[% IF ( rule.unlimited_maxissueqty ) %]
214
                            after [% rule.hardduedate %] <input type="hidden" name="hardduedatecomparebackup" value="1" />
215
									Unlimited
215
                        [% END %]
216
								[% ELSE %]
216
                    [% ELSE %]
217
									[% rule.maxissueqty %]
217
                        None defined
218
								[% END %]
218
                    [% END %]</td>
219
							</td>
219
                    <td>[% rule.fine %]</td>
220
                            <td>[% IF rule.unlimited_maxonsiteissueqty %]
220
                    <td>[% rule.chargeperiod %]</td>
221
                                    Unlimited
221
                    <td>[% IF rule.chargeperiod_charge_at %]Start of interval[% ELSE %]End of interval[% END %]</td>
222
                                [% ELSE %]
222
                    <td>[% rule.firstremind %]</td>
223
                                    [% rule.maxonsiteissueqty %]
223
                    <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
224
                                [% END %]
224
                    <td>[% IF rule.cap_fine_to_replacement_price %]<input type="checkbox" checked="checked" disabled="disabled" />[% ELSE %]<input type="checkbox" disabled="disabled" />[% END %]</td>
225
                            </td>
225
                    <td>[% rule.finedays %]</td>
226
							<td>[% rule.issuelength %]</td>
226
                    <td>[% rule.maxsuspensiondays %]</td>
227
							<td>
227
                    <td>[% rule.renewalsallowed %]</td>
228
							    [% rule.lengthunit %]
228
                    <td>[% rule.renewalperiod %]</td>
229
							</td>
229
                    <td>[% rule.norenewalbefore %]</td>
230
                            <td>
230
                    <td>[% IF ( rule.auto_renew ) %]Yes[% ELSE %]No[% END %]</td>
231
                              [% IF ( rule.hardduedate ) %]
231
                    <td>[% rule.no_auto_renewal_after %]</td>
232
                                [% IF ( rule.hardduedatebefore ) %]
232
                    <td>[% rule.reservesallowed %]</td>
233
                                  before [% rule.hardduedate %]
233
                    <td>[% rule.holds_per_record %]</td>
234
                                  <input type="hidden" name="hardduedatecomparebackup" value="-1" />
234
                    <td>[% IF rule.onshelfholds == 1 %]
235
                                [% ELSIF ( rule.hardduedateexact ) %]
235
                        Yes
236
                                  on [% rule.hardduedate %]
236
                    [% ELSIF rule.onshelfholds == 2 %]
237
                                  <input type="hidden" name="hardduedatecomparebackup" value="0" />
237
                        If all unavailable
238
                                [% ELSIF ( rule.hardduedateafter ) %]
238
                    [% ELSE %]
239
                                  after [% rule.hardduedate %]
239
                        If any unavailable
240
                                  <input type="hidden" name="hardduedatecomparebackup" value="1" />
240
                    [% END %]</td>
241
                                [% END %]
241
                    <td>[% IF rule.opacitemholds == 'F'%]Force[% ELSIF rule.opacitemholds == 'Y'%]Allow[% ELSE %]Don't allow[% END %]</td>
242
                              [% ELSE %]
242
                    <td>[% IF rule.article_requests == 'no' %]
243
                                None defined
243
                        No
244
                              [% END %]
244
                    [% ELSIF rule.article_requests == 'yes' %]
245
                            </td>
245
                        Yes
246
							<td>[% rule.fine %]</td>
246
                    [% ELSIF rule.article_requests == 'bib_only' %]
247
							<td>[% rule.chargeperiod %]</td>
247
                        Record only
248
                <td>[% IF rule.chargeperiod_charge_at %]Start of interval[% ELSE %]End of interval[% END %]</td>
248
                    [% ELSIF rule.article_requests == 'item_only' %]
249
							<td>[% rule.firstremind %]</td>
249
                        Item only
250
                            <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
250
                    [% END %]</td>
251
                            <td>
251
                    <td>[% rule.decreaseloanholds %]</td>
252
                                [% IF rule.cap_fine_to_replacement_price %]
252
                    <td>[% rule.rentaldiscount %]</td>
253
                                    <input type="checkbox" checked="checked" disabled="disabled" />
253
                    <td class="actions">
254
                                [% ELSE %]
254
                        <a href="#" class="editrule btn btn-mini"><i class="fa fa-pencil"></i> Edit</a>
255
                                    <input type="checkbox" disabled="disabled" />
255
                        <a class="btn btn-mini delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype %]&amp;categorycode=[% rule.categorycode %]&amp;branch=[% rule.current_branch %]"><i class="fa fa-trash"></i> Delete</a>
256
                                [% END %]
256
                    </td>
257
                            </td>
257
                </tr>
258
							<td>[% rule.finedays %]</td>
259
                            <td>[% rule.maxsuspensiondays %]</td>
260
							<td>[% rule.renewalsallowed %]</td>
261
                            <td>[% rule.renewalperiod %]</td>
262
                            <td>[% rule.norenewalbefore %]</td>
263
                            <td>
264
                                [% IF ( rule.auto_renew ) %]
265
                                Yes
266
                                [% ELSE %]
267
                                No
268
                                [% END %]
269
                            </td>
270
                            <td>[% rule.no_auto_renewal_after %]</td>
271
							<td>[% rule.reservesallowed %]</td>
272
                                                        <td>[% rule.holds_per_record %]</td>
273
                                                        <td>
274
                                                            [% IF rule.onshelfholds == 1 %]
275
                                                                Yes
276
                                                            [% ELSIF rule.onshelfholds == 2 %]
277
                                                                If all unavailable
278
                                                            [% ELSE %]
279
                                                                If any unavailable
280
                                                            [% END %]</td>
281
                                                        <td>[% IF rule.opacitemholds == 'F'%]Force[% ELSIF rule.opacitemholds == 'Y'%]Allow[% ELSE %]Don't allow[% END %]</td>
282
                                                        <td>
283
                                                            [% IF rule.article_requests == 'no' %]
284
                                                                No
285
                                                            [% ELSIF rule.article_requests == 'yes' %]
286
                                                                Yes
287
                                                            [% ELSIF rule.article_requests == 'bib_only' %]
288
                                                                Record only
289
                                                            [% ELSIF rule.article_requests == 'item_only' %]
290
                                                                Item only
291
                                                            [% END %]
292
                                                        </td>
293
                                                        <td>[% rule.decreaseloanholds %]</td>
294
                                                        <td>[% rule.rentaldiscount %]</td>
295
                                                        <td class="actions">
296
                                                          <a href="#" class="editrule btn btn-mini"><i class="fa fa-pencil"></i> Edit</a>
297
                                                          <a class="btn btn-mini delete" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=[% rule.itemtype %]&amp;categorycode=[% rule.categorycode %]&amp;branch=[% rule.current_branch %]"><i class="fa fa-trash"></i> Delete</a></td>
298
            </tr>
299
            [% END %]
258
            [% END %]
300
                <tr id="edit_row">
259
                <tr id="edit_row">
301
                    <td>
260
                    <td>
302
- 

Return to bug 14866