<table>
<tr>
<th>Nom</th>
- <th>Actions</th>
+ <th>Commandes</th>
</tr>
<?php if(isset($tasks)) { foreach ($tasks as $task): ?>
<tr>
<td><?php echo $task['Task']['name'] ?></td>
<td>
- <?php echo $this->Html->link(
+ <?php
+
+ // CHECKING COMMAND EXISTENCE
+ if(isset($commandsArray) && count($commandsArray) > 0) { ?>
+ <table>
+ <?php if(array_key_exists($task['Task']['id'], $commandsArray)) {
+ $order = 1;
+ foreach ($commandsArray[$task['Task']['id']] as $command): ?>
+ <tr>
+ <td><?php echo $command['Command']['value']; ?></td>
+ <td><?php echo $this->Html->link(
+ 'HAUT', array('controller' => 'tasks', 'action' => 'order_command', $task['Task']['id'], $order, "up")
+ ).' '.
+ $this->Html->link(
+ 'BAS', array('controller' => 'tasks', 'action' => 'order_command', $task['Task']['id'], $order, "down")
+ );
+ $order++;?>
+ </td>
+ </tr>
+ <?php endforeach; } ?>
+ </table>
+ <?php }
+ echo $this->Html->link(
'Nouvelle commande',
array('controller' => 'commands', 'action' => 'add', $task['Task']['id'])
); ?>