Bug 10513

Summary: Light up a warning/message when returning a chosen item type.
Product: Koha Reporter: Viktor Sarge <viktor.sarge>
Component: CirculationAssignee: Magnus Enger <magnus>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P5 - low CC: bgkriegel, gmcharlt, katrin.fischer, kyle.m.hall, magnus, tomascohen
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: Sponsored Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 10965, 10969    
Attachments: Bug 10513 - Light up a warning/message when returning a chosen item type
Bug 10513 - Light up a warning/message when returning a chosen item type
Bug 10513 - Light up a warning/message when returning a chosen item type
Bug 10513 - Light up a warning/message when returning a chosen item type
Bug 10513 - Light up a warning/message when returning a chosen item type
[SIGNED-OFF] Bug 10513 - Light up a warning/message when returning a chosen item type
[PASSED QA] Bug 10513 - Light up a warning/message when returning a chosen item type

Description Viktor Sarge 2013-06-27 13:37:04 UTC
We plan to use a specific item type to keep track of ILLs. The possibility to chose a message to display when returning specific item types would be highly useful to make sure that the ILLs isn't shelved at the local library. I imagine others could find other uses for it so building it as general as possible would be good.
Comment 1 Magnus Enger 2013-07-04 12:50:49 UTC Comment hidden (obsolete)
Comment 2 Magnus Enger 2013-07-04 13:00:24 UTC Comment hidden (obsolete)
Comment 3 Viktor Sarge 2013-07-04 14:03:08 UTC
Looks great! I do not however (yet) have a dev install to test it on, but I hope someone who does can give it spin.
Comment 4 Chris Cormack 2013-07-07 04:07:44 UTC Comment hidden (obsolete)
Comment 5 Katrin Fischer 2013-07-14 09:02:03 UTC
Hi Magnus, 

I am sorry, but I found a bug:

1) (Major) You can no longer create new itemtypes, as we are missing a ?:

[Sun Jul 14 10:58:14 2013] [error] [client 127.0.0.1] [Sun Jul 14 10:58:14 2013] itemtypes.pl: DBD::mysql::st execute failed: called with 7 bind variables when 6 are needed at /home/katrin/kohaclone/admin/itemtypes.pl line 174., referer: http://localhost:8080/cgi-bin/koha/admin/itemtypes.pl?op=add_form
[Sun Jul 14 10:58:17 2013] [error] [client 127.0.0.1] File does not exist: /home/katrin/kohaclone/koha-tmpl/intranet-tmpl/prog/img/itemtypeimg/sudoc, referer: http://localhost:8080/cgi-bin/koha/admin/itemtypes.pl

2) (Trivial) Can you please add an AFTER summary to your database update?
Comment 6 Magnus Enger 2013-07-22 11:17:06 UTC
Thanks for catching these, Katrin! I'm not sure I understand the second point, though. I have this in updatedatabase.pl:

$DBversion = "3.13.00.XXX";
if ( CheckVersion($DBversion) ) {
    $dbh->do("ALTER TABLE itemtypes ADD COLUMN checkinmsg VARCHAR(255);");
    print "Upgrade to $DBversion done (Bug 10513 - Light up a warning/message when returning a chosen item type)\n";
    SetVersion($DBversion);
}
Comment 7 Katrin Fischer 2013-07-22 11:51:53 UTC
In your updatedatabase SQL statement you don't specify where the new column should be added within the table - so it is theoretically possible that the sequence of columns ends up being different from the one in kohastructure.sql. To avoid this you can tell it specifically to add the new column after summary :)
Comment 8 Magnus Enger 2013-07-22 17:25:23 UTC Comment hidden (obsolete)
Comment 9 Owen Leonard 2013-07-23 14:06:05 UTC
When I tested this I found that I did not see the custom message if the item was on hold (prompting a hold message) or required a transfer (prompting a transfer message). Is this a bug, or is it by design?
Comment 10 Magnus Enger 2013-07-29 09:34:41 UTC
(In reply to Owen Leonard from comment #9)
> When I tested this I found that I did not see the custom message if the item
> was on hold (prompting a hold message) or required a transfer (prompting a
> transfer message). Is this a bug, or is it by design?

Sounds like a bug to me. Corrected patch coming shortly.
Comment 11 Magnus Enger 2013-07-29 11:17:59 UTC Comment hidden (obsolete)
Comment 12 Magnus Enger 2013-07-29 11:20:34 UTC
I added another enhancement to this patch: the ability to choose if the check in message should be displayed as an alert or a message. 

The check in messages are displayed without a heading, but if libraries want one, they can include HTML along these lines in the check in message it self:

<h3>Warning!</h3><p>This is an ILL item, please return it to the owning library!</p>
Comment 13 Owen Leonard 2013-08-01 20:24:24 UTC Comment hidden (obsolete)
Comment 14 Katrin Fischer 2013-09-09 19:46:56 UTC
Created attachment 20925 [details] [review]
[PASSED QA] Bug 10513 - Light up a warning/message when returning a chosen item type

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>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Fixed some tabs to make the QA script happy.
All old and new tests pass.
Comment 15 Galen Charlton 2013-09-16 17:43:59 UTC
Pushed to master, along with a follow-up to add support for multiline checkin messages and a tweak to standardize labels on "checkin" rather than "check in" when used as an adjective.

Thanks, Magnus!
Comment 16 Bernardo Gonzalez Kriegel 2013-09-28 19:50:08 UTC
Warning: with this change, sample imtemtypes can't load.
See Bug 10965