<?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');
?>