2017-12-29 17:19:27 +01:00
|
|
|
<?php
|
|
|
|
|
2018-10-09 21:47:31 +02:00
|
|
|
use Engelsystem\Models\User\User;
|
2020-09-12 19:45:25 +02:00
|
|
|
use Engelsystem\Models\Worklog;
|
2018-10-09 21:47:31 +02:00
|
|
|
|
2017-12-29 17:19:27 +01:00
|
|
|
/**
|
|
|
|
* Delete work log entry.
|
2018-01-14 18:09:34 +01:00
|
|
|
*
|
2020-09-13 14:31:21 +02:00
|
|
|
* @param User $user
|
2018-01-14 18:09:34 +01:00
|
|
|
* @return string
|
2017-12-29 17:19:27 +01:00
|
|
|
*/
|
2020-09-13 14:31:21 +02:00
|
|
|
function UserWorkLog_delete_view(User $user)
|
2017-12-29 17:19:27 +01:00
|
|
|
{
|
|
|
|
return page_with_title(UserWorkLog_delete_title(), [
|
2018-01-14 18:09:34 +01:00
|
|
|
info(sprintf(
|
2018-08-29 21:55:32 +02:00
|
|
|
__('Do you want to delete the worklog entry for %s?'),
|
2020-09-13 14:31:21 +02:00
|
|
|
User_Nick_render($user)
|
2018-01-14 18:09:34 +01:00
|
|
|
), true),
|
2018-11-20 16:02:03 +01:00
|
|
|
form([
|
|
|
|
buttons([
|
2020-09-13 14:31:21 +02:00
|
|
|
button(user_link($user->id), glyph('remove') . __('cancel')),
|
2018-11-20 16:02:03 +01:00
|
|
|
form_submit('submit', glyph('ok') . __('delete'), 'btn-danger', false),
|
|
|
|
]),
|
|
|
|
]),
|
2017-12-29 17:19:27 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Title for work log delete.
|
|
|
|
*/
|
|
|
|
function UserWorkLog_delete_title()
|
|
|
|
{
|
2018-08-29 21:55:32 +02:00
|
|
|
return __('Delete work log entry');
|
2017-12-29 17:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render edit table.
|
2018-01-14 18:09:34 +01:00
|
|
|
*
|
2020-09-13 14:31:21 +02:00
|
|
|
* @param User $user
|
|
|
|
* @param Worklog $worklog
|
2018-01-14 18:09:34 +01:00
|
|
|
* @return string
|
2017-12-29 17:19:27 +01:00
|
|
|
*/
|
2020-09-13 14:31:21 +02:00
|
|
|
function UserWorkLog_edit_form(User $user, Worklog $worklog)
|
2017-12-29 17:19:27 +01:00
|
|
|
{
|
|
|
|
return form([
|
2020-09-13 14:31:21 +02:00
|
|
|
form_info(__('User'), User_Nick_render($user)),
|
|
|
|
form_date('work_timestamp', __('Work date'), $worklog->worked_at->timestamp, null, time()),
|
|
|
|
form_text('work_hours', __('Work hours'), $worklog->hours),
|
|
|
|
form_text('comment', __('Comment'), $worklog->comment, false, 200),
|
2018-08-29 21:55:32 +02:00
|
|
|
form_submit('submit', __('Save'))
|
2017-12-29 17:19:27 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Form for edit a user work log entry.
|
|
|
|
*
|
2020-09-13 14:31:21 +02:00
|
|
|
* @param User $user
|
|
|
|
* @param Worklog $worklog
|
2018-01-14 18:09:34 +01:00
|
|
|
* @return string
|
2017-12-29 17:19:27 +01:00
|
|
|
*/
|
2020-09-13 14:31:21 +02:00
|
|
|
function UserWorkLog_edit_view(User $user, Worklog $worklog)
|
2017-12-29 17:19:27 +01:00
|
|
|
{
|
|
|
|
return page_with_title(UserWorkLog_edit_title(), [
|
|
|
|
buttons([
|
2020-09-13 14:31:21 +02:00
|
|
|
button(user_link($user->id), __('back'))
|
2017-12-29 17:19:27 +01:00
|
|
|
]),
|
|
|
|
msg(),
|
2020-09-13 14:31:21 +02:00
|
|
|
UserWorkLog_edit_form($user, $worklog)
|
2017-12-29 17:19:27 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Form for adding a user work log entry.
|
|
|
|
*
|
2020-09-13 14:31:21 +02:00
|
|
|
* @param User $user
|
|
|
|
* @param Worklog $worklog
|
2018-01-14 18:09:34 +01:00
|
|
|
* @return string
|
2017-12-29 17:19:27 +01:00
|
|
|
*/
|
2020-09-13 14:31:21 +02:00
|
|
|
function UserWorkLog_add_view(User $user, Worklog $worklog)
|
2017-12-29 17:19:27 +01:00
|
|
|
{
|
|
|
|
return page_with_title(UserWorkLog_add_title(), [
|
|
|
|
buttons([
|
2020-09-13 14:31:21 +02:00
|
|
|
button(user_link($user->id), __('back'))
|
2017-12-29 17:19:27 +01:00
|
|
|
]),
|
|
|
|
msg(),
|
2020-09-13 14:31:21 +02:00
|
|
|
UserWorkLog_edit_form($user, $worklog)
|
2017-12-29 17:19:27 +01:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Title text for editing work log entry.
|
|
|
|
*/
|
|
|
|
function UserWorkLog_edit_title()
|
|
|
|
{
|
2018-08-29 21:55:32 +02:00
|
|
|
return __('Edit work log entry');
|
2017-12-29 17:19:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Title text for adding work log entry.
|
|
|
|
*/
|
|
|
|
function UserWorkLog_add_title()
|
|
|
|
{
|
2018-08-29 21:55:32 +02:00
|
|
|
return __('Add work log entry');
|
2017-12-29 17:19:27 +01:00
|
|
|
}
|