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

(-)a/C4/CourseReserves.pm (-82 / +99 lines)
Lines 22-27 use List::MoreUtils qw(any); Link Here
22
use C4::Context;
22
use C4::Context;
23
use C4::Circulation qw(GetOpenIssue);
23
use C4::Circulation qw(GetOpenIssue);
24
24
25
use Koha::Courses;
26
use Koha::Course::Instructors;
27
use Koha::Course::Items;
28
use Koha::Course::Reserves;
29
25
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS);
30
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS);
26
31
27
BEGIN {
32
BEGIN {
Lines 78-96 sub GetCourse { Link Here
78
    my ($course_id) = @_;
83
    my ($course_id) = @_;
79
    warn whoami() . "( $course_id )" if $DEBUG;
84
    warn whoami() . "( $course_id )" if $DEBUG;
80
85
81
    my $query = "SELECT * FROM courses WHERE course_id = ?";
86
    my $course = Koha::Courses->find( $course_id );
82
    my $dbh   = C4::Context->dbh;
87
    return undef unless $course;
83
    my $sth   = $dbh->prepare($query);
88
    $course = $course->unblessed;
84
    $sth->execute($course_id);
85
86
    my $course = $sth->fetchrow_hashref();
87
89
88
    $query = "
90
    my $dbh = C4::Context->dbh;
91
    my $query = "
89
        SELECT b.* FROM course_instructors ci
92
        SELECT b.* FROM course_instructors ci
90
        LEFT JOIN borrowers b ON ( ci.borrowernumber = b.borrowernumber )
93
        LEFT JOIN borrowers b ON ( ci.borrowernumber = b.borrowernumber )
91
        WHERE course_id =  ?
94
        WHERE course_id =  ?
92
    ";
95
    ";
93
    $sth = $dbh->prepare($query);
96
    my $sth = $dbh->prepare($query);
94
    $sth->execute($course_id);
97
    $sth->execute($course_id);
95
    $course->{'instructors'} = $sth->fetchall_arrayref( {} );
98
    $course->{'instructors'} = $sth->fetchall_arrayref( {} );
96
99
Lines 304-310 sub EnableOrDisableCourseItem { Link Here
304
    ## or disable and already disabled item,
307
    ## or disable and already disabled item,
305
    ## as that would cause the fields to swap
308
    ## as that would cause the fields to swap
306
    if ( $course_item->{'enabled'} ne $enabled ) {
309
    if ( $course_item->{'enabled'} ne $enabled ) {
307
        _SwapAllFields($ci_id);
310
        _SwapAllFields($ci_id, $enabled );
308
311
309
        my $query = "
312
        my $query = "
310
            UPDATE course_items
313
            UPDATE course_items
Lines 492-514 sub _AddCourseItem { Link Here
492
    my (%params) = @_;
495
    my (%params) = @_;
493
    warn identify_myself(%params) if $DEBUG;
496
    warn identify_myself(%params) if $DEBUG;
494
497
495
    my ( @fields, @values );
498
    $params{holdingbranch} ||= undef; # Can't be empty string, FK constraint
496
499
497
    push( @fields, 'itemnumber = ?' );
500
    my %data = map { $_ => $params{$_} } @FIELDS;
498
    push( @values, $params{'itemnumber'} );
501
    my %enabled = map { $_ . "_enabled" => $params{ $_ . "_enabled" } } @FIELDS;
499
502
500
    foreach (@FIELDS) {
503
    my $ci = Koha::Course::Item->new(
501
        push( @fields, "$_ = ?" );
504
        {
502
        push( @values, $params{$_} || undef );
505
            itemnumber => $params{itemnumber},
503
    }
506
            %data,
504
507
            %enabled,
505
    my $query = "INSERT INTO course_items SET " . join( ',', @fields );
508
        }
506
    my $dbh = C4::Context->dbh;
509
    )->store();
507
    $dbh->do( $query, undef, @values );
508
509
    my $ci_id = $dbh->last_insert_id( undef, undef, 'course_items', 'ci_id' );
510
510
511
    return $ci_id;
511
    return $ci->id;
512
}
512
}
513
513
514
=head2 _UpdateCourseItem
514
=head2 _UpdateCourseItem
Lines 524-582 sub _UpdateCourseItem { Link Here
524
    my $ci_id         = $params{'ci_id'};
524
    my $ci_id         = $params{'ci_id'};
525
    my $course_item   = $params{'course_item'};
525
    my $course_item   = $params{'course_item'};
526
526
527
    return unless ( $ci_id || $course_item );
527
    $params{holdingbranch} ||= undef; # Can't be empty string, FK constraint
528
529
    $course_item = GetCourseItem( ci_id => $ci_id )
530
      unless ($course_item);
531
    $ci_id = $course_item->{'ci_id'} unless ($ci_id);
532
533
    my %mod_params =
534
      map {
535
        defined $params{$_} && $params{$_} ne ''
536
          ? ( $_ => $params{$_} )
537
          : ()
538
      } @FIELDS;
539
540
    Koha::Items->find( $course_item->{itemnumber} )
541
               ->set( \%mod_params )
542
               ->store;
543
}
544
545
=head2 _ModStoredFields
546
547
    _ModStoredFields( %params );
548
528
549
    Updates the values for the 'original' fields in course_items
529
    return unless ( $ci_id || $course_item );
550
    for a given ci_id
551
530
552
=cut
531
    $course_item = Koha::Course::Items->find( $ci_id || $course_item->{ci_id} );
553
532
554
sub _ModStoredFields {
533
    my %data = map { $_ => $params{$_} } @FIELDS;
555
    my (%params) = @_;
534
    my %enabled = map { $_ . "_enabled" => $params{ $_ . "_enabled" } } @FIELDS;
556
    warn identify_myself(%params) if $DEBUG;
557
535
558
    return unless ( $params{'ci_id'} );
536
    $course_item->update( { %data, %enabled } );
537
    if ( $course_item->is_enabled ) {
538
        my $item_fields = {};
539
        $item_fields->{itype}         = $course_item->itype         if $course_item->itype_enabled;
540
        $item_fields->{ccode}         = $course_item->ccode         if $course_item->ccode_enabled;
541
        $item_fields->{location}      = $course_item->location      if $course_item->location_enabled;
542
        $item_fields->{holdingbranch} = $course_item->holdingbranch if $course_item->holdingbranch_enabled;
559
543
560
    my ( @fields_to_update, @values_to_update );
544
        Koha::Items->find( $course_item->itemnumber )
545
                   ->set( $item_fields )
546
                   ->store
547
            if keys %$item_fields;
561
548
562
    foreach (@FIELDS) {
563
        if ( defined($params{$_}) ) {
564
            push( @fields_to_update, $_ );
565
            push( @values_to_update, $params{$_} );
566
        }
567
    }
549
    }
568
550
569
    my $query = "UPDATE course_items SET " . join( ',', map { "$_=?" } @fields_to_update ) . " WHERE ci_id = ?";
570
571
    C4::Context->dbh->do( $query, undef, @values_to_update, $params{'ci_id'} )
572
      if (@values_to_update);
573
574
}
551
}
575
552
576
=head2 _RevertFields
553
=head2 _RevertFields
577
554
578
    _RevertFields( ci_id => $ci_id, fields => \@fields_to_revert );
555
    _RevertFields( ci_id => $ci_id, fields => \@fields_to_revert );
579
556
557
    Copies fields from course item storage back to the actual item
558
580
=cut
559
=cut
581
560
582
sub _RevertFields {
561
sub _RevertFields {
Lines 585-599 sub _RevertFields { Link Here
585
564
586
    my $ci_id = $params{'ci_id'};
565
    my $ci_id = $params{'ci_id'};
587
566
588
    return unless ($ci_id);
567
    return unless $ci_id;
589
568
590
    my $course_item = GetCourseItem( ci_id => $params{'ci_id'} );
569
    my $course_item = Koha::Course::Items->find( $ci_id );
591
    my $course_item_object = Koha::Items->find($course_item->{'itemnumber'});
570
592
    foreach my $field ( @FIELDS ) {
571
    my $item_fields = {};
593
        next unless defined $course_item->{$field};
572
    $item_fields->{itype}         = $course_item->itype_storage         if $course_item->itype_enabled;
594
        $course_item_object->$field($course_item->{$field});
573
    $item_fields->{ccode}         = $course_item->ccode_storage         if $course_item->ccode_enabled;
595
    }
574
    $item_fields->{location}      = $course_item->location_storage      if $course_item->location_enabled;
596
    $course_item_object->store;
575
    $item_fields->{holdingbranch} = $course_item->holdingbranch_storage if $course_item->holdingbranch_enabled;
576
577
    Koha::Items->find( $course_item->itemnumber )
578
               ->set( $item_fields )
579
               ->store
580
        if keys %$item_fields;
581
582
    $course_item->itype_storage(undef);
583
    $course_item->ccode_storage(undef);
584
    $course_item->location_storage(undef);
585
    $course_item->holdingbranch_storage(undef);
586
    $course_item->store();
597
}
587
}
598
588
599
=head2 _SwapAllFields
589
=head2 _SwapAllFields
Lines 603-623 sub _RevertFields { Link Here
603
=cut
593
=cut
604
594
605
sub _SwapAllFields {
595
sub _SwapAllFields {
606
    my ($ci_id) = @_;
596
    my ( $ci_id, $enabled ) = @_;
607
    warn "C4::CourseReserves::_SwapFields( $ci_id )" if $DEBUG;
597
    warn "C4::CourseReserves::_SwapFields( $ci_id )" if $DEBUG;
608
598
609
    my $course_item = GetCourseItem( ci_id => $ci_id );
599
    my $course_item = Koha::Course::Items->find( $ci_id );
610
    my $item = Koha::Items->find($course_item->{'itemnumber'});
600
    my $item = Koha::Items->find( $course_item->itemnumber );
611
601
612
    my %item_fields;
602
    if ( $enabled eq 'yes' ) { # Copy item fields to course item storage, course item fields to item
613
    foreach (@FIELDS) {
603
        $course_item->itype_storage( $item->effective_itemtype )    if $course_item->itype_enabled;
614
        if ( defined( $course_item->{$_} ) ) {
604
        $course_item->ccode_storage( $item->ccode )                 if $course_item->ccode_enabled;
615
            $item_fields{$_}        = $item->$_ || q{};
605
        $course_item->location_storage( $item->location )           if $course_item->location_enabled;
616
            $item->$_($course_item->{$_});
606
        $course_item->holdingbranch_storage( $item->holdingbranch ) if $course_item->holdingbranch_enabled;
617
        }
607
        $course_item->store();
608
609
        my $item_fields = {};
610
        $item_fields->{itype}         = $course_item->itype         if $course_item->itype_enabled;
611
        $item_fields->{ccode}         = $course_item->ccode         if $course_item->ccode_enabled;
612
        $item_fields->{location}      = $course_item->location      if $course_item->location_enabled;
613
        $item_fields->{holdingbranch} = $course_item->holdingbranch if $course_item->holdingbranch_enabled;
614
615
        Koha::Items->find( $course_item->itemnumber )
616
                   ->set( $item_fields )
617
                   ->store
618
            if keys %$item_fields;
619
620
    } else { # Copy course item storage to item
621
        my $item_fields = {};
622
        $item_fields->{itype}         = $course_item->itype_storage         if $course_item->itype_enabled;
623
        $item_fields->{ccode}         = $course_item->ccode_storage         if $course_item->ccode_enabled;
624
        $item_fields->{location}      = $course_item->location_storage      if $course_item->location_enabled;
625
        $item_fields->{holdingbranch} = $course_item->holdingbranch_storage if $course_item->holdingbranch_enabled;
626
627
        Koha::Items->find( $course_item->itemnumber )
628
                   ->set( $item_fields )
629
                   ->store
630
            if keys %$item_fields;
631
632
        $course_item->itype_storage(undef);
633
        $course_item->ccode_storage(undef);
634
        $course_item->location_storage(undef);
635
        $course_item->holdingbranch_storage(undef);
636
        $course_item->store();
618
    }
637
    }
619
    $item->store;
620
    _ModStoredFields( %item_fields, ci_id => $ci_id );
621
}
638
}
622
639
623
=head2 GetCourseItems {
640
=head2 GetCourseItems {
(-)a/Koha/Course/Instructors.pm (-1 / +1 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use Carp;
20
use Carp;
21
21
22
use Koha::Course;
22
use Koha::Course::Instructor;
23
23
24
use base qw(Koha::Objects);
24
use base qw(Koha::Objects);
25
25
(-)a/Koha/Course/Item.pm (+36 lines)
Lines 21-32 use Carp; Link Here
21
21
22
use base qw(Koha::Object);
22
use base qw(Koha::Object);
23
23
24
use Koha::Course::Reserves;
25
24
=head1 NAME
26
=head1 NAME
25
27
26
Koha::Course::Item - Koha Course Item Object class
28
Koha::Course::Item - Koha Course Item Object class
27
29
28
=head1 API
30
=head1 API
29
31
32
=head2 Methods
33
34
=head3 is_enabled
35
36
=cut
37
38
sub is_enabled {
39
    my ( $self ) = @_;
40
41
    return $self->enabled eq 'yes';
42
}
43
44
=head3 course_reserves
45
46
=cut
47
48
sub course_reserves {
49
    my ($self) = @_;
50
51
    my $rs = $self->_result->course_reserves;
52
    return Koha::Course::Reserves->_new_from_dbic( $rs );
53
}
54
55
=head3 item
56
57
=cut
58
59
sub item {
60
    my ($self) = @_;
61
62
    my $rs = $self->_result->itemnumber;
63
    return Koha::Item->_new_from_dbic( $rs );
64
}
65
30
=head2 Internal methods
66
=head2 Internal methods
31
67
32
=cut
68
=cut
(-)a/Koha/Course/Items.pm (-1 / +1 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use Carp;
20
use Carp;
21
21
22
use Koha::Course;
22
use Koha::Course::Item;
23
23
24
use base qw(Koha::Objects);
24
use base qw(Koha::Objects);
25
25
(-)a/Koha/Course/Reserves.pm (-1 / +1 lines)
Lines 19-25 use Modern::Perl; Link Here
19
19
20
use Carp;
20
use Carp;
21
21
22
use Koha::Course;
22
use Koha::Course::Reserve;
23
23
24
use base qw(Koha::Objects);
24
use base qw(Koha::Objects);
25
25
(-)a/course_reserves/add_items.pl (-8 / +24 lines)
Lines 39-48 my $action = $cgi->param('action') || ''; Link Here
39
my $course_id    = $cgi->param('course_id')    || '';
39
my $course_id    = $cgi->param('course_id')    || '';
40
my $barcode      = $cgi->param('barcode')      || '';
40
my $barcode      = $cgi->param('barcode')      || '';
41
my $return       = $cgi->param('return')       || '';
41
my $return       = $cgi->param('return')       || '';
42
my $itemnumber   = ($cgi->param('itemnumber') && $action eq 'lookup') ? $cgi->param('itemnumber') : '';
42
my $itemnumber   = $cgi->param('itemnumber')   || '';
43
my $is_edit      = $cgi->param('is_edit')      || '';
43
my $is_edit      = $cgi->param('is_edit')      || '';
44
44
45
my $item = Koha::Items->find( { ( $itemnumber ? ( itemnumber => $itemnumber ) : ( barcode => $barcode ) ) } );
45
my $item = Koha::Items->find( { ( $itemnumber ? ( itemnumber => $itemnumber ) : ( barcode => $barcode ) ) } );
46
$itemnumber = $item->id if $item;
47
46
my $title = ($item) ? $item->biblio->title : undef;
48
my $title = ($item) ? $item->biblio->title : undef;
47
49
48
my $step = ( $action eq 'lookup' && $item ) ? '2' : '1';
50
my $step = ( $action eq 'lookup' && $item ) ? '2' : '1';
Lines 65-76 if ( !$item && $action eq 'lookup' ){ Link Here
65
$template->param( course => GetCourse($course_id) );
67
$template->param( course => GetCourse($course_id) );
66
68
67
if ( $action eq 'lookup' and $item ) {
69
if ( $action eq 'lookup' and $item ) {
68
    my $course_item = GetCourseItem( itemnumber => $item->itemnumber );
70
    my $course_item = Koha::Course::Items->find({ itemnumber => $item->id });
69
    my $course_reserve =
71
    my $course_reserve =
70
      ($course_item)
72
      ($course_item)
71
      ? GetCourseReserve(
73
      ? GetCourseReserve(
72
        course_id => $course_id,
74
        course_id => $course_id,
73
        ci_id     => $course_item->{'ci_id'}
75
        ci_id     => $course_item->ci_id,
74
      )
76
      )
75
      : undef;
77
      : undef;
76
78
Lines 89-100 if ( $action eq 'lookup' and $item ) { Link Here
89
    );
91
    );
90
92
91
} elsif ( $action eq 'add' ) {
93
} elsif ( $action eq 'add' ) {
94
    my $itype         = scalar $cgi->param('itype');
95
    my $ccode         = scalar $cgi->param('ccode');
96
    my $holdingbranch = scalar $cgi->param('holdingbranch');
97
    my $location      = scalar $cgi->param('location');
98
99
    my $itype_enabled         = scalar $cgi->param('itype_enabled') ? 1 : 0;
100
    my $ccode_enabled         = scalar $cgi->param('ccode_enabled') ? 1 : 0;
101
    my $holdingbranch_enabled = scalar $cgi->param('holdingbranch_enabled') ? 1 : 0;
102
    my $location_enabled      = scalar $cgi->param('location_enabled') ? 1 : 0;
103
92
    my $ci_id = ModCourseItem(
104
    my $ci_id = ModCourseItem(
93
        itemnumber    => scalar $cgi->param('itemnumber'),
105
            itemnumber    => $itemnumber,
94
        itype         => scalar $cgi->param('itype'),
106
            itype         => $itype,
95
        ccode         => scalar $cgi->param('ccode'),
107
            ccode         => $ccode,
96
        holdingbranch => scalar $cgi->param('holdingbranch'),
108
            holdingbranch => $holdingbranch,
97
        location      => scalar $cgi->param('location'),
109
            location      => $location,
110
            itype_enabled         => $itype_enabled,
111
            ccode_enabled         => $ccode_enabled,
112
            holdingbranch_enabled => $holdingbranch_enabled,
113
            location_enabled      => $location_enabled,
98
    );
114
    );
99
115
100
    my $cr_id = ModCourseReserve(
116
    my $cr_id = ModCourseReserve(
(-)a/course_reserves/batch_add_items.pl (-5 / +14 lines)
Lines 42-47 my $location = $cgi->param('location'); Link Here
42
my $staff_note    = $cgi->param('staff_note');
42
my $staff_note    = $cgi->param('staff_note');
43
my $public_note   = $cgi->param('public_note');
43
my $public_note   = $cgi->param('public_note');
44
44
45
my $itype_enabled         = scalar $cgi->param('itype_enabled') ? 1 : 0;
46
my $ccode_enabled         = scalar $cgi->param('ccode_enabled') ? 1 : 0;
47
my $holdingbranch_enabled = scalar $cgi->param('holdingbranch_enabled') ? 1 : 0;
48
my $location_enabled      = scalar $cgi->param('location_enabled') ? 1 : 0;
49
45
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
50
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
46
    {
51
    {
47
        template_name   => "course_reserves/batch_add_items.tt",
52
        template_name   => "course_reserves/batch_add_items.tt",
Lines 78-88 if ( $course_id && $course ) { Link Here
78
83
79
        foreach my $item (@items) {
84
        foreach my $item (@items) {
80
            my $ci_id = ModCourseItem(
85
            my $ci_id = ModCourseItem(
81
                itemnumber    => $item->id,
86
                itemnumber            => $item->id,
82
                itype         => $itype,
87
                itype                 => $itype,
83
                ccode         => $ccode,
88
                ccode                 => $ccode,
84
                holdingbranch => $holdingbranch,
89
                holdingbranch         => $holdingbranch,
85
                location      => $location,
90
                location              => $location,
91
                itype_enabled         => $itype_enabled,
92
                ccode_enabled         => $ccode_enabled,
93
                holdingbranch_enabled => $holdingbranch_enabled,
94
                location_enabled      => $location_enabled,
86
            );
95
            );
87
96
88
            my $cr_id = ModCourseReserve(
97
            my $cr_id = ModCourseReserve(
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt (-13 / +76 lines)
Lines 1-4 Link Here
1
[% USE Branches %]
1
[% USE Branches %]
2
[% SET footerjs = 1 %]
2
[% INCLUDE 'doc-head-open.inc' %]
3
[% INCLUDE 'doc-head-open.inc' %]
3
<title>Koha &rsaquo; Course reserves &rsaquo;[% IF is_edit || course_reserve %] Edit item[% ELSE %] Add items[% END %]</title>
4
<title>Koha &rsaquo; Course reserves &rsaquo;[% IF is_edit || course_reserve %] Edit item[% ELSE %] Add items[% END %]</title>
4
[% INCLUDE 'doc-head-close.inc' %]
5
[% INCLUDE 'doc-head-close.inc' %]
Lines 16-22 Link Here
16
        <div class="col-md-8 col-md-offset-2">
17
        <div class="col-md-8 col-md-offset-2">
17
18
18
        [% IF course_reserve && !is_edit%]<div class="dialog message" id="already_on_reserve_this">This course already has this item on reserve.</div>[% END %]
19
        [% IF course_reserve && !is_edit%]<div class="dialog message" id="already_on_reserve_this">This course already has this item on reserve.</div>[% END %]
19
        [% IF course_item %]<div class="dialog message" id="already_on_reserve">Number of courses reserving this item: [% course_item.course_reserves.size | html %]</div>[% END %]
20
        [% IF course_item %]<div class="dialog message" id="already_on_reserve">Number of courses reserving this item: [% course_item.course_reserves.count | html %]</div>[% END %]
20
21
21
        <form method="post" action="/cgi-bin/koha/course_reserves/add_items.pl">
22
        <form method="post" action="/cgi-bin/koha/course_reserves/add_items.pl">
22
            <input type="hidden" name="course_id" value="[% course.course_id | html %]" />
23
            <input type="hidden" name="course_id" value="[% course.course_id | html %]" />
Lines 39-49 Link Here
39
                    [% IF item_level_itypes %]
40
                    [% IF item_level_itypes %]
40
                    <li>
41
                    <li>
41
                        <label class="required" for="itype">Item type:</label>
42
                        <label class="required" for="itype">Item type:</label>
42
                        <select id="itype" name="itype">
43
                            <option value="">LEAVE UNCHANGED</option>
44
43
44
                        [% IF course_item.itype_enabled %]
45
                            <input type="checkbox" class="field-toggle" data-pulldown="itype" value="1" name="itype_enabled" id="itype_enabled" checked="checked" />
46
                        [% ELSE %]
47
                            <input type="checkbox" class="field-toggle" data-pulldown="itype" value="1" name="itype_enabled" id="itype_enabled" />
48
                        [% END %]
49
50
                        [% IF course_item.itype_enabled %]
51
                            <select id="itype" name="itype">
52
                        [% ELSE %]
53
                            <select id="itype" name="itype" disabled="disabled">
54
                        [% END %]
55
56
                            <option value=""></option>
45
                            [% FOREACH it IN itypes %]
57
                            [% FOREACH it IN itypes %]
46
                                [% IF course_item.itype.defined && ( ( course.enabled == 'yes' && it.itemtype == item.itype ) || ( course.enabled == 'no' && it.itemtype == course_item.itype ) ) %]
58
                                [% IF it.itemtype == course_item.itype %]
47
                                    <option value="[% it.itemtype | html %]" selected="selected">[% it.description | html %]</option>
59
                                    <option value="[% it.itemtype | html %]" selected="selected">[% it.description | html %]</option>
48
                                [% ELSE %]
60
                                [% ELSE %]
49
                                    <option value="[% it.itemtype | html %]">[% it.description | html %]</option>
61
                                    <option value="[% it.itemtype | html %]">[% it.description | html %]</option>
Lines 55-65 Link Here
55
67
56
                    <li>
68
                    <li>
57
                        <label class="required" for="ccode">Collection:</label>
69
                        <label class="required" for="ccode">Collection:</label>
58
                        <select id="ccode" name="ccode">
59
                            <option value="">LEAVE UNCHANGED</option>
60
70
71
                        [% IF course_item.ccode_enabled %]
72
                            <input type="checkbox" class="field-toggle" data-pulldown="ccode" value="1" name="ccode_enabled" id="ccode_enabled" checked="checked" />
73
                        [% ELSE %]
74
                            <input type="checkbox" class="field-toggle" data-pulldown="ccode" value="1" name="ccode_enabled" id="ccode_enabled" />
75
                        [% END %]
76
77
                        [% IF course_item.ccode_enabled %]
78
                            <select id="ccode" name="ccode">
79
                        [% ELSE %]
80
                            <select id="ccode" name="ccode" disabled="disabled">
81
                        [% END %]
82
83
                            <option value=""></option>
61
                            [% FOREACH c IN ccodes %]
84
                            [% FOREACH c IN ccodes %]
62
                                [% IF course_item.ccode.defined && ( ( course.enabled == 'yes' && c.authorised_value == item.ccode ) || ( course.enabled == 'no' && c.authorised_value == course_item.ccode ) ) %]
85
                                [% IF c.authorised_value == course_item.ccode %]
63
                                    <option value="[% c.authorised_value | html %]" selected="selected">[% c.lib | html %]</option>
86
                                    <option value="[% c.authorised_value | html %]" selected="selected">[% c.lib | html %]</option>
64
                                [% ELSE %]
87
                                [% ELSE %]
65
                                    <option value="[% c.authorised_value | html %]">[% c.lib | html %]</option>
88
                                    <option value="[% c.authorised_value | html %]">[% c.lib | html %]</option>
Lines 70-80 Link Here
70
93
71
                    <li>
94
                    <li>
72
                        <label class="required" for="location">Shelving location:</label>
95
                        <label class="required" for="location">Shelving location:</label>
73
                        <select id="location" name="location">
74
                            <option value="">LEAVE UNCHANGED</option>
75
96
97
                        [% IF course_item.location_enabled %]
98
                            <input type="checkbox" class="field-toggle" data-pulldown="location" value="1" name="location_enabled" id="location_enabled" checked="checked" />
99
                        [% ELSE %]
100
                            <input type="checkbox" class="field-toggle" data-pulldown="location"  value="1" name="location_enabled" id="location_enabled" />
101
                        [% END %]
102
103
                        [% IF course_item.location_enabled %]
104
                            <select id="location" name="location">
105
                        [% ELSE %]
106
                            <select id="location" name="location" disabled="disabled">
107
                        [% END %]
108
109
                            <option value=""></option>
76
                            [% FOREACH s IN locations %]
110
                            [% FOREACH s IN locations %]
77
                                [% IF course_item.location.defined && ( ( course.enabled == 'yes' && s.authorised_value == item.location ) || ( course.enabled == 'no' && s.authorised_value == course_item.location ) ) %]
111
                                [% IF s.authorised_value == course_item.location %]
78
                                    <option value="[% s.authorised_value | html %]" selected="selected">[% s.lib | html %]</option>
112
                                    <option value="[% s.authorised_value | html %]" selected="selected">[% s.lib | html %]</option>
79
                                [% ELSE %]
113
                                [% ELSE %]
80
                                    <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
114
                                    <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
Lines 85-94 Link Here
85
119
86
                    <li>
120
                    <li>
87
                        <label class="required" for="holdingbranch">Holding library:</label>
121
                        <label class="required" for="holdingbranch">Holding library:</label>
88
                        <select id="holdingbranch" name="holdingbranch">
122
89
                            <option value="">LEAVE UNCHANGED</option>
123
                        [% IF course_item.holdingbranch_enabled %]
124
                            <input type="checkbox" value="1" class="field-toggle" data-pulldown="holdingbranch" name="holdingbranch_enabled" id="holdingbranch_enabled" checked="checked" />
125
                        [% ELSE %]
126
                            <input type="checkbox" value="1" class="field-toggle" data-pulldown="holdingbranch" name="holdingbranch_enabled" id="holdingbranch_enabled" />
127
                        [% END %]
128
129
                        [% IF course_item.holdingbranch_enabled %]
130
                            <select id="holdingbranch" name="holdingbranch">
131
                        [% ELSE %]
132
                            <select id="holdingbranch" name="holdingbranch" disabled="disabled">
133
                        [% END %]
134
135
                            <option value=""></option>
90
                            [% FOREACH b IN Branches.all() %]
136
                            [% FOREACH b IN Branches.all() %]
91
                                [% IF course_item.holdingbranch.defined && ( ( course.enabled == 'yes' && b.branchcode == item.holdingbranch ) || ( course.enabled == 'no' && b.branchcode == course_item.holdingbranch ) ) %]
137
                                [% IF b.branchcode == course_item.holdingbranch %]
92
                                    <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
138
                                    <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
93
                                [% ELSE %]
139
                                [% ELSE %]
94
                                    <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
140
                                    <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
Lines 119-122 Link Here
119
    </div>
165
    </div>
120
</div>
166
</div>
121
167
168
[% MACRO jsinclude BLOCK %]
169
    <script type="text/javascript">
170
    //<![CDATA[
171
        $(document).ready(function(){
172
            $('.field-toggle').change(function() {
173
                if( this.checked ) {
174
                    $('#' + $(this).data('pulldown') ).removeAttr('disabled');
175
                } else {
176
                    $('#' + $(this).data('pulldown') ).val('');
177
                    $('#' + $(this).data('pulldown') ).attr('disabled', 'disabled');
178
                }
179
            });
180
        });
181
    //]]>
182
    </script>
183
[% END %]
184
122
[% INCLUDE 'intranet-bottom.inc' %]
185
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/batch_add_items.tt (-8 / +31 lines)
Lines 2-7 Link Here
2
[% USE Branches %]
2
[% USE Branches %]
3
[% USE ItemTypes %]
3
[% USE ItemTypes %]
4
4
5
[% SET footerjs = 1 %]
6
5
[% INCLUDE 'doc-head-open.inc' %]
7
[% INCLUDE 'doc-head-open.inc' %]
6
<title>Koha &rsaquo; Course reserves &rsaquo; Add items</title>
8
<title>Koha &rsaquo; Course reserves &rsaquo; Add items</title>
7
[% INCLUDE 'doc-head-close.inc' %]
9
[% INCLUDE 'doc-head-close.inc' %]
Lines 35-42 Link Here
35
                        [% IF item_level_itypes %]
37
                        [% IF item_level_itypes %]
36
                        <li>
38
                        <li>
37
                            <label class="required" for="itype">Item type:</label>
39
                            <label class="required" for="itype">Item type:</label>
38
                            <select id="itype" name="itype">
40
                            <input type="checkbox" class="field-toggle" data-pulldown="itype" value="1" name="itype_enabled" id="itype_enabled" />
39
                                <option value="">LEAVE UNCHANGED</option>
41
                            <select id="itype" name="itype" disabled="disabled">
42
                                <option value=""></option>
40
43
41
                                [% FOREACH it IN ItemTypes.Get() %]
44
                                [% FOREACH it IN ItemTypes.Get() %]
42
                                    <option value="[% it.itemtype | html %]">[% it.description | html %]</option>
45
                                    <option value="[% it.itemtype | html %]">[% it.description | html %]</option>
Lines 47-54 Link Here
47
50
48
                        <li>
51
                        <li>
49
                            <label class="required" for="ccode">Collection:</label>
52
                            <label class="required" for="ccode">Collection:</label>
50
                            <select id="ccode" name="ccode">
53
                            <input type="checkbox" class="field-toggle" data-pulldown="ccode" value="1" name="ccode_enabled" id="ccode_enabled" />
51
                                <option value="">LEAVE UNCHANGED</option>
54
                            <select id="ccode" name="ccode" disabled="disabled">
55
                                <option value=""></option>
52
                                [% FOREACH c IN AuthorisedValues.Get('CCODE') %]
56
                                [% FOREACH c IN AuthorisedValues.Get('CCODE') %]
53
                                    <option value="[% c.authorised_value | html %]">[% c.lib | html %]</option>
57
                                    <option value="[% c.authorised_value | html %]">[% c.lib | html %]</option>
54
                                [% END %]
58
                                [% END %]
Lines 57-64 Link Here
57
61
58
                        <li>
62
                        <li>
59
                            <label class="required" for="location">Shelving location:</label>
63
                            <label class="required" for="location">Shelving location:</label>
60
                            <select id="location" name="location">
64
                            <input type="checkbox" class="field-toggle" data-pulldown="location"  value="1" name="location_enabled" id="location_enabled" />
61
                                <option value="">LEAVE UNCHANGED</option>
65
                            <select id="location" name="location" disabled="disabled">
66
                                <option value=""></option>
62
                                [% FOREACH s IN AuthorisedValues.Get('LOC') %]
67
                                [% FOREACH s IN AuthorisedValues.Get('LOC') %]
63
                                    <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
68
                                    <option value="[% s.authorised_value | html %]">[% s.lib | html %]</option>
64
                                [% END %]
69
                                [% END %]
Lines 67-74 Link Here
67
72
68
                        <li>
73
                        <li>
69
                            <label class="required" for="holdingbranch">Holding library:</label>
74
                            <label class="required" for="holdingbranch">Holding library:</label>
70
                            <select id="holdingbranch" name="holdingbranch">
75
                            <input type="checkbox" value="1" class="field-toggle" data-pulldown="holdingbranch" name="holdingbranch_enabled" id="holdingbranch_enabled" />
71
                                <option value="">LEAVE UNCHANGED</option>
76
                            <select id="holdingbranch" name="holdingbranch" disabled="disabled">
77
                                <option value=""></option>
72
                                [% FOREACH b IN Branches.all() %]
78
                                [% FOREACH b IN Branches.all() %]
73
                                    <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
79
                                    <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
74
                                [% END %]
80
                                [% END %]
Lines 132-135 Link Here
132
    </div>
138
    </div>
133
</div>
139
</div>
134
140
141
[% MACRO jsinclude BLOCK %]
142
    <script type="text/javascript">
143
    //<![CDATA[
144
        $(document).ready(function(){
145
            $('.field-toggle').change(function() {
146
                if( this.checked ) {
147
                    $('#' + $(this).data('pulldown') ).removeAttr('disabled');
148
                } else {
149
                    $('#' + $(this).data('pulldown') ).val('');
150
                    $('#' + $(this).data('pulldown') ).attr('disabled', 'disabled');
151
                }
152
            });
153
        });
154
    //]]>
155
    </script>
156
[% END %]
157
135
[% INCLUDE 'intranet-bottom.inc' %]
158
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt (-14 / +10 lines)
Lines 102-118 Link Here
102
                            <td>[% cr.item.itemcallnumber | html %]</td>
102
                            <td>[% cr.item.itemcallnumber | html %]</td>
103
                            [% IF item_level_itypes %]
103
                            [% IF item_level_itypes %]
104
                            <td>
104
                            <td>
105
                                [% IF cr.course_item.itype.defined %]
105
                                [% IF cr.course_item.itype_enabled %]
106
                                    [% IF cr.course_item.enabled == 'yes' %]
106
                                    [% IF cr.course_item.enabled == 'yes' %]
107
                                        <strong>[% ItemTypes.GetDescription( cr.item.itype) | html %]</strong>
107
                                        <strong>[% ItemTypes.GetDescription( cr.item.effective_itemtype ) | html %]</strong>
108
                                        [% IF cr.item.itype %]
108
                                        ([% ItemTypes.GetDescription( cr.course_item.itype_storage ) | html %])
109
                                            ([% ItemTypes.GetDescription( cr.course_item.itype ) | html %])
110
                                        [% END %]
111
                                    [% ELSE %]
109
                                    [% ELSE %]
112
                                        [% ItemTypes.GetDescription( cr.course_item.itype ) | html %]
110
                                        [% ItemTypes.GetDescription( cr.course_item.itype ) | html %]
113
                                        [% IF cr.item.itype %]
111
                                        (<strong>[% ItemTypes.GetDescription( cr.item.effective_itemtype) | html %]</strong>)
114
                                            (<strong>[% ItemTypes.GetDescription( cr.item.itype) | html %]</strong>)
115
                                        [% END %]
116
                                    [% END %]
112
                                    [% END %]
117
                                [% ELSE %]
113
                                [% ELSE %]
118
                                     <i>Unchanged</i>
114
                                     <i>Unchanged</i>
Lines 123-133 Link Here
123
                            </td>
119
                            </td>
124
                            [% END %]
120
                            [% END %]
125
                            <td>
121
                            <td>
126
                                 [% IF cr.course_item.ccode.defined %]
122
                                 [% IF cr.course_item.ccode_enabled %]
127
                                     [% IF cr.course_item.enabled == 'yes' %]
123
                                     [% IF cr.course_item.enabled == 'yes' %]
128
                                        <strong>[% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) | html %]</strong>
124
                                        <strong>[% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) | html %]</strong>
129
                                        [% IF cr.item.ccode %]
125
                                        [% IF cr.item.ccode %]
130
                                            ([% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) | html %])
126
                                            ([% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode_storage ) | html %])
131
                                        [% END %]
127
                                        [% END %]
132
                                     [% ELSE %]
128
                                     [% ELSE %]
133
                                        [% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) | html %]
129
                                        [% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) | html %]
Lines 143-153 Link Here
143
                                 [% END %]
139
                                 [% END %]
144
                            </td>
140
                            </td>
145
                            <td>
141
                            <td>
146
                                [% IF cr.course_item.location.defined %]
142
                                [% IF cr.course_item.location_enabled %]
147
                                    [% IF cr.course_item.enabled == 'yes' %]
143
                                    [% IF cr.course_item.enabled == 'yes' %]
148
                                        <strong>[% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]</strong>
144
                                        <strong>[% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]</strong>
149
                                        [% IF cr.item.permanent_location %]
145
                                        [% IF cr.item.permanent_location %]
150
                                            ([% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) | html %])
146
                                            ([% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location_storage ) | html %])
151
                                        [% END %]
147
                                        [% END %]
152
                                    [% ELSE %]
148
                                    [% ELSE %]
153
                                        [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) | html %]
149
                                        [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) | html %]
Lines 163-173 Link Here
163
                                [% END %]
159
                                [% END %]
164
                            </td>
160
                            </td>
165
                            <td>
161
                            <td>
166
                                [% IF cr.course_item.holdingbranch.defined %]
162
                                [% IF cr.course_item.holdingbranch_enabled %]
167
                                    [% IF cr.course_item.enabled == 'yes' %]
163
                                    [% IF cr.course_item.enabled == 'yes' %]
168
                                        <strong>[% Branches.GetName( cr.item.holdingbranch ) | html %]</strong>
164
                                        <strong>[% Branches.GetName( cr.item.holdingbranch ) | html %]</strong>
169
                                        [% IF cr.item.holdingbranch %]
165
                                        [% IF cr.item.holdingbranch %]
170
                                            ([% Branches.GetName( cr.course_item.holdingbranch ) | html %])
166
                                            ([% Branches.GetName( cr.course_item.holdingbranch_storage ) | html %])
171
                                        [% END %]
167
                                        [% END %]
172
                                    [% ELSE %]
168
                                    [% ELSE %]
173
                                        [% Branches.GetName( cr.course_item.holdingbranch ) | html %]
169
                                        [% Branches.GetName( cr.course_item.holdingbranch ) | html %]
(-)a/t/db_dependent/CourseReserves/CourseItems.t (-41 / +61 lines)
Lines 38-54 create_dependent_objects(); Link Here
38
my ($biblionumber, $itemnumber) = create_bib_and_item();
38
my ($biblionumber, $itemnumber) = create_bib_and_item();
39
39
40
my $ci_id = ModCourseItem(
40
my $ci_id = ModCourseItem(
41
    itemnumber    => $itemnumber,
41
    itemnumber            => $itemnumber,
42
    itype         => 'BK_foo',
42
    itype_enabled         => 1,
43
    ccode         => 'BOOK',
43
    ccode_enabled         => 1,
44
    holdingbranch => 'B2',
44
    holdingbranch_enabled => 1,
45
    location      => 'TH',
45
    location_enabled      => 1,
46
    itype                 => 'BK_foo',
47
    ccode                 => 'BOOK',
48
    holdingbranch         => 'B2',
49
    location              => 'TH',
46
);
50
);
47
51
48
my $course = $builder->build({
52
my $course = $builder->build({
49
    source => 'CourseReserve',
53
    source => 'CourseReserve',
50
    value => {
54
    value => {
51
        ci_id => $ci_id,
55
        ci_id => $ci_id,
56
        enabled => 'no',
52
    }
57
    }
53
});
58
});
54
59
Lines 60-82 my $cr_id = ModCourseReserve( Link Here
60
);
65
);
61
66
62
my $course_item = GetCourseItem( ci_id => $ci_id );
67
my $course_item = GetCourseItem( ci_id => $ci_id );
63
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo');
68
is($course_item->{itype_storage}, 'CD_foo', 'Course item itype storage should be CD_foo');
64
is($course_item->{ccode}, 'CD', 'Course item ccode should be CD');
69
is($course_item->{ccode_storage}, 'CD', 'Course item ccode storage should be CD');
65
is($course_item->{holdingbranch}, 'B1', 'Course item holding branch should be B1');
70
is($course_item->{holdingbranch_storage}, 'B1', 'Course item holding branch storage should be B1');
66
is($course_item->{location}, 'HR', 'Course item location should be HR');
71
is($course_item->{location_storage}, 'HR', 'Course item location storage should be HR');
67
72
68
my $item = Koha::Items->find($itemnumber);
73
my $item = Koha::Items->find($itemnumber);
69
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo');
74
is($item->effective_itemtype, 'BK_foo', 'Item type in course should be BK_foo');
70
is($item->ccode, 'BOOK', 'Item ccode in course should be BOOK');
75
is($item->ccode, 'BOOK', 'Item ccode in course should be BOOK');
71
is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2');
76
is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2');
72
is($item->location, 'TH', 'Item location in course should be TH');
77
is($item->location, 'TH', 'Item location in course should be TH');
73
78
74
ModCourseItem(
79
ModCourseItem(
75
    itemnumber    => $itemnumber,
80
    itemnumber            => $itemnumber,
76
    itype         => 'BK_foo',
81
    itype_enabled         => 1,
77
    ccode         => 'DVD',
82
    ccode_enabled         => 1,
78
    holdingbranch => 'B3',
83
    holdingbranch_enabled => 1,
79
    location      => 'TH',
84
    location_enabled      => 1,
85
    itype                 => 'BK_foo',
86
    ccode                 => 'DVD',
87
    holdingbranch         => 'B3',
88
    location              => 'TH',
80
);
89
);
81
90
82
ModCourseReserve(
91
ModCourseReserve(
Lines 87-106 ModCourseReserve( Link Here
87
);
96
);
88
97
89
$course_item = GetCourseItem( ci_id => $ci_id );
98
$course_item = GetCourseItem( ci_id => $ci_id );
90
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo');
99
is($course_item->{itype_storage}, 'CD_foo', 'Course item itype storage should be CD_foo');
91
is($course_item->{ccode}, 'CD', 'Course item ccode should be CD');
100
is($course_item->{ccode_storage}, 'CD', 'Course item ccode storage should be CD');
92
is($course_item->{holdingbranch}, 'B1', 'Course item holding branch should be B1');
101
is($course_item->{holdingbranch_storage}, 'B1', 'Course item holding branch storage should be B1');
93
is($course_item->{location}, 'HR', 'Course item location should be HR');
102
is($course_item->{location_storage}, 'HR', 'Course item location storage should be HR');
94
103
95
$item = Koha::Items->find($itemnumber);
104
$item = Koha::Items->find($itemnumber);
96
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo');
105
is($item->effective_itemtype, 'BK_foo', 'Item type in course should be BK_foo');
97
is($item->ccode, 'DVD', 'Item ccode in course should be DVD');
106
is($item->ccode, 'DVD', 'Item ccode in course should be DVD');
98
is($item->holdingbranch, 'B3', 'Item holding branch in course should be B3');
107
is($item->holdingbranch, 'B3', 'Item holding branch in course should be B3');
99
is($item->location, 'TH', 'Item location in course should be TH');
108
is($item->location, 'TH', 'Item location in course should be TH');
100
109
101
DelCourseReserve( cr_id => $cr_id );
110
DelCourseReserve( cr_id => $cr_id );
102
$item = Koha::Items->find($itemnumber);
111
$item = Koha::Items->find($itemnumber);
103
is($item->itype, 'CD_foo', 'Item type removed from course should be set back to CD_foo');
112
is($item->effective_itemtype, 'CD_foo', 'Item type removed from course should be set back to CD_foo');
104
is($item->ccode, 'CD', 'Item ccode removed from course should be set back to CD');
113
is($item->ccode, 'CD', 'Item ccode removed from course should be set back to CD');
105
is($item->holdingbranch, 'B1', 'Item holding branch removed from course should be set back B1');
114
is($item->holdingbranch, 'B1', 'Item holding branch removed from course should be set back B1');
106
is($item->location, 'HR', 'Item location removed from course should be TH');
115
is($item->location, 'HR', 'Item location removed from course should be TH');
Lines 112-122 $item = Koha::Items->find($itemnumber); Link Here
112
is($item->ccode, '', 'Item ccode should be empty');
121
is($item->ccode, '', 'Item ccode should be empty');
113
122
114
my $ci_id2 = ModCourseItem(
123
my $ci_id2 = ModCourseItem(
115
    itemnumber    => $itemnumber,
124
    itemnumber            => $itemnumber,
116
    itype         => 'CD_foo',
125
    itype_enabled         => 1,
117
    ccode         => 'BOOK',
126
    ccode_enabled         => 1,
118
    holdingbranch => 'B1',
127
    holdingbranch_enabled => 1,
119
    location      => 'HR',
128
    location_enabled      => 1,
129
    itype                 => 'CD_foo',
130
    ccode                 => 'BOOK',
131
    holdingbranch         => 'B1',
132
    location              => 'HR',
120
);
133
);
121
134
122
my $cr_id2 = ModCourseReserve(
135
my $cr_id2 = ModCourseReserve(
Lines 130-143 $item = Koha::Items->find($itemnumber); Link Here
130
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
143
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
131
144
132
my $course_item2 = GetCourseItem( ci_id => $ci_id2 );
145
my $course_item2 = GetCourseItem( ci_id => $ci_id2 );
133
is($course_item2->{ccode}, '', 'Course item ccode should be empty');
146
is($course_item2->{ccode_storage}, '', 'Course item ccode storage should be empty');
134
147
135
ModCourseItem(
148
ModCourseItem(
136
    itemnumber    => $itemnumber,
149
    itemnumber            => $itemnumber,
137
    itype         => 'CD_foo',
150
    itype_enabled         => 1,
138
    ccode         => 'DVD',
151
    ccode_enabled         => 1,
139
    holdingbranch => 'B1',
152
    holdingbranch_enabled => 1,
140
    location      => 'HR',
153
    location_enabled      => 1,
154
    itype                 => 'CD_foo',
155
    ccode                 => 'DVD',
156
    holdingbranch         => 'B1',
157
    location              => 'HR',
141
);
158
);
142
159
143
ModCourseReserve(
160
ModCourseReserve(
Lines 151-167 $item = Koha::Items->find($itemnumber); Link Here
151
is($item->ccode, 'DVD', 'Item ccode should be DVD');
168
is($item->ccode, 'DVD', 'Item ccode should be DVD');
152
169
153
ModCourseItem(
170
ModCourseItem(
154
    itemnumber    => $itemnumber,
171
    itemnumber            => $itemnumber,
155
    itype         => 'BK',
172
    itype_enabled         => 1,
156
    ccode         => 'BOOK',
173
    ccode_enabled         => 1,
157
    holdingbranch => '', # LEAVE UNCHANGED
174
    holdingbranch_enabled => 0,             # LEAVE UNCHANGED
158
    location      => 'TH',
175
    location_enabled      => 1,
176
    itype                 => 'BK',
177
    ccode                 => 'BOOK',
178
    holdingbranch         => undef,         # LEAVE UNCHANGED
179
    location              => 'TH',
159
);
180
);
160
$item = Koha::Items->find($itemnumber);
181
$item = Koha::Items->find($itemnumber);
161
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
182
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
162
183
163
$course_item2 = GetCourseItem( ci_id => $ci_id2 );
184
$course_item2 = GetCourseItem( ci_id => $ci_id2 );
164
is($course_item2->{ccode}, '', 'Course item ccode should be empty');
185
is($course_item2->{ccode_storage}, '', 'Course item ccode storage should be empty');
165
186
166
DelCourseReserve( cr_id => $cr_id2 );
187
DelCourseReserve( cr_id => $cr_id2 );
167
$item = Koha::Items->find($itemnumber);
188
$item = Koha::Items->find($itemnumber);
Lines 195-201 subtest 'Ensure item info is preserved' => sub { Link Here
195
    #Remove course reservei
216
    #Remove course reservei
196
    DelCourseReserve( cr_id => $course_reserve_id );
217
    DelCourseReserve( cr_id => $course_reserve_id );
197
    my $item_after = Koha::Items->find( $item->itemnumber );
218
    my $item_after = Koha::Items->find( $item->itemnumber );
198
    is( $item->itype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course");
219
    is( $item->effective_itemtype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course");
199
    is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course");
220
    is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course");
200
    is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course");
221
    is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course");
201
    is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course");
222
    is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course");
Lines 225-231 subtest 'Ensure item info is preserved' => sub { Link Here
225
    #Remove course reserve
246
    #Remove course reserve
226
    DelCourseReserve( cr_id => $course_reserve_id );
247
    DelCourseReserve( cr_id => $course_reserve_id );
227
    $item_after = Koha::Items->find( $item->itemnumber );
248
    $item_after = Koha::Items->find( $item->itemnumber );
228
    is( $item->itype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course");
249
    is( $item->effective_itemtype, $item_after->itype, "Itemtype is unchanged after adding to and removing from course reserves for inactive course");
229
    is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course");
250
    is( $item->location, $item_after->location, "Location is unchanged after adding to and removing from course reserves for inactive course");
230
    is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course");
251
    is( $item->holdingbranch, $item_after->holdingbranch, "Holdingbranch is unchanged after adding to and removing from course reserves for inactive course");
231
    is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course");
252
    is( $item->ccode, $item_after->ccode, "Collection is unchanged after adding to and removing from course reserves for inactive course");
232
- 

Return to bug 23727