<h2>Invoice: <?=$document['Invoice']['title']?> for <?=$html->link($enquiry['Customer']['name'], '/customers/view/'.$enquiry['Customer']['id']);?></h2>
<h2>Job: <?=$html->link($invoice['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $invoice['Job']['id']));?></h2>

<div id="flashMessage" class="message">
</div>
<div class="docButtons">
    <button id="paymentReceived">Enter Payment Received</button>
	<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 Invoice to customer</button>  
</div>

<div class="docOperations">
	<h3>Create new Documents based on this</h3>
	<ul class="document-buttons">
				
		<li>
			<button id="createPackingList" class="button-link" data-href="/documents/newDocument/packingList/<?=$enquiry['Enquiry']['id']?>/<?=$invoice['Job']['id']?>/<?=$document['Document']['id']?>">Create Packing List</button>
		
		</li>
	</ul>
</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('Invoice.id');
	echo $form->input('Invoice.job_id');
	echo $form->input('Invoice.currency_id');
	echo $form->input('Invoice.issue_date');
	echo $form->input('Invoice.due_date');

	echo $form->input('billing_address_id', array('div' => 'addressradio', 'legend' => 'Select Billing Address', 'options' => $billing_addresses_list, 'type' => 'radio', 'class'=>'billing_address'));
	echo $form->input('Document.bill_to');
	
	
	echo $form->input('shipping_address_id', array('div' => 'addressradio','legend' => 'Select Shipping Address', 'options' => $shipping_addresses_list, 'type' => 'radio', 'class' => 'shipping_address'));
	echo $form->input('Document.ship_to');



	echo $form->input('Invoice.ship_via');
	echo $form->input('Invoice.fob');
	echo $form->input('Document.shipping_details', array('id'=>'shippingDetails'));
	echo $form->end(array('label'=>'Save Invoice Details', 'id'=>'saveInvoiceButton'));
	?>
    </fieldset>
</div>


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

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

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