From a9f553e3219d1def6a22df41664d594b41fbd9ac Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 14 Feb 2018 12:05:59 +0100 Subject: [PATCH] Bug 20194: Display ccode and both itemtypes in checkouts tables Test plan: 1. Verify that biblioitems.itemtype, items.itype and items.ccode are mapped to a MARC field. Otherwise create those mappings. 2. Create a biblio with an itemtype 3. Create an item with a ccode and a different itemtype for this biblio 4. Check out this item to a patron (P1) 5. Verify that both itemtypes and the ccode are displayed in the checkouts table 6. Create a patron whose guarantor is P1 and verify that both itemtypes and the ccode are displayed in the 'relatives checkouts' table --- admin/columns_settings.yml | 2 ++ .../prog/en/includes/checkouts-table-footer.inc | 2 +- .../prog/en/includes/checkouts-table.inc | 1 + .../prog/en/modules/circ/circulation.tt | 1 + koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 34 ++++++++++++++++++++-- svc/checkouts | 21 +++++++++++-- 6 files changed, 55 insertions(+), 6 deletions(-) diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 61fa864b38..244f087afc 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -336,6 +336,8 @@ modules: columnname: title - columnname: item_type + - + columnname: ccode - columnname: location - diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc index 3adbfa326a..415e1d5b17 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc @@ -1,6 +1,6 @@ - Totals: + Totals: [% totaldue %] [% finetotal %] [% totalprice %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc index b34089d3c7..f7c68218c4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -16,6 +16,7 @@ Due date Title Item type + Collection Location Home library Checked out on diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index d47d7037e9..1c0d00b32e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -980,6 +980,7 @@ No patron matched [% message | html %] Due date Title Item type + Collection Location Checked out on Checked out from diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js index 1d16823045..2a3c104a7e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js +++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js @@ -290,7 +290,22 @@ $(document).ready(function() { }, "sType": "anti-the" }, - { "mDataProp": "itemtype_description" }, + { + "mDataProp": function ( oObj ) { + let itemtypes = []; + + if ('itemtype' in oObj.itemtypes) { + itemtypes.push(oObj.itemtypes.itemtype.translated_description); + } + + if ('itype' in oObj.itemtypes) { + itemtypes.push(oObj.itemtypes.itype.translated_description); + } + + return itemtypes.join('
'); + } + }, + { "mDataProp": "ccode" }, { "mDataProp": "location" }, { "mDataProp": "homebranch" }, { "mDataProp": "issuedate_formatted" }, @@ -588,7 +603,22 @@ $(document).ready(function() { }, "sType": "anti-the" }, - { "mDataProp": "itemtype" }, + { + "mDataProp": function ( oObj ) { + let itemtypes = []; + + if ('itemtype' in oObj.itemtypes) { + itemtypes.push(oObj.itemtypes.itemtype.translated_description); + } + + if ('itype' in oObj.itemtypes) { + itemtypes.push(oObj.itemtypes.itype.translated_description); + } + + return itemtypes.join('
'); + } + }, + { "mDataProp": "ccode" }, { "mDataProp": "location" }, { "mDataProp": "issuedate_formatted" }, { "mDataProp": "branchname" }, diff --git a/svc/checkouts b/svc/checkouts index fefadeeeea..5bf55f87ea 100755 --- a/svc/checkouts +++ b/svc/checkouts @@ -87,6 +87,7 @@ my $sql = ' issues.branchcode, branches.branchname, + items.ccode, items.itype, biblioitems.itemtype, @@ -148,7 +149,16 @@ while ( my $c = $sth->fetchrow_hashref() ) { my ( $renewals_count, $renewals_allowed, $renewals_remaining ) = GetRenewCount( $c->{borrowernumber}, $c->{itemnumber} ); - my $itemtype = Koha::ItemTypes->find( $item_level_itypes ? $c->{itype} : $c->{itemtype} ); + my $itemtypes; + foreach my $key (qw(itemtype itype)) { + if ($c->{$key}) { + my $itemtype = Koha::ItemTypes->find($c->{$key}); + if ($itemtype) { + $itemtypes->{$key} = $itemtype->TO_JSON; + $itemtypes->{$key}->{translated_description} = $itemtype->translated_description; + } + } + } my $location; if ( $c->{location} ) { my $av = Koha::AuthorisedValues->search({ category => 'LOC', authorised_value => $c->{location} }); @@ -164,13 +174,18 @@ while ( my $c = $sth->fetchrow_hashref() ) { my $av = Koha::AuthorisedValues->search({ category => 'DAMAGED', authorised_value => $c->{damaged} }); $damaged = $av->count ? $av->next->lib : ''; } + my $ccode; + if ($c->{ccode}) { + my $av = Koha::AuthorisedValues->search({ category => 'CCODE', authorised_value => $c->{ccode} }); + $ccode = $av->count ? $av->next->lib : $c->{ccode}; + } my $checkout = { DT_RowId => $c->{itemnumber} . '-' . $c->{borrowernumber}, title => $c->{title}, author => $c->{author}, barcode => $c->{barcode}, - itemtype => $item_level_itypes ? $c->{itype} : $c->{itemtype}, - itemtype_description => $itemtype ? $itemtype->translated_description : q{}, + itemtypes => $itemtypes, + ccode => $ccode, location => $location, homebranch => $c->{homebranch}, itemnotes => $c->{itemnotes}, -- 2.14.2