<?php echo $javascript->link('costing_dialog'); ?>


<div class="products view">
<h2><?php  __('Product: '.$product['Product']['title']);?></h2>

	<dl><?php $i = 0; $class = ' class="altrow"';?>
		
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Principle'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $html->link($product['Principle']['name'], array('controller'=> 'principles', 'action'=>'view', $product['Principle']['id'])); ?>
			&nbsp;
		</dd>
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Title'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $product['Product']['title']; ?>
			&nbsp;
		</dd>
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Description'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $product['Product']['description']; ?>
			&nbsp;
		</dd>
		
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Model Number'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $product['Product']['model_number']; ?>
			&nbsp;
		</dd>
	
		<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Model Number Format'); ?></dt>
		<dd<?php if ($i++ % 2 == 0) echo $class;?>>
			<?php echo $product['Product']['model_number_format']; ?>
			&nbsp;
		</dd>
</dl>
</div>

<div class="actions">
	<ul>
		<li><?php echo $html->link(__('Edit Product', true), array('action'=>'edit', $product['Product']['id'])); ?> </li>
                <li><?php echo $html->link(__('Add Costing', true), array('controller'=>'costings', 'action'=>'add/productid:'.$product['Product']['id']));?></li>

                <button id="addCostingDialog">Add Costing</button>
	
	</ul>
</div>


<?php echo $javascript->link('product-model-number-builder'); ?>




<div id="modelNumberFormat">
    <h3>Model Number configuration</h3>
    <ul id="sortable">
        <?php foreach($options as $opt): ?>
    <li class="ui-state-default"><?php echo $opt['ProductOptionsCategory']['name']; ?></li>
    <li class="ui-state-default">-</li>
    <?php endforeach; ?>
    </ul>
    <button id="DoModelConfig">Click here to configure the model number builder</button>
</div>


<div class="related"> 
<h2>Option Categories for this Product</h2>
<?php echo $html->link(__('Add new Option Category', true), array('controller'=>'ProductOptionsCategories', 'action'=>'add', $product['Product']['id'])); ?>
<?php foreach($options as $opt): ?>
<h3><?php echo $opt['ProductOptionsCategory']['name']; ?></h3><?php echo $html->image('edit_add.png');?>
<table class="productoptions">
	<th><?php __('Model Number'); ?></th>
	<th><?php __('Name'); ?></th>
	<th class="actions">Actions</th>
	<?php 
	if($opt['ProductOption']):
	foreach($opt['ProductOption'] as $option): ?> 
	

	<?php 
		if($option['default'] == '1') {
			echo '<tr class="defaultoption">';
		}
		else {
			echo '<tr>';
		}
?>
		<td><?php echo $option['model_number'];?></td>
		<td><?php echo $option['title'];?></td>
		<td class="actions">
				<?php echo $html->link(__('View', true), array('controller' => 'product_options', 'action' => 'view', $option['id'])); ?>
				<?php echo $html->link(__('Edit', true), array('controller' => 'product_options', 'action' => 'edit', $option['id'])); 
				//if($option['default'] != '1') {
				//	echo $html->link(__('Set as Default', true), array('controller' => 'product_options', 'action' => 'set_default', $option['id']));
				//}
		
				?>
		</td>	
</tr>
	<? endforeach;
		endif;
	?>
</table>
<?php echo $html->link(__('Add new '.$opt['ProductOptionsCategory']['name'].' option', true), array('controller'=>'ProductOptions', 'action'=>'add', $opt['ProductOptionsCategory']['id'])); ?>

<?php endforeach; ?>

</div>


<div id="costingdiv"></div>


<?php debug($product); ?>

<?php debug($options); ?>


