Bugzilla – Attachment 20051 Details for
Bug 10513
Light up a warning/message when returning a chosen item type.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED-OFF] Bug 10513 - Light up a warning/message when returning a chosen item type
SIGNED-OFF-Bug-10513---Light-up-a-warningmessage-w.patch (text/plain), 14.04 KB, created by
Owen Leonard
on 2013-08-01 20:24:24 UTC
(
hide
)
Description:
[SIGNED-OFF] Bug 10513 - Light up a warning/message when returning a chosen item type
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2013-08-01 20:24:24 UTC
Size:
14.04 KB
patch
obsolete
>From a8e41693fa835ac70c048411b1fe52e242751c32 Mon Sep 17 00:00:00 2001 >From: Magnus Enger <magnus@enger.priv.no> >Date: Thu, 27 Jun 2013 22:22:18 +0200 >Subject: [PATCH] [SIGNED-OFF] Bug 10513 - Light up a warning/message when > returning a chosen item type >Content-Type: text/plain; charset="utf-8" > >This patch adds a new column to item types. Text in this column is >displayed as a warning when an item of the given type is checked in. >The type of message can also be chosen, affecting how the message is >displayed. > >Use case: Items that are on inter-library loan can have a separate >item type, and when items of this type are checked in a message >saying something like "ILL! Remember to return it to the owning >library!" can be displayed. > >To test: >- Apply the patch >- Go to Home > Administration > Item types administration >- Check that there is a new column, called "Check in message" >- Edit an item type and add a check in message >- Check that the check in message you added is displayed in the table >- Check in an item with an item type that has a check in message >- Check that the message is displayed >- Repeat the steps above, but select "Alert" instead of the default > "Message" as the "Check in message type". Check that the message > is displayed in a yellow alert box, not a blue message box. >- Check in an item with an item type that does *not* have a check > in message, and make sure no false messages are displayed >- Create a new item type from scratch and check that it works > the way it is supposed to >- Run the tests in t/ItemType.t, which are updated by this patch > >This patch also removes backticks around column names in the >itemtypes table in installer/data/mysql/kohastructure.sql > >UPDATE 2013-07-22 >- Rebased on current master (no changes) >- Added "AFTER summary" to the SQL statement in updatedatabase.pl >- Added another placeholder on line 170 of admin/itemtypes.pl >Thanks Katrin! > >UPDATE 2013-07-29 >- Make this message independent of all other messages - thanks Owen! >- Make it possible to choose the type of message ("alert" or > "message") > >Sponsored-by: Kultur i Halland - Regionbibliotek >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > C4/ItemType.pm | 27 +++++++++++ > admin/itemtypes.pl | 12 ++++- > circ/returns.pl | 10 +++++ > installer/data/mysql/kohastructure.sql | 14 +++--- > installer/data/mysql/updatedatabase.pl | 8 ++++ > .../prog/en/modules/admin/itemtypes.tt | 21 +++++++++ > .../intranet-tmpl/prog/en/modules/circ/returns.tt | 10 +++++ > t/ItemType.t | 47 ++++++++++++++++---- > 8 files changed, 132 insertions(+), 17 deletions(-) > >diff --git a/C4/ItemType.pm b/C4/ItemType.pm >index 648cff9..ad253a7 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 841672d..ee70238 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 9472797..eb0c290 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 8a8b70f..355f120 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 74aeb3e..5a8efa9 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7067,6 +7067,14 @@ 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 > > =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 210b575..5e967a5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/itemtypes.tt >@@ -229,6 +229,25 @@ Item types administration > <input type="text" id="rentalcharge" name="rentalcharge" size="10" value="[% rentalcharge %]" /> > </li> > <li> >+ <label for="checkinmsg">Check in message: </label> >+ <input type="text" id="checkinmsg" name="checkinmsg" size="48" value="[% checkinmsg %]" /> >+ </li> >+ <li> >+ <label for="checkinmsgtype">Check in message type: </label> >+ <select type="text" id="checkinmsgtype" name="checkinmsgtype"> >+ [% IF ( checkinmsgtype == 'message' ) %] >+ <option value="message" selected="selected">Message</option> >+ [% ELSE %] >+ <option value="message">Message</option> >+ [% END %] >+ [% IF ( checkinmsgtype == 'alert' ) %] >+ <option value="alert" selected="selected">Alert</option> >+ [% ELSE %] >+ <option value="alert">Alert</option> >+ [% END %] >+ <select> >+ </li> >+ <li> > <label for="summary">Summary: </label> > <textarea id="summary" name="summary" cols="55" rows="5">[% summary %]</textarea> > <p>Enter a summary that will overwrite the default one in search results lists. Example, for a website itemtype : </p> >@@ -282,6 +301,7 @@ Item types administration > <th>Description</th> > <th>Not for loan</th> > <th>Charge</th> >+ <th>Check in message</th> > <th>Actions</th> > </thead> > [% FOREACH loo IN loop %] >@@ -303,6 +323,7 @@ Item types administration > [% loo.rentalcharge %] > [% END %] > </td> >+ <td>[% loo.checkinmsg %]</td> > <td> > <a href="[% loo.script_name %]?op=add_form&itemtype=[% loo.itemtype |html %]">Edit</a> > <a href="[% loo.script_name %]?op=delete_confirm&itemtype=[% loo.itemtype |html %]">Delete</a> >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 98d2ae9..3342de2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >@@ -362,6 +362,16 @@ $(document).ready(function () { > </div> > [% END %] > >+[% IF ( checkinmsg ) %] >+ [% IF ( checkinmsgtype == 'alert' ) %] >+ <div class="dialog alert"> >+ [% ELSE %] >+ <div class="dialog message"> >+ [% END %] >+ <p class="problem">[% checkinmsg %]</p> >+ </div> >+[% END%] >+ > <div id="exemptfines" class="dialog message" style="display:none;"> > <p>Fines for returned items are forgiven.</p> > </div> >diff --git a/t/ItemType.t b/t/ItemType.t >index 87e090e..558bba9 100755 >--- a/t/ItemType.t >+++ b/t/ItemType.t >@@ -1,11 +1,9 @@ > #!/usr/bin/perl >-# >-# Add more tests here!!! > > use strict; > use warnings; > use DBI; >-use Test::More tests => 15; >+use Test::More tests => 26; > use Test::MockModule; > > BEGIN { >@@ -26,16 +24,16 @@ $module->mock( > my $itemtypes = [ > [ > 'itemtype', 'description', 'rentalcharge', 'notforloan', >- 'imageurl', 'summary' >+ 'imageurl', 'summary', 'checkinmsg' > ], >- [ 'BK', 'Books', 0, 0, '', '' ], >- [ 'CD', 'CDRom', 0, 0, '', '' ] >+ [ 'BK', 'Books', 0, 0, '', '', 'foo' ], >+ [ 'CD', 'CDRom', 0, 0, '', '', 'bar' ] > ]; > > my $itemtypes_empty = [ > [ > 'itemtype', 'description', 'rentalcharge', 'notforloan', >- 'imageurl', 'summary' >+ 'imageurl', 'summary', 'checkinmsg' > ], > ]; > >@@ -53,6 +51,10 @@ is( scalar( @{$history} ), 1, 'Correct number of statements executed' ); > $dbh->{mock_add_resultset} = $itemtypes; > > @itemtypes = C4::ItemType->all(); >+ >+$history = $dbh->{mock_all_history}; >+is( scalar( @{$history} ), 2, 'Correct number of statements executed' ); >+ > is( @itemtypes, 2, 'ItemType->all should return an array with 2 elements' ); > > is( $itemtypes[0]->fish, undef, 'Calling a bad descriptor gives undef' ); >@@ -73,6 +75,33 @@ is( $itemtypes[0]->notforloan, '0', 'first not for loan is 0' ); > > is( $itemtypes[1]->notforloan, '0', 'second not for loan is 0' ); > >-is( $itemtypes[0]->imageurl, '', 'first not for loan is undef' ); >+is( $itemtypes[0]->imageurl, '', 'first imageurl is undef' ); >+ >+is( $itemtypes[1]->imageurl, '', 'second imageurl is undef' ); >+ >+is( $itemtypes[0]->checkinmsg, 'foo', 'first checkinmsg is foo' ); >+ >+is( $itemtypes[1]->checkinmsg, 'bar', 'second checkinmsg is bar' ); >+ >+# Mock the data again >+$dbh->{mock_add_resultset} = $itemtypes; >+ >+# Test get(), which should return one itemtype >+my $itemtype = C4::ItemType->get( 'BK' ); >+ >+$history = $dbh->{mock_all_history}; >+is( scalar( @{$history} ), 3, 'Correct number of statements executed' ); >+ >+is( $itemtype->fish, undef, 'Calling a bad descriptor gives undef' ); >+ >+is( $itemtype->itemtype, 'BK', 'itemtype is bk' ); >+ >+is( $itemtype->description, 'Books', 'description is books' ); >+ >+is( $itemtype->rentalcharge, '0', 'rental charge is 0' ); >+ >+is( $itemtype->notforloan, '0', 'not for loan is 0' ); >+ >+is( $itemtype->imageurl, '', ' not for loan is undef' ); > >-is( $itemtypes[1]->imageurl, '', 'second not for loan is undef' ); >+is( $itemtype->checkinmsg, 'foo', 'checkinmsg is foo' ); >-- >1.7.9.5
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 10513
:
19397
|
19398
|
19444
|
19854
|
19976
|
20051
|
20925