Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Merge branch '2022.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlabci committed Nov 10, 2022
2 parents 33cb6fe + 2a177fe commit ce6d575
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tine20/HumanResources/Frontend/Json.php
Expand Up @@ -706,13 +706,15 @@ public function getAttendanceRecorderDeviceStates()
'dir' => 'ASC'
], HumanResources_Controller_AttendanceRecord::getInstance(), HumanResources_Model_AttendanceRecord::class);

$backend = HumanResources_Controller_AttendanceRecord::getInstance()->getBackend();
$db = Tinebase_Core::getDb();
$tableName = $db->quoteIdentifier($backend->getTablePrefix() . $backend->getTableName());
$ids = $db->query('SELECT `id` FROM ' . $tableName . ' AS a JOIN (SELECT device_id, MAX(`sequence`) as `sequence` FROM ' . $tableName .
') AS b ON a.device_id = b.device_id AND a.sequence = b.sequence AND a.account_id = ' .
$db->quoteInto('?', Tinebase_Core::getUser()->getId()))->fetchAll(Zend_Db::FETCH_COLUMN);
$lastRecordPerDevice = $this->_search([
['field' => HumanResources_Model_AttendanceRecord::FLD_ACCOUNT_ID, 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->getId()],
], [
'sort' => HumanResources_Model_AttendanceRecord::FLD_SEQUENCE,
'dir' => 'DESC',
'group' => HumanResources_Model_AttendanceRecord::FLD_DEVICE_ID,
], HumanResources_Controller_AttendanceRecord::getInstance(), HumanResources_Model_AttendanceRecord::class);
['field' => 'id', 'operator' => 'in', 'value' => $ids],
], null, HumanResources_Controller_AttendanceRecord::getInstance(), HumanResources_Model_AttendanceRecord::class);

foreach ($lastRecordPerDevice['results'] as $lastRecord) {
foreach ($openRecords['results'] as $openRecord) {
Expand Down

0 comments on commit ce6d575

Please sign in to comment.