<div class="principles view">
<h2><?php  __('Principle');?></h2>
	<dl><?php $i = 0; $class = ' class="altrow"';?>
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Name'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $principle['Principle']['name']; ?>
			&nbsp;
		</dd>
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Short Name'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $principle['Principle']['short_name']; ?>
			&nbsp;
		</dd>
		
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Code'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $principle['Principle']['code']; ?>
			&nbsp;
		</dd>
		
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('URL'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $html->link($principle['Principle']['url'], $principle['Principle']['url']); ?>
			&nbsp;
		</dd>
		
		
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Country'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $html->link($principle['Country']['name'], array('controller'=> 'countries', 'action'=>'view', $principle['Country']['id'])); ?>
			&nbsp;
		</dd>
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Currency'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $html->link($principle['Currency']['name'], array('controller'=> 'currencies', 'action'=>'view', $principle['Currency']['id'])); ?>
			&nbsp;
		</dd>
	</dl>
</div>
<div class="actions">
	<ul>
		<li><?php echo $html->link(__('Edit Principle', true), array('action'=>'edit', $principle['Principle']['id'])); ?> </li>
		
	</ul>
</div>
<div class="related">
	<h3><?php __('Principle Contacts');?> <?php echo $html->image('system-users.png'); ?></h3>
	<?php if (!empty($principleContacts)):?>
	<? echo $this->element('principle_contacts', $principleContacts); ?>
<?php endif; ?>
	<button id="addUser">Add Principle Contact</button>
</div>


<div class="related">
	<h3><?php __('Addresses');?> <?php echo $html->image('x-office-address-book.png'); ?></h3>
	<?php if (!empty($principle['PrincipleAddress'])):?>
	<? echo $this->element('principle_address_table', $addresses); ?>
<?php endif; ?>
	<div class="actions">
		<ul>
			<li><?php echo $html->link(__('New Address for this Principle', true), array('controller'=> 'principle_addresses', 'action'=>'add/principleid:'.$principle['Principle']['id']));?> </li>
		</ul>
	</div>
</div>

<div class="related">
	<h3><?php __('Related Enquiries');?></h3>
	<?php if (!empty($principle['Enquiry'])):?>
	<? echo $this->element('enquiry_table', $enquiries); ?>
<?php endif; ?>

	<div class="actions">
		<ul>
			<li><?php echo $html->link(__('New Enquiry', true), array('controller'=> 'enquiries', 'action'=>'add'));?> </li>
		</ul>
	</div>
</div>
<div class="related">
	<h3><?php __('Related Products');?></h3>
	<?php if (!empty($principle['Product'])):?>
	<table cellpadding = "0" cellspacing = "0">
	<tr>
		
		<th><?php __('Title'); ?></th>
	
		
		<th class="actions"><?php __('Actions');?></th>
	</tr>
	<?php
		$i = 0;
		foreach ($principle['Product'] as $product):
			$class = null;
			if ($i++ % 2 == 0) {
				$class = ' class="altrow"';
			}
		?>
		<tr<?php echo $class;?>>
			
			<td><?php echo $product['title'];?></td>
			
			
			<td class="actions">
				<?php echo $html->link(__('View', true), array('controller'=> 'products', 'action'=>'view', $product['id'])); ?>
				<?php echo $html->link(__('Edit', true), array('controller'=> 'products', 'action'=>'edit', $product['id'])); ?>
				<?php echo $html->link(__('Delete', true), array('controller'=> 'products', 'action'=>'delete', $product['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $product['id'])); ?>
			</td>
		</tr>
	<?php endforeach; ?>
	</table>
<?php endif; ?>

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

<? echo $javascript->link('add_user'); ?>
<div id="addUserDiv">

    <?php echo $form->create('User');?>

    <?php
    echo $form->input('first_name');
    echo $form->input('last_name');
    echo $form->input('email');
    echo $form->input('job_title');
    echo $form->input('phone');
    echo $form->input('mobile');
    echo $form->input('fax');
    echo $form->input('phone_extension');
    echo $form->input('direct_phone');
    echo $form->input('notes');
    echo $form->input('type', array('type'=>'hidden', 'value'=>'principle'));
    echo $form->input('principle_id', array('type'=>'hidden', 'value'=>$principle['Principle']['id']));
    echo $form->submit('Add Principle Contact', array('id'=>'submitUserButton'));
    ?>



</div>
<?php debug($principleContacts); ?>