Fixed removing attachments

This commit is contained in:
Karl Cordes 2013-03-29 16:30:35 +11:00
parent a73fd66440
commit 296336e431
5 changed files with 9 additions and 16 deletions

View file

@ -139,9 +139,9 @@ class DocumentsController extends AppController {
function removeAttachments() {
$this->layout = 'ajax';
foreach($this->data as $attachment) {
$this->Document->DocumentAttachment->delete($attachment);
foreach($this->data['DocumentAttachment'] as $attachment) {
$this->Document->DocumentAttachment->delete($attachment['id']);
}
echo 'SUCCESS';
}

View file

@ -7,10 +7,10 @@
</thead>
<tbody>
<?php
foreach($attachments as $attachment) {
foreach($attachments as $index => $attachment) {
?>
<tr>
<td><?php echo $form->input('DocumentAttachment.id', array('type'=>'checkbox', 'value'=> $attachment['DocumentAttachment']['id'], 'label' => false, 'class'=>'documentAttachment-checkbox')); ?></td>
<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>

View file

@ -47,7 +47,7 @@ echo $form->input("DocPage.content", array('class'=>'page', 'label'=>'Page', 'be
foreach($attachments as $index => $attachment) {
?>
<tr>
<td><?php echo $form->input("DocumentAttachment[{$index}].id",
<td><?php echo $form->input("DocumentAttachment.{$index}.id",
array('type'=>'checkbox',
'value'=> $attachment['DocumentAttachment']['id'],
'label' => false, 'class'=>'documentAttachment-checkbox')); ?></td>

View file

@ -544,16 +544,9 @@ function savePages() {
});
$.post('/documents/ajax_edit', docPages, function(data) {
if(data =='SUCCESS') {
$("#flashMessage").html("Pages Saved Successfully");
}
else {
$("#flashMessage").html("Unable to Save Pages");
}
$("#flashMessage").show();
loadLineItems();
$("#flashMessage").show();
loadLineItems();
});
}

View file

@ -57,7 +57,7 @@ $(function() {
function removeAttachments() {
var selectedAttachments = $(".documentAttachment-checkbox:checked");
$.post('/documents/removeAttachments', selectedAttachments, function(data) {
$.post('/documents/removeAttachments', selectedAttachments, function(data) {
loadAttachments();
});