根据php中的日期时间选择器值过滤我的日志表

时间:2015-03-30 06:11:54

标签: php

我需要根据我在PHP中设置日期时间的值来过滤我的日志表。是否可以使用ajax? 代码:

<?php
include_once("_inc/php_header.php");
?>

<!DOCTYPE html>
<html lang="en">

    <head>

        <?php include_once("_inc/head.php"); ?>

        <!-- DataTables CSS -->
        <link href="css/plugins/dataTables.bootstrap.css" rel="stylesheet">


        <!-- DataTables JavaScript -->
        <script src="js/plugins/dataTables/jquery.dataTables.js"></script>
        <script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>
        <script>
           $(document).ready(function () {
               $('#dataTables').dataTable({
                   "columnDefs": [{"targets": 2, "orderable": false, "searchable": false}]
               });
           });
        </script>

    </script>

    <!--    DELETION SCRIPT-->

    <script type="text/javascript">

       $(document).ready(function () {
           $("body").on("click", ".trash", function () {
               if (confirm("Do you want to delete this profile details?")) {
                   $("#delid").val($(this).attr("element-id"));
                   $("#del_form").submit();
               }
           });
       });


    </script>

    <!--    DELETION SCRIPT ENDS-->
</head>

<body>

    <!--DELETION FORM-->
    <form method="post" action="_proc/delete.php" id="del_form" name="del_form">
        <input type="hidden" name="src" value="log"/>
        <input type="hidden" id="delid" name="delid" value=""/>
    </form>
    <!--    DELETION FORM ENDS-->

    <div id="wrapper">

        <!-- Navigation -->
        <?php
        $nav = "log";
        include_once("_inc/navigation.php");
        ?>
        <!-- /Navigation -->

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-12">
                        <h1 class="page-header">Detailed Logs</h1>
                        <!-- TEMPORARY NOTIFICATION ENDS-->
                        <?php if (isset($_SESSION['log_alert'])) {
                           ?>
                        <div class="alert alert-success" role="alert">
                            <a href="#" class="alert-link"><strong><?php
                                       echo $_SESSION['log_alert'];
                                       unset($_SESSION['log_alert']);
                                       ?></strong></a>
                        </div>
                        <?php } ?>

                        <!-- TEMPORARY NOTIFICATION -->
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->
                <div class="row">
                    <div class="col-lg-12">
                        <div class="panel panel-default">

                            <!--SORT BY DATE-->

                            <div onclick="show_class(this.value)" class="panel-heading">Sort by date:
                                <div class='input-group date datetimepicker1'>
                                    <input name="date" type='text' class="form-control" value="<?php
                                    echo date('d/m/Y');
                                    ?>"/>
                                    <span style="width: 1cm" class="input-group-addon glyphicon glyphicon-calendar">
                                    </span>
                                </div>  
                                <script type="text/javascript">
                                   $(function () {
                                       $('.datetimepicker1').datetimepicker({format: 'DD-MM-YYYY'});
                                   });
                                </script>

                           <!--SORT BY DATE ENDS-->


                                <div class="pull-right clearfix">


                                </div>
                            </div>
                            <!-- /.panel-heading -->

                            <div class="panel-body">

                                <?php
                                include_once("_inc/_class/Profile.php");
                                $dbprofile = new Profile();

                                include_once("_inc/_class/Designation.php");
                                $dbdesignation = new Designation();

                                include_once("_inc/_class/Type.php");
                                $dbtype = new Type();

                                include_once("_inc/_class/Department.php");
                                $dbdepartment = new Department();

                                include_once("_inc/_class/Faculty.php");
                                $dbfaculty = new Faculty();

                                include_once("_inc/_class/Log.php");
                                $dblog = new Log();

                                $logs = $dblog->selectAll("u_date >'" . date("Y-m-d", strtotime("-5 days")) . "'", "", "id DESC");

                                $i = 1;
                                if (!empty($logs)) {
                                   ?>
                                <div class="table-responsive" id="log">
                                    <table class="table table-striped table-bordered table-hover" id="dataTables">
                                        <thead>
                                            <tr>
                                                <th>SN</th>
                                                <th>Name</th>
                                                <th>Type</th>
                                                <th>Department</th>
                                                <th>Designation</th>
                                                <th>Action Performed</th>
                                                <th>Date&Time</th>
                                                   <?php if (isset($_SESSION['level']) && $_SESSION['level'] == 1000) { ?>
                                                    <th>Action</th>
                                                   <?php } ?>
                                            </tr>
                                        </thead>
                                        <tbody>
                                               <?php foreach ($logs as $log) { ?>

                                                <tr>
                                                    <td><?php echo $i; ?></td>

                                                      <?php
                                                      $dbprofile = new Profile();
                                                      $dbprofile->select($log->profile_id);
                                                      ?>
                                                    <td data-toggle="popover" title="<?php echo "$dbprofile->title" . " " . "$dbprofile->first_name" . " " . "$dbprofile->last_name"; ?>" data-content="Hello"><?php echo "$dbprofile->title" . " " . "$dbprofile->first_name" . " " . "$dbprofile->last_name"; ?></td>
                                                      <?php
                                                      $dbfaculty->selectWithProfile($log->profile_id);
                                                      ?>
                                                    <td><?php
                                                          $dbtype->TypeTitle($dbfaculty->type);
                                                          echo $dbtype->title;
                                                          ?></td>
                                                    <td><?php
                                                          $dbdepartment->DepartmentTitle($dbfaculty->department_id);
                                                          echo $dbdepartment->title;
                                                          ?></td>
                                                    <td><?php
                                                          $dbdesignation->DesignationTitle($dbfaculty->designation_id);
                                                          echo $dbdesignation->title;
                                                          ?></td>
                                                    <td><?php echo $log->action; ?></td>

                                                      <?php $dbprofile->select($log->operation); ?>


                                                    <td><?php echo $log->u_date; ?></td>

                                                      <?php if (isset($_SESSION['level']) && $_SESSION['level'] == 1000) { ?>
                                                        <td width="70px">
                                                            <div class="btn-group">
                                                                <button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
                                                                    Actions
                                                                    <span class="caret"></span>
                                                                </button>
                                                                <ul class="dropdown-menu pull-right" role="menu">
                                                                    <li  ><a href="#" class=" trash"element-id="<?php echo $log->id; ?>"><i class="fa fa-trash"></i> Delete</a></li>
                                                                </ul>
                                                            </div>
                                                        </td>
                                                      <?php } ?>
                                                </tr>

                                                  <?php
                                                  $i++;
                                               }
                                               ?>
                                        </tbody>
                                    </table>
                                </div>
                                <?php } else { ?>

                                <p>No Log  Found!!</p>

                                <?php } ?>
                                <!-- /.table-responsive -->




                            </div>
                            <!-- /.panel-body -->
                        </div>
                        <!-- /.panel -->
                    </div>
                    <!-- /.col-lg-12 -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.container-fluid -->
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->

</body>

</html>

0 个答案:

没有答案