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

(-)a/C4/CourseReserves.pm (-1 / +1 lines)
Lines 52-58 BEGIN { Link Here
52
    %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
52
    %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
53
53
54
    $DEBUG = 0;
54
    $DEBUG = 0;
55
    @FIELDS = ( 'itype', 'ccode', 'holdingbranch', 'location' );
55
    @FIELDS = ( 'itype', 'ccode', 'homebranch', 'holdingbranch', 'location' );
56
}
56
}
57
57
58
=head1 NAME
58
=head1 NAME
(-)a/course_reserves/add_items.pl (+1 lines)
Lines 93-98 if ( $action eq 'lookup' and $item ) { Link Here
93
        itemnumber    => scalar $cgi->param('itemnumber'),
93
        itemnumber    => scalar $cgi->param('itemnumber'),
94
        itype         => scalar $cgi->param('itype'),
94
        itype         => scalar $cgi->param('itype'),
95
        ccode         => scalar $cgi->param('ccode'),
95
        ccode         => scalar $cgi->param('ccode'),
96
        homebranch    => scalar $cgi->param('homebranch'),
96
        holdingbranch => scalar $cgi->param('holdingbranch'),
97
        holdingbranch => scalar $cgi->param('holdingbranch'),
97
        location      => scalar $cgi->param('location'),
98
        location      => scalar $cgi->param('location'),
98
    );
99
    );
(-)a/installer/data/mysql/atomicupdate/bug-22630.perl (+13 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if (CheckVersion($DBversion)) {
3
    if (!column_exists('course_items', 'homebranch')) {
4
        $dbh->do(q{
5
            ALTER TABLE course_items
6
            ADD COLUMN homebranch VARCHAR(10) NULL DEFAULT NULL AFTER ccode,
7
            ADD CONSTRAINT course_items_ibfk_3 FOREIGN KEY (homebranch) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE
8
        });
9
    }
10
11
    SetVersion($DBversion);
12
    print "Upgrade to $DBversion done (Bug 22630 - Add course_items.homebranch)\n";
13
}
(-)a/installer/data/mysql/kohastructure.sql (+2 lines)
Lines 3753-3758 CREATE TABLE `course_items` ( Link Here
3753
  `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve
3753
  `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve
3754
  `itype` varchar(10) DEFAULT NULL, -- new itemtype for the item to have while on reserve (optional)
3754
  `itype` varchar(10) DEFAULT NULL, -- new itemtype for the item to have while on reserve (optional)
3755
  `ccode` varchar(80) DEFAULT NULL, -- new category code for the item to have while on reserve (optional)
3755
  `ccode` varchar(80) DEFAULT NULL, -- new category code for the item to have while on reserve (optional)
3756
  `homebranch` varchar(10) DEFAULT NULL, -- new home branch for the item to have while on reserve (optional)
3756
  `holdingbranch` varchar(10) DEFAULT NULL, -- new holding branch for the item to have while on reserve (optional)
3757
  `holdingbranch` varchar(10) DEFAULT NULL, -- new holding branch for the item to have while on reserve (optional)
3757
  `location` varchar(80) DEFAULT NULL, -- new shelving location for the item to have while on reseve (optional)
3758
  `location` varchar(80) DEFAULT NULL, -- new shelving location for the item to have while on reseve (optional)
3758
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no', -- if at least one enabled course has this item on reseve, this field will be 'yes', otherwise it will be 'no'
3759
  `enabled` enum('yes','no') NOT NULL DEFAULT 'no', -- if at least one enabled course has this item on reseve, this field will be 'yes', otherwise it will be 'no'
Lines 3766-3771 CREATE TABLE `course_items` ( Link Here
3766
-- Constraints for table `course_items`
3767
-- Constraints for table `course_items`
3767
--
3768
--
3768
ALTER TABLE `course_items`
3769
ALTER TABLE `course_items`
3770
  ADD CONSTRAINT `course_items_ibfk_3` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
3769
  ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
3771
  ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
3770
  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
3772
  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
3771
3773
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt (+14 lines)
Lines 83-88 Link Here
83
                        </select>
83
                        </select>
84
                    </li>
84
                    </li>
85
85
86
                    <li>
87
                        <label class="required" for="homebranch">Home library:</label>
88
                        <select id="homebranch" name="homebranch">
89
                            <option value="">LEAVE UNCHANGED</option>
90
                            [% FOREACH b IN Branches.all() %]
91
                                [% IF course_item.homebranch.defined && ( ( course.enabled == 'yes' && b.value == item.homebranch ) || ( course.enabled == 'no' && b.value == course_item.homebranch ) ) %]
92
                                    <option value="[% b.branchcode | html %]" selected="selected">[% b.branchname | html %]</option>
93
                                [% ELSE %]
94
                                    <option value="[% b.branchcode | html %]">[% b.branchname | html %]</option>
95
                                [% END %]
96
                            [% END %]
97
                        </select>
98
                    </li>
99
86
                    <li>
100
                    <li>
87
                        <label class="required" for="holdingbranch">Holding library:</label>
101
                        <label class="required" for="holdingbranch">Holding library:</label>
88
                        <select id="holdingbranch" name="holdingbranch">
102
                        <select id="holdingbranch" name="holdingbranch">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/course-details.tt (-1 / +22 lines)
Lines 81-87 Link Here
81
                        [% IF item_level_itypes %]<th>Item type</th>[% END %]
81
                        [% IF item_level_itypes %]<th>Item type</th>[% END %]
82
                        <th>Collection</th>
82
                        <th>Collection</th>
83
                        <th>Location</th>
83
                        <th>Location</th>
84
                        <th>Library</th>
84
                        <th>Home Library</th>
85
                        <th>Holding Library</th>
85
                        <th>Staff note</th>
86
                        <th>Staff note</th>
86
                        <th>Public note</th>
87
                        <th>Public note</th>
87
                        <th>Link</th>
88
                        <th>Link</th>
Lines 161-166 Link Here
161
                                    [% END %]
162
                                    [% END %]
162
                                [% END %]
163
                                [% END %]
163
                            </td>
164
                            </td>
165
                            <td>
166
                                [% IF cr.course_item.homebranch.defined %]
167
                                    [% IF cr.course_item.enabled == 'yes' %]
168
                                        <strong>[% Branches.GetName( cr.item.homebranch ) | html %]</strong>
169
                                        [% IF cr.item.homebranch %]
170
                                            ([% Branches.GetName( cr.course_item.homebranch ) | html %])
171
                                        [% END %]
172
                                    [% ELSE %]
173
                                        [% Branches.GetName( cr.course_item.homebranch ) | html %]
174
                                        [% IF cr.item.homebranch %]
175
                                            (<strong>[% Branches.GetName( cr.item.homebranch ) | html %]</strong>)
176
                                        [% END %]
177
                                    [% END %]
178
                                [% ELSE %]
179
                                    <i>Unchanged</i>
180
                                    [% IF cr.item.homebranch %]
181
                                        ([% Branches.GetName( cr.item.homebranch ) | html %])
182
                                    [% END %]
183
                                [% END %]
184
                            </td>
164
                            <td>
185
                            <td>
165
                                [% IF cr.course_item.holdingbranch.defined %]
186
                                [% IF cr.course_item.holdingbranch.defined %]
166
                                    [% IF cr.course_item.enabled == 'yes' %]
187
                                    [% IF cr.course_item.enabled == 'yes' %]
(-)a/t/db_dependent/CourseReserves/CourseItems.t (-2 / +10 lines)
Lines 23-29 use C4::CourseReserves qw/ModCourseItem ModCourseReserve DelCourseReserve GetCou Link Here
23
use C4::Context;
23
use C4::Context;
24
use Koha::Items;
24
use Koha::Items;
25
25
26
use Test::More tests => 28;
26
use Test::More tests => 33;
27
27
28
BEGIN {
28
BEGIN {
29
    require_ok('C4::CourseReserves');
29
    require_ok('C4::CourseReserves');
Lines 41-46 my $ci_id = ModCourseItem( Link Here
41
    itemnumber    => $itemnumber,
41
    itemnumber    => $itemnumber,
42
    itype         => 'BK_foo',
42
    itype         => 'BK_foo',
43
    ccode         => 'BOOK',
43
    ccode         => 'BOOK',
44
    homebranch    => 'B2',
44
    holdingbranch => 'B2',
45
    holdingbranch => 'B2',
45
    location      => 'TH',
46
    location      => 'TH',
46
);
47
);
Lines 62-73 my $cr_id = ModCourseReserve( Link Here
62
my $course_item = GetCourseItem( ci_id => $ci_id );
63
my $course_item = GetCourseItem( ci_id => $ci_id );
63
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo');
64
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo');
64
is($course_item->{ccode}, 'CD', 'Course item ccode should be CD');
65
is($course_item->{ccode}, 'CD', 'Course item ccode should be CD');
66
is($course_item->{homebranch}, 'B1', 'Course item home branch should be B1');
65
is($course_item->{holdingbranch}, 'B1', 'Course item holding branch should be B1');
67
is($course_item->{holdingbranch}, 'B1', 'Course item holding branch should be B1');
66
is($course_item->{location}, 'HR', 'Course item location should be HR');
68
is($course_item->{location}, 'HR', 'Course item location should be HR');
67
69
68
my $item = Koha::Items->find($itemnumber);
70
my $item = Koha::Items->find($itemnumber);
69
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo');
71
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo');
70
is($item->ccode, 'BOOK', 'Item ccode in course should be BOOK');
72
is($item->ccode, 'BOOK', 'Item ccode in course should be BOOK');
73
is($item->homebranch, 'B2', 'Item home branch in course should be B2');
71
is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2');
74
is($item->holdingbranch, 'B2', 'Item holding branch in course should be B2');
72
is($item->location, 'TH', 'Item location in course should be TH');
75
is($item->location, 'TH', 'Item location in course should be TH');
73
76
Lines 75-80 ModCourseItem( Link Here
75
    itemnumber    => $itemnumber,
78
    itemnumber    => $itemnumber,
76
    itype         => 'BK_foo',
79
    itype         => 'BK_foo',
77
    ccode         => 'DVD',
80
    ccode         => 'DVD',
81
    homebranch    => 'B3',
78
    holdingbranch => 'B3',
82
    holdingbranch => 'B3',
79
    location      => 'TH',
83
    location      => 'TH',
80
);
84
);
Lines 89-100 ModCourseReserve( Link Here
89
$course_item = GetCourseItem( ci_id => $ci_id );
93
$course_item = GetCourseItem( ci_id => $ci_id );
90
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo');
94
is($course_item->{itype}, 'CD_foo', 'Course item itype should be CD_foo');
91
is($course_item->{ccode}, 'CD', 'Course item ccode should be CD');
95
is($course_item->{ccode}, 'CD', 'Course item ccode should be CD');
96
is($course_item->{homebranch}, 'B1', 'Course item home branch should be B1');
92
is($course_item->{holdingbranch}, 'B1', 'Course item holding branch should be B1');
97
is($course_item->{holdingbranch}, 'B1', 'Course item holding branch should be B1');
93
is($course_item->{location}, 'HR', 'Course item location should be HR');
98
is($course_item->{location}, 'HR', 'Course item location should be HR');
94
99
95
$item = Koha::Items->find($itemnumber);
100
$item = Koha::Items->find($itemnumber);
96
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo');
101
is($item->itype, 'BK_foo', 'Item type in course should be BK_foo');
97
is($item->ccode, 'DVD', 'Item ccode in course should be DVD');
102
is($item->ccode, 'DVD', 'Item ccode in course should be DVD');
103
is($item->homebranch, 'B3', 'Item home branch in course should be B3');
98
is($item->holdingbranch, 'B3', 'Item holding branch in course should be B3');
104
is($item->holdingbranch, 'B3', 'Item holding branch in course should be B3');
99
is($item->location, 'TH', 'Item location in course should be TH');
105
is($item->location, 'TH', 'Item location in course should be TH');
100
106
Lines 102-107 DelCourseReserve( cr_id => $cr_id ); Link Here
102
$item = Koha::Items->find($itemnumber);
108
$item = Koha::Items->find($itemnumber);
103
is($item->itype, 'CD_foo', 'Item type removed from course should be set back to CD_foo');
109
is($item->itype, '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');
110
is($item->ccode, 'CD', 'Item ccode removed from course should be set back to CD');
111
is($item->homebranch, 'B1', 'Item home branch removed from course should be set back B1');
105
is($item->holdingbranch, 'B1', 'Item holding branch removed from course should be set back B1');
112
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');
113
is($item->location, 'HR', 'Item location removed from course should be TH');
107
114
Lines 115-120 my $ci_id2 = ModCourseItem( Link Here
115
    itemnumber    => $itemnumber,
122
    itemnumber    => $itemnumber,
116
    itype         => 'CD_foo',
123
    itype         => 'CD_foo',
117
    ccode         => 'BOOK',
124
    ccode         => 'BOOK',
125
    homebranch    => 'B1',
118
    holdingbranch => 'B1',
126
    holdingbranch => 'B1',
119
    location      => 'HR',
127
    location      => 'HR',
120
);
128
);
Lines 136-141 ModCourseItem( Link Here
136
    itemnumber    => $itemnumber,
144
    itemnumber    => $itemnumber,
137
    itype         => 'CD_foo',
145
    itype         => 'CD_foo',
138
    ccode         => 'DVD',
146
    ccode         => 'DVD',
147
    homebranch    => 'B1',
139
    holdingbranch => 'B1',
148
    holdingbranch => 'B1',
140
    location      => 'HR',
149
    location      => 'HR',
141
);
150
);
142
- 

Return to bug 22630