<div class="customers index">
<h2><?php __('Customers');?></h2>
<span>
<?php echo 'Or Show Only: ';
foreach($customer_categories as $category) {
	echo $html->link($category['CustomerCategory']['name'], array('action'=>"index/showonly:".$category['CustomerCategory']['id'])).' ';
}
?><br>
</span><br>
<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('Company Name', 'name');?></th>
	<th><?php echo $paginator->sort('ABN', 'abn');?></th>
	<th><?php echo $paginator->sort('Payment Terms', 'payment_terms'); ?></th>
	<th><?php echo $paginator->sort('Category', 'customer_category_id'); ?></th>
	<th><?php echo $paginator->sort('Date Added', 'created');?></th>
	<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($customers as $customer):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
	if($customer['Customer']['customer_category_id'] == 1) {
		$class = ' class="customer-suspect"';
	}
	if($customer['Customer']['customer_category_id'] == 2) {
		$class = ' class="customer-prospect"';
	}
	if($customer['Customer']['customer_category_id'] == 3) {
		$class = ' class="customer-customer"';
	}
		
		
	
?>
	<tr<?php echo $class;?>>
	
		<td>
			<?php echo $html->link(__($customer['Customer']['name'], true), array('action'=>'view', $customer['Customer']['id'])); ?>
		</td>
		<td>
			<?php echo $html->link($this->element('abn', array('abn'=>$customer['Customer']['abn'])), 'http://www.abr.business.gov.au/abnDetails.aspx?ABN='.$customer['Customer']['abn'], 
				array('target'=>'_blank')); ?>
		</td>
		<td>
			<?php echo $customer['Customer']['payment_terms']; ?>
		</td>
		<td>
			<?php echo $customer['CustomerCategory']['name']; ?>
		</td>
		
		<td>
			<?php echo date('j M Y',$time->toUnix($customer['Customer']['created'])); ?>
			
		</td>
		<td class="actions">
			<?php echo $html->link(__('View', true), array('action'=>'view', $customer['Customer']['id'])); ?>
			<?php echo $html->link(__('Edit', true), array('action'=>'edit', $customer['Customer']['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 Customer', true), array('action'=>'add')); ?></li>
		<li><?php echo $html->link(__('List Addresses', true), array('controller'=> 'addresses', 'action'=>'index')); ?> </li>
		<li><?php echo $html->link(__('New Address', true), array('controller'=> 'addresses', 'action'=>'add')); ?> </li>
		<li><?php echo $html->link(__('List Enquiries', true), array('controller'=> 'enquiries', 'action'=>'index')); ?> </li>
		<li><?php echo $html->link(__('New Enquiry', true), array('controller'=> 'enquiries', 'action'=>'add')); ?> </li>
	</ul>
</div>


