1<?php /* @var \dokuwiki\plugin\bez\meta\Tpl $tpl */ ?>
2
3<?php if (!$tpl->get('no_filters', false)): ?>
4
5<?php if ($tpl->factory('thread')->permission() >= BEZ_TABLE_PERMISSION_INSERT): ?>
6    <a href="<?php echo $tpl->url('thread_report', 'type', $tpl->action() == 'projects' ? 'project' : 'issue') ?>" class="bez_start_button" id="bez_report_issue_button">
7        <?php echo $tpl->getLang('report_' . $tpl->action()) ?>
8    </a>
9<?php endif ?>
10
11<br /><br />
12
13<div class="bez_filter_form">
14<form action="<?php echo $tpl->url($tpl->action()) ?>" method="post">
15
16    <label><?php echo $tpl->getLang('reporter') ?>:
17        <select name="original_poster">
18            <option <?php if ($tpl->value('original_poster') == '-all') echo 'selected' ?>
19                    value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
20            <optgroup label="<?php echo $tpl->getLang('users') ?>">
21                <?php foreach ($tpl->get('users') as $nick => $name): ?>
22                    <option <?php if ($tpl->value('original_poster') == $nick) echo 'selected' ?>
23                            value="<?php echo $nick ?>"><?php echo $name ?></option>
24                <?php endforeach ?>
25            </optgroup>
26            <optgroup label="<?php echo $tpl->getLang('groups') ?>">
27                <?php foreach ($tpl->get('groups') as $name): ?>
28                    <?php $group = "@$name" ?>
29                    <option <?php if ($tpl->value('original_poster') == $group) echo 'selected' ?>
30                            value="<?php echo $group ?>"><?php echo $group ?></option>
31                <?php endforeach ?>
32            </optgroup>
33        </select>
34    </label>
35
36	<label><?php echo $tpl->getLang('state') ?>:
37		<select name="state">
38			<option <?php if ($tpl->value('state') === '-all') echo 'selected' ?>
39				value="-all">--- <?php echo $tpl->getLang('all_not_rejected') ?> ---</option>
40		<?php foreach (\dokuwiki\plugin\bez\mdl\Thread::get_states() as $state): ?>
41			<option <?php if ($tpl->value('state') === $state) echo 'selected' ?>
42				value="<?php echo $state ?>"><?php echo $tpl->getLang('state_' . $state) ?></option>
43		<?php endforeach ?>
44		</select>
45	</label>
46    <?php if ($tpl->action() != 'projects'): ?>
47        <label><?php echo $tpl->getLang('just_type') ?>:
48            <select name="label_id">
49                <option <?php if ($tpl->value('label_id') === '-all') echo 'selected' ?>
50                    value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
51                <option <?php if ($tpl->value('label_id') === '-none') echo 'selected' ?>
52                value="-none">--- <?php echo $tpl->getLang('issue_type_no_specified') ?> ---</option>
53            <?php foreach ($tpl->get('labels') as $label): ?>
54                <option <?php if ($tpl->value('label_id') === $label->id) echo 'selected' ?>
55                    value="<?php echo $label->id ?>"><?php echo $label->name ?></option>
56            <?php endforeach ?>
57            </select>
58        </label>
59    <?php endif ?>
60
61	<label><?php echo $tpl->getLang('coordinator') ?>:
62		<select name="coordinator">
63			<option <?php if ($tpl->value('coordinator') === '-all') echo 'selected' ?>
64				value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
65			<option <?php if ($tpl->value('coordinator') === '-none') echo 'selected' ?>
66				value="-none">--- <?php echo $tpl->getLang('none') ?> ---</option>
67		<optgroup label="<?php echo $tpl->getLang('users') ?>">
68			<?php foreach ($tpl->get('users') as $nick => $name): ?>
69				<option <?php if ($tpl->value('coordinator') === $nick) echo 'selected' ?>
70					value="<?php echo $nick ?>"><?php echo $name ?></option>
71			<?php endforeach ?>
72	</optgroup>
73	<optgroup label="<?php echo $tpl->getLang('groups') ?>">
74		<?php foreach ($tpl->get('groups') as $name): ?>
75			<?php $group = "@$name" ?>
76			<option <?php if ($tpl->value('coordinator') === $group) echo 'selected' ?>
77				value="<?php echo $group ?>"><?php echo $group ?></option>
78		<?php endforeach ?>
79	</optgroup>
80	</select>
81	</label>
82
83	<label><?php echo $tpl->getLang('title') ?>:
84		<input name="title" value="<?php echo $tpl->value('title') ?>" />
85	</label>
86
87
88	<label><?php echo $tpl->getLang('year') ?>:
89		<select name="year">
90			<option <?php if ($tpl->value('year') === '-all') echo 'selected' ?>
91				value="-all">--- <?php echo $tpl->getLang('all') ?> ---</option>
92		<?php foreach ($tpl->get('years') as $year): ?>
93			<option <?php if ($tpl->value('year') === $year) echo 'selected' ?>
94				value="<?php echo $year ?>"><?php echo $year ?></option>
95		<?php endforeach ?>
96		</select>
97	</label>
98
99	<label><?php echo $tpl->getLang('sort_by_open_date') ?>:
100			<input type="checkbox" name="sort_open"
101			<?php if ($tpl->value('sort_open') === 'on') echo 'checked="checked"' ?>>
102	</label>
103<?php if ($tpl->action() == 'threads'): ?>
104    <label><?php echo $tpl->getLang('has_causes') ?>:
105        <input type="checkbox" name="has_causes"
106            <?php if ($tpl->value('has_causes') === 'on') echo 'checked="checked"' ?>>
107    </label>
108
109    <label><?php echo $tpl->getLang('has_risks') ?>:
110        <input type="checkbox" name="has_risks"
111            <?php if ($tpl->value('has_risks') === 'on') echo 'checked="checked"' ?>>
112    </label>
113
114    <label><?php echo $tpl->getLang('has_opportunities') ?>:
115        <input type="checkbox" name="has_opportunities"
116            <?php if ($tpl->value('has_opportunities') === 'on') echo 'checked="checked"' ?>>
117    </label>
118<?php endif ?>
119
120	<label><input type="submit" value="<?php echo $tpl->getLang('filter') ?>" /></label>
121</form>
122</div>
123<?php endif ?>
124
125
126<table class="bez bez_sumarise">
127	<tr>
128		<th><?php echo $tpl->getLang('id') ?></th>
129		<th><?php echo $tpl->getLang('state') ?></th>
130        <?php if ($tpl->action() != 'projects'): ?>
131		    <th><?php echo $tpl->getLang('type') ?></th>
132        <?php endif ?>
133		<th><?php echo $tpl->getLang('title')?></th>
134		<th><?php echo $tpl->getLang('coordinator') ?></th>
135		<th><?php echo $tpl->getLang('date') ?></th>
136		<th><?php echo $tpl->getLang('last_mod_date') ?></th>
137		<th><?php echo $tpl->getLang('closed') ?></th>
138		<th><?php echo $tpl->getLang('cost') ?></th>
139		<th><?php echo $tpl->getLang('closed_tasks') ?></th>
140        <?php if ($tpl->action() == 'threads'): ?>
141            <th><?php echo $tpl->getLang('causes') ?></th>
142            <th><?php echo $tpl->getLang('risks') ?></th>
143            <th><?php echo $tpl->getLang('opportunities') ?></th>
144        <?php endif ?>
145	</tr>
146    <?php $count = 0 ?>
147    <?php $total_cost = 0.0 ?>
148    <?php $total_task_closed = 0 ?>
149    <?php $total_task = 0 ?>
150    <?php $total_cause = 0 ?>
151    <?php $total_risk = 0 ?>
152    <?php $total_opportunity = 0 ?>
153	<?php foreach ($tpl->get('threads') as $thread): ?>
154        <?php if ($thread->acl_of('id') < BEZ_PERMISSION_VIEW) continue ?>
155        <?php $count += 1 ?>
156        <?php $total_cost += (float) $thread->task_sum_cost ?>
157        <?php $total_task_closed += (int) $thread->task_count_closed ?>
158        <?php $total_task += (int) $thread->task_count ?>
159        <?php $total_cause += (int) $thread->cause_count ?>
160        <?php $total_risk += (int) $thread->risk_count ?>
161        <?php $total_opportunity += (int) $thread->opportunity_count ?>
162		<tr class="<?php
163            if ($thread->state == 'opened') {
164                echo 'priority_' . $thread->priority;
165            } elseif ($thread->state == 'proposal') {
166                echo 'priority_';
167            }
168        ?>">
169			<td style="white-space: nowrap">
170                <a href="<?php echo $tpl->url('thread', 'id', $thread->id) ?>">#<?php echo $thread->id ?></a>
171                <?php if($thread->private == '1'): ?>
172                    <?php echo inlineSVG(DOKU_PLUGIN . 'bez/images/lock-small.svg') ?>
173                <?php endif ?>
174			</td>
175			<td>
176			<?php echo $tpl->getLang('state_'.$thread->state) ?>
177			</td>
178            <?php if ($tpl->action() != 'projects'): ?>
179                <td>
180                    <?php if ($thread->label_name === NULL): ?>
181                        <i style="color: #777"><?php echo $tpl->getLang('issue_type_no_specified') ?></i>
182                    <?php else: ?>
183                        <?php echo $thread->label_name ?>
184                    <?php endif ?>
185                </td>
186            <?php endif ?>
187			<td><?php echo $thread->title ?></td>
188			<td>
189                <?php if ($thread->coordinator === NULL): ?>
190                    <i style="color: #777"><?php echo $tpl->getLang('none') ?></i>
191                <?php else: ?>
192                    <?php echo $tpl->user_name($thread->coordinator) ?>
193                <?php endif ?>
194            </td>
195            <td>
196                <?php echo $tpl->date($thread->create_date) ?>
197            </td>
198            <td>
199                <?php echo $tpl->date($thread->last_activity_date) ?>
200            </td>
201			<td>
202				<?php if (in_array($thread->state, array('closed', 'rejected'))): ?>
203                    <?php echo $tpl->date($thread->close_date) ?><br />
204                    <?php $s = $tpl->getLang('report_priority').': ' .
205                        $tpl->date_diff_days($thread->create_date, $thread->close_date, '%a') ?>
206                    <?php echo str_replace(' ', '&nbsp;', $s) ?>
207				<?php else: ?>
208                    <em>---</em>
209				<?php endif ?>
210			</td>
211			<td>
212				<?php if ($thread->task_sum_cost === NULL): ?>
213					<em>---</em>
214				<?php else: ?>
215					<?php echo $thread->task_sum_cost ?>
216				<?php endif ?>
217			</td>
218			<td>
219                <?php echo $thread->task_count_closed ?> / <?php echo $thread->task_count ?>
220
221			</td>
222            <?php if ($tpl->action() == 'threads'): ?>
223                <td>
224                    <?php echo $thread->cause_count ?>
225                </td>
226                <td>
227                    <?php echo $thread->risk_count ?>
228                </td>
229                <td>
230                    <?php echo $thread->opportunity_count ?>
231                </td>
232            <?php endif ?>
233		</tr>
234	<?php endforeach ?>
235	<tr>
236		<th><?php echo $tpl->getLang('report_total') ?></th>
237		<td colspan="<?php echo $tpl->action() == 'threads' ? '7' : '6' ?>"><?php echo $count ?></td>
238		<td><?php echo $total_cost ?></td>
239        <td><?php echo $total_task_closed.'&nbsp;/&nbsp;'.$total_task ?></td>
240
241        <?php if ($tpl->action() == 'threads'): ?>
242            <td><?php echo $total_cause ?></td>
243            <td><?php echo $total_risk ?></td>
244            <td><?php echo $total_opportunity ?></td>
245        <?php endif ?>
246	</tr>
247</table>
248