<?php
    session_start();
	if ( empty($_SESSION['login']) ) {
        header( 'Location: login.php' );
        die;
	}

	include 'include/header.php';
?>

    <script type="text/javascript">
        $(function(){
            $('#report').load(function() {
                this.style.height = this.contentWindow.document.body.scrollHeight + 'px';
            });
        });
    </script>

    <div class="wrap">

        <h1 class="pad">USM - Report Viewer</h1>

        <div id="nav">
            <a href="/">Home</a>
            <a href="roomList.php">Room View</a>
            <a href="reports.php" class="selected">Reports</a>
            <a href="admin.php">Administration</a>
            <a href="logout.php">Logout</a>
        </div>

        <hr>
<?php
    include 'include/database.php';
    $connection = connect($database);
    $canAdmin = canAdministrate($connection, $_SESSION['login']);
	$connection = null;
	if ( $canAdmin ) {
        echo '
        <iframe id="report" class="center pad-bottom" src="reportico/runadmin.php?clear_session=1" seamless></iframe>
        ';
	} else {
        echo '
        <iframe id="report" class="center pad-bottom" src="reportico/run.php?clear_session=1" seamless></iframe>
        ';
    }
?>
        
    </div>

<?php include('include/footer.php'); ?>