Fixed bug in removing attachments. Fixed editing attachmetns. Closes #66
This commit is contained in:
parent
0793d5b088
commit
a73fd66440
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -139,9 +139,11 @@ class DocumentsController extends AppController {
|
|||
|
||||
function removeAttachments() {
|
||||
$this->layout = 'ajax';
|
||||
|
||||
foreach($this->data as $attachment) {
|
||||
$this->Document->DocumentAttachment->delete($attachment);
|
||||
}
|
||||
echo 'SUCCESS';
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
0
app/webroot/js/document_attachments.js
Normal file → Executable file
Loading…
Reference in a new issue