Fixed removing attachments
This commit is contained in:
parent
a73fd66440
commit
296336e431
|
|
@ -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';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue