Location: PHPKode > projects > Opensheet > opensheet/pm_reports.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']);
	$login_type = new users();
		if ($_SESSION['permissions']['pm'] !== "1"){
		Header("Location: timesheet.php");
					exit();

		}
		
		#get DM user_id
$user_index = $_SESSION['id'];

?>
<!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.2.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/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>	
	<script type="text/javascript">
			$(document).ready(function(){
				$('.button').live('click',function(){ 
					var id = $(this).attr('id');
						if($(".tr_"+id).is(":visible")){
							$(".tr_"+id).hide();
						}else{
						 	$(".tr_"+id).show();
						}
		return(false); // disable normal anchor behavior
				});
			});
</script>



<!--[if lte IE 7]>
<style type="text/css">
html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/
</style>
<![endif]-->
<title>Project report</title>



  
  <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 

$year = date('Y');
include ('include/menu.pm.inc.html');




# Get PM projects
		$projects = new projects();
		$tasks = new tasks();
		$task_summ = new projects();
		$gettask= new projects();
		$user = new users();
		$hours=new projects();	

		
		
$proj_arr = $projects->getProjectsbyOwner($user_index);






#print_r($proj_types);

#foreach($proj_arr as $num=>$value){

if(isset($_GET['pid']) && isset($_GET['action'])){
		$pid= $_GET['pid'];
		echo '<table class="tablesorter" cellspacing="1" style="width:100%;"><thead><tr><th style="width:22%;">Proj_Name</th>';
			for($month=1;$month<13;$month++)
			{
			echo "<th style='width:6%;'>".$month."</th>";
			}
		echo "<th style='width:6%;'>Summ</th></tr>";
		echo "</thead><tbody>";
		echo "<tr>";
			echo "<td style='width:22%;text-align: left;' id='".$pid."'>".$projects->getProjectName($pid)."</td>";
					for($month=1;$month<13;$month++)
					{
						echo "<td style='width:6%;text-align: center;'>".$projects->getProjSumm($pid,$year,$month)."</td>";
					}
	
			echo "<td style='width:6%;text-align: center;'>".$projects->getProjectSummYear($pid,$year)."</td>";
			echo "</tr>";
	
			foreach($projects->getProjUsers($pid,$year) as $uid=>$value)
			{
					$userTasks = $tasks->getTaskUserByYear($pid,$uid,$year);
						foreach ($userTasks[$uid] as $tid=>$data)
						{
							 foreach($data as $taskMonth=>$statt)
							 {
				 				$temp[$uid][$taskMonth][$tid]="Y";
				 			 }
						}
			}

			foreach($projects->getProjUsers($pid,$year) as $uid=>$value)
			{
				foreach($value as $projMonth=>$trash)
				{
					if (isset($temp[$uid][$projMonth]))
					{
						foreach($temp[$uid][$projMonth] as $tid=>$tstat)
						{
						$array['with_task'][$tid][$uid][$projMonth] = "Y";
						}
					}else
					{
					
					$array['without_task'][$uid][$projMonth] = "Y";
					}
					
				
				}
	
			}
	#	print_r($temp);	
			
			



			foreach($array['with_task'] as $tid=>$value )
			{
					echo "<tr style='background:#F8FFF7;' class='button' id='$tid'>";
					echo "<td style='width:22%;text-align: left;background:#C2E7BE;'>".$tasks->getTaskName($tid)."</td>";
					for($month=1;$month<13;$month++)
					{
					 		echo "<td style='width:6%;text-align: center;'>".$tasks->getTaskMonthSumm($tid,$year,$month)."</td>";
						$summ += $tasks->getTaskMonthSumm($tid,$year,$month);
					}
					echo "<td style='width:6%;text-align: center;'>".$summ."</td>";unset($summ);
					echo "</tr>";
					foreach($value as $uid=>$month_data)
					{
						echo "<tr class='tr_".$tid."' style='display:none;'>";
						echo "<td style='width:22%;text-align: left;' id='".$uid."_task'>".$user->getRealName($uid)."</td>";
						for($month=1;$month<13;$month++)
						{
							if	(isset($month_data[$month]))
							{
								$hours =  $tasks->getTskUsrSummMonth($tid,$uid,$year,$month);
								echo "<td style='width:6%;text-align: center;'>".$hours[$tid]['summ']."</td>";
								$summ +=$hours[$tid]['summ'];
							}else
							{
							echo "<td style='width:6%;text-align: center;'></td>";
							}
						}
						echo "<td style='width:6%;text-align: center;'>".$summ."</td>";unset($summ);
						echo "</tr>";
					}
	
			}
		
			
						#add row about without task
					echo "<tr style='background:#F8FFF7;' class='button' id='without_tasks'>";
					echo "<td style='width:22%;text-align: left;background:#C2E7BE;'>".gettext('Users Without tasks')."</td>";
					for($month=1;$month<13;$month++)
					{
					 		echo "<td style='width:6%;text-align: center;'></td>";
						#$summ += $tasks->getTaskMonthSumm($tid,$year,$month);
					}
					echo "<td style='width:6%;text-align: center;'>".$summ."</td>";unset($summ);
					echo "</tr>";
			
			
			
			foreach($array['without_task'] as $uid=>$month_data )
			{	
					echo "<tr class='tr_without_tasks' style='display:none;'>";
					echo "<td style='width:22%;text-align: left;' id='".$uid."_task'>".$user->getRealName($uid)."</td>";
					for($month=1;$month<13;$month++)
					{
						if	(isset($month_data[$month]))
						{
							$hours =  $projects->getPrjUsrSummMonth($pid,$uid,$year,$month);
							echo "<td style='width:6%;text-align: center;'>".$hours[$pid]['summ']."</td>";
							$summ += $hours[$pid]['summ'];
						}else
						{
							echo "<td style='width:6%;text-align: center;'></td>";
						}
					}
				echo "<td style='width:6%;text-align: center;'>".$summ."</td>";unset($summ);
				echo "</tr>";	
			}	
	
}else
 {  ?>
			<table class="tablesorter" cellspacing="1" style="width:60%;"><thead><tr><th style="width:22%;"><?php echo gettext('project_name');?></th>
			<th style='width:6%;'><?php echo gettext('project_index');?></th>
			<th style='width:6%;'><?php echo gettext('proj_type');?></th>
			<th style='width:6%;'><?php echo gettext('department');?></th>
			<th style='width:6%;'><?php echo gettext('action');?></th>
			<th style='width:6%;'><?php echo gettext('report');?></th></tr>
			</thead><tbody>

<?php 
	
	
	foreach ($proj_types as $num=>$type){
			foreach($proj_arr as $num=>$value){
				if($value['proj_type'] == $type) {
		
					echo "<tr>";
					echo "<td style='text-align:left;'>".$value['proj_name']."</td>";
					echo "<td>".$value['proj_index']."</td>";
					echo "<td>".$value['proj_type']."</td>";
					echo "<td>".$value['']."</td>";
					echo "<td></td>";
					echo "<td><a href='pm_reports.php?pid=".$value['id']."&action=perform_project'  class='add_user_button'><img style='border:0px;' src='images/report-32.png'></td>";
					echo "</tr>";
				}
	
			}
		}
}

?>
</body></html>
Return current item: Opensheet