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

(-)a/C4/Letters.pm (-3 / +5 lines)
Lines 963-971 sub EnqueueLetter { Link Here
963
    my $dbh       = C4::Context->dbh();
963
    my $dbh       = C4::Context->dbh();
964
    my $statement = << 'ENDSQL';
964
    my $statement = << 'ENDSQL';
965
INSERT INTO message_queue
965
INSERT INTO message_queue
966
( borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, reply_address, content_type, failure_code )
966
( borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, reply_address, content_type, failure_code, delay_until )
967
VALUES
967
VALUES
968
( ?,              ?,       ?,       ?,        ?,           ?,                      ?,      CAST(NOW() AS DATETIME),       ?,          ?,            ?,           ?,              ? )
968
( ?,              ?,       ?,       ?,        ?,           ?,                      ?,      CAST(NOW() AS DATETIME),       ?,          ?,            ?,           ?,              ?,    ?)
969
ENDSQL
969
ENDSQL
970
970
971
    my $sth    = $dbh->prepare($statement);
971
    my $sth    = $dbh->prepare($statement);
Lines 982-987 ENDSQL Link Here
982
        $params->{'reply_address'},               # reply_address
982
        $params->{'reply_address'},               # reply_address
983
        $params->{'letter'}->{'content-type'},    # content_type
983
        $params->{'letter'}->{'content-type'},    # content_type
984
        $params->{'failure_code'}        || '',   # failure_code
984
        $params->{'failure_code'}        || '',   # failure_code
985
        $params->{'delay_until'} || undef,        # delay_until
985
    );
986
    );
986
    return $dbh->last_insert_id(undef,undef,'message_queue', undef);
987
    return $dbh->last_insert_id(undef,undef,'message_queue', undef);
987
}
988
}
Lines 1124-1130 sub GetQueuedMessages { Link Here
1124
1125
1125
    my $dbh = C4::Context->dbh();
1126
    my $dbh = C4::Context->dbh();
1126
    my $statement = << 'ENDSQL';
1127
    my $statement = << 'ENDSQL';
1127
SELECT message_id, borrowernumber, subject, content, message_transport_type, status, time_queued, updated_on, failure_code
1128
SELECT message_id, borrowernumber, subject, content, message_transport_type, status, time_queued, updated_on, failure_code, delay_until
1128
FROM message_queue
1129
FROM message_queue
1129
ENDSQL
1130
ENDSQL
1130
1131
Lines 1292-1297 sub _get_unsent_messages { Link Here
1292
        FROM message_queue mq
1293
        FROM message_queue mq
1293
        LEFT JOIN borrowers b ON b.borrowernumber = mq.borrowernumber
1294
        LEFT JOIN borrowers b ON b.borrowernumber = mq.borrowernumber
1294
        WHERE status = ?
1295
        WHERE status = ?
1296
        AND ( delay_until < CURRENT_TIMESTAMP OR delay_until IS NULL)
1295
    };
1297
    };
1296
1298
1297
    my @query_params = ('pending');
1299
    my @query_params = ('pending');
(-)a/C4/Reserves.pm (-5 / +7 lines)
Lines 1173-1179 sub ModReserveStatus { Link Here
1173
1173
1174
=head2 ModReserveAffect
1174
=head2 ModReserveAffect
1175
1175
1176
  &ModReserveAffect($itemnumber,$borrowernumber,$diffBranchSend,$reserve_id, $desk_id);
1176
  &ModReserveAffect($itemnumber,$borrowernumber,$diffBranchSend,$reserve_id, $desk_id, $delay_notice_until);
1177
1177
1178
This function affect an item and a status for a given reserve, either fetched directly
1178
This function affect an item and a status for a given reserve, either fetched directly
1179
by record_id, or by borrowernumber and itemnumber or biblionumber. If only biblionumber
1179
by record_id, or by borrowernumber and itemnumber or biblionumber. If only biblionumber
Lines 1189-1195 This function also removes any entry of the hold in holds queue table. Link Here
1189
=cut
1189
=cut
1190
1190
1191
sub ModReserveAffect {
1191
sub ModReserveAffect {
1192
    my ( $itemnumber, $borrowernumber, $transferToDo, $reserve_id, $desk_id ) = @_;
1192
    my ( $itemnumber, $borrowernumber, $transferToDo, $reserve_id, $desk_id, $delay_notice_until) = @_;
1193
1193
    my $dbh = C4::Context->dbh;
1194
    my $dbh = C4::Context->dbh;
1194
1195
1195
    # we want to attach $itemnumber to $borrowernumber, find the biblionumber
1196
    # we want to attach $itemnumber to $borrowernumber, find the biblionumber
Lines 1223-1229 sub ModReserveAffect { Link Here
1223
        $hold->set_processing();
1224
        $hold->set_processing();
1224
    } else {
1225
    } else {
1225
        $hold->set_waiting($desk_id);
1226
        $hold->set_waiting($desk_id);
1226
        _koha_notify_reserve( $hold->reserve_id ) unless $already_on_shelf;
1227
        _koha_notify_reserve( $hold->reserve_id , $delay_notice_until ) unless $already_on_shelf;
1227
        # Complete transfer if one exists
1228
        # Complete transfer if one exists
1228
        my $transfer = $hold->item->get_transfer;
1229
        my $transfer = $hold->item->get_transfer;
1229
        $transfer->receive if $transfer;
1230
        $transfer->receive if $transfer;
Lines 1818-1824 sub _Findgroupreserve { Link Here
1818
1819
1819
=head2 _koha_notify_reserve
1820
=head2 _koha_notify_reserve
1820
1821
1821
  _koha_notify_reserve( $hold->reserve_id );
1822
  _koha_notify_reserve( $hold->reserve_id, $delay_until );
1822
1823
1823
Sends a notification to the patron that their hold has been filled (through
1824
Sends a notification to the patron that their hold has been filled (through
1824
ModReserveAffect, _not_ ModReserveFill)
1825
ModReserveAffect, _not_ ModReserveFill)
Lines 1845-1851 The following tables are availalbe witin the notice: Link Here
1845
=cut
1846
=cut
1846
1847
1847
sub _koha_notify_reserve {
1848
sub _koha_notify_reserve {
1848
    my $reserve_id = shift;
1849
    my ($reserve_id, $delay_until )= @_;
1849
    my $hold = Koha::Holds->find($reserve_id);
1850
    my $hold = Koha::Holds->find($reserve_id);
1850
    my $borrowernumber = $hold->borrowernumber;
1851
    my $borrowernumber = $hold->borrowernumber;
1851
1852
Lines 1894-1899 sub _koha_notify_reserve { Link Here
1894
            borrowernumber => $borrowernumber,
1895
            borrowernumber => $borrowernumber,
1895
            from_address => $admin_email_address,
1896
            from_address => $admin_email_address,
1896
            message_transport_type => $mtt,
1897
            message_transport_type => $mtt,
1898
            delay_until => $delay_until,
1897
        } );
1899
        } );
1898
    };
1900
    };
1899
1901
(-)a/circ/returns.pl (-2 / +6 lines)
Lines 86-91 my $userenv = C4::Context->userenv; Link Here
86
my $userenv_branch = $userenv->{'branch'} // '';
86
my $userenv_branch = $userenv->{'branch'} // '';
87
my $forgivemanualholdsexpire = $query->param('forgivemanualholdsexpire');
87
my $forgivemanualholdsexpire = $query->param('forgivemanualholdsexpire');
88
88
89
my $delay_notice_until = $query->param('delay_notice_until') || '';
90
my $delay_notice_until_dt = eval { dt_from_string( $delay_notice_until ) } if $delay_notice_until;
91
89
my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') eq 'production');
92
my $overduecharges = (C4::Context->preference('finesMode') && C4::Context->preference('finesMode') eq 'production');
90
93
91
# Set up the item stack ....
94
# Set up the item stack ....
Lines 150-156 if ( $query->param('reserve_id') ) { Link Here
150
        my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
153
        my $diffBranchSend = ($userenv_branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
151
        # diffBranchSend tells ModReserveAffect whether document is expected in this library or not,
154
        # diffBranchSend tells ModReserveAffect whether document is expected in this library or not,
152
        # i.e., whether to apply waiting status
155
        # i.e., whether to apply waiting status
153
        ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id, $desk_id );
156
        ModReserveAffect( $itemnumber, $borrowernumber, $diffBranchSend, $reserve_id, $desk_id, $delay_notice_until_dt );
154
    }
157
    }
155
#   check if we have other reserves for this document, if we have a return send the message of transfer
158
#   check if we have other reserves for this document, if we have a return send the message of transfer
156
    my ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber);
159
    my ( $messages, $nextreservinfo ) = GetOtherReserves($itemnumber);
Lines 434-440 if ( $messages->{'ResFound'}) { Link Here
434
        my $biblio = $item->biblio;
437
        my $biblio = $item->biblio;
435
438
436
        my $diffBranchSend = !$branchCheck ? $reserve->{branchcode} : undef;
439
        my $diffBranchSend = !$branchCheck ? $reserve->{branchcode} : undef;
437
        ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id}, $desk_id );
440
        ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id}, $desk_id, $delay_notice_until_dt );
438
        my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber});
441
        my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber});
439
442
440
        $template->param(
443
        $template->param(
Lines 641-646 $template->param( Link Here
641
    forgivemanualholdsexpire => $forgivemanualholdsexpire,
644
    forgivemanualholdsexpire => $forgivemanualholdsexpire,
642
    overduecharges => $overduecharges,
645
    overduecharges => $overduecharges,
643
    AudioAlerts        => C4::Context->preference("AudioAlerts"),
646
    AudioAlerts        => C4::Context->preference("AudioAlerts"),
647
    delay_notice_until => $delay_notice_until,
644
);
648
);
645
649
646
if ( $barcode ) {
650
if ( $barcode ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc (+49 lines)
Lines 155-160 Link Here
155
                options['enableTime'] = true;
155
                options['enableTime'] = true;
156
                options['dateFormat'] = flatpickr_dateformat_string + " " + flatpickr_timeformat_string;
156
                options['dateFormat'] = flatpickr_dateformat_string + " " + flatpickr_timeformat_string;
157
            }
157
            }
158
            if  ( $(this).data('flatpickr-futuredatetime') === true ) {
159
                let original_date = $(this).val();
160
                if ( original_date ) {
161
                    original_date = DateTime_from_syspref( original_date ).getTime();
162
                    let now = new Date().getTime();
163
164
                    options['enable'] = [function(date){
165
                        date = date.getTime();
166
                        if ( date == original_date ) return true;
167
                        if ( date >= now)       return true;
168
                    }];
169
                }
170
                else {
171
                    options['minDate'] = new Date();
172
                    options['defaultHour'] = new Date().getHours();
173
                    options['defaultMinute'] = new Date().getMinutes();
174
175
                }
176
                options['plugins'] = [ ShortcutButtonsPlugin({
177
                                       button: [
178
                                       {
179
                                           label: __("1h")
180
                                       },
181
                                       {
182
                                           label: __("2h")
183
                                       },
184
                                       {
185
                                           label: __("4h")
186
                                       }
187
                                       ],
188
                                       label: __("or"),
189
                                       onClick: (index, fp) => {
190
                                           let date;
191
                                           let hh = 23, mm = 59;
192
                                           switch (index) {
193
                                               case 0:
194
                                                   date = new Date(Date.now() + 1 * 60 * 60 * 1000);
195
                                                   break;
196
                                               case 1:
197
                                                   date = new Date(Date.now() + 2 * 60 * 60 * 1000);
198
                                                   break;
199
                                               case 2:
200
                                                  date = new Date(Date.now() + 4 * 60 * 60 * 1000);
201
                                                  break;
202
                                           }
203
                                           fp.setDate(date, true);
204
                                       }
205
                                     })];
206
            }
158
207
159
            let fp = $(this).flatpickr(options);
208
            let fp = $(this).flatpickr(options);
160
            if ( refresh_max_date ) {
209
            if ( refresh_max_date ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (-1 / +29 lines)
Lines 367-372 Link Here
367
                                            <form method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off">
367
                                            <form method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off">
368
                                                <input type="hidden" name="barcode" value="[% item.barcode | html %]" />
368
                                                <input type="hidden" name="barcode" value="[% item.barcode | html %]" />
369
                                                <input type="hidden" name="multiple_confirm" value="1" />
369
                                                <input type="hidden" name="multiple_confirm" value="1" />
370
                                                <input type="hidden" name="delay_notice_until" value="[% delay_notice_until | html %]" />
370
                                                [% FOREACH inputloo IN inputloop %]
371
                                                [% FOREACH inputloo IN inputloop %]
371
                                                    <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" />
372
                                                    <input type="hidden" name="ri-[% inputloo.counter | html %]" value="[% inputloo.barcode | html %]" />
372
                                                    <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" />
373
                                                    <input type="hidden" name="dd-[% inputloo.counter | html %]" value="[% inputloo.duedate | html %]" />
Lines 432-437 Link Here
432
                                            <form method="post" action="returns.pl" name="wrongtransferform" id="wrongtransferform">
433
                                            <form method="post" action="returns.pl" name="wrongtransferform" id="wrongtransferform">
433
                                                <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
434
                                                <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
434
                                                <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
435
                                                <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
436
                                                <input type="hidden" name="delay_notice_until" value="[% delay_notice_until | html %]" />
435
                                                <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
437
                                                <input type="hidden" name="itemnumber" value="[% itemnumber | html %]" />
436
                                                <input type="hidden" name="transit" value="[% NewTransfer | html %]" />
438
                                                <input type="hidden" name="transit" value="[% NewTransfer | html %]" />
437
                                                [% FOREACH inputloo IN inputloop %]
439
                                                [% FOREACH inputloo IN inputloop %]
Lines 538-543 Link Here
538
540
539
                                                    <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
541
                                                    <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
540
                                                    <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
542
                                                    <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
543
                                                    <input type="hidden" name="delay_notice_until" value="[% delay_notice_until | html %]" />
541
                                                    [% INCLUDE all_checkin_messages %]
544
                                                    [% INCLUDE all_checkin_messages %]
542
                                                </div> <!-- /.modal-body -->
545
                                                </div> <!-- /.modal-body -->
543
546
Lines 609-614 Link Here
609
                                                    [% END %]
612
                                                    [% END %]
610
                                                    <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
613
                                                    <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
611
                                                    <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
614
                                                    <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
615
                                                    <input type="hidden" name="delay_notice_until" value="[% delay_notice_until | html %]" />
612
                                                    <input type="hidden" name="exemptfine" value="[% exemptfine | html %]" />
616
                                                    <input type="hidden" name="exemptfine" value="[% exemptfine | html %]" />
613
                                                    <input type="hidden" name="dropboxmode" value="[% dropboxmode | html %]" />
617
                                                    <input type="hidden" name="dropboxmode" value="[% dropboxmode | html %]" />
614
                                                    <input type="hidden" name="forgivemanualholdsexpire" value="[% forgivemanualholdsexpire | html %]" />
618
                                                    <input type="hidden" name="forgivemanualholdsexpire" value="[% forgivemanualholdsexpire | html %]" />
Lines 708-713 Link Here
708
                                                    <input type="hidden" name="forgivemanualholdsexpire" value="[% forgivemanualholdsexpire | html %]" />
712
                                                    <input type="hidden" name="forgivemanualholdsexpire" value="[% forgivemanualholdsexpire | html %]" />
709
                                                    <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
713
                                                    <input type="hidden" name="return_date_override" value="[% return_date_override | html %]" />
710
                                                    <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
714
                                                    <input type="hidden" name="return_date_override_remember" value="[% return_date_override_remember | html %]" />
715
                                                    <input type="hidden" name="delay_notice_until" value="[% delay_notice_until | html %]" />
711
                                                    [% INCLUDE all_checkin_messages %]
716
                                                    [% INCLUDE all_checkin_messages %]
712
                                                </div>
717
                                                </div>
713
718
Lines 800-805 Link Here
800
                                        [% END %]
805
                                        [% END %]
801
                                            <p><i class="fa fa-check"></i> Saved check-in date: <span id="saved_return_date" class="single-line">[% return_date_override | html %]</span></p>
806
                                            <p><i class="fa fa-check"></i> Saved check-in date: <span id="saved_return_date" class="single-line">[% return_date_override | html %]</span></p>
802
                                        </div>
807
                                        </div>
808
                                        [% IF ( delay_notice_until ) %]
809
                                            <div id="delay_notice" class="checkin-active-setting">
810
                                        [% ELSE %]
811
                                            <div id="delay_notice" class="checkin-active-setting" style="display:none;">
812
                                        [% END %]
813
                                            <p><i class="fa fa-check"></i> Delay pickup notice until: <span id="saved_delay_notice" class="single-line">[% delay_notice_until | html %]</span></p>
814
                                        </div>
803
                                    </div>
815
                                    </div>
804
                                </div>
816
                                </div>
805
817
Lines 851-857 Link Here
851
                                            <label for="forgivemanualholdsexpire">Forgive fees for manually expired holds</label>
863
                                            <label for="forgivemanualholdsexpire">Forgive fees for manually expired holds</label>
852
                                        </div>
864
                                        </div>
853
                                    [% END %] <!-- overduecharges -->
865
                                    [% END %] <!-- overduecharges -->
854
866
                                    <div id="delay-notice" class="date-select" >
867
                                        <div class="hint">Delay pickup notice until: </div>
868
                                        <input type="text" size="20" id="delay_notice_until" name="delay_notice_until" value="[% delay_notice_until | html %]" class="flatpickr" data-flatpickr-enable-time="true" data-flatpickr-on-close-focus="#barcode" data-flatpickr-futuredatetime="true" />
869
                                    </div>
855
                                </div> <!-- /.circ-settings -->
870
                                </div> <!-- /.circ-settings -->
856
                            </fieldset> <!-- /#circ_returns_checkin -->
871
                            </fieldset> <!-- /#circ_returns_checkin -->
857
                        </form> <!-- /#checkin-form -->
872
                        </form> <!-- /#checkin-form -->
Lines 1038-1043 Link Here
1038
                    "dom": 'B<"clearfix">t',
1053
                    "dom": 'B<"clearfix">t',
1039
                    }, columns_settings);
1054
                    }, columns_settings);
1040
1055
1056
1041
            $("#exemptcheck").change(function () {
1057
            $("#exemptcheck").change(function () {
1042
                if (this.checked == true) {
1058
                if (this.checked == true) {
1043
                    $("#barcode").addClass("input-warning");
1059
                    $("#barcode").addClass("input-warning");
Lines 1147-1152 Link Here
1147
                window.open("/cgi-bin/koha/members/printslip.pl?borrowernumber=" + borrowernumber + "&amp;print=checkinslip", "printwindow");
1163
                window.open("/cgi-bin/koha/members/printslip.pl?borrowernumber=" + borrowernumber + "&amp;print=checkinslip", "printwindow");
1148
            });
1164
            });
1149
1165
1166
            $("input#delay_notice_until").on("change", function () {
1167
                console.log('change');
1168
                let delay_date = $(this).val();
1169
                $("span#saved_delay_notice").text(delay_date);
1170
                if ( delay_date == '' ){
1171
                    $("div#delay_notice").hide();
1172
                }
1173
                else {
1174
                    $("div#delay_notice").show();
1175
                }
1176
            });
1177
1150
        });
1178
        });
1151
    </script>
1179
    </script>
1152
[% END %]
1180
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/notices.tt (-2 / +1 lines)
Lines 72-78 Link Here
72
        </td>
72
        </td>
73
		<td>
73
		<td>
74
            [% IF ( QUEUED_MESSAGE.status == 'sent' ) %]sent
74
            [% IF ( QUEUED_MESSAGE.status == 'sent' ) %]sent
75
            [% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %]pending
75
            [% ELSIF ( QUEUED_MESSAGE.status == 'pending' ) %]pending [% IF QUEUED_MESSAGE.delay_until %], delayed until [% QUEUED_MESSAGE.delay_until | $KohaDates  with_hours => 1 %][% END %]
76
            [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]failed
76
            [% ELSIF ( QUEUED_MESSAGE.status == 'failed' ) %]failed
77
            [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %]deleted
77
            [% ELSIF ( QUEUED_MESSAGE.status == 'deleted' ) %]deleted
78
            [% ELSE %][% QUEUED_MESSAGE.status | html %][% END %]
78
            [% ELSE %][% QUEUED_MESSAGE.status | html %][% END %]
79
- 

Return to bug 27208