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

(-)a/Koha/ILL/Request.pm (+49 lines)
Lines 1305-1310 sub get_type_disclaimer_value { Link Here
1305
    return $attr->value;
1305
    return $attr->value;
1306
}
1306
}
1307
1307
1308
=head3 set_copyright_clearance_confirmed
1309
1310
    $request->set_copyright_clearance_confirmed(1);
1311
1312
Sets the copyright clearance confirmation status for the request.
1313
1314
=cut
1315
1316
sub set_copyright_clearance_confirmed {
1317
    my ( $self, $confirmed ) = @_;
1318
1319
    # Normalize to boolean: 0 or 1
1320
    my $value = $confirmed ? 1 : 0;
1321
1322
    # Check if attribute already exists
1323
    my $existing_attr = $self->extended_attributes->find( { type => 'copyrightclearance_confirmed' } );
1324
1325
    if ($existing_attr) {
1326
1327
        # Update existing attribute
1328
        $existing_attr->value($value)->store;
1329
    } else {
1330
1331
        # Create new attribute
1332
        $self->extended_attributes(
1333
            [
1334
                {
1335
                    type  => 'copyrightclearance_confirmed',
1336
                    value => $value,
1337
                }
1338
            ]
1339
        );
1340
    }
1341
}
1342
1343
=head3 get_copyright_clearance_confirmed
1344
1345
    my $confirmed = $request->get_copyright_clearance_confirmed;
1346
1347
Returns 1 if copyright clearance has been confirmed, 0 otherwise.
1348
1349
=cut
1350
1351
sub get_copyright_clearance_confirmed {
1352
    my ($self) = @_;
1353
    my $attr = $self->extended_attributes->find( { type => 'copyrightclearance_confirmed' } );
1354
    return $attr ? ( $attr->value ? 1 : 0 ) : 0;
1355
}
1356
1308
=head3 get_type_disclaimer_date
1357
=head3 get_type_disclaimer_date
1309
1358
1310
    my $type = $abstract->type_disclaimer_date();
1359
    my $type = $abstract->type_disclaimer_date();
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt (-2 / +1 lines)
Lines 620-627 Link Here
620
                <div class="page-section">
620
                <div class="page-section">
621
                    <h3>Request details</h3>
621
                    <h3>Request details</h3>
622
                    <h4>Details from library</h4>
622
                    <h4>Details from library</h4>
623
                    [% copyrightclearance_confirmed = request.extended_attributes.find({'type'=>'copyrightclearance_confirmed'}).value %]
623
                    [% IF request.get_copyright_clearance_confirmed %]
624
                    [% IF copyrightclearance_confirmed %]
625
                        <h5> <i class="fa fa-fw fa-check text-success" aria-hidden="true"></i> <span class="tab-title">Patron has confirmed copyright clearance for this request</span> </h5>
624
                        <h5> <i class="fa fa-fw fa-check text-success" aria-hidden="true"></i> <span class="tab-title">Patron has confirmed copyright clearance for this request</span> </h5>
626
                    [% END %]
625
                    [% END %]
627
                    <div class="rows">
626
                    <div class="rows">
(-)a/opac/opac-illrequests.pl (-8 / +2 lines)
Lines 200-213 if ( $op eq 'list' ) { Link Here
200
            );
200
            );
201
            if ( $backend_result->{stage} eq 'commit' ) {
201
            if ( $backend_result->{stage} eq 'commit' ) {
202
202
203
                $request->extended_attributes(
203
                $request->set_copyright_clearance_confirmed(1)
204
                    [
204
                    if $params->{copyrightclearance_confirmed};
205
                        {
206
                            type  => 'copyrightclearance_confirmed',
207
                            value => 1,
208
                        }
209
                    ]
210
                ) if $params->{copyrightclearance_confirmed};
211
205
212
                # After creation actions
206
                # After creation actions
213
                if ( $params->{type_disclaimer_submitted} ) {
207
                if ( $params->{type_disclaimer_submitted} ) {
(-)a/t/db_dependent/Koha/ILL/Request.t (-2 / +37 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::NoWarnings;
22
use Test::NoWarnings;
23
use Test::More tests => 6;
23
use Test::More tests => 7;
24
use Test::MockModule;
24
use Test::MockModule;
25
25
26
use Koha::ILL::Requests;
26
use Koha::ILL::Requests;
Lines 197-199 subtest 'get_backend_plugin() tests' => sub { Link Here
197
197
198
    $schema->storage->txn_rollback;
198
    $schema->storage->txn_rollback;
199
};
199
};
200
- 
200
201
subtest 'copyright clearance methods tests' => sub {
202
203
    plan tests => 8;
204
205
    $schema->storage->txn_begin;
206
207
    # Test set_copyright_clearance_confirmed with truthy value
208
    my $request = $builder->build_object( { class => 'Koha::ILL::Requests' } );
209
210
    $request->set_copyright_clearance_confirmed(1);
211
212
    my $attr = $request->extended_attributes->find( { type => 'copyrightclearance_confirmed' } );
213
    ok( $attr, 'Copyright clearance attribute created' );
214
    is( $attr->value, 1, 'Copyright clearance value set to 1' );
215
216
    # Test setting to false creates attribute with value 0
217
    my $request2 = $builder->build_object( { class => 'Koha::ILL::Requests' } );
218
    $request2->set_copyright_clearance_confirmed(0);
219
220
    my $attr2 = $request2->extended_attributes->find( { type => 'copyrightclearance_confirmed' } );
221
    ok( $attr2, 'Attribute created for false value' );
222
    is( $attr2->value, 0, 'False value normalized to 0' );
223
224
    # Test setting to false when already true updates the value
225
    $request->set_copyright_clearance_confirmed(0);
226
    my $attr_after_false = $request->extended_attributes->find( { type => 'copyrightclearance_confirmed' } );
227
    ok( $attr_after_false, 'Attribute still exists after setting to false' );
228
    is( $attr_after_false->value, 0, 'Attribute value updated to 0 when set to false' );
229
230
    # Test get_copyright_clearance_confirmed returns boolean values
231
    is( $request->get_copyright_clearance_confirmed,  0, 'Returns 0 when set to false' );
232
    is( $request2->get_copyright_clearance_confirmed, 0, 'Returns 0 when set to false value' );
233
234
    $schema->storage->txn_rollback;
235
};

Return to bug 40262