<?php 
 ob_start();
 require_once 'var/session.php';
 require_once 'var/controller.php';
 include 'toprel.php';
 ?>

    
<div class="page-wrapper">
        <div class="page-inner bg-brand-gradient">
            <div class="page-content-wrapper bg-transparent m-0">
                
                <div class="height-10 w-100 shadow-lg px-4 bg-brand-gradient">
                    <div class="d-flex align-items-center container p-0">
                        <div class="page-logo width-mobile-auto m-0 align-items-center justify-content-center p-0 bg-transparent bg-img-none shadow-0 height-9">
                            <a href="javascript:void(0)" class="page-logo-link press-scale-down d-flex align-items-center site-logo">
                                <img src="img/logo/bm2.png" alt="Beam" aria-roledescription="logo" style="width: 100px;">
                            </a>
                        </div>
                        <a href="javascript:void(0)" class="btn-link text-white ml-auto">
                            Help?
                        </a>
                    </div>
                </div>

                <div class="flex-1" style="background: url(img/svg/pattern-1.svg) no-repeat center bottom fixed; background-size: cover;">
                    <div class="container py-4 py-lg-5 my-lg-5 px-4 px-sm-0">
                        <div class="row">
                        <div class="col col-md-6 col-lg-7 hidden-sm-down animation-slideDown">
                                <?php
                                    $tm=date("Y-m-d H:i:s");
                                    
                                if (isset($_SESSION['us_access']) and isset( $_SESSION['sess_id'])){
                                    $logout_user = $db->prepare("update tbl_user_session set time_logout=?,status=? where sess_id=?");
                                    try {
                                        // insert into tbl_personal_ug
                                        $logout_user->execute(array($tm, 'OFF', $_SESSION['sess_id']));
                                            
                                    $logout_access = $db->prepare("UPDATE tbl_user_access SET last_logged_out=? WHERE u_id=?");
                                    $logout_access->execute(array($tm, $_SESSION['us_access']));
                                    // end to update

                                    $name = $_SESSION['email'];
                                    session_unset();
                                    session_destroy();
                                    
                                    echo "<br /><br /><center><font style='color: #fff;' face='Verdana' size='2' >Dear <b>".$name."</b>, You have successfully logged out. <br /><br /><br /></font></center>";
                                    echo'<meta http-equiv="refresh"'.'content="3;URL=index">';
                                    }
                                    catch (PDOException $ex) {
                                    //Something went wrong rollback!			
                                    echo $ex->getMessage();
                                }

                                }
                                else
                                {
                                echo "<br><center> <font face='Verdana' size='2' class='text-danger'>No User Data. Use your login and try!. <br/><br/><br/> </center><br><center><input type='button' value='Retry' onClick='history.go(-1)'></font></center>";
                                echo'<meta http-equiv="refresh"'.'content="3;URL=index">';
                                    
                                }
                                ?>
                            </div>
                          </div>
                        <div class="position-absolute pos-bottom pos-left pos-right p-3 text-center text-white">
                        <script>document.write(new Date().getFullYear());</script> &copy; ENGR COMD 
                    </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
    
<?php 
 include 'endsrc.php';
?>     

