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

(-)a/C4/HoldsQueue.pm (-2 / +2 lines)
Lines 231-237 sub GetBibsWithPendingHoldRequests { Link Here
231
                     FROM reserves
231
                     FROM reserves
232
                     WHERE found IS NULL
232
                     WHERE found IS NULL
233
                     AND priority > 0
233
                     AND priority > 0
234
                     AND reservedate <= CURRENT_DATE()
234
                     AND reservedate <= CURRENT_TIMESTAMP()
235
                     AND suspend = 0
235
                     AND suspend = 0
236
                     ";
236
                     ";
237
    my $sth = $dbh->prepare($bib_query);
237
    my $sth = $dbh->prepare($bib_query);
Lines 275-281 sub GetPendingHoldRequestsForBib { Link Here
275
                         WHERE biblionumber = ?
275
                         WHERE biblionumber = ?
276
                         AND found IS NULL
276
                         AND found IS NULL
277
                         AND priority > 0
277
                         AND priority > 0
278
                         AND reservedate <= CURRENT_DATE()
278
                         AND reservedate <= CURRENT_TIMESTAMP()
279
                         AND suspend = 0
279
                         AND suspend = 0
280
                         ORDER BY priority";
280
                         ORDER BY priority";
281
    my $sth = $dbh->prepare($request_query);
281
    my $sth = $dbh->prepare($request_query);
(-)a/C4/Reserves.pm (-7 / +27 lines)
Lines 194-203 sub AddReserve { Link Here
194
    my $itemtype       = $params->{itemtype};
194
    my $itemtype       = $params->{itemtype};
195
    my $non_priority   = $params->{non_priority};
195
    my $non_priority   = $params->{non_priority};
196
196
197
    $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' })
197
    if ( C4::Context->preference('HourBasedHolds') ){
198
        or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' });
198
        if ( $resdate ){
199
199
            $resdate = dt_from_string( $resdate );
200
    $expdate = output_pref({ str => $expdate, dateonly => 1, dateformat => 'iso' });
200
        } else {
201
            $resdate = dt_from_string();
202
        }
203
        if ( $expdate ){
204
            $expdate = dt_from_string( $expdate );
205
        }
206
    } else {
207
        # add hour and minute components
208
        if ( $resdate ){
209
            $resdate = dt_from_string( $resdate )->set({ hour => 00, minute => 00, second => 00 });
210
        } else {
211
            $resdate = dt_from_string();
212
        }
213
        if ( $expdate ){
214
            $expdate = dt_from_string( $expdate )->set({ hour => 23, minute => 59, second => 59 });
215
        }
216
    }
201
217
202
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
218
    # if we have an item selectionned, and the pickup branch is the same as the holdingbranch
203
    # of the document, we force the value $priority and $found .
219
    # of the document, we force the value $priority and $found .
Lines 470-478 sub CanItemBeReserved { Link Here
470
        }
486
        }
471
    }
487
    }
472
488
489
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
490
    my $fromdate = dt_from_string->set({ hour => 00, minute => 00, second => 00 });
491
    my $todate = dt_from_string->set({ hour => 23, minute => 59, second => 59 });
492
473
    my $today_holds = Koha::Holds->search({
493
    my $today_holds = Koha::Holds->search({
474
        borrowernumber => $borrowernumber,
494
        borrowernumber => $borrowernumber,
475
        reservedate    => dt_from_string->date
495
        reservedate    => [ -and => { '>=' => $dtf->format_datetime($fromdate) }, { '<=' => $dtf->format_datetime($todate) } ],
476
    });
496
    });
477
497
478
    if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne ''
498
    if (!$params->{ignore_hold_counts} && defined $holds_per_day && $holds_per_day ne ''
Lines 947-953 sub CancelExpiredReserves { Link Here
947
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
967
    my $expireWaiting = C4::Context->preference('ExpireReservesMaxPickUpDelay');
948
968
949
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
969
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
950
    my $params = { expirationdate => { '<', $dtf->format_date($today) } };
970
    my $params = { expirationdate => { '<', $dtf->format_datetime($today) } };
951
    $params->{found} = [ { '!=', 'W' }, undef ]  unless $expireWaiting;
971
    $params->{found} = [ { '!=', 'W' }, undef ]  unless $expireWaiting;
952
972
953
    # FIXME To move to Koha::Holds->search_expired (?)
973
    # FIXME To move to Koha::Holds->search_expired (?)
Lines 2221-2227 sub CalculatePriority { Link Here
2221
        $sql.= ' AND ( reservedate <= ? )';
2241
        $sql.= ' AND ( reservedate <= ? )';
2222
    }
2242
    }
2223
    else {
2243
    else {
2224
        $sql.= ' AND ( reservedate < NOW() )';
2244
        $sql.= ' AND ( reservedate <= NOW() )';
2225
    }
2245
    }
2226
    my $dbh = C4::Context->dbh();
2246
    my $dbh = C4::Context->dbh();
2227
    my @row = $dbh->selectrow_array(
2247
    my @row = $dbh->selectrow_array(
(-)a/Koha/Hold.pm (-1 / +1 lines)
Lines 214-220 sub set_waiting { Link Here
214
    # If patron's requested expiration date is prior to the
214
    # If patron's requested expiration date is prior to the
215
    # calculated one, we keep the patron's one.
215
    # calculated one, we keep the patron's one.
216
    my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
216
    my $cmp = $requested_expiration ? DateTime->compare($requested_expiration, $expirationdate) : 0;
217
    $values->{expirationdate} = $cmp == -1 ? $requested_expiration->ymd : $expirationdate->ymd;
217
    $values->{expirationdate} = $cmp == -1 ? $requested_expiration : $expirationdate;
218
218
219
    $self->set($values)->store();
219
    $self->set($values)->store();
220
220
(-)a/Koha/Item.pm (-1 / +1 lines)
Lines 796-802 sub current_holds { Link Here
796
        itemnumber => $self->itemnumber,
796
        itemnumber => $self->itemnumber,
797
        suspend => 0,
797
        suspend => 0,
798
        -or => [
798
        -or => [
799
            reservedate => { '<=' => $dtf->format_date(dt_from_string) },
799
            reservedate => { '<=' => $dtf->format_datetime(dt_from_string) },
800
            waitingdate => { '!=' => undef },
800
            waitingdate => { '!=' => undef },
801
        ],
801
        ],
802
    };
802
    };
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc (-3 / +15 lines)
Lines 108-120 Link Here
108
            <td>[% hold.notes | html | html_line_break %]</td>
108
            <td>[% hold.notes | html | html_line_break %]</td>
109
            <td>
109
            <td>
110
                [% IF Koha.Preference('AllowHoldDateInFuture') %]
110
                [% IF Koha.Preference('AllowHoldDateInFuture') %]
111
                    <input type="text" class="flatpickr" value="[% hold.date | $KohaDates %]" required="required" size="10" name="reservedate" />
111
                    [% IF Koha.Preference('HourBasedHolds') %]
112
                        <input type="text" class="holdst_reservedate" value="[% hold.date | $KohaDates with_hours = 1 %]" required="required" size="15" name="reservedate" />
113
                    [% ELSE %]
114
                        <input type="text" class="flatpickr" value="[% hold.date | $KohaDates %]" required="required" size="15" name="reservedate" />
115
                    [% END %]
112
                [% ELSE %]
116
                [% ELSE %]
113
                    [% hold.date | $KohaDates %]
117
                    [% IF Koha.Preference('HourBasedHolds') %]
118
                        [% hold.date | $KohaDates with_hours = 1 %]
119
                    [% ELSE %]
120
                        [% hold.date | $KohaDates %]
121
                    [% END %]
114
                [% END %]
122
                [% END %]
115
            </td>
123
            </td>
116
            <td>
124
            <td>
117
                <input type="text" class="flatpickr futuredate" value="[% hold.expirationdate | $KohaDates %]" size="10" name="expirationdate" />
125
                [% IF Koha.Preference('HourBasedHolds') %]
126
                    <input type="text" class="futuredate" value="[% hold.expirationdate | $KohaDates with_hours = 1 %]" size="15" name="expirationdate" />
127
                [% ELSE %]
128
                    <input type="text" class="flatpickr futuredate" value="[% hold.expirationdate | $KohaDates %]" size="15" name="expirationdate" />
129
                [% END %]
118
            </td>
130
            </td>
119
            <td>
131
            <td>
120
                [%- IF ( hold.found ) -%]
132
                [%- IF ( hold.found ) -%]
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/waiting_holds.inc (-1 / +5 lines)
Lines 26-32 Link Here
26
                <th><input type="checkbox" class="select_hold" data-id="[% reserveloo.reserve_id | html %]"/></th>
26
                <th><input type="checkbox" class="select_hold" data-id="[% reserveloo.reserve_id | html %]"/></th>
27
                [% END %]
27
                [% END %]
28
                <td><span title="[% reserveloo.waitingdate | html %]">[% reserveloo.waitingdate | $KohaDates %]</span></td>
28
                <td><span title="[% reserveloo.waitingdate | html %]">[% reserveloo.waitingdate | $KohaDates %]</span></td>
29
                <td><span title="[% reserveloo.reservedate | html %]">[% reserveloo.reservedate | $KohaDates %]</span></td>
29
                [% IF Koha.Preference('HourBasedHolds') %]
30
                    <td><span title="[% reserveloo.reservedate | html %]">[% reserveloo.reservedate | $KohaDates with_hours = 1 %]</span></td>
31
                [% ELSE %]
32
                    <td><span title="[% reserveloo.reservedate | html %]">[% reserveloo.reservedate | $KohaDates %]</span></td>
33
                [% END %]
30
                <td>
34
                <td>
31
                    [% INCLUDE 'biblio-title.inc' biblio=reserveloo.biblio link = 1 %]
35
                    [% INCLUDE 'biblio-title.inc' biblio=reserveloo.biblio link = 1 %]
32
                        [% UNLESS ( item_level_itypes ) %]
36
                        [% UNLESS ( item_level_itypes ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/pendingreserves.tt (-1 / +5 lines)
Lines 177-183 Link Here
177
            </ul>
177
            </ul>
178
        </td>
178
        </td>
179
        <td data-order="[% hold.reservedate | html %]">
179
        <td data-order="[% hold.reservedate | html %]">
180
            [% hold.reservedate | $KohaDates %] in [% Branches.GetName ( hold.branchcode ) | html %]
180
            [% IF Koha.Preference('HourBasedHolds') %]
181
                [% hold.reservedate | $KohaDates with_hours = 1 %] in [% Branches.GetName ( hold.branchcode ) | html %]
182
            [% ELSE %]
183
                [% hold.reservedate | $KohaDates %] in [% Branches.GetName ( hold.branchcode ) | html %]
184
            [% END %]
181
        </td>
185
        </td>
182
        <td>[% hold.reservenotes | html %]</td>
186
        <td>[% hold.reservenotes | html %]</td>
183
        <td>
187
        <td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt (-1 / +7 lines)
Lines 191-197 Link Here
191
              [% END %]
191
              [% END %]
192
            </td>
192
            </td>
193
            <td class="hq-sendto">[% Branches.GetName( itemsloo.pickbranch ) | html %]</td>
193
            <td class="hq-sendto">[% Branches.GetName( itemsloo.pickbranch ) | html %]</td>
194
            <td class="hq-date" data-order="[% itemsloo.reservedate | html %]">[% itemsloo.reservedate | $KohaDates %]</td>
194
            <td class="hq-date" data-order="[% itemsloo.reservedate | html %]">
195
                [% IF Koha.Preference('HourBasedHolds') %]
196
                    [% itemsloo.reservedate | $KohaDates with_hours = 1 %]
197
                [% ELSE %]
198
                    [% itemsloo.reservedate | $KohaDates %]
199
                [% END %]
200
            </td>
195
            <td class="hq-notes">[% itemsloo.notes | html %]</td>
201
            <td class="hq-notes">[% itemsloo.notes | html %]</td>
196
        </tr>
202
        </tr>
197
    [% END %]</tbody>
203
    [% END %]</tbody>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt (-4 / +7 lines)
Lines 75-84 Link Here
75
          <td>[% hold.biblio.author | html %]</td>
75
          <td>[% hold.biblio.author | html %]</td>
76
          <td>[% hold.item.barcode | html %]</td>
76
          <td>[% hold.item.barcode | html %]</td>
77
          <td>[% Branches.GetName( hold.branchcode ) | html %]</td>
77
          <td>[% Branches.GetName( hold.branchcode ) | html %]</td>
78
          <td data-order="[% hold.reservedate | html %]">[% hold.reservedate | $KohaDates %]</td>
78
          [% IF Koha.Preference('HourBasedHolds') %]
79
          <td data-order="[% hold.expirationdate | html %]">
79
              <td data-order="[% hold.reservedate | html %]">[% hold.reservedate | $KohaDates with_hours = 1 %]</td>
80
                [% hold.expirationdate | $KohaDates %]
80
              <td data-order="[% hold.expirationdate | html %]">[% hold.expirationdate | $KohaDates with_hours = 1 %]</td>
81
          </td>
81
          [% ELSE %]
82
              <td data-order="[% hold.reservedate | html %]">[% hold.reservedate | $KohaDates %]</td>
83
              <td data-order="[% hold.expirationdate | html %]">[% hold.expirationdate | $KohaDates %]</td>
84
          [% END %]
82
          <td data-order="[% hold.waitingdate | html %]">
85
          <td data-order="[% hold.waitingdate | html %]">
83
                [% hold.waitingdate | $KohaDates %]
86
                [% hold.waitingdate | $KohaDates %]
84
          </td>
87
          </td>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt (-2 / +17 lines)
Lines 492-505 Link Here
492
                            [% IF ( reserve_in_future ) %]
492
                            [% IF ( reserve_in_future ) %]
493
                                <li>
493
                                <li>
494
                                    <label for="from">Hold starts on date:</label>
494
                                    <label for="from">Hold starts on date:</label>
495
                                    <input id="reserve_date" name="reserve_date" id="from" size="10" type="text" >
495
                                    <input id="reserve_date" name="reserve_date" id="from" size="15" type="text" >
496
                                    <input type="hidden" class="datepickerfrom_hidden" />
496
                                    <input type="hidden" class="datepickerfrom_hidden" />
497
                                </li>
497
                                </li>
498
                            [% END %]
498
                            [% END %]
499
499
500
                            <li>
500
                            <li>
501
                                <label for="to">Hold expires on date:</label>
501
                                <label for="to">Hold expires on date:</label>
502
                                <input id="expiration_date" name="expiration_date" id="to" size="10" type="text" />
502
                                <input id="expiration_date" name="expiration_date" id="to" size="15" type="text" />
503
                                <input type="hidden" class="datepickerto_hidden" />
503
                                <input type="hidden" class="datepickerto_hidden" />
504
                            </li>
504
                            </li>
505
505
Lines 1155-1160 Link Here
1155
1155
1156
1156
1157
            var startPicker = $("#reserve_date").flatpickr({
1157
            var startPicker = $("#reserve_date").flatpickr({
1158
                [% IF Koha.Preference('HourBasedHolds') %]
1159
                    enableTime: true,
1160
                    dateFormat: flatpickr_dateformat_string + " " + flatpickr_timeformat_string,
1161
                [% END %]
1158
                minDate: new Date().fp_incr(1), /* Require that "Hold starts on date" be in the future */
1162
                minDate: new Date().fp_incr(1), /* Require that "Hold starts on date" be in the future */
1159
                onChange: function(selectedDates, dateStr, instance) {
1163
                onChange: function(selectedDates, dateStr, instance) {
1160
                    altFormat = instance.formatDate(selectedDates[0], "Y-m-d");
1164
                    altFormat = instance.formatDate(selectedDates[0], "Y-m-d");
Lines 1167-1172 Link Here
1167
            });
1171
            });
1168
1172
1169
            var endPicker = $("#expiration_date").flatpickr({
1173
            var endPicker = $("#expiration_date").flatpickr({
1174
                [% IF Koha.Preference('HourBasedHolds') %]
1175
                    enableTime: true,
1176
                    dateFormat: flatpickr_dateformat_string + " " + flatpickr_timeformat_string,
1177
                [% END %]
1170
                minDate: new Date().fp_incr(1), // Require that "Hold expires on date" be in the future
1178
                minDate: new Date().fp_incr(1), // Require that "Hold expires on date" be in the future
1171
                onChange: function(selectedDates, dateStr, instance) {
1179
                onChange: function(selectedDates, dateStr, instance) {
1172
                    altFormat = instance.formatDate(selectedDates[0], "Y-m-d");
1180
                    altFormat = instance.formatDate(selectedDates[0], "Y-m-d");
Lines 1177-1182 Link Here
1177
                },
1185
                },
1178
            });
1186
            });
1179
1187
1188
            [% IF Koha.Preference('HourBasedHolds') %]
1189
                $(".holdst_reservedate, .futuredate").flatpickr({
1190
                    enableTime: true,
1191
                    dateFormat: flatpickr_dateformat_string + " " + flatpickr_timeformat_string,
1192
                });
1193
            [% END %]
1194
1180
            var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
1195
            var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
1181
                'bPaginate': false,
1196
                'bPaginate': false,
1182
                "sDom": '<"top pager"ilf>t',
1197
                "sDom": '<"top pager"ilf>t',
(-)a/svc/holds (-6 / +19 lines)
Lines 114-132 while ( my $h = $holds_rs->next() ) { Link Here
114
        waiting_here   => $h->branch()->branchcode() eq $branch,
114
        waiting_here   => $h->branch()->branchcode() eq $branch,
115
        priority       => $h->priority(),
115
        priority       => $h->priority(),
116
        itemtype_limit => $itemtype_limit,
116
        itemtype_limit => $itemtype_limit,
117
        reservedate_formatted => $h->reservedate() ? output_pref(
118
            { dt => dt_from_string( $h->reservedate() ), dateonly => 1 }
119
          )
120
        : q{},
121
        suspend_until_formatted => $h->suspend_until() ? output_pref(
117
        suspend_until_formatted => $h->suspend_until() ? output_pref(
122
            { dt => dt_from_string( $h->suspend_until() ), dateonly => 1 }
118
            { dt => dt_from_string( $h->suspend_until() ), dateonly => 1 }
123
          )
119
          )
124
        : q{},
120
        : q{},
125
        expirationdate_formatted => $h->expirationdate() ? output_pref(
121
    };
122
123
    if ( C4::Context->preference('HourBasedHolds') ){
124
        $hold->{reservedate_formatted} = $h->reservedate() ? output_pref(
125
            { dt => dt_from_string( $h->reservedate() ) }
126
          )
127
        : q{},
128
        $hold->{expirationdate_formatted} = $h->expirationdate() ? output_pref(
129
            { dt => dt_from_string( $h->expirationdate() ) }
130
          )
131
        : q{},
132
    } else {
133
        $hold->{reservedate_formatted} = $h->reservedate() ? output_pref(
134
            { dt => dt_from_string( $h->reservedate() ), dateonly => 1 }
135
          )
136
        : q{},
137
        $hold->{expirationdate_formatted} = $h->expirationdate() ? output_pref(
126
            { dt => dt_from_string( $h->expirationdate() ), dateonly => 1 }
138
            { dt => dt_from_string( $h->expirationdate() ), dateonly => 1 }
127
          )
139
          )
128
        : q{},
140
        : q{},
129
    };
141
    }
142
130
143
131
    $hold->{transfered}     = 0;
144
    $hold->{transfered}     = 0;
132
    $hold->{not_transfered} = 0;
145
    $hold->{not_transfered} = 0;
(-)a/t/db_dependent/Holds.t (-5 / +71 lines)
Lines 7-13 use t::lib::TestBuilder; Link Here
7
7
8
use C4::Context;
8
use C4::Context;
9
9
10
use Test::More tests => 72;
10
use Test::More tests => 73;
11
use MARC::Record;
11
use MARC::Record;
12
12
13
use C4::Biblio;
13
use C4::Biblio;
Lines 102-108 my $reservedate = $first_hold->reservedate; Link Here
102
my $borrowernumber = $first_hold->borrowernumber;
102
my $borrowernumber = $first_hold->borrowernumber;
103
my $branch_1code = $first_hold->branchcode;
103
my $branch_1code = $first_hold->branchcode;
104
my $reserve_id = $first_hold->reserve_id;
104
my $reserve_id = $first_hold->reserve_id;
105
is( $reservedate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), "holds_placed_today should return a valid reserve date");
105
is( dt_from_string($reservedate), dt_from_string, "holds_placed_today should return a valid reserve date");
106
is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber");
106
is( $borrowernumber, $borrowernumbers[0], "holds_placed_today should return a valid borrowernumber");
107
is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode");
107
is( $branch_1code, $branch_1, "holds_placed_today should return a valid branchcode");
108
ok($reserve_id, "Test holds_placed_today()");
108
ok($reserve_id, "Test holds_placed_today()");
Lines 922-928 subtest 'CanItemBeReserved / holds_per_day tests' => sub { Link Here
922
    is_deeply(
922
    is_deeply(
923
        CanItemBeReserved( $patron->borrowernumber, $itemnumber_2 ),
923
        CanItemBeReserved( $patron->borrowernumber, $itemnumber_2 ),
924
        { status => 'tooManyReservesToday', limit => 2 },
924
        { status => 'tooManyReservesToday', limit => 2 },
925
        'Patron cannot a third item with 2 reserves daily cap'
925
        'Patron cannot reserve a third item with 2 reserves daily cap'
926
    );
926
    );
927
927
928
    # Update last hold so reservedate is in the past, so 2 holds, but different day
928
    # Update last hold so reservedate is in the past, so 2 holds, but different day
Lines 1658-1667 subtest 'ModReserve can only update expirationdate for found holds' => sub { Link Here
1658
1658
1659
    $hold = Koha::Holds->find($reserve_id);
1659
    $hold = Koha::Holds->find($reserve_id);
1660
1660
1661
    is( $hold->expirationdate, '1981-06-10',
1661
    is( dt_from_string( $hold->expirationdate )->ymd, '1981-06-10',
1662
        'Found hold expiration date updated correctly' );
1662
        'Found hold expiration date updated correctly' );
1663
    is( $hold->priority, '0', 'Found hold priority was not updated' );
1663
    is( $hold->priority, '0', 'Found hold priority was not updated' );
1664
1664
1665
    $schema->storage->txn_rollback;
1665
    $schema->storage->txn_rollback;
1666
1666
1667
};
1667
};
1668
- 
1668
1669
subtest 'HourBasedHolds' => sub {
1670
    plan tests => 4;
1671
    $schema->storage->txn_begin;
1672
1673
    my $category = $builder->build({ source => 'Category' });
1674
    my $branch = $builder->build({ source => 'Branch' })->{ branchcode };
1675
    my $biblio = $builder->build_sample_biblio( { itemtype => 'DUMMY' } );
1676
    my $itemnumber = $builder->build_sample_item(
1677
        { library => $branch, biblionumber => $biblio->biblionumber } )
1678
      ->itemnumber;
1679
1680
    my $borrowernumber = Koha::Patron->new(
1681
        {
1682
            firstname    => 'firstname',
1683
            surname      => 'surname',
1684
            categorycode => $category->{categorycode},
1685
            branchcode   => $branch,
1686
        }
1687
    )->store->borrowernumber;
1688
1689
    t::lib::Mocks::mock_preference('HourBasedHolds', 1);
1690
1691
    my $reservation_date = DateTime->now->set( hour => 7, minute => 30 );
1692
    my $expiration_date = DateTime->now->set( hour => 19, minute => 30 );
1693
1694
    my $reserve_id = AddReserve(
1695
        {
1696
            branchcode     => $branch,
1697
            borrowernumber => $borrowernumber,
1698
            biblionumber   => $biblio->biblionumber,
1699
            priority       =>
1700
              C4::Reserves::CalculatePriority( $biblio->biblionumber ),
1701
            itemnumber => $itemnumber,
1702
            reservation_date => $reservation_date,
1703
            expiration_date => $expiration_date,
1704
        }
1705
    );
1706
1707
    my $hold = Koha::Holds->find($reserve_id);
1708
    is( dt_from_string( $hold->reservedate )->hour, 07, "Hold reserve date is set correctly with hours when HourBasedHolds enabled" );
1709
    is( dt_from_string( $hold->expirationdate )->hour, 19, "Hold expiration date is set correctly with hours when HourBasedHolds enabled" );
1710
1711
    t::lib::Mocks::mock_preference('HourBasedHolds', 0);
1712
1713
    $reservation_date = DateTime->now->ymd;
1714
    $expiration_date = DateTime->now->ymd;
1715
1716
    $reserve_id = AddReserve(
1717
        {
1718
            branchcode     => $branch,
1719
            borrowernumber => $borrowernumber,
1720
            biblionumber   => $biblio->biblionumber,
1721
            priority       =>
1722
              C4::Reserves::CalculatePriority( $biblio->biblionumber ),
1723
            itemnumber => $itemnumber,
1724
            reservation_date => $reservation_date,
1725
            expiration_date => $expiration_date,
1726
        }
1727
    );
1728
1729
    $hold = Koha::Holds->find($reserve_id);
1730
    is( dt_from_string( $hold->reservedate )->hour, 00, "Hold reserve date is set correctly when HourBasedHolds disabled" );
1731
    is( dt_from_string( $hold->expirationdate )->hour, 23, "Hold expiration date is set correctly when HourBasedHolds disabled" );
1732
1733
    $schema->storage->txn_rollback;
1734
};

Return to bug 24718