Created
January 24, 2014 12:05
-
-
Save g33klord/8596131 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/**************************************************************************** | |
*****************************Controller**************************************/ | |
public function deleteSelect() | |
{ | |
if(!empty($this->data)) { | |
foreach($this->data['Department'] as $key => $value){ | |
$this->Department->delete($value); | |
} | |
$this->Session->setFlash('Selected Departments deleted.'); | |
$this->redirect(array('action' => 'index')); | |
} | |
$this->Session->setFlash('Select the Departments first.'); | |
} | |
/*Multiple Activate on selecting radion box*/ | |
public function activateSelect(){ | |
if(!empty($this->data)) { | |
foreach($this->data['Department'] as $key => $value) { | |
$this->Department->id=$value; | |
$this->Department->saveField('status', TRUE); | |
} | |
$this->Session->setFlash('Selected Departments activated.'); | |
$this->redirect(array('action' => 'index')); | |
} | |
$this->Session->setFlash('Select the Departments first.'); | |
} | |
/*Multiple Deactivate on selecting radion box*/ | |
public function deactivateSelect(){ | |
if(!empty($this->data)) { | |
foreach($this->data['Department'] as $key => $value) { | |
$this->Department->id=$value; | |
$this->Department->saveField('status', FALSE); | |
} | |
$this->Session->setFlash('Selected Departments deactivated.'); | |
$this->redirect(array('action' => 'index')); | |
} | |
$this->Session->setFlash('Select the Departments first.'); | |
} | |
/**************************************************************************** | |
*****************************view**************************************/ | |
<?php echo $this->Form->create('Department',array('action' =>'deleteSelect','name'=>'deplist')); ?> | |
<table id = "example"> | |
<thead> | |
<tr> | |
<th> </th> | |
<th>S.N.</th> | |
<th>Name</th> | |
<th> </th> | |
</tr> | |
</thead> | |
<tbody> | |
<?php $sn =1; ?> | |
<?php foreach($results as $result): ?> | |
<tr> | |
<td> <?php echo $this->Form->checkbox($result['Department']['_id'], | |
array( | |
'value' => $result['Department']['_id'], | |
));?> | |
</td> | |
<td><?php echo $sn++; ?> </td> | |
<td><?php echo $result['Department']['name']; ?> </td> | |
<td> | |
<?php | |
if($result['Department']['status']==0 ||$result['Department']['status']== FALSE ||$result['Department']['status']=='0' ) { | |
echo $this->Html->link('Activate',array('action'=>'activate',$result['Department']['_id'])); | |
} elseif ($result['Department']['status']==1 ||$result['Department']['status']== TRUE ||$result['Department']['status']=='1' ) { | |
echo $this->Html->link('Deactivate',array('action'=>'deactivate',$result['Department']['_id'])); | |
} | |
?> | | |
<?php echo $this->Html->link('Edit',array('action'=>'edit',$result['Department']['_id'])); ?> | | |
<?php echo $this->Html->link('Delete',array('action'=>'delete',$result['Department']['_id'])); ?> | |
</td> | |
</tr> | |
<?php endforeach; ?> | |
</tbody> | |
</table> | |
<INPUT type="button" value="Delete Selected" name=button1 onclick="return OnButton1();"> | |
<INPUT type="button" value="Activate Selected" name=button2 onclick="return OnButton2();"> | |
<INPUT type="button" value="Deactivate Selected" name=button3 onclick="return OnButton3();"> | |
<?php echo $this->Form->end(); ?> | |
<script language="Javascript"> | |
function OnButton1() | |
{ | |
document.deplist.action = "/cake/departments/deleteSelect" | |
document.deplist.submit(); | |
return true; | |
} | |
function OnButton2() | |
{ | |
document.deplist.action = "/cake/departments/activateSelect" | |
document.deplist.submit(); | |
return true; | |
} | |
function OnButton3() | |
{ | |
document.deplist.action = "/cake/departments/deactivateSelect" | |
document.deplist.submit(); | |
return true; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment