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

(-)a/Koha/Hold.pm (+41 lines)
Lines 178-183 sub delete { Link Here
178
    return $deleted;
178
    return $deleted;
179
}
179
}
180
180
181
=head3 move_hold_item
182
183
$hold->move_hold_item();
184
185
=cut
186
187
sub move_hold_item {
188
    my ( $self, $args ) = @_;
189
190
    my $new_itemnumber   = $args->{new_itemnumber};
191
    my $new_biblionumber = $args->{new_biblionumber};
192
    my $original         = $self;
193
194
    my $patron   = Koha::Patrons->find( { borrowernumber => $self->borrowernumber } );
195
    my $new_item = Koha::Items->find( { itemnumber => $new_itemnumber } );
196
197
    if ($new_itemnumber) {
198
199
        #check to see if moving this hold is allowed
200
        my $canReserve =
201
            C4::Reserves::CanItemBeReserved( $patron, $new_item, $self->branchcode, { ignore_hold_counts => 1 } );
202
203
        if ( $canReserve->{status} eq 'OK' ) {
204
            $self->update(
205
                {
206
                    itemnumber   => $new_item->itemnumber,
207
                    biblionumber => $new_item->biblionumber
208
                }
209
            );
210
211
            C4::Log::logaction( 'HOLDS', 'MODIFY', $self->reserve_id, $self, undef, $original )
212
                if C4::Context->preference('HoldsLog');
213
214
            return { success => 1, hold => $self };
215
        } else {
216
            return { success => 0, error => $canReserve->{status} };
217
        }
218
    }
219
    return $self;
220
}
221
181
=head3 set_transfer
222
=head3 set_transfer
182
223
183
=cut
224
=cut
(-)a/reserve/request.pl (-3 / +46 lines)
Lines 44-49 use C4::Search qw( enabled_staff_search_views ); Link Here
44
use Koha::Biblios;
44
use Koha::Biblios;
45
use Koha::Checkouts;
45
use Koha::Checkouts;
46
use Koha::Holds;
46
use Koha::Holds;
47
use Koha::Hold;
47
use Koha::CirculationRules;
48
use Koha::CirculationRules;
48
use Koha::Items;
49
use Koha::Items;
49
use Koha::ItemTypes;
50
use Koha::ItemTypes;
Lines 90-95 my $exceeded_maxreserves; Link Here
90
my $exceeded_holds_per_record;
91
my $exceeded_holds_per_record;
91
my @failed_holds   = $input->multi_param('failed_holds');
92
my @failed_holds   = $input->multi_param('failed_holds');
92
my $form_submitted = $input->param('form_submitted');
93
my $form_submitted = $input->param('form_submitted');
94
my @biblionumbers  = $input->multi_param('biblionumber');
93
95
94
my $op = $input->param('op') || q{};
96
my $op = $input->param('op') || q{};
95
97
Lines 109-114 if ( $op eq 'cud-move' ) { Link Here
109
            $next_priority, $first_priority, $last_priority
111
            $next_priority, $first_priority, $last_priority
110
        );
112
        );
111
    }
113
    }
114
} elsif ( $op eq 'cud-move_hold_item' ) {
115
    my $new_itemnumber   = $input->param('new_itemnumber');
116
    my $new_biblionumber = $input->param('new_biblionumber');
117
    my $target_biblio    = Koha::Biblios->find($new_biblionumber);
118
    my @hold_ids         = $input->multi_param('hold_id');
119
120
    my @success_messages;
121
    my @error_messages;
122
123
    foreach my $hold_id (@hold_ids) {
124
        my $hold            = Koha::Holds->find($hold_id);
125
        my $original_biblio = Koha::Biblios->find( $hold->biblionumber );
126
        my $result          = $hold->move_hold_item(
127
            {
128
                new_itemnumber   => $new_itemnumber,
129
                new_biblionumber => $new_biblionumber,
130
            }
131
        );
132
133
        #push info about successes and errors to the template
134
        if ( $result->{success} ) {
135
            push @success_messages, {
136
                hold_id         => $hold_id,
137
                success         => 1,
138
                original_biblio => $original_biblio,
139
                target_biblio   => $target_biblio,
140
            };
141
        } else {
142
            push @error_messages, {
143
                hold_id         => $hold_id,
144
                success         => 0,
145
                original_biblio => $original_biblio,
146
                target_biblio   => $target_biblio,
147
                error           => $result->{error},
148
            };
149
        }
150
    }
151
152
    push @biblionumbers, $new_biblionumber;
153
154
    $template->param(
155
        hold_move_successes => \@success_messages,
156
        hold_move_failures  => \@error_messages,
157
    );
112
} elsif ( $op eq 'cud-cancel' ) {
158
} elsif ( $op eq 'cud-cancel' ) {
113
    my $reserve_id          = $input->param('reserve_id');
159
    my $reserve_id          = $input->param('reserve_id');
114
    my $cancellation_reason = $input->param("cancellation-reason");
160
    my $cancellation_reason = $input->param("cancellation-reason");
Lines 172-179 if ($form_submitted) { Link Here
172
    }
218
    }
173
}
219
}
174
220
175
my @biblionumbers = $input->multi_param('biblionumber');
176
177
my $multi_hold = @biblionumbers > 1;
221
my $multi_hold = @biblionumbers > 1;
178
$template->param(
222
$template->param(
179
    multi_hold => $multi_hold,
223
    multi_hold => $multi_hold,
180
- 

Return to bug 31698