<table cellpadding="0" cellspacing="0" class="shipments">
	    <tr>
		<th class="actions"><?php __('Actions');?></th>
		<th><?php echo $paginator->sort('date_arrived');?></th>
		<th><?php echo $paginator->sort('type');?></th>
		<th>Principle(s)</th>
		<th>PO(s)</th>
		<th><?php echo $paginator->sort('# Boxes','box_count');?></th>
		<th>Box Details<br>
		LxWxH (cm)
		</th>
		<th>Weight (kg)</th>
		<th><?php echo $paginator->sort('freight_forwarder_id');?></th>


		<th><?php echo $paginator->sort('airway_bill');?></th>
		<th><?php echo $paginator->sort('comments');?></th>
		<th class="actions"><?php __('Actions');?></th>
	    </tr>
	    <?php
	    $i = 0;
	    foreach ($shipments as $shipment):
		?>
	    <tr>
		<td class="actions">
		    <button id="<?=$shipment['Shipment']['id']?>" class="editButton">Edit</button>
		</td>

		<td>
			<?php
			echo $this->element('isEmptyDate', array('date'=>$shipment['Shipment']['date_arrived']));
			?>
		</td>

		<td>
			<?php echo $shipmentTypeShort[$shipment['Shipment']['type']]; ?>
		</td>

		<td>
			<?php foreach($shipment['Principle'] as $principle):?>
			    <? if(!empty($principle['short_name'])) {
				echo $html->link($principle['short_name'], array('controller'=>'principles','action'=>'view',$principle['id']));
			    }
			    else {
				echo $html->link($principle['name'], array('controller'=>'principles','action'=>'view',$principle['id']));
			    }
			    ?>

		    <br>
			<?php endforeach;?>
		</td>

		<td>
			<?php foreach($shipment['PurchaseOrder'] as $po):?>
			    <?=$html->link($po['title'], array('controller'=>'purchase_orders', 'action'=>'view', $po['id']));?>
		    <br>
			<?endforeach;?>
		</td>


		<td>
			<?php echo $shipment['Shipment']['box_count']; ?>
		</td>

		<td  class="boxDimensions">

			<?php

			$totalWeight = 0;
			$weightString = '';

			foreach($shipment['Box'] as $box):?>
			    <?=$box['length']?>x<?=$box['width']?>x<?=$box['height']?><br>
			    <?
			    $weightString .= $box['weight'].' kg <br>';
			    $totalWeight += $box['weight']; ?>
			<?php endforeach;?>

		</td>

		<td>    <?

			$boxCount = $shipment['Shipment']['box_count'];
			if($boxCount > 1) {
			    echo $weightString;
			    echo '<hr>';

			}?>
			<? if($boxCount != 0): ?>
		    <span class="totalWeight"><?=$totalWeight;?> kg</span></td>
		    <? endif;?>
		<td>
			<?php echo $html->link($shipment['FreightForwarder']['name'], array('controller' => 'freight_forwarders', 'action' => 'view', $shipment['FreightForwarder']['id'])); ?>
		</td>


		<td>
			<?php echo $shipment['Shipment']['airway_bill']; ?>
		</td>
		<td>
			<?php echo $shipment['Shipment']['comments']; ?>
		</td>
		<td class="actions">
		    <button id="<?=$shipment['Shipment']['id']?>" class="editButton">Edit</button>
		</td>
	    </tr>
	    <?php endforeach; ?>
	</table>