|
|
@ -3,22 +3,31 @@ use Engelsystem\Database\Db;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Load a single work log entry.
|
|
|
|
* Load a single work log entry.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param int $user_worklog_id
|
|
|
|
* @param int $user_worklog_id
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function UserWorkLog($user_worklog_id) {
|
|
|
|
function UserWorkLog($user_worklog_id)
|
|
|
|
return Db::selectOne("SELECT * FROM `UserWorkLog` WHERE `id`=?", [$user_worklog_id]);
|
|
|
|
{
|
|
|
|
|
|
|
|
return Db::selectOne("SELECT * FROM `UserWorkLog` WHERE `id`=?", [
|
|
|
|
|
|
|
|
$user_worklog_id
|
|
|
|
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Returns all work log entries for a user.
|
|
|
|
* Returns all work log entries for a user.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param User $user
|
|
|
|
* @param User $user
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function UserWorkLogsForUser($user) {
|
|
|
|
function UserWorkLogsForUser($user)
|
|
|
|
return Db::select("SELECT * FROM `UserWorkLog` WHERE `user_id`=? ORDER BY `created_timestamp`", [$user['UID']]);
|
|
|
|
{
|
|
|
|
|
|
|
|
return Db::select("SELECT * FROM `UserWorkLog` WHERE `user_id`=? ORDER BY `created_timestamp`", [
|
|
|
|
|
|
|
|
$user['UID']
|
|
|
|
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Delete a work log entry.
|
|
|
|
* Delete a work log entry.
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function UserWorkLog_delete($userWorkLog)
|
|
|
|
function UserWorkLog_delete($userWorkLog)
|
|
|
@ -28,16 +37,14 @@ function UserWorkLog_delete($userWorkLog)
|
|
|
|
$userWorkLog['id']
|
|
|
|
$userWorkLog['id']
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
engelsystem_log(sprintf('Delete work log for %s, %s hours, %s',
|
|
|
|
engelsystem_log(sprintf('Delete work log for %s, %s hours, %s', User_Nick_render($user_source), $userWorkLog['work_hours'], $userWorkLog['comment']));
|
|
|
|
User_Nick_render($user_source),
|
|
|
|
|
|
|
|
$userWorkLog['work_hours'],
|
|
|
|
|
|
|
|
$userWorkLog['comment']));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Update work log entry (only work hours and comment)
|
|
|
|
* Update work log entry (only work hours and comment)
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function UserWorkLog_update($userWorkLog)
|
|
|
|
function UserWorkLog_update($userWorkLog)
|
|
|
@ -45,24 +52,24 @@ function UserWorkLog_update($userWorkLog)
|
|
|
|
$user_source = User($userWorkLog['user_id']);
|
|
|
|
$user_source = User($userWorkLog['user_id']);
|
|
|
|
|
|
|
|
|
|
|
|
$result = Db::update("UPDATE `UserWorkLog` SET
|
|
|
|
$result = Db::update("UPDATE `UserWorkLog` SET
|
|
|
|
|
|
|
|
`work_timestamp`=?,
|
|
|
|
`work_hours`=?,
|
|
|
|
`work_hours`=?,
|
|
|
|
`comment`=?
|
|
|
|
`comment`=?
|
|
|
|
WHERE `id`=?", [
|
|
|
|
WHERE `id`=?", [
|
|
|
|
|
|
|
|
$userWorkLog['work_timestamp'],
|
|
|
|
$userWorkLog['work_hours'],
|
|
|
|
$userWorkLog['work_hours'],
|
|
|
|
$userWorkLog['comment'],
|
|
|
|
$userWorkLog['comment'],
|
|
|
|
$userWorkLog['id']
|
|
|
|
$userWorkLog['id']
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
engelsystem_log(sprintf('Updated work log for %s, %s hours, %s',
|
|
|
|
engelsystem_log(sprintf('Updated work log for %s, %s hours, %s', User_Nick_render($user_source), $userWorkLog['work_hours'], $userWorkLog['comment']));
|
|
|
|
User_Nick_render($user_source),
|
|
|
|
|
|
|
|
$userWorkLog['work_hours'],
|
|
|
|
|
|
|
|
$userWorkLog['comment']));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Create a new work log entry
|
|
|
|
* Create a new work log entry
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
* @param UserWorkLog $userWorkLog
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function UserWorkLog_create($userWorkLog)
|
|
|
|
function UserWorkLog_create($userWorkLog)
|
|
|
@ -73,23 +80,22 @@ function UserWorkLog_create($userWorkLog)
|
|
|
|
|
|
|
|
|
|
|
|
$result = Db::insert("INSERT INTO `UserWorkLog` (
|
|
|
|
$result = Db::insert("INSERT INTO `UserWorkLog` (
|
|
|
|
`user_id`,
|
|
|
|
`user_id`,
|
|
|
|
|
|
|
|
`work_timestamp`,
|
|
|
|
`work_hours`,
|
|
|
|
`work_hours`,
|
|
|
|
`comment`,
|
|
|
|
`comment`,
|
|
|
|
`created_user_id`,
|
|
|
|
`created_user_id`,
|
|
|
|
`created_timestamp`
|
|
|
|
`created_timestamp`
|
|
|
|
)
|
|
|
|
)
|
|
|
|
VALUES (?, ?, ?, ?, ?)", [
|
|
|
|
VALUES (?, ?, ?, ?, ?, ?)", [
|
|
|
|
$userWorkLog['user_id'],
|
|
|
|
$userWorkLog['user_id'],
|
|
|
|
|
|
|
|
$userWorkLog['work_timestamp'],
|
|
|
|
$userWorkLog['work_hours'],
|
|
|
|
$userWorkLog['work_hours'],
|
|
|
|
$userWorkLog['comment'],
|
|
|
|
$userWorkLog['comment'],
|
|
|
|
$user['UID'],
|
|
|
|
$user['UID'],
|
|
|
|
time()
|
|
|
|
time()
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
engelsystem_log(sprintf('Added work log entry for %s, %s hours, %s',
|
|
|
|
engelsystem_log(sprintf('Added work log entry for %s, %s hours, %s', User_Nick_render($user_source), $userWorkLog['work_hours'], $userWorkLog['comment']));
|
|
|
|
User_Nick_render($user_source),
|
|
|
|
|
|
|
|
$userWorkLog['work_hours'],
|
|
|
|
|
|
|
|
$userWorkLog['comment']));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -101,8 +107,14 @@ function UserWorkLog_create($userWorkLog)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function UserWorkLog_new($user)
|
|
|
|
function UserWorkLog_new($user)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
$work_date = parse_date('Y-m-d H:i', date('Y-m-d 00:00', time()));
|
|
|
|
|
|
|
|
$event_config = EventConfig();
|
|
|
|
|
|
|
|
if (! empty($event_config['buildup_start_date'])) {
|
|
|
|
|
|
|
|
$work_date = parse_date('Y-m-d H:i', date('Y-m-d 00:00', $event_config['buildup_start_date']));
|
|
|
|
|
|
|
|
}
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
'user_id' => $user['UID'],
|
|
|
|
'user_id' => $user['UID'],
|
|
|
|
|
|
|
|
'work_timestamp' => $work_date,
|
|
|
|
'work_hours' => 0,
|
|
|
|
'work_hours' => 0,
|
|
|
|
'comment' => ''
|
|
|
|
'comment' => ''
|
|
|
|
];
|
|
|
|
];
|
|
|
|