<?php session_start(); ob_start(); ?>

<?php  include 'header.php'; ?>

<?php
ini_set('display_errors', 0);

if(empty($_SESSION['LOGINID']) && empty($_SESSION['LOGINNM']) ){

	header("Location:index.php");
}


include("user.php");
date_default_timezone_set('Asia/Dhaka');
 $date_c = date('Y-m-d H:i:s', time());
if (isset($_POST['log_submit'])) {
								  
$sqlUpdate = "TRUNCATE `sajisurx_crm`.`activity_log` ";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 

$sqlUpdate = "INSERT INTO `activity_log` (`id`, `user`, `activity`, `time`) VALUES (NULL, '$ad_id', 'log cleaned', '$date_c')";
$sqlUpdate = mysqli_query($connection, $sqlUpdate); 

echo "<div>
											 </br>
											 </div>";
											 include_once('updated.html');
}

?>



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

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Activity Logs</title>
    <!-- ================= Favicon ================== -->
    <!-- Standard -->
    <link rel="shortcut icon" href="http://placehold.it/64.png/000/fff">
    <!-- Retina iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="144x144" href="http://placehold.it/144.png/000/fff">
    <!-- Retina iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="114x114" href="http://placehold.it/114.png/000/fff">
    <!-- Standard iPad Touch Icon-->
    <link rel="apple-touch-icon" sizes="72x72" href="http://placehold.it/72.png/000/fff">
    <!-- Standard iPhone Touch Icon-->
    <link rel="apple-touch-icon" sizes="57x57" href="http://placehold.it/57.png/000/fff">
    <!-- Styles -->
     <link href="assets/css/lib/data-table/buttons.bootstrap.min.css" rel="stylesheet" />
    <link href="assets/css/lib/font-awesome.min.css" rel="stylesheet">
    <link href="assets/css/lib/themify-icons.css" rel="stylesheet">
    <link href="assets/css/lib/owl.carousel.min.css" rel="stylesheet" />
    <link href="assets/css/lib/owl.theme.default.min.css" rel="stylesheet" />
    <link href="assets/css/lib/weather-icons.css" rel="stylesheet" />
    <link href="assets/css/lib/menubar/sidebar.css" rel="stylesheet">
    <link href="assets/css/lib/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/lib/unix.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
</head>

<body>

   
   
   
     <?php include("sidebar.php"); ?>
	
	
    <!-- /# sidebar -->
     <?php include("top.php"); ?>
	<!-- /# topebar --> 
	
	
	
    <div class="content-wrap">
        <div class="main">
            <div class="container-fluid">
                <div class="row">
                    <div class="col-lg-8 p-r-0 title-margin-right">
                        <div class="page-header">
                            <div class="page-title">
                                <h1>Hello, <span>Welcome Here</span></h1>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                    <div class="col-lg-4 p-l-0 title-margin-left">
                        <div class="page-header">
                            <div class="page-title">
                                <ol class="breadcrumb text-right">
                                    <li><a href="#">Dashboard</a></li>
                                    <li class="active">Home</li>
                                </ol>
                            </div>
                        </div>
                    </div>
                    <!-- /# column -->
                </div>
                <!-- /# row -->
				
				
					<?php if ($user_type==1){ ?>
                <section id="main-content">
				
				
			
				
				
				
				
				
				<div class="row">
				
				        <div class="col-lg-12">
						
						<div class="panel panel-info m-t-15">
                                            <div class="panel-heading">Activity Logs</div>
                                            <div class="panel-body">
						
								  
								  
                                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card alert">
							
								
								
								
								
							<?php if ($user_type==1){  ?>
								
								<form method="post">
								<input class="submit" type="submit"  name="log_submit"  onclick="return confirm('Are you sure you want to clean the logs?');" value="Clean Log" /> 
								</form>
								
								 <div class="bootstrap-data-table-panel">
                                    <div class="table-responsive">
                                        <table id="bootstrap-data-table-export" class="table table-striped table-bordered">
                                            <thead>
                                                <tr>
												      <th>SL.</th>
                                                     <th>User</th>
													
													<th>Activity</th>
													
													<th>Time</th>
													<th>Info</th>
													
													
                                                </tr>
                                            </thead>
                                            <tbody>
											
											<?php
$sl=0;
						$sqlSelectedLG = "SELECT t1.*,t2.name FROM `activity_log` t1 left join users t2 on t1.user=t2.id order by t1.id desc";

$sqlSelectedLG = mysqli_query($connection, $sqlSelectedLG);
while ($list = mysqli_fetch_object($sqlSelectedLG)) {

                                    
                                   
                                    $idn = $list->id;
									$user = $list->user;
									$activity = $list->activity;
									$name = $list->name;
									$time = $list->time;
									$temp_id = $list->temp_id;
									
									
									$time = date('d-m-Y g:ia', strtotime($time));
										$sl=$sl+1;
								
                                    
                                   
                                ?>
											
											
											
											
                                                <tr>
												    <td> <?php echo $sl;  ?> </td>
												
                                                    <td>  <?php echo $name;  ?> </td>
													  <td><?php echo $activity;  ?></td>
													    <td><?php echo $time;  ?></td>
														<td>
														<?php if($temp_id!="") { ?>
														<a href="booking_tmp.php?id=<?php echo $temp_id;  ?>" target="_blank">Booking Info</a>
														<?php } ?>
														</td>
													  

													
													
                                                </tr>
                                                
												
<?php } ?>			
												
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
							<?php } ?>			
							
								
                            </div>
                            <!-- /# card -->
                        </div>
                        <!-- /# column -->
                    </div>

                                   


							 </div> </div>
							
                        </div>
				
				
                        <!-- /# column -->
                        
                    </div>
				
				
				
				
				
                    <!-- /# row -->
                     <?php include("footer.php"); ?>
                </section>
					<?php } ?>
				
				
            </div>
        </div>
    </div>

    <div id="search">
        <button type="button" class="close">×</button>
        <form action="search.php">
            <input type="search" name="search" value="" placeholder="type keyword(s) here" />
            <button type="submit" class="btn btn-primary">Search</button>
        </form>
    </div>


    </div>
    <script src="assets/js/lib/jquery.min.js"></script>
    <!-- jquery vendor -->
    <script src="assets/js/lib/jquery.nanoscroller.min.js"></script>
    <!-- nano scroller -->
    <script src="assets/js/lib/menubar/sidebar.js"></script>
    <script src="assets/js/lib/preloader/pace.min.js"></script>
    <!-- sidebar -->
    <script src="assets/js/lib/bootstrap.min.js"></script>
    <!-- bootstrap -->
   
    <script src="assets/js/scripts.js"></script>
	
	 



</body>

</html>