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

(-)a/C4/CourseReserves.pm (-2 / +2 lines)
Lines 642-648 sub _RevertFields { Link Here
642
    my @fields_to_null;
642
    my @fields_to_null;
643
    foreach my $field (@fields) {
643
    foreach my $field (@fields) {
644
        foreach (@FIELDS) {
644
        foreach (@FIELDS) {
645
            if ( $field eq $_ && $course_item->{$_} ) {
645
            if ( $field eq $_ && $course_item->{$_} ne '<UNCHANGED>' ) {
646
                $mod_item_params->{$_} = $course_item->{$_};
646
                $mod_item_params->{$_} = $course_item->{$_};
647
                push( @fields_to_null, $_ );
647
                push( @fields_to_null, $_ );
648
            }
648
            }
Lines 671-677 sub _SwapAllFields { Link Here
671
    my %course_item_fields;
671
    my %course_item_fields;
672
    my %item_fields;
672
    my %item_fields;
673
    foreach (@FIELDS) {
673
    foreach (@FIELDS) {
674
        if ( defined( $course_item->{$_} ) ) {
674
        if ( defined( $course_item->{$_} ) && $course_item->{$_} ne '<UNCHANGED>' ) {
675
            $course_item_fields{$_} = $course_item->{$_};
675
            $course_item_fields{$_} = $course_item->{$_};
676
            $item_fields{$_}        = $item->{$_} || q{};
676
            $item_fields{$_}        = $item->{$_} || q{};
677
        }
677
        }
(-)a/installer/data/mysql/atomicupdate/bug_10382-changes-on-courseitems-table.sql (+4 lines)
Line 0 Link Here
1
ALTER TABLE course_items DROP FOREIGN KEY course_items_ibfk_2;
2
ALTER TABLE course_items MODIFY itype VARCHAR(20);
3
ALTER TABLE course_items MODIFY ccode VARCHAR(20);
4
ALTER TABLE course_items MODIFY holdingbranch VARCHAR(20);
(-)a/installer/data/mysql/kohastructure.sql (-4 / +3 lines)
Lines 3780-3788 DROP TABLE IF EXISTS course_items; Link Here
3780
CREATE TABLE `course_items` (
3780
CREATE TABLE `course_items` (
3781
  `ci_id` int(11) NOT NULL AUTO_INCREMENT, -- course item id
3781
  `ci_id` int(11) NOT NULL AUTO_INCREMENT, -- course item id
3782
  `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve
3782
  `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve
3783
  `itype` varchar(10) DEFAULT NULL, -- new itemtype for the item to have while on reserve (optional)
3783
  `itype` varchar(20) DEFAULT NULL, -- new itemtype for the item to have while on reserve (optional)
3784
  `ccode` varchar(10) DEFAULT NULL, -- new category code for the item to have while on reserve (optional)
3784
  `ccode` varchar(20) DEFAULT NULL, -- new category code for the item to have while on reserve (optional)
3785
  `holdingbranch` varchar(10) DEFAULT NULL, -- new holding branch for the item to have while on reserve (optional)
3785
  `holdingbranch` varchar(20) DEFAULT NULL, -- new holding branch for the item to have while on reserve (optional)
3786
  `location` varchar(80) DEFAULT NULL, -- new shelving location for the item to have while on reseve (optional)
3786
  `location` varchar(80) DEFAULT NULL, -- new shelving location for the item to have while on reseve (optional)
3787
  `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'
3787
  `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'
3788
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
3788
  `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
Lines 3795-3801 CREATE TABLE `course_items` ( Link Here
3795
-- Constraints for table `course_items`
3795
-- Constraints for table `course_items`
3796
--
3796
--
3797
ALTER TABLE `course_items`
3797
ALTER TABLE `course_items`
3798
  ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE,
3799
  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
3798
  ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE;
3800
3799
3801
--
3800
--
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt (-4 / +4 lines)
Lines 35-41 Link Here
35
                    <li>
35
                    <li>
36
                        <label class="required" for="itype">Item type:</label>
36
                        <label class="required" for="itype">Item type:</label>
37
                        <select id="itype" name="itype">
37
                        <select id="itype" name="itype">
38
                            <option value="">LEAVE UNCHANGED</option>
38
                            <option value="<UNCHANGED>">LEAVE UNCHANGED</option>
39
39
40
                            [% FOREACH it IN itypes %]
40
                            [% FOREACH it IN itypes %]
41
                                [% IF course_item.itype.defined && ( ( course.enabled == 'yes' && it.itemtype == item.itype ) || ( course.enabled == 'no' && it.itemtype == course_item.itype ) ) %]
41
                                [% IF course_item.itype.defined && ( ( course.enabled == 'yes' && it.itemtype == item.itype ) || ( course.enabled == 'no' && it.itemtype == course_item.itype ) ) %]
Lines 51-57 Link Here
51
                    <li>
51
                    <li>
52
                        <label class="required" for="ccode">Collection code:</label>
52
                        <label class="required" for="ccode">Collection code:</label>
53
                        <select id="ccode" name="ccode">
53
                        <select id="ccode" name="ccode">
54
                            <option value="">LEAVE UNCHANGED</option>
54
                            <option value="<UNCHANGED>">LEAVE UNCHANGED</option>
55
55
56
                            [% FOREACH c IN ccodes %]
56
                            [% FOREACH c IN ccodes %]
57
                                [% IF course_item.ccode.defined && ( ( course.enabled == 'yes' && c.authorised_value == item.ccode ) || ( course.enabled == 'no' && c.authorised_value == course_item.ccode ) ) %]
57
                                [% IF course_item.ccode.defined && ( ( course.enabled == 'yes' && c.authorised_value == item.ccode ) || ( course.enabled == 'no' && c.authorised_value == course_item.ccode ) ) %]
Lines 66-72 Link Here
66
                    <li>
66
                    <li>
67
                        <label class="required" for="location">Shelving location:</label>
67
                        <label class="required" for="location">Shelving location:</label>
68
                        <select id="location" name="location">
68
                        <select id="location" name="location">
69
                            <option value="">LEAVE UNCHANGED</option>
69
                            <option value="<UNCHANGED>">LEAVE UNCHANGED</option>
70
70
71
                            [% FOREACH s IN locations %]
71
                            [% FOREACH s IN locations %]
72
                                [% IF course_item.location.defined && ( ( course.enabled == 'yes' && s.authorised_value == item.location ) || ( course.enabled == 'no' && s.authorised_value == course_item.location ) ) %]
72
                                [% IF course_item.location.defined && ( ( course.enabled == 'yes' && s.authorised_value == item.location ) || ( course.enabled == 'no' && s.authorised_value == course_item.location ) ) %]
Lines 81-87 Link Here
81
                    <li>
81
                    <li>
82
                        <label class="required" for="holdingbranch">Holding library:</label>
82
                        <label class="required" for="holdingbranch">Holding library:</label>
83
                        <select id="holdingbranch" name="holdingbranch">
83
                        <select id="holdingbranch" name="holdingbranch">
84
                            <option value="">LEAVE UNCHANGED</option>
84
                            <option value="<UNCHANGED>">LEAVE UNCHANGED</option>
85
                            [% FOREACH b IN Branches.all() %]
85
                            [% FOREACH b IN Branches.all() %]
86
                                [% IF course_item.holdingbranch.defined && ( ( course.enabled == 'yes' && b.value == item.holdingbranch ) || ( course.enabled == 'no' && b.value == course_item.holdingbranch ) ) %]
86
                                [% IF course_item.holdingbranch.defined && ( ( course.enabled == 'yes' && b.value == item.holdingbranch ) || ( course.enabled == 'no' && b.value == course_item.holdingbranch ) ) %]
87
                                    <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
87
                                    <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option>
(-)a/t/db_dependent/CourseReserves/CourseItems.t (-5 / +8 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 => 17;
26
use Test::More tests => 21;
27
27
28
BEGIN {
28
BEGIN {
29
    require_ok('C4::CourseReserves');
29
    require_ok('C4::CourseReserves');
Lines 83-92 is($item->ccode, '', 'Item ccode should be empty'); Link Here
83
83
84
my $ci_id2 = ModCourseItem(
84
my $ci_id2 = ModCourseItem(
85
    itemnumber    => $itemnumber,
85
    itemnumber    => $itemnumber,
86
    itype         => 'CD_foo',
86
    itype         => '<UNCHANGED>',
87
    ccode         => 'BOOK',
87
    ccode         => 'BOOK',
88
    holdingbranch => 'B1',
88
    holdingbranch => '<UNCHANGED>',
89
    location      => 'HR',
89
    location      => '<UNCHANGED>',
90
);
90
);
91
91
92
my $cr_id2 = ModCourseReserve(
92
my $cr_id2 = ModCourseReserve(
Lines 97-106 my $cr_id2 = ModCourseReserve( Link Here
97
);
97
);
98
98
99
$item = Koha::Items->find($itemnumber);
99
$item = Koha::Items->find($itemnumber);
100
is($item->itype, 'CD_foo', 'Item type should be CD_foo');
100
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
101
is($item->ccode, 'BOOK', 'Item ccode should be BOOK');
101
102
102
my $course_item2 = GetCourseItem( ci_id => $ci_id2 );
103
my $course_item2 = GetCourseItem( ci_id => $ci_id2 );
104
is($course_item2->{itype}, '<UNCHANGED>', 'Course item ccode should be <UNCHANGED>');
103
is($course_item2->{ccode}, '', 'Course item ccode should be empty');
105
is($course_item2->{ccode}, '', 'Course item ccode should be empty');
106
is($course_item2->{holdingbranch}, '<UNCHANGED>', 'Course item holding branch should be <UNCHANGED>');
107
is($course_item2->{location}, '<UNCHANGED>', 'Course item location should be <UNCHANGED>');
104
108
105
DelCourseReserve( cr_id => $cr_id2 );
109
DelCourseReserve( cr_id => $cr_id2 );
106
$item = Koha::Items->find($itemnumber);
110
$item = Koha::Items->find($itemnumber);
107
- 

Return to bug 10382