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

(-)a/Koha/ILL/Backend/Standard.pm (-27 / +78 lines)
Lines 276-284 sub create { Link Here
276
        }
276
        }
277
277
278
        # Received completed details of form.  Validate and create request.
278
        # Received completed details of form.  Validate and create request.
279
        ## Validate
280
        my ( $brw_count, $brw ) =
281
            _validate_borrower( $other->{'cardnumber'} );
282
        my $result = {
279
        my $result = {
283
            cwd     => dirname(__FILE__),
280
            cwd     => dirname(__FILE__),
284
            status  => "",
281
            status  => "",
Lines 290-320 sub create { Link Here
290
            core    => $core_fields
287
            core    => $core_fields
291
        };
288
        };
292
        my $failed = 0;
289
        my $failed = 0;
293
        if ( !$other->{'type'} ) {
290
294
            $result->{status} = "missing_type";
291
        my $unauthenticated_request =
295
            $result->{value}  = $params;
292
            C4::Context->preference("ILLOpacUnauthenticatedRequest") && !$other->{'cardnumber'};
296
            $failed           = 1;
293
        if ($unauthenticated_request) {
297
        } elsif ( !$other->{'branchcode'} ) {
294
            ( $failed, $result ) = _validate_form_params( $other, $result, $params );
298
            $result->{status} = "missing_branch";
295
            if ( !_unauth_request_data_check($other) ) {
299
            $result->{value}  = $params;
296
                $result->{status} = "missing_unauth_data";
300
            $failed           = 1;
297
                $result->{value}  = $params;
301
        } elsif ( !Koha::Libraries->find( $other->{'branchcode'} ) ) {
298
                $failed           = 1;
302
            $result->{status} = "invalid_branch";
299
            }
303
            $result->{value}  = $params;
300
        } else {
304
            $failed           = 1;
301
            ( $failed, $result ) = _validate_form_params( $other, $result, $params );
305
        } elsif ( $brw_count == 0 ) {
302
306
            $result->{status} = "invalid_borrower";
303
            my ( $brw_count, $brw ) =
307
            $result->{value}  = $params;
304
                _validate_borrower( $other->{'cardnumber'} );
308
            $failed           = 1;
305
309
        } elsif ( $brw_count > 1 ) {
306
            if ( $brw_count == 0 ) {
310
307
                $result->{status} = "invalid_borrower";
311
            # We must select a specific borrower out of our options.
308
                $result->{value}  = $params;
312
            $params->{brw}   = $brw;
309
                $failed           = 1;
313
            $result->{value} = $params;
310
            } elsif ( $brw_count > 1 ) {
314
            $result->{stage} = "borrowers";
311
315
            $result->{error} = 0;
312
                # We must select a specific borrower out of our options.
316
            $failed          = 1;
313
                $params->{brw}   = $brw;
314
                $result->{value} = $params;
315
                $result->{stage} = "borrowers";
316
                $result->{error} = 0;
317
                $failed          = 1;
318
            }
317
        }
319
        }
320
318
        return $result if $failed;
321
        return $result if $failed;
319
322
320
        $self->add_request( { request => $params->{request}, other => $other } );
323
        $self->add_request( { request => $params->{request}, other => $other } );
Lines 1221-1226 sub _set_suppression { Link Here
1221
    return 1;
1224
    return 1;
1222
}
1225
}
1223
1226
1227
=head3 _unauth_request_data_check
1228
1229
    _unauth_request_data_check($other);
1230
1231
Checks if unauthenticated request data is present
1232
1233
=cut
1234
1235
sub _unauth_request_data_check {
1236
    my ($other) = @_;
1237
1238
    return 1 unless C4::Context->preference("ILLOpacUnauthenticatedRequest");
1239
1240
    return
1241
           $other->{unauthenticated_first_name}
1242
        && $other->{unauthenticated_last_name}
1243
        && $other->{unauthenticated_email};
1244
}
1245
1246
=head3 _validate_form_params
1247
1248
    _validate_form_params( $other, $result, $params );
1249
1250
Validate form parameters and return the validation result
1251
1252
=cut
1253
1254
sub _validate_form_params {
1255
    my ( $other, $result, $params ) = @_;
1256
1257
    my $failed = 0;
1258
    if ( !$other->{'type'} ) {
1259
        $result->{status} = "missing_type";
1260
        $result->{value}  = $params;
1261
        $failed           = 1;
1262
    } elsif ( !$other->{'branchcode'} ) {
1263
        $result->{status} = "missing_branch";
1264
        $result->{value}  = $params;
1265
        $failed           = 1;
1266
    } elsif ( !Koha::Libraries->find( $other->{'branchcode'} ) ) {
1267
        $result->{status} = "invalid_branch";
1268
        $result->{value}  = $params;
1269
        $failed           = 1;
1270
    }
1271
1272
    return ( $failed, $result );
1273
}
1274
1224
=head1 AUTHORS
1275
=head1 AUTHORS
1225
1276
1226
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
1277
Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
(-)a/Koha/ILL/Backend/opac-includes/create.inc (-1 / +4 lines)
Lines 11-16 Link Here
11
    <div class="alert alert-warning">
11
    <div class="alert alert-warning">
12
        <strong>Please note:</strong> Type is a mandatory field.
12
        <strong>Please note:</strong> Type is a mandatory field.
13
    </div>
13
    </div>
14
[% ELSIF whole.status == 'missing_unauth_data' %]
15
    <div class="alert alert-warning">
16
        <strong>Please note:</strong> Patron data (first name, last name and e-mail) are mandatory fields.
17
    </div>
14
[% ELSIF whole.status == 'missing_branch' %]
18
[% ELSIF whole.status == 'missing_branch' %]
15
    <div class="alert alert-warning">
19
    <div class="alert alert-warning">
16
        <strong>Please note:</strong> Library is a mandatory field.
20
        <strong>Please note:</strong> Library is a mandatory field.
17
- 

Return to bug 36197