<div class="attachments index">
<h2><?php __('Attachments');?></h2>

<div class="actions">
	<ul>
		<li><?php echo $html->link(__('New Attachment', true), array('action' => 'add')); ?></li>
		<li><?php echo $html->link('View archived', array('action' => 'archived')); ?></li>
	</ul>
</div>

<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
	<th><?php echo $paginator->sort('principle_id');?></th>
	<th><?php echo $paginator->sort('created');?></th>
	<th><?php echo $paginator->sort('name');?></th>
	<th><?php echo $paginator->sort('type');?></th>
	<th><?php echo $paginator->sort('size');?></th>
	<th><?php echo $paginator->sort('description');?></th>
	<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;

$last_principle = array();

foreach ($attachments as $attachment):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td>
      <?php 
      if($attachment['Principle']['short_name']) {
        echo $html->link($attachment['Principle']['short_name'], '/principles/view/'.$attachment['Principle']['id']); 
      }
      else {
        echo $html->link($attachment['Principle']['name'], '/principles/view/'.$attachment['Principle']['id']); 
      }  
      ?>
		</td>
		<td>
			<?php echo $time->nice($attachment['Attachment']['created']); ?>
		</td>
		<td>
			<?php echo $attachment['Attachment']['name']; ?>
		</td>
		<td>
			<?php echo $attachment['Attachment']['type']; ?>
		</td>
		<td>
			<?php echo $number->toReadAbleSize($attachment['Attachment']['size']); ?>
		</td>
		<td>
			<?php echo $attachment['Attachment']['description']; ?>
		</td>
		<td class="actions">
			<?php echo $html->link(__('View', true), array('action' => 'view', $attachment['Attachment']['id'])); ?>
			<?php echo $html->link(__('Edit', true), array('action' => 'edit', $attachment['Attachment']['id'])); ?>
		</td>
	</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div>
<div class="actions">
	<ul>
		<li><?php echo $html->link(__('New Attachment', true), array('action' => 'add')); ?></li>
	</ul>
</div>
