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

(-)a/C4/Circulation.pm (-4 / +9 lines)
Lines 23-29 use strict; Link Here
23
#use warnings; FIXME - Bug 2505
23
#use warnings; FIXME - Bug 2505
24
use DateTime;
24
use DateTime;
25
use POSIX qw( floor );
25
use POSIX qw( floor );
26
use Koha::DateUtils;
27
use C4::Context;
26
use C4::Context;
28
use C4::Stats;
27
use C4::Stats;
29
use C4::Reserves;
28
use C4::Reserves;
Lines 1049-1062 sub CanBookBeIssued { Link Here
1049
        # Decrease loan period for item if rule exist in smart-rules.pl
1048
        # Decrease loan period for item if rule exist in smart-rules.pl
1050
        # Overrides decreaseLoanHighHoldsValue syspref
1049
        # Overrides decreaseLoanHighHoldsValue syspref
1051
        my $branch = _GetCircControlBranch($item,$borrower);
1050
        my $branch = _GetCircControlBranch($item,$borrower);
1052
        my $issuingrule = GetIssuingRule($borrower->{categorycode}, $item->{itype}, $branch);
1051
        my $issuingrule = Koha::IssuingRules->get_effective_issuing_rule(
1053
        my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
1052
            {   categorycode => $borrower->{categorycode},
1053
                itemtype     => $item->{itype},
1054
                branchcode   => $branch
1055
            }
1056
        );
1057
        my $issuedate = dt_from_string();
1054
        my $calendar = Koha::Calendar->new( branchcode => $branch );
1058
        my $calendar = Koha::Calendar->new( branchcode => $branch );
1059
        $issuingrule->{decreaseloanholds} = 0 if not defined $issuingrule->{decreaseloanholds};
1055
        my $reduced_datedue = $calendar->addDate( $issuedate, $issuingrule->{decreaseloanholds} );
1060
        my $reduced_datedue = $calendar->addDate( $issuedate, $issuingrule->{decreaseloanholds} );
1056
1061
1057
        if ( defined($issuingrule->{decreaseloanholds}) ) {
1062
        if ( defined($issuingrule->{decreaseloanholds}) ) {
1058
            $needsconfirmation{HIGHHOLDS} = {
1063
            $needsconfirmation{HIGHHOLDS} = {
1059
                num_holds  => $num,
1064
                num_holds  => $issuingrule->{outstanding},
1060
                duration   => $issuingrule->{decreaseloanholds},
1065
                duration   => $issuingrule->{decreaseloanholds},
1061
                returndate => output_pref($reduced_datedue),
1066
                returndate => output_pref($reduced_datedue),
1062
            }
1067
            }
(-)a/Koha/Schema/Result/Issuingrule.pm (-2 / +9 lines)
Lines 221-226 __PACKAGE__->table("issuingrules"); Link Here
221
  extra: {list => ["no","yes","bib_only","item_only"]}
221
  extra: {list => ["no","yes","bib_only","item_only"]}
222
  is_nullable: 0
222
  is_nullable: 0
223
223
224
=head2 decreaseloanholds
225
226
  data_type: 'integer'
227
  is_nullable: 1
228
224
=cut
229
=cut
225
230
226
__PACKAGE__->add_columns(
231
__PACKAGE__->add_columns(
Lines 302-307 __PACKAGE__->add_columns( Link Here
302
    extra => { list => ["no", "yes", "bib_only", "item_only"] },
307
    extra => { list => ["no", "yes", "bib_only", "item_only"] },
303
    is_nullable => 0,
308
    is_nullable => 0,
304
  },
309
  },
310
  "decreaseloanholds",
311
  { data_type => "integer", is_nullable => 1 },
305
);
312
);
306
313
307
=head1 PRIMARY KEY
314
=head1 PRIMARY KEY
Lines 321-328 __PACKAGE__->add_columns( Link Here
321
__PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype");
328
__PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype");
322
329
323
330
324
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-12-13 12:44:30
331
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-06-07 03:02:31
325
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:VBD8atc/D/6rN0D+aTaSOQ
332
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wRqrq6dJHXE+ocOQKhnKnA
326
333
327
334
328
# You can replace this text with custom code or comments, and it will be preserved on regeneration
335
# 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 160-166 elsif ($op eq 'add') { Link Here
160
    my $article_requests = $input->param('article_requests') || 'no';
160
    my $article_requests = $input->param('article_requests') || 'no';
161
    my $overduefinescap = $input->param('overduefinescap') || undef;
161
    my $overduefinescap = $input->param('overduefinescap') || undef;
162
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
162
    my $cap_fine_to_replacement_price = $input->param('cap_fine_to_replacement_price') eq 'on';
163
    my $decreaseloanholds = $input->param('decreaseloanholds');
163
    my $decreaseloanholds = $input->param('decreaseloanholds') || undef;
164
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
164
    $debug and warn "Adding $br, $bor, $itemtype, $fine, $maxissueqty, $maxonsiteissueqty, $cap_fine_to_replacement_price";
165
165
166
    my $params = {
166
    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 858-868 CREATE TABLE `issuingrules` ( -- circulation and fine rules Link Here
858
  `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
858
  `reservesallowed` smallint(6) NOT NULL default "0", -- how many holds are allowed
859
  `holds_per_record` SMALLINT(6) NOT NULL DEFAULT 1, -- How many holds a patron can have on a given bib
859
  `holds_per_record` SMALLINT(6) NOT NULL DEFAULT 1, -- How many holds a patron can have on a given bib
860
  `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
860
  `branchcode` varchar(10) NOT NULL default '', -- the branch this rule is for (branches.branchcode)
861
  overduefinescap decimal(28,6) default NULL, -- the maximum amount of an overdue fine
861
  `overduefinescap` decimal(28,6) default NULL, -- the maximum amount of an overdue fine
862
  cap_fine_to_replacement_price BOOLEAN NOT NULL DEFAULT  '0', -- cap the fine based on item's replacement price
862
  `cap_fine_to_replacement_price` BOOLEAN NOT NULL DEFAULT  '0', -- cap the fine based on item's replacement price
863
  onshelfholds tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf
863
  `onshelfholds` tinyint(1) NOT NULL default 0, -- allow holds for items that are on shelf
864
  opacitemholds char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold
864
  `opacitemholds` char(1) NOT NULL default 'N', -- allow opac users to place specific items on hold
865
  article_requests enum('no','yes','bib_only','item_only') NOT NULL DEFAULT 'no', -- allow article requests to be placed,
865
  `article_requests` enum('no','yes','bib_only','item_only') NOT NULL DEFAULT 'no', -- allow article requests to be placed,
866
  `decreaseloanholds` int(11) default NULL,
866
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
867
  PRIMARY KEY  (`branchcode`,`categorycode`,`itemtype`),
867
  KEY `categorycode` (`categorycode`),
868
  KEY `categorycode` (`categorycode`),
868
  KEY `itemtype` (`itemtype`)
869
  KEY `itemtype` (`itemtype`)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt (-120 / +120 lines)
Lines 97-225 Link Here
97
            </tr>
97
            </tr>
98
            </thead>
98
            </thead>
99
            <tbody>
99
            <tbody>
100
				[% FOREACH rule IN rules %]
100
                [% FOREACH rule IN rules %]
101
					<tr id="row_[% loop.count %]">
101
                    <tr id="row_[% loop.count %]">
102
							<td>[% IF ( rule.default_humancategorycode ) %]
102
                        <td>
103
									<em>All</em>
103
                            [% IF ( rule.default_humancategorycode ) %]
104
								[% ELSE %]
104
                                <em>All</em>
105
									[% rule.humancategorycode %]
105
                            [% ELSE %]
106
								[% END %]
106
                                [% rule.humancategorycode %]
107
							</td>
107
                            [% END %]
108
                            <td>[% IF rule.default_translated_description %]
108
                        </td>
109
									<em>All</em>
109
                        <td>
110
								[% ELSE %]
110
                            [% IF rule.default_translated_description %]
111
									[% rule.translated_description %]
111
                                <em>All</em>
112
								[% END %]
112
                            [% ELSE %]
113
							</td>
113
                                [% rule.translated_description %]
114
                                                        <td class="actions">
114
                            [% END %]
115
                                                          <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
115
                        </td>
116
                                                          <a class="btn btn-default btn-xs 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>
116
                        <td class="actions">
117
                                                        </td>
117
                            <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
118
118
                            <a class="btn btn-default btn-xs 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>
119
							<td>[% IF ( rule.unlimited_maxissueqty ) %]
119
                        </td>
120
									<span>Unlimited</span>
120
                        <td>
121
								[% ELSE %]
121
                            [% IF ( rule.unlimited_maxissueqty ) %]
122
									[% rule.maxissueqty %]
122
                                <span>Unlimited</span>
123
								[% END %]
123
                            [% ELSE %]
124
							</td>
124
                                [% rule.maxissueqty %]
125
                            <td>[% IF rule.unlimited_maxonsiteissueqty %]
125
                            [% END %]
126
                                    <span>Unlimited</span>
126
                        </td>
127
                                [% ELSE %]
127
                        <td>
128
                                    [% rule.maxonsiteissueqty %]
128
                            [% IF rule.unlimited_maxonsiteissueqty %]
129
                                [% END %]
129
                                 <span>Unlimited</span>
130
                            </td>
130
                            [% ELSE %]
131
							<td>[% rule.issuelength %]</td>
131
                                 [% rule.maxonsiteissueqty %]
132
							<td>
132
                            [% END %]
133
							    [% rule.lengthunit %]
133
                        </td>
134
							</td>
134
                        <td>[% rule.issuelength %]</td>
135
                            <td>
135
                        <td>[% rule.lengthunit %]<td>
136
                              [% IF ( rule.hardduedate ) %]
136
                        <td>
137
                            [% IF ( rule.hardduedate ) %]
137
                                [% IF ( rule.hardduedatebefore ) %]
138
                                [% IF ( rule.hardduedatebefore ) %]
138
                                  before [% rule.hardduedate %]
139
                                    before [% rule.hardduedate %]
139
                                  <input type="hidden" name="hardduedatecomparebackup" value="-1" />
140
                                    <input type="hidden" name="hardduedatecomparebackup" value="-1" />
140
                                [% ELSIF ( rule.hardduedateexact ) %]
141
                                [% ELSIF ( rule.hardduedateexact ) %]
141
                                  on [% rule.hardduedate %]
142
                                    on [% rule.hardduedate %]
142
                                  <input type="hidden" name="hardduedatecomparebackup" value="0" />
143
                                    <input type="hidden" name="hardduedatecomparebackup" value="0" />
143
                                [% ELSIF ( rule.hardduedateafter ) %]
144
                                [% ELSIF ( rule.hardduedateafter ) %]
144
                                  after [% rule.hardduedate %]
145
                                    after [% rule.hardduedate %]
145
                                  <input type="hidden" name="hardduedatecomparebackup" value="1" />
146
                                    <input type="hidden" name="hardduedatecomparebackup" value="1" />
146
                                [% END %]
147
                                [% END %]
147
                              [% ELSE %]
148
                            [% ELSE %]
148
                                <span>None defined</span>
149
                                <span>None defined</span>
149
                              [% END %]
150
                            [% END %]
150
                            </td>
151
                        </td>
151
							<td>[% rule.fine %]</td>
152
                        <td>[% rule.fine %]</td>
152
							<td>[% rule.chargeperiod %]</td>
153
                        <td>[% rule.chargeperiod %]</td>
153
                            <td>
154
                        <td>
154
                                [% IF rule.chargeperiod_charge_at %]
155
                            [% IF rule.chargeperiod_charge_at %]
155
                                    <span>Start of interval</span>
156
                                <span>Start of interval</span>
156
                                [% ELSE %]
157
                            [% ELSE %]
157
                                    <span>End of interval</span>
158
                                <span>End of interval</span>
158
                                [% END %]
159
                            [% END %]
159
                            </td>
160
                        </td>
160
							<td>[% rule.firstremind %]</td>
161
                        <td>[% rule.firstremind %]</td>
161
                            <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
162
                        <td>[% rule.overduefinescap FILTER format("%.2f") %]</td>
162
                            <td>
163
                        <td>
163
                                [% IF rule.cap_fine_to_replacement_price %]
164
                            [% IF rule.cap_fine_to_replacement_price %]
164
                                    <input type="checkbox" checked="checked" disabled="disabled" />
165
                                <input type="checkbox" checked="checked" disabled="disabled" />
165
                                [% ELSE %]
166
                            [% ELSE %]
166
                                    <input type="checkbox" disabled="disabled" />
167
                                <input type="checkbox" disabled="disabled" />
167
                                [% END %]
168
                            [% END %]
168
                            </td>
169
                        </td>
169
							<td>[% rule.finedays %]</td>
170
                        <td>[% rule.finedays %]</td>
170
                            <td>[% rule.maxsuspensiondays %]</td>
171
                        <td>[% rule.maxsuspensiondays %]</td>
171
                            <td>[% rule.suspension_chargeperiod %]</td>
172
                        <td>[% rule.suspension_chargeperiod %]</td>
172
							<td>[% rule.renewalsallowed %]</td>
173
                        <td>[% rule.renewalsallowed %]</td>
173
                            <td>[% rule.renewalperiod %]</td>
174
                        <td>[% rule.renewalperiod %]</td>
174
                            <td>[% rule.norenewalbefore %]</td>
175
                        <td>[% rule.norenewalbefore %]</td>
175
                            <td>
176
                        <td>
176
                                [% IF ( rule.auto_renew ) %]
177
                            [% IF ( rule.auto_renew ) %]
177
                                    <span>Yes</span>
178
                                <span>Yes</span>
178
                                [% ELSE %]
179
                            [% ELSE %]
179
                                    <span>No</span>
180
                                <span>No</span>
180
                                [% END %]
181
                            [% END %]
181
                            </td>
182
                        </td>
182
                            <td>[% rule.no_auto_renewal_after %]</td>
183
                        <td>[% rule.no_auto_renewal_after %]</td>
183
                            <td>[% rule.no_auto_renewal_after_hard_limit %]</td>
184
                        <td>[% rule.no_auto_renewal_after_hard_limit %]</td>
184
							<td>[% rule.reservesallowed %]</td>
185
                        <td>[% rule.reservesallowed %]</td>
185
                                                        <td>[% rule.holds_per_record %]</td>
186
                        <td>[% rule.holds_per_record %]</td>
186
                                                        <td>
187
                        <td>
187
                                                            [% IF rule.onshelfholds == 1 %]
188
                            [% IF rule.onshelfholds == 1 %]
188
                                                                <span>Yes</span>
189
                                <span>Yes</span>
189
                                                            [% ELSIF rule.onshelfholds == 2 %]
190
                            [% ELSIF rule.onshelfholds == 2 %]
190
                                                                <span>If all unavailable</span>
191
                                <span>If all unavailable</span>
191
                                                            [% ELSE %]
192
                            [% ELSE %]
192
                                                                <span>If any unavailable</span>
193
                                <span>If any unavailable</span>
193
                                                            [% END %]
194
                            [% END %]
194
                                                        </td>
195
                        </td>
195
                                                        <td>
196
                        <td>
196
                                                            [% IF rule.opacitemholds == 'F'%]
197
                            [% IF rule.opacitemholds == 'F'%]
197
                                                                <span>Force</span>
198
                                <span>Force</span>
198
                                                            [% ELSIF rule.opacitemholds == 'Y'%]
199
                            [% ELSIF rule.opacitemholds == 'Y'%]
199
                                                                <span>Allow</span>
200
                                <span>Allow</span>
200
                                                            [% ELSE %]
201
                            [% ELSE %]
201
                                                                <span>Don't allow</span>
202
                                <span>Don't allow</span>
202
                                                            [% END %]
203
                            [% END %]
203
                                                        </td>
204
                        </td>
204
                                                        <td>[% rule.decreaseloanholds %]</td>
205
                        <td>[% rule.decreaseloanholds %]</td>
205
                                                        <td>
206
                        <td>
206
                                                            [% IF rule.article_requests == 'no' %]
207
                            [% IF rule.article_requests == 'no' %]
207
                                                                <span>No</span>
208
                                <span>No</span>
208
                                                            [% ELSIF rule.article_requests == 'yes' %]
209
                            [% ELSIF rule.article_requests == 'yes' %]
209
                                                                <span>Yes</span>
210
                                <span>Yes</span>
210
                                                            [% ELSIF rule.article_requests == 'bib_only' %]
211
                            [% ELSIF rule.article_requests == 'bib_only' %]
211
                                                                <span>Record only</span>
212
                                <span>Record only</span>
212
                                                            [% ELSIF rule.article_requests == 'item_only' %]
213
                            [% ELSIF rule.article_requests == 'item_only' %]
213
                                                                <span>Item only</span>
214
                                <span>Item only</span>
214
                                                            [% END %]
215
                            [% END %]
215
                                                        </td>
216
                        </td>
216
							<td>[% rule.rentaldiscount %]</td>
217
                        <td>[% rule.rentaldiscount %]</td>
217
                                                        <td class="actions">
218
                        <td class="actions">
218
                                                          <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
219
                            <a href="#" class="editrule btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
219
                                                          <a class="btn btn-default btn-xs 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>
220
                            <a class="btn btn-default btn-xs 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>
220
                                                        </td>
221
                        </td>
221
                	</tr>
222
                    </tr>
222
            	[% END %]
223
                [% END %]
223
                <tr id="edit_row">
224
                <tr id="edit_row">
224
                    <td>
225
                    <td>
225
                        <select name="categorycode" id="categorycode">
226
                        <select name="categorycode" id="categorycode">
Lines 344-350 Link Here
344
                      <th>No renewal before</th>
345
                      <th>No renewal before</th>
345
                      <th>Automatic renewal</th>
346
                      <th>Automatic renewal</th>
346
                      <th>No automatic renewal after</th>
347
                      <th>No automatic renewal after</th>
347
                       <th>No automatic renewal after (hard limit)</th>
348
                      <th>No automatic renewal after (hard limit)</th>
348
                      <th>Holds allowed (count)</th>
349
                      <th>Holds allowed (count)</th>
349
                      <th>Holds per record (count)</th>
350
                      <th>Holds per record (count)</th>
350
                      <th>On shelf holds allowed</th>
351
                      <th>On shelf holds allowed</th>
351
- 

Return to bug 14866