| Summary: | Make itemsearch.pl use Koha::CSV for CSV generation | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Tomás Cohen Arazi (tcohen) <tomascohen> |
| Component: | Architecture, internals, and plumbing | Assignee: | Tomás Cohen Arazi (tcohen) <tomascohen> |
| Status: | Needs Signoff --- | QA Contact: | Testopia <testopia> |
| Severity: | enhancement | ||
| Priority: | P5 - low | CC: | martin.renvoize, nick, tomascohen |
| Version: | Main | ||
| Hardware: | All | ||
| OS: | All | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Comma delimited list of Sponsors: | |
| Crowdfunding goal: | 0 | Patch complexity: | Medium patch |
| Documentation contact: | Documentation submission: | ||
| Text to go in the release notes: | Version(s) released in: | ||
| Circulation function: | |||
| Bug Depends on: | 41619, 40880 | ||
| Bug Blocks: | 41621 | ||
| Attachments: |
Bug 41620: Introduce Koha::CSV::ItemSearch
Bug 41620: Use Koha::CSV::ItemSearch for CSV exports |
||
|
Description
Tomás Cohen Arazi (tcohen)
2026-01-14 19:51:38 UTC
Created attachment 191467 [details] [review] Bug 41620: Introduce Koha::CSV::ItemSearch This patch adds Koha::CSV::ItemSearch, a specialized CSV generator for item search results with predefined headers and formatting. The class: - Extends Koha::CSV with always_quote enabled for Excel compatibility - Provides 21 predefined column headers for item search exports - Formats Koha::Item objects into CSV-ready field arrays - Handles authorized values, dates, and library names - Supports MARC21 and UNIMARC title formatting This replaces the template-based CSV generation in itemsearch.pl, eliminating spacing issues and providing a testable, maintainable approach to item search CSV exports. Test plan: 1. Apply patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/CSV/ItemSearch.t => SUCCESS: Tests pass! 3. Tests cover: - Object initialization with always_quote enabled - Header generation (21 columns) - Item formatting with all field types - Authorized value lookups - Date formatting - Library name resolution - CSV output to filehandle 4. Sign off :-D Created attachment 191468 [details] [review] Bug 41620: Use Koha::CSV::ItemSearch for CSV exports This patch replaces template-based CSV generation with Koha::CSV::ItemSearch in both itemsearch.pl and item-export.pl, eliminating spacing issues around delimiters that caused Excel to display quotes as literal characters. Changes: - Update itemsearch.pl to use Koha::CSV::ItemSearch - Update item-export.pl to use Koha::CSV::ItemSearch - Remove obsolete CSV templates - Stream output directly without template overhead This fixes the issue where extra spaces around commas in the templates caused Excel to treat quotes as part of the data rather than CSV delimiters. Test plan: 1. Apply patches 2. Test itemsearch.pl: a. Go to Cataloging > Item search b. Perform a search c. Click "Export results" > "CSV" d. Open items.csv in Excel => SUCCESS: Fields display without quotes 3. Test item-export.pl: a. Go to a bibliographic record b. Select multiple items c. Click "Export selected items" d. Open items.csv in Excel => SUCCESS: Fields display without quotes 4. Verify all 21 columns are present and correctly formatted 5. Verify dates, authorized values, and library names display correctly 6. Sign off :-D |