From c38b25f8ddb045036df614e9a1fe532ceb94bcf0 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 3 Apr 2019 14:49:00 +0200 Subject: [PATCH] Bug 22630: Allow to change homebranch in course reserves Test plan: 1. Create a course (disabled) 2. Add a reserve to this course for an item and set a homebranch different from the item's homebranch 3. Enable the course 4. Verify that the item's homebranch has changed 5. Disable the course 6. Verify that the item's homebranch was reset to its initial value 7. prove t/db_dependent/CourseReserves/CourseItems.t Signed-off-by: Liz Rea Signed-off-by: SONIA BOUIS --- C4/CourseReserves.pm | 2 +- course_reserves/add_items.pl | 1 + installer/data/mysql/atomicupdate/bug-22630.perl | 13 ++++++++++++ installer/data/mysql/kohastructure.sql | 2 ++ .../en/modules/course_reserves/add_items-step2.tt | 14 +++++++++++++ .../en/modules/course_reserves/course-details.tt | 23 +++++++++++++++++++++- t/db_dependent/CourseReserves/CourseItems.t | 11 ++++++++++- 7 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug-22630.perl diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm index 428d7e9..0488dd4 100644 --- a/C4/CourseReserves.pm +++ b/C4/CourseReserves.pm @@ -52,7 +52,7 @@ BEGIN { %EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); $DEBUG = 0; - @FIELDS = ( 'itype', 'ccode', 'holdingbranch', 'location' ); + @FIELDS = ( 'itype', 'ccode', 'homebranch', 'holdingbranch', 'location' ); } =head1 NAME diff --git a/course_reserves/add_items.pl b/course_reserves/add_items.pl index 42416b3..f7133b3 100755 --- a/course_reserves/add_items.pl +++ b/course_reserves/add_items.pl @@ -93,6 +93,7 @@ if ( $action eq 'lookup' and $item ) { itemnumber => scalar $cgi->param('itemnumber'), itype => scalar $cgi->param('itype'), ccode => scalar $cgi->param('ccode'), + homebranch => scalar $cgi->param('homebranch'), holdingbranch => scalar $cgi->param('holdingbranch'), location => scalar $cgi->param('location'), ); diff --git a/installer/data/mysql/atomicupdate/bug-22630.perl b/installer/data/mysql/atomicupdate/bug-22630.perl new file mode 100644 index 0000000..02b7fab --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-22630.perl @@ -0,0 +1,13 @@ +$DBversion = 'XXX'; +if (CheckVersion($DBversion)) { + if (!column_exists('course_items', 'homebranch')) { + $dbh->do(q{ + ALTER TABLE course_items + ADD COLUMN homebranch VARCHAR(10) NULL DEFAULT NULL AFTER ccode, + ADD CONSTRAINT course_items_ibfk_3 FOREIGN KEY (homebranch) REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE + }); + } + + SetVersion($DBversion); + print "Upgrade to $DBversion done (Bug 22630 - Add course_items.homebranch)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index da3ff83..35d3a45 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3813,6 +3813,7 @@ CREATE TABLE `course_items` ( `itemnumber` int(11) NOT NULL, -- items.itemnumber for the item on reserve `itype` varchar(10) DEFAULT NULL, -- new itemtype for the item to have while on reserve (optional) `ccode` varchar(80) DEFAULT NULL, -- new category code for the item to have while on reserve (optional) + `homebranch` varchar(10) DEFAULT NULL, -- new home branch for the item to have while on reserve (optional) `holdingbranch` varchar(10) DEFAULT NULL, -- new holding branch for the item to have while on reserve (optional) `location` varchar(80) DEFAULT NULL, -- new shelving location for the item to have while on reseve (optional) `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' @@ -3826,6 +3827,7 @@ CREATE TABLE `course_items` ( -- Constraints for table `course_items` -- ALTER TABLE `course_items` + ADD CONSTRAINT `course_items_ibfk_3` FOREIGN KEY (`homebranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `course_items_ibfk_2` FOREIGN KEY (`holdingbranch`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `course_items_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt index 919c7d5..b59af81 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/course_reserves/add_items-step2.tt @@ -84,6 +84,20 @@
  • + + +
  • + +