summaryrefslogtreecommitdiff
path: root/includes/view/UserWorkLog_view.php
blob: 0d5e779774c92fb5259386a39cb58c09b6e436bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php

use Engelsystem\Models\User\User;

/**
 * Delete work log entry.
 *
 * @param User $user_source
 * @return string
 */
function UserWorkLog_delete_view($user_source)
{
    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),
        form([
            buttons([
                button(user_link($user_source->id), glyph('remove') . __('cancel')),
                form_submit('submit', glyph('ok') . __('delete'), 'btn-danger', false),
            ]),
        ]),
    ]);
}

/**
 * Title for work log delete.
 */
function UserWorkLog_delete_title()
{
    return __('Delete work log entry');
}

/**
 * Render edit table.
 *
 * @param User  $user_source
 * @param array $userWorkLog
 * @return string
 */
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'))
    ]);
}

/**
 * Form for edit a user work log entry.
 *
 * @param User  $user_source
 * @param array $userWorkLog
 * @return string
 */
function UserWorkLog_edit_view($user_source, $userWorkLog)
{
    return page_with_title(UserWorkLog_edit_title(), [
        buttons([
            button(user_link($user_source->id), __('back'))
        ]),
        msg(),
        UserWorkLog_edit_form($user_source, $userWorkLog)
    ]);
}

/**
 * Form for adding a user work log entry.
 *
 * @param User  $user_source
 * @param array $userWorkLog
 * @return string
 */
function UserWorkLog_add_view($user_source, $userWorkLog)
{
    return page_with_title(UserWorkLog_add_title(), [
        buttons([
            button(user_link($user_source->id), __('back'))
        ]),
        msg(),
        UserWorkLog_edit_form($user_source, $userWorkLog)
    ]);
}

/**
 * Title text for editing work log entry.
 */
function UserWorkLog_edit_title()
{
    return __('Edit work log entry');
}

/**
 * Title text for adding work log entry.
 */
function UserWorkLog_add_title()
{
    return __('Add work log entry');
}