1<?php
2/* @var \dokuwiki\plugin\bez\meta\Tpl $tpl */
3if ($tpl->action() == 'thread') {
4	$url = $tpl->url('thread', 'id', $tpl->get('thread')->id, 'action', $tpl->param('action', 'add'), 'tid', $tpl->param('tid'), 'kid', $tpl->param('kid'));
5    $id = 'bez:thread' . $tpl->get('thread')->id;
6} elseif ($tpl->action() == 'task_form') {
7    $url = $tpl->url('task_form', 'action', $tpl->param('action', 'add'), 'tid', $tpl->param('tid'));
8    $id = 'bez:tasks';
9} else {
10    $url = $tpl->url('task', 'action', $tpl->param('action', 'add'), 'tid', $tpl->param('tid'));
11    $id = 'bez:tasks';
12}
13?>
14<a name="z_"></a>
15<form 	class="bez_form bez_task_form"
16		action="<?php echo $url ?>" method="POST">
17		<input type="hidden" name="id" value="<?php echo $id ?>">
18
19		<fieldset class="bds_form">
20			<?php if ($tpl->param('tid') != ''): ?>
21				<div class="row">
22				<label for="id"><?php echo $tpl->getLang('id') ?>:</label>
23				<span><strong>#z<?php echo $tpl->get('task')->id ?></strong></span>
24				</div>
25
26				<?php if ($tpl->get('thread') != '' &&
27                    $tpl->get('task')->acl_of('thread_comment_id') >= BEZ_PERMISSION_CHANGE): ?>
28				<div class="row">
29					<label for="thread_comment_id"><?php echo ucfirst($tpl->getLang('cause')) ?>:</label>
30					<span>
31						<select name="thread_comment_id" id="thread_comment_id">
32							<option <?php if ($tpl->value('thread_comment_id') == '') echo 'selected' ?>
33								value="">--- <?php echo $tpl->getLang('correction') ?> ---</option>
34
35							<?php foreach ($tpl->get('thread')->get_causes() as $cause_id): ?>
36								<option <?php if ($tpl->value('thread_comment_id') == $cause_id) echo 'selected' ?>
37								 value="<?php echo $cause_id ?>">#k<?php echo $cause_id ?></option>
38							<?php endforeach ?>
39						</select>
40					</span>
41				</div>
42				<?php endif ?>
43			<?php endif ?>
44			<div class="row">
45			<label for="assignee"><?php echo $tpl->getLang('executor') ?>:</label>
46			<span>
47			<?php if ($tpl->get('task')->acl_of('assignee') >= BEZ_PERMISSION_CHANGE): ?>
48				<select name="assignee" id="assignee" data-validation="required">
49					<option value="">--- <?php echo $tpl->getLang('select') ?>---</option>
50				<?php foreach ($tpl->get('users') as $nick => $name): ?>
51					<option <?php if ($tpl->value('assignee') == $nick) echo 'selected' ?>
52					 value="<?php echo $nick ?>"><?php echo $name ?></option>
53				<?php endforeach ?>
54				</select>
55			<?php else: ?>
56				<strong>
57				<?php echo $tpl->user_name() ?>
58				</strong>
59			<?php endif ?>
60
61
62			</span>
63			</div>
64
65			<div class="row">
66				<label for="content"><?php echo $tpl->getLang('description') ?>:</label>
67				<span>
68                    <?php if ($tpl->get('task')->acl_of('content') >= BEZ_PERMISSION_CHANGE): ?>
69                        <div class="bez_toolbar"></div>
70                    <?php endif ?>
71					<textarea name="content" id="content" data-validation="required" <?php if ($tpl->get('task')->acl_of('content') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>><?php echo $tpl->value('content') ?></textarea>
72				</span>
73			</div>
74
75			<div class="row task_plan_field">
76				<label for="plan_date"><?php echo $tpl->getLang('plan_date') ?>:</label>
77				<span>
78                    <input name="plan_date" style="width:90px;" data-validation="required,date" value="<?php echo $tpl->value('plan_date') ?>"
79                    <?php if ($tpl->get('task')->acl_of('plan_date') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>
80                    />
81                    <div style="display:inline" id="task_datapair">
82                        <?php echo $tpl->getLang('from_hour') ?>
83                        <input name="start_time" style="width:60px;" class="time start" value="<?php echo $tpl->value('start_time') ?>"
84                        data-validation="required,custom"
85                        data-validation-regexp="^(\d{1,2}):(\d{1,2})$"
86                        data-validation-depends-on="all_day_event"
87                        <?php if ($tpl->get('task')->acl_of('plan_date') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>
88                        />
89                        <?php echo $tpl->getLang('to_hour') ?>
90                        <input name="finish_time" style="width:60px;" class="time end" value="<?php echo $tpl->value('finish_time') ?>"
91                        data-validation="required,custom"
92                        data-validation-regexp="^(\d{1,2}):(\d{1,2})$"
93                        data-validation-depends-on="all_day_event"
94                        <?php if ($tpl->get('task')->acl_of('plan_date') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>
95                        />
96                    </div>
97				</span>
98			</div>
99
100			<div class="row">
101				<label></label>
102				<span>
103					<label>
104                        <?php if ($tpl->get('task')->acl_of('all_day_event') >= BEZ_PERMISSION_CHANGE): ?>
105                        <input type="checkbox" name="all_day_event" value="1"
106                            <?php if ($tpl->value('all_day_event') == '' ||
107                                        $tpl->value('all_day_event') == '1'): ?>
108                                checked
109                            <?php endif ?> />
110                        <?php else: ?>
111                             <input type="checkbox" disabled
112                            <?php if ($tpl->get('task')->all_day_event == '1'): ?>
113                                checked
114                            <?php endif ?> />
115                        <?php endif ?> <?php echo $tpl->getLang('all_day_event') ?>
116                    </label>
117
118                </span>
119			</div>
120
121			<div class="row">
122			<label for="tasktype"><?php echo $tpl->getLang('task_type') ?>:</label>
123			<span>
124                <select id="task_program_id" name="task_program_id"
125                    <?php if ($tpl->get('task')->acl_of('task_program_id') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>
126                    <?php if (!$tpl->get('task')->can_be_null('task_program_id')) echo 'data-validation="required"' ?>>
127                    <?php if ($tpl->get('task')->can_be_null('task_program_id')): ?>
128                        <option <?php if ($tpl->value('task_program_id') == '') echo 'selected' ?> value="">
129                            <?php echo $tpl->getLang('tasks_no_type') ?>
130                        </option>
131                    <?php else: ?>
132                        <option value="">--- <?php echo $tpl->getLang('select') ?>---</option>
133                    <?php endif ?>
134
135                    <?php foreach ($tpl->get('task_programs') as $task_program): ?>
136                        <option <?php if ($tpl->value('task_program_id') == $task_program->id) echo 'selected' ?> value="<?php echo $task_program->id ?>"><?php echo $task_program->name ?></option>
137                    <?php endforeach ?>
138                </select>
139			</span>
140			</div>
141
142			<div class="row">
143				<label for="cost"><?php echo $tpl->getLang('cost') ?>:</label>
144				<span><input 	type="number" name="cost" id="cost"
145								min="0" step="0.01"
146                                value="<?php echo $tpl->value('cost') ?>"
147                                <?php if ($tpl->get('task')->acl_of('plan_date') < BEZ_PERMISSION_CHANGE) echo 'disabled' ?>></span>
148			</div>
149			<?php if ($tpl->param('tid') != ''): ?>
150				<div class="row">
151				<label for="task_state"><?php echo $tpl->getLang('task_state') ?>:</label>
152				<span>
153					<strong><?php echo $tpl->getLang('task_' . $tpl->get('task')->state) ?></strong>
154				</span>
155				</div>
156			<?php endif ?>
157			<div class="row">
158				<label></label>
159				<span style="padding-top:10px;">
160					<input type="submit" value="<?php echo $tpl->param('tid') == '' ? $tpl->getLang('add') : $tpl->getLang('correct') ?>">
161					<a href="<?php
162				if ($tpl->action() == 'thread') {
163					echo $tpl->url('thread', 'id', $tpl->get('thread')->id);
164				} else if ($tpl->action() == 'task' && $tpl->get('task')->id != '') {
165					echo $tpl->url('task', 'tid', $tpl->get('task')->id);
166				} else if ($tpl->get('task')->task_program_id != '') {
167                    echo $tpl->url('tasks', 'task_program_id', $tpl->get('task')->task_program_id);
168                } else {
169                    echo $tpl->url('tasks');
170                }
171				?><?php if ($tpl->param('tid') != '') echo '#z'.$tpl->param('tid') ?>"
172				class="bez_delete_button bez_link_button">
173					<?php echo $tpl->getLang('cancel') ?>
174				</a>
175			</span>
176        </div>
177    </fieldset>
178</form>
179