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

(-)a/Koha/Illrequest.pm (+16 lines)
Lines 527-532 sub mark_completed { Link Here
527
    };
527
    };
528
}
528
}
529
529
530
=head2 backend_migrate
531
532
Migrate a request from one backend to another.
533
534
=cut
535
536
sub backend_migrate {
537
    my ( $self, $params ) = @_;
538
539
    my $response = $self->_backend->migrate({
540
            request    => $self,
541
            other      => $params,
542
        });
543
    return $self->expandTemplate($response);
544
}
545
530
=head2 backend_confirm
546
=head2 backend_confirm
531
547
532
Confirm a request. The backend handles setting of mandatory fields in the commit stage:
548
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 282-297 output_html_with_http_headers( $cgi, $cookie, $template->output ); Link Here
282
304
283
sub handle_commit_maybe {
305
sub handle_commit_maybe {
284
    my ( $backend_result, $request ) = @_;
306
    my ( $backend_result, $request ) = @_;
307
285
    # We need to special case 'commit'
308
    # We need to special case 'commit'
286
    if ( $backend_result->{stage} eq 'commit' ) {
309
    if ( $backend_result->{stage} eq 'commit' ) {
287
        if ( $backend_result->{next} eq 'illview' ) {
310
        if ( $backend_result->{next} eq 'illview' ) {
311
288
            # Redirect to a view of the newly created request
312
            # Redirect to a view of the newly created request
289
            print $cgi->redirect(
313
            print $cgi->redirect( '/cgi-bin/koha/ill/ill-requests.pl'
290
                '/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id='.
314
                  . '?method=illview'
291
                $request->id
315
                  . '&illrequest_id='
292
            );
316
                  . $request->id );
293
            exit;
317
            exit;
294
        } else {
318
        }
319
        elsif ( $backend_result->{next} eq 'emigrate' ) {
320
321
            # Redirect to a view of the newly created request
322
            print $cgi->redirect( '/cgi-bin/koha/ill/ill-requests.pl'
323
                  . '?method=migrate'
324
                  . '&stage=emigrate'
325
                  . '&illrequest_id='
326
                  . $request->id );
327
            exit;
328
        }
329
        else {
295
            # Redirect to a requests list view
330
            # Redirect to a requests list view
296
            redirect_to_list();
331
            redirect_to_list();
297
        }
332
        }
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (-3 / +26 lines)
Lines 506-513 Link Here
506
                        Edit request
506
                        Edit request
507
                        </a>
507
                        </a>
508
                        [% FOREACH action IN request.available_actions %]
508
                        [% FOREACH action IN request.available_actions %]
509
                            [% IF action.method != 0 %]
509
                            [% IF action.method == 'migrate' %]
510
                                <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 %]">
510
                                [% IF backends.size > 2 %]
511
                                    <div class="dropdown btn-group">
512
                                        <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-migrate-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
513
                                            <i class="fa [% action.ui_method_icon | html %]"></i> [% action.ui_method_name | html %] <span class="caret"></span>
514
                                        </button>
515
                                        <ul class="dropdown-menu" aria-labelledby="ill-migrate-dropdown">
516
                                            [% FOREACH backend IN backends %]
517
                                                [% IF backend != request.backend %]
518
                                                    <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>
519
                                                [% END %]
520
                                            [% END %]
521
                                        </ul>
522
                                    </div>
523
                                [% ELSIF backends.size == 2 %]
524
                                    [% FOREACH backend IN backends %]
525
                                        [% IF backend != request.backend %]
526
                                            <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 %]">
527
                                            <span class="fa [% action.ui_method_icon | html %]"></span>
528
                                            [% action.ui_method_name | html %]
529
                                            </a>
530
                                        [% END %]
531
                                    [% END %]
532
                                [% END %]
533
                            [% ELSIF action.method != 0 %]
534
                                <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 %]">
511
                                <span class="fa [% action.ui_method_icon | html %]"></span>
535
                                <span class="fa [% action.ui_method_icon | html %]"></span>
512
                                [% action.ui_method_name | html %]
536
                                [% action.ui_method_name | html %]
513
                                </a>
537
                                </a>
514
- 

Return to bug 20640