<?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']);
$login_type = new users();
if ($_SESSION['permissions']['dm'] !== "1"){
Header("Location: timesheet.php");
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="css/south-street/jquery-ui-1.7.1.custom.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="css/jqueryslidemenu.css" />
<link rel="stylesheet" href="css/green/style.css" type="text/css" media="print, projection, screen" />
<link rel="stylesheet" href="js/addons/pager/jquery.tablesorter.pager.css" type="text/css" media="print, projection, screen" />
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.7.1.custom.min.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/jqueryslidemenu.js"></script>
<script type="text/javascript" src="js/addons/pager/jquery.tablesorter.pager.js"></script>
<script src="js/i18n/jquery-ui-i18n.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()Â {Â
    $(".tablesorter")Â
    .tablesorter({widthFixed: true, widgets: ['zebra']})Â
});Â
</script>
<!--[if lte IE 7]>
<style type="text/css">
html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/
</style>
<![endif]-->
<title>Exports</title>
</head>
<script type="text/javascript">
$(function() {
$.datepicker.formatDate('yy-mm-dd');
$("#datepicker_start").datepicker();
});
</script>
<script type="text/javascript">
$(function() {
$.datepicker.setDefaults($.datepicker.regional['ru']);
$("#datepicker_end").datepicker();
});
</script>
</head>
<body>
<?php
include ('include/menu.dm.inc.html');
if (isset($_POST['date_1'])){
$date_start = date('Y-m-d', strtotime($_POST['date_1']));
}else{
$date_start = date('Y-m-d');
}
# echo $date_start;
if (isset($_POST['date_2'])){
$date_finish = date('Y-m-d', strtotime($_POST['date_2']));
} else{
$date_finish = date('Y-m-t');
}
#
# echo $date_finish;
if (isset($_POST['type'])){
$proj_type = $_POST['type'];
} else{
$proj_type = 'All';
}
#print_r($_POST);
#$proj_type = $_POST['type'];
#echo "<pre>";
# Get PM projects
#$year= '2009';
$user_index = $_SESSION['id'];
$groups = new Groups();
$projects = new Projects;
$hours = new Stats;
$group = $groups->getOwnersGroup($user_index);
$array = array();
$year = date(Y);
$month = date(n);
?>
<form method='POST' action="">
<table style="width: 100%;height: 40px;"><tr><td style="width: 20%;"><?php echo gettext('start');?><input id="datepicker_start" type='text' name='date_1' maxlength="40" size='15'></td>
<td style="width: 20%;"><?php echo gettext('end');?><input id="datepicker_end" type='text' name='date_2' maxlength="40" size='15'></td>
<td style="width: 10%;"><select name="type">
<option value="project">ÐÑоекÑÑ</option>
<option value="tender">ТендеÑÑ</option>
<option value="office">ÐÑиÑÐ½Ð°Ñ ÑабоÑа</option>
<option value="off_hours">ÐÑÑÑÑÑÑвие</option>
<option value="All">ÐÑе</option>
</td>
<td style="width: 10%;"><input type='submit' name='ok' value='ÐоеÑ
али'></form></td>
<?php if (isset($date_start) && isset($date_finish) && isset($proj_type) ) {?>
<td style="width: 10%;"> <a href="functions/export.xls.dm.projects.php?start=<?php echo $date_start;?>&finish=<?php echo $date_finish;?>&type=<?php echo $proj_type;?>"><img style='border:0px;'src="images/xls.png"></a></td>
<?php }else { ?>
<td style="width: 10%;"></td>
<?php } ?>
<td style="width: 30%;"></td></tr></table>
<?php
#if (isset($_POST['ok'])){
$user = new Users;
$project = new Projects;
$group = new Groups;
?>
<table class="tablesorter" cellspacing="1" style="width:100%;">
<thead>
<tr>
<th style="width:25%;"><?php echo gettext('User name');?></th>
<th style="width:15%;"><?php echo gettext('project_name');?></th>
<th style="width:15%;"><?php echo gettext('hours');?></th>
<th style="width:10%;"><?php echo gettext('owner');?></th>
<th style="width:10%;"><?php echo gettext('proj_type');?></th>
<th style="width:20%;"><?php echo gettext('group');?></th>
</tr>
</thead>
<tbody>
<?php
foreach($groups->getOwnersGroup($user_index) as $vars){
foreach ($groups->getGroupUsers($vars['id']) as $num=>$value){
foreach($hours->getPrjHoursPerDayByUser($date_start,$date_finish,'All',$value['id']) as $uid=>$value){
foreach($value as $pid=>$data){
$proj_type = array_keys($data);
echo "<tr>";
echo "<td>".$user->getRealName($uid)."</td>";
echo "<td>".$project->getProjectName($pid)."</td>";
echo "<td>".$data[$proj_type['0']]."</td>";
echo "<td>".$project->getProjOwner($pid)."</td>";
echo "<td>".$proj_type['0']."</td>";
echo "<td>".$user->getUserGroup($uid)."</td>";
echo "</tr>";
}
}
}
}
?>
</tbody>
</table>