<?php if (!empty($addresses)):?>
	<table cellpadding = "0" cellspacing = "0">
	<tr>
		<th><?php __('Address'); ?></th>
		<th><?php __('City'); ?></th>
		<th><?php __('State'); ?></th>
		<th><?php __('Post Code'); ?></th>
		<th><?php __('Country'); ?></th>
		<th><?php __('Type'); ?></th>
		<th class="actions"><?php __('Actions');?></th>
	</tr>
	<?php
		$i = 0;
		foreach ($addresses as $address):
			$class = null;
			if ($i++ % 2 == 0) {
				$class = ' class="altrow"';
			}
		?>
		<tr<?php echo $class;?>>
			<td><?php echo $address['Address']['address'];?></td>
			<td><?php echo $address['Address']['city'];?></td>
			<td><?php echo $html->link(__($address['State']['name'], true), array('controller'=>'states', 'action' => 'view', $address['State']['id']));?></td>
			<td><?php echo $address['Address']['postcode']; ?></td>
			<td><?php echo $html->link(__($address['Country']['name'], true), array('controller'=>'countries', 'action' => 'view', $address['Country']['id']));?></td>
			<td><?php 
			
				/* Could probably use an Enum in the table instead.
				 * This will stay for now though */
				switch($address['Address']['type']) {
						case 0:
							echo "Billing";
							break;
						case 1:
							echo "Shipping";
							break;
						case 2:
							echo "Both Shipping and Billing";
							break;
						}
			?></td>
			<td class="actions">
				<?php echo $html->link(__('View', true), array('controller'=> 'addresses', 'action'=>'view', $address['Address']['id'])); ?>
				<?php echo $html->link(__('Edit', true), array('controller'=> 'addresses', 'action'=>'edit', $address['Address']['id'])); ?>
				
			</td>
		</tr>
	<?php endforeach; ?>
	</table>
<?php endif; ?>
