<?php
include($_SERVER['DOCUMENT_ROOT'] . "/Authorization/script/php/permission/check_right.php");
?>
<!doctype html>
<html class="fixed">

<head>
    <!-- Basic -->
    <meta charset="UTF-8">
    <title>設計資料庫工具</title>
    <meta name="keywords" content="HTML5 Admin Template" />
    <meta name="description" content="JSOFT Admin - Responsive HTML5 Template">
    <meta name="author" content="JSOFT.net">

    <script src="/DataBase/assets/vendor/jquery/jquery.js"></script>
    <script src="/Common/script/js/user-image.js"></script>
    <!-- Mobile Metas -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />

    <!-- Web Fonts  -->
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800|Shadows+Into+Light" rel="stylesheet" type="text/css">

    <!-- Vendor CSS -->
    <link rel="stylesheet" href="assets/vendor/bootstrap/css/bootstrap.css" />
    <link rel="stylesheet" href="assets/vendor/font-awesome/css/font-awesome.css" />
    <link rel="stylesheet" href="assets/vendor/magnific-popup/magnific-popup.css" />
    <link rel="stylesheet" href="assets/vendor/bootstrap-datepicker/css/datepicker3.css" />

    <!-- Specific Page Vendor CSS -->
    <link rel="stylesheet" href="assets/vendor/select2/select2.css" />
    <link rel="stylesheet" href="assets/vendor/jquery-datatables-bs3/assets/css/datatables.css" />

    <!-- Theme CSS -->
    <link rel="stylesheet" href="assets/stylesheets/theme.css" />

    <!-- Skin CSS -->
    <link rel="stylesheet" href="assets/stylesheets/skins/default.css" />

    <!-- Theme Custom CSS -->
    <link rel="stylesheet" href="assets/stylesheets/theme-custom.css">

    <!-- Head Libs -->
    <script src="assets/vendor/modernizr/modernizr.js"></script>
    <script src="assets/vendor/jquery/jquery.js"></script>


    <!-- Icon -->
    <link rel="shortcut icon" href="assets/images/favicon.ico" />
    <style>
        body {
            color: #000;
        }

        .page-header>ul {
            list-style: none;
            padding: 0;
            margin: 0;
        }

        .page-header>ul>li {
            display: inline-block;
            font-size: 25px;
            color: #FFFFFF;
        }

        .page-header>ul>li.right {
            float: right;
            padding-right: 10px;
        }

        .input-search {
            margin-top: 8px;
        }

        .page-header li>label {
            margin-top: 13px;
            border-bottom: 4px solid #0088cc;
            height: 41px;
            padding-left: 40px;
        }

        .sidebar-left {
            box-shadow: 0 0 0;
        }

        .jstree-default .jstree-icon {
            color: #ffe693;
        }

        .jqsfield {
            color: white;
            font: 10px arial, san serif;
            text-align: left;
        }

        .jstree-anchor {
            width: 250px;
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
        }

        .jstree-anchor,
        .jstree-anchor:link,
        .jstree-anchor:visited,
        .jstree-anchor:hover,
        .jstree-anchor:active {
            color: #abb4be;
        }

        td,
        th {
            text-align: center;

        }


        .nav-main {
            padding: 15px;
        }

        .node-hidden {
            display: none;
        }

        html.fixed .page-header {
            left: 0px;
        }

        html.fixed .content-body {
            margin-left: 0px;
        }

        .sidebar-left {
            width: 0px;
        }

        #viewDiv {
            height: 100%;
            width: 100%;
        }

        #zoom {
            margin-bottom: 5px;
        }

        #actions {
            padding: 5px;
        }

        .container {
            height: 50%;
            width: 100%;
        }

        #createSlideDiv {
            background-color: white;
            opacity: 0.9;
            color: black;
            padding: 6px;
        }

        #slidesDiv {
            background-color: white;
            opacity: 0.9;
            color: black;
            padding: 10px;
            visibility: hidden;
            bottom: 20px;
            overflow-y: auto;
            text-align: center;
            height: 260px;
        }

        #slidesDiv .slide {
            /* Show cursor as pointer when on a slide */
            cursor: pointer;
            margin-bottom: 6px;
        }

        #slidesDiv .slide .title {
            /* Center the title text */
            text-align: center;
        }

        /* Draw active slide with a nice border around the thumbnail */

        #slidesDiv .slide.active img {
            box-shadow: 0px 0px 12px black;
            border-style: solid;
            border-width: thin;
            border-color: black;
        }


        #topbar {
            background: #fff;
            padding: 10px;
        }
    </style>


</head>

<body>
    <section class="body">
        <!-- start: header -->
        <header class="header">
            <div class="logo-container">
                <div class="banner-txt">設計資料庫匯入工具</div>
                <div class="visible-xs toggle-sidebar-left" data-toggle-class="sidebar-left-opened" data-target="html" data-fire-event="sidebar-left-opened">
                    <i class="fa fa-bars" aria-label="Toggle sidebar"></i>
                </div>
            </div>
            <!-- start: search & user box -->
            <div class="header-right">
                <span class="separator"></span>
                <ul class="notifications">
                    <li>
                        <a href="/DataBase/index.php" class="notification-icon" data-toggle="tooltip" title="設計資料庫查詢" data-placement="bottom">
                            <i class="fa fa-database"></i>
                        </a>
                        <a href="/Front-Page/home.php" class="notification-icon" data-toggle="tooltip" title="綜合登入入口" data-placement="bottom">
                            <i class="fa fa-home"></i>
                        </a>
                    </li>
                </ul>
                <span class="separator"></span>
                <div id="userbox" class="userbox">
                    <a href="#" data-toggle="dropdown">
                        <figure class="profile-picture"> <img src="/DataBase/assets/images/!logged-user.jpg" alt="Joseph Doe" class="img-circle" data-lock-picture="/DataBase/assets/images/!logged-user.jpg" /> </figure>
                        <div class="profile-info" data-lock-name="John Doe" data-lock-email="johndoe@JSOFT.com"> <span class="name"><?php echo $_SESSION['name'] ?></span> <span class="role"><?php echo ($groupName); ?></span>
                        </div> <i class="fa custom-caret"></i>
                    </a>
                    <div class="dropdown-menu">
                        <ul class="list-unstyled">
                            <li class="divider"></li>
                            <li> <a role="menuitem" tabindex="-1" href="/DataBase/script/php/Logout.php"><i class="fa fa-power-off"></i> Logout</a> </li>
                        </ul>
                    </div>
                </div>
            </div>
            <!-- end: search & user box -->
        </header>
        <!-- end: header -->
        <div class="inner-wrapper">
            <!-- start: sidebar -->

            <section role="main" class="content-body">
                <header class="page-header">
                    <ul>
                        <li>
                            <label id="header">LOG日誌</label>
                        </li>
                    </ul>
                </header>
                <section class="panel">
                    <header class="panel-heading">
                        <div class="panel-actions">
                            <a href="#" class="fa fa-caret-down"></a>
                            <a href="#" class="fa fa-times"></a>
                        </div>
                        <h2 class="panel-title">匯入日誌</h2>
                    </header>
                    <div class="panel-body">
                        <table class="table table-bordered table-striped mb-none" id="datatable">
                            <thead>
                                <tr>
                                    <th>上傳人員</th>
                                    <th>所屬部門</th>
                                    <th>計畫編號</th>
                                    <th>計畫名稱</th>
                                    <th>上傳時間</th>
                                </tr>
                            </thead>
                            <tbody id="table-data">

                            </tbody>
                        </table>
                    </div>
                </section>
        </div>
    </section>
    </div>


    </section>


</body>

<!-- Vendor -->
<script src="assets/vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.js"></script>
<script src="assets/vendor/nanoscroller/nanoscroller.js"></script>
<script src="assets/vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
<script src="assets/vendor/magnific-popup/magnific-popup.js"></script>
<script src="assets/vendor/jquery-placeholder/jquery.placeholder.js"></script>

<!-- Specific Page Vendor -->
<script src="assets/vendor/select2/select2.js"></script>
<script src="assets/vendor/jquery-datatables/media/js/jquery.dataTables.js"></script>
<script src="assets/vendor/jquery-datatables/extras/TableTools/js/dataTables.tableTools.min.js"></script>
<script src="assets/vendor/jquery-datatables-bs3/assets/js/datatables.js"></script>

<!-- Theme Base, Components and Settings -->
<script src="assets/javascripts/theme.js"></script>

<!-- Theme Custom -->
<script src="assets/javascripts/theme.custom.js"></script>

<!-- Theme Initialization Files -->
<script src="assets/javascripts/theme.init.js"></script>


<script type="text/javascript">
    var userName = "<?php //echo $_SESSION['name'] 
                    ?>";
    var role = "<?php //echo ($groupName); 
                ?>";
    //var right = <?php //echo $right; 
                    ?>;
    getLog();

    function getLog() {
        $.ajax({
            url: "./script/php/get_log.php",
            type: "POST",
            dataType: "json"
        }).done(function(result) {

            result.forEach(function(data) {
                $('#table-data').append(`<tr>
						<td>${data.UserID}</td>
						<td>${data.DepartmentName}</td>
						<td>${data.project_id}</td>
						<td>${data.project_name}</td>
						<td>${data.upload_time}</td>
					</tr>`);

            });

        }).error(function(error) {
            console.log(error);
        }).complete(function(e) {
            $('#datatable').DataTable({
                bProcessing: true,
                responsive: true,
                "searching": true,
                "pageLength": 10,
                "language": {
                    "processing": "處理中...",
                    "loadingRecords": "載入中...",
                    "lengthMenu": "顯示 _MENU_ 項結果",
                    "zeroRecords": "沒有符合的結果或是沒有資料",
                    "info": "顯示第 _START_ 至 _END_ 項結果，共 _TOTAL_ 項",
                    "infoEmpty": "顯示第 0 至 0 項結果，共 0 項",
                    "infoFiltered": "(從 _MAX_ 項結果中過濾)",
                    "infoPostFix": "",
                    "search": "",
                    "paginate": {
                        "first": '<i class="fa fa-step-backward"></i>',
                        "previous": '<i class="fa fa-backward"></i>',
                        "next": '<i class="fa fa-forward"></i>',
                        "last": '<i class="fa fa-step-forward"></i>'
                    },
                    "aria": {
                        "sortAscending": ": 升冪排列",
                        "sortDescending": ": 降冪排列"
                    }
                },
            });
            $('body .dropdown-toggle').dropdown();
            $("body").on('click', '.groupDropdown', function(e) {
                let groupName = $(this).text();
                let groupID = $(this).attr('groupID');
                let userAccount = $(this).closest("td").attr('id');
                $(this).closest("td").append(addPermission(groupID, groupName, userAccount));
            })
        });
    }
</script>


</html>