<?php 
require_once("includes/initialize.php");
date_default_timezone_get();

// $user = $_SESSION['user'];
// $date = date('Y-m-d h:i');
 $alldept = EDITING:: showdept();

 $mlga = EDITING:: lga();
 $mState = EDITING:: state();

 $mSubject = EDITING:: subject();

 

// $user='';
// $id = $session->user_id;

// $user= ADMINACCOUNT::find_by_id($id);
// $email='';
// if (isset($_POST['btnsearch']) && !empty($_POST['btnsearch'])) {
// $email=$_POST['searchtxt'];
// $stuid= UPDATESTUACCOUNT::findid($email);
// echo "Surname: ".$stuid->surname;
// }

?>
           <!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>  -->
           <!--<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />  -->
           <!--<script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>  -->
           <!--<script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script>            -->
           <!--<link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.bootstrap.min.css" />-->
<head> 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /> 
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker.css" />
</head>
    <body>       
		<div class="container" align="center" style="width: 100%">
			<!-- <h2 align="center">Welcome :: <?php echo ucwords($user->surname); ?> </h2><br/> -->
            <!-- <div class="container"> -->
            <div class="panel panel-primary chat-panel">
                <div class="panel-heading ">
                    <form class="form-horizontal" method="post" role="form">          
                        <div class="input-append date" id="datepicker2">
                            <label class="col-sm-5 control-label">Search Date :</label>
                            <div class="col-sm-4">
                                <input class="form-control" size="16" type="text" name="date" placeholder="yyyy-mm-dd" required="required">
                                <span class="add-on"><i class="icon-th"></i></span>
                            </div>
                        </div>
                        <div class="col-sm-4">
                            <input type="submit" class="btn btn-danger" name="searchDate" value="Search" title="Search Student">    
                        </div>      	
                    </form>
                </div><br/>
                <!-- <form method="post" action="" role="form"> -->
                
            </div>
		</div>

<?php


if(isset($_POST['searchDate'])!="")
{

    $date = $_POST['date'];
    
    $rows = EDITING:: monitorBU($date);


?>
<div class="callout callout-info">
              <div class="dataTable_wrapper">
                  <table class="table table-bordered table-hover">
                      <thead>
                          <tr>
                              <th>Business Unit Staff</th>
                              <th>Number of Form Edited</th>
                          </tr>
                      </thead>
                      <tbody>
                          <?php
                        //   if ($rows){
                        //     foreach($rows as $row){
                        //         $adm = $row->user;
                        //         $count = $row->COUNT(edited_date)
                        $query = "SELECT user, COUNT(edited_date) FROM admitted_student_details_2019 
                    		WHERE edited_date LIKE '%{$date}%' GROUP BY user";
                        $result = mysql_query($query) or die(mysql_error());
                        
                         while($row = mysql_fetch_array($result)){
                            ?>
                            <tr >
                                <td><?php echo $row['user']; ?></td>
                                <td><?php echo $row['COUNT(edited_date)']; ?></td> 
                                </tr>
                          <?php } //}}?>
                      </tbody>
            
                  </table>
              </div>
              <!-- /.table-responsive -->                            
          </div>
<?php }?>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>  
    <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>  
    <script src="https://cdn.datatables.net/1.10.12/js/dataTables.bootstrap.min.js"></script> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.js"></script>
    

<script>
$(document).ready(function()
{

    $('#datepicker2').datepicker({
    todayBtn:'linked',
    format: "yyyy-mm-dd",
    autoclose: true
    });
});
</script>