Bugzilla – Attachment 159236 Details for
Bug 34142
Add column sub_location to items table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34142: Add new column sub_location to (deleted)items
0001-Bug-34142-Add-new-column-sub_location-to-deleted-ite.patch (text/plain), 11.09 KB, created by
Emmi Takkinen
on 2023-11-24 12:18:49 UTC
(
hide
)
Description:
Bug 34142: Add new column sub_location to (deleted)items
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2023-11-24 12:18:49 UTC
Size:
11.09 KB
patch
obsolete
>From 4362eb5b86ae80467b90fafbc2231d0facf3b1d0 Mon Sep 17 00:00:00 2001 >From: Pasi Kallinen <pasi.kallinen@koha-suomi.fi> >Date: Mon, 6 Jun 2022 07:16:45 +0300 >Subject: [PATCH 1/2] Bug 34142: Add new column sub_location to (deleted)items > >Add new column sub_location to items and deleteditems table. >Column can be used to indicate e.g. if item has some other >more specific location than permanent location. > >To test: >1) Add new authorized value for sublocation e.g. "SUBLOC" >and add some values to it. >2) Add new 952 subfield e.g. S to MARC framework and link >your new authorized value "SUBLOC" to it. >3) Link subfield to items.sub_location field in "Koha to MARC >mapping" (add 952,S). >4) Find a record and attempt to add new item to it. >=> Note that new subfield S is now displayed on item form >and dropdown selector contains values added to "SUBLOC". >=> Saving should be successfull. >=> After saving confirm that sublocation is displayed in >its own column in items listing above item form and that >sublocation is displayed with correct description. >5) Attempt to modify item. >=> Confirm that sublocation is displayed and it's correct. >6) Attempt to delete item. >=> Deleting should be successfull. > >Also confirm that sub location is displayed on these pages: >1) detail.pl >2) moredetail.pl >3. returns.pl > >Sponsored-by: Koha-Suomi Oy >--- > Koha/Database/Columns.pm | 1 + > Koha/Item.pm | 1 + > api/v1/swagger/definitions/item.yaml | 5 +++++ > circ/returns.pl | 4 +++- > .../data/mysql/atomicupdate/bug_34142.pl | 19 +++++++++++++++++++ > installer/data/mysql/kohastructure.sql | 2 ++ > .../prog/en/modules/catalogue/detail.tt | 6 ++++++ > .../prog/en/modules/catalogue/moredetail.tt | 6 ++++++ > .../prog/en/modules/circ/returns.tt | 2 +- > 9 files changed, 44 insertions(+), 2 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_34142.pl > >diff --git a/Koha/Database/Columns.pm b/Koha/Database/Columns.pm >index 4637d0cab3..feccf24d18 100644 >--- a/Koha/Database/Columns.pm >+++ b/Koha/Database/Columns.pm >@@ -229,6 +229,7 @@ sub columns { > "deleted_on" => __("Deleted on"), > "location" => __("Shelving location"), > "permanent_location" => __("Permanent shelving location"), >+ "sub_location" => __("Sublocation"), > "onloan" => __("Due date"), > "cn_source" => __("Source of classification / shelving scheme"), > "cn_sort" => __("Koha normalized classification for sorting"), >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 22eaceac94..7df22b802d 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -1716,6 +1716,7 @@ sub to_api_mapping { > stocknumber => 'inventory_number', > new_status => 'new_status', > deleted_on => undef, >+ sub_location => 'sub_location' > }; > } > >diff --git a/api/v1/swagger/definitions/item.yaml b/api/v1/swagger/definitions/item.yaml >index 1d0ed7ac95..b44fa20045 100644 >--- a/api/v1/swagger/definitions/item.yaml >+++ b/api/v1/swagger/definitions/item.yaml >@@ -220,6 +220,11 @@ properties: > - string > - "null" > description: "'new' value, whatever free-text information." >+ sub_location: >+ type: >+ - string >+ - "null" >+ description: sub_location for this item > exclude_from_local_holds_priority: > type: boolean > description: Exclude this item from local holds priority. >diff --git a/circ/returns.pl b/circ/returns.pl >index c0df061139..52fd0d97d6 100755 >--- a/circ/returns.pl >+++ b/circ/returns.pl >@@ -760,6 +760,8 @@ my $count = 0; > my @riloop; > my $shelflocations = > { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.location' } ) }; >+my $sublocation = >+ { map { $_->{authorised_value} => $_->{lib} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => '', kohafield => 'items.sub_location' } ) }; > foreach ( sort { $a <=> $b } keys %returneditems ) { > my %ri; > if ( $count++ < $returned_counter ) { >@@ -815,7 +817,7 @@ foreach ( sort { $a <=> $b } keys %returneditems ) { > $ri{location} = $item->location; > my $shelfcode = $ri{'location'}; > $ri{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) ); >- >+ $ri{sub_location} = $sublocation->{$item->sub_location} if ( defined( $item->sub_location ) && defined($sublocation) && exists( $sublocation->{$item->sub_location} ) ); > } > else { > last; >diff --git a/installer/data/mysql/atomicupdate/bug_34142.pl b/installer/data/mysql/atomicupdate/bug_34142.pl >new file mode 100644 >index 0000000000..5d225c970f >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_34142.pl >@@ -0,0 +1,19 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "34142", >+ description => "Add column sub_location to (deleted)items table", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ >+ if( !column_exists( 'items', 'sub_location' ) ) { >+ $dbh->do(q{ALTER TABLE items ADD COLUMN sub_location VARCHAR(80) DEFAULT NULL AFTER permanent_location}); >+ say $out "Added new column items.sub_location"; >+ } >+ if( !column_exists( 'deleteditems', 'sub_location' ) ) { >+ $dbh->do(q{ALTER TABLE deleteditems ADD COLUMN sub_location VARCHAR(80) DEFAULT NULL AFTER permanent_location}); >+ say $out "Added new column deleteditems.sub_location"; >+ } >+ }, >+}; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 09a6adcc47..2406ee46e1 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2767,6 +2767,7 @@ CREATE TABLE `deleteditems` ( > `deleted_on` datetime DEFAULT NULL COMMENT 'date/time of deletion', > `location` varchar(80) DEFAULT NULL COMMENT 'authorized value for the shelving location for this item (MARC21 952$c)', > `permanent_location` varchar(80) DEFAULT NULL COMMENT 'linked to the CART and PROC temporary locations feature, stores the permanent shelving location', >+ `sub_location` varchar(80) DEFAULT NULL COMMENT 'authorized value for the sublocation for this item', > `onloan` date DEFAULT NULL COMMENT 'defines if item is checked out (NULL for not checked out, and due date for checked out)', > `cn_source` varchar(10) DEFAULT NULL COMMENT 'classification source used on this item (MARC21 952$2)', > `cn_sort` varchar(255) DEFAULT NULL COMMENT 'normalized form of the call number (MARC21 952$o) used for sorting', >@@ -3994,6 +3995,7 @@ CREATE TABLE `items` ( > `deleted_on` datetime DEFAULT NULL COMMENT 'date/time of deletion', > `location` varchar(80) DEFAULT NULL COMMENT 'authorized value for the shelving location for this item (MARC21 952$c)', > `permanent_location` varchar(80) DEFAULT NULL COMMENT 'linked to the CART and PROC temporary locations feature, stores the permanent shelving location', >+ `sub_location` varchar(80) DEFAULT NULL COMMENT 'authorized value for the sublocation for this item', > `onloan` date DEFAULT NULL COMMENT 'defines if item is checked out (NULL for not checked out, and due date for checked out)', > `cn_source` varchar(10) DEFAULT NULL COMMENT 'classification source used on this item (MARC21 952$2)', > `cn_sort` varchar(255) DEFAULT NULL COMMENT 'normalized form of the call number (MARC21 952$o) used for sorting', >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 05da5acf56..0493816856 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -436,6 +436,12 @@ > [% ELSE %] > [% item_location | html %] > [% END %] >+ [% SET item_sublocation= AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.sub_location', authorised_value => item.sub_location ) %] >+ [% IF ( item_sublocation ) %] >+ <span class="sub_location"> >+ ([% item_sublocation | html %]) >+ </span> >+ [% END %] > </span> > </td> > [% IF ( itemdata_ccode ) %]<td>[% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.ccode', authorised_value => item.ccode ) | html %]</td>[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >index c24aa47c8a..0b17368030 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >@@ -147,6 +147,12 @@ > [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => ITEM_DAT.location ) | html %] > </li> > [% END %] >+ [% IF ( ITEM_DAT.sub_location ) %] >+ <li> >+ <span class="label">Sublocation:</span> >+ [% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.sub_location', authorised_value => ITEM_DAT.sub_location ) | html %] >+ </li> >+ [% END %] > [% IF ( ITEM_DAT.replacementprice ) %] > <li><span class="label">Replacement price:</span> [% ITEM_DAT.replacementprice | $Price %] </li> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >index 2abde7f9c5..26aad823bb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >@@ -1289,7 +1289,7 @@ > [%- END -%] > </td> > <td class="ci-shelvinglocation"> >- <span class="shelvingloc">[% riloo.location | html %]</span> >+ <span class="shelvingloc">[% riloo.location | html %] [% IF ( riloo.sub_location ) %] ([% riloo.sub_location | html %]) [% END %]</span> > </td> > <td class="ci-callnumber"> > [% riloo.itemcallnumber | html %] >-- >2.34.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 34142
:
157299
|
157300
|
159236
|
159237
|
164875
|
164876
|
164877
|
167714
|
172103
|
172104