engelsystem/includes/view/UserWorkLog_view.php

105 lines
2.3 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
2018-01-14 18:09:34 +01:00
* @return string
2017-12-29 17:19:27 +01: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(
__('Do you want to delete the worklog entry for %s?'),
User_Nick_render($user)
2018-01-14 18:09:34 +01:00
), true),
form([
buttons([
button(user_link($user->id), icon('x-lg') . __('cancel')),
form_submit('submit', icon('check-lg') . __('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
*
* @param User $user
* @param Worklog $worklog
2018-01-14 18:09:34 +01:00
* @return string
2017-12-29 17:19:27 +01:00
*/
function UserWorkLog_edit_form(User $user, Worklog $worklog)
2017-12-29 17:19:27 +01:00
{
return form([
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),
form_submit('submit', __('Save'))
2017-12-29 17:19:27 +01:00
]);
}
/**
* Form for edit a user work log entry.
*
* @param User $user
* @param Worklog $worklog
2018-01-14 18:09:34 +01:00
* @return string
2017-12-29 17:19:27 +01: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([
button(user_link($user->id), __('back'))
2017-12-29 17:19:27 +01:00
]),
msg(),
UserWorkLog_edit_form($user, $worklog)
2017-12-29 17:19:27 +01:00
]);
}
/**
* Form for adding a user work log entry.
*
* @param User $user
* @param Worklog $worklog
2018-01-14 18:09:34 +01:00
* @return string
2017-12-29 17:19:27 +01: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([
button(user_link($user->id), __('back'))
2017-12-29 17:19:27 +01:00
]),
msg(),
UserWorkLog_edit_form($user, $worklog)
2017-12-29 17:19:27 +01:00
]);
}
/**
* 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
}