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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt (+62 lines)
Lines 106-111 Link Here
106
        <h1>Modified holds</h1>
106
        <h1>Modified holds</h1>
107
        <div id="modified_holds_results-wrapper">
107
        <div id="modified_holds_results-wrapper">
108
            <div id="modified_holds_results" class="page-section">
108
            <div id="modified_holds_results" class="page-section">
109
                <h2>Holds updated</h2>
109
                <table id="modified_holds">
110
                <table id="modified_holds">
110
                    <thead>
111
                    <thead>
111
                        <tr>
112
                        <tr>
Lines 154-159 Link Here
154
                    </tbody>
155
                    </tbody>
155
                </table>
156
                </table>
156
            </div>
157
            </div>
158
            [% IF failed_holds_obj.size %]
159
                <div id="failed_holds_results" class="page-section">
160
                    <h2>Holds not updated</h2>
161
                    <table id="failed_holds">
162
                        <thead>
163
                            <tr>
164
                                <th>Title</th>
165
                                <th>Patron</th>
166
                                <th>Pickup location</th>
167
                                <th>Priority</th>
168
                                <th>Expiration date</th>
169
                                <th>Status</th>
170
                                <th>Suspended</th>
171
                                <th>Suspended until</th>
172
                                <th>Notes</th>
173
                            </tr>
174
                        </thead>
175
                        <tbody>
176
                            [% FOREACH failure IN failed_holds_obj %]
177
                                [% SET hold = failure.hold %]
178
                                <tr>
179
                                    <td>
180
                                        [% INCLUDE 'biblio-title.inc' biblio=hold.biblio link = 1 %]
181
                                        <div class="alert alert-warning">[% failure.reason %]</div>
182
                                    </td>
183
                                    <td>[% INCLUDE 'patron-title.inc' invert_name=1 patron=hold.borrower hide_patron_infos_if_needed=1 link_to="circulation_reserves" %]</td>
184
                                    <td>[% hold.branch.branchname | html %]</td>
185
                                    <td>[% hold.priority | html %]</td>
186
                                    <td>[% hold.expirationdate | $KohaDates %]</td>
187
                                    <td>
188
                                        [% IF hold.found == 'F' %]
189
                                            <span>Fulfilled</span>
190
                                        [% ELSIF hold.cancellationdate %]
191
                                            <span>Cancelled</span>
192
                                        [% ELSIF hold.found == 'W' %]
193
                                            [% IF hold.cancellation_requests.count == 0 %]
194
                                                <span>Waiting</span>
195
                                            [% ELSE %]
196
                                                <span>Cancelled</span>
197
                                            [% END %]
198
                                        [% ELSIF hold.found == 'T' %]
199
                                            <span>In transit</span>
200
                                        [% ELSE %]
201
                                            <span>Pending</span>
202
                                        [% END %]
203
                                    </td>
204
                                    <td>[% IF hold.suspend %]Yes[% ELSE %]No[% END %]</td>
205
                                    <td>[% IF hold.suspend_until %][% hold.suspend_until | $KohaDates %][% ELSE %]-[% END %]</td>
206
                                    <td>[% hold.reservenotes | html %]</td>
207
                                </tr>
208
                            [% END %]
209
                        </tbody>
210
                    </table>
211
                </div>
212
            [% END %]
157
            <!-- /#modified_holds_results -->
213
            <!-- /#modified_holds_results -->
158
            <fieldset class="action">
214
            <fieldset class="action">
159
                <a href="/cgi-bin/koha/tools/batch_modify_holds.pl">Return to batch hold modification</a>
215
                <a href="/cgi-bin/koha/tools/batch_modify_holds.pl">Return to batch hold modification</a>
Lines 648-653 Link Here
648
                pagingType: "full",
704
                pagingType: "full",
649
                autoWidth: false
705
                autoWidth: false
650
            }, table_settings);
706
            }, table_settings);
707
            [% IF failed_holds_obj.size %]
708
                $("#failed_holds").kohaTable({
709
                    pagingType: "full",
710
                    autoWidth: false
711
                }, table_settings);
712
            [% END %]
651
713
652
        });
714
        });
653
    </script>
715
    </script>
(-)a/tools/batch_modify_holds.pl (-3 / +40 lines)
Lines 28-33 use C4::Output qw( output_html_with_http_headers ); Link Here
28
28
29
use Koha::DateUtils qw( dt_from_string );
29
use Koha::DateUtils qw( dt_from_string );
30
use Koha::Holds;
30
use Koha::Holds;
31
use Koha::Libraries;
32
use Koha::Policy::Holds;
33
use C4::Circulation qw( GetBranchItemRule );
31
34
32
my $input = CGI->new;
35
my $input = CGI->new;
33
my $op    = $input->param('op') // q|cud-form|;
36
my $op    = $input->param('op') // q|cud-form|;
Lines 59-65 if ( $op eq 'cud-form' ) { Link Here
59
    my $clear_hold_notes    = $input->param('clear_hold_notes');
62
    my $clear_hold_notes    = $input->param('clear_hold_notes');
60
63
61
    @hold_ids = $input->multi_param('hold_id');
64
    @hold_ids = $input->multi_param('hold_id');
62
    my @holds_data = ();
65
    my @holds_data   = ();
66
    my @failed_holds = ();
63
67
64
    my $holds_to_update =
68
    my $holds_to_update =
65
        Koha::Holds->search( { reserve_id => { -in => \@hold_ids } }, { join => [ "item", "biblio" ] } );
69
        Koha::Holds->search( { reserve_id => { -in => \@hold_ids } }, { join => [ "item", "biblio" ] } );
Lines 71-77 if ( $op eq 'cud-form' ) { Link Here
71
        }
75
        }
72
76
73
        if ( $new_pickup_loc && ( $hold->branchcode ne $new_pickup_loc ) ) {
77
        if ( $new_pickup_loc && ( $hold->branchcode ne $new_pickup_loc ) ) {
74
            $hold->branchcode($new_pickup_loc)->store;
78
79
            #check if the new pickup location is allowed
80
            my $pickup_allowed          = 1;
81
            my $item                    = $hold->item;
82
            my $patron                  = $hold->patron;
83
            my $branch                  = Koha::Policy::Holds->holds_control_library( $item, $patron );
84
            my $branchitemrule          = GetBranchItemRule( $branch, $item->effective_itemtype );
85
            my $hold_fulfillment_policy = $branchitemrule->{hold_fulfillment_policy};
86
            my $item_library            = Koha::Libraries->find( { branchcode => $item->homebranch } );
87
            my $reason;
88
89
            if ( $hold_fulfillment_policy eq 'holdgroup'
90
                && !$item_library->validate_hold_sibling( { branchcode => $new_pickup_loc } ) )
91
            {
92
                $pickup_allowed = 0;
93
                $reason         = "pickupNotInHoldGroup";
94
            } elsif ( ( $hold_fulfillment_policy eq 'homebranch' || $hold_fulfillment_policy eq 'holdingbranch' )
95
                && $new_pickup_loc ne $item->$hold_fulfillment_policy )
96
            {
97
                $pickup_allowed = 0;
98
                $reason = $hold_fulfillment_policy eq 'homebranch' ? 'pickupNotHomeLibrary' : 'pickupNotHoldingLibrary';
99
100
            } elsif ( !$item->can_be_transferred( { to => Koha::Libraries->find($new_pickup_loc) } ) ) {
101
                $pickup_allowed = 0;
102
                $reason         = 'cannotBeTransferred';
103
            }
104
105
            if ($pickup_allowed) {
106
                $hold->branchcode($new_pickup_loc)->store;
107
            } else {
108
                push @failed_holds, { hold => $hold, reason => $reason };
109
                next;
110
            }
75
        }
111
        }
76
112
77
        if ( $new_suspend_status ne "" ) {
113
        if ( $new_suspend_status ne "" ) {
Lines 104-110 if ( $op eq 'cud-form' ) { Link Here
104
    $template->param(
140
    $template->param(
105
        updated_holds     => to_json( \@hold_ids ),
141
        updated_holds     => to_json( \@hold_ids ),
106
        updated_holds_obj => \@holds_data,
142
        updated_holds_obj => \@holds_data,
143
        failed_holds_obj  => \@failed_holds,
107
        total_updated     => scalar @holds_data,
144
        total_updated     => scalar @holds_data,
145
        total_failed      => scalar @failed_holds,
108
        view              => 'report',
146
        view              => 'report',
109
    );
147
    );
110
148
111
- 

Return to bug 41882