<div class="jobs index">
    <h2><?php __('Jobs');?></h2>
    <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('created');?></th>
            <th><?php echo $paginator->sort('Job Number');?></th>
            <th><?php echo $paginator->sort('enquiry_id');?></th>
            <th><?php echo $paginator->sort('comments');?></th>
            <th><?php echo $paginator->sort('date_order_received');?></th>
            <th><?php echo $paginator->sort('date_order_placed_on_principle');?></th>
            <th><?php echo $paginator->sort('date_scheduled_ex_works');?></th>
            <th><?php echo $paginator->sort('date_order_sent_to_customer');?></th>
            <th><?php echo $paginator->sort('customer_order_number');?></th>
            <th><?php echo $paginator->sort('domestic_freight_paid_by');?></th>
            <th><?php echo $paginator->sort('sale_category');?></th>
            <th><?php echo $paginator->sort('shipment_category');?></th>
            <th class="actions"><?php __('Actions');?></th>
        </tr>
        <?php
        $i = 0;
        foreach ($jobs as $job):
            $class = null;
            if ($i++ % 2 == 0) {
                $class = ' class="altrow"';
            }
            ?>
        <tr<?php echo $class;?>>

            <td>
                    <?php echo $job['Job']['created']; ?>
            </td>
            <td>
                    <?php echo $job['Job']['title']; ?>
            </td>
            <td>
                    <?php echo $html->link($job['Enquiry']['title'], array('controller' => 'enquiries', 'action' => 'view', $job['Enquiry']['id'])); ?>
            </td>
            <td>
                    <?php echo $job['Job']['comments']; ?>
            </td>
            <td>
                    <?php echo $job['Job']['date_order_received']; ?>
            </td>
            <td>
                    <?php echo isEmptyDate($job['Job']['date_order_placed_on_principle']);
                    
                    ?>
            </td>
            <td>
                    <?php echo isEmptyDate($job['Job']['date_scheduled_ex_works']); ?>
            </td>
            <td>
                    <?php echo isEmptyDate($job['Job']['date_order_sent_to_customer']); ?>
            </td>
            <td>
                    <?php echo $job['Job']['customer_order_number']; ?>
            </td>
            <td>
                    <?php echo $job['Job']['domestic_freight_paid_by']; ?>
            </td>
            <td>
                    <?php echo $job['Job']['sale_category']; ?>
            </td>
            <td>
                    <?php echo $job['Job']['shipment_category']; ?>
            </td>
            <td class="actions">
                    <?php echo $html->link(__('View', true), array('action' => 'view', $job['Job']['id'])); ?>
                    <?php echo $html->link(__('Edit', true), array('action' => 'edit', $job['Job']['id'])); ?>
                    <?php echo $html->link(__('Delete', true), array('action' => 'delete', $job['Job']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $job['Job']['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 Job', true), array('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>


<?php

    function isEmptyDate($date) {
    if($date == "0000-00-00") {
        return "-";
    }
    else {
        return $date;
    }
}
?>