<?php
	session_start();

    require_once('libs/Ultraviolet.php');

	require_once('libs/Database.php');

	require_once('libs/AdminFunctions.php');

	$database =& DatabaseConnect::getInstance();

	$database->query("SET CHARACTER SET utf8");

	$functions =& AdminFunctions::getInstance();

	$user_ip=$_SERVER['REMOTE_ADDR'];

		$user = $_SESSION['admin_username'];

	//if($user_ip != '89.216.16.219' ) {

		//if($user_ip != '92.244.141.162'){

		//header('location:login.php?error=Nije dozvoljen pristup sa vaše IP adrese');}

	//}

			if(!isset($_SESSION['admin_username'])){


		header('location:login.php');
	}



$page = (isset($_GET['page'])) ? $_GET['page'] : 'homepage' ;

$action = (isset($_GET['action'])) ? $_GET['action'] : 'client' ;

		$database->setBareQuery("SELECT user_type FROM admin_users WHERE user_name = '".$_SESSION['admin_username']."'");

		$type = $database->loadResultArray(0);



	if(!isset($_SESSION['week'])){



		$week = 0;

	}

	elseif(isset($_GET['week'])){

		$week = 0;

		}

	else {
		$week = $_SESSION['week'];

	}

	$nextw = $week + 7;

	$prevw = $week - 7;

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="language" content="en" />
		<meta name="description" content="" />
		<meta name="keywords" content="" />
		<title>Timesheet</title>
        <link href="css/style.css" rel="stylesheet" type="text/css" media="screen" />

        <?php if($page === 'tools') { ?>

        <link href="css/forms.css" rel="stylesheet" type="text/css" media="screen" />

		<?php } ?>

        <script type="text/javascript" src="javascript/jquery-1.3.2.min.js"></script>
				<link rel="icon" type="image/png" href="./images/ikonica.png">



	</head>

	<body>

    <?php

    if($page == 'tools'):

    	include('pages/projects.php');

	elseif($page == 'reports'):

		include('pages/reports.php');

    else:

    ?>

        <div id="header">

			<div id="period-prev">prethodna nedelja</div><div id="user-panel"> <a href="admin.php?week=current"><?=$_SESSION['admin_fname']?> <?=$_SESSION['admin_lname']?></a> <a href="libs/Authenticate.php?login=logout"><img src="images/signout.png" /></a><span id="choice-pick"><?php if($type[0] == '1'){ ?><a href="admin.php?page=tools">Dodaj / izmeni projekat</a> | <a href="admin.php?page=reports">Izveštaji</a><? } ?></span></div><div id="period-next">sledeća nedelja</div>



            <div class="clear"></div>

        </div>
        <div id="page">

            <div id="content">

            	<?php

					include('pages/users.php');

				?>

            </div>

            <div id="extras">

            	<div class="extras-cell">

                	<div class="left"><span class="gray">ROĐENDANI:</span><span id="birthdayload"></span></div><div class="right"></div>
                </div>

                <div class="extras-cell">

                <div class="left"><span class="gray">DOGODILO SE:</span>

                <?php

				$database->setBareQuery("SELECT content FROM events WHERE date = '".date("Y-m-d")."'");

				$events = $database->loadResultArray(0);

				$i = rand(0, count($events)-1);

				echo $events[$i];

				?>


                </div>

                <div class="right">

                		<form id="event" class="" method="post" action="">
                        	<label> Događaj:</label>
        					<input type="text" name="event-text" id="event-text" value="" class="pending" />
                            <input type="submit" id="send-search" value="" />
                        </form></div>

                </div>

                <div class="extras-cell">

                <div class="left"><span class="gray">DREVNE MUDROSTI:</span>

                 <?php

				$database->setBareQuery("SELECT content, date FROM wisdoms");

				$wisdom = $database->loadResultArray(0);

				$date = $database->loadResultArray(1);

				$i = rand(0, count($wisdom)-1);

				$setdate = explode("-", $date[$i]);

				echo $setdate[2].'.'.$setdate[1].'.'.$setdate[0].' '.$wisdom[$i];

				?>

                </div>

                <div class="right">

                	<form id="wisdom" class="" method="post" action="">
                    		<label>Mudrost:</label>
        					<input type="text" name="wisdom-text" id="wisdom-text" value="" class="pending" />
                            <input type="submit" id="send-search" value="" />
                        </form></div>

                </div>

            </div>

        </div>

        <div id="footer"></div>

       <?php endif; ?>

        <script type="text/javascript" src="javascript/functions.js"></script>

  <link rel="stylesheet" href="css/jquery.autocomplete.css" type="text/css" />
  <script type="text/javascript" src="javascript/jquery.bgiframe.js"></script>
  <script type="text/javascript" src="javascript/jquery.dimensions.js"></script>
  <script type="text/javascript" src="javascript/jquery.autocomplete.js"></script>

	<script type="text/javascript">

		var user = '<?=$user?>';

	</script>




	</body>
</html>
