engelsystem/includes/view/UserWorkLog_view.php

104 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;
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
2018-01-14 18:09:34 +01:00
* @param array $userWorkLog
* @return string
2017-12-29 17:19:27 +01:00
*/
function UserWorkLog_edit_form($user_source, $userWorkLog)
{
return form([
form_info(__('User'), User_Nick_render($user_source)),
form_date('work_timestamp', __('Work date'), $userWorkLog['work_timestamp'], null, time()),
form_text('work_hours', __('Work hours'), $userWorkLog['work_hours']),
form_text('comment', __('Comment'), $userWorkLog['comment']),
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
2018-01-14 18:09:34 +01:00
* @param array $userWorkLog
* @return string
2017-12-29 17:19:27 +01:00
*/
function UserWorkLog_edit_view($user_source, $userWorkLog)
{
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
2018-01-14 18:09:34 +01:00
* @param array $userWorkLog
* @return string
2017-12-29 17:19:27 +01:00
*/
function UserWorkLog_add_view($user_source, $userWorkLog)
{
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
}