1<?php /* @var \dokuwiki\plugin\bez\meta\Tpl $tpl */ ?>
2<?php $D = 2 ?>
3<?php if (count($tpl->get('8d_tasks')['correction']) > 0) $D++ ?>
4<?php if (count($tpl->get('causes')) > 0) $D++ ?>
5<?php if (count($tpl->get('8d_tasks')['corrective']) > 0) $D++ ?>
6<?php $corrective_done = array_filter($tpl->get('8d_tasks')['corrective'], function ($task) {
7    return $task->state == 'done';
8}) ?>
9<?php if (count($corrective_done) > 0) $D++ ?>
10<?php if (count($tpl->get('8d_tasks')['preventive']) > 0) $D++ ?>
11<?php if ($tpl->get('thread')->state == 'closed' || $tpl->get('thread')->state == 'rejected') $D++ ?>
12
13<h1>
14    <?php printf($tpl->getLang('8d_report_header'), $D); ?>
15	<span id="bez_8d_send_button">[<a href="
16		<?php echo $tpl->mailto('',
17   $tpl->getLang('8d_report').': #'.$tpl->get('thread')->id.' '.$tpl->get('thread')->title,
18            $tpl->url('8d', 'id', $tpl->get('thread')->id) . '?t=' . $_GET['t']) ?>">
19<?php echo $tpl->getLang('send_mail') ?>
20	</a>]</span>
21</h1>
22
23<table>
24<tr>
25	<td>
26		 <strong>
27		 	<a href="<?php echo $tpl->url('thread', 'id', $tpl->get('thread')->id) ?>">
28				#<?php echo  $tpl->get('thread')->id ?>
29			</a>
30		</strong>
31        <?php if (!empty($tpl->get('thread')->label_name)): ?>
32            <?php echo $tpl->get('thread')->label_name ?>
33        <?php else: ?>
34            <i style="color: #777"><?php echo $tpl->getLang('issue_type_no_specified') ?></i>
35        <?php endif ?>
36	</td>
37
38	<td>
39		<strong><?php echo $tpl->getLang('open_date') ?>:</strong>
40        <?php echo $tpl->date($tpl->get('thread')->create_date) ?>
41	</td>
42</tr>
43
44	<tr>
45	<td colspan="2">
46		<strong><?php echo $tpl->getLang('title') ?>:</strong>
47		<?php echo  $tpl->get('thread')->title ?>
48	</td>
49</tr>
50</table>
51<?php $D = 1 ?>
52<h2><?php echo $D++ ?>D - <?php echo $tpl->getLang('1d') ?></h2>
53<ul>
54	<?php foreach($tpl->get('thread')->get_participants() as $participant): ?>
55		<li><?php echo $tpl->user_name($participant['user_id']) ?></li>
56	<?php endforeach ?>
57</ul>
58
59<h2><?php echo $D++ ?>D - <?php echo $tpl->getLang('2d') ?></h2>
60<?php echo $tpl->get('thread')->content_html ?>
61
62<?php if (count($tpl->get('8d_tasks')['correction']) > 0): ?>
63    <h2><?php echo $D++ ?>D - <?php echo $tpl->getLang('3d') ?></h2>
64    <?php $tpl->set('tasks', $tpl->get('8d_tasks')['correction']) ?>
65    <?php include '8d_tasks.php' ?>
66<?php endif ?>
67
68<?php if (count($tpl->get('causes')) > 0): ?>
69    <h2><?php echo $D++ ?>D - <?php echo $tpl->getLang('4d') ?></h2>
70    <?php $tpl->set('causes', $tpl->get('causes')) ?>
71    <?php include '8d_causes.php' ?>
72<?php endif ?>
73
74<?php if (count($tpl->get('8d_tasks')['corrective']) > 0): ?>
75    <h2><?php echo $D++ ?>D - <?php echo $tpl->getLang('5d') ?></h2>
76    <?php $tpl->set('tasks', $tpl->get('8d_tasks')['corrective']) ?>
77    <?php include '8d_tasks.php' ?>
78<?php endif ?>
79
80<?php if ($tpl->get('thread')->state == 'closed' || $tpl->get('thread')->state == 'rejected'): ?>
81    <h2><?php echo $D++ ?>D - <?php echo $tpl->getLang('6d-var2') ?></h2>
82    <?php echo  $tpl->get('thread')->closing_comment() ?>
83<?php endif ?>
84
85<?php if (count($tpl->get('8d_tasks')['preventive']) > 0): ?>
86    <h2><?php echo $D++ ?>D - <?php echo $tpl->getLang('7d') ?></h2>
87    <?php $preventive = array_merge($tpl->get('risks'), $tpl->get('opportunities')) ?>
88    <?php usort($preventive, function ($a, $b) {
89        return $a->id > $b->id;
90    }); ?>
91    <?php $tpl->set('causes', $preventive) ?>
92    <?php include '8d_causes.php' ?>
93
94    <?php $tpl->set('tasks', $tpl->get('8d_tasks')['preventive']) ?>
95    <?php include '8d_tasks.php' ?>
96<?php endif ?>
97
98
99<h2><?php echo $D++ ?>D - <?php echo $tpl->getLang('8d') ?></h2>
100
101<table>
102    <tr>
103        <td <?php if (count($tpl->get('8d_tasks')['preventive']) == 0) echo 'colspan="2"' ?>>
104            <strong><?php echo $tpl->getLang('problem_close_date') ?>:</strong>
105            <?php if ($tpl->get('thread')->state == 'closed' || $tpl->get('thread')->state == 'rejected'): ?>
106                <?php echo $tpl->date($tpl->get('thread')->close_date) ?>
107            <?php else: ?>
108                ---
109            <?php endif ?>
110        </td>
111        <?php if (count($tpl->get('8d_tasks')['preventive']) > 0): ?>
112            <td>
113                <strong><?php echo $tpl->getLang('preventive_close_date') ?>:</strong>
114                <?php if ($tpl->get('preventive_close_date')): ?>
115                    <?php echo $tpl->get('preventive_close_date') ?>
116                <?php else: ?>
117                    ---
118                <?php endif ?>
119            </td>
120        <?php endif ?>
121    </tr>
122
123    <tr>
124        <td>
125            <strong><?php echo $tpl->getLang('totalcost') ?>:</strong>
126            <?php if ($tpl->get('thread')->task_sum_cost != ''): ?>
127                <?php echo $tpl->get('thread')->task_sum_cost ?>
128            <?php else: ?>
129                <em>---</em>
130            <?php endif ?>
131        </td>
132        <td>
133            <strong><?php echo $tpl->getLang('coordinator') ?>:</strong>
134            <?php echo $tpl->user_name($tpl->get('thread')->coordinator) ?>
135        </td>
136    </tr>
137</table>
138