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

(-)a/C4/CourseReserves.pm (-83 / +84 lines)
Lines 23-28 use C4::Context; Link Here
23
use C4::Items qw(ModItem);
23
use C4::Items qw(ModItem);
24
use C4::Circulation qw(GetOpenIssue);
24
use C4::Circulation qw(GetOpenIssue);
25
25
26
use Koha::Courses;
27
use Koha::Course::Instructors;
28
use Koha::Course::Items;
29
use Koha::Course::Reserves;
30
26
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS);
31
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $DEBUG @FIELDS);
27
32
28
BEGIN {
33
BEGIN {
Lines 79-97 sub GetCourse { Link Here
79
    my ($course_id) = @_;
84
    my ($course_id) = @_;
80
    warn whoami() . "( $course_id )" if $DEBUG;
85
    warn whoami() . "( $course_id )" if $DEBUG;
81
86
82
    my $query = "SELECT * FROM courses WHERE course_id = ?";
87
    my $course = Koha::Courses->find( $course_id );
83
    my $dbh   = C4::Context->dbh;
88
    return undef unless $course;
84
    my $sth   = $dbh->prepare($query);
89
    $course = $course->unblessed;
85
    $sth->execute($course_id);
86
87
    my $course = $sth->fetchrow_hashref();
88
90
89
    $query = "
91
    my $dbh = C4::Context->dbh;
92
    my $query = "
90
        SELECT b.* FROM course_instructors ci
93
        SELECT b.* FROM course_instructors ci
91
        LEFT JOIN borrowers b ON ( ci.borrowernumber = b.borrowernumber )
94
        LEFT JOIN borrowers b ON ( ci.borrowernumber = b.borrowernumber )
92
        WHERE course_id =  ?
95
        WHERE course_id =  ?
93
    ";
96
    ";
94
    $sth = $dbh->prepare($query);
97
    my $sth = $dbh->prepare($query);
95
    $sth->execute($course_id);
98
    $sth->execute($course_id);
96
    $course->{'instructors'} = $sth->fetchall_arrayref( {} );
99
    $course->{'instructors'} = $sth->fetchall_arrayref( {} );
97
100
Lines 305-311 sub EnableOrDisableCourseItem { Link Here
305
    ## or disable and already disabled item,
308
    ## or disable and already disabled item,
306
    ## as that would cause the fields to swap
309
    ## as that would cause the fields to swap
307
    if ( $course_item->{'enabled'} ne $enabled ) {
310
    if ( $course_item->{'enabled'} ne $enabled ) {
308
        _SwapAllFields($ci_id);
311
        _SwapAllFields($ci_id, $enabled );
309
312
310
        my $query = "
313
        my $query = "
311
            UPDATE course_items
314
            UPDATE course_items
Lines 493-515 sub _AddCourseItem { Link Here
493
    my (%params) = @_;
496
    my (%params) = @_;
494
    warn identify_myself(%params) if $DEBUG;
497
    warn identify_myself(%params) if $DEBUG;
495
498
496
    my ( @fields, @values );
499
    $params{holdingbranch} ||= undef; # Can't be empty string, FK constraint
497
500
498
    push( @fields, 'itemnumber = ?' );
501
    my %data = map { $_ => $params{$_} } @FIELDS;
499
    push( @values, $params{'itemnumber'} );
502
    my %enabled = map { $_ . "_enabled" => $params{ $_ . "_enabled" } } @FIELDS;
500
503
501
    foreach (@FIELDS) {
504
    my $ci = Koha::Course::Item->new(
502
        push( @fields, "$_ = ?" );
505
        {
503
        push( @values, $params{$_} || undef );
506
            itemnumber => $params{itemnumber},
504
    }
507
            %data,
505
508
            %enabled,
506
    my $query = "INSERT INTO course_items SET " . join( ',', @fields );
509
        }
507
    my $dbh = C4::Context->dbh;
510
    )->store();
508
    $dbh->do( $query, undef, @values );
509
510
    my $ci_id = $dbh->last_insert_id( undef, undef, 'course_items', 'ci_id' );
511
511
512
    return $ci_id;
512
    return $ci->id;
513
}
513
}
514
514
515
=head2 _UpdateCourseItem
515
=head2 _UpdateCourseItem
Lines 525-581 sub _UpdateCourseItem { Link Here
525
    my $ci_id         = $params{'ci_id'};
525
    my $ci_id         = $params{'ci_id'};
526
    my $course_item   = $params{'course_item'};
526
    my $course_item   = $params{'course_item'};
527
527
528
    return unless ( $ci_id || $course_item );
528
    $params{holdingbranch} ||= undef; # Can't be empty string, FK constraint
529
530
    $course_item = GetCourseItem( ci_id => $ci_id )
531
      unless ($course_item);
532
    $ci_id = $course_item->{'ci_id'} unless ($ci_id);
533
529
534
    my %mod_params =
530
    return unless ( $ci_id || $course_item );
535
      map {
536
        defined $params{$_} && $params{$_} ne ''
537
          ? ( $_ => $params{$_} )
538
          : ()
539
      } @FIELDS;
540
541
    ModItem( \%mod_params, undef, $course_item->{'itemnumber'} );
542
}
543
544
=head2 _ModStoredFields
545
546
    _ModStoredFields( %params );
547
548
    Updates the values for the 'original' fields in course_items
549
    for a given ci_id
550
551
=cut
552
531
553
sub _ModStoredFields {
532
    $course_item = Koha::Course::Items->find( $ci_id || $course_item->{ci_id} );
554
    my (%params) = @_;
555
    warn identify_myself(%params) if $DEBUG;
556
533
557
    return unless ( $params{'ci_id'} );
534
    my %data = map { $_ => $params{$_} } @FIELDS;
535
    my %enabled = map { $_ . "_enabled" => $params{ $_ . "_enabled" } } @FIELDS;
558
536
559
    my ( @fields_to_update, @values_to_update );
537
    $course_item->update( { %data, %enabled } );
538
    if ( $course_item->is_enabled ) {
539
        my $item_fields = {};
540
        $item_fields->{itype}         = $course_item->itype         if $course_item->itype_enabled;
541
        $item_fields->{ccode}         = $course_item->ccode         if $course_item->ccode_enabled;
542
        $item_fields->{location}      = $course_item->location      if $course_item->location_enabled;
543
        $item_fields->{holdingbranch} = $course_item->holdingbranch if $course_item->holdingbranch_enabled;
560
544
561
    foreach (@FIELDS) {
545
        ModItem( $item_fields, undef, $course_item->itemnumber ) if keys %$item_fields;
562
        if ( defined($params{$_}) ) {
563
            push( @fields_to_update, $_ );
564
            push( @values_to_update, $params{$_} );
565
        }
566
    }
546
    }
567
547
568
    my $query = "UPDATE course_items SET " . join( ',', map { "$_=?" } @fields_to_update ) . " WHERE ci_id = ?";
569
570
    C4::Context->dbh->do( $query, undef, @values_to_update, $params{'ci_id'} )
571
      if (@values_to_update);
572
573
}
548
}
574
549
575
=head2 _RevertFields
550
=head2 _RevertFields
576
551
577
    _RevertFields( ci_id => $ci_id, fields => \@fields_to_revert );
552
    _RevertFields( ci_id => $ci_id, fields => \@fields_to_revert );
578
553
554
    Copies fields from course item storage back to the actual item
555
579
=cut
556
=cut
580
557
581
sub _RevertFields {
558
sub _RevertFields {
Lines 584-600 sub _RevertFields { Link Here
584
561
585
    my $ci_id = $params{'ci_id'};
562
    my $ci_id = $params{'ci_id'};
586
563
587
    return unless ($ci_id);
564
    return unless $ci_id;
588
565
589
    my $course_item = GetCourseItem( ci_id => $params{'ci_id'} );
566
    my $course_item = Koha::Course::Items->find( $ci_id );
590
567
591
    my $mod_item_params;
568
    my $item_fields = {};
592
    foreach my $field ( @FIELDS ) {
569
    $item_fields->{itype}         = $course_item->itype_storage         if $course_item->itype_enabled;
593
        next unless defined $course_item->{$field};
570
    $item_fields->{ccode}         = $course_item->ccode_storage         if $course_item->ccode_enabled;
594
        $mod_item_params->{$field} = $course_item->{$field};
571
    $item_fields->{location}      = $course_item->location_storage      if $course_item->location_enabled;
595
    }
572
    $item_fields->{holdingbranch} = $course_item->holdingbranch_storage if $course_item->holdingbranch_enabled;
596
573
597
    ModItem( $mod_item_params, undef, $course_item->{'itemnumber'} ) if $mod_item_params && %$mod_item_params;
574
    ModItem( $item_fields, undef, $course_item->itemnumber ) if keys %$item_fields;
575
576
    $course_item->itype_storage(undef);
577
    $course_item->ccode_storage(undef);
578
    $course_item->location_storage(undef);
579
    $course_item->holdingbranch_storage(undef);
580
    $course_item->store();
598
}
581
}
599
582
600
=head2 _SwapAllFields
583
=head2 _SwapAllFields
Lines 604-626 sub _RevertFields { Link Here
604
=cut
587
=cut
605
588
606
sub _SwapAllFields {
589
sub _SwapAllFields {
607
    my ($ci_id) = @_;
590
    my ($ci_id, $enabled) = @_;
608
    warn "C4::CourseReserves::_SwapFields( $ci_id )" if $DEBUG;
591
    warn "C4::CourseReserves::_SwapFields( $ci_id )" if $DEBUG;
609
592
610
    my $course_item = GetCourseItem( ci_id => $ci_id );
593
    my $course_item = Koha::Course::Items->find( $ci_id );
611
    my $item = Koha::Items->find($course_item->{'itemnumber'});
594
    my $item = Koha::Items->find( $course_item->itemnumber );
612
595
613
    my %course_item_fields;
596
    if ( $enabled eq 'yes' ) { # Copy item fields to course item storage, course item fields to item
614
    my %item_fields;
597
        $course_item->itype_storage( $item->effective_itemtype )    if $course_item->itype_enabled;
615
    foreach (@FIELDS) {
598
        $course_item->ccode_storage( $item->ccode )                 if $course_item->ccode_enabled;
616
        if ( defined( $course_item->{$_} ) ) {
599
        $course_item->location_storage( $item->location )           if $course_item->location_enabled;
617
            $course_item_fields{$_} = $course_item->{$_};
600
        $course_item->holdingbranch_storage( $item->holdingbranch ) if $course_item->holdingbranch_enabled;
618
            $item_fields{$_}        = $item->$_ || q{};
601
        $course_item->store();
619
        }
602
603
        my $item_fields = {};
604
        $item_fields->{itype}         = $course_item->itype         if $course_item->itype_enabled;
605
        $item_fields->{ccode}         = $course_item->ccode         if $course_item->ccode_enabled;
606
        $item_fields->{location}      = $course_item->location      if $course_item->location_enabled;
607
        $item_fields->{holdingbranch} = $course_item->holdingbranch if $course_item->holdingbranch_enabled;
608
609
        ModItem( $item_fields, undef, $course_item->itemnumber ) if keys %$item_fields;
610
    } else { # Copy course item storage to item
611
        my $item_fields = {};
612
        $item_fields->{itype}         = $course_item->itype_storage         if $course_item->itype_enabled;
613
        $item_fields->{ccode}         = $course_item->ccode_storage         if $course_item->ccode_enabled;
614
        $item_fields->{location}      = $course_item->location_storage      if $course_item->location_enabled;
615
        $item_fields->{holdingbranch} = $course_item->holdingbranch_storage if $course_item->holdingbranch_enabled;
616
617
        ModItem( $item_fields, undef, $course_item->itemnumber ) if keys %$item_fields;
618
619
        $course_item->itype_storage(undef);
620
        $course_item->ccode_storage(undef);
621
        $course_item->location_storage(undef);
622
        $course_item->holdingbranch_storage(undef);
623
        $course_item->store();
620
    }
624
    }
621
622
    ModItem( \%course_item_fields, undef, $course_item->{'itemnumber'} ) if %course_item_fields;
623
    _ModStoredFields( %item_fields, ci_id => $ci_id );
624
}
625
}
625
626
626
=head2 GetCourseItems {
627
=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 code:</label>
69
                        <label class="required" for="ccode">Collection code:</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 code:</label>
52
                            <label class="required" for="ccode">Collection code:</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 101-117 Link Here
101
                            <td>[% cr.item.itemcallnumber | html %]</td>
101
                            <td>[% cr.item.itemcallnumber | html %]</td>
102
                            [% IF item_level_itypes %]
102
                            [% IF item_level_itypes %]
103
                            <td>
103
                            <td>
104
                                [% IF cr.course_item.itype.defined %]
104
                                [% IF cr.course_item.itype_enabled %]
105
                                    [% IF cr.course_item.enabled == 'yes' %]
105
                                    [% IF cr.course_item.enabled == 'yes' %]
106
                                        <strong>[% ItemTypes.GetDescription( cr.item.itype) | html %]</strong>
106
                                        <strong>[% ItemTypes.GetDescription( cr.item.effective_itemtype ) | html %]</strong>
107
                                        [% IF cr.item.itype %]
107
                                        ([% ItemTypes.GetDescription( cr.course_item.itype_storage ) | html %])
108
                                            ([% ItemTypes.GetDescription( cr.course_item.itype ) | html %])
109
                                        [% END %]
110
                                    [% ELSE %]
108
                                    [% ELSE %]
111
                                        [% ItemTypes.GetDescription( cr.course_item.itype ) | html %]
109
                                        [% ItemTypes.GetDescription( cr.course_item.itype ) | html %]
112
                                        [% IF cr.item.itype %]
110
                                        (<strong>[% ItemTypes.GetDescription( cr.item.effective_itemtype) | html %]</strong>)
113
                                            (<strong>[% ItemTypes.GetDescription( cr.item.itype) | html %]</strong>)
114
                                        [% END %]
115
                                    [% END %]
111
                                    [% END %]
116
                                [% ELSE %]
112
                                [% ELSE %]
117
                                     <i>Unchanged</i>
113
                                     <i>Unchanged</i>
Lines 122-132 Link Here
122
                            </td>
118
                            </td>
123
                            [% END %]
119
                            [% END %]
124
                            <td>
120
                            <td>
125
                                 [% IF cr.course_item.ccode.defined %]
121
                                 [% IF cr.course_item.ccode_enabled %]
126
                                     [% IF cr.course_item.enabled == 'yes' %]
122
                                     [% IF cr.course_item.enabled == 'yes' %]
127
                                        <strong>[% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) | html %]</strong>
123
                                        <strong>[% AuthorisedValues.GetByCode( 'CCODE', cr.item.ccode ) | html %]</strong>
128
                                        [% IF cr.item.ccode %]
124
                                        [% IF cr.item.ccode %]
129
                                            ([% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) | html %])
125
                                            ([% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode_storage ) | html %])
130
                                        [% END %]
126
                                        [% END %]
131
                                     [% ELSE %]
127
                                     [% ELSE %]
132
                                        [% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) | html %]
128
                                        [% AuthorisedValues.GetByCode( 'CCODE', cr.course_item.ccode ) | html %]
Lines 142-152 Link Here
142
                                 [% END %]
138
                                 [% END %]
143
                            </td>
139
                            </td>
144
                            <td>
140
                            <td>
145
                                [% IF cr.course_item.location.defined %]
141
                                [% IF cr.course_item.location_enabled %]
146
                                    [% IF cr.course_item.enabled == 'yes' %]
142
                                    [% IF cr.course_item.enabled == 'yes' %]
147
                                        <strong>[% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]</strong>
143
                                        <strong>[% AuthorisedValues.GetByCode( 'LOC', cr.item.permanent_location ) | html %]</strong>
148
                                        [% IF cr.item.permanent_location %]
144
                                        [% IF cr.item.permanent_location %]
149
                                            ([% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) | html %])
145
                                            ([% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location_storage ) | html %])
150
                                        [% END %]
146
                                        [% END %]
151
                                    [% ELSE %]
147
                                    [% ELSE %]
152
                                        [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) | html %]
148
                                        [% AuthorisedValues.GetByCode( 'LOC', cr.course_item.location ) | html %]
Lines 162-172 Link Here
162
                                [% END %]
158
                                [% END %]
163
                            </td>
159
                            </td>
164
                            <td>
160
                            <td>
165
                                [% IF cr.course_item.holdingbranch.defined %]
161
                                [% IF cr.course_item.holdingbranch_enabled %]
166
                                    [% IF cr.course_item.enabled == 'yes' %]
162
                                    [% IF cr.course_item.enabled == 'yes' %]
167
                                        <strong>[% Branches.GetName( cr.item.holdingbranch ) | html %]</strong>
163
                                        <strong>[% Branches.GetName( cr.item.holdingbranch ) | html %]</strong>
168
                                        [% IF cr.item.holdingbranch %]
164
                                        [% IF cr.item.holdingbranch %]
169
                                            ([% Branches.GetName( cr.course_item.holdingbranch ) | html %])
165
                                            ([% Branches.GetName( cr.course_item.holdingbranch_storage ) | html %])
170
                                        [% END %]
166
                                        [% END %]
171
                                    [% ELSE %]
167
                                    [% ELSE %]
172
                                        [% Branches.GetName( cr.course_item.holdingbranch ) | html %]
168
                                        [% Branches.GetName( cr.course_item.holdingbranch ) | html %]
(-)a/t/db_dependent/CourseReserves/CourseItems.t (-41 / +62 lines)
Lines 1-4 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
use Carp::Always;
2
3
3
# This file is part of Koha.
4
# This file is part of Koha.
4
#
5
#
Lines 38-54 create_dependent_objects(); Link Here
38
my ($biblionumber, $itemnumber) = create_bib_and_item();
39
my ($biblionumber, $itemnumber) = create_bib_and_item();
39
40
40
my $ci_id = ModCourseItem(
41
my $ci_id = ModCourseItem(
41
    itemnumber    => $itemnumber,
42
    itemnumber            => $itemnumber,
42
    itype         => 'BK_foo',
43
    itype_enabled         => 1,
43
    ccode         => 'BOOK',
44
    ccode_enabled         => 1,
44
    holdingbranch => 'B2',
45
    holdingbranch_enabled => 1,
45
    location      => 'TH',
46
    location_enabled      => 1,
47
    itype                 => 'BK_foo',
48
    ccode                 => 'BOOK',
49
    holdingbranch         => 'B2',
50
    location              => 'TH',
46
);
51
);
47
52
48
my $course = $builder->build({
53
my $course = $builder->build({
49
    source => 'CourseReserve',
54
    source => 'CourseReserve',
50
    value => {
55
    value => {
51
        ci_id => $ci_id,
56
        ci_id => $ci_id,
57
        enabled => 'no',
52
    }
58
    }
53
});
59
});
54
60
Lines 60-82 my $cr_id = ModCourseReserve( Link Here
60
);
66
);
61
67
62
my $course_item = GetCourseItem( ci_id => $ci_id );
68
my $course_item = GetCourseItem( ci_id => $ci_id );
63
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo');
69
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');
70
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');
71
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');
72
is($course_item->{location_storage}, 'HR', 'Course item location storage should be HR');
67
73
68
my $item = Koha::Items->find($itemnumber);
74
my $item = Koha::Items->find($itemnumber);
69
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo');
75
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');
76
is($item->ccode, 'BOOK', 'Item ccode in course should be BOOK');
71
is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2');
77
is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2');
72
is($item->location, 'TH', 'Item location in course should be TH');
78
is($item->location, 'TH', 'Item location in course should be TH');
73
79
74
ModCourseItem(
80
ModCourseItem(
75
    itemnumber    => $itemnumber,
81
    itemnumber            => $itemnumber,
76
    itype         => 'BK_foo',
82
    itype_enabled         => 1,
77
    ccode         => 'DVD',
83
    ccode_enabled         => 1,
78
    holdingbranch => 'B3',
84
    holdingbranch_enabled => 1,
79
    location      => 'TH',
85
    location_enabled      => 1,
86
    itype                 => 'BK_foo',
87
    ccode                 => 'DVD',
88
    holdingbranch         => 'B3',
89
    location              => 'TH',
80
);
90
);
81
91
82
ModCourseReserve(
92
ModCourseReserve(
Lines 87-106 ModCourseReserve( Link Here
87
);
97
);
88
98
89
$course_item = GetCourseItem( ci_id => $ci_id );
99
$course_item = GetCourseItem( ci_id => $ci_id );
90
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo');
100
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');
101
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');
102
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');
103
is($course_item->{location_storage}, 'HR', 'Course item location storage should be HR');
94
104
95
$item = Koha::Items->find($itemnumber);
105
$item = Koha::Items->find($itemnumber);
96
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo');
106
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');
107
is($item->ccode, 'DVD', 'Item ccode in course should be DVD');
98
is($item->holdingbranch, 'B3', 'Item holding branch in course should be B3');
108
is($item->holdingbranch, 'B3', 'Item holding branch in course should be B3');
99
is($item->location, 'TH', 'Item location in course should be TH');
109
is($item->location, 'TH', 'Item location in course should be TH');
100
110
101
DelCourseReserve( cr_id => $cr_id );
111
DelCourseReserve( cr_id => $cr_id );
102
$item = Koha::Items->find($itemnumber);
112
$item = Koha::Items->find($itemnumber);
103
is($item->itype, 'CD_foo', 'Item type removed from course should be set back to CD_foo');
113
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');
114
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');
115
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');
116
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');
122
is($item->ccode, '', 'Item ccode should be empty');
113
123
114
my $ci_id2 = ModCourseItem(
124
my $ci_id2 = ModCourseItem(
115
    itemnumber    => $itemnumber,
125
    itemnumber            => $itemnumber,
116
    itype         => 'CD_foo',
126
    itype_enabled         => 1,
117
    ccode         => 'BOOK',
127
    ccode_enabled         => 1,
118
    holdingbranch => 'B1',
128
    holdingbranch_enabled => 1,
119
    location      => 'HR',
129
    location_enabled      => 1,
130
    itype                 => 'CD_foo',
131
    ccode                 => 'BOOK',
132
    holdingbranch         => 'B1',
133
    location              => 'HR',
120
);
134
);
121
135
122
my $cr_id2 = ModCourseReserve(
136
my $cr_id2 = ModCourseReserve(
Lines 130-143 $item = Koha::Items->find($itemnumber); Link Here
130
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
144
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
131
145
132
my $course_item2 = GetCourseItem( ci_id => $ci_id2 );
146
my $course_item2 = GetCourseItem( ci_id => $ci_id2 );
133
is($course_item2->{ccode}, '', 'Course item ccode should be empty');
147
is($course_item2->{ccode_storage}, '', 'Course item ccode storage should be empty');
134
148
135
ModCourseItem(
149
ModCourseItem(
136
    itemnumber    => $itemnumber,
150
    itemnumber            => $itemnumber,
137
    itype         => 'CD_foo',
151
    itype_enabled         => 1,
138
    ccode         => 'DVD',
152
    ccode_enabled         => 1,
139
    holdingbranch => 'B1',
153
    holdingbranch_enabled => 1,
140
    location      => 'HR',
154
    location_enabled      => 1,
155
    itype                 => 'CD_foo',
156
    ccode                 => 'DVD',
157
    holdingbranch         => 'B1',
158
    location              => 'HR',
141
);
159
);
142
160
143
ModCourseReserve(
161
ModCourseReserve(
Lines 151-167 $item = Koha::Items->find($itemnumber); Link Here
151
is($item->ccode, 'DVD', 'Item ccode should be DVD');
169
is($item->ccode, 'DVD', 'Item ccode should be DVD');
152
170
153
ModCourseItem(
171
ModCourseItem(
154
    itemnumber    => $itemnumber,
172
    itemnumber            => $itemnumber,
155
    itype         => 'BK',
173
    itype_enabled         => 1,
156
    ccode         => 'BOOK',
174
    ccode_enabled         => 1,
157
    holdingbranch => '', # LEAVE UNCHANGED
175
    holdingbranch_enabled => 0,             # LEAVE UNCHANGED
158
    location      => 'TH',
176
    location_enabled      => 1,
177
    itype                 => 'BK',
178
    ccode                 => 'BOOK',
179
    holdingbranch         => undef,         # LEAVE UNCHANGED
180
    location              => 'TH',
159
);
181
);
160
$item = Koha::Items->find($itemnumber);
182
$item = Koha::Items->find($itemnumber);
161
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
183
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
162
184
163
$course_item2 = GetCourseItem( ci_id => $ci_id2 );
185
$course_item2 = GetCourseItem( ci_id => $ci_id2 );
164
is($course_item2->{ccode}, '', 'Course item ccode should be empty');
186
is($course_item2->{ccode_storage}, '', 'Course item ccode storage should be empty');
165
187
166
DelCourseReserve( cr_id => $cr_id2 );
188
DelCourseReserve( cr_id => $cr_id2 );
167
$item = Koha::Items->find($itemnumber);
189
$item = Koha::Items->find($itemnumber);
Lines 195-201 subtest 'Ensure item info is preserved' => sub { Link Here
195
    #Remove course reservei
217
    #Remove course reservei
196
    DelCourseReserve( cr_id => $course_reserve_id );
218
    DelCourseReserve( cr_id => $course_reserve_id );
197
    my $item_after = Koha::Items->find( $item->itemnumber );
219
    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");
220
    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");
221
    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");
222
    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");
223
    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
247
    #Remove course reserve
226
    DelCourseReserve( cr_id => $course_reserve_id );
248
    DelCourseReserve( cr_id => $course_reserve_id );
227
    $item_after = Koha::Items->find( $item->itemnumber );
249
    $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");
250
    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");
251
    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");
252
    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");
253
    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