1<?php /* @var \dokuwiki\plugin\bez\meta\Tpl $tpl */ ?>
2<form action="<?php echo $tpl->url('task_programs') ?>" method="POST">
3<table>
4    <tr>
5        <th>Name</th>
6        <th colspan="3">Count</th>
7    </tr>
8    <?php foreach ($tpl->get('task_programs') as $task_program): ?>
9        <tr>
10            <?php if (  in_array($tpl->param('action'), array('edit', 'update')) &&
11                $tpl->param('id') == $task_program->id): ?>
12
13                    <td>
14                        <input type="hidden" name="id" value="<?php echo $task_program->id ?>" />
15                        <input name="name" value="<?php echo $tpl->value('name') ?>" />
16                    </td>
17                    <td colspan="2">
18                        <button name="action" value="update"><?php echo $tpl->getLang('save') ?></button>
19                        <a href="<?php echo $tpl->url('task_programs') ?>">
20                            <?php echo $tpl->getLang('cancel') ?>
21                        </a>
22                    </td>
23            <?php else: ?>
24                <td><?php echo $task_program->name ?></td>
25                <td <?php if ($task_program->count > 0) echo 'colspan="2"'; ?>>
26                    <a href="<?php echo $tpl->url('task_programs', 'action', 'edit', 'id', $task_program->id) ?>">
27                        <?php echo $tpl->getLang('edit') ?>
28                    </a>
29                </td>
30                <?php if ($task_program->count == 0): ?>
31                    <td>
32                        <a onclick="return confirm('<?php echo $tpl->getLang('js')['remove_confirm'] ?>')"
33                           href="<?php echo $tpl->url('task_programs', 'action', 'remove', 'id', $task_program->id) ?>">
34                            <?php echo $tpl->getLang('delete') ?>
35                        </a>
36                    </td>
37                <?php endif ?>
38            <?php endif ?>
39
40            <td>
41                <a href="<?php echo $tpl->url('tasks', 'task_program_id', $task_program->id) ?>">
42                    <?php echo $task_program->count ?>
43                </a>
44            </td>
45        </tr>
46    <?php endforeach ?>
47    <?php if (  $tpl->param('action') !== 'edit' &&
48    $tpl->param('action') != 'update'): ?>
49        <tr>
50            <td><input name="name" value="<?php echo $tpl->value('name') ?>" /></td>
51            <td colspan="3">
52                <button name="action" value="add"><?php echo $tpl->getLang('save') ?></button>
53            </td>
54        </tr>
55        <?php endif ?>
56</table>
57</form>
58