Rename method for the website GetLoans and recreate GetCirculations for internal tools
This commit is contained in:
@@ -83,7 +83,50 @@ class User extends DbMapping
|
|||||||
return $results->current() !== false ? new User($results->current()) : null;
|
return $results->current() !== false ? new User($results->current()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _getCirculations($table, $sort = "ItemNr ASC") {
|
/**
|
||||||
|
* Circulations as needed for the BSR internal tools
|
||||||
|
*/
|
||||||
|
public function GetCirculations()
|
||||||
|
{
|
||||||
|
$sql = sprintf("SELECT
|
||||||
|
n.NoticeID,
|
||||||
|
ItemNr,
|
||||||
|
LTRIM(RTRIM(n.NoticeNr)) AS code,
|
||||||
|
LTRIM(RTRIM(n.Title)) AS Title,
|
||||||
|
LTRIM(RTRIM(n.Author)) AS author,
|
||||||
|
Fields.[300] AS media,
|
||||||
|
Fields.[901] AS readBy
|
||||||
|
FROM Circulations AS c
|
||||||
|
INNER JOIN Items AS i ON i.ItemId = c.ItemId
|
||||||
|
INNER JOIN Notices AS n ON n.NoticeID = i.NoticeID
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT *
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
NoticeID,
|
||||||
|
Tag AS Field,
|
||||||
|
LTRIM(RTRIM(COALESCE(
|
||||||
|
NULLIF(NoticeFields.ContentShortPart, ''),
|
||||||
|
NULLIF(NoticeFields.ContentLongPart, ''),
|
||||||
|
'na'
|
||||||
|
))) AS Data
|
||||||
|
FROM NoticeFields
|
||||||
|
WHERE Tag IN ('901', '300')
|
||||||
|
) AS src
|
||||||
|
PIVOT (
|
||||||
|
MIN(Data)
|
||||||
|
FOR Field IN ([901], [300])
|
||||||
|
) AS pvt
|
||||||
|
) Fields ON n.NoticeID = Fields.NoticeID
|
||||||
|
WHERE
|
||||||
|
c.UserAccountID = %s
|
||||||
|
ORDER BY ItemNr ASC", $this->id);
|
||||||
|
|
||||||
|
$result = Connection::execute($sql);
|
||||||
|
return $result ? $result->to_array() : array();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _getLoans($table, $sort = "ItemNr ASC") {
|
||||||
$sql = sprintf("SELECT
|
$sql = sprintf("SELECT
|
||||||
n.NoticeNr,
|
n.NoticeNr,
|
||||||
CheckOutDate,
|
CheckOutDate,
|
||||||
@@ -114,14 +157,22 @@ class User extends DbMapping
|
|||||||
return $books;
|
return $books;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCirculations()
|
/**
|
||||||
|
* Loans (Circulations) as needed on the website
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function GetLoans()
|
||||||
{
|
{
|
||||||
return $this->_getCirculations('Circulations');
|
return $this->_getLoans('Circulations');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOldCirculations()
|
/**
|
||||||
|
* Old loans (OldCirculations) as needed on the website
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function GetOldLoans()
|
||||||
{
|
{
|
||||||
return $this->_getCirculations('OldCirculations', 'CheckOutDate DESC');
|
return $this->_getLoans('OldCirculations', 'CheckOutDate DESC');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -411,15 +411,28 @@ class NetBiblio extends WebService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the list of books that are currently let to the
|
* This method returns the list of all Circulations for the currently
|
||||||
* authenticated user.
|
* authenticated user in a format suited for BSR internal tools
|
||||||
|
* (CD engraving for example).
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
*/
|
*/
|
||||||
public function GetCirculations()
|
public function GetCirculations()
|
||||||
{
|
{
|
||||||
$circulations = $this->getUser()->getCirculations();
|
return $this->getUser()->GetCirculations();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the list of books that are currently lent to the
|
||||||
|
* authenticated user.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @throws AuthenticationException
|
||||||
|
*/
|
||||||
|
public function GetLoans()
|
||||||
|
{
|
||||||
|
$circulations = $this->getUser()->GetLoans();
|
||||||
return array_values($this->AddBookData($circulations));
|
return array_values($this->AddBookData($circulations));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,9 +443,9 @@ class NetBiblio extends WebService
|
|||||||
* @return array
|
* @return array
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
*/
|
*/
|
||||||
public function GetOldCirculations()
|
public function GetOldLoans()
|
||||||
{
|
{
|
||||||
$circulations = $this->getUser()->getOldCirculations();
|
$circulations = $this->getUser()->GetOldLoans();
|
||||||
return array_values($this->AddBookData($circulations));
|
return array_values($this->AddBookData($circulations));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user