<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
session_start();
include ('start.php'); ## ÑÑиÑаем вÑÐµÐ¼Ñ Ð½Ð° генеÑаÑÐ¸Ñ ÑÑÑаниÑÑ
#include ("include/auth_chk.inc.php");
#require ('functions/projects.inc.php');
#require ('functions/users.inc.php');
require ('functions/base.functions.php');
require ('functions/draw.pics.inc.php');
include ('classes/global.class.php');
set_lang($_SESSION['lang']);
#Get date of reports
$project_type = isset($_POST['projects_switch'])? $_POST['projects_switch'] : 'project';
$project_type ='project';
if (isset($_POST['timestamp'])) {
$timestamp = $_POST['timestamp'];
$month = date("n",$timestamp);
$year = date("Y",$timestamp);
} elseif (isset($_POST['year']) && ($_POST['month'])) {
$month = $_POST['month'];
$year = $_POST['year'];
}else {
$month = date("n");
$year = date("Y");
}
?>
<!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 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>
<!--[if lte IE 7]>
<style type="text/css">
html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/
</style>
<![endif]-->
<title>Users Stats</title>
</head>
<body>
<?php
include ('include/menu.reports.inc.html');
include ('include/reports_users.buttons.inc.html');
echo $project_type;
$stats = new Projects;
$users = new Users;
$projects = $stats->getProjectsByTypeFromSheet($project_type,$year,$month);
#echo "<pre>";
$stats = $stats->hoursProjectByType($project_type,$year,$month);
$empty_cells=36 - count($projects);
echo $empty_cells;
#print_r($stats->getProjectsByTypeFromSheet($project_type,$year,$month));
echo '<table style="width:100%;border: 1px solid black;"><tr>';
echo '<th style="width:25%;border: 1px solid black;">'.gettext('users').'</th>';
foreach ($projects as $key=>$value){
echo '<th>'.$key.'</th>';
}
echo '<th>'.gettext('summ').'</th>';
for($empty_cell=0;$empty_cell<$empty_cells;$empty_cell++){
echo '<th> </th>';
}
echo "</tr>";
foreach($stats as $user=>$data){
echo "<tr><td style='width:25%;'>". $users->getRealName($user)." </td>";
foreach ($projects as $key=>$value){
echo '<td>'.$data[$key].'</td>';
}
echo '<th></th>';
for($empty_cell=0;$empty_cell<$empty_cells;$empty_cell++){
echo '<th> </th>';
}
echo "</tr>";
}
#ÑиÑÑем ÑапкÑ
#echo '<table class="p_header" ><tr>';
#echo '<td class="reports" scope="col">СоÑÑÑдники</td>';
#for($i=0;$i<$howmany_projects;$i++){
#$img_name = draw_proj($proj_array[$i]['proj_name']);
#echo '<td class="proj_pics" scope="col"><img src="cache/'.$img_name.'"></td>';
#}
#echo '<td class="proj_pics">ÐÑего</td>';
#for($empty_cell=0;$empty_cell<$empty_cells;$empty_cell++){
#echo '<td class="proj_pics" scope="col"></td>';
#}
#echo '</tr>';
#ÐаполнÑем даннÑми
#for ($u=0;$u<$howmany_users;$u++){
#echo '<tr>';
#echo '<td class="reports">'.$stats[$user_list[$u]]['real_name'].'</td>';
#for($i=0;$i<$howmany_projects;$i++){
# echo '<td class="month">'.$stats[$user_list[$u]][$proj_array[$i]['proj_index']]['hours'].'</td>';
# $stats[$user_list[$u]]['sum']= $stats[$user_list[$u]][sum]+$stats[$user_list[$u]][$proj_array[$i]['proj_index']]['hours'];
# $prj_sum[$proj_array[$i]['proj_index']]=$prj_sum[$proj_array[$i]['proj_index']]+$stats[$user_list[$u]][$proj_array[$i]['proj_index']]['hours'];
#}
#echo '<td class="summ" scope="col">'.$stats[$user_list[$u]]['sum'].'</td>';
#for($empty_cell=0;$empty_cell<$empty_cells;$empty_cell++){
#echo '<td class="month" scope="col"></td>';
#}
#echo '</tr>';
#}
#echo '</tr>';
#echo '<tr>';
#echo '<td class="reports" scope="col">СÑмма по ÐÑоекÑам</td>';
#$proj_nums_summ=array_keys($prj_sum);
#for($i=0;$i<$howmany_projects;$i++){
# echo '<td class="month" scope="col">'.$prj_sum[$proj_nums_summ[$i]].'</td>';
#}
#echo '<td class="summ" width="10%" rowspan="2" scope="col">'.array_sum($prj_sum).'</td>';
#for($empty_cell=0;$empty_cell<$empty_cells;$empty_cell++){
#echo '<td class="month" scope="col"></td>';
#}
#echo '</tr></table>';
##TEST
include ('end.php');
?>