diff --git a/C4/ItemType.pm b/C4/ItemType.pm index 648cff95f5..ad253a7741 100644 --- a/C4/ItemType.pm +++ b/C4/ItemType.pm @@ -90,6 +90,29 @@ sub all { +=head3 C4::ItemType->get + +Return the itemtype indicated by the itemtype given as argument, as +an object. + +=cut + +sub get { + my ($class, $itemtype) = @_; + my $dbh = C4::Context->dbh; + + my $data = $dbh->selectrow_hashref( + "SELECT * FROM itemtypes WHERE itemtype = ?", undef, $itemtype + ); + if ( $data->{description} ) { + utf8::encode($data->{description}); + } + return $class->new($data); +} + + + + =head2 Object Methods These are read-only accessors for attributes of a C4::ItemType object. @@ -118,6 +141,10 @@ These are read-only accessors for attributes of a C4::ItemType object. =cut +=head3 $itemtype->checkinmsg + +=cut + =head3 $itemtype->summary =cut diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl index 841672d34d..ee7023810c 100755 --- a/admin/itemtypes.pl +++ b/admin/itemtypes.pl @@ -117,6 +117,8 @@ if ( $op eq 'add_form' ) { imageurl => $data->{'imageurl'}, template => C4::Context->preference('template'), summary => $data->{summary}, + checkinmsg => $data->{'checkinmsg'}, + checkinmsgtype => $data->{'checkinmsgtype'}, imagesets => $imagesets, remote_image => $remote_image, ); @@ -141,6 +143,8 @@ elsif ( $op eq 'add_validate' ) { , notforloan = ? , imageurl = ? , summary = ? + , checkinmsg = ? + , checkinmsgtype = ? WHERE itemtype = ? '; $sth = $dbh->prepare($query2); @@ -156,15 +160,17 @@ elsif ( $op eq 'add_validate' ) { ) ), $input->param('summary'), + $input->param('checkinmsg'), + $input->param('checkinmsgtype'), $input->param('itemtype') ); } else { # add a new itemtype & not modif an old my $query = " INSERT INTO itemtypes - (itemtype,description,rentalcharge, notforloan, imageurl,summary) + (itemtype,description,rentalcharge, notforloan, imageurl, summary, checkinmsg, checkinmsgtype) VALUES - (?,?,?,?,?,?); + (?,?,?,?,?,?,?,?); "; my $sth = $dbh->prepare($query); my $image = $input->param('image'); @@ -177,6 +183,8 @@ elsif ( $op eq 'add_validate' ) { $image eq 'remoteImage' ? $input->param('remoteImage') : $image, $input->param('summary'), + $input->param('checkinmsg'), + $input->param('checkinmsgtype'), ); } diff --git a/circ/returns.pl b/circ/returns.pl index 618190b771..3a235e9848 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -225,6 +225,16 @@ if ($barcode) { # fix up item type for display $biblio->{'itemtype'} = C4::Context->preference('item-level_itypes') ? $biblio->{'itype'} : $biblio->{'itemtype'}; + # Check if we should display a check in message, based on the the item + # type of the checked in item + my $itemtype = C4::ItemType->get( $biblio->{'itemtype'} ); + if ( $itemtype->{'checkinmsg'} ) { + $template->param( + checkinmsg => $itemtype->{'checkinmsg'}, + checkinmsgtype => $itemtype->{'checkinmsgtype'}, + ); + } + $template->param( title => $biblio->{'title'}, homebranch => $biblio->{'homebranch'}, diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index b22134bbd2..fdab8796ae 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -1204,12 +1204,14 @@ CREATE TABLE `items` ( -- holdings/item information DROP TABLE IF EXISTS `itemtypes`; CREATE TABLE `itemtypes` ( -- defines the item types - `itemtype` varchar(10) NOT NULL default '', -- unique key, a code associated with the item type - `description` mediumtext, -- a plain text explanation of the item type - `rentalcharge` double(16,4) default NULL, -- the amount charged when this item is checked out/issued - `notforloan` smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan - `imageurl` varchar(200) default NULL, -- URL for the item type icon - `summary` text, -- information from the summary field, may include HTML + itemtype varchar(10) NOT NULL default '', -- unique key, a code associated with the item type + description mediumtext, -- a plain text explanation of the item type + rentalcharge double(16,4) default NULL, -- the amount charged when this item is checked out/issued + notforloan smallint(6) default NULL, -- 1 if the item is not for loan, 0 if the item is available for loan + imageurl varchar(200) default NULL, -- URL for the item type icon + 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" PRIMARY KEY (`itemtype`), UNIQUE KEY `itemtype` (`itemtype`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index d8b5818f0e..a3acd7a621 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7122,6 +7122,13 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.13.00.XXX"; +if ( CheckVersion($DBversion) ) { + $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsg VARCHAR(255) AFTER summary;"); + $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsgtype CHAR(16) DEFAULT 'message' NOT NULL AFTER checkinmsg;"); + print "Upgrade to $DBversion done (Bug 10513 - Light up a warning/message when returning a chosen item type)\n"; + SetVersion($DBversion); +} =head1 FUNCTIONS 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 210b57551e..7d8f7813a6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt @@ -228,6 +228,25 @@ Item types administration +