Formatting
This commit is contained in:
parent
fe58e4f422
commit
5227fe6a94
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a work log entry.
|
* Delete a work log entry.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function user_worklog_delete_controller()
|
function user_worklog_delete_controller()
|
||||||
{
|
{
|
||||||
|
@ -29,6 +31,8 @@ function user_worklog_delete_controller()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit work log for user.
|
* Edit work log for user.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function user_worklog_edit_controller()
|
function user_worklog_edit_controller()
|
||||||
{
|
{
|
||||||
|
@ -59,9 +63,10 @@ function user_worklog_edit_controller()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Handle form
|
||||||
*
|
*
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param array $userWorkLog
|
||||||
* @return [bool $valid, UserWorkLog $userWorkLog]
|
* @return array [bool $valid, UserWorkLog $userWorkLog]
|
||||||
*/
|
*/
|
||||||
function user_worklog_from_request($userWorkLog)
|
function user_worklog_from_request($userWorkLog)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +74,10 @@ function user_worklog_from_request($userWorkLog)
|
||||||
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
|
|
||||||
$userWorkLog['work_timestamp'] = parse_date('Y-m-d H:i', $request->input('work_timestamp') . ' 00:00');
|
$userWorkLog['work_timestamp'] = parse_date(
|
||||||
|
'Y-m-d H:i',
|
||||||
|
$request->input('work_timestamp') . ' 00:00'
|
||||||
|
);
|
||||||
if (is_null($userWorkLog['work_timestamp'])) {
|
if (is_null($userWorkLog['work_timestamp'])) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please enter work date.'));
|
error(_('Please enter work date.'));
|
||||||
|
@ -95,6 +103,8 @@ function user_worklog_from_request($userWorkLog)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add work log entry to user.
|
* Add work log entry to user.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function user_worklog_add_controller()
|
function user_worklog_add_controller()
|
||||||
{
|
{
|
||||||
|
@ -128,7 +138,9 @@ function user_worklog_add_controller()
|
||||||
/**
|
/**
|
||||||
* Link to work log entry add for given user.
|
* Link to work log entry add for given user.
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param array $user
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function user_worklog_add_link($user)
|
function user_worklog_add_link($user)
|
||||||
{
|
{
|
||||||
|
@ -141,7 +153,8 @@ function user_worklog_add_link($user)
|
||||||
/**
|
/**
|
||||||
* Link to work log entry edit.
|
* Link to work log entry edit.
|
||||||
*
|
*
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param array $userWorkLog
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function user_worklog_edit_link($userWorkLog)
|
function user_worklog_edit_link($userWorkLog)
|
||||||
{
|
{
|
||||||
|
@ -154,8 +167,9 @@ function user_worklog_edit_link($userWorkLog)
|
||||||
/**
|
/**
|
||||||
* Link to work log entry delete.
|
* Link to work log entry delete.
|
||||||
*
|
*
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param array $userWorkLog
|
||||||
* @param array[] $parameters
|
* @param array[] $parameters
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function user_worklog_delete_link($userWorkLog, $parameters = [])
|
function user_worklog_delete_link($userWorkLog, $parameters = [])
|
||||||
{
|
{
|
||||||
|
@ -167,8 +181,10 @@ function user_worklog_delete_link($userWorkLog, $parameters = [])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Work log entry actions
|
* Work log entry actions
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function user_worklogs_controller()
|
function user_worklog_controller()
|
||||||
{
|
{
|
||||||
global $user, $privileges;
|
global $user, $privileges;
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Engelsystem\Database\Db;
|
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
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function UserWorkLog($user_worklog_id)
|
function UserWorkLog($user_worklog_id)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +18,8 @@ function UserWorkLog($user_worklog_id)
|
||||||
/**
|
/**
|
||||||
* Returns all work log entries for a user.
|
* Returns all work log entries for a user.
|
||||||
*
|
*
|
||||||
* @param User $user
|
* @param array $user
|
||||||
|
* @return array[]
|
||||||
*/
|
*/
|
||||||
function UserWorkLogsForUser($user)
|
function UserWorkLogsForUser($user)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +31,8 @@ function UserWorkLogsForUser($user)
|
||||||
/**
|
/**
|
||||||
* Delete a work log entry.
|
* Delete a work log entry.
|
||||||
*
|
*
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param $userWorkLog
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
function UserWorkLog_delete($userWorkLog)
|
function UserWorkLog_delete($userWorkLog)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +41,12 @@ function UserWorkLog_delete($userWorkLog)
|
||||||
$userWorkLog['id']
|
$userWorkLog['id']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
engelsystem_log(sprintf('Delete work log for %s, %s hours, %s', User_Nick_render($user_source), $userWorkLog['work_hours'], $userWorkLog['comment']));
|
engelsystem_log(sprintf(
|
||||||
|
'Delete work log for %s, %s hours, %s',
|
||||||
|
User_Nick_render($user_source),
|
||||||
|
$userWorkLog['work_hours'],
|
||||||
|
$userWorkLog['comment']
|
||||||
|
));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +54,8 @@ function UserWorkLog_delete($userWorkLog)
|
||||||
/**
|
/**
|
||||||
* Update work log entry (only work hours and comment)
|
* Update work log entry (only work hours and comment)
|
||||||
*
|
*
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param $userWorkLog
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
function UserWorkLog_update($userWorkLog)
|
function UserWorkLog_update($userWorkLog)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +72,12 @@ function UserWorkLog_update($userWorkLog)
|
||||||
$userWorkLog['id']
|
$userWorkLog['id']
|
||||||
]);
|
]);
|
||||||
|
|
||||||
engelsystem_log(sprintf('Updated work log for %s, %s hours, %s', User_Nick_render($user_source), $userWorkLog['work_hours'], $userWorkLog['comment']));
|
engelsystem_log(sprintf(
|
||||||
|
'Updated work log for %s, %s hours, %s',
|
||||||
|
User_Nick_render($user_source),
|
||||||
|
$userWorkLog['work_hours'],
|
||||||
|
$userWorkLog['comment'])
|
||||||
|
);
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +85,8 @@ function UserWorkLog_update($userWorkLog)
|
||||||
/**
|
/**
|
||||||
* Create a new work log entry
|
* Create a new work log entry
|
||||||
*
|
*
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param $userWorkLog
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function UserWorkLog_create($userWorkLog)
|
function UserWorkLog_create($userWorkLog)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +111,8 @@ function UserWorkLog_create($userWorkLog)
|
||||||
time()
|
time()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
engelsystem_log(sprintf('Added work log entry for %s, %s hours, %s', User_Nick_render($user_source), $userWorkLog['work_hours'], $userWorkLog['comment']));
|
engelsystem_log(sprintf('Added work log entry for %s, %s hours, %s', User_Nick_render($user_source),
|
||||||
|
$userWorkLog['work_hours'], $userWorkLog['comment']));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -104,6 +121,7 @@ function UserWorkLog_create($userWorkLog)
|
||||||
* New user work log entry
|
* New user work log entry
|
||||||
*
|
*
|
||||||
* @param array[] $user
|
* @param array[] $user
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function UserWorkLog_new($user)
|
function UserWorkLog_new($user)
|
||||||
{
|
{
|
||||||
|
@ -119,5 +137,3 @@ function UserWorkLog_new($user)
|
||||||
'comment' => ''
|
'comment' => ''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -22,8 +22,10 @@ function User_delete($user_id)
|
||||||
* Accounts only ended shifts.
|
* Accounts only ended shifts.
|
||||||
*
|
*
|
||||||
* @param array[] $user
|
* @param array[] $user
|
||||||
|
* @return int
|
||||||
*/
|
*/
|
||||||
function User_tshirt_score($user) {
|
function User_tshirt_score($user)
|
||||||
|
{
|
||||||
$shift_sum_formula = config('shift_sum_formula');
|
$shift_sum_formula = config('shift_sum_formula');
|
||||||
|
|
||||||
$result_shifts = DB::selectOne('
|
$result_shifts = DB::selectOne('
|
||||||
|
|
|
@ -2,13 +2,18 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete work log entry.
|
* Delete work log entry.
|
||||||
* @param User $user_source
|
*
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param array $user_source
|
||||||
|
* @param array $userWorkLog
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function UserWorkLog_delete_view($user_source, $userWorkLog)
|
function UserWorkLog_delete_view($user_source, $userWorkLog)
|
||||||
{
|
{
|
||||||
return page_with_title(UserWorkLog_delete_title(), [
|
return page_with_title(UserWorkLog_delete_title(), [
|
||||||
info(sprintf(_('Do you want to delete the worklog entry for %s?'), User_Nick_render($user_source)), true),
|
info(sprintf(
|
||||||
|
_('Do you want to delete the worklog entry for %s?'),
|
||||||
|
User_Nick_render($user_source)
|
||||||
|
), true),
|
||||||
buttons([
|
buttons([
|
||||||
button(user_link($user_source), glyph('remove') . _('cancel')),
|
button(user_link($user_source), glyph('remove') . _('cancel')),
|
||||||
button(user_worklog_delete_link($userWorkLog, [
|
button(user_worklog_delete_link($userWorkLog, [
|
||||||
|
@ -29,8 +34,9 @@ function UserWorkLog_delete_title()
|
||||||
/**
|
/**
|
||||||
* Render edit table.
|
* Render edit table.
|
||||||
*
|
*
|
||||||
* @param User $user_source
|
* @param array $user_source
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param array $userWorkLog
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function UserWorkLog_edit_form($user_source, $userWorkLog)
|
function UserWorkLog_edit_form($user_source, $userWorkLog)
|
||||||
{
|
{
|
||||||
|
@ -46,8 +52,9 @@ function UserWorkLog_edit_form($user_source, $userWorkLog)
|
||||||
/**
|
/**
|
||||||
* Form for edit a user work log entry.
|
* Form for edit a user work log entry.
|
||||||
*
|
*
|
||||||
* @param User $user_source
|
* @param array $user_source
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param array $userWorkLog
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function UserWorkLog_edit_view($user_source, $userWorkLog)
|
function UserWorkLog_edit_view($user_source, $userWorkLog)
|
||||||
{
|
{
|
||||||
|
@ -63,8 +70,9 @@ function UserWorkLog_edit_view($user_source, $userWorkLog)
|
||||||
/**
|
/**
|
||||||
* Form for adding a user work log entry.
|
* Form for adding a user work log entry.
|
||||||
*
|
*
|
||||||
* @param User $user_source
|
* @param array $user_source
|
||||||
* @param UserWorkLog $userWorkLog
|
* @param array $userWorkLog
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
function UserWorkLog_add_view($user_source, $userWorkLog)
|
function UserWorkLog_add_view($user_source, $userWorkLog)
|
||||||
{
|
{
|
||||||
|
@ -92,5 +100,3 @@ function UserWorkLog_add_title()
|
||||||
{
|
{
|
||||||
return _('Add work log entry');
|
return _('Add work log entry');
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -406,10 +406,21 @@ function User_view_myshift($shift, $user_source, $its_me)
|
||||||
* @param array[] $shifts
|
* @param array[] $shifts
|
||||||
* @param array $user_source
|
* @param array $user_source
|
||||||
* @param bool $its_me
|
* @param bool $its_me
|
||||||
|
* @param int $tshirt_score
|
||||||
|
* @param bool $tshirt_admin
|
||||||
|
* @param array[] $user_worklogs
|
||||||
|
* @param $admin_user_worklog_privilege
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin, $user_worklogs, $admin_user_worklog_privilege)
|
function User_view_myshifts(
|
||||||
{
|
$shifts,
|
||||||
|
$user_source,
|
||||||
|
$its_me,
|
||||||
|
$tshirt_score,
|
||||||
|
$tshirt_admin,
|
||||||
|
$user_worklogs,
|
||||||
|
$admin_user_worklog_privilege
|
||||||
|
) {
|
||||||
$myshifts_table = [];
|
$myshifts_table = [];
|
||||||
$timesum = 0;
|
$timesum = 0;
|
||||||
foreach ($shifts as $shift) {
|
foreach ($shifts as $shift) {
|
||||||
|
@ -453,10 +464,13 @@ function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshi
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders table entry for user work log
|
* Renders table entry for user work log
|
||||||
* @param UserWorkLog $worklog
|
*
|
||||||
|
* @param array $worklog
|
||||||
* @param bool $admin_user_worklog_privilege
|
* @param bool $admin_user_worklog_privilege
|
||||||
|
* @return array
|
||||||
*/
|
*/
|
||||||
function User_view_worklog($worklog, $admin_user_worklog_privilege) {
|
function User_view_worklog($worklog, $admin_user_worklog_privilege)
|
||||||
|
{
|
||||||
$actions = '';
|
$actions = '';
|
||||||
if ($admin_user_worklog_privilege) {
|
if ($admin_user_worklog_privilege) {
|
||||||
$actions = table_buttons([
|
$actions = table_buttons([
|
||||||
|
@ -500,6 +514,8 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege) {
|
||||||
* @param bool $its_me
|
* @param bool $its_me
|
||||||
* @param int $tshirt_score
|
* @param int $tshirt_score
|
||||||
* @param bool $tshirt_admin
|
* @param bool $tshirt_admin
|
||||||
|
* @param bool $admin_user_worklog_privilege
|
||||||
|
* @param array[] $user_worklogs
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function User_view(
|
function User_view(
|
||||||
|
@ -518,7 +534,15 @@ function User_view(
|
||||||
$user_name = htmlspecialchars($user_source['Vorname']) . ' ' . htmlspecialchars($user_source['Name']);
|
$user_name = htmlspecialchars($user_source['Vorname']) . ' ' . htmlspecialchars($user_source['Name']);
|
||||||
$myshifts_table = '';
|
$myshifts_table = '';
|
||||||
if ($its_me || $admin_user_privilege) {
|
if ($its_me || $admin_user_privilege) {
|
||||||
$my_shifts = User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshirt_admin, $user_worklogs, $admin_user_worklog_privilege);
|
$my_shifts = User_view_myshifts(
|
||||||
|
$shifts,
|
||||||
|
$user_source,
|
||||||
|
$its_me,
|
||||||
|
$tshirt_score,
|
||||||
|
$tshirt_admin,
|
||||||
|
$user_worklogs,
|
||||||
|
$admin_user_worklog_privilege
|
||||||
|
);
|
||||||
if (count($my_shifts) > 0) {
|
if (count($my_shifts) > 0) {
|
||||||
$myshifts_table = table([
|
$myshifts_table = table([
|
||||||
'date' => _('Day & time'),
|
'date' => _('Day & time'),
|
||||||
|
|
|
@ -132,7 +132,7 @@ if (
|
||||||
$content = user_shifts();
|
$content = user_shifts();
|
||||||
break;
|
break;
|
||||||
case 'user_worklog':
|
case 'user_worklog':
|
||||||
list($title, $content) = user_worklogs_controller();
|
list($title, $content) = user_worklog_controller();
|
||||||
break;
|
break;
|
||||||
case 'user_messages':
|
case 'user_messages':
|
||||||
$title = messages_title();
|
$title = messages_title();
|
||||||
|
|
Loading…
Reference in New Issue