Added ability to delete multiple events at once

This commit is contained in:
Kevin Crider 2013-09-18 15:53:35 -04:00
parent 0f25bec1d6
commit c6bbdac0d7
2 changed files with 24 additions and 9 deletions

View File

@ -70,6 +70,13 @@ public function index() {
} }
} }
public function deleteSelected() {
$this->log(print_r($this->data['Events'], true));
foreach($this->data['Events'] as $key => $value) {
$this->Event->delete($value);
}
$this->redirect($this->referer());
}
} }
?> ?>

View File

@ -61,12 +61,20 @@ echo $this->Form->inputs(array(
<?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?> <?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?>
</ul> </ul>
<?
echo $this->Form->create('Events', array('action' => 'deleteSelected'));
?>
<table class="table table-condensed table-striped" id="Events"> <table class="table table-condensed table-striped" id="Events">
<?php <?php
echo $this->Html->tableHeaders(array( 'Thumbnail', 'Id', 'Name', 'Monitor', 'Cause', 'Time', 'Duration', 'Alarm Frames', 'Total Score', 'Avg. Score', 'Max Score', '' )); echo $this->Html->tableHeaders(array('', 'Thumbnail', 'Id', 'Name', 'Monitor', 'Cause', 'Time', 'Duration', 'Alarm Frames', 'Total Score', 'Avg. Score', 'Max Score'));
foreach ($events as $key => $value) { foreach ($events as $key => $value) {
echo $this->Html->tableCells(array( echo $this->Html->tableCells(array(
$this->Form->checkbox('delete.', array(
'value' => $value['Event']['Id'],
'hiddenField' => false
)),
$this->Html->link($this->Html->image('/events/'.$thumbData[$key]['Path'], array( $this->Html->link($this->Html->image('/events/'.$thumbData[$key]['Path'], array(
'alt' => $thumbData[$key]['Frame']['FrameId'].'/'.$thumbData[$key]['Event']['MaxScore'], 'alt' => $thumbData[$key]['Frame']['FrameId'].'/'.$thumbData[$key]['Event']['MaxScore'],
'width' => $thumbData[$key]['Width'], 'width' => $thumbData[$key]['Width'],
@ -82,16 +90,16 @@ foreach ($events as $key => $value) {
$value['Event']['AlarmFrames'], $value['Event']['AlarmFrames'],
$value['Event']['TotScore'], $value['Event']['TotScore'],
$value['Event']['AvgScore'], $value['Event']['AvgScore'],
$value['Event']['MaxScore'], $value['Event']['MaxScore']
$this->Form->postLink(
'Delete',
array('action' => 'delete', $value['Event']['Id']),
array('confirm' => 'Are you sure?'))
)); ));
} }
?> ?>
</table> </table>
<?
echo $this->Form->end('Delete Selected');
?>
<ul class="pagination"> <ul class="pagination">
<?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?> <?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?>
</ul> </ul>