@owner Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb @copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /-------------------------------------------------------------------------------------------------------/ Cost Benefit Projection Tool. /------------------------------------------------------------------------------------------------------*/ // No direct access to this file defined('_JEXEC') or die('Restricted access'); // load chart builder $chart = new Chartbuilder('BarChart'); $scaled = array('unscaled','scaled'); if(isset($this->results->interventions) && CostbenefitprojectionHelper::checkArray($this->results->interventions)){ $intervention_number = 0; foreach ($this->results->interventions as $intervention){ if (isset($intervention->items)) { foreach ($scaled as $scale){ $i =0; $rowArray = array(); if(is_array($intervention->items) || is_object($intervention->items)){ foreach ($intervention->items as $key => &$item){ $rowArray[] = array('c' => array( array('v' => $item->name), array('v' => round($item->{'cost_of_problem_'.$scale}), 'f' => $item->{'costmoney_of_problem_'.$scale}), array('v' => $item->cost, 'f' => $item->costmoney), array('v' => $item->{'benefit_'.$scale}, 'f' => $item->{'benefitmoney_'.$scale}), array('v' => $item->{'net_benefit_'.$scale}, 'f' => $item->{'net_benefitmoney_'.$scale}) )); $i++; } } usort($rowArray, function($b, $a) { return $a['c'][4]['v'] - $b['c'][4]['v']; }); $data = array( 'cols' => array( array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK_FACTOR'), 'type' => 'string'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_COST_OF_PROBLEM'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_COST_OF_INTERVENTION'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_BENEFIT'), 'type' => 'number'), array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_NET_BENEFIT'), 'type' => 'number') ), 'rows' => $rowArray ); $height = ($i * 80)+100; $chart->load(json_encode($data)); $options = array(); $main_title = JText::sprintf("COM_COSTBENEFITPROJECTION_INTERVENTIONS_NAME_S", $intervention->name); $title = ''; if($intervention->duration > 1){ $title .= JText::sprintf('COM_COSTBENEFITPROJECTION_DURATION_S_YEARS', $intervention->duration); } else { $title .= JText::sprintf('COM_COSTBENEFITPROJECTION_DURATION_S_YEAR', $intervention->duration); } $title .= ' | ' . JText::sprintf('COM_COSTBENEFITPROJECTION_COVERAGE_S', round($intervention->coverage)). '%'; $options = array( 'title' => $main_title, 'colors' => array('#cc0000', '#ff9933', '#0070c0', '#70ad47'), 'backgroundColor' => $this->Chart['backgroundColor'], 'width' => $this->Chart['width'], 'height' => $height, 'chartArea' => $this->Chart['chartArea'], 'legend' => $this->Chart['legend'], 'vAxis' => $this->Chart['vAxis'], 'hAxis' => array('textStyle' => $this->Chart['hAxis']['textStyle'], 'title' => $title, 'titleTextStyle' => $this->Chart['hAxis']['titleTextStyle'])); echo $chart->draw('icb_'.$intervention_number.'_'.$scale, $options); $intervention_number++; } } } } ?>

results->interventions) && CostbenefitprojectionHelper::checkArray($this->results->interventions)) : ?> results->interventions as $intervention): ?> items)): ?>