Fixed bug in removing attachments. Fixed editing attachmetns. Closes #66

This commit is contained in:
Karl Cordes 2013-03-29 12:38:50 +11:00
parent 0793d5b088
commit a73fd66440
7 changed files with 19 additions and 15 deletions

View file

@ -43,7 +43,7 @@ Router::connect('/', array('controller' => 'enquiries', 'action' => 'index'));
* Then we connect url '/test' to our test controller. This is helpful in
* developement.
*/
Router::connect('/tests', array('controller' => 'tests', 'action' => 'index'));
# Router::connect('/tests', array('controller' => 'tests', 'action' => 'index'));
Router::connect('/admin', array('controller'=>'pages','action'=>'display','admin')); //Display the admin page

View file

@ -43,8 +43,7 @@ class AttachmentsController extends AppController {
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
$attachment = $this->Attachment->process_attachment($this->data);
if ($this->Attachment->save($attachment)) {
if ($this->Attachment->save($this->data)) {
$this->Session->setFlash(__('The Attachment has been saved', true));
$this->redirect(array('action'=>'index'));
} else {
@ -54,9 +53,8 @@ class AttachmentsController extends AppController {
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'));
$this->set(compact('principles'));
}
function delete($id = null) {

View file

@ -138,10 +138,12 @@ class DocumentsController extends AppController {
}
function removeAttachments() {
$this->layout = 'ajax';
foreach($this->data as $attachment) {
$this->layout = 'ajax';
foreach($this->data as $attachment) {
$this->Document->DocumentAttachment->delete($attachment);
}
}
echo 'SUCCESS';
}

View file

@ -6,9 +6,13 @@
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');
?>
<div class="input text">
<label>Filename</label>
<?php echo $this->data['Attachment']['filename']; ?>
</div>
<?php
echo $form->input('description');
echo $form->input('archived');
?>

View file

@ -1,4 +1,4 @@
<?php if (file_exists($attachment['Attachment']['filename'])) {
<?php if (file_exists($attachment['Attachment']['file'])) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($attachment['Attachment']['filename']));
@ -6,10 +6,10 @@
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($attachment['Attachment']['filename']));
header('Content-Length: ' . filesize($attachment['Attachment']['file']));
ob_clean();
flush();
readfile($attachment['Attachment']['filename']);
readfile($attachment['Attachment']['file']);
exit;
}

View file

@ -10,7 +10,7 @@
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 $form->input('DocumentAttachment.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>

0
app/webroot/js/document_attachments.js Normal file → Executable file
View file