I'm using Yii application. In that how to give pagination to a table contents( not using cgridview).
config/main.php
'params'=>array(
'adminEmail'=>'webmaster#example.com',
'listPerPage'=> 10,//default pagination size
),
In Controller,
public function actionOutbox() {
$criteria = new CDbCriteria;
$criteria->condition = 'from_userid = :id';
$criteria->order = 'time DESC';
$criteria->params = array (':id'=>Yii::app()->user->id);
$item_count = Email::model()->count($criteria);
$model = Email::model()->findAll($criteria);
$pages = new CPagination($item_count);
$pages->setPageSize(Yii::app()->params['listPerPage']);
$pages->applyLimit($criteria);
$this->render('outbox', array(
'model' => $model,
'item_count'=>$item_count,
'page_size'=>Yii::app()->params['listPerPage'],
'items_count'=>$item_count,
'pages'=>$pages,
));
}
In View,
<table data-provides="rowlink" data-page-size="20" data-filter="#mailbox_search" class="table toggle-square default footable-loaded footable" id="mailbox_table">
<thead>
<tr>
<th></th>
<th data-hide="phone,tablet">To</th>
<th>Subject</th>
<th data-hide="phone" class="footable-last-column">Date</th>
</tr>
</thead>
<tbody>
<?php
foreach ($model as $item) {
if ($item->email_status == 1)
echo '<tr id="' . $item->emailid . '" class="unreaded rowlink" style="display: table-row;">';
else
echo '<tr id="' . $item->emailid . '" class="rowlink" style="display: table-row;">';
echo '<td class="nolink footable-first-column">';
echo '<span class="footable-toggle"></span>';
echo '</span></td>';
echo '<td>' . $item->touser->username . '</td>';
echo '<td>' . $item->email_subject . '</td>';
$originalDate = $item->time;
$newDate = date("Y-M-d H:i:s", strtotime($originalDate));
echo '<td class="footable-last-column">' . $newDate . '</td></tr>';
}
?>
</tbody>
</table>
<?php
$this->widget('CLinkPager', array(
'currentPage' => $pages->getCurrentPage(),
'itemCount' => $item_count,
'pageSize'=> $page_size,
'maxButtonCount' => 5,
//'nextPageLabel' =>'My text >',
'htmlOptions' => array('class'=>'pages'),
));
?>
By using this code current page size is not working. Full values from table are displayed. I changed page size from 10 to 2 also, but not working.
What am I doing wrong?
Please help me. Thanks in advance
You use findAll without limit and want that yii understand about pagination?
Use CGridView widget instead it and set pagination in DataProvider (not create separate object of pagination: it not affort to result count).
And please read this topic.
Thanks.
Related
WHAT:
So I cannot for the life of me figure out why I'm getting this error. I'm trying to create a function that will display the user information from the database in a table but I have like a ton of these errors on the page and I don't know whats wrong.
STEPS TO RESOLVE:
So I've gone over my code a bunch of types to make sure that all the variables and what not were spelled correctly and as far as I can tell they are.
I've also googled this issue to see if I can find a solution but none of them are very helpful.
I honestly don't know whats wrong so kinda hard to find ways to resolve an issue, I don't even really know what this error means.
THE CODE:
This is the function:
<?php
function display_table($fields, $data, $rows, $page){
if(isset($_GET['page'])){
$page = $_GET['page'];
} else {
$page = 1;
}
$firstRecord = ($page - 1) * ROWS_PER_PAGE;
$pageNumbers = ceil($rows / ROWS_PER_PAGE);
echo '<div class="table-responsive w-75 mx-auto py-3">
<table class="table table-dark table-bordered table-sm">
<thead>
<tr>';
foreach($fields as $key){
echo '<th class="py-2">' . $key . '</th>';
}
echo '</tr>
</thead>
</tbody>';
$keys = array_keys($fields);
for($record = $firstRecord; $record < $firstRecord + ROWS_PER_PAGE; $record++){
$row = $data[$record];
echo '<tr>';
for($recordCount = 0; $recordCount < count($keys); $recordCount++){
$column = $keys[$recordCount];
echo '<td class="py-2">' . $row[$column] . '</td>';
}
echo '</tr>';
}
echo '</tbody>
</table';
for($pages = 1; $pages <= $pageNumbers; $pages++){
echo '<a class="btn btn-dark mx-1" href=?page=' . $pages . '</a>';
}
}
?>
This is where the function is put into action:
<?php
display_table(
array(
"id" => "Id",
"emailaddress" => "Email",
"firstname" => "First Name",
"lastname" => "Last Name",
"salesperson" => "Salesperson",
"phonenumber" => "Phone Number",
"extension" => "Extension",
"type" => "Type"
),
client_select_all(),
client_count(),
1
);
?>
Any help would be really appreciated.
NOTE: client_select_all and client_count are other functions, don't know if you'll need to see those or not
Hi guys i am trying to display the first td values as static so i have keep those values in one array and i try to increase the values and try to display but when i get it is displaying depending on foreach values if i have one record in foreach it is displaying one value and if i have 2 records it is displaying 2 values.
But i want to display all td value if i have values in foreach or not also.
Here is my code:
<tbody>
<?php
$arr = array(0=>'On Hold',1=>'Asset Incomplete',2=>'SME Discussion',3=>'a',4=>'b',5=>'c',6=>'d',7=>'e',8=>'f',9=>'g',10=>'h');
$i = 0;
foreach($getCourse as $report)
$status= $report->status;
{
?>
<tr>
<td><?php echo $arr[$i]; ?>
<?php $i++; ?></td>
<td><?php
if($status==1)
{
echo "On Hold";
}
elseif($status==2)
{
echo "Asset Incomplete";
}
elseif($status==3)
{
echo "Yet to Start";
}
elseif($status==4)
{
echo "SME Discussion";
}
elseif($status==5)
{
echo "Development";
}
elseif($status==6)
{
echo "PB Review";
}
elseif($status==7)
{
echo "PB Fixes";
}
elseif($status==8)
{
echo "PB2 Review";
}
elseif($status==9)
{
echo "PB2 Fixes";
}
elseif($status==10)
{
echo "Alpha Development";
}
elseif($status==11)
{
echo "Alpha Review";
}
elseif($status==12)
{
echo "Alpha Fixes";
}
elseif($status==13)
{
echo "Beta Review";
}
elseif($status==14)
{
echo "Beta Fixes";
}
elseif($status==15)
{
echo "Gamma";
}
?></td>
<td><?php echo $report->coursename; ?></td>
<td><?php echo $report->statuscount;?></td>
<td></td>
</tr>
<?php
}
?>
</tbody>
Here is my controller:
public function index()
{
if ($this->session->userdata('is_logged')) {
$data['getCourse']=$this->Report_model->getTopicReports();
$this->load->view('template/header');
$this->load->view('reports/report',$data);
$this->load->view('template/footer');
}
else {
redirect("Login");
}
}
Here is my model:
public function getTopicReports()
{
$this->db->select('count(t.status) as statuscount,t.topicName as topicname,c.coursename,t.status')
->from('topics t')
->join('course c', 't.courseId = c.id')
->where('t.courseid',1)
->where('t.status',5);
$query = $this->db->get();
return $query->result();
}
This is how i want to display here is my referrence image:
Can anyone help me how to do that thanks in advance.
FINAL UPDATED & WORKING VERSION
For me this was tricky. This turned out to be what I felt to be a awkward indexing issue.
The problem is that your data is not optimized very well to accommodate the task you are asking for. You have to make odd comparisons as you traverse the table. I was able to get it accomplished.
I would actually be very interested in seeing a more refined approach. But until that happens this code will dynamically generate a table that matches the output of the sample pictures that you posted in your question.
I have tested this code with some sample data that matches the array structure that you posted in your comments.
Here is the code:
//Create an array with your status values.
$rowName = array(
'On Hold',
'Asset Incomplete',
'Yet to Start',
'SME Discussion',
'Development',
'PB Review',
'PB Fixes',
'PB2 Review',
'PB2 Fixes',
'Alpha Development',
'Alpha Review',
'Alpha Fixes',
'Beta Review',
'Beta Fixes',
'Gamma'
);
//Generate a list of class names and get rid of any duplicates.
foreach($getCourse as $report){
$courseNames[] = $report->coursename;
}
$courseNames = array_unique($courseNames);
//Create the header.
echo
'<table>
<thead>
<tr>
<th>#</th>';
foreach($courseNames as $course){
echo '<th>' . $course . '</td>';
}
echo
'<th>Total</th>
</tr>
</thead>
<tbody>';
//Iterate across the array(list) of status values.
for($i = 0; $i < count($rowName); $i++){
echo
'<tr>';
echo '<td>' . $rowName[$i] . '</td>';
//Iterate through all combinations of class names and status values.
for($j = 0; $j < count($courseNames); $j++){
//Set flags and intial values.
$found = FALSE;
$total = 0;
$value = NULL;
for($k = 0; $k < count($getCourse); $k++){
//***Note - The ""$getCourse[$k]->status - 1" is because the status values in your data do not appear
//to start with an index of 0. Had to adjust for that.
//Sum up all the values for matching status values.
if(($getCourse[$k]->status - 1) == $i){
$total += $getCourse[$k]->statuscount;
}
//Here we are checking that status row and the status value match and that the class names match.
//If they do we set some values and generate a table cell value.
if(($getCourse[$k]->status - 1) == $i && $courseNames[$j] == $getCourse[$k]->coursename){
//Set flags and values for later.
$found = TRUE;
$value = $k;
}
}
//Use flags and values to generate your data onto the table.
if($found){
echo '<td>' . $getCourse[$value]->statuscount . '</td>';
}else{
echo '<td>' . '0' . '</td>';
}
}
echo '<td>' . $total . '</td>';
echo
'</tr>';
}
echo '</tbody>
</table>';
Try this. I am storing course status in $used_status then displaying the remaining status which are not displayed in foreach.
$arr = array ( '1' =>'On Hold', '2' => 'Asset Incomplete', '3' => 'SME Discussion', '4' => 'a', '5' => 'b', '6' => 'c', '7' =>'d', '8' => 'e', '9' => 'f', '10' => 'g', '11' => 'h' );
$used_status = array();
foreach($getCourse as $report) { ?>
<tr>
<td>
<?php $course_status = isset($arr[$report->status]) ? $arr[$report->status] : "-";
echo $course_status;
$used_status[] = $course_status; ?>
</td>
<td>
<?php echo $report->coursename; ?>
</td>
<td>
<?php echo $report->statuscount; ?>
</td>
</tr>
<?php }
foreach($arr as $status) {
if(!in_array($status, $used_status)) { ?>
<tr>
<td>
<?php echo $status; ?>
</td>
<td>
<?php echo "-"; ?>
</td>
<td>
<?php echo "-"; ?>
</td>
</tr>
<?php }
} ?>
I try to display every each data on the specific td, but I dont know where to fix my code. Please check the screenshop below to understand the clearly problems. Please any help to solve this problems.
<table class="table table-hover table-bordered ">
<tr><th>Day</th><th colspan="2">08:00-08:40</th><th colspan="2">8:40-09:20</th><th colspan="2">09:20-10:00</th><th>10:00-10:15</th><th colspan="2">10:15-10:55</th><th colspan="2">10:55-11:35</th><th colspan="2">11:35-12:15</th><th>12:15-01:15</th><th colspan="2">01:15-01:55</th><th colspan="2">01:55-02:35</th></tr>
<?php
$timesVariants = array("08:00-08:40", "08:40-09:20", "09:20-10:00", "10:00-10:15", "10:15-10:55", "10:55-11:35", "11:35-12:15", "12:15-01:15", "01:15-01:55","01:55-02:35");
$sqlquery = "SELECT * FROM timetable,classroom,subprogramme WHERE classroom.classid = timetable.classid AND subprogramme.subid = timetable.subid";
$res = $connect->query($sqlquery);
$classes = array();
while($row = $res->fetch_assoc()) {
$classes[$row['day']][$row['tid']][$row['time']] = array('courseid'=> $row['cid'], 'classname' => $row['classname'], 'subname' => $row['subname']);
}
//This is a loop
foreach($classes as $day => $daySchedule) {
foreach($daySchedule as $teacher) {
print '<tr>';
print "<td>$day</td>";
foreach($timesVariants as $time) {
if (empty($teacher[$time])){
print "<td>*</td><td>*</td>";
}
else{
print '<td>' . $teacher[$time]['courseid'] . '</td><td>' . $teacher[$time]['subname'] . ''. $teacher[$time]['classname'] . '</td>';
}
}
print '</tr>';
}
}
?>
</table>
Output
Results display on the webpage
You trouble is in the GROUP BY. MySql have no strict restrictions (by default) that each column should use aggregation function, so the result is the first row, instead of complicating SQL use PHP, your result seems not to be huge, so another loop will not affect performance:
$timesVariants = array("08:00-08:40", "08:40-09:20", "09:20-10:00", "10:00-10:15", "10:15-10:55", "10:55-11:35", "11:35-12:15", "12:15-1:15", "01:15-01:55","01:55-02:35");
$sqlquery = "SELECT * FROM timetable";
$classes = array();
while($row = $res->fetch_assoc()) {
$classes[$row['day']][$row['tid']][$row['time']] = array('subject'=> $row['subject'], 'class' => $row['class'], 'progid' => $row['progid']);
}
//This is a loop
foreach($classes as $day => $daySchedule) {
foreach($daySchedule as $teacher) {
print '<tr>';
print "<td>$day</td>";
foreach($timesVariants as $time) {
if (empty($teacher[$time]))
print "<td>None</td><td>None</td>";
else
print '<td>' . $teacher[$time]['subject'] . '</td><td>' . $teacher[$time]['class'] . '</td>';
}
print '</tr>';
}
}
<?php
if(isset($_POST["tid"])){
$tid = $connect->real_escape_string($_POST["tid"]);
$sqlquery = "SELECT * FROM timetable,classroom,subprogramme WHERE classroom.classid = timetable.classid AND subprogramme.subid = timetable.subid AND timetable.tid = ".$tid." ORDER BY timetable.timid ASC";
$res = $connect->query($sqlquery);
if($res->num_rows > 0){
?>
<table class="table table-bordered table-striped">
<tr><th>Day</th><th colspan="2">8:00-8:40</th><th colspan="2">8:40-9:20</th><th colspan="2">9:20-10:00</th><th colspan="2">10:00-10:15</th><th colspan="2">10:15-10:55</th><th colspan="2">10:55-11:35</th><th colspan="2">11:35-12:15</th><th colspan="2">12:15-1:15</th><th colspan="2">1:15-1:55</th><th colspan="2">1:55-2:35</th></tr>
<?php
$timesVariants = array("8:00-8:40", "8:40-9:20", "9:20-10:00", "10:00-10:15", "10:15-10:55", "10:55-11:35", "11:35-12:15", "12:15-01:15", "1:15-1:55","1:55-2:35");
$classes = array();
while($row = $res->fetch_assoc()) {
$classes[$row['day']][$row['tid']][$row['time']] = array('courseid'=> $row['cid'], 'classname' => $row['classname'], 'subname' => $row['subname']);
}
//This is a loop
foreach($classes as $day => $daySchedule) {
foreach($daySchedule as $teacher) {
print '<tr>';
print "<td>$day</td>";
foreach($timesVariants as $time) {
if (empty($teacher[$time])){
print "<td>*</td><td>*</td>";
}
else{
print '<td>' . $teacher[$time]['courseid'] . '</td><td>' . $teacher[$time]['subname'] . ''. $teacher[$time]['classname'] . '</td>';
}
}
print '</tr>';
}
}
?>
</table>
<?php
}
else{ print "<div class='alert alert-danger col-md-4'><span class='glyphicon glyphicon-remove'></span> Not yet set timetable</div>"; }
} ?>
</div>
The problems was on td I forgot to put colspan = 2, and other problem on sql query I forgot to inner join the tables in order to get all right that i want to display on the page.
I'm using Yii application. In that how to give pagination to a table contents (not using cgridview).
In view,
<table data-provides="rowlink" data-page-size="20" data-filter="#mailbox_search" class="table toggle-square default footable-loaded footable line-content" id="mailbox_table">
<thead>
<tr>
<th></th>
<th data-hide="phone,tablet">From</th>
<th>Subject</th>
<th data-hide="phone" class="footable-last-column">Date</th>
</tr>
</thead>
<tbody>
<?php
foreach ($model as $item) {
if ($item->fromuser->usertypeid === '0') {
$name = $item->fromuser->username;
} else if ($item->fromuser->usertypeid === '1') {
$student = Student::model()->findByPk($item->fromuser->userid);
$name = $student->student_admissionno . " - " . $student->student_firstname . " " . $student->student_middlename . " " . $student->student_lastname;
} else if ($item->fromuser->usertypeid === '3') {
$guardian = Guardian::model()->findByPk($item->fromuser->userid);
$name = $guardian->guardian_name;
} else {
$employee = Employeemaster::model()->findByPk($item->fromuser->userid);
$name = $employee->employee_code . " - " . $employee->employee_firstname . " " . $employee->employee_middlename . " " . $employee->employee_lastname;
}
if ($item->email_status == 1)
echo '<tr id="' . $item->emailid . '" class="unreaded rowlink" style="display: table-row;">';
else
echo '<tr id="' . $item->emailid . '" class="rowlink" style="display: table-row;">';
echo '<td class="nolink footable-first-column">';
echo '<span class="footable-toggle"></span>';
echo '<input type="checkbox" class="mbox_msg_select" name="msg_sel"></td>';
echo '</span></td>';
echo '<td>' . $name . '</td>';
echo '<td>' . $item->email_subject . '</td>';
$originalDate = $item->time;
$newDate = date("Y-M-d H:i:s", strtotime($originalDate));
echo '<td class="footable-last-column">' . $newDate . '</td></tr>';
}
?>
</tbody>
</table>
<div class="main-detail-con" style="width:700px;">
<div style="width:700px; padding-left: 0px;" class="listing-center-numbers">
<?php
$this->widget('CLinkPager', array(
'pages' => $pages,
'currentPage' => $pages->getCurrentPage(),
'itemCount' => $item_count,
'pageSize' => $page_size,
'maxButtonCount' => 5,
));
?>
</div>
</div>
<div class="clear"></div>
In Controller,
public function actionEmail() {
$criteria = new CDbCriteria;
$criteria->order = 'time DESC';
$criteria->condition = 'to_userid = :id';
$criteria->params = array(':id' => Yii::app()->user->id);
$criteria->addCondition('t.email_status= "2" OR
t.email_status= "1"');
$item_count = Email::model()->count($criteria);
$model = Email::model()->findAll($criteria);
$pages = new CPagination($item_count);
$pages->setPageSize(Yii::app()->params['listPerPage']);
$pages->applyLimit($criteria);
$this->render('inbox', array(
'model' => $model,
'item_count' => $item_count,
'page_size' => Yii::app()->params['listPerPage'],
'items_count' => $item_count,
'pages' => $pages,
));
}
In main/config.php
'params' => array(
'listPerPage'=> 2,//default pagination size
),
Output is,
The page size (I am giving 2 for per page) is not working by using this code. Please help me...
First of all define a new params in config/main.php, something like:
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster#example.com',
'listPerPage'=> 10,//default pagination size
),
Now, modify your controller's action like:
public function actionOutbox() {
$criteria = new CDbCriteria;
$criteria->condition = 'from_userid = :id';
$criteria->order = 'time DESC';
$criteria->params = array (':id'=>Yii::app()->user->id);
$item_count = Email::model()->count($criteria);
$model = Email::model()->findAll($criteria);
$pages = new CPagination($item_count);
$pages->setPageSize(Yii::app()->params['listPerPage']);
$pages->applyLimit($criteria);
$this->render('outbox', array(
'model' => $model,
'item_count'=>$item_count,
'page_size'=>Yii::app()->params['listPerPage'],
'items_count'=>$item_count,
'pages'=>$pages,
));
}
Then in your view after foreach loop add CLinkPager widget, like:
<?php
$this->widget('CLinkPager', array(
'currentPage' => $pages->getCurrentPage(),
'itemCount' => $item_count,
'pageSize'=> $page_size,
'maxButtonCount' => 5,
//'nextPageLabel' =>'My text >',
'htmlOptions' => array('class'=>'pages'),
));
?>
Thats all you need to do, you might have to do some css changes though, hope that helps :)
Am working on a Yii staff-hours scheduling project, stuck on editable-curd-staffhours-module. I want to store staff scheduling hours in StaffHourstable using Editable Yii Booster Extension.
My staffhours table DB stucture as:
id(pk) user_id(fk) staff_id(int) monday(text) tuesday(text) wednesday(text) thursday(text) friday(text) saturday(text) sunday(text)
All day-text fields used to store serialize time as in associative-array format:
array(
'12:00 AM' => 'open',
'12:30 AM' => 'close',
'01:00 AM' => 'close',
'01:30 AM' => 'open',
'02:00 AM' => 'open',
.
.
.
'11:00 PM' => 'close'
'11:30 PM' => 'close'
);
I have implemented Editable UI using Yii Booster Extension, watch snap below:
Problem is that am unable to recognize how to store/update staff-hours data in DB.
Some Of Code i have done
---- In View ----
<?php
$this->breadcrumbs=array(
'Settings'=>array('settings/settings'),
'Staff Hours',
);
$user_id = Yii::app()->user->getId();
$condition = "user_id = '$user_id'";
$data = StaffHours::model()->findAll();
$Monday = unserialize($data[0]['monday']);
$Tuesday = unserialize($data[0]['tuesday']);
$Wednesday = unserialize($data[0]['wednesday']);
$Thursday = unserialize($data[0]['thursday']);
$Friday = unserialize($data[0]['friday']);
$Saturday = unserialize($data[0]['saturday']);
$Sunday = unserialize($data[0]['sunday']);
foreach($data as $data)
{
?>
<div id="settinghead">StaffS Hours </div>
<div id="leftmenu"> <?php $this->widget('application.components.widgets.SettingsMenu.settingsmenuWidget'); ?></div>
<div id="rightcontent">
<div id="pageheding">Staff Hours Detail </div>
<table class="items table table-bordered">
<thead>
<tr><th scope="col">Time</th> <th scope="col">Monday</th> <th scope="col">Tuesday</th><th scope="col">Wednesday</th>
<th scope="col">Thursday</th><th scope="col">Friday</th><th scope="col">Saturday</th><th scope="col">Sunday</th> </tr>
</thead>
<?php
$start = strtotime('12:00am');
$end = strtotime('11:59pm');
for( $i = $start; $i <= $end; $i += 900)
{
$time = date('h:i A', $i);
?>
<tr>
<th scope="row"><?php echo $time; ?></th>
<td id="mon<?php echo $time; ?>">
<?php
$this->widget('bootstrap.widgets.TbEditableField', array(
'type' => 'select',
'model' => $data,
'emptytext' => $Monday[$time],
'attribute' => 'monday',
'url' => $this->createUrl('staffhours/updatetime&time='.$time), //url for submit data
'source' => array('Open', 'Close', 'Away'),
'value' => $time,
'enabled' => true
));
?>
</td>
<td id="tue<?php echo date('g:i A', $i); ?>"><?php echo $Tuesday[$time]; ?></td>
<td id="wed<?php echo date('g:i A', $i); ?>"><?php echo $Wednesday[$time]; ?></td>
<td id="thu<?php echo date('g:i A', $i); ?>"><?php echo $Thursday[$time]; ?></td>
<td id="fri<?php echo date('g:i A', $i); ?>"><?php echo $Friday[$time]; ?></td>
<td id="sat<?php echo date('g:i A', $i); ?>"><?php echo $Saturday[$time]; ?></td>
<td id="sun<?php echo date('g:i A', $i); ?>"><?php echo $Sunday[$time]; ?></td>
</tr>
<?php
}
}
?>
</table>
</div>
---- In StaffHoursController Controller ----
/**
* Update time.
*/
public function actionUpdatetime($time)
{
$user_id = Yii::app()->user->getId();
$pk = $_POST['pk'];
$day = $_POST['name'];
$status = $_POST['value'];
$GetData = StaffHours::model()->findByPk($pk);
$DayTimes = unserialize($GetData->monday);
if(array_key_exists($time, $DayTimes))
{
unset($DayTimes[$time]);
//merge new value
$DayTimes[$time] = $status;
array_push($DayTimes, $DayTimes[$time]);
$attributes = array($day => serialize($DayTimes));
$condition = "id = '$pk' AND user_id = '$user_id'";
StaffHours::model()->updateByPk($pk, $attributes, $condition);
}
}
If am going wrong or another easy way available to staff hours using Editable-UI.
Then please suggest a better way to store Staff-Hours using Editable-UI.
I believe storing array data into MySql text column is very impractical, since you will loose performance, ability to implement proper searching technique and etc. A better database design can be:
Each staff has many hours, and each hour can be assigned to many staff, a simple MANY_MANY relationship.
The advantage is that you can search for any date, any hour, any staff with a very easy,simple, singe query, or ActiveRecord: