From fd3ab5e21af4010dd1c153bf09b19471171919cc Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 6 Dec 2013 13:35:49 -0500 Subject: [PATCH] Bug 11351 - Add support for SIP2 media types Koha's SIP2 server implementation does not currently support the SIP2 protocol field "media type" ( CK ). This patch implements the SIP2 media type by allowing an arbitrary mapping of itemtypes to SIP2 media types. Test Plan: 1) Apply this patch 2) Run updatedatabase 3) Edit an itemtype, select a SIP media type, and save the changes 4) Make a SIP2 Item Information Request 5) Verify that the CK field of the Item Information Response contains the correct media type code. Signed-off-by: Benjamin Rokseth Signed-off-by: Martin Renvoize --- C4/SIP/ILS/Item.pm | 6 +++- Koha/Schema/Result/Itemtype.pm | 36 ++++++++----------- Koha/Template/Plugin/AuthorisedValues.pm | 5 +++ admin/itemtypes.pl | 8 +++-- .../data/mysql/de-DE/optional/auth_val.sql | 13 +++++++ installer/data/mysql/en/optional/auth_val.sql | 13 +++++++ .../data/mysql/es-ES/optional/auth_val.sql | 13 +++++++ installer/data/mysql/kohastructure.sql | 1 + .../data/mysql/nb-NO/2-Valgfritt/auth_val.sql | 13 +++++++ .../data/mysql/pl-PL/optional/auth_val.sql | 13 +++++++ installer/data/mysql/updatedatabase.pl | 23 ++++++++++++ .../prog/en/modules/admin/itemtypes.tt | 15 ++++++++ 12 files changed, 135 insertions(+), 24 deletions(-) diff --git a/C4/SIP/ILS/Item.pm b/C4/SIP/ILS/Item.pm index 049dd175e0..30586a3a16 100644 --- a/C4/SIP/ILS/Item.pm +++ b/C4/SIP/ILS/Item.pm @@ -21,6 +21,7 @@ use C4::Items; use C4::Circulation; use C4::Members; use C4::Reserves; +use Koha::Database; our $VERSION = 3.07.00.049; @@ -86,7 +87,10 @@ sub new { $item->{permanent_location}= $item->{homebranch}; $item->{'collection_code'} = $item->{ccode}; $item->{ 'call_number' } = $item->{itemcallnumber}; - # $item->{'destination_loc'} = ? + + my $it = C4::Context->preference('item-level_itypes') ? $item->{itype} : $item->{itemtype}; + my $itemtype = Koha::Database->new()->schema()->resultset('Itemtype')->find( $it ); + $item->{sip_media_type} = $itemtype->sip_media_type() if $itemtype; # check if its on issue and if so get the borrower my $issue = GetItemIssue($item->{'itemnumber'}); diff --git a/Koha/Schema/Result/Itemtype.pm b/Koha/Schema/Result/Itemtype.pm index 67f64c5e9d..b9aed45745 100644 --- a/Koha/Schema/Result/Itemtype.pm +++ b/Koha/Schema/Result/Itemtype.pm @@ -1,21 +1,17 @@ -use utf8; package Koha::Schema::Result::Itemtype; # Created by DBIx::Class::Schema::Loader # DO NOT MODIFY THE FIRST PART OF THIS FILE -=head1 NAME - -Koha::Schema::Result::Itemtype - -=cut - use strict; use warnings; use base 'DBIx::Class::Core'; -=head1 TABLE: C + +=head1 NAME + +Koha::Schema::Result::Itemtype =cut @@ -70,6 +66,13 @@ __PACKAGE__->table("itemtypes"); is_nullable: 0 size: 16 +=head2 sip_media_type + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 3 + =cut __PACKAGE__->add_columns( @@ -94,18 +97,9 @@ __PACKAGE__->add_columns( is_nullable => 0, size => 16, }, + "sip_media_type", + { data_type => "varchar", default_value => "", is_nullable => 0, size => 3 }, ); - -=head1 PRIMARY KEY - -=over 4 - -=item * L - -=back - -=cut - __PACKAGE__->set_primary_key("itemtype"); =head1 RELATIONS @@ -141,8 +135,8 @@ __PACKAGE__->might_have( ); -# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BmFEWUxi2Ha50Hv6nQhDKQ +# Created by DBIx::Class::Schema::Loader v0.07000 @ 2013-12-09 08:22:44 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uGDyscA28BOAzCTb2gBcCg # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm index 0a19be240d..8f80cb1a52 100644 --- a/Koha/Template/Plugin/AuthorisedValues.pm +++ b/Koha/Template/Plugin/AuthorisedValues.pm @@ -43,4 +43,9 @@ sub GetByCode { return encode( 'UTF-8', GetAuthorisedValueByCode( $category, $code, $opac ) ); } +sub Get { + my ( $self, $category, $selected, $opac ) = @_; + return GetAuthorisedValues( $category, $selected, $opac ); +} + 1; diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index 3c33073cbb..df91e7bdf2 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -121,6 +121,7 @@ if ( $op eq 'add_form' ) { checkinmsgtype => $data->{'checkinmsgtype'}, imagesets => $imagesets, remote_image => $remote_image, + sip_media_type => $data->{sip_media_type}, ); # END $OP eq ADD_FORM @@ -145,6 +146,7 @@ elsif ( $op eq 'add_validate' ) { , summary = ? , checkinmsg = ? , checkinmsgtype = ? + , sip_media_type = ? WHERE itemtype = ? '; $sth = $dbh->prepare($query2); @@ -162,15 +164,16 @@ elsif ( $op eq 'add_validate' ) { $input->param('summary'), $input->param('checkinmsg'), $input->param('checkinmsgtype'), + $input->param('sip_media_type'), $input->param('itemtype') ); } else { # add a new itemtype & not modif an old my $query = " INSERT INTO itemtypes - (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype) + (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype, sip_media_type) VALUES - (?,?,?,?,?,?,?,?); + (?,?,?,?,?,?,?,?,?); "; my $sth = $dbh->prepare($query); my $image = $input->param('image'); @@ -185,6 +188,7 @@ elsif ( $op eq 'add_validate' ) { $input->param('summary'), $input->param('checkinmsg'), $input->param('checkinmsgtype'), + $input->param('sip_media_type'), ); } diff --git a/installer/data/mysql/de-DE/optional/auth_val.sql b/installer/data/mysql/de-DE/optional/auth_val.sql index 214121deab..2ee7fde64a 100644 --- a/installer/data/mysql/de-DE/optional/auth_val.sql +++ b/installer/data/mysql/de-DE/optional/auth_val.sql @@ -57,3 +57,16 @@ INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_ INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'PAT', 'Benutzer'); INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'ACQ', 'Erwerbung'); INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'ACC', 'Gebühren'); + +-- SIP2 media types +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '000', 'Other'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '001', 'Book'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '002', 'Magazine'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '003', 'Bound journal'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '004', 'Audio tape'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '005', 'Video tape'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '006', 'CD/CDROM'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '007', 'Diskette'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '008', 'Book with deskette'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '009', 'Book with cd'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '010', 'Book with audio tape'); diff --git a/installer/data/mysql/en/optional/auth_val.sql b/installer/data/mysql/en/optional/auth_val.sql index 5318ceeae2..8a4b32a78f 100644 --- a/installer/data/mysql/en/optional/auth_val.sql +++ b/installer/data/mysql/en/optional/auth_val.sql @@ -57,3 +57,16 @@ INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_ INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'PAT', 'Patrons'); INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'ACQ', 'Acquisitions'); INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'ACC', 'Accounts'); + +-- SIP2 media types +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '000', 'Other'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '001', 'Book'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '002', 'Magazine'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '003', 'Bound journal'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '004', 'Audio tape'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '005', 'Video tape'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '006', 'CD/CDROM'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '007', 'Diskette'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '008', 'Book with deskette'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '009', 'Book with cd'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '010', 'Book with audio tape'); diff --git a/installer/data/mysql/es-ES/optional/auth_val.sql b/installer/data/mysql/es-ES/optional/auth_val.sql index ec433ad828..ec44e456fa 100644 --- a/installer/data/mysql/es-ES/optional/auth_val.sql +++ b/installer/data/mysql/es-ES/optional/auth_val.sql @@ -50,3 +50,16 @@ INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('BOR_N -- OPAC Suggestions reasons INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('OPAC_SUG','damaged','The copy on the shelf is damaged','The copy on the shelf is damaged'); INSERT INTO authorised_values (category,authorised_value,lib,lib_opac) VALUES ('OPAC_SUG','bestseller','Upcoming title by popular author','Upcoming title by popular author'); + +-- SIP2 media types +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '000', 'Other'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '001', 'Book'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '002', 'Magazine'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '003', 'Bound journal'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '004', 'Audio tape'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '005', 'Video tape'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '006', 'CD/CDROM'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '007', 'Diskette'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '008', 'Book with deskette'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '009', 'Book with cd'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '010', 'Book with audio tape'); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index ea4f944961..c7d35f250b 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1242,6 +1242,7 @@ CREATE TABLE `itemtypes` ( -- defines the item types summary text, -- information from the summary field, may include HTML checkinmsg VARCHAR(255), -- message that is displayed when an item with the given item type is checked in checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL, -- type (CSS class) for the checkinmsg, can be "alert" or "message" + sip_media_type VARCHAR(3) DEFAULT NULL, -- SIP2 protocol media type for this itemtype PRIMARY KEY (`itemtype`), UNIQUE KEY `itemtype` (`itemtype`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/installer/data/mysql/nb-NO/2-Valgfritt/auth_val.sql b/installer/data/mysql/nb-NO/2-Valgfritt/auth_val.sql index 567d30d02d..11e5866be3 100644 --- a/installer/data/mysql/nb-NO/2-Valgfritt/auth_val.sql +++ b/installer/data/mysql/nb-NO/2-Valgfritt/auth_val.sql @@ -78,3 +78,16 @@ INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_ INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'PAT', 'LÃ¥nere'); INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'ACQ', 'Innkjøp'); INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('REPORT_GROUP', 'ACC', 'Gebyrer'); + +-- SIP2 media types +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '000', 'Other'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '001', 'Book'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '002', 'Magazine'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '003', 'Bound journal'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '004', 'Audio tape'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '005', 'Video tape'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '006', 'CD/CDROM'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '007', 'Diskette'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '008', 'Book with deskette'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '009', 'Book with cd'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '010', 'Book with audio tape'); diff --git a/installer/data/mysql/pl-PL/optional/auth_val.sql b/installer/data/mysql/pl-PL/optional/auth_val.sql index 8a7d630335..dc3e3df1b7 100644 --- a/installer/data/mysql/pl-PL/optional/auth_val.sql +++ b/installer/data/mysql/pl-PL/optional/auth_val.sql @@ -38,3 +38,16 @@ INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('NOT_L -- restricted status of an item, linked to items.restricted INSERT INTO `authorised_values` (category, authorised_value, lib) VALUES ('RESTRICTED','1','Restricted Access'); + +-- SIP2 media types +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '000', 'Other'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '001', 'Book'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '002', 'Magazine'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '003', 'Bound journal'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '004', 'Audio tape'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '005', 'Video tape'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '006', 'CD/CDROM'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '007', 'Diskette'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '008', 'Book with deskette'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '009', 'Book with cd'); +INSERT INTO authorised_values (category, authorised_value, lib) VALUES ('SIP_MEDIA_TYPE', '010', 'Book with audio tape'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 89170811a8..e033a92b40 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8202,6 +8202,29 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.15.00.XXX"; +if(CheckVersion($DBversion)) { + $dbh->do(q{ + ALTER TABLE itemtypes ADD sip_media_type VARCHAR( 3 ) DEFAULT NULL + }); + $dbh->do(q{ + INSERT INTO authorised_values (category, authorised_value, lib) VALUES + ('SIP_MEDIA_TYPE', '000', 'Other'), + ('SIP_MEDIA_TYPE', '001', 'Book'), + ('SIP_MEDIA_TYPE', '002', 'Magazine'), + ('SIP_MEDIA_TYPE', '003', 'Bound journal'), + ('SIP_MEDIA_TYPE', '004', 'Audio tape'), + ('SIP_MEDIA_TYPE', '005', 'Video tape'), + ('SIP_MEDIA_TYPE', '006', 'CD/CDROM'), + ('SIP_MEDIA_TYPE', '007', 'Diskette'), + ('SIP_MEDIA_TYPE', '008', 'Book with deskette'), + ('SIP_MEDIA_TYPE', '009', 'Book with cd'), + ('SIP_MEDIA_TYPE', '010', 'Book with audio tape') + }); + print "Upgrade to $DBversion done (Bug 11351 - Add support for SIP2 media type)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt index a07ae46403..522420be0a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -1,3 +1,5 @@ +[% USE EncodeUTF8 %] +[% USE AuthorisedValues %] [% INCLUDE 'doc-head-open.inc' %] Koha › Administration › Item types [% IF ( add_form ) %]› [% IF ( itemtype ) %] @@ -193,6 +195,19 @@ Item types administration [% END %] </select> </li> + <li> + <label for="sip_media_type">SIP media type: </label> + <select id="sip_media_type" name="sip_media_type"> + <option value=""></option> + [% FOREACH a IN AuthorisedValues.Get('SIP_MEDIA_TYPE', sip_media_type ) %] + [% IF a.selected %] + <option value="[% a.authorised_value %]" selected="selected">[% a.lib | $EncodeUTF8 %]</option> + [% ELSE %] + <option value="[% a.authorised_value %]">[% a.lib | $EncodeUTF8 %]</option> + [% END %] + [% END %] + </select> + </li> <li> <label for="summary">Summary: </label> <textarea id="summary" name="summary" cols="55" rows="5">[% summary %]</textarea> -- 2.39.5