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

(-)a/Koha/Illrequest.pm (+16 lines)
Lines 515-520 sub mark_completed { Link Here
515
    };
515
    };
516
}
516
}
517
517
518
=head2 backend_migrate
519
520
Migrate a request from one backend to another.
521
522
=cut
523
524
sub backend_migrate {
525
    my ( $self, $params ) = @_;
526
527
    my $response = $self->_backend->migrate({
528
            request    => $self,
529
            other      => $params,
530
        });
531
    return $self->expandTemplate($response);
532
}
533
518
=head2 backend_confirm
534
=head2 backend_confirm
519
535
520
Confirm a request. The backend handles setting of mandatory fields in the commit stage:
536
Confirm a request. The backend handles setting of mandatory fields in the commit stage:
(-)a/ill/ill-requests.pl (-5 / +40 lines)
Lines 81-86 if ( $backends_available ) { Link Here
81
        );
81
        );
82
        handle_commit_maybe($backend_result, $request);
82
        handle_commit_maybe($backend_result, $request);
83
83
84
    } elsif ( $op eq 'migrate' ) {
85
        # We're in the process of migrating a request
86
        my $request = Koha::Illrequests->find($params->{illrequest_id});
87
        my $backend_result;
88
        if ( $params->{backend} ) {
89
            my $new_request = Koha::Illrequest->new->load_backend( $params->{backend} );
90
            $backend_result = $new_request->backend_migrate($params);
91
            $template->param(
92
                whole   => $backend_result,
93
                request => $new_request
94
            );
95
        }
96
        else {
97
            $request = Koha::Illrequests->find( $params->{illrequest_id} );
98
            $backend_result = $request->backend_migrate($params);
99
            $template->param(
100
                whole   => $backend_result,
101
                request => $request
102
            );
103
        }
104
        handle_commit_maybe( $backend_result, $request );
105
84
    } elsif ( $op eq 'confirm' ) {
106
    } elsif ( $op eq 'confirm' ) {
85
        # Backend 'confirm' method
107
        # Backend 'confirm' method
86
        # confirm requires a specific request, so first, find it.
108
        # confirm requires a specific request, so first, find it.
Lines 264-279 output_html_with_http_headers( $cgi, $cookie, $template->output ); Link Here
264
286
265
sub handle_commit_maybe {
287
sub handle_commit_maybe {
266
    my ( $backend_result, $request ) = @_;
288
    my ( $backend_result, $request ) = @_;
289
267
    # We need to special case 'commit'
290
    # We need to special case 'commit'
268
    if ( $backend_result->{stage} eq 'commit' ) {
291
    if ( $backend_result->{stage} eq 'commit' ) {
269
        if ( $backend_result->{next} eq 'illview' ) {
292
        if ( $backend_result->{next} eq 'illview' ) {
293
270
            # Redirect to a view of the newly created request
294
            # Redirect to a view of the newly created request
271
            print $cgi->redirect(
295
            print $cgi->redirect( '/cgi-bin/koha/ill/ill-requests.pl'
272
                '/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id='.
296
                  . '?method=illview'
273
                $request->id
297
                  . '&illrequest_id='
274
            );
298
                  . $request->id );
275
            exit;
299
            exit;
276
        } else {
300
        }
301
        elsif ( $backend_result->{next} eq 'emigrate' ) {
302
303
            # Redirect to a view of the newly created request
304
            print $cgi->redirect( '/cgi-bin/koha/ill/ill-requests.pl'
305
                  . '?method=migrate'
306
                  . '&stage=emigrate'
307
                  . '&illrequest_id='
308
                  . $request->id );
309
            exit;
310
        }
311
        else {
277
            # Redirect to a requests list view
312
            # Redirect to a requests list view
278
            redirect_to_list();
313
            redirect_to_list();
279
        }
314
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (-3 / +26 lines)
Lines 492-499 Link Here
492
                        Edit request
492
                        Edit request
493
                        </a>
493
                        </a>
494
                        [% FOREACH action IN request.available_actions %]
494
                        [% FOREACH action IN request.available_actions %]
495
                            [% IF action.method != 0 %]
495
                            [% IF action.method == 'migrate' %]
496
                                <a title="[% action.ui_method_name | html %]" id="ill-toolbar-btn-[% action.id | lower | html %]" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method | html %]&amp;illrequest_id=[% request.illrequest_id | html %]">
496
                                [% IF backends.size > 2 %]
497
                                    <div class="dropdown btn-group">
498
                                        <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-migrate-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
499
                                            <i class="fa [% action.ui_method_icon | html %]"></i> [% action.ui_method_name | html %] <span class="caret"></span>
500
                                        </button>
501
                                        <ul class="dropdown-menu" aria-labelledby="ill-migrate-dropdown">
502
                                            [% FOREACH backend IN backends %]
503
                                                [% IF backend != request.backend %]
504
                                                    <li><a href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method | uri %]&amp;illrequest_id=[% request.illrequest_id | uri %]&amp;backend=[% backend | uri %]">[% backend | html %]</a></li>
505
                                                [% END %]
506
                                            [% END %]
507
                                        </ul>
508
                                    </div>
509
                                [% ELSIF backends.size == 2 %]
510
                                    [% FOREACH backend IN backends %]
511
                                        [% IF backend != request.backend %]
512
                                            <a title="[% action.ui_method_name | html %]" id="ill-toolbar-btn-[% action.id | lower | html %]" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method | uri %]&amp;illrequest_id=[% request.illrequest_id | uri %]">
513
                                            <span class="fa [% action.ui_method_icon | html %]"></span>
514
                                            [% action.ui_method_name | html %]
515
                                            </a>
516
                                        [% END %]
517
                                    [% END %]
518
                                [% END %]
519
                            [% ELSIF action.method != 0 %]
520
                                <a title="[% action.ui_method_name | html %]" id="ill-toolbar-btn-[% action.id | lower | html %]" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=[% action.method | uri %]&amp;illrequest_id=[% request.illrequest_id | uri %]">
497
                                <span class="fa [% action.ui_method_icon | html %]"></span>
521
                                <span class="fa [% action.ui_method_icon | html %]"></span>
498
                                [% action.ui_method_name | html %]
522
                                [% action.ui_method_name | html %]
499
                                </a>
523
                                </a>
500
- 

Return to bug 20640