<?php
echo $javascript->link('ckeditor/ckeditor');
echo $javascript->link('ckeditor/adapters/jquery');

echo $javascript->link('document_add_edit');
echo $javascript->link('document_attachments');

?>
<?=$this->element('pdf_created_message'); ?>

<?
echo $this->element($docTypeElement);
?>

<button class="addLineItem">Add Line Item</button>
<div id="lineItems">
</div>
<button class="addLineItem">Add Line Item</button>


<div id="pageContentFactory">
<?
echo $form->input("DocPage.content", array('class'=>'page', 'label'=>'Page', 'between'=>'<button class="removePage">X</button>'));
?>
</div>


<div id="addLineItemModal" title="Add Line Item">
</div>

<div id="editLineItemModal" title="Edit Line Item">
</div>

<div id="Attachments" title="Attachments">
  <h2 class="document-attachments">Attachments</h2><button id="addAttachment">Add Attachment</button>
     
  <div id="attachments-table">
  <table>
    <thead>
    <th></th>
    <th>Filename</th>
    <th>Name</th>
    <th>Desc</th>
    </thead>
    <tbody>
<?php 
foreach($attachments as $index => $attachment) {
?>
	<tr>
	<?php echo $form->input('DocumentAttachment.document_id', 
	array('type'=>'hidden', 'value'=> $document['Document']['id'])); ?>
    <td><?php echo $form->input("DocumentAttachment.{$index}.id", 
    array('type'=>'checkbox', 
                   'value'=> $attachment['DocumentAttachment']['id'], 
                   'label' => false, 'class'=>'documentAttachment-checkbox')); ?></td>
    <td>
      <?php echo $html->link($attachment['Attachment']['filename'], '/attachments/view/'.$attachment['Attachment']['id']); ?>
    </td>  
    <td><?php echo $attachment['Attachment']['name']; ?></td>
    <td><?php echo $attachment['Attachment']['description']; ?></td>
</tr>

  <?php } ?>
  </tbody> 
  </table>
  </div> <!-- #attachments-table -->

  <button id="removeAttachments">Remove Selected</button>
</div>

<div id="addAttachmentModal" title="Add Attachment">
  <?php echo $this->element('add_attachment'); ?>
</div>



<div id="QuoteDetails" title="Edit Quote Details">

</div>


<div id="InvoiceDetails">

</div>

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

