=== SG Library Management ===
Contributors: sglibrarytools
Tags: library, marc21, iso2709, circulation, catalogue, patrons
Requires at least: 6.2
Tested up to: 6.8
Requires PHP: 7.4
Stable tag: 1.1.0
License: GPLv2 or later

Library catalogue, MARC21/ISO 2709 exchange, copy/item management, patrons, circulation, holiday-aware due dates, holds, reports, and patron self-service.

== Version 1.1.0 ==
* Reworked ISO 2709 record reader with record-length, base-address, directory, field-terminator, and record-terminator checks.
* MARC21 directory field parsing, indicators/subfield-aware field access, common bibliographic field mapping, raw-byte preservation, and ISO 2709 writer for locally created records.
* Added automated standalone MARC codec smoke tests in tests/marc21-test.php.
* Added hold queue and patron self-service hold requests.
* Added patron self-service and staff loan renewals with renewal-limit and active-hold checks.
* Added responsive catalogue and account styling plus SCSS and LESS source files.
* Added automatic database schema upgrade on plugin version changes.

== Installation ==
1. Back up your WordPress database.
2. Upload the ZIP via Plugins > Add New Plugin > Upload Plugin.
3. Activate SG Library Management. When upgrading from 1.0.0, schema migration runs on the next WordPress plugin load.
4. Assign library staff the `manage_sglm` capability (administrators receive it on activation).
5. Create a public catalogue page with [sg_library_catalog]. Create a login-protected patron account page with [sg_library_patron_lookup].

== MARC exchange notes ==
* Import expects binary ISO 2709 records (commonly .mrc/.marc/.iso), not MARCXML.
* Imported raw record bytes are retained and exported unchanged when available, preserving fields not mapped to the local display columns.
* Locally-created records are serialized from supported local fields; this is not a full cataloguer's editor for every MARC21 field.
* The reader validates ISO 2709 structure and provides a basic title-245 validation helper. This is not a replacement for the Library of Congress MARC validation suite.
* MARC-8 to Unicode transcoding is not implemented. UTF-8 records are preserved as bytes; confirm encoding with your source and target systems before batch migration.
* Import is capped at 50 MB in the admin upload handler. Always test with a copy of the catalogue before production imports.

== Testing ==
Run `php tests/marc21-test.php` from the plugin directory. This is a standalone codec smoke test; live WordPress, MySQL, theme compatibility, real-world corpus, and independent validator tests must be completed on the target installation before production use.

== Shortcodes ==
[sg_library_catalog] - public searchable catalogue and authenticated hold requests.
[sg_library_patron_lookup] - signed-in patron's loans, renewals, and holds.


= Version 1.2.0 =
* Added MARC21 editor for leader and arbitrary variable fields, ISO 2709 serialization and structural validation.
* Added optional independent pymarc validation/round-trip utility in tools/validate_marc.py.
* Added OAI-PMH ListRecords harvesting for oai_dc and provider-supplied MARCXML prefixes, resumption tokens, source tracking and duplicate suppression.
* Added Open Library Covers API ISBN thumbnails to the public catalogue. Open Library requests are per displayed title, not bulk crawls.
* Added conditional item-claim transactions for circulation and a WordPress PHPUnit integration-test scaffold plus staging concurrency plan.
* Added SCSS and LESS source stylesheets alongside compiled CSS.

== Validation commands ==
Run PHP MARC tests: php tests/marc21-test.php
Run PHP syntax checks for all plugin PHP files.
For independent MARC validation, install Python pymarc and run: python tools/validate_marc.py catalog.mrc --roundtrip pymarc-roundtrip.mrc
For circulation integration tests, configure the WordPress PHPUnit test suite, activate the plugin, and run tests/test-circulation.php. True parallel checkout testing must be done against a staging MySQL/MariaDB instance.

= Public OPAC (1.3.0) =
Use the [sg_library_catalog] shortcode on a WordPress page to render the responsive public catalogue. Search supports all fields, title, author, subject, ISBN, and call number, with 24 results per page. Cover thumbnails are requested from the Open Library Covers API by ISBN; records without ISBNs or matching covers use a generated fallback. Add [sg_library_patron_lookup] to a separate page for signed-in patron self-service.

= Version 1.5.0 =
* OPAC filters: author, language and branch, alongside material type, year and availability.
* Logged-in users can save searches and add/remove catalogue favourites.
* Add the shortcode [sg_library_saved_items] to a WordPress page to show a signed-in patron's saved searches and favourite titles.
* Optional daily due-date and overdue email reminders. They are disabled by default; enable them under Library > Settings > Email notifications.
* Library > Analytics & Audit includes circulation rankings, branch inventory counts and recent audit events.
* Reminder timing uses WordPress Cron, which is request-triggered; a server cron is recommended where punctual reminders matter.
