Merge branch 'feature/DocumentAttachments' into release
This commit is contained in:
commit
49fa68e2cf
|
|
@ -24,7 +24,7 @@ class AppController extends Controller {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//WTF. Why is this here??
|
||||||
function isAuthorized() {
|
function isAuthorized() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
74
controllers/attachments_controller.php
Normal file
74
controllers/attachments_controller.php
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?php
|
||||||
|
class AttachmentsController extends AppController {
|
||||||
|
|
||||||
|
var $name = 'Attachments';
|
||||||
|
var $helpers = array('Html', 'Form','Number','Time');
|
||||||
|
|
||||||
|
function index() {
|
||||||
|
$this->Attachment->recursive = 1;
|
||||||
|
$this->set('attachments', $this->paginate());
|
||||||
|
}
|
||||||
|
|
||||||
|
function view($id = null) {
|
||||||
|
if (!$id) {
|
||||||
|
$this->Session->setFlash(__('Invalid Attachment.', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
$this->set('attachment', $this->Attachment->read(null, $id));
|
||||||
|
$this->layout = 'pdf';
|
||||||
|
}
|
||||||
|
|
||||||
|
function add() {
|
||||||
|
if (!empty($this->data)) {
|
||||||
|
|
||||||
|
$attachment = $this->Attachment->process_attachment($this->data);
|
||||||
|
|
||||||
|
|
||||||
|
$this->Attachment->create();
|
||||||
|
|
||||||
|
if ($this->Attachment->save($attachment)) {
|
||||||
|
$this->Session->setFlash(__('The Attachment has been saved', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
} else {
|
||||||
|
$this->Session->setFlash(__('The Attachment could not be saved. Please, try again.', true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$principles = $this->Attachment->Principle->find('list');
|
||||||
|
$this->set(compact('products', 'principles'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function edit($id = null) {
|
||||||
|
if (!$id && empty($this->data)) {
|
||||||
|
$this->Session->setFlash(__('Invalid Attachment', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
if (!empty($this->data)) {
|
||||||
|
$attachment = $this->Attachment->process_attachment($this->data);
|
||||||
|
if ($this->Attachment->save($attachment)) {
|
||||||
|
$this->Session->setFlash(__('The Attachment has been saved', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
} else {
|
||||||
|
$this->Session->setFlash(__('The Attachment could not be saved. Please, try again.', true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($this->data)) {
|
||||||
|
$this->data = $this->Attachment->read(null, $id);
|
||||||
|
}
|
||||||
|
$products = $this->Attachment->Product->find('list');
|
||||||
|
$principles = $this->Attachment->Principle->find('list');
|
||||||
|
$this->set(compact('products','principles'));
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete($id = null) {
|
||||||
|
if (!$id) {
|
||||||
|
$this->Session->setFlash(__('Invalid id for Attachment', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
if ($this->Attachment->del($id)) {
|
||||||
|
$this->Session->setFlash(__('Attachment deleted', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
File diff suppressed because it is too large
Load diff
77
models/attachment.php
Normal file
77
models/attachment.php
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
class Attachment extends AppModel {
|
||||||
|
|
||||||
|
var $name = 'Attachment';
|
||||||
|
var $validate = array(
|
||||||
|
'principle_id' => array('numeric'),
|
||||||
|
'name' => array('notempty'),
|
||||||
|
'type' => array('notempty'),
|
||||||
|
'size' => array('numeric'),
|
||||||
|
'archived' => array('numeric'),
|
||||||
|
);
|
||||||
|
|
||||||
|
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
||||||
|
var $belongsTo = array(
|
||||||
|
'Principle' => array(
|
||||||
|
'className' => 'Principle',
|
||||||
|
'foreignKey' => 'principle_id',
|
||||||
|
'conditions' => '',
|
||||||
|
'fields' => '',
|
||||||
|
'order' => ''
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
var $hasMany = array(
|
||||||
|
'DocumentAttachment' => array(
|
||||||
|
'className' => 'DocumentAttachment',
|
||||||
|
'foreignKey' => 'attachment_id'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Based on comment 8 from: http://bakery.cakephp.org/articles/view/improved-advance-validation-with-parameters
|
||||||
|
|
||||||
|
function isUploadedFile($params){
|
||||||
|
$val = array_shift($params);
|
||||||
|
if ((isset($val['error']) && $val['error'] == 0) ||
|
||||||
|
(!empty( $val['tmp_name']) && $val['tmp_name'] != 'none')) {
|
||||||
|
return is_uploaded_file($val['tmp_name']);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Passed a PHP upload
|
||||||
|
* array('name', 'type', 'tmp_name', 'error' 'size').
|
||||||
|
*
|
||||||
|
* Move the uploaded file to the storage directory
|
||||||
|
* and return a cake array for insertion.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
function process_attachment($attachment) {
|
||||||
|
|
||||||
|
$upload = $attachment['Attachment']['file'];
|
||||||
|
|
||||||
|
$new_filename = Configure::read('attachments_directory').time().$upload['name'];
|
||||||
|
|
||||||
|
$moved = move_uploaded_file($upload['tmp_name'], $new_filename);
|
||||||
|
|
||||||
|
if($moved) {
|
||||||
|
$attachment['Attachment']['filename'] = $upload['name'];
|
||||||
|
$attachment['Attachment']['file'] = $new_filename;
|
||||||
|
$attachment['Attachment']['size'] = $upload['size'];
|
||||||
|
$attachment['Attachment']['type'] = $upload['type'];
|
||||||
|
return $attachment;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
die("Error! Unable to move the uploaded file");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
@ -28,7 +28,14 @@ class Document extends AppModel {
|
||||||
'className'=> 'DocPage',
|
'className'=> 'DocPage',
|
||||||
'foreignKey' => 'document_id',
|
'foreignKey' => 'document_id',
|
||||||
'order' => 'DocPage.page_number ASC'
|
'order' => 'DocPage.page_number ASC'
|
||||||
)
|
),
|
||||||
|
|
||||||
|
'DocumentAttachment' => array(
|
||||||
|
'className'=> 'DocumentAttachment',
|
||||||
|
'foreignKey' => 'document_id',
|
||||||
|
'order' => 'DocumentAttachment.id ASC'
|
||||||
|
),
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -53,7 +60,6 @@ class Document extends AppModel {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
//So much refactoring possible on this.
|
//So much refactoring possible on this.
|
||||||
function getCurrency($document) {
|
function getCurrency($document) {
|
||||||
|
|
||||||
|
|
@ -170,4 +176,4 @@ class Document extends AppModel {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
28
models/document_attachment.php
Normal file
28
models/document_attachment.php
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
class DocumentAttachment extends AppModel {
|
||||||
|
|
||||||
|
var $name = 'DocumentAttachment';
|
||||||
|
|
||||||
|
var $useTable = 'document_attachments';
|
||||||
|
|
||||||
|
|
||||||
|
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
||||||
|
var $belongsTo = array(
|
||||||
|
'Document' => array(
|
||||||
|
'className' => 'Document',
|
||||||
|
'foreignKey' => 'document_id',
|
||||||
|
'conditions' => '',
|
||||||
|
'fields' => '',
|
||||||
|
'order' => ''
|
||||||
|
),
|
||||||
|
'Attachment' => array(
|
||||||
|
'className' => 'Attachment',
|
||||||
|
'foreignKey' => 'attachment_id',
|
||||||
|
'conditions' => '',
|
||||||
|
'fields' => '',
|
||||||
|
'order' => ''
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
14
views/attachments/add.ctp
Normal file
14
views/attachments/add.ctp
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<div class="attachments form">
|
||||||
|
<?php echo $form->create('Attachment', array('type'=>'file'));?>
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php __('Add Attachment');?></legend>
|
||||||
|
<?php
|
||||||
|
echo $form->input('principle_id');
|
||||||
|
echo $form->input('name');
|
||||||
|
echo $form->file('file');
|
||||||
|
echo $form->input('description');
|
||||||
|
echo $form->input('archived');
|
||||||
|
?>
|
||||||
|
</fieldset>
|
||||||
|
<?php echo $form->end('Submit');?>
|
||||||
|
</div>
|
||||||
23
views/attachments/edit.ctp
Normal file
23
views/attachments/edit.ctp
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<div class="attachments form">
|
||||||
|
<?php echo $form->create('Attachment');?>
|
||||||
|
<fieldset>
|
||||||
|
<legend><?php __('Edit Attachment');?></legend>
|
||||||
|
<?php
|
||||||
|
echo $form->input('id');
|
||||||
|
echo $form->input('principle_id');
|
||||||
|
echo $form->input('name');
|
||||||
|
echo $form->input('filename');
|
||||||
|
echo $form->input('type');
|
||||||
|
echo $form->input('size');
|
||||||
|
echo $form->input('description');
|
||||||
|
echo $form->input('archived');
|
||||||
|
?>
|
||||||
|
</fieldset>
|
||||||
|
<?php echo $form->end('Submit');?>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<ul>
|
||||||
|
<li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('Attachment.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('Attachment.id'))); ?></li>
|
||||||
|
<li><?php echo $html->link(__('List Attachments', true), array('action' => 'index'));?></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
75
views/attachments/index.ctp
Normal file
75
views/attachments/index.ctp
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
<div class="attachments index">
|
||||||
|
<h2><?php __('Attachments');?></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('id');?></th>
|
||||||
|
<th><?php echo $paginator->sort('principle_id');?></th>
|
||||||
|
<th><?php echo $paginator->sort('created');?></th>
|
||||||
|
<th><?php echo $paginator->sort('name');?></th>
|
||||||
|
<th><?php echo $paginator->sort('type');?></th>
|
||||||
|
<th><?php echo $paginator->sort('size');?></th>
|
||||||
|
<th><?php echo $paginator->sort('description');?></th>
|
||||||
|
<th class="actions"><?php __('Actions');?></th>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
$i = 0;
|
||||||
|
foreach ($attachments as $attachment):
|
||||||
|
$class = null;
|
||||||
|
if ($i++ % 2 == 0) {
|
||||||
|
$class = ' class="altrow"';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<tr<?php echo $class;?>>
|
||||||
|
<td>
|
||||||
|
<?php echo $attachment['Attachment']['id']; ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
if($attachment['Principle']['short_name']) {
|
||||||
|
echo $html->link($attachment['Principle']['short_name'], '/principles/view/'.$attachment['Principle']['id']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo $html->link($attachment['Principle']['name'], '/principles/view/'.$attachment['Principle']['id']);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $time->nice($attachment['Attachment']['created']); ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $attachment['Attachment']['name']; ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $attachment['Attachment']['type']; ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $number->toReadAbleSize($attachment['Attachment']['size']); ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<?php echo $attachment['Attachment']['description']; ?>
|
||||||
|
</td>
|
||||||
|
<td class="actions">
|
||||||
|
<?php echo $html->link(__('View', true), array('action' => 'view', $attachment['Attachment']['id'])); ?>
|
||||||
|
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $attachment['Attachment']['id'])); ?>
|
||||||
|
<?php echo $html->link(__('Delete', true), array('action' => 'delete', $attachment['Attachment']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $attachment['Attachment']['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 Attachment', true), array('action' => 'add')); ?></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
17
views/attachments/view.ctp
Normal file
17
views/attachments/view.ctp
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?php if (file_exists($attachment['Attachment']['filename'])) {
|
||||||
|
header('Content-Description: File Transfer');
|
||||||
|
header('Content-Type: application/octet-stream');
|
||||||
|
header('Content-Disposition: attachment; filename='.basename($attachment['Attachment']['filename']));
|
||||||
|
header('Content-Transfer-Encoding: binary');
|
||||||
|
header('Expires: 0');
|
||||||
|
header('Cache-Control: must-revalidate');
|
||||||
|
header('Pragma: public');
|
||||||
|
header('Content-Length: ' . filesize($attachment['Attachment']['filename']));
|
||||||
|
ob_clean();
|
||||||
|
flush();
|
||||||
|
readfile($attachment['Attachment']['filename']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
23
views/documents/get_attachments.ctp
Normal file
23
views/documents/get_attachments.ctp
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<th></th>
|
||||||
|
<th>Filename</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Desc</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach($attachments as $attachment) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $form->input('DocumentAttachment.id', array('type'=>'checkbox', 'value'=> $attachment['DocumentAttachment']['id'], 'label' => false)); ?></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>
|
||||||
24
views/documents/get_attachments_by_principle.ctp
Normal file
24
views/documents/get_attachments_by_principle.ctp
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<th>Add</td>
|
||||||
|
<th>Filename</th>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Desc</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach($attachments as $attachment) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<input name="data[DocumentAttachment][attachment_id][]" type="checkbox" value="<?php echo $attachment['Attachment']['id']; ?>">
|
||||||
|
</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>
|
||||||
0
views/documents/remove_attachments.ctp
Normal file
0
views/documents/remove_attachments.ctp
Normal file
0
views/documents/save_attachments.ctp
Normal file
0
views/documents/save_attachments.ctp
Normal file
|
|
@ -3,6 +3,7 @@ echo $javascript->link('ckeditor/ckeditor');
|
||||||
echo $javascript->link('ckeditor/adapters/jquery');
|
echo $javascript->link('ckeditor/adapters/jquery');
|
||||||
|
|
||||||
echo $javascript->link('document_add_edit');
|
echo $javascript->link('document_add_edit');
|
||||||
|
echo $javascript->link('document_attachments');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<?=$this->element('pdf_created_message'); ?>
|
<?=$this->element('pdf_created_message'); ?>
|
||||||
|
|
@ -18,9 +19,9 @@ echo $this->element($docTypeElement);
|
||||||
|
|
||||||
|
|
||||||
<div id="pageContentFactory">
|
<div id="pageContentFactory">
|
||||||
<?
|
<?
|
||||||
echo $form->input("DocPage.content", array('class'=>'page', 'label'=>'Page', 'between'=>'<button class="removePage">X</button>'));
|
echo $form->input("DocPage.content", array('class'=>'page', 'label'=>'Page', 'between'=>'<button class="removePage">X</button>'));
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -30,6 +31,47 @@ echo $this->element($docTypeElement);
|
||||||
<div id="editLineItemModal" title="Edit Line Item">
|
<div id="editLineItemModal" title="Edit Line Item">
|
||||||
</div>
|
</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>
|
||||||
|
<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 id="QuoteDetails" title="Edit Quote Details">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -46,4 +88,5 @@ echo $this->element($docTypeElement);
|
||||||
|
|
||||||
<?php //debug($enquiry);?>
|
<?php //debug($enquiry);?>
|
||||||
|
|
||||||
<?php // debug($document);?>
|
<?php // debug($document);?>
|
||||||
|
<?php debug($attachments);?>
|
||||||
|
|
|
||||||
14
views/elements/add_attachment.ctp
Normal file
14
views/elements/add_attachment.ctp
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
<? echo $form->create('DocumentAttachment', array('default'=>false)); ?>
|
||||||
|
<? echo $form->input('DocumentAttachment.document_id', array('type'=>'hidden', 'value'=> $document['Document']['id'])); ?>
|
||||||
|
<? echo $form->input('DocumentAttachment.principle_id', array('id'=>'attachmentPrincipleSelect', 'label'=>'Principle','empty'=>'Select Principle'));?>
|
||||||
|
|
||||||
|
<div id="principleAttachments">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?
|
||||||
|
echo $form->end();
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -20,6 +20,7 @@ echo $form->input('Document.id');
|
||||||
<button id="addPage">Add Content Page</button>
|
<button id="addPage">Add Content Page</button>
|
||||||
<button id="editQuoteDetails">View/Edit Quote Details</button>
|
<button id="editQuoteDetails">View/Edit Quote Details</button>
|
||||||
<?=$html->link('Generate PDF of this Quote', '/documents/pdf/'.$document['Document']['id']);?>
|
<?=$html->link('Generate PDF of this Quote', '/documents/pdf/'.$document['Document']['id']);?>
|
||||||
|
<?=$html->link('Email this Quote', '/documents/email_pdf/'.$document['Document']['id']);?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="flashMessage" class="message">
|
<div id="flashMessage" class="message">
|
||||||
|
|
|
||||||
|
|
@ -138,13 +138,14 @@
|
||||||
|
|
||||||
|
|
||||||
<div class="related">
|
<div class="related">
|
||||||
<h3><?php if($enquiry['Enquiry']['quote_count'] > 1) {
|
<h3><?php if($enquiry['Enquiry']['quote_count'] > 1) {
|
||||||
echo $enquiry['Enquiry']['quote_count'].' Quotes for this Enquiry';
|
$word = ' Quotes';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo $enquiry['Enquiry']['quote_count'].' Quote for this Enquiry';
|
$word = ' Quote';
|
||||||
|
}
|
||||||
}?>
|
echo $enquiry['Enquiry']['quote_count'].$word;
|
||||||
|
?>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<? echo $this->element('quote_table', $quotes);
|
<? echo $this->element('quote_table', $quotes);
|
||||||
|
|
@ -350,4 +351,4 @@
|
||||||
|
|
||||||
<?php debug($order_acknowledgements); ?>
|
<?php debug($order_acknowledgements); ?>
|
||||||
<?php // debug($jobs);?>
|
<?php // debug($jobs);?>
|
||||||
<?php //debug($emails); ?>
|
<?php //debug($emails); ?>
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,7 @@ if ($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['a
|
||||||
<li><?php echo $html->link('Principles', '/principles/index'); ?>
|
<li><?php echo $html->link('Principles', '/principles/index'); ?>
|
||||||
<ul>
|
<ul>
|
||||||
<li><?php echo $html->link('Principle Index', '/principles/index'); ?></li>
|
<li><?php echo $html->link('Principle Index', '/principles/index'); ?></li>
|
||||||
|
<li><?php echo $html->link('Attachments', '/attachments/index'); ?></li>
|
||||||
<li class="last"><?php echo $html->link('Add Principle', '/principles/add'); ?></li>
|
<li class="last"><?php echo $html->link('Add Principle', '/principles/add'); ?></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -1578,6 +1578,7 @@ div.address span {
|
||||||
}
|
}
|
||||||
|
|
||||||
table.lineItems {
|
table.lineItems {
|
||||||
|
margin-top: 0.2em;
|
||||||
border: 1px solid;
|
border: 1px solid;
|
||||||
border-spacing: 0px;
|
border-spacing: 0px;
|
||||||
}
|
}
|
||||||
|
|
@ -1647,6 +1648,18 @@ div.warning {
|
||||||
|
|
||||||
|
|
||||||
tr.no_items {
|
tr.no_items {
|
||||||
font-size: 2em;
|
font-size: 1.5em;
|
||||||
padding: 0.5em;
|
padding: 1em;
|
||||||
|
}
|
||||||
|
#Attachments {
|
||||||
|
margin-top: 1.5em;
|
||||||
|
}
|
||||||
|
h2.document-attachments {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#attachments-list {
|
||||||
|
margin-top: 0.5em;
|
||||||
|
list-style: none;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
66
webroot/js/document_attachments.js
Normal file
66
webroot/js/document_attachments.js
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
$(function() {
|
||||||
|
var documentID = $("#documentID").html();
|
||||||
|
|
||||||
|
|
||||||
|
$("#addAttachment").click(function() {
|
||||||
|
$("#addAttachmentModal").dialog('open');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$("#addAttachmentModal").dialog({
|
||||||
|
autoOpen: false,
|
||||||
|
height: 900,
|
||||||
|
width: 600,
|
||||||
|
modal: true,
|
||||||
|
buttons: {
|
||||||
|
"Add Attachment": function() {
|
||||||
|
|
||||||
|
var attachmentInputs = $('#DocumentAttachmentAddForm').find('input');
|
||||||
|
|
||||||
|
$.post('/documents/saveAttachments', attachmentInputs, function(data) {
|
||||||
|
$("#addAttachmentModal").dialog( "close" );
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
Cancel: function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
close: function() {
|
||||||
|
loadAttachments();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#attachmentPrincipleSelect").change(function() {
|
||||||
|
var principleID = $(this).val();
|
||||||
|
loadPrincipleAttachments(principleID);
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#removeAttachments").click(function() {
|
||||||
|
removeAttachments();
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadPrincipleAttachments(id) {
|
||||||
|
$.get('/documents/getAttachmentsByPrinciple/'+id, function(attachments) {
|
||||||
|
$('#principleAttachments').html(attachments);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadAttachments() {
|
||||||
|
$.get('/documents/getAttachments/'+documentID, function(attachments) {
|
||||||
|
$("#attachments-table").html(attachments);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeAttachments() {
|
||||||
|
var selectedAttachments = $(".documentAttachment-checkbox:checked");
|
||||||
|
$.post('/documents/removeAttachments', selectedAttachments, function(data) {
|
||||||
|
loadAttachments();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue