Codeigniter:筛选jquery数据表中多列上两个日期之间的日期范围

Codeigniter:筛选jquery数据表中多列上两个日期之间的日期范围,jquery,mysql,json,ajax,codeigniter,Jquery,Mysql,Json,Ajax,Codeigniter,在使用json和ajax的jQueryDataTables中,我的日期范围和submit按钮没有在多个列上的两个日期之间进行过滤或显示。我希望它使用codeigniter上的MVC在多个列上过滤或显示两个日期之间的日期范围,日期格式为yyyy mm dd 例如: 这是jquery数据表的图像 我想筛选从2016年1月22日到2016年1月25日的日期范围。结果/显示将如下所示。 以下是jquery、json和ajax(Employee.js): 以下是控制器(home.php): 以下是视图(

在使用json和ajax的jQueryDataTables中,我的日期范围和submit按钮没有在多个列上的两个日期之间进行过滤或显示。我希望它使用codeigniter上的MVC在多个列上过滤或显示两个日期之间的日期范围,日期格式为yyyy mm dd

例如: 这是jquery数据表的图像

我想筛选从2016年1月22日到2016年1月25日的日期范围。结果/显示将如下所示。

以下是jquery、json和ajax(Employee.js):

以下是控制器(home.php):

以下是视图(employee.php):

$(document).ready( function () {
    var table = $('#attendance').dataTable( { 
        "aoColumnDefs": [ {"bSortable": false, "aTargets": [ 0, 1, 4 ] } ],  
        "aaSorting": [], "aLengthMenu": [[5, 15, 25, 50], [5, 15, 25, 50]],
        buttons:['excel'],
        dom:'lrtip'
    } );


    $(function() {
        $( "#fromDate" ).datepicker();
        $( "#toDate" ).datepicker();
    });

//ajax to query attendance
$("#btnFind").click(function(){

    var from = $("#fromDate").val();
    var to = $("#toDate").val();

    $.ajax({
        url:"FindAttendance",
        type:"POST",
        data:{fromDate:from, toDate:to},
        success:function(msg){
//console.log(msg);
$("#divAttendance").html(msg);
}
})
})                                      

} );
public function goEmployee() {  // view of employees if they login
        $username = $this->session->userdata('username');
        $this->load->model('Model_attendance');
        $query = $this->Model_attendance->getOne($username);
        $data['EMPLOYEES'] = null;
        $data['isAdmin'] = false; //that will check if the user is admin or not
        if ($query) {
            $data['EMPLOYEES'] = $query;
        }

        $this->load->view('imports/header');
        $this->load->view('imports/menu');

        $this->load->view('employee', $data);
    }

public function FindAttendance(){

        $from=$this->input->post('fromDate');
        $to = $this->input->post('toDate');

        $this->load->model('model_attendance');
        $data = $this->model_attendance->GetAttendance($from,$to);

        echo json_encode($data);
    }
<div>
    <input type="text" placeholder="From" id="fromDate">&nbsp;<input type="text" placeholder="To" id="toDate">&nbsp;
    <a href="#" class="btn btn-info" id="btnFind" title="Search Attendance"><span class="glyphicon glyphicon-search"></span></a>
</div><br/>
<div id="divAttendance">

<table class="table table-striped responsive-utilities jambo_table" id="attendance">
    <thead>
        <tr class="headings">
            <th>Employee ID</th>      
            <th>Name</th>
            <th>Time-in</th>
            <th>Time-out</i></th> 
            <th>Duration</th>
        </tr>
    </thead>
    <tbody>

        <?php 
        foreach($EMPLOYEES as $employee){

            $timein = $employee->TIMEIN;
            $timeout = $employee->TIMEOUT;

            ?>

            <tr>
                <td data-order="<?php echo $timein; ?>"><?php echo $employee->empnum; ?></td>
                <td><?php echo $employee->NAME; ?></td>
                <td data-order="<?php echo $timein;?>"><?php echo $timein; ?></td>
                <td data-order="<?php echo $timeout;?>"><?php echo $timeout; ?></td>
                <td><?php 
                $employee->DUR;

                ?>

            </td>
        </tr>
        <?php } ?>
    </tbody>
</table>
public function GetAttendance($from, $to){

        $sql = "SELECT a.empnum,CONCAT(a.name,' ',a.midname,' ',a.lastname) AS
                NAME,CONCAT(b.indate,' ',b.intime) AS 'TIMEIN',CONCAT(b.outdate,'
                ',b.outtime)AS 'TIMEOUT', DATEDIFF('timeout','timein') AS 'DUR' 
                FROM employees AS a
                JOIN times AS b ON (a.empnum=b.userid)
                WHERE b.indate BETWEEN
                STR_TO_DATE('".$from."','%m/%d/%Y') AND STR_TO_DATE('".$to."','%m/%d/%Y')";

        $query = $this->db->query($sql);

        return $query->result();
    }