|
|
|
@ -121,74 +121,44 @@ class User extends DbMapping
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function reload()
|
|
|
|
public function reload()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->setAttributes(User::find($this->login)->toArray());
|
|
|
|
$this->setAttributes(User::find($this->login)->toArray());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getCirculations()
|
|
|
|
private function _getCirculations($table, $sort = "ItemNr ASC") {
|
|
|
|
{
|
|
|
|
$sql = sprintf("SELECT
|
|
|
|
if (!$this->circulations) {
|
|
|
|
NoticeID,
|
|
|
|
$strSQL = "SELECT NoticeId, CheckOutDate, ItemNr FROM Circulations, Items " .
|
|
|
|
CheckOutDate,
|
|
|
|
"WHERE Circulations.UseraccountId = $this->id and Items.ItemId=Circulations.ItemId " .
|
|
|
|
ItemNr
|
|
|
|
"ORDER BY ItemNr asc";
|
|
|
|
FROM %s AS c, Items
|
|
|
|
|
|
|
|
WHERE
|
|
|
|
|
|
|
|
c.UseraccountId = %s
|
|
|
|
|
|
|
|
AND Items.ItemId=c.ItemId
|
|
|
|
|
|
|
|
ORDER BY %s", $table, $this->id, $sort);
|
|
|
|
|
|
|
|
|
|
|
|
$result = Connection::execute($strSQL);
|
|
|
|
$result = Connection::execute($sql);
|
|
|
|
|
|
|
|
|
|
|
|
$ids = array();
|
|
|
|
$circulations = $result->to_array();
|
|
|
|
$checkOutDates = array();
|
|
|
|
$books = array_map(function($c) { return $c['NoticeID']; }, $circulations);
|
|
|
|
$itemNrs = array();
|
|
|
|
$books = AudioBook::findBy('NoticeID', $books, true);
|
|
|
|
|
|
|
|
|
|
|
|
while ($row = $result->next()) {
|
|
|
|
foreach($circulations as $c) {
|
|
|
|
$ids[] = $row['NoticeId'];
|
|
|
|
$books[$c['NoticeID']]['date'] = $c['CheckOutDate'];
|
|
|
|
$checkOutDates[] = $row['CheckOutDate'];
|
|
|
|
$books[$c['NoticeID']]['itemNr'] = $c['ItemNr'];
|
|
|
|
$itemNrs[] = $row['ItemNr'];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->circulations = AudioBook::find($ids);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ici je remplace le champs date du livre par la date du prêt
|
|
|
|
return $books;
|
|
|
|
$counter = 0;
|
|
|
|
|
|
|
|
foreach ($this->circulations as &$circulation) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$circulation->date = substr($checkOutDates[$counter], 0, 10);
|
|
|
|
|
|
|
|
$circulation->itemNr = $itemNrs[$counter];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$counter++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->circulations;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getOldCirculations()
|
|
|
|
public function getCirculations()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
return $this->_getCirculations('Circulations');
|
|
|
|
//if(!$this->oldCirculations){
|
|
|
|
|
|
|
|
$strSQL = "SELECT NoticeId, CheckOutDate FROM OldCirculations, Items " .
|
|
|
|
|
|
|
|
"WHERE OldCirculations.UseraccountId = $this->id and Items.ItemId=OldCirculations.ItemId " .
|
|
|
|
|
|
|
|
"ORDER BY CheckOutDate desc";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$result = Connection::execute($strSQL);
|
|
|
|
|
|
|
|
$ids = array();
|
|
|
|
|
|
|
|
$checkOutDates = array();
|
|
|
|
|
|
|
|
while ($row = $result->next()) {
|
|
|
|
|
|
|
|
$ids[] = $row['NoticeId'];
|
|
|
|
|
|
|
|
$checkOutDates[] = $row['CheckOutDate'];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->oldCirculations = AudioBook::find($ids);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ici je remplace le champs date du livre par la date du prêt
|
|
|
|
public function getOldCirculations()
|
|
|
|
$counter = 0;
|
|
|
|
{
|
|
|
|
foreach ($this->oldCirculations as &$circulation) {
|
|
|
|
return $this->_getCirculations('OldCirculations', 'CheckOutDate DESC');
|
|
|
|
|
|
|
|
|
|
|
|
$circulation->date = substr($checkOutDates[$counter], 0, 10);
|
|
|
|
|
|
|
|
$counter++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->oldCirculations;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
|