
<h2><?=$docTypeFullName?>: <?=$html->link($enquiry['Enquiry']['title'], array('controller'=>'enquiries','action'=>'view',$enquiry['Enquiry']['id']));?>
    <?
    if($document['Document']['revision'] > 0) {
	echo "Revision {$document['Document']['revision']} ";
    }
    ?>
    for
    <?=$html->link($enquiry['Customer']['name'], array('controller'=>'customers','action'=>'view',$enquiry['Customer']['id']));?>
</h2>

<?

echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
echo $form->input('Document.id');
?>

<div class="docButtons">
    <button id="generateFirstPage">Generate first fage</button>
    <button id="addPage">Add Content Page</button>
    <button id="editQuoteDetails">View/Edit Quote details</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 Quote to customer</button>  
</div>

<div id="flashMessage" class="message">
</div>


<div class="docOperations">
	<h3>Create new Documents based on this</h3>
	<ul class="document-buttons">
		<li>
			<button id="createOA">Create Order Acknowledgement</button>
		</li>

		<li>
		<button id="createInvoice" data-href="/documents/newDocument/invoice/<?=$enquiry['Enquiry']['id']?>/0/<?=$document['Document']['id']?>">Create Invoice</button>
		</li>
	</ul>
</div>

<div class="pages">
    <?php
    $first = true;

    foreach($document['DocPage'] as $key => $page):?>

	<? if($first == true) {
	    $class = 'page firstPage';
	    $first = false;
	}
	else {
	    $class = 'page';
	}
	?>

    <div class="docPage">
	    <?=$form->input("DocPage.{$key}.id");?>
	    <?=$form->input("DocPage.{$key}.content", array('class'=>$class, 'label'=>'Page '.$page['page_number'], 'between'=>'<button class="removePage">X</button>'));?>
	    <?=$form->input("DocPage.{$key}.document_id", array('type'=>'hidden'));?>
	    <?=$form->input("DocPage.{$key}.page_number", array('type'=>'hidden'));?>
    </div>

    <?endforeach?>
</div>
<div class="input submit"><button id="savePages">Save Pages</button></div>
<?=$form->end();?>

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

<div id="commCommentsInitialString" style="display:none;">
    <u>Commercial Comments:</u><br />
    <span style="font-size: small;">The prices quoted are subject to our Standard Terms and Conditions of Sale dated 1/7/06 that is attached and remain firm unless specifically varied in writing. The prices above are based on the following:</span>
    <ol class="commList">
    </ol>
    <span style="font-size: small;">ANY VARIATIONS ON ITEMS 5. TO 7. WILL BE TO YOUR ACCOUNT. THIS QUOTATION IS BASED ON QUANTITIES STATED AND IS SUBJECT TO CHANGE IF QUANTITIES VARY.</span>
</div>

<? //For re-Generating the first page ?>
<div id="contactFirstName" style="display: none;"><?=$enquiry['Contact']['first_name'];?></div>



<div id="addJobConfirmation" title="Create New Job and Order Acknowledgment">
    <span>This will create an Order Acknowledgement based on this Quote</span><br>
    <span>The Enquiry will also be marked as "Job Won - Order Placed"</span><br><br>
    <span>You can create a new Job now, or add it to an existing Job later</span><br>
 
    <? echo $form->create('Document',array('type'=>'post','action'=>'convert_to_oa'));
	echo $form->input('Document.id');
	echo $form->input('Job.create_new_job', array('type'=>'select', 'options'=> array('No', 'Yes')));
	echo $form->input('Job.customer_order_number');
    echo $form->end();
    ?>
</div>

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