Location: PHPKode > projects > Opensheet > opensheet/timesheet.php
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
session_start();
	
	

include ('start.php'); ## считаем время на генерацию страницы
require ('functions/base.functions.php');
include ('classes/global.class.php');
set_lang($_SESSION['lang']);

$user= new Users;


#Проверяем пользователя Есть нет в пост, тоесть не передан до этого скриптом берем из сессий
#Добавить проверку на сессии !!
$user_ip = $_SERVER['REMOTE_ADDR'];#clients ip adress
$user_agent = $_SERVER['HTTP_USER_AGENT'];# clients web browser
	
    
if (isset($_POST['user_index'])){
	$user_index = $_POST['user_index'];	}
			elseif (isset ($_GET['user_index'])){
	$user_index = $_GET['user_index'];}
			elseif (isset ($_SESSION['id'])){
		$user_index = $_SESSION['id'];}
			else {
				$login = $_SESSION['id'];
				$user_index = $_SESSION['id'];
				
}

#print_r($_SESSION);


#timestep_dates это массив с проектами днями и часами работы
#Проверяем установки времени, полученные записываем  в переменные



			#we realy need to know date of sheet
		if (isset($_POST['timestamp'])) {
			$timestamp = $_POST['timestamp'];
			$month = date("m",$timestamp);
			$year = date("Y",$timestamp);
	
 		   } elseif (isset($_GET['year']) && ($_GET['month'])) 
 		   {
  			  $month  = $_GET['month'];
  			  $year  = $_GET['year'];	
  			  }elseif (isset($_POST['year']) && ($_POST['month'])){
  				  $month  = $_POST['month'];
  				  $year  = $_POST['year'];		 
  		      }else {
				$month = date("m");
				$year = date("Y");
			}



		#Пwrite timesheet hours to database
		if (isset($_POST['hours']) && isset($_POST['year']) && isset($_POST['month']) && isset($_POST['user_id']) ) {
			$year = $_POST['year'];
			$month = $_POST['month'];
			$array=$_POST['hours'];
			$hours = new Timesheet;
			$hours->setHours($user_index,$array,$year,$month);
			unset($array);
		}






		#write notes hours to database
		if (isset($_POST['add_notes']) && isset($_POST['year']) && isset($_POST['month']) && isset($_POST['user_id']) ) {
			$year = $_POST['year'];
			$month = $_POST['month'];
			$array=$_POST['notes'];
			$notes = new Timesheet;
			$notes->setNotes($user_index,$array,$year,$month);
			unset($array);
		}

			#add page header and js
				include('include/page.header.timesheet.inc.html');

			#Get company name and settings

			$settings = new getSetting();
			$stats = new Stats;
			$user = new Users;
		echo  '</head><body style="padding: 1px; background:#fc0;"><table class="main" >';

			#draw UsersMenu 
		$drawTSMenu = new drawPage;
		$drawTSMenu->drawTSheader($_SESSION['id'],$user_index,$year,$month,$_SESSION['permissions']);

			#timesheet menu
		include('include/page.timesheet.header.inc.html');
			#timesheet tables
		include('include/draw.time.table.new.inc.php');


				#lets draw footer
			if ($stats->getWorkDays($year,$month) == '0')
    		{ 
    			echo "<center>".gettext('We have no holidays, ask you admin')."</center>";
   			} else { include ('include/page.timesheet.foo.inc.html');}


include('include/notes.inc.php');

?>
Return current item: Opensheet