From 5303f1fd487913bf3ddf5a56dffd49204acbd449 Mon Sep 17 00:00:00 2001 From: Thomas Misilo <misilot@users.noreply.github.com> Date: Mon, 13 Jun 2016 16:01:41 -0400 Subject: [PATCH] Updated KohaILSDI to support getPurchaseHistory() (#723) What it does is return the latest received issue from the Serials module in Koha --- .../src/VuFind/ILS/Driver/KohaILSDI.php | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/module/VuFind/src/VuFind/ILS/Driver/KohaILSDI.php b/module/VuFind/src/VuFind/ILS/Driver/KohaILSDI.php index 2eafb2c98a4..d6878e27310 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/KohaILSDI.php +++ b/module/VuFind/src/VuFind/ILS/Driver/KohaILSDI.php @@ -1339,8 +1339,30 @@ class KohaILSDI extends \VuFind\ILS\Driver\AbstractBase implements */ public function getPurchaseHistory($id) { - // TODO - return []; + try { + if (!$this->db) { + $this->initDb(); + } + $sql = "SELECT b.title, b.biblionumber, + MAX(CONCAT(s.publisheddate, ' / ',s.serialseq)) + AS 'date and enumeration' + FROM serial s + LEFT JOIN biblio b USING (biblionumber) + WHERE s.STATUS=2 and b.biblionumber = :id + GROUP BY b.biblionumber + ORDER BY s.publisheddate DESC"; + + $sqlStmt = $this->db->prepare($sql); + $sqlStmt->execute(['id' => $id]); + + $result = []; + foreach ($sqlStmt->fetchAll() as $rowItem) { + $result[] = ['issue' => $rowItem["date and enumeration"]]; + } + } catch (PDOException $e) { + throw new ILSException($e->getMessage()); + } + return $result; } /** -- GitLab