From idgbpo at gmail.com Sun May 10 17:27:26 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Sun, 10 May 2015 20:57:26 +0530 Subject: [Koha-patches] [PATCH 3/3] Bug 13993 - (3) Transfer order leaves incorrect orderstatus In-Reply-To: <1431271646-11974-1-git-send-email-indradg@gmail.com> References: <1431271646-11974-1-git-send-email-indradg@gmail.com> Message-ID: <1431271646-11974-3-git-send-email-indradg@gmail.com> From: Amit Gupta 11) Apply patch (3) 12) Log in to staff client 13) Acquisitions 14) Create a basket for two different vendors 15) Place an order in one vendor's basket. 16) Transfer the order to the other vendor's basket. 17) prove -v t/db_dependent/Acquisition/TransferOrder.t -- This should succeed without intervention. 18) Run koha qa test tools for the last 3 commits. Signed-off-by: Indranil Das Gupta Signed-off-by: Indranil Das Gupta (L2C2 Technologies) --- C4/Acquisition.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index 83ec911..063b353 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1856,11 +1856,11 @@ sub TransferOrder { $query = q{ UPDATE aqorders - SET datecancellationprinted = CAST(NOW() AS date) + SET datecancellationprinted = CAST(NOW() AS date), orderstatus = ? WHERE ordernumber = ? }; $sth = $dbh->prepare($query); - $rv = $sth->execute($ordernumber); + $rv = $sth->execute('cancelled', $ordernumber); delete $order->{'ordernumber'}; delete $order->{parent_ordernumber}; -- 1.9.1 From idgbpo at gmail.com Sun May 10 17:27:25 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Sun, 10 May 2015 20:57:25 +0530 Subject: [Koha-patches] [PATCH 2/3] Bug 13993 - (2) Correct poorly transferred orders In-Reply-To: <1431271646-11974-1-git-send-email-indradg@gmail.com> References: <1431271646-11974-1-git-send-email-indradg@gmail.com> Message-ID: <1431271646-11974-2-git-send-email-indradg@gmail.com> From: Mark Tompsett Added Atomic Update to fix poorly transferred orders TEST PLAN --------- 8) Apply patch (2) 9) Run the database updates $ ./installer/data/mysql/updatedatabase.pl -- This should run without error 10) prove -v t/db_dependent/Acquisition/TransferOrder.t -- This should fail, because the transfer function is still not fixed. Signed-off-by: Indranil Das Gupta (L2C2 Technologies) --- .../Bug-13993-Correct-OrderStatus-Of-Poorly-Transferred-Orders.sql | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/Bug-13993-Correct-OrderStatus-Of-Poorly-Transferred-Orders.sql diff --git a/installer/data/mysql/atomicupdate/Bug-13993-Correct-OrderStatus-Of-Poorly-Transferred-Orders.sql b/installer/data/mysql/atomicupdate/Bug-13993-Correct-OrderStatus-Of-Poorly-Transferred-Orders.sql new file mode 100644 index 0000000..0a05ae5 --- /dev/null +++ b/installer/data/mysql/atomicupdate/Bug-13993-Correct-OrderStatus-Of-Poorly-Transferred-Orders.sql @@ -0,0 +1,3 @@ +UPDATE aqorders SET orderstatus='cancelled' + WHERE (datecancellationprinted IS NOT NULL OR + datecancellationprinted<>'0000-00-00'); -- 1.9.1 From idgbpo at gmail.com Sun May 10 17:27:24 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Sun, 10 May 2015 20:57:24 +0530 Subject: [Koha-patches] [PATCH 1/3] Bug 13993 - (1) Add tests to confirm 'new' and 'cancelled' Message-ID: <1431271646-11974-1-git-send-email-indradg@gmail.com> From: Mark Tompsett This adds 2 tests to t/db_dependent/Acquisition/TransferOrder.t in order to confirm the order's status is properly marked. TEST PLAN --------- 1) Log into staff client 2) Acquisitions 3) Create a basket for two differing vendors. 4) Place an order in one of the baskets. 5) Transfer the order from one vendor's basket to the others. 6) Apply this patch (1) only 7) prove -v t/db_dependent/Acquisition/TransferOrder.t -- should fail one test: not marked as 'cancelled'. Signed-off-by: Indranil Das Gupta (L2C2 Technologies) --- t/db_dependent/Acquisition/TransferOrder.t | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Acquisition/TransferOrder.t b/t/db_dependent/Acquisition/TransferOrder.t index d868240..2a1d6f2 100644 --- a/t/db_dependent/Acquisition/TransferOrder.t +++ b/t/db_dependent/Acquisition/TransferOrder.t @@ -2,7 +2,7 @@ use Modern::Perl; -use Test::More tests => 11; +use Test::More tests => 13; use C4::Context; use C4::Acquisition; use C4::Biblio; @@ -76,6 +76,12 @@ is(scalar GetOrders($basketno2), 0, "0 order in basket2"); my $newordernumber = TransferOrder($ordernumber, $basketno2); is(scalar GetOrders($basketno1), 0, "0 order in basket1"); is(scalar GetOrders($basketno2), 1, "1 order in basket2"); + +# Determine if the transfer marked things cancelled properly. +is($order->{orderstatus},'new','Order marked as new as expected'); +($order) = GetOrders($basketno1, { 'cancelled' => 1 }); +is($order->{orderstatus},'cancelled','Order marked as cancelled as expected'); + ($order) = GetOrders($basketno2); is(scalar GetItemnumbersFromOrder($order->{ordernumber}), 1, "1 item in basket2's order"); -- 1.9.1 From idgbpo at gmail.com Sun May 10 23:43:33 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Mon, 11 May 2015 03:13:33 +0530 Subject: [Koha-patches] [PATCH] Bug 12146 [ENH] Add isocode column to parameters.sql Message-ID: <1431294213-26606-1-git-send-email-indradg@gmail.com> a) Adds currency.isocode column to parameters.sql b) Introduces INR as an option for Koha's EN installation locale in the list of currencies Remarks: The issue of non-mandatory nature of isocode column is already settled via bug 9593, comment 77. Test Plan ========= 1/ create a fresh Koha instance and run the web installer 2/ at step #3 - "Selecting Default Settings", select "Some basic currencies with USA dollar as default for ACQ module" under the section "Optional" to import the sample currencies. 3/ login to this new instance and go to Home -> Administration -> Currencies & Exchange rates 4/ click edit for any of the currency options 5/ ISO code will be blank 6/ Apply patch 7/ Repeat steps 1 to 4 above 8/ ISO code will now show 3-letter ISO codes inserted by patched parameters.sql --- installer/data/mysql/en/optional/parameters.sql | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/installer/data/mysql/en/optional/parameters.sql b/installer/data/mysql/en/optional/parameters.sql index 16e8642..5334740 100644 --- a/installer/data/mysql/en/optional/parameters.sql +++ b/installer/data/mysql/en/optional/parameters.sql @@ -1,5 +1,6 @@ -INSERT INTO `currency` (currency, rate, symbol, active) VALUES -('USD', 1.0, '$', '1'), -('GBP', 1.9929, '?', '0'), -('CAD', 1.02207, '$', '0'), -('EUR', .874003, '?', '0'); +INSERT INTO `currency` (currency, rate, symbol, active, isocode) VALUES +('USD', 1.0, '$', '1', 'USD'), +('GBP', 1.9929, '?', '0', 'GBP'), +('CAD', 1.02207, '$', '0', 'CAD'), +('EUR', .874003, '?', '0', 'EUR'), +('INR', 63.71, '?', '0', 'INR'); -- 1.9.1 From idgbpo at gmail.com Mon May 11 01:59:38 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Mon, 11 May 2015 05:29:38 +0530 Subject: [Koha-patches] [PATCH 2/2] Bug 14179 - Update currency field's maxlength attribute In-Reply-To: <1431302378-29177-1-git-send-email-indradg@gmail.com> References: <1431302378-29177-1-git-send-email-indradg@gmail.com> Message-ID: <1431302378-29177-2-git-send-email-indradg@gmail.com> Updates 'maxlength' attribute of field 'currency' in the 'New currency' addition form to 255 and brings it in sync with the field width of corresponding `currency`.`currency` column. --- koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt index 57c38cf..dda6940 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/currency.tt @@ -85,7 +85,7 @@ [% searchfield %] [% ELSE %] - Required + Required [% END %]
  • -- 1.9.1 From idgbpo at gmail.com Mon May 11 01:59:37 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Mon, 11 May 2015 05:29:37 +0530 Subject: [Koha-patches] [PATCH 1/2] Bug 14179 - Alters currency field to VARCHAR(255) Message-ID: <1431302378-29177-1-git-send-email-indradg@gmail.com> Alters `currency`.`currency` column from VARCHAR(10) to VARCHAR(255) --- .../data/mysql/atomicupdate/bug_14179-alter-currency-table.sql | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_14179-alter-currency-table.sql diff --git a/installer/data/mysql/atomicupdate/bug_14179-alter-currency-table.sql b/installer/data/mysql/atomicupdate/bug_14179-alter-currency-table.sql new file mode 100644 index 0000000..e6a06e6 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_14179-alter-currency-table.sql @@ -0,0 +1,6 @@ +-- +-- Alter `currency` column from VARCHAR(10) to VARCHAR(255) +-- + +ALTER TABLE `currency` + MODIFY COLUMN `currency` VARCHAR(255) NOT NULL DEFAULT ''; -- 1.9.1 From srdjan at catalyst.net.nz Mon May 11 02:07:23 2015 From: srdjan at catalyst.net.nz (Srdjan) Date: Mon, 11 May 2015 12:07:23 +1200 Subject: [Koha-patches] [PATCH] bug_11213: Changed XSLTParse4Display() interface Message-ID: <1431302843-16663-1-git-send-email-srdjan@catalyst.net.nz> The list of biblio items is passed on now, instead of GetItemsInfo() being called. This is because the callers already have the list ready, so the GetItemsInfo() call is being duplicated unnecessarily. Search::searchResults() builds items list from XML, and that one is passed instead. * XSLT::XSLTParse4Display() - supply the items list as input param - removed hidden items list param - hidden should not be in the items list - changed buildKohaItemsNamespace() accordingly * Items - removed GetItemsLocationInfo() - added sort_by input param to GetItemsInfo() - VirtualShelves::Page::shelfpage() - replaced GetItemsLocationInfo() call with GetItemsInfo() call, passing order_by "cn_sort" * catalogue/detail.pl, opac/opac-detail.pl, shelfpage() - added items list to the XSLTParse4Display() call * Search::searchResults() - include all available info when building items lists - added combined items list (available, on loan, other) to the XSLTParse4Display() call To test: This change is a noop, so following screens need to be checked against any changes: * Intranet: - catalogue/search.pl (results) - catalogue/detail.pl - virtualshelves/shelves.pl * Opac - opac-search.pl (results, hidelostitems syspref on and off) - opac-detail.pl - opac-shelves.pl The display should stay the same before and after patch. The speed should increase though. --- C4/Items.pm | 91 ++++++++++++----------------------------------- C4/Search.pm | 19 +++------- C4/VirtualShelves/Page.pm | 8 ++--- C4/XSLT.pm | 23 ++++++------ catalogue/detail.pl | 12 +++---- opac/opac-detail.pl | 10 +++--- 6 files changed, 55 insertions(+), 108 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index d1a866b..ed753f6 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -69,7 +69,6 @@ BEGIN { GetItemInfosOf GetItemsByBiblioitemnumber GetItemsInfo - GetItemsLocationInfo GetHostItemsInfo GetItemnumbersForBiblio get_itemnumbers_of @@ -1257,10 +1256,14 @@ sub GetItemsByBiblioitemnumber { =head2 GetItemsInfo - @results = GetItemsInfo($biblionumber); + @results = GetItemsInfo($biblionumber, $order_by); Returns information about items with the given biblionumber. +The list is ordered by home branch name and some complex criteria +within it (see the code), unless $order_by is specified. +Currently only "cn_sort" is supported. + C returns a list of references-to-hash. Each element contains a number of keys. Most of them are attributes from the C, C, C, and C tables in the @@ -1298,7 +1301,8 @@ If this is set, it is set to C. =cut sub GetItemsInfo { - my ( $biblionumber ) = @_; + my ( $biblionumber, $order_by ) = @_; + my $dbh = C4::Context->dbh; # note biblioitems.* must be avoided to prevent large marc and marcxml fields from killing performance. my $query = " @@ -1344,7 +1348,18 @@ sub GetItemsInfo { LEFT JOIN serial USING (serialid) LEFT JOIN itemtypes ON itemtypes.itemtype = " . (C4::Context->preference('item-level_itypes') ? 'items.itype' : 'biblioitems.itemtype'); - $query .= " WHERE items.biblionumber = ? ORDER BY home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ; + $query .= " WHERE items.biblionumber = ? ORDER BY "; + my $order_by_cause = "home.branchname, items.enumchron, LPAD( items.copynumber, 8, '0' ), items.dateaccessioned DESC" ; + if ($order_by) { + if ($order_by eq 'cn_sort') { + $order_by_cause = "cn_sort ASC"; + } + else { + warn qq{Unsupported order by "$order_by"}; + } + } + $query .= $order_by_cause; + my $sth = $dbh->prepare($query); $sth->execute($biblionumber); my $i = 0; @@ -1377,6 +1392,9 @@ sub GetItemsInfo { $data->{stack} = C4::Koha::GetKohaAuthorisedValueLib( $code, $data->{stack} ); } + $data->{location_intranet} = GetKohaAuthorisedValueLib('LOC', $data->{location}); + $data->{location_opac} = GetKohaAuthorisedValueLib('LOC', $data->{location}, 1); + # Find the last 3 people who borrowed this item. my $sth2 = $dbh->prepare("SELECT * FROM old_issues,borrowers WHERE itemnumber = ? @@ -1401,71 +1419,6 @@ sub GetItemsInfo { : @results; } -=head2 GetItemsLocationInfo - - my @itemlocinfo = GetItemsLocationInfo($biblionumber); - -Returns the branch names, shelving location and itemcallnumber for each item attached to the biblio in question - -C returns a list of references-to-hash. Data returned: - -=over 2 - -=item C<$data-E{homebranch}> - -Branch Name of the item's homebranch - -=item C<$data-E{holdingbranch}> - -Branch Name of the item's holdingbranch - -=item C<$data-E{location}> - -Item's shelving location code - -=item C<$data-E{location_intranet}> - -The intranet description for the Shelving Location as set in authorised_values 'LOC' - -=item C<$data-E{location_opac}> - -The OPAC description for the Shelving Location as set in authorised_values 'LOC'. Falls back to intranet description if no OPAC -description is set. - -=item C<$data-E{itemcallnumber}> - -Item's itemcallnumber - -=item C<$data-E{cn_sort}> - -Item's call number normalized for sorting - -=back - -=cut - -sub GetItemsLocationInfo { - my $biblionumber = shift; - my @results; - - my $dbh = C4::Context->dbh; - my $query = "SELECT a.branchname as homebranch, b.branchname as holdingbranch, - location, itemcallnumber, cn_sort - FROM items, branches as a, branches as b - WHERE homebranch = a.branchcode AND holdingbranch = b.branchcode - AND biblionumber = ? - ORDER BY cn_sort ASC"; - my $sth = $dbh->prepare($query); - $sth->execute($biblionumber); - - while ( my $data = $sth->fetchrow_hashref ) { - $data->{location_intranet} = GetKohaAuthorisedValueLib('LOC', $data->{location}); - $data->{location_opac}= GetKohaAuthorisedValueLib('LOC', $data->{location}, 1); - push @results, $data; - } - return @results; -} - =head2 GetHostItemsInfo $hostiteminfo = GetHostItemsInfo($hostfield); diff --git a/C4/Search.pm b/C4/Search.pm index 990ed39..b5ab049 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -2057,7 +2057,6 @@ sub searchResults { my $items_count = scalar(@fields); my $maxitems_pref = C4::Context->preference('maxItemsinSearchResults'); my $maxitems = $maxitems_pref ? $maxitems_pref - 1 : 1; - my @hiddenitems; # hidden itemnumbers based on OpacHiddenItems syspref # loop through every item foreach my $field (@fields) { @@ -2079,7 +2078,6 @@ sub searchResults { # hidden based on OpacHiddenItems syspref my @hi = C4::Items::GetHiddenItemnumbers($item); if (scalar @hi) { - push @hiddenitems, @hi; $hideatopac_count++; next; } @@ -2096,7 +2094,7 @@ sub searchResults { $item->{'branchname'} = $branches{$item->{$otherbranch}}; } - my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber}; + my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber}; # For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item my $userenv = C4::Context->userenv; if ( $item->{onloan} @@ -2104,12 +2102,10 @@ sub searchResults { { $onloan_count++; my $key = $prefix . $item->{onloan} . $item->{barcode}; + $onloan_items->{$key} = { %$item }; $onloan_items->{$key}->{due_date} = format_date( $item->{onloan} ); $onloan_items->{$key}->{count}++ if $item->{$hbranch}; - $onloan_items->{$key}->{branchname} = $item->{branchname}; $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} }; - $onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber}; - $onloan_items->{$key}->{description} = $item->{description}; $onloan_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); @@ -2192,25 +2188,20 @@ sub searchResults { $other_count++; my $key = $prefix . $item->{status}; - foreach (qw(withdrawn itemlost damaged branchname itemcallnumber)) { - $other_items->{$key}->{$_} = $item->{$_}; - } + $other_items->{$key} = { %$item }; $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0; $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0; $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan}; $other_items->{$key}->{count}++ if $item->{$hbranch}; $other_items->{$key}->{location} = $shelflocations->{ $item->{location} }; - $other_items->{$key}->{description} = $item->{description}; $other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); } # item is available else { $can_place_holds = 1; $available_count++; + $available_items->{$prefix} = { %$item }; $available_items->{$prefix}->{count}++ if $item->{$hbranch}; - foreach (qw(branchname itemcallnumber description)) { - $available_items->{$prefix}->{$_} = $item->{$_}; - } $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} }; $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); } @@ -2239,7 +2230,7 @@ sub searchResults { # XSLT processing of some stuff my $interface = $search_context eq 'opac' ? 'OPAC' : ''; if (!$scan && C4::Context->preference($interface . "XSLTResultsDisplay")) { - $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", 1, \@hiddenitems); + $oldbiblio->{XSLTResultsRecord} = XSLTParse4Display($oldbiblio->{biblionumber}, $marcrecord, $interface."XSLTResultsDisplay", [@available_items_loop, @onloan_items_loop, @other_items_loop], 1); # the last parameter tells Koha to clean up the problematic ampersand entities that Zebra outputs } diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index beed3e2..b0c7df0 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -263,11 +263,13 @@ sub shelfpage { for my $this_item (@$items) { my $biblionumber = $this_item->{'biblionumber'}; + # Getting items infos for location display + my @items_infos = &GetItemsInfo( $this_item->{'biblionumber'}, "cn_sort" ); my $record = GetMarcBiblio($biblionumber); if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') { - $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay"); + $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay", \@items_infos); } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') { - $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay"); + $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay", \@items_infos); } # the virtualshelfcontents table does not store these columns nor are they retrieved from the items @@ -283,8 +285,6 @@ sub shelfpage { $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour); $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour); if(!defined($this_item->{'size'})) { $this_item->{'size'} = "" }; #TT has problems with size - # Getting items infos for location display - my @items_infos = &GetItemsLocationInfo( $this_item->{'biblionumber'}); $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} ); $this_item->{'ITEM_RESULTS'} = \@items_infos; if ( grep {$_ eq $biblionumber} @cart_list) { diff --git a/C4/XSLT.pm b/C4/XSLT.pm index ea9c7f5..db32d6f 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -156,8 +156,17 @@ sub _get_best_default_xslt_filename { return $xslfilename; } +=head2 XSLTParse4Display( $biblionumber, $orig_record, $xslsyspref, $items, $fixamps ) + + $items => an array of items rerords, as returned from eg. GetItemsInfo + +Returns XSLT block + +=cut + sub XSLTParse4Display { - my ( $biblionumber, $orig_record, $xslsyspref, $fixamps, $hidden_items ) = @_; + my ( $biblionumber, $orig_record, $xslsyspref, $items, $fixamps ) = @_; + my $xslfilename = C4::Context->preference($xslsyspref); if ( $xslfilename =~ /^\s*"?default"?\s*$/i ) { my $htdocs; @@ -195,7 +204,7 @@ sub XSLTParse4Display { # grab the XML, run it through our stylesheet, push it out to the browser my $record = transformMARCXML4XSLT($biblionumber, $orig_record); - my $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items); + my $itemsxml = $items ? buildKohaItemsNamespace($biblionumber, $items) : ""; my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); my $sysxml = "\n"; foreach my $syspref ( qw/ hidelostitems OPACURLOpenInNewWindow @@ -236,13 +245,7 @@ Is only used in this module currently. =cut sub buildKohaItemsNamespace { - my ($biblionumber, $hidden_items) = @_; - - my @items = C4::Items::GetItemsInfo($biblionumber); - if ($hidden_items && @$hidden_items) { - my %hi = map {$_ => 1} @$hidden_items; - @items = grep { !$hi{$_->{itemnumber}} } @items; - } + my ($biblionumber, $items) = @_; my $shelflocations = GetKohaAuthorisedValues('items.location',GetFrameworkCode($biblionumber), 'opac'); my $ccodes = GetKohaAuthorisedValues('items.ccode',GetFrameworkCode($biblionumber), 'opac'); @@ -252,7 +255,7 @@ sub buildKohaItemsNamespace { my $location = ""; my $ccode = ""; my $xml = ''; - for my $item (@items) { + for my $item (@$items) { my $status; my ( $transfertwhen, $transfertfrom, $transfertto ) = C4::Circulation::GetTransfers($item->{itemnumber}); diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 74665b1..93f8721 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -84,12 +84,6 @@ my $fw = GetFrameworkCode($biblionumber); my $showallitems = $query->param('showallitems'); my $marcflavour = C4::Context->preference("marcflavour"); -# XSLT processing of some stuff -if (C4::Context->preference("XSLTDetailsDisplay") ) { - $template->param('XSLTDetailsDisplay' =>'1', - 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "XSLTDetailsDisplay") ); -} - $template->param( 'SpineLabelShowPrintOnBibDetails' => C4::Context->preference("SpineLabelShowPrintOnBibDetails") ); $template->param( ocoins => GetCOinSBiblio($record) ); @@ -137,6 +131,12 @@ if (@hostitems){ push (@items, at hostitems); } +# XSLT processing of some stuff +if (C4::Context->preference("XSLTDetailsDisplay") ) { + $template->param('XSLTDetailsDisplay' =>'1', + 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "XSLTDetailsDisplay", \@all_items) ); +} + my $dat = &GetBiblioData($biblionumber); #coping with subscriptions diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl index ca882ea..b9ac3e3 100755 --- a/opac/opac-detail.pl +++ b/opac/opac-detail.pl @@ -140,11 +140,6 @@ SetUTF8Flag($record); my $marcflavour = C4::Context->preference("marcflavour"); my $ean = GetNormalizedEAN( $record, $marcflavour ); -# XSLT processing of some stuff -if (C4::Context->preference("OPACXSLTDetailsDisplay") ) { - $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "OPACXSLTDetailsDisplay" ) ); -} - my $OpacBrowseResults = C4::Context->preference("OpacBrowseResults"); $template->{VARS}->{'OpacBrowseResults'} = $OpacBrowseResults; @@ -480,6 +475,11 @@ if ($hideitems) { @items = @all_items; } +# XSLT processing of some stuff +if (C4::Context->preference("OPACXSLTDetailsDisplay") ) { + $template->param( 'XSLTBloc' => XSLTParse4Display($biblionumber, $record, "OPACXSLTDetailsDisplay", \@items) ); +} + my $branches = GetBranches(); my $branch = ''; if (C4::Context->userenv){ -- 1.9.1 From srdjan at catalyst.net.nz Mon May 11 02:07:36 2015 From: srdjan at catalyst.net.nz (Srdjan) Date: Mon, 11 May 2015 12:07:36 +1200 Subject: [Koha-patches] [PATCH] bug_11213: whitespace correction Message-ID: <1431302856-16769-1-git-send-email-srdjan@catalyst.net.nz> --- C4/Search.pm | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index b5ab049..29506b7 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -2105,7 +2105,7 @@ sub searchResults { $onloan_items->{$key} = { %$item }; $onloan_items->{$key}->{due_date} = format_date( $item->{onloan} ); $onloan_items->{$key}->{count}++ if $item->{$hbranch}; - $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} }; + $onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} }; $onloan_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); @@ -2191,19 +2191,22 @@ sub searchResults { $other_items->{$key} = { %$item }; $other_items->{$key}->{intransit} = ( $transfertwhen ne '' ) ? 1 : 0; $other_items->{$key}->{onhold} = ($reservestatus) ? 1 : 0; - $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value and $item->{notforloan}; - $other_items->{$key}->{count}++ if $item->{$hbranch}; - $other_items->{$key}->{location} = $shelflocations->{ $item->{location} }; - $other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); + $other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) + if $notforloan_authorised_value and $item->{notforloan}; + $other_items->{$key}->{count}++ + if $item->{$hbranch}; + $other_items->{$key}->{location} = $shelflocations->{ $item->{location} }; + $other_items->{$key}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); } # item is available else { $can_place_holds = 1; $available_count++; $available_items->{$prefix} = { %$item }; - $available_items->{$prefix}->{count}++ if $item->{$hbranch}; - $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} }; - $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); + $available_items->{$prefix}->{count}++ + if $item->{$hbranch}; + $available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} }; + $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( $search_context, $itemtypes{ $item->{itype} }->{imageurl} ); } } } # notforloan, item level and biblioitem level -- 1.9.1 From srdjan at catalyst.net.nz Mon May 11 02:07:48 2015 From: srdjan at catalyst.net.nz (Srdjan) Date: Mon, 11 May 2015 12:07:48 +1200 Subject: [Koha-patches] [PATCH] bug_11213: Include XSLT processing for searchResults() test Message-ID: <1431302868-16862-1-git-send-email-srdjan@catalyst.net.nz> * Added template paths to temp test dir, so XSLT templates can be picked up --- C4/XSLT.pm | 1 + t/db_dependent/Search.t | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index db32d6f..62b38f7 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -25,6 +25,7 @@ use strict; use warnings; use C4::Context; +use C4::Templates; use C4::Branch; use C4::Items; use C4::Koha; diff --git a/t/db_dependent/Search.t b/t/db_dependent/Search.t index b96cc19..c3b2c77 100644 --- a/t/db_dependent/Search.t +++ b/t/db_dependent/Search.t @@ -127,6 +127,8 @@ $contextmodule->mock('preference', sub { return ''; } elsif ($pref eq 'AlternateHoldingsField') { return '490av'; + } elsif ($pref =~ m/XSLTResultsDisplay/) { + return 'default'; } elsif ($pref eq 'AuthoritySeparator') { return '--'; } elsif ($pref eq 'DisplayLibraryFacets') { @@ -195,6 +197,15 @@ sub mock_marcfromkohafield { sub run_marc21_search_tests { my $indexing_mode = shift; $datadir = tempdir(); + # Unix friendly, but so is the zebra_config.pl command below... + my $tpl_dir = File::Spec->rel2abs( dirname(__FILE__) ) . "/../../koha-tmpl"; + my $opac_dir = "$datadir/opac"; + mkdir $opac_dir; + symlink "$tpl_dir/opac-tmpl", "$opac_dir/templates"; + my $intranet_dir = "$datadir/intranet"; + mkdir $intranet_dir; + symlink "$tpl_dir/intranet-tmpl", "$intranet_dir/templates"; + system(dirname(__FILE__) . "/zebra_config.pl $datadir marc21 $indexing_mode"); mock_marcfromkohafield('marc21'); -- 1.9.1 From srdjan at catalyst.net.nz Mon May 11 02:07:55 2015 From: srdjan at catalyst.net.nz (Srdjan) Date: Mon, 11 May 2015 12:07:55 +1200 Subject: [Koha-patches] [PATCH] bug_11213: C4::VirtualShelves::Page::shelf_contents() Message-ID: <1431302875-16945-1-git-send-email-srdjan@catalyst.net.nz> * Extracted shelf items processing from shelfpage() into a separate sub shelf_contents() in order to be able to test it * Added tests for shelf_contents() with XSLT --- C4/VirtualShelves/Page.pm | 113 +++++++++++++++++++++-------------- t/db_dependent/VirtualShelves_Page.t | 43 ++++++++++++- 2 files changed, 110 insertions(+), 46 deletions(-) diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index b0c7df0..629c944 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -74,7 +74,6 @@ sub shelfpage { my $itemoff = ( $query->param('itemoff') ? $query->param('itemoff') : 1 ); my $displaymode = ( $query->param('display') ? $query->param('display') : 'publicshelves' ); my ( $shelflimit, $shelfoffset, $shelveslimit, $shelvesoffset ); - my $marcflavour = C4::Context->preference("marcflavour"); $shelflimit = ( $type eq 'opac' ? C4::Context->preference('OPACnumSearchResults') : C4::Context->preference('numSearchResults') ); $shelflimit = $shelflimit || ShelvesMax('MGRPAGE'); @@ -240,7 +239,6 @@ sub shelfpage { #check that the user can view the shelf if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) { my $items; - my $tag_quantity; my $sortfield = ( $sorton ? $sorton : 'title' ); $sortfield = $query->param('sort') || $sortfield; ## Passed in sorting overrides default sorting my $direction = $query->param('direction') || 'asc'; @@ -248,8 +246,6 @@ sub shelfpage { sort => $sortfield, direction => $direction, ); - ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction ); - # get biblionumbers stored in the cart # Note that it's not use at the intranet my @cart_list; @@ -259,47 +255,16 @@ sub shelfpage { @cart_list = split(/\//, $cart_list); } - my $borrower = GetMember( 'borrowernumber' => $loggedinuser ); - - for my $this_item (@$items) { - my $biblionumber = $this_item->{'biblionumber'}; - # Getting items infos for location display - my @items_infos = &GetItemsInfo( $this_item->{'biblionumber'}, "cn_sort" ); - my $record = GetMarcBiblio($biblionumber); - if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') { - $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay", \@items_infos); - } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') { - $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay", \@items_infos); - } - - # the virtualshelfcontents table does not store these columns nor are they retrieved from the items - # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn - #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype} }->{'imageurl'}; - #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'}; - $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} ); - $this_item->{'imageurl'} = getitemtypeinfo( $this_item->{'itemtype'}, $type )->{'imageurl'}; - $this_item->{'coins'} = GetCOinSBiblio( $record ); - $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'})); - $this_item->{'normalized_upc'} = GetNormalizedUPC( $record,$marcflavour); - $this_item->{'normalized_ean'} = GetNormalizedEAN( $record,$marcflavour); - $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour); - $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour); - if(!defined($this_item->{'size'})) { $this_item->{'size'} = "" }; #TT has problems with size - $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} ); - $this_item->{'ITEM_RESULTS'} = \@items_infos; - if ( grep {$_ eq $biblionumber} @cart_list) { - $this_item->{'incart'} = 1; - } - - if (C4::Context->preference('TagsEnabled') and $tag_quantity = C4::Context->preference('TagsShowOnList')) { - $this_item->{'TagLoop'} = get_tags({ - biblionumber=>$this_item->{'biblionumber'}, approved=>1, 'sort'=>'-weight', - limit=>$tag_quantity - }); - } - - $this_item->{'allow_onshelf_holds'} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower); - } + ( $items, $totitems ) = shelf_contents({ + borrower => GetMember( 'borrowernumber' => $loggedinuser ), + shelfnumber => $shelfnumber, + shelflimit => $shelflimit, + shelfoffset => $shelfoffset, + sortfield => $sortfield, + direction => $direction, + type => $type, + cart_list => \@cart_list, + }); if($type eq 'intranet'){ # Build drop-down list for 'Add To:' menu... my ($totalref, $pubshelves, $barshelves)= @@ -505,6 +470,64 @@ sub shelfpage { output_html_with_http_headers $query, $cookie, $template->output; } +sub shelf_contents { + my ( $params ) = @_; + my $borrower = $params->{borrower}; + my $shelfnumber = $params->{shelfnumber}; + my $shelflimit = $params->{shelflimit}; + my $shelfoffset = $params->{shelfoffset}; + my $sortfield = $params->{sortfield}; + my $direction = $params->{direction}; + my $type = $params->{type}; + my $cart_list = $params->{cart_list}; + + my $marcflavour = C4::Context->preference("marcflavour"); + my $tag_quantity = C4::Context->preference('TagsEnabled') + ? C4::Context->preference('TagsShowOnList') + : undef; + my ( $items, $totitems ) = GetShelfContents( $shelfnumber, $shelflimit, $shelfoffset, $sortfield, $direction ); + for my $this_item (@$items) { + my $biblionumber = $this_item->{'biblionumber'}; + # Getting items infos for location display + my @items_infos = &GetItemsInfo( $this_item->{'biblionumber'}, "cn_sort" ); + my $record = GetMarcBiblio($biblionumber); + if (C4::Context->preference("OPACXSLTResultsDisplay") && $type eq 'opac') { + $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "OPACXSLTResultsDisplay", \@items_infos); + } elsif (C4::Context->preference("XSLTResultsDisplay") && $type eq 'intranet') { + $this_item->{XSLTBloc} = XSLTParse4Display($biblionumber, $record, "XSLTResultsDisplay", \@items_infos); + } + + # the virtualshelfcontents table does not store these columns nor are they retrieved from the items + # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn + #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype} }->{'imageurl'}; + #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'}; + $this_item->{'dateadded'} = format_date( $this_item->{'dateadded'} ); + $this_item->{'imageurl'} = getitemtypeinfo( $this_item->{'itemtype'}, $type )->{'imageurl'}; + $this_item->{'coins'} = GetCOinSBiblio( $record ); + $this_item->{'subtitle'} = GetRecordValue('subtitle', $record, GetFrameworkCode($this_item->{'biblionumber'})); + $this_item->{'normalized_upc'} = GetNormalizedUPC( $record,$marcflavour); + $this_item->{'normalized_ean'} = GetNormalizedEAN( $record,$marcflavour); + $this_item->{'normalized_oclc'} = GetNormalizedOCLCNumber($record,$marcflavour); + $this_item->{'normalized_isbn'} = GetNormalizedISBN(undef,$record,$marcflavour); + if(!defined($this_item->{'size'})) { $this_item->{'size'} = "" }; #TT has problems with size + $this_item->{'itemsissued'} = CountItemsIssued( $this_item->{'biblionumber'} ); + $this_item->{'ITEM_RESULTS'} = \@items_infos; + if ( $cart_list && grep {$_ eq $biblionumber} @$cart_list) { + $this_item->{'incart'} = 1; + } + + if ($tag_quantity) { + $this_item->{'TagLoop'} = get_tags({ + biblionumber=>$this_item->{'biblionumber'}, approved=>1, 'sort'=>'-weight', + limit=>$tag_quantity + }); + } + + $this_item->{'allow_onshelf_holds'} = C4::Reserves::OnShelfHoldsAllowed($this_item, $borrower); + } + return ( $items, $totitems ); +} + 1; __END__ diff --git a/t/db_dependent/VirtualShelves_Page.t b/t/db_dependent/VirtualShelves_Page.t index 236d147..dfe4b62 100755 --- a/t/db_dependent/VirtualShelves_Page.t +++ b/t/db_dependent/VirtualShelves_Page.t @@ -6,9 +6,50 @@ use strict; use warnings; -use Test::More tests => 1; +use Test::More tests => 3; + +use C4::Context; BEGIN { use_ok('C4::VirtualShelves::Page'); } +my $dbh = C4::Context->dbh; +# Start transaction +$dbh->{AutoCommit} = 0; +$dbh->{RaiseError} = 1; + +C4::Context->set_preference('XSLTResultsDisplay', 'default'); +C4::Context->set_preference('OPACXSLTResultsDisplay', 'default'); +C4::Context->clear_syspref_cache(); + +my $query = qq{ + SELECT vs.shelfnumber, vs.shelfname,vs.owner, + bo.surname,bo.firstname,vs.category,vs.sortfield, + count(vc.biblionumber) as count + FROM virtualshelves vs + JOIN borrowers bo ON vs.owner=bo.borrowernumber + JOIN virtualshelfcontents vc USING (shelfnumber) + GROUP BY vs.shelfnumber + LIMIT 1 +}; +my $shelf = $dbh->selectrow_hashref($query); + +my %params = ( + shelfnumber => $shelf->{shelfnumber}, + shelflimit => 1, + shelfoffset => 0, + sortfield => $shelf->{sortfield}, + direction => 'asc', + type => 'opac', + cart_list => [], +); +my ( $items, $totitems ) = C4::VirtualShelves::Page::shelf_contents(\%params); +ok( $items->[0]{XSLTBloc}, "opac items XSLT"); + +$params{type} = 'intranet'; +( $items, $totitems ) = C4::VirtualShelves::Page::shelf_contents(\%params); +ok( $items->[0]{XSLTBloc}, "intranet items XSLT"); + +# Cleanup +$dbh->rollback; -- 1.9.1 From srdjan at catalyst.net.nz Mon May 11 02:08:04 2015 From: srdjan at catalyst.net.nz (Srdjan) Date: Mon, 11 May 2015 12:08:04 +1200 Subject: [Koha-patches] [PATCH] bug_11213: GetItemsInfo() test Message-ID: <1431302884-17029-1-git-send-email-srdjan@catalyst.net.nz> --- t/db_dependent/Items.t | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index b41b483..6cfb862 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -35,7 +35,7 @@ my ($branch1, $branch2) = keys %$branches; subtest 'General Add, Get and Del tests' => sub { - plan tests => 6; + plan tests => 8; # Start transaction $dbh->{AutoCommit} = 0; @@ -50,6 +50,11 @@ subtest 'General Add, Get and Del tests' => sub { cmp_ok($item_bibnum, '==', $bibnum, "New item is linked to correct biblionumber."); cmp_ok($item_bibitemnum, '==', $bibitemnum, "New item is linked to correct biblioitemnumber."); + # Get items. + my @items_infos = GetItemsInfo( $bibnum, "cn_sort" ); + cmp_ok(scalar(@items_infos), '==', 1, "One item for biblionumber."); + cmp_ok($items_infos[0]{biblionumber}, '==', $bibnum, "Item has correct biblionumber."); + # Get item. my $getitem = GetItem($itemnumber); cmp_ok($getitem->{'itemnumber'}, '==', $itemnumber, "Retrieved item has correct itemnumber."); -- 1.9.1 From srdjan at catalyst.net.nz Mon May 11 02:08:28 2015 From: srdjan at catalyst.net.nz (Srdjan) Date: Mon, 11 May 2015 12:08:28 +1200 Subject: [Koha-patches] [PATCH] bug_11213: Added XSLTParse4Display() to Items test Message-ID: <1431302908-17177-1-git-send-email-srdjan@catalyst.net.nz> --- t/db_dependent/Items.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index 6cfb862..ce5342e 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -21,6 +21,7 @@ use Modern::Perl; use MARC::Record; use C4::Biblio; use C4::Branch; +use C4::XSLT; use Koha::Database; use Test::More tests => 6; @@ -35,7 +36,7 @@ my ($branch1, $branch2) = keys %$branches; subtest 'General Add, Get and Del tests' => sub { - plan tests => 8; + plan tests => 10; # Start transaction $dbh->{AutoCommit} = 0; @@ -55,6 +56,16 @@ subtest 'General Add, Get and Del tests' => sub { cmp_ok(scalar(@items_infos), '==', 1, "One item for biblionumber."); cmp_ok($items_infos[0]{biblionumber}, '==', $bibnum, "Item has correct biblionumber."); + C4::Context->set_preference('XSLTResultsDisplay', 'default'); + C4::Context->set_preference('OPACXSLTResultsDisplay', 'default'); + C4::Context->clear_syspref_cache(); + my $record = GetMarcBiblio($bibnum); + my $html = XSLTParse4Display($bibnum, $record, "OPACXSLTResultsDisplay", \@items_infos); + ok($html, "XSLTParse4Display( OPACXSLTResultsDisplay )"); + $html = XSLTParse4Display($bibnum, $record, "XSLTResultsDisplay", \@items_infos); + ok($html, "XSLTParse4Display( XSLTResultsDisplay )"); + + # Get item. my $getitem = GetItem($itemnumber); cmp_ok($getitem->{'itemnumber'}, '==', $itemnumber, "Retrieved item has correct itemnumber."); -- 1.9.1 From srdjan at catalyst.net.nz Mon May 11 02:08:39 2015 From: srdjan at catalyst.net.nz (Srdjan) Date: Mon, 11 May 2015 12:08:39 +1200 Subject: [Koha-patches] [PATCH] bug_11213: Check for $item->{itype} presence to avoid warning Message-ID: <1431302919-17270-1-git-send-email-srdjan@catalyst.net.nz> --- C4/XSLT.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 62b38f7..a793524 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -263,8 +263,16 @@ sub buildKohaItemsNamespace { my $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} ); - if ( $itemtypes->{ $item->{itype} }->{notforloan} || $item->{notforloan} || $item->{onloan} || $item->{withdrawn} || $item->{itemlost} || $item->{damaged} || - (defined $transfertwhen && $transfertwhen ne '') || $item->{itemnotforloan} || (defined $reservestatus && $reservestatus eq "Waiting") ){ + if ( ($item->{itype} && $itemtypes->{ $item->{itype} }->{notforloan}) + || $item->{notforloan} + || $item->{onloan} + || $item->{withdrawn} + || $item->{itemlost} + || $item->{damaged} + || (defined $transfertwhen && $transfertwhen ne '') + || $item->{itemnotforloan} + || (defined $reservestatus && $reservestatus eq "Waiting") + ){ if ( $item->{notforloan} < 0) { $status = "On order"; } -- 1.9.1 From idgbpo at gmail.com Wed May 13 02:21:16 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Wed, 13 May 2015 05:51:16 +0530 Subject: [Koha-patches] [PATCH] Bug 14185: Undefined $limit causes warn in opac/opac-readingrecord.pl Message-ID: <1431476476-690-1-git-send-email-indradg@gmail.com> From: Aleisha This patch sets $limit to be an empty string. Test plan ========= 1/ login into the opac using your user account credentials 2/ in a terminal, run a `tail -f ` on your instance's opac-error.log 3/ go back to the opac, click on 'your reading history' tab to go to opac-readingrecord.pl 4/ notice the warning - "opac-readingrecord.pl: Use of uninitialized value $limit" appear in the `tail`ed opac-error.log 5/ apply the patch 6/ reload the page (opac-readingrecord.pl) 7/ page works but the warning in step #4 is no longer logged 8/ run qa test (i.e. koha-qa.pl -c 1 -v 2), there should be no error Remarks: Testing result match expected test plan output. The QA tests pass with "OK" for the commit. Signed-off-by: Indranil Das Gupta (L2C2 Technologies) --- opac/opac-readingrecord.pl | 1 + 1 file changed, 1 insertion(+) diff --git a/opac/opac-readingrecord.pl b/opac/opac-readingrecord.pl index 4a1ac78..795e90c 100755 --- a/opac/opac-readingrecord.pl +++ b/opac/opac-readingrecord.pl @@ -73,6 +73,7 @@ else { my $limit = $query->param('limit'); +$limit //= ''; $limit = ( $limit eq 'full' ) ? 0 : 50; my $issues = GetAllIssues( $borrowernumber, $order, $limit ); -- 1.9.1 From idgbpo at gmail.com Wed May 13 17:53:00 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Wed, 13 May 2015 21:23:00 +0530 Subject: [Koha-patches] [PATCH] Bug 14194: Restore the HH:MM to 23:59 for onsite-checkouts Message-ID: <1431532380-17604-1-git-send-email-indradg@gmail.com> From: Jonathan Druart (Introduced by bug 13601) Test plan ========= 1/ enable 'OnSiteCheckouts' pref under Circulation Preferences 2/ go to the checkouts page and try to issue an item to any user. 3/ when the item barcode entry form shows, select the 'On-site checkout' checkbox 4/ the default date due should show as today with 00:00 as HH:MM 5/ apply the patch 6/ repeat steps 2 - 3. The default date due should show today's date with 23:59 as HH:MM. 7/ run koha-qa.pl -c 1 -v 2 Remarks: Testing result match expected test plan output. The QA tests pass with "OK" for the commit. Technical note: There is a confusion with iso and sql date formats at some places in the code. A better way should be provided (later) to fix globally the mismatch between these 2 formats. What happened before this patch: the DateTime was cast to a string and the template received "YYYY-MM-DDTHH:MM:SS" which is an iso formatted date. BUT this format is not managed by Koha::DateUtils::output_pref ("iso" and "sql" are considered as indentical which is wrong). As I did not estimated the problem (how big it is) I prefer to fix it easily (and dirty) for now. Signed-off-by: Indranil Das Gupta (L2C2 Technologies) --- circ/circulation.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index ab47895..ab6db3b 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -587,7 +587,7 @@ $template->param( AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"), canned_bor_notes_loop => $canned_notes, debarments => GetDebarments({ borrowernumber => $borrowernumber }), - todaysdate => dt_from_string()->set(hour => 23)->set(minute => 59), + todaysdate => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ), ); output_html_with_http_headers $query, $cookie, $template->output; -- 1.9.1 From idgbpo at gmail.com Thu May 14 03:00:50 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Thu, 14 May 2015 06:30:50 +0530 Subject: [Koha-patches] [PATCH 1/2] Bug 14194: Restore the HH:MM to 23:59 for onsite-checkouts Message-ID: <1431565251-28259-1-git-send-email-indradg@gmail.com> From: Jonathan Druart (Introduced by bug 13601) Test plan ========= 1/ enable 'OnSiteCheckouts' pref under Circulation Preferences 2/ go to the checkouts page and try to issue an item to any user. 3/ when the item barcode entry form shows, select the 'On-site checkout' checkbox 4/ the default date due should show as today with 00:00 as HH:MM 5/ apply the patch 6/ repeat steps 2 - 3. The default date due should show today's date with 23:59 as HH:MM. 7/ run koha-qa.pl -c 1 -v 2 Remarks: Testing result match expected test plan output. The QA tests pass with "OK" for the commit. Technical note: There is a confusion with iso and sql date formats at some places in the code. A better way should be provided (later) to fix globally the mismatch between these 2 formats. What happened before this patch: the DateTime was cast to a string and the template received "YYYY-MM-DDTHH:MM:SS" which is an iso formatted date. BUT this format is not managed by Koha::DateUtils::output_pref ("iso" and "sql" are considered as indentical which is wrong). As I did not estimated the problem (how big it is) I prefer to fix it easily (and dirty) for now. Signed-off-by: Indranil Das Gupta (L2C2 Technologies) --- circ/circulation.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circ/circulation.pl b/circ/circulation.pl index ab47895..ab6db3b 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -587,7 +587,7 @@ $template->param( AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"), canned_bor_notes_loop => $canned_notes, debarments => GetDebarments({ borrowernumber => $borrowernumber }), - todaysdate => dt_from_string()->set(hour => 23)->set(minute => 59), + todaysdate => output_pref( { dt => dt_from_string()->set(hour => 23)->set(minute => 59), dateformat => 'sql' } ), ); output_html_with_http_headers $query, $cookie, $template->output; -- 1.9.1 From idgbpo at gmail.com Thu May 14 03:05:55 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Thu, 14 May 2015 06:35:55 +0530 Subject: [Koha-patches] [PATCH 2/2] Bug 14184: Undefined $term causes noisy warns in C4/CourseReserves.pm Message-ID: <1431565555-28494-2-git-send-email-indradg@gmail.com> From: Aleisha This patch sets $term to be an empty string. Test plan ========= 1/ enable 'UseCourseReserves' syspref in Circulation preferences 2/ in a terminal, run a `tail -f ` on your instance's opac-error.log 3/ go to the opac, click on 'Course reserve' tab to go to opac-course-reserves.pl 4/ notice the warning - "opac-course-reserves.pl: Use of uninitialized value $term" appear in the `tail`ed opac-error.log 5/ apply the patch 6/ reload the page (opac-course-reserves.pl) 7/ page works but the warning in step #4 is no longer logged 8/ run qa test (i.e. koha-qa.pl -c 1 -v 2), there should be no error Remarks: Testing result match expected test plan output. The QA tests pass with "OK" for the commit. Signed-off-by: Indranil Das Gupta (L2C2 Technologies) --- C4/CourseReserves.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/C4/CourseReserves.pm b/C4/CourseReserves.pm index 4a7bb22..7e160d0 100644 --- a/C4/CourseReserves.pm +++ b/C4/CourseReserves.pm @@ -1052,6 +1052,7 @@ sub SearchCourses { GROUP BY c.course_id "; + $term //= ''; $term = "%$term%"; @params = ($term) x 10; -- 1.9.1 From idgbpo at gmail.com Thu May 14 04:09:27 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Thu, 14 May 2015 07:39:27 +0530 Subject: [Koha-patches] [PATCH 2/2] [FOLLOWUP] Bug 14186: Undefined $reservedfor causes warn in opac-reserve.pl In-Reply-To: <1431569367-32370-1-git-send-email-indradg@gmail.com> References: <1431569367-32370-1-git-send-email-indradg@gmail.com> Message-ID: <1431569367-32370-2-git-send-email-indradg@gmail.com> This is a followup for Bug 14186 that removes the extraneous tab char on line 470, so that the patch can clear QA tools. This patch sets $reservedfor to an empty string. Test plan ========= 1/ in a terminal, run `tail -f ` on your instance's opac-error.log 2/ go to the opac and search from an item that exists on the Koha instance. 3/ Select the title (if more than one title is returned) and click on 'Place hold' link to go to opac-reserve.pl 4/ notice the warning - "opac-reserve.pl: Use of uninitialized value $reservedfor" appear in the `tail`ed opac-error.log 5/ apply the patch 6/ reload the page (opac-reserve.pl) 7/ page works but the warning in step #4 is no longer thrown up 8/ run qa test (i.e. koha-qa.pl -c 1 -v 2), there should be no error Remarks: Testing result match expected test plan output. The QA tests pass with "OK" for the commit. Signed-off-by: Indranil Das Gupta (L2C2 Technologies) --- opac/opac-reserve.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 51402b8..b6c8768 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -467,7 +467,7 @@ foreach my $biblioNum (@biblionumbers) { # the item could be reserved for this borrower vi a host record, flag this $reservedfor //= ''; - if ($reservedfor eq $borrowernumber){ + if ($reservedfor eq $borrowernumber){ $itemLoopIter->{already_reserved} = 1; } -- 1.9.1 From idgbpo at gmail.com Thu May 14 04:09:26 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Thu, 14 May 2015 07:39:26 +0530 Subject: [Koha-patches] [PATCH 1/2] Bug 14186: Undefined $reservedfor causes warn in opac-reserve.pl Message-ID: <1431569367-32370-1-git-send-email-indradg@gmail.com> From: Aleisha This patch sets $reservedfor to an empty string. Test plan ========= 1/ in a terminal, run `tail -f ` on your instance's opac-error.log 2/ go to the opac and search from an item that exists on the Koha instance. 3/ Select the title (if more than one title is returned) and click on 'Place hold' link to go to opac-reserve.pl 4/ notice the warning - "opac-reserve.pl: Use of uninitialized value $reservedfor" appear in the `tail`ed opac-error.log 5/ apply the patch 6/ reload the page (opac-reserve.pl) 7/ page works but the warning in step #4 is no longer thrown up 8/ run qa test (i.e. koha-qa.pl -c 1 -v 2), there should be no error Remarks: The QA test failed - "forbidden pattern: tab char (line 470)". Marking this as 'FAILED QA' --- opac/opac-reserve.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl index 5ab4c34..51402b8 100755 --- a/opac/opac-reserve.pl +++ b/opac/opac-reserve.pl @@ -466,7 +466,8 @@ foreach my $biblioNum (@biblionumbers) { my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0); # the item could be reserved for this borrower vi a host record, flag this - if ($reservedfor eq $borrowernumber){ + $reservedfor //= ''; + if ($reservedfor eq $borrowernumber){ $itemLoopIter->{already_reserved} = 1; } -- 1.9.1 From idgbpo at gmail.com Mon May 18 03:03:48 2015 From: idgbpo at gmail.com (Indranil Das Gupta) Date: Mon, 18 May 2015 06:33:48 +0530 Subject: [Koha-patches] [PATCH] Bug 14206 - Fixes deletion issue for non-email notices Message-ID: <1431911028-11831-1-git-send-email-indradg@gmail.com> message_transport_type was not being passed to routine in letter.pl routines, so notices that did not include an email template couldn't be deleted from Tools -> Notices & Slips page. This patch fixes that issue. Test plan ========= 1/ Go to Tools -> Notices & Slips. Add a new notice only for print, leave 'Library' and 'Koha module' options as default selections. Enter 'KOHA_14206' and 'Koha Test 14206' against Code and Name respectively, and 'Test' and 'Test Message' for subject and body. Leave the Email, Phone and SMS tabs blank. Save the notice. 2/ On the notices listing page the new notice will be listed. Try to delete it. It will load the 'Delete notice' dialog form, but the table will not show any data under s - 'Library', 'Module', 'Code' or 'Name'. 3/ Click the "Yes, delete" button. The page will be submitted and the Notices listing reloaded. The print-only KOHA_14206 notice should continue to exist. This is *wrong*. 4/ Apply the patch 5/ Reload the listings page and click on the 'Delete' link for Notice KOHA_14206. This time, it should show the data under 'Module', 'Code' or 'Name' at least. 6/ Click on 'Yes, delete'. The page should submit and the listing page reload. This time KOHA_14206 will be gone. 7/ Run sql statement SELECT * FROM `letter` WHERE `code` = 'KOHA_14206' to check actual deletion from the database. No record should be returned. 8/ Re-add notice KOHA_14206, but this time also add fill in print, email, phone and sms delivery options. 9/ Delete the newly re-added notice KOHA_14206. It should no longer be shown in the listing. Confirm deletion by running step #7. No record should be returned. 10/ run koha qa test tools --- koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt | 4 ++-- tools/letter.pl | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt index 3106498..f842060 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -231,7 +231,7 @@ $(document).ready(function() { [% IF !lette.protected && can_edit %] - Delete + Delete [% END %] @@ -444,7 +444,7 @@ $(document).ready(function() { - [% Branches.GetName( letter.branchcode ) %] + [% IF letter.branchcode %][% Branches.GetName( letter.branchcode ) %][% ELSE %](All libraries)[% END %] [% letter.module %] [% letter.code %] [% letter.name %] diff --git a/tools/letter.pl b/tools/letter.pl index e9f39d9..82316fe 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -66,6 +66,7 @@ my $code = $input->param('code'); my $module = $input->param('module') || ''; my $content = $input->param('content'); my $op = $input->param('op') || ''; +my $mtt = $input->param('mtt') || ''; my $dbh = C4::Context->dbh; our ( $template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user( @@ -112,7 +113,7 @@ elsif ( $op eq 'add_form' ) { add_form($branchcode, $module, $code); } elsif ( $op eq 'delete_confirm' ) { - delete_confirm($branchcode, $module, $code); + delete_confirm($branchcode, $module, $code, $mtt); } elsif ( $op eq 'delete_confirmed' ) { delete_confirmed($branchcode, $module, $code); @@ -293,9 +294,9 @@ sub add_validate { } sub delete_confirm { - my ($branchcode, $module, $code) = @_; + my ($branchcode, $module, $code, $mtt) = @_; my $dbh = C4::Context->dbh; - my $letter = C4::Letters::getletter($module, $code, $branchcode); + my $letter = C4::Letters::getletter($module, $code, $branchcode, $mtt); my @values = values %$letter; $template->param( letter => $letter, @@ -325,7 +326,7 @@ sub retrieve_letters { my $dbh = C4::Context->dbh; my ($sql, @where, @args); - $sql = "SELECT branchcode, module, code, name, branchname + $sql = "SELECT branchcode, module, code, name, branchname, message_transport_type FROM letter LEFT OUTER JOIN branches USING (branchcode) "; -- 1.9.1