Month: October 2013

Room booking query

$out=$this->Booking->find(‘list’,array(‘conditions’=>array(‘Booking.datein =’.$da),’fields’=>’Booking.room_no’));
if(empty($out)){
$this->set(‘rooms’,$this->Room->find(‘all’));
}
else
{
$out=$this->Room->find(‘all’,array(‘conditions’=>array(‘NOT’=>array(‘Room.room_no’=>$out))));
$this->set(‘rooms’,$out);

}

Filter the records from the table using JQuery

$(document).ready(function(){
$(“.styled”).click(function() {
//fetch all the rows of table
var ab = $(“tr.allrooms”);
//hide all rows at first
ab.hide();
var data;
var stype;
//loop over each checked box
$(‘input:checked’).each(function() {
//fetch what to search i.e.fetch value from checkbox
data=$(this).attr(‘id’);
//The data type is for getting value of column to be searched i.e.add the data-type to checkboxes
stype=$(this).data(‘type’);
//here add the class name of column same as that of data-type added to the checkbox and display trs of table
$(“tr.allrooms td.”+stype+”:contains(‘”+data +”‘)” ).parent(‘tr’).show();
})

if($(‘input:checked’).length==0){
//if all checkboxes are unchecked after checking them,it displays all rows again
ab.show();
}

});

});