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,14 +74,17 @@ 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.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$userWorkLog['work_hours'] = $request->input('work_hours');
|
$userWorkLog['work_hours'] = $request->input('work_hours');
|
||||||
if (! preg_match("/[0-9]+(\.[0-9]+)?/", $userWorkLog['work_hours'])) {
|
if (!preg_match("/[0-9]+(\.[0-9]+)?/", $userWorkLog['work_hours'])) {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
error(_('Please enter work hours in format ##[.##].'));
|
error(_('Please enter work hours in format ##[.##].'));
|
||||||
}
|
}
|
||||||
|
@ -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,12 +138,14 @@ 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)
|
||||||
{
|
{
|
||||||
return page_link_to('user_worklog', [
|
return page_link_to('user_worklog', [
|
||||||
'action' => 'add',
|
'action' => 'add',
|
||||||
'user_id' => $user['UID']
|
'user_id' => $user['UID']
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -141,12 +153,13 @@ 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)
|
||||||
{
|
{
|
||||||
return page_link_to('user_worklog', [
|
return page_link_to('user_worklog', [
|
||||||
'action' => 'edit',
|
'action' => 'edit',
|
||||||
'user_worklog_id' => $userWorkLog['id']
|
'user_worklog_id' => $userWorkLog['id']
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -154,31 +167,34 @@ 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 = [])
|
||||||
{
|
{
|
||||||
return page_link_to('user_worklog', array_merge([
|
return page_link_to('user_worklog', array_merge([
|
||||||
'action' => 'delete',
|
'action' => 'delete',
|
||||||
'user_worklog_id' => $userWorkLog['id']
|
'user_worklog_id' => $userWorkLog['id']
|
||||||
], $parameters));
|
], $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;
|
||||||
|
|
||||||
if (! in_array('admin_user_worklog', $privileges)) {
|
if (!in_array('admin_user_worklog', $privileges)) {
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
$request = request();
|
$request = request();
|
||||||
$action = $request->input('action');
|
$action = $request->input('action');
|
||||||
if (! $request->has('action')) {
|
if (!$request->has('action')) {
|
||||||
redirect(user_link($user));
|
redirect(user_link($user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -15,8 +17,9 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -27,8 +30,9 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -36,21 +40,27 @@ function UserWorkLog_delete($userWorkLog)
|
||||||
$result = Db::delete("DELETE FROM `UserWorkLog` WHERE `id`=?", [
|
$result = Db::delete("DELETE FROM `UserWorkLog` WHERE `id`=?", [
|
||||||
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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)
|
||||||
{
|
{
|
||||||
$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_timestamp`=?,
|
||||||
`work_hours`=?,
|
`work_hours`=?,
|
||||||
|
@ -61,23 +71,29 @@ function UserWorkLog_update($userWorkLog)
|
||||||
$userWorkLog['comment'],
|
$userWorkLog['comment'],
|
||||||
$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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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)
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$user_source = User($userWorkLog['user_id']);
|
$user_source = User($userWorkLog['user_id']);
|
||||||
|
|
||||||
$result = Db::insert("INSERT INTO `UserWorkLog` (
|
$result = Db::insert("INSERT INTO `UserWorkLog` (
|
||||||
`user_id`,
|
`user_id`,
|
||||||
`work_timestamp`,
|
`work_timestamp`,
|
||||||
|
@ -94,30 +110,30 @@ function UserWorkLog_create($userWorkLog)
|
||||||
$user['UID'],
|
$user['UID'],
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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)
|
||||||
{
|
{
|
||||||
$work_date = parse_date('Y-m-d H:i', date('Y-m-d 00:00', time()));
|
$work_date = parse_date('Y-m-d H:i', date('Y-m-d 00:00', time()));
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
if (! empty($event_config['buildup_start_date'])) {
|
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']));
|
$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_timestamp' => $work_date,
|
||||||
'work_hours' => 0,
|
'work_hours' => 0,
|
||||||
'comment' => ''
|
'comment' => ''
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
|
@ -20,12 +20,14 @@ function User_delete($user_id)
|
||||||
/**
|
/**
|
||||||
* Returns the tshirt score (number of hours counted for tshirt).
|
* Returns the tshirt score (number of hours counted for tshirt).
|
||||||
* 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('
|
||||||
SELECT ROUND((' . $shift_sum_formula . ') / 3600, 2) AS `tshirt_score`
|
SELECT ROUND((' . $shift_sum_formula . ') / 3600, 2) AS `tshirt_score`
|
||||||
FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
|
FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID`
|
||||||
|
@ -33,7 +35,7 @@ function User_tshirt_score($user) {
|
||||||
WHERE `User`.`UID` = ?
|
WHERE `User`.`UID` = ?
|
||||||
AND `Shifts`.`end` < ?
|
AND `Shifts`.`end` < ?
|
||||||
GROUP BY `User`.`UID`
|
GROUP BY `User`.`UID`
|
||||||
',[
|
', [
|
||||||
$user['UID'],
|
$user['UID'],
|
||||||
time()
|
time()
|
||||||
]);
|
]);
|
||||||
|
@ -43,11 +45,11 @@ function User_tshirt_score($user) {
|
||||||
LEFT JOIN `UserWorkLog` ON `User`.`UID` = `UserWorkLog`.`user_id`
|
LEFT JOIN `UserWorkLog` ON `User`.`UID` = `UserWorkLog`.`user_id`
|
||||||
WHERE `User`.`UID` = ?
|
WHERE `User`.`UID` = ?
|
||||||
AND `UserWorkLog`.`work_timestamp` < ?
|
AND `UserWorkLog`.`work_timestamp` < ?
|
||||||
',[
|
', [
|
||||||
$user['UID'],
|
$user['UID'],
|
||||||
time()
|
time()
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $result_shifts['tshirt_score'] + $result_worklog['tshirt_score'];
|
return $result_shifts['tshirt_score'] + $result_worklog['tshirt_score'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +387,7 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de
|
||||||
return new ValidationResult(false, $planned_arrival_date);
|
return new ValidationResult(false, $planned_arrival_date);
|
||||||
}
|
}
|
||||||
$event_config = EventConfig();
|
$event_config = EventConfig();
|
||||||
if (empty($event_config )) {
|
if (empty($event_config)) {
|
||||||
// Nothing to validate against
|
// Nothing to validate against
|
||||||
return new ValidationResult(true, $planned_departure_date);
|
return new ValidationResult(true, $planned_departure_date);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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, [
|
||||||
|
@ -28,9 +33,10 @@ 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) {
|
||||||
|
@ -420,8 +431,8 @@ function User_view_myshifts($shifts, $user_source, $its_me, $tshirt_score, $tshi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($its_me || $admin_user_worklog_privilege) {
|
if ($its_me || $admin_user_worklog_privilege) {
|
||||||
foreach($user_worklogs as $worklog) {
|
foreach ($user_worklogs as $worklog) {
|
||||||
$myshifts_table[$worklog['work_timestamp']] = User_view_worklog($worklog, $admin_user_worklog_privilege);
|
$myshifts_table[$worklog['work_timestamp']] = User_view_worklog($worklog, $admin_user_worklog_privilege);
|
||||||
$timesum += $worklog['work_hours'] * 3600;
|
$timesum += $worklog['work_hours'] * 3600;
|
||||||
}
|
}
|
||||||
|
@ -453,12 +464,15 @@ 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 bool $admin_user_worklog_privilege
|
* @param array $worklog
|
||||||
|
* @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([
|
||||||
button(
|
button(
|
||||||
user_worklog_edit_link($worklog),
|
user_worklog_edit_link($worklog),
|
||||||
|
@ -479,11 +493,11 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege) {
|
||||||
'room' => '',
|
'room' => '',
|
||||||
'shift_info' => _('Work log entry'),
|
'shift_info' => _('Work log entry'),
|
||||||
'comment' => $worklog['comment'] . '<br>'
|
'comment' => $worklog['comment'] . '<br>'
|
||||||
. sprintf(
|
. sprintf(
|
||||||
_('Added by %s at %s'),
|
_('Added by %s at %s'),
|
||||||
User_Nick_render(User($worklog['created_user_id'])),
|
User_Nick_render(User($worklog['created_user_id'])),
|
||||||
date('Y-m-d H:i', $worklog['created_timestamp'])
|
date('Y-m-d H:i', $worklog['created_timestamp'])
|
||||||
),
|
),
|
||||||
'actions' => $actions
|
'actions' => $actions
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -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(
|
||||||
|
@ -517,9 +533,17 @@ 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(
|
||||||
if(count($my_shifts) > 0) {
|
$shifts,
|
||||||
|
$user_source,
|
||||||
|
$its_me,
|
||||||
|
$tshirt_score,
|
||||||
|
$tshirt_admin,
|
||||||
|
$user_worklogs,
|
||||||
|
$admin_user_worklog_privilege
|
||||||
|
);
|
||||||
|
if (count($my_shifts) > 0) {
|
||||||
$myshifts_table = table([
|
$myshifts_table = table([
|
||||||
'date' => _('Day & time'),
|
'date' => _('Day & time'),
|
||||||
'duration' => _('Duration'),
|
'duration' => _('Duration'),
|
||||||
|
@ -528,7 +552,7 @@ function User_view(
|
||||||
'comment' => _('Comment'),
|
'comment' => _('Comment'),
|
||||||
'actions' => _('Action')
|
'actions' => _('Action')
|
||||||
], $my_shifts);
|
], $my_shifts);
|
||||||
} elseif($user_source['force_active']) {
|
} elseif ($user_source['force_active']) {
|
||||||
$myshifts_table = success(_('You have done enough to get a t-shirt.'), true);
|
$myshifts_table = success(_('You have done enough to get a t-shirt.'), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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