1<?php /* @var \dokuwiki\plugin\bez\meta\Tpl $tpl */ ?>
2
3<?php if (!$tpl->get('no_filters', false)): ?>
4
5<?php if ($tpl->factory('task')->permission() >= BEZ_TABLE_PERMISSION_INSERT): ?>
6    <a href="<?php echo $tpl->url('task_form') ?>" class="bez_start_button" id="bez_report_task_button">
7        <?php echo $tpl->getLang('add_task') ?>
8    </a>
9<?php endif ?>
10
11<br /><br />
12
13<div class="bez_filter_form">
14<form action="<?php echo $tpl->url('tasks') ?>" method="POST">
15
16
17<label><?php echo $tpl->getLang('reporter') ?>:
18    <select name="original_poster">
19        <option <?php if ($tpl->value('original_poster') == '-all') echo 'selected' ?>
20                value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
21        <optgroup label="<?php echo $tpl->getLang('users') ?>">
22            <?php foreach ($tpl->get('users') as $nick => $name): ?>
23                <option <?php if ($tpl->value('original_poster') == $nick) echo 'selected' ?>
24                        value="<?php echo $nick ?>"><?php echo $name ?></option>
25            <?php endforeach ?>
26        </optgroup>
27        <optgroup label="<?php echo $tpl->getLang('groups') ?>">
28            <?php foreach ($tpl->get('groups') as $name): ?>
29                <?php $group = "@$name" ?>
30                <option <?php if ($tpl->value('original_poster') == $group) echo 'selected' ?>
31                        value="<?php echo $group ?>"><?php echo $group ?></option>
32            <?php endforeach ?>
33        </optgroup>
34    </select>
35</label>
36
37<label><?php echo $tpl->getLang('class') ?>:
38	<select name="type">
39		<option <?php if ($tpl->value('type') == '-all') echo 'selected' ?>
40			value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
41	<?php foreach (\dokuwiki\plugin\bez\mdl\Task::get_types() as $type): ?>
42		<option <?php if ($tpl->value('type') == $type) echo 'selected' ?>
43			value="<?php echo $type ?>"><?php echo $tpl->getLang('task_type_' . $type) ?></option>
44	<?php endforeach ?>
45	</select>
46</label>
47
48<label><?php echo $tpl->getLang('state') ?>:
49	<select name="state">
50		<option <?php if ($tpl->value('state') == '-all') echo 'selected' ?>
51			value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
52	<?php foreach (\dokuwiki\plugin\bez\mdl\Task::get_states() as $state): ?>
53		<option <?php if ($tpl->value('state') == $state) echo 'selected' ?>
54			value="<?php echo $state ?>"><?php echo lcfirst($tpl->getLang('task_' . $state)) ?></option>
55	<?php endforeach ?>
56	</select>
57</label>
58
59<label><?php echo $tpl->getLang('task_type') ?>:
60	<select name="task_program_id">
61		<option <?php if ($tpl->value('task_program_id') == '-all') echo 'selected' ?>
62			value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
63		<option <?php if ($tpl->value('task_program_id') == '-none') echo 'selected' ?>
64			value="-none">-- <?php echo $tpl->getLang('none') ?> --</option>
65	<?php foreach ($tpl->get('task_programs') as $task_program): ?>
66		<option <?php if ($tpl->value('task_program_id') == $task_program->id) echo 'selected' ?>
67			value="<?php echo $task_program->id ?>"><?php echo $task_program->name ?></option>
68	<?php endforeach ?>
69	</select>
70</label>
71
72<label><?php echo $tpl->getLang('executor') ?>:
73    <select name="assignee">
74        <option <?php if ($tpl->value('assignee') == '-all') echo 'selected' ?>
75                value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
76        <optgroup label="<?php echo $tpl->getLang('users') ?>">
77            <?php foreach ($tpl->get('users') as $nick => $name): ?>
78                <option <?php if ($tpl->value('assignee') == $nick) echo 'selected' ?>
79                        value="<?php echo $nick ?>"><?php echo $name ?></option>
80            <?php endforeach ?>
81        </optgroup>
82        <optgroup label="<?php echo $tpl->getLang('groups') ?>">
83            <?php foreach ($tpl->get('groups') as $name): ?>
84                <?php $group = "@$name" ?>
85                <option <?php if ($tpl->value('assignee') == $group) echo 'selected' ?>
86                        value="<?php echo $group ?>"><?php echo $group ?></option>
87            <?php endforeach ?>
88        </optgroup>
89    </select>
90</label>
91
92
93<label><?php echo $tpl->getLang('description') ?>:
94	<input name="content" value="<?php echo $tpl->value('content') ?>" />
95</label>
96
97
98<div class="time_filter">
99	<label>
100		<select name="date_type">
101			<option <?php if ($tpl->value('date_type') == 'plan_date') echo 'selected' ?>
102				value="plan_date"><?php echo $tpl->getLang('plan_date') ?></option>
103			<option <?php if ($tpl->value('date_type') == 'create_date') echo 'selected' ?>
104				value="create_date"><?php echo $tpl->getLang('open_date') ?></option>
105			<option <?php if ($tpl->value('date_type') == 'close_date') echo 'selected' ?>
106				value="close_date"><?php echo $tpl->getLang('close_date') ?></option>
107		</select>:
108	</label>
109	<label><?php echo $tpl->getLang('month') ?>:
110		<select name="month">
111			<option <?php if ($tpl->value('month') == '-all') echo 'selected' ?>
112				value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
113		<?php foreach ($tpl->get('months') as $nr => $month): ?>
114			<option <?php if ($tpl->value('month') == $nr) echo 'selected' ?>
115				value="<?php echo $nr ?>"><?php echo $tpl->getLang($month) ?></option>
116		<?php endforeach ?>
117		</select>
118	</label>
119	<label><?php echo $tpl->getLang('year') ?>:
120		<select name="year">
121			<option <?php if ($tpl->value('year') == '-all') echo 'selected' ?>
122				value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
123		<?php foreach ($tpl->get('years') as $year): ?>
124			<option <?php if ($tpl->value('year') == $year) echo 'selected' ?>
125				value="<?php echo $year ?>"><?php echo $year ?></option>
126		<?php endforeach ?>
127		</select>
128	</label>
129	<label><button name="action" value="filter" type="submit"><?php echo $tpl->getLang('filter') ?></button></label>
130</div>
131</form>
132</div>
133
134<?php endif ?>
135
136<?php if ($tpl->user_acl_level() >= BEZ_AUTH_ADMIN): ?>
137<form action="<?php echo $tpl->url('tasks') ?>" method="post">
138<div id="plugin__bez_bulk_actions_box" style="display:none;">
139    <button type="submit" name="action" value="bulk_delete"><?= $tpl->getLang('delete_selected') ?></button>
140    <label><?= $tpl->getLang('move_to') ?>:</label>
141    <select name="task_program">
142        <?php foreach ($tpl->get('task_programs') as $task_program): ?>
143            <option value="<?php echo $task_program->id ?>"><?php echo $task_program->name ?></option>
144        <?php endforeach ?>
145    </select>
146    <button type="submit" name="action" value="bulk_move"><?= $tpl->getLang('button_move') ?></button>
147</div>
148<?php endif ?>
149<table class="bez bez_sumarise">
150<tr>
151    <?php if ($tpl->user_acl_level() >= BEZ_AUTH_ADMIN): ?>
152        <th></th>
153    <?php endif ?>
154	<th><?php echo $tpl->getLang('id') ?></th>
155	<th><?php echo $tpl->getLang('state') ?></th>
156	<th><?php echo $tpl->getLang('task_type') ?></th>
157	<th><?php echo $tpl->getLang('description') ?></th>
158
159	<th><?php echo $tpl->getLang('executor') ?></th>
160	<th><?php echo $tpl->getLang('plan') ?></th>
161	<th><?php echo $tpl->getLang('cost') ?></th>
162
163	<th><?php echo $tpl->getLang('closed') ?></th>
164	<th><?php echo $tpl->getLang('hours_no') ?></th>
165
166</tr>
167<?php $count = 0 ?>
168<?php $total_cost = 0.0 ?>
169<?php $total_hours = 0.0 ?>
170<?php foreach ($tpl->get('tasks') as $task): ?>
171    <?php if ($task->acl_of('id') < BEZ_PERMISSION_VIEW) continue ?>
172    <?php $count += 1 ?>
173    <?php $total_cost += (float) $task->cost ?>
174    <?php $hours = $tpl->date_diff_hours($task->start_time, $task->finish_time) ?>
175    <?php $total_hours += $tpl->time_to_float($hours) ?>
176	<tr class="<?php if ($task->state == 'opened') echo 'priority_' . $task->priority ?>" data-bez-row-id="<?php echo $task->id ?>">
177        <?php if ($tpl->user_acl_level() >= BEZ_AUTH_ADMIN): ?>
178            <td><input type="checkbox" name="task_id[]" class="plugin__bez_bulk_checkbox" value="<?= $task->id ?>"></td>
179        <?php endif ?>
180		<td style="white-space: nowrap">
181            <a href="<?php echo $tpl->url('task', 'tid', $task->id) ?>">
182               <?php if ($task->thread_id != '') echo '#'.$task->thread_id ?>
183		       #z<?php echo $task->id ?>
184	       </a>
185            <?php if($task->private == '1'): ?>
186                <?php echo inlineSVG(DOKU_PLUGIN . 'bez/images/lock-small.svg') ?>
187            <?php endif ?>
188		</td>
189		<td>
190			<?php echo lcfirst($tpl->getLang('task_' . $task->state)) ?>
191			<?php if ($task->plan_date < date('%Y-%m-%d')): ?>
192			(<?php echo lcfirst($tpl->getLang('task_outdated')) ?>)
193			<?php endif ?>
194		</td>
195		<td>
196			<?php if ($task->task_program_id == ''): ?>
197				<em>---</em>
198			<?php else: ?>
199				<?php echo $task->task_program_name ?>
200			<?php endif ?>
201		</td>
202		<td>
203			<div style="max-width:200px;max-height:60px;overflow:hidden;">
204			<?php echo $task->content_html ?>
205			</div>
206			 <a class="bez_show_single_desc" href="#">(...)</a>
207			</td>
208		<td><?php echo $tpl->user_name($task->assignee) ?></td>
209
210		<td>
211        <?php echo $task->plan_date ?>
212        <?php if ($task->state == 'opened'): ?>
213            (<?php echo $tpl->date_diff_days($task->plan_date) ?>)
214        <?php endif ?>
215        <?php if ($task->all_day_event == '0'): ?>
216            <?php echo $task->start_time ?>&nbsp;-&nbsp;<?php echo $task->finish_time ?>
217        <?php endif ?>
218		</td>
219
220		<td>
221			<?php if ($task->cost == ''): ?>
222				<em>---</em>
223			<?php else: ?>
224				<?php echo $task->cost ?>
225			<?php endif ?>
226		</td>
227
228		<td>
229			<?php if ($task->state == 'opened'): ?>
230				<em>---</em>
231			<?php else: ?>
232				<?php echo $tpl->date($task->close_date) ?>
233			<?php endif ?>
234		</td>
235		<td>
236			<?php if ($task->start_time == ''): ?>
237				<em>---</em>
238			<?php else: ?>
239                <?php echo $hours ?>
240			<?php endif ?>
241		</td>
242		</tr>
243		<tr class="bez_desc_row task<?php echo $task->id ?>">
244			<td colspan="10">
245				<?php echo $task->content_html ?>
246			</td>
247		</tr>
248	<?php endforeach ?>
249	<tr>
250		<th><?php echo $tpl->getLang('report_total') ?></th>
251        <?php $colspan = $tpl->user_acl_level() >= BEZ_AUTH_ADMIN ? 6 : 5 ?>
252		<td colspan="<?= $colspan ?>>"><?php echo $count ?></td>
253		<td colspan="2"><?php echo $total_cost ?></td>
254		<td colspan="1"><?php echo $tpl->float_to_time($total_hours) ?></td>
255	</tr>
256</table>
257<?php if ($tpl->user_acl_level() >= BEZ_AUTH_ADMIN): ?>
258    </form>
259<?php endif ?>