engelsystem/includes/view/UserWorkLog_view.php

105 lines
2.4 KiB
PHP
Raw Normal View History

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
*
* @param User $user_source
2018-01-14 18:09:34 +01:00
* @return string
2017-12-29 17:19:27 +01:00
*/
function UserWorkLog_delete_view($user_source)
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(
__('Do you want to delete the worklog entry for %s?'),
2018-01-14 18:09:34 +01:00
User_Nick_render($user_source)
), true),
form([
buttons([
button(user_link($user_source->id), glyph('remove') . __('cancel')),
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()
{
return __('Delete work log entry');
2017-12-29 17:19:27 +01:00
}
/**
* Render edit table.
2018-01-14 18:09:34 +01:00
*
2018-10-17 01:30:10 +02:00
* @param User $user_source
2020-09-12 19:45:25 +02:00
* @param Worklog $userWorkLog
2018-01-14 18:09:34 +01:00
* @return string
2017-12-29 17:19:27 +01:00
*/
2020-09-12 19:45:25 +02:00
function UserWorkLog_edit_form($user_source, Worklog $userWorkLog)
2017-12-29 17:19:27 +01:00
{
return form([
form_info(__('User'), User_Nick_render($user_source)),
2020-09-12 19:45:25 +02:00
form_date('work_timestamp', __('Work date'), $userWorkLog->worked_at->timestamp, null, time()),
form_text('work_hours', __('Work hours'), $userWorkLog->hours),
form_text('comment', __('Comment'), $userWorkLog->comment, false, 200),
form_submit('submit', __('Save'))
2017-12-29 17:19:27 +01:00
]);
}
/**
* Form for edit a user work log entry.
*
2018-10-17 01:30:10 +02:00
* @param User $user_source
2020-09-12 19:45:25 +02:00
* @param Worklog $userWorkLog
2018-01-14 18:09:34 +01:00
* @return string
2017-12-29 17:19:27 +01:00
*/
2020-09-12 19:45:25 +02:00
function UserWorkLog_edit_view($user_source, Worklog $userWorkLog)
2017-12-29 17:19:27 +01:00
{
return page_with_title(UserWorkLog_edit_title(), [
buttons([
2018-10-10 03:10:28 +02:00
button(user_link($user_source->id), __('back'))
2017-12-29 17:19:27 +01:00
]),
msg(),
UserWorkLog_edit_form($user_source, $userWorkLog)
]);
}
/**
* Form for adding a user work log entry.
*
2018-10-17 01:30:10 +02:00
* @param User $user_source
2020-09-12 19:45:25 +02:00
* @param Worklog $userWorkLog
2018-01-14 18:09:34 +01:00
* @return string
2017-12-29 17:19:27 +01:00
*/
2020-09-12 19:45:25 +02:00
function UserWorkLog_add_view($user_source, Worklog $userWorkLog)
2017-12-29 17:19:27 +01:00
{
return page_with_title(UserWorkLog_add_title(), [
buttons([
2018-10-10 03:10:28 +02:00
button(user_link($user_source->id), __('back'))
2017-12-29 17:19:27 +01:00
]),
msg(),
UserWorkLog_edit_form($user_source, $userWorkLog)
]);
}
/**
* Title text for editing work log entry.
*/
function UserWorkLog_edit_title()
{
return __('Edit work log entry');
2017-12-29 17:19:27 +01:00
}
/**
* Title text for adding work log entry.
*/
function UserWorkLog_add_title()
{
return __('Add work log entry');
2017-12-29 17:19:27 +01:00
}