<?php if (!empty($files)):?>
	<span class = "note">Eg. Principle's quotes to CMC, a Customer's completed datasheet, or emails relevent to the Enquiry.<br>
	Note: These files are read-only once they are uploaded. Changes you make on a local copy are not sent back to the database - the file must be re-uploaded.
	</span>
	<table cellpadding = "0" cellspacing = "0" class="filetable">
	<tr>
		<th><?php __('Date Added'); ?></th>
		<th><?php __('Name'); ?></th>
		<th><?php __('Type'); ?></th>
		<th><?php __('Size'); ?></th>	
		<th><?php __('Description'); ?></th>
		<th class="actions"><?php __('Actions');?></th>
	</tr>
	<?php
		$i = 0;
		foreach ($files as $file):
			$class = null;
			
			if ($i % 2 == 0) {
				$class = ' class="altrow"';
			}
			$i++;			
		?>
		<tr<?php echo $class;?>>
			<td><?php echo $time->nice($file['EnquiryFile']['created']);?></td>
			<td><?php echo $html->link($file['EnquiryFile']['name'], array('controller'=>'enquiry_files', 'action' => 'download/', $file['EnquiryFile']['id']));?></td>
			<td><?php 
				if($file['EnquiryFile']['type'] == 'application/pdf') {
					echo $html->image('pdf_type.png');
				}
				else if($file['EnquiryFile']['type'] == 'application/msword') {
					echo $html->image('document_type.png');
				}
				else if($file['EnquiryFile']['type'] == 'message/rfc822') {
					echo $html->image('message_type.png');
				}
				else if($file['EnquiryFile']['type'] == 'application/vnd.ms-excel') {
					echo $html->image('spreadsheet_document_type.png');
				}
				else if($file['EnquiryFile']['type'] == 'image/jpeg') {
					echo $html->image('image_type.png');
				}
				else {
					echo $html->image('unknown_type.png');
				}
				?></td>
			<td><?php echo $number->toReadableSize($file['EnquiryFile']['size']);?></td>
			<td><?php echo $file['EnquiryFile']['description'];?></td>
			<td class="actions">
				<?php echo $html->link(__('View', true), array('controller'=> 'enquiry_files', 'action'=>'download/', $file['EnquiryFile']['id'])); ?>
			</td>
		</tr>
	<?php endforeach; ?>
	</table>
<?php endif; ?>

	<div class="actions">
		<ul>
			<li><?php echo $html->link(__('Add File to this Enquiry', true), array('controller'=> 'enquiry_files', 'action'=>'add/enquiryid:'.$enquiry['Enquiry']['id']));?> </li>
		</ul>
	</div>
