<h2>Purchase Order: <?=$document['PurchaseOrder']['title']?></h2>

<div id="flashMessage" class="message">
</div>
<div class="docButtons">
	<button id="pdfDocButton" data-url="/documents/pdf/<?= $document['Document']['id']; ?>">Generate PDF</button>  
	<button id="emailDocButton" data-url="/documents/email_pdf/<?= $document['Document']['id']; ?>">Email PurchaseOrder to Principle</button> 
</div>



<div id="invoiceDetails" class="documentDetails">
	<fieldset>
	<? echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
	echo $form->input('Document.id');
	echo $form->input('PurchaseOrder.id');
	echo $form->input('PurchaseOrder.principle_id');
	echo $form->input('PurchaseOrder.principle_reference');
	echo $form->input('PurchaseOrder.description', array('type'=>'text'));
?>
<div id="job" class="hiddenDefault">
    <?
    echo $form->input('job', array('id'=>'job_autocomplete', array('label'=>'Job (start typing and select from the list)')));
    ?>
    <span class="moreInfo">All Items from the OA for this Job will be added automatically to the PO.</span>

    <ul id="jobsList" class="habtmList">
	<?php foreach($purchaseOrder['Job'] as $job):?>
	<li id="JobID_<?=$job['id']?>">
	    <button class="removeFromList">X</button>
		<?=$job['title'];?>
	    <input type="hidden" name="data[PurchaseOrder][Job][]" value="<?=$job['id']?>">
	</li>
	<?php endforeach?>
    </ul>
</div>

<?php
	echo $form->input('PurchaseOrder.jobs_text');?>
	<span class="moreInfo">Jobs added above will appear in this field automatically.<br>You can add other things like CMC STOCK.</span>
<?php	
	echo $form->input('PurchaseOrder.currency_id');
	echo $form->input('PurchaseOrder.dispatch_date');
	echo $form->input('PurchaseOrder.date_arrived'); //ARGH. Really Karl?

	echo $form->input('PurchaseOrder.ordered_from');
	echo $form->input('PurchaseOrder.description');

	echo $form->input('PurchaseOrder.dispatch_by');

	echo $form->input('PurchaseOrder.deliver_to');
	echo $form->input('PurchaseOrder.shipping_instructions');


	echo $form->end(array('label'=>'Save PurchaseOrder Details', 'id'=>'savePurchaseOrderButton'));
	?>
    </fieldset>
</div>


<span id="purchaseOrderID" style="display: none;"><?=$document['PurchaseOrder']['id']?></span>

<? //debug($this->data);?>
<? //debug($enquiry);?>
<?php  //debug($document);?>
<?php //debug($docType);?>

<? //debug($invoice); ?>
