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

@ -69,7 +69,14 @@ public function index() {
return $this->redirect(array('action' => '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,13 +61,21 @@ echo $this->Form->inputs(array(
<?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?>
</ul>
<?
echo $this->Form->create('Events', array('action' => 'deleteSelected'));
?>
<table class="table table-condensed table-striped" id="Events">
<?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) {
echo $this->Html->tableCells(array(
$this->Html->link($this->Html->image('/events/'.$thumbData[$key]['Path'], array(
$this->Form->checkbox('delete.', array(
'value' => $value['Event']['Id'],
'hiddenField' => false
)),
$this->Html->link($this->Html->image('/events/'.$thumbData[$key]['Path'], array(
'alt' => $thumbData[$key]['Frame']['FrameId'].'/'.$thumbData[$key]['Event']['MaxScore'],
'width' => $thumbData[$key]['Width'],
'height' => $thumbData[$key]['Height']
@ -82,16 +90,16 @@ foreach ($events as $key => $value) {
$value['Event']['AlarmFrames'],
$value['Event']['TotScore'],
$value['Event']['AvgScore'],
$value['Event']['MaxScore'],
$this->Form->postLink(
'Delete',
array('action' => 'delete', $value['Event']['Id']),
array('confirm' => 'Are you sure?'))
$value['Event']['MaxScore']
));
}
?>
</table>
<?
echo $this->Form->end('Delete Selected');
?>
<ul class="pagination">
<?php echo $this->Paginator->numbers(array('tag' => 'li', 'separator' => false, 'currentClass' => 'active', 'currentTag' => 'span')); ?>
</ul>
</ul>