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

(-)a/admin/columns_settings.yml (+2 lines)
Lines 2671-2676 modules: Link Here
2671
              columnname: suspended_until
2671
              columnname: suspended_until
2672
            -
2672
            -
2673
              columnname: notes
2673
              columnname: notes
2674
            -
2675
              columnname: result
2674
    logviewer:
2676
    logviewer:
2675
      logst:
2677
      logst:
2676
        default_display_length: 20
2678
        default_display_length: 20
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt (-57 / +135 lines)
Lines 103-165 Link Here
103
        </div>
103
        </div>
104
        <!-- /#modify_holds_search -->
104
        <!-- /#modify_holds_search -->
105
    [% ELSIF view == "report" %]
105
    [% ELSIF view == "report" %]
106
        <h1>Modified holds</h1>
106
        <h1>Modified holds report</h1>
107
        <div id="modified_holds_results-wrapper">
107
        [% IF updated_holds_obj %]
108
            <div id="modified_holds_results" class="page-section">
108
            <div id="modified_holds_results-wrapper">
109
                <table id="modified_holds">
109
                <div id="modified_holds_results" class="page-section">
110
                    <thead>
110
                    <h2>Updated holds ([% total_updated | html %])</h2>
111
                        <tr>
111
                    <table id="modified_holds">
112
                            <th>Title</th>
112
                        <thead>
113
                            <th>Patron</th>
114
                            <th>Pickup location</th>
115
                            <th>Priority</th>
116
                            <th>Expiration date</th>
117
                            <th>Status</th>
118
                            <th>Suspended</th>
119
                            <th>Suspended until</th>
120
                            <th>Notes</th>
121
                            <!-- Add other columns as needed -->
122
                        </tr>
123
                    </thead>
124
                    <tbody>
125
                        [% FOREACH hold IN updated_holds_obj %]
126
                            <tr>
113
                            <tr>
127
                                <td>[% INCLUDE 'biblio-title.inc' biblio=hold.biblio link = 1 %]</td>
114
                                <th>Title</th>
128
                                <td>[% INCLUDE 'patron-title.inc' invert_name=1 patron=hold.borrower hide_patron_infos_if_needed=1 link_to="circulation_reserves" %]</td>
115
                                <th>Patron</th>
129
                                <td>[% hold.branch.branchname | html %]</td>
116
                                <th>Pickup location</th>
130
                                <td>[% hold.priority | html %]</td>
117
                                <th>Priority</th>
131
                                <td>[% hold.expirationdate | $KohaDates %]</td>
118
                                <th>Expiration date</th>
132
                                <td>
119
                                <th>Status</th>
133
                                    [% IF hold.found == 'F' %]
120
                                <th>Suspended</th>
134
                                        <span>Fulfilled</span>
121
                                <th>Suspended until</th>
135
                                    [% ELSIF hold.cancellationdate %]
122
                                <th>Notes</th>
136
                                        <span>Cancelled</span>
123
                                <th>Result</th>
137
                                    [% ELSIF hold.found == 'W' %]
124
                                <!-- Add other columns as needed -->
138
                                        [% IF hold.cancellation_requests.count == 0 %]
125
                            </tr>
139
                                            <span>Waiting</span>
126
                        </thead>
140
                                        [% ELSE %]
127
                        <tbody>
128
                            [% FOREACH hold IN updated_holds_obj %]
129
                                <tr>
130
                                    <td>[% INCLUDE 'biblio-title.inc' biblio=hold.biblio link = 1 %]</td>
131
                                    <td>[% INCLUDE 'patron-title.inc' invert_name=1 patron=hold.borrower hide_patron_infos_if_needed=1 link_to="circulation_reserves" %]</td>
132
                                    <td>[% hold.branch.branchname | html %]</td>
133
                                    <td>[% hold.priority | html %]</td>
134
                                    <td>[% hold.expirationdate | $KohaDates %]</td>
135
                                    <td>
136
                                        [% IF hold.found == 'F' %]
137
                                            <span>Fulfilled</span>
138
                                        [% ELSIF hold.cancellationdate %]
141
                                            <span>Cancelled</span>
139
                                            <span>Cancelled</span>
140
                                        [% ELSIF hold.found == 'W' %]
141
                                            [% IF hold.cancellation_requests.count == 0 %]
142
                                                <span>Waiting</span>
143
                                            [% ELSE %]
144
                                                <span>Cancelled</span>
145
                                            [% END %]
146
                                        [% ELSIF hold.found == 'T' %]
147
                                            <span>In transit</span>
148
                                        [% ELSE %]
149
                                            <span>Pending</span>
142
                                        [% END %]
150
                                        [% END %]
143
                                    [% ELSIF hold.found == 'T' %]
151
                                    </td>
144
                                        <span>In transit</span>
152
                                    <td>[% IF hold.suspend %]Yes[% ELSE %]No[% END %]</td>
145
                                    [% ELSE %]
153
                                    <td>[% IF hold.suspend_until %][% hold.suspend_until | $KohaDates %][% ELSE %]-[% END %]</td>
146
                                        <span>Pending</span>
154
                                    <td>[% hold.reservenotes | html %]</td>
147
                                    [% END %]
155
                                    <td><span class="badge rounded-pill bg-success">Success</span></td>
148
                                </td>
156
                                </tr>
149
                                <td>[% IF hold.suspend %]Yes[% ELSE %]No[% END %]</td>
157
                            [% END %]
150
                                <td>[% IF hold.suspend_until %][% hold.suspend_until | $KohaDates %][% ELSE %]-[% END %]</td>
158
                        </tbody>
151
                                <td>[% hold.reservenotes | html %]</td>
159
                    </table>
160
                </div>
161
                <!-- /#modified_holds_results -->
162
            </div>
163
            <!-- /#modified_holds_results-wrapper -->
164
        [% END %]
165
        [% IF failed_holds_obj %]
166
            <div id="failed_holds_results-wrapper">
167
                <div id="failed_holds_results" class="page-section">
168
                    <h2>Failed holds ([% total_failed | html %])</h2>
169
                    <div class="alert alert-warning">Important: The following holds were not modified.</div>
170
                    <table id="failed_holds">
171
                        <thead>
172
                            <tr>
173
                                <th>Title</th>
174
                                <th>Patron</th>
175
                                <th>Pickup location</th>
176
                                <th>Priority</th>
177
                                <th>Expiration date</th>
178
                                <th>Status</th>
179
                                <th>Suspended</th>
180
                                <th>Suspended until</th>
181
                                <th>Notes</th>
182
                                <th>Result</th>
183
                                <!-- Add other columns as needed -->
152
                            </tr>
184
                            </tr>
153
                        [% END %]
185
                        </thead>
154
                    </tbody>
186
                        <tbody>
155
                </table>
187
                            [% FOREACH failure IN failed_holds_obj %]
188
                                [% SET hold = failure.hold %]
189
                                <tr>
190
                                    <td>[% INCLUDE 'biblio-title.inc' biblio=hold.biblio link = 1 %]</td>
191
                                    <td>[% INCLUDE 'patron-title.inc' invert_name=1 patron=hold.borrower hide_patron_infos_if_needed=1 link_to="circulation_reserves" %]</td>
192
                                    <td>[% hold.branch.branchname | html %]</td>
193
                                    <td>[% hold.priority | html %]</td>
194
                                    <td>[% hold.expirationdate | $KohaDates %]</td>
195
                                    <td>
196
                                        [% IF hold.found == 'F' %]
197
                                            <span>Fulfilled</span>
198
                                        [% ELSIF hold.cancellationdate %]
199
                                            <span>Cancelled</span>
200
                                        [% ELSIF hold.found == 'W' %]
201
                                            [% IF hold.cancellation_requests.count == 0 %]
202
                                                <span>Waiting</span>
203
                                            [% ELSE %]
204
                                                <span>Cancelled</span>
205
                                            [% END %]
206
                                        [% ELSIF hold.found == 'T' %]
207
                                            <span>In transit</span>
208
                                        [% ELSE %]
209
                                            <span>Pending</span>
210
                                        [% END %]
211
                                    </td>
212
                                    <td>[% IF hold.suspend %]Yes[% ELSE %]No[% END %]</td>
213
                                    <td>[% IF hold.suspend_until %][% hold.suspend_until | $KohaDates %][% ELSE %]-[% END %]</td>
214
                                    <td>[% hold.reservenotes | html %]</td>
215
                                    <td>
216
                                        <span class="badge rounded-pill bg-warning text-dark">Failed</span>
217
                                        [% IF failure.reason == 'pickupLocationNotAllowed' %]
218
                                            New pickup location is invalid
219
                                        [% END %]
220
                                    </td>
221
                                </tr>
222
                            [% END %]
223
                        </tbody>
224
                    </table>
225
                </div>
226
                <!-- /#failed_holds_results -->
156
            </div>
227
            </div>
157
            <!-- /#modified_holds_results -->
228
            <!-- /#failed_holds_results-wrapper -->
158
            <fieldset class="action">
229
        [% END %]
159
                <a href="/cgi-bin/koha/tools/batch_modify_holds.pl">Return to batch hold modification</a>
230
        <fieldset class="action">
160
            </fieldset>
231
            <a href="/cgi-bin/koha/tools/batch_modify_holds.pl">Return to batch hold modification</a>
161
        </div>
232
        </fieldset>
162
        <!-- /#modified_holds_results-wrapper -->
163
    [% END %]
233
    [% END %]
164
    <div id="modify_holds_results-wrapper" style="display:none;">
234
    <div id="modify_holds_results-wrapper" style="display:none;">
165
        <div id="toolbar" class="btn-toolbar">
235
        <div id="toolbar" class="btn-toolbar">
Lines 642-653 Link Here
642
                return true;
712
                return true;
643
            });
713
            });
644
714
645
            //Modified holds table
715
            //Modified holds table and failed holds table share table settings
646
            var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %];
716
            var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %];
647
            $("#modified_holds").kohaTable({
717
            [% IF updated_holds_obj  %]
648
                pagingType: "full",
718
                $("#modified_holds").kohaTable({
649
                autoWidth: false
719
                    pagingType: "full",
650
            }, table_settings);
720
                    autoWidth: false
721
                }, table_settings);
722
            [% END %]
723
            [% IF failed_holds_obj  %]
724
                $("#failed_holds").kohaTable({
725
                    pagingType: "full",
726
                    autoWidth: false
727
                }, table_settings);
728
            [% END %]
651
729
652
        });
730
        });
653
    </script>
731
    </script>
(-)a/tools/batch_modify_holds.pl (-23 / +49 lines)
Lines 59-110 if ( $op eq 'cud-form' ) { Link Here
59
    my $clear_hold_notes    = $input->param('clear_hold_notes');
59
    my $clear_hold_notes    = $input->param('clear_hold_notes');
60
60
61
    @hold_ids = $input->multi_param('hold_id');
61
    @hold_ids = $input->multi_param('hold_id');
62
    my @holds_data = ();
62
    my @holds_data   = ();
63
    my @failed_holds = ();
63
64
64
    my $holds_to_update =
65
    my $holds_to_update =
65
        Koha::Holds->search( { reserve_id => { -in => \@hold_ids } }, { join => [ "item", "biblio" ] } );
66
        Koha::Holds->search( { reserve_id => { -in => \@hold_ids } }, { join => [ "item", "biblio" ] } );
66
67
67
    while ( my $hold = $holds_to_update->next ) {
68
    while ( my $hold = $holds_to_update->next ) {
69
        my $hold_failed = 0;
70
        if ( $new_pickup_loc && ( $hold->branchcode ne $new_pickup_loc ) ) {
71
            my $patron = $hold->patron;
72
            my $item   = $hold->item;
73
            my $locations;
68
74
69
        if ($new_expiration_date) {
75
            if ($item) {
70
            $hold->expirationdate($new_expiration_date)->store;
76
71
        }
77
                #item level pickup location allowed?
78
                $locations = $item->pickup_locations( { patron => $patron } );
79
            } else {
80
81
                #record level pickup location allowed?
82
                $locations = $hold->biblio->pickup_locations( { patron => $patron } );
83
            }
84
85
            unless ( $locations->search( { branchcode => $new_pickup_loc } )->count ) {
86
                push @failed_holds, { hold => $hold, reason => 'pickupLocationNotAllowed' };
87
                $hold_failed = 1;
88
                next;
89
            }
72
90
73
        if ( $new_pickup_loc && ( $hold->branchcode ne $new_pickup_loc ) ) {
74
            $hold->branchcode($new_pickup_loc)->store;
91
            $hold->branchcode($new_pickup_loc)->store;
75
        }
92
        }
76
93
77
        if ( $new_suspend_status ne "" ) {
94
        #only continue to update the hold if it hasn't failed
78
            if ( $new_suspend_status && !$hold->is_found ) {
95
        unless ($hold_failed) {
79
                $hold->suspend(1)->store;
96
            if ( $new_suspend_status ne "" ) {
80
                if ($new_suspend_date) {
97
                if ( $new_suspend_status && !$hold->is_found ) {
98
                    $hold->suspend(1)->store;
99
                    if ($new_suspend_date) {
100
                        $hold->suspend_until($new_suspend_date)->store;
101
                    } else {
102
                        $hold->suspend_until(undef)->store;
103
                    }
104
                } elsif ( !$new_suspend_status && $new_suspend_date ) {
105
                    $hold->suspend(1)->store;
81
                    $hold->suspend_until($new_suspend_date)->store;
106
                    $hold->suspend_until($new_suspend_date)->store;
82
                } else {
107
                } else {
108
                    $hold->suspend(0)->store;
83
                    $hold->suspend_until(undef)->store;
109
                    $hold->suspend_until(undef)->store;
84
                }
110
                }
85
            } elsif ( !$new_suspend_status && $new_suspend_date ) {
86
                $hold->suspend(1)->store;
87
                $hold->suspend_until($new_suspend_date)->store;
88
            } else {
89
                $hold->suspend(0)->store;
90
                $hold->suspend_until(undef)->store;
91
            }
111
            }
92
        }
93
112
94
        if ($new_hold_note) {
113
            if ($new_expiration_date) {
95
            $hold->reservenotes($new_hold_note)->store;
114
                $hold->expirationdate($new_expiration_date)->store;
96
        }
115
            }
116
117
            if ($new_hold_note) {
118
                $hold->reservenotes($new_hold_note)->store;
119
            }
120
121
            if ($clear_hold_notes) {
122
                $hold->reservenotes(undef)->store;
123
            }
97
124
98
        if ($clear_hold_notes) {
125
            push @holds_data, $hold;
99
            $hold->reservenotes(undef)->store;
100
        }
126
        }
101
        push @holds_data, $hold;
102
    }
127
    }
103
128
104
    $template->param(
129
    $template->param(
105
        updated_holds     => to_json( \@hold_ids ),
130
        updated_holds     => to_json( \@hold_ids ),
106
        updated_holds_obj => \@holds_data,
131
        updated_holds_obj => \@holds_data,
132
        failed_holds_obj  => \@failed_holds,
107
        total_updated     => scalar @holds_data,
133
        total_updated     => scalar @holds_data,
134
        total_failed      => scalar @failed_holds,
108
        view              => 'report',
135
        view              => 'report',
109
    );
136
    );
110
137
111
- 

Return to bug 41882