Système de feedback par gilles

envoi du mail après un certain nombre de tl.
Amélioration de la rcherche.
2-3 autres trucs.
This commit is contained in:
SIMON_\Simon
2017-07-24 17:05:05 +02:00
parent c140c28bd4
commit ddaf517579
5 changed files with 121 additions and 26 deletions

View File

@@ -182,6 +182,24 @@ class User extends DbMapping
return $this->_getLoans('OldCirculations', $count, 'CheckOutDate DESC');
}
/**
* Books eligible for feedback by the user. Lent or downloaded more than 2 weeks ago and less than 5 monthes.
* @return array
*/
public function GetBooksForFeedback()
{
$sql = sprintf("SELECT n.NoticeNr
FROM OldCirculations AS c
INNER JOIN Items AS i ON i.ItemId = c.ItemId
INNER JOIN Notices AS n ON n.NoticeID = i.NoticeID
WHERE
c.UserAccountID = %s
AND DATEDIFF(week, CheckOutDate, GETDATE()) > 1
AND DATEDIFF(month, CheckOutDate, GETDATE()) < 5
", $this->id);
return Connection::execute($sql)->to_array(); }
/**
* Add a book to the wish list if it is not already inside.
@@ -237,20 +255,38 @@ class User extends DbMapping
* @param int $limit
* @return array
*/
public function getWishes($count = false, $limit = 50)
public function getWishes($count = false, $limit = 200)
{
$sql = sprintf("SELECT TOP $limit
NoticeID
NoticeID, CreationDate
FROM Wishes
WHERE UserAccountID = %s
ORDER BY CreationDate DESC", $this->id);
$result = Connection::execute($sql);
$ids = array_map(function($r) { return $r['NoticeID']; }, $result->to_array());
$wishList = $result->to_array();
$ids = array_map(function($r) { return $r['NoticeID']; }, $wishList);
if($count) {
return count($ids);
}
return BookSearch::GetBooks($ids, 'id');
$books = BookSearch::GetBooks($ids, 'id');
foreach($wishList as $w) {
$id = $w['NoticeID'];
if(isset($books[$id])) {
$books[$id]['creationDate'] = $w['CreationDate'];
}
}
$creationDates = array();
foreach ($books as $key => $book)
{
$creationDates[$key] = $book['creationDate'];
}
array_multisort($creationDates, SORT_DESC, $books);
return $books;
}
/**
@@ -269,4 +305,4 @@ class User extends DbMapping
$status = Connection::execute($sql, true);
return $status && ! $status->is_error() && $status->get_num_rows() > 0;
}
}
}