Location: PHPKode > projects > XPWeb > XPWeb_v3.3.2/XPWeb/View/Reports_view.inc.php
<?php
// *********************************************************************
// Class ReportsGUI
// *********************************************************************

require "View/Planning_view.inc.php";

class ReportsFactoryView extends ReportsFactory {

	function & newReports($arguments) {

		// Create the object
		$object = & parent::newReports($arguments);

		// Create the associated view
		$view = & new ReportsView($object);

		return $object;
	}

}

$gReportsFactory = & new ReportsFactoryView();

class ReportsView extends PlanningView {

	var $imgWidth;
	var $imgHeight;

	function ReportsView (& $item) {

		parent::PlanningView($item);

		$this->imgWidth = 640;

		$this->imgHeight = 480;

	}

	function & getInitGraph() {
		$graph = & new Graph($this->imgWidth, $this->imgHeight, "auto");

		$graph->SetBackgroundImage("View/images/XPWeb_report.png");

		$graph->SetMarginColor("#eeeeee");

		$graph->SetScale("textlin");

		$graph->img->SetMargin(60, 20, 30, 50);

		$graph->SetShadow(true, 5, array(200, 200, 230));

		// Show 0 label on Y-axis (default is not to show)
		$graph->yscale->ticks->SupressZeroLabel(false);
		
		$graph->legend->Pos(0.15, 0.12, "left", "top"); 

		$graph->legend->SetFillColor("hide@address.com"); 

		$graph->SetAlphaBlending(true);

		$graph->img->SetAntiAliasing();

		$graph->yscale->SetGrace(10);
		
		return $graph;
	}

	function getPercent($value, $total) {
		if ($total == 0) {
			return "";
		}
		return sprintf("%.1f", $value / $total * 100)."%";
	}

	function displayPrintHeader() {

		$this->displayMemberHeader();

	}
    
	function display() {
		//
		// Calculations done.  Start displaying.
		//

		if ($this->isPrint) {
			$this->displayPrintHeader();
		}

		$this->_displayScopeStart();
		
		
		if ( $this->item->isReady && @sizeof( $this->item->datax ) > 0 ) {

			// @todo this code should be cleaned up...
			// some of this must be moved to Reports_model

			?>
			<table align="center" class="reports" cellpadding="2" cellspacing="0">
			<tr>
				<th>
					<?=getLang("metric")?>
					<?=echoSpan("fromMember", $this->getFromMemberLegend())?>
				</th>
				<th align="right">
					n
				</th>
				<th align="right">
					%
				</th>
			</tr>

			<!-- stories -->
				
			<tr class="reportHead">
				<td>
					<?=getLang("total_stories")?>
				</td>
				<td class="reportValue">
					<?=$this->item->totalStories?>
				</td>
				<td>
				</td>
			</tr>
    
    		<tr>
				<td class="reportValName">
					<?=getLang("completed")?>
				</td>
				<td class="reportValue">
					<?=$this->item->totalStoriesCompleted?>
				</td>
				<td class="reportValue">
					<?=$this->getPercent($this->item->totalStoriesCompleted, $this->item->totalStories)?>
				</td>
			</tr>

			<tr>
				<td class="reportValName">
					<?=getLang("uncompleted")?>
				</td>
				<td class="reportValue">
					<?=($this->item->totalStories - $this->item->totalStoriesCompleted)?>
				</td>
				<td class="reportValue">
					<?=$this->getPercent(($this->item->totalStories - $this->item->totalStoriesCompleted), $this->item->totalStories)?>
				</td>
			</tr>

			<!-- Story points -->

			<tr class="reportHead">
				<td>
					<?=getLang("total_story_points")?>
				</td>
				<td class="reportValue">
					<?=($this->item->totalStoriesWeightCompleted + $this->item->totalStoriesWeightUncompleted)?>
				</td>
				<td>
				</td>
			</tr>

			<tr>
				<td class="reportValName">
					<?=getLang("completed")?>
				</td>
				<td class="reportValue">
					<?=$this->item->totalStoriesWeightCompleted?>
				</td>
				<td class="reportValue">
					<?=$this->getPercent($this->item->totalStoriesWeightCompleted, $this->item->totalStoriesWeightCompleted + $this->item->totalStoriesWeightUncompleted)?>
				</td>
			</tr>

			<tr>
				<td class="reportValName">
					<?=getLang("uncompleted")?>
				</td>
				<td class="reportValue">
					<?=$this->item->totalStoriesWeightUncompleted?>
				</td>
				<td class="reportValue">
					<?=$this->getPercent($this->item->totalStoriesWeightUncompleted, $this->item->totalStoriesWeightCompleted + $this->item->totalStoriesWeightUncompleted)?>
				</td>
			</tr>

			</table>

			<?php
			// Setup the graph. 
			
	   		$graph = & $this->getInitGraph();
    		
        	// Set up the title for the graph
        	$graph->title->Set(getLang("stories")." ".$this->getFromMemberLegend());

        	$graph->SetScale("textlin", 0, $this->item->maxStoriesPerIte);
			$graph->xaxis->SetTickLabels($this->item->datax);
	            
        	$graph->xaxis->title->Set(getLangNoHtml("type_iteration"));
	       	$graph->yaxis->title->Set(getLangNoHtml("stories"));
    		$graph->AdjustMarginsForTitles();

			// Completed during
    		$plotCompletedDuring =
				& new BarPlot($this->item->dataYStoriesCompletedDuring);

    		$plotCompletedDuring->SetFillColor("#hide@address.com");
    		$plotCompletedDuring->SetLegend( getLangNoHtml("completed_during") );
    		$plotCompletedDuring->value->Show();
    		$plotCompletedDuring->value->SetFormat("%d");

			// In progress

    		$plotInProgress =
				& new BarPlot($this->item->dataYStoriesInProgress);

    		$plotInProgress->SetFillColor("#hide@address.com");
    		$plotInProgress->SetLegend( getLangNoHtml("in_progress") );
    		$plotInProgress->value->Show();
    		$plotInProgress->value->SetFormat("%d");

			// Completed prior

    		$plotCompletedPrior =
				& new BarPlot($this->item->dataYStoriesCompletedPrior);

    		$plotCompletedPrior->SetFillColor("#hide@address.com");
    		$plotCompletedPrior->SetLegend( getLangNoHtml("completed_prior") );
    		$plotCompletedPrior->value->Show();
    		$plotCompletedPrior->value->SetFormat("%d");
    		
			// Not started

    		$plotNotStarted =
				& new BarPlot($this->item->dataYStoriesNotStarted);

    		$plotNotStarted->SetFillColor("hide@address.com");
    		$plotNotStarted->SetLegend( getLangNoHtml("not_started") );
    		$plotNotStarted->value->Show();
    		$plotNotStarted->value->SetFormat("%d");

    		// Create the accumulated bar plots
    		$ab1plot = & new AccBarPlot(
				array (
					$plotCompletedPrior,
					$plotCompletedDuring,
					$plotInProgress,
					$plotNotStarted
				)
			);

			// ...and add it to the graph
    		$graph->Add($ab1plot);

    		// Finally send the graph to the browser
    		$imgStoriesSrc = XP_REPORT_TEMP_PATH."/Graph-Stories.png";
    		
    		$graph->Stroke($imgStoriesSrc);

    		?>
				<img class="reportImg" src="<?=$imgStoriesSrc?>?<?=urlencode(microtime())?>" alt="Stories" width="<?=$this->imgWidth?>" height="<?=$this->imgHeight?>"/>
			<?php
			
		} else {	
			echoDiv("error", getLang("nodata"));
		}

		//
		// Quality
		//
		
		if ( file_exists( "View/ReportsQuality_view.inc.php" ) ) {
			include( "View/ReportsQuality_view.inc.php" );

			$this->_displayQualityStart();
			
			// Defined in included file above
			
			displayQualityUnit();
    		displayQualityAcceptance();
		
		}

		//
		// Time
		//

		if ( $this->item->isReady ) {
			$this->_displayTimeStart();			
			
			//
			// Make sure their is data to display
			//

			if (@sizeof($this->item->datax) > 0) {

				?>
				<table align="center" class="reports" cellpadding="2" cellspacing="0">
				<tr>
					<td>
						<?=getLang("velocity_exp")?>
    					<br/>
	    				<?=echoSpan("fromMember", $this->getFromMemberLegend())?>
					</td>
					<td class="reportValue">
    					<?=sprintf( "%.1f", $this->item->velocity)?>
    				</td>
				</tr>
    			</table>

				<?php				
    			$graph = & $this->getInitGraph();
    			
    			// Setup the graph. 
    			// Set up the title for the graph
    			$graph->title->Set(getLangNoHtml("velocity")." ".$this->getFromMemberLegend());

    			// Show 0 label on Y-axis (default is not to show)
    			$graph->xaxis->title->Set( getLangNoHtml("type_iteration") );
    			$graph->xaxis->SetTickLabels( $this->item->datax );
    			$plotCompletedDuring = & new BarPlot( $this->item->dataYIterationTaskWeight );
    			$plotCompletedDuring->SetFillColor("#hide@address.com");
    			$plotCompletedDuring->SetLegend( getLangNoHtml("task_weight") );
    			$plotCompletedDuring->value->Show();
    			$plotCompletedPrior = & new BarPlot( $this->item->dataYIterationTaskDone );
    			$plotCompletedPrior->SetFillColor("#hide@address.com");
    			$plotCompletedPrior->SetLegend("(".getLangNoHtml("real_days").")");
    			$plotCompletedPrior->value->Show();
    			$plotInProgress = & new BarPlot($this->item->dataYIterationStoryWeight);
    			$plotInProgress->SetFillColor("#hide@address.com");
    			$plotInProgress->SetLegend( getLangNoHtml("story_weight") );
    			$plotInProgress->value->Show();

    			// Create the grouped bar plot
    			$gbplot = & new GroupBarPlot( array($plotInProgress,$plotCompletedDuring,$plotCompletedPrior) );

    			// ...and add it to the graph
    			$graph->Add($gbplot);

    			// Finally send the graph to the browser
    			
    			$imgTimeSrc = XP_REPORT_TEMP_PATH."/Graph-Time.png";
    			
    			$graph->Stroke($imgTimeSrc);
				
				?>
					<img class="reportImg" src="<?=$imgTimeSrc?>?<?=urlencode(microtime())?>" alt="Time" width="<?=$this->imgWidth?>" height="<?=$this->imgHeight?>"/>
					<br/>
				<?php
	
			} else {	
				echoDiv("error", getLang("nodata"));
			}
		}
	}	

	function _displayScopeStart() {
		newSectionStart();
		echo getLang("scope");		
		newSectionEnd();
	}

	function _displayQualityStart() {
		newSectionStart();
		echo getLang("quality");
		newSectionEnd();
	}

	function _displayTimeStart() {
		newSectionStart();
		echo getLang("time");
		newSectionEnd();
	}

	function _displayResourcesStart() {
		newSectionStart();
		echo getLang("resources");
		newSectionEnd();
	}

	function displayChoosePrintOptions() {
		$this->setPrint();

		displayPrintParamFormStart(false);

		$this->displayBasicOptions();

		displayPrintParamFormEnd();
	}
	
	function displaySpecificOptions() {
		// No specific options for reports
	}
	
}

function getPostedReportsParams() {
	global $MEMBER_TASKS;
	
	if (isSet($_GET[XP_PLANNING_POP_RESPONSIBLE])) {
        $MEMBER_TASKS = $_GET[XP_PLANNING_POP_RESPONSIBLE];
    }
}

?>
Return current item: XPWeb