Removed attachment deleting. Attachments files can now be edited
This commit is contained in:
parent
800cec1a0d
commit
356b9ef9bf
|
|
@ -5,11 +5,11 @@ class AttachmentsController extends AppController {
|
|||
var $helpers = array('Html', 'Form','Number','Time');
|
||||
|
||||
|
||||
var $paginate = array(
|
||||
var $paginate = array(
|
||||
|
||||
'contain' => false,
|
||||
'limit' => 5000,
|
||||
);
|
||||
'contain' => false,
|
||||
'limit' => 5000,
|
||||
);
|
||||
|
||||
|
||||
function index() {
|
||||
|
|
@ -54,14 +54,31 @@ class AttachmentsController extends AppController {
|
|||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
if (!empty($this->data)) {
|
||||
if ($this->Attachment->save($this->data)) {
|
||||
$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));
|
||||
//Process editing the PDFs.
|
||||
$existing = $this->Attachment->find('first', array('conditions'=>array('Attachment.id' => $this->data['Attachment']['id'])));
|
||||
|
||||
if(!empty($existing)) {
|
||||
//Delete old file
|
||||
unlink($existing['Attachment']['file']);
|
||||
|
||||
}
|
||||
$attachment = $this->Attachment->process_attachment($this->data);
|
||||
|
||||
if(!$attachment) {
|
||||
$this->Session->setFlash('The Attachment could not be saved. The filename exists');
|
||||
}
|
||||
else {
|
||||
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)) {
|
||||
else {
|
||||
$this->data = $this->Attachment->read(null, $id);
|
||||
}
|
||||
$principles = $this->Attachment->Principle->find('list');
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class Email extends AppModel {
|
|||
|
||||
function getEnquiryEmails($id) {
|
||||
|
||||
return $this->find('first', array('Enquiry.id'=>$id));
|
||||
return $this->find('first', array('Enquiry.id'=>$id));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<div class="attachments form">
|
||||
<?php echo $form->create('Attachment');?>
|
||||
<?php echo $form->create('Attachment', array('type'=>'file'));?>
|
||||
<fieldset>
|
||||
<legend><?php __('Edit Attachment');?></legend>
|
||||
<?php
|
||||
|
|
@ -12,6 +12,8 @@
|
|||
<?php echo $this->data['Attachment']['filename']; ?>
|
||||
</div>
|
||||
|
||||
<?php echo $form->file('file'); ?>
|
||||
|
||||
<?php
|
||||
echo $form->input('description');
|
||||
echo $form->input('archived');
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@ foreach ($attachments as $attachment):
|
|||
<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; ?>
|
||||
|
|
|
|||
Loading…
Reference in a new issue