fixed import error with version is ignored.
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage combinedresults.css
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* CSS Document */
|
||||
|
||||
|
@@ -0,0 +1,24 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage company.css
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* CSS Document */
|
||||
|
||||
|
||||
input[type="checkbox"] {
|
||||
margin: 0 !important;
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage companyresults.css
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* CSS Document */
|
||||
|
||||
|
@@ -0,0 +1,21 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage cpanel.css
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* CSS Document */
|
||||
|
||||
|
@@ -0,0 +1,21 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage createaccount.css
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* CSS Document */
|
||||
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,28 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage intervention.css
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* CSS Document */
|
||||
|
||||
|
||||
.text_area{
|
||||
height: 200px;
|
||||
width: 100%;
|
||||
}
|
||||
.causewidth {
|
||||
width: 100%;
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage publicresults.css
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* CSS Document */
|
||||
|
||||
|
@@ -0,0 +1,25 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage scaling_factor.css
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* CSS Document */
|
||||
|
||||
|
||||
.text_area{
|
||||
height: 200px;
|
||||
width: 100%;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage site.css
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
/* CSS Document */
|
||||
.no-click {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage controller.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import Joomla controller library
|
||||
jimport('joomla.application.component.controller');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Component Controller
|
||||
*/
|
||||
class CostbenefitprojectionController extends JControllerLegacy
|
||||
{
|
||||
/**
|
||||
* display task
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function display($cachable = false, $urlparams = false)
|
||||
{
|
||||
// set default view if not set
|
||||
$view = $this->input->getCmd('view', 'cpanel');
|
||||
$isEdit = $this->checkEditView($view);
|
||||
$layout = $this->input->get('layout', null, 'WORD');
|
||||
$id = $this->input->getInt('id');
|
||||
$cachable = true;
|
||||
|
||||
// Check for edit form.
|
||||
if($isEdit)
|
||||
{
|
||||
if ($layout == 'edit' && !$this->checkEditId('com_costbenefitprojection.edit.'.$view, $id))
|
||||
{
|
||||
// Somehow the person just went to the form - we don't allow that.
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
|
||||
$this->setMessage($this->getError(), 'error');
|
||||
// check if item was opend from other then its own list view
|
||||
$ref = $this->input->getCmd('ref', 0);
|
||||
$refid = $this->input->getInt('refid', 0);
|
||||
// set redirect
|
||||
if ($refid > 0 && CostbenefitprojectionHelper::checkString($ref))
|
||||
{
|
||||
// redirect to item of ref
|
||||
$this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false));
|
||||
}
|
||||
elseif (CostbenefitprojectionHelper::checkString($ref))
|
||||
{
|
||||
|
||||
// redirect to ref
|
||||
$this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view='.(string)$ref, false));
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal redirect back to the list default site view
|
||||
$this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=cpanel', false));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return parent::display($cachable, $urlparams);
|
||||
}
|
||||
|
||||
protected function checkEditView($view)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkString($view))
|
||||
{
|
||||
$views = array(
|
||||
'company',
|
||||
'scaling_factor',
|
||||
'intervention'
|
||||
);
|
||||
// check if this is a edit view
|
||||
if (in_array($view,$views))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage ajax.json.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import Joomla controllerform library
|
||||
jimport('joomla.application.component.controller');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Ajax Controller
|
||||
*/
|
||||
class CostbenefitprojectionControllerAjax extends JControllerLegacy
|
||||
{
|
||||
public function __construct($config)
|
||||
{
|
||||
parent::__construct($config);
|
||||
// make sure all json stuff are set
|
||||
JFactory::getDocument()->setMimeEncoding( 'application/json' );
|
||||
JResponse::setHeader('Content-Disposition','attachment;filename="getajax.json"');
|
||||
JResponse::setHeader("Access-Control-Allow-Origin", "*");
|
||||
// load the tasks
|
||||
$this->registerTask('calculatedResult', 'ajax');
|
||||
$this->registerTask('interventionBuildTable', 'ajax');
|
||||
$this->registerTask('getClusterData', 'ajax');
|
||||
}
|
||||
|
||||
public function ajax()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$jinput = JFactory::getApplication()->input;
|
||||
// Check Token!
|
||||
$token = JSession::getFormToken();
|
||||
$call_token = $jinput->get('token', 0, 'ALNUM');
|
||||
if($token == $call_token)
|
||||
{
|
||||
$task = $this->getTask();
|
||||
switch($task)
|
||||
{
|
||||
case 'calculatedResult':
|
||||
try
|
||||
{
|
||||
$idValue = $jinput->get('id', NULL, 'INT');
|
||||
$dataValue = $jinput->get('data', NULL, 'BASE64');
|
||||
if($idValue && $dataValue && $user->id != 0)
|
||||
{
|
||||
$result = $this->getModel('ajax')->getCalculatedResult($idValue, $dataValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = false;
|
||||
}
|
||||
if(array_key_exists('callback',$_GET))
|
||||
{
|
||||
echo $_GET['callback'] . "(".json_encode($result).");";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($result).");";
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if(array_key_exists('callback',$_GET))
|
||||
{
|
||||
echo $_GET['callback']."(".json_encode($e).");";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($e).");";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'interventionBuildTable':
|
||||
try
|
||||
{
|
||||
$idNameValue = $jinput->get('idName', NULL, 'CMD');
|
||||
$ojectValue = $jinput->get('oject', NULL, 'STRING');
|
||||
$clusterValue = $jinput->get('cluster', NULL, 'WORD');
|
||||
if($idNameValue && $ojectValue && $clusterValue && $user->id != 0)
|
||||
{
|
||||
$result = $this->getModel('ajax')->getInterventionBuildTable($idNameValue, $ojectValue, $clusterValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = false;
|
||||
}
|
||||
if(array_key_exists('callback',$_GET))
|
||||
{
|
||||
echo $_GET['callback'] . "(".json_encode($result).");";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($result).");";
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if(array_key_exists('callback',$_GET))
|
||||
{
|
||||
echo $_GET['callback']."(".json_encode($e).");";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($e).");";
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'getClusterData':
|
||||
try
|
||||
{
|
||||
$idNameValue = $jinput->get('idName', NULL, 'CMD');
|
||||
$clusterValue = $jinput->get('cluster', NULL, 'STRING');
|
||||
if($idNameValue && $clusterValue && $user->id != 0)
|
||||
{
|
||||
$result = $this->getModel('ajax')->getClusterData($idNameValue, $clusterValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = false;
|
||||
}
|
||||
if(array_key_exists('callback',$_GET))
|
||||
{
|
||||
echo $_GET['callback'] . "(".json_encode($result).");";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($result).");";
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
if(array_key_exists('callback',$_GET))
|
||||
{
|
||||
echo $_GET['callback']."(".json_encode($e).");";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode($e).");";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(array_key_exists('callback',$_GET))
|
||||
{
|
||||
echo $_GET['callback']."(".json_encode(false).");";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "(".json_encode(false).");";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,575 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage company.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import Joomla controllerform library
|
||||
jimport('joomla.application.component.controllerform');
|
||||
|
||||
/**
|
||||
* Company Controller
|
||||
*/
|
||||
class CostbenefitprojectionControllerCompany extends JControllerForm
|
||||
{
|
||||
/**
|
||||
* Current or most recently performed task.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
* @note Replaces _task.
|
||||
*/
|
||||
protected $task;
|
||||
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->view_list = 'cpanel'; // safeguard for setting the return view listing to the default site view.
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can add a new record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowAdd($data = array())
|
||||
{
|
||||
// Access check.
|
||||
$access = JFactory::getUser()->authorise('company.access', 'com_costbenefitprojection');
|
||||
if (!$access)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// In the absense of better information, revert to the component permissions.
|
||||
return JFactory::getUser()->authorise('company.create', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can edit an existing record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowEdit($data = array(), $key = 'id')
|
||||
{
|
||||
// get user object.
|
||||
$user = JFactory::getUser();
|
||||
// get record id.
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
if (!$user->authorise('core.options', 'com_costbenefitprojection'))
|
||||
{
|
||||
// make absolutely sure that this company can be edited
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($user->id);
|
||||
if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($recordId,$companies))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// ensure lockdown
|
||||
$userIs = CostbenefitprojectionHelper::userIs($user->id);
|
||||
if (1 != $userIs && ! CostbenefitprojectionHelper::accessCompany($recordId))
|
||||
{
|
||||
// this company is locked
|
||||
return false;
|
||||
}
|
||||
|
||||
// Access check.
|
||||
$access = ($user->authorise('company.access', 'com_costbenefitprojection.company.' . (int) $recordId) && $user->authorise('company.access', 'com_costbenefitprojection'));
|
||||
if (!$access)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
// The record has been set. Check the record permissions.
|
||||
$permission = $user->authorise('company.edit', 'com_costbenefitprojection.company.' . (int) $recordId);
|
||||
if (!$permission && !is_null($permission))
|
||||
{
|
||||
if ($user->authorise('company.edit.own', 'com_costbenefitprojection.company.' . $recordId))
|
||||
{
|
||||
// Now test the owner is the user.
|
||||
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
|
||||
if (empty($ownerId))
|
||||
{
|
||||
// Need to do a lookup from the model.
|
||||
$record = $this->getModel()->getItem($recordId);
|
||||
|
||||
if (empty($record))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$ownerId = $record->created_by;
|
||||
}
|
||||
|
||||
// If the owner matches 'me' then allow.
|
||||
if ($ownerId == $user->id)
|
||||
{
|
||||
if ($user->authorise('company.edit.own', 'com_costbenefitprojection'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Since there is no permission, revert to the component permissions.
|
||||
return $user->authorise('company.edit', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL arguments to append to an item redirect.
|
||||
*
|
||||
* @param integer $recordId The primary key id for the item.
|
||||
* @param string $urlVar The name of the URL variable for the id.
|
||||
*
|
||||
* @return string The arguments to append to the redirect URL.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
|
||||
{
|
||||
$tmpl = $this->input->get('tmpl');
|
||||
$layout = $this->input->get('layout', 'edit', 'string');
|
||||
|
||||
$ref = $this->input->get('ref', 0, 'string');
|
||||
$refid = $this->input->get('refid', 0, 'int');
|
||||
|
||||
// Setup redirect info.
|
||||
|
||||
$append = '';
|
||||
|
||||
if ($refid)
|
||||
{
|
||||
$append .= '&ref='.(string)$ref.'&refid='.(int)$refid;
|
||||
}
|
||||
elseif ($ref)
|
||||
{
|
||||
$append .= '&ref='.(string)$ref;
|
||||
}
|
||||
|
||||
if ($tmpl)
|
||||
{
|
||||
$append .= '&tmpl=' . $tmpl;
|
||||
}
|
||||
|
||||
if ($layout)
|
||||
{
|
||||
$append .= '&layout=' . $layout;
|
||||
}
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
$append .= '&' . $urlVar . '=' . $recordId;
|
||||
}
|
||||
|
||||
return $append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to run batch operations.
|
||||
*
|
||||
* @param object $model The model.
|
||||
*
|
||||
* @return boolean True if successful, false otherwise and internal error is set.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function batch($model = null)
|
||||
{
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
// Set the model
|
||||
$model = $this->getModel('Company', '', array());
|
||||
|
||||
// Preset the redirect
|
||||
$this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=companies' . $this->getRedirectToListAppend(), false));
|
||||
|
||||
return parent::batch($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cancel an edit.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
*
|
||||
* @return boolean True if access level checks pass, false otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function cancel($key = null)
|
||||
{
|
||||
// get the referal details
|
||||
$this->ref = $this->input->get('ref', 0, 'word');
|
||||
$this->refid = $this->input->get('refid', 0, 'int');
|
||||
|
||||
$cancel = parent::cancel($key);
|
||||
|
||||
if ($cancel)
|
||||
{
|
||||
if ($this->refid)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid;
|
||||
|
||||
// Redirect to the item screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
elseif ($this->ref)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref;
|
||||
|
||||
// Redirect to the list screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Redirect to the items screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_list, false
|
||||
)
|
||||
);
|
||||
}
|
||||
return $cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save a record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return boolean True if successful, false otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function save($key = null, $urlVar = null)
|
||||
{
|
||||
// get the referal details
|
||||
$this->ref = $this->input->get('ref', 0, 'word');
|
||||
$this->refid = $this->input->get('refid', 0, 'int');
|
||||
|
||||
if ($this->ref || $this->refid)
|
||||
{
|
||||
// to make sure the item is checkedin on redirect
|
||||
$this->task = 'save';
|
||||
}
|
||||
|
||||
$saved = parent::save($key, $urlVar);
|
||||
|
||||
if ($this->refid && $saved)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid;
|
||||
|
||||
// Redirect to the item screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
elseif ($this->ref && $saved)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref;
|
||||
|
||||
// Redirect to the list screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
return $saved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that allows child controller access to model data
|
||||
* after the data has been saved.
|
||||
*
|
||||
* @param JModel &$model The data model object.
|
||||
* @param array $validData The validated data.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function postSaveHook(JModelLegacy $model, $validData = array())
|
||||
{
|
||||
if ($validData['id'] >= 0)
|
||||
{
|
||||
// get user object
|
||||
$user = JFactory::getUser();
|
||||
// if id is 0 get id
|
||||
if (0 >= (int) $validData['id'])
|
||||
{
|
||||
// Get the created by id
|
||||
$created_by = (isset($validData['created_by']) && $validData['created_by'] > 0) ? $validData['created_by'] : $user->id;
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
// Select id of this company
|
||||
$query->select($db->quoteName(array('id')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_company'));
|
||||
$query->where($db->quoteName('name') . ' = '. $db->quote($validData['name']));
|
||||
$query->where($db->quoteName('email') . ' = '. $db->quote($validData['email']));
|
||||
$query->where($db->quoteName('country') . ' = '. (int) $validData['country']);
|
||||
$query->where($db->quoteName('service_provider') . ' = '. (int) $validData['service_provider']);
|
||||
$query->where($db->quoteName('created_by') . ' = '. (int) $created_by);
|
||||
if (isset($validData['created']))
|
||||
{
|
||||
$query->where($db->quoteName('created') . ' = '. $db->quote($validData['created']));
|
||||
}
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$validData['id'] = $db->loadResult();
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
// user setup if not set
|
||||
if (0 >= (int) $validData['user'] && (int) $validData['id'] > 0)
|
||||
{
|
||||
$userIs = CostbenefitprojectionHelper::userIs($user->id);
|
||||
if (1 == $userIs)
|
||||
{
|
||||
// this is a company so just use its id
|
||||
$userId = $user->id;
|
||||
// add this user id to this company
|
||||
$validData['user'] = $userId;
|
||||
$model->save($validData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// setup config array
|
||||
$newUser = array('name' => $validData['name'], 'email' => $validData['email']);
|
||||
$userId = CostbenefitprojectionHelper::createUser($newUser);
|
||||
if (!is_int($userId))
|
||||
{
|
||||
$this->setMessage($userId, 'error');
|
||||
}
|
||||
else
|
||||
{
|
||||
// add this user id to this company
|
||||
$validData['user'] = $userId;
|
||||
$model->save($validData);
|
||||
}
|
||||
}
|
||||
}
|
||||
// only continue if we have a company id
|
||||
if ((int) $validData['id'] > 0)
|
||||
{
|
||||
// get params
|
||||
$params = JComponentHelper::getParams('com_costbenefitprojection');
|
||||
// get all this users companies
|
||||
$hisCompanies = CostbenefitprojectionHelper::hisCompanies($validData['user']);
|
||||
if (CostbenefitprojectionHelper::checkArray($hisCompanies))
|
||||
{
|
||||
// set the user group based on the overall status of its companies
|
||||
$departments = CostbenefitprojectionHelper::getVars('company', $hisCompanies, 'id', 'department');
|
||||
if (in_array(2, $departments))
|
||||
{
|
||||
$memberGroups = $params->get('advancedmembergroup');
|
||||
}
|
||||
else
|
||||
{
|
||||
$memberGroups = $params->get('memberbasicgroup');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// first company so act simply on this company department status
|
||||
if (2 == $validData['department'])
|
||||
{
|
||||
$memberGroups = $params->get('advancedmembergroup');
|
||||
}
|
||||
else
|
||||
{
|
||||
$memberGroups = $params->get('memberbasicgroup');
|
||||
}
|
||||
}
|
||||
// update the user groups
|
||||
JUserHelper::setUserGroups((int)$validData['user'],(array)$memberGroups);
|
||||
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
// Select all records in scaling factors the belong to this company
|
||||
$query->select($db->quoteName(array('id','causerisk','published')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_scaling_factor'));
|
||||
$query->where($db->quoteName('company') . ' = '. (int) $validData['id']);
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
// load the scaling factors already set
|
||||
$already = $db->loadObjectList();
|
||||
$publish = array();
|
||||
$archive = array();
|
||||
$bucket = array();
|
||||
foreach ($already as $scale)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkArray($validData['causesrisks']))
|
||||
{
|
||||
if (in_array($scale->causerisk, $validData['causesrisks']) && $scale->published != 1)
|
||||
{
|
||||
// publish the scaling factor (update)
|
||||
$publish[$scale->id] = $scale->id;
|
||||
}
|
||||
elseif (!in_array($scale->causerisk, $validData['causesrisks']))
|
||||
{
|
||||
// archive the scaling factor (update)
|
||||
$archive[$scale->id] = $scale->id;
|
||||
}
|
||||
$bucket[] = $scale->causerisk;
|
||||
}
|
||||
else
|
||||
{
|
||||
// archive the scaling factor (update)
|
||||
$archive[$scale->id] = $scale->id;
|
||||
}
|
||||
}
|
||||
// update the needed records
|
||||
$types = array('publish' => 1,'archive' => 2);
|
||||
foreach ($types as $type => $int)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkArray(${$type}))
|
||||
{
|
||||
foreach (${$type} as $id)
|
||||
{
|
||||
$query = $db->getQuery(true);
|
||||
// Fields to update.
|
||||
$fields = array(
|
||||
$db->quoteName('published') . ' = ' . (int) $int
|
||||
);
|
||||
// Conditions for which records should be updated.
|
||||
$conditions = array(
|
||||
$db->quoteName('id') . ' = ' . (int) $id
|
||||
);
|
||||
|
||||
$query->update($db->quoteName('#__costbenefitprojection_scaling_factor'))->set($fields)->where($conditions);
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (CostbenefitprojectionHelper::checkArray($validData['causesrisks']))
|
||||
{
|
||||
// remove those already set from the saved list of causesrisks
|
||||
if (CostbenefitprojectionHelper::checkArray($bucket))
|
||||
{
|
||||
$insert = array();
|
||||
foreach ($validData['causesrisks'] as $causerisk)
|
||||
{
|
||||
if (!in_array($causerisk,$bucket))
|
||||
{
|
||||
$insert[] = $causerisk;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$insert = $validData['causesrisks'];
|
||||
}
|
||||
}
|
||||
// insert the new records
|
||||
if (CostbenefitprojectionHelper::checkArray($insert))
|
||||
{
|
||||
$created = $db->quote(JFactory::getDate()->toSql());
|
||||
$created_by = JFactory::getUser()->get('id');
|
||||
$company = $validData['id'];
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
// Insert columns.
|
||||
$columns = array(
|
||||
'causerisk', 'company', 'mortality_scaling_factor_females',
|
||||
'mortality_scaling_factor_males', 'presenteeism_scaling_factor_females',
|
||||
'presenteeism_scaling_factor_males', 'yld_scaling_factor_females',
|
||||
'yld_scaling_factor_males', 'published',
|
||||
'created_by', 'created');
|
||||
// setup the values
|
||||
$values = array();
|
||||
foreach ($insert as $new)
|
||||
{
|
||||
$array = array($new,$company,1,1,1,1,1,1,1,$created_by,$created);
|
||||
$values[] = implode(',',$array);
|
||||
}
|
||||
// Prepare the insert query.
|
||||
$query
|
||||
->insert($db->quoteName('#__costbenefitprojection_scaling_factor'))
|
||||
->columns($db->quoteName($columns))
|
||||
->values(implode('), (', $values));
|
||||
|
||||
// Set the query using our newly populated query object and execute it.
|
||||
$db->setQuery($query);
|
||||
$done = $db->execute();
|
||||
if ($done)
|
||||
{
|
||||
// we must set the assets
|
||||
foreach ($insert as $causerisk)
|
||||
{
|
||||
// get all the ids. Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
$query->select($db->quoteName(array('id')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_scaling_factor'));
|
||||
$query->where($db->quoteName('causerisk') . ' = '. (int) $causerisk);
|
||||
$query->where($db->quoteName('company') . ' = '. (int) $company);
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$aId = $db->loadResult();
|
||||
// make sure the access of asset is set
|
||||
CostbenefitprojectionHelper::setAsset($aId,'scaling_factor');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage help.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import Joomla controllerform library
|
||||
jimport('joomla.application.component.controller');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Help Controller
|
||||
*/
|
||||
class CostbenefitprojectionControllerHelp extends JControllerLegacy
|
||||
{
|
||||
public function __construct($config)
|
||||
{
|
||||
parent::__construct($config);
|
||||
// load the tasks
|
||||
$this->registerTask('getText', 'help');
|
||||
}
|
||||
|
||||
public function help()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$jinput = JFactory::getApplication()->input;
|
||||
// Check Token!
|
||||
$token = JSession::getFormToken();
|
||||
$call_token = $jinput->get('token', 0, 'ALNUM');
|
||||
if($token == $call_token){
|
||||
$task = $this->getTask();
|
||||
switch($task){
|
||||
case 'getText':
|
||||
try
|
||||
{
|
||||
$idValue = $jinput->get('id', 0, 'INT');
|
||||
if($idValue)
|
||||
{
|
||||
$result = $this->getHelpDocumentText($idValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = '';
|
||||
}
|
||||
echo $result;
|
||||
// stop execution gracefully
|
||||
jexit();
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
// stop execution gracefully
|
||||
jexit();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// stop execution gracefully
|
||||
jexit();
|
||||
}
|
||||
}
|
||||
|
||||
protected function getHelpDocumentText($id)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$query->select(array('a.title','a.content'));
|
||||
$query->from('#__costbenefitprojection_help_document AS a');
|
||||
$query->where('a.id = '.(int) $id);
|
||||
$query->where('a.published = 1');
|
||||
$query->where('a.location = 2');
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if($db->getNumRows())
|
||||
{
|
||||
$text = array();
|
||||
$document = $db->loadObject();
|
||||
// fix image issue
|
||||
$images['src="images'] = 'src="'.JURI::root().'images';
|
||||
$images["src='images"] = "src='".JURI::root()."images";
|
||||
$images['src="/images'] = 'src="'.JURI::root().'images';
|
||||
$images["src='/images"] = "src='".JURI::root()."images";
|
||||
// set document template
|
||||
$text[] = "<!doctype html>";
|
||||
$text[] = '<html>';
|
||||
$text[] = "<head>";
|
||||
$text[] = '<meta charset="utf-8">';
|
||||
$text[] = "<title>".$document->title."</title>";
|
||||
$text[] = '<link type="text/css" href="'.JURI::root().'media/com_costbenefitprojection/uikit/css/uikit.gradient.min.css" rel="stylesheet"></link>';
|
||||
$text[] = '<script type="text/javascript" src="'.JURI::root().'media/com_costbenefitprojection/uikit/js/uikit.min.js"></script>';
|
||||
$text[] = "</head>";
|
||||
$text[] = '<body><br />';
|
||||
$text[] = '<div class="uk-container uk-container-center uk-grid-collapse">';
|
||||
$text[] = '<div class="uk-panel uk-width-1-1 uk-panel-box uk-panel-box-primary">';
|
||||
// build the help text
|
||||
$text[] = '<h1 class="uk-panel-title">'.$document->title."</h1>";
|
||||
$text[] = str_replace(array_keys($images),array_values($images),$document->content);
|
||||
// end template
|
||||
$text[] = '</div><br /><br />';
|
||||
$text[] = '</div>';
|
||||
$text[] = "</body>";
|
||||
$text[] = "</html>";
|
||||
|
||||
return implode("\n",$text);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,335 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage intervention.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import Joomla controllerform library
|
||||
jimport('joomla.application.component.controllerform');
|
||||
|
||||
/**
|
||||
* Intervention Controller
|
||||
*/
|
||||
class CostbenefitprojectionControllerIntervention extends JControllerForm
|
||||
{
|
||||
/**
|
||||
* Current or most recently performed task.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
* @note Replaces _task.
|
||||
*/
|
||||
protected $task;
|
||||
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->view_list = 'cpanel'; // safeguard for setting the return view listing to the default site view.
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can add a new record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowAdd($data = array())
|
||||
{
|
||||
// Access check.
|
||||
$access = JFactory::getUser()->authorise('intervention.access', 'com_costbenefitprojection');
|
||||
if (!$access)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// In the absense of better information, revert to the component permissions.
|
||||
return JFactory::getUser()->authorise('intervention.create', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can edit an existing record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowEdit($data = array(), $key = 'id')
|
||||
{
|
||||
// get user object.
|
||||
$user = JFactory::getUser();
|
||||
// get record id.
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
// get company id
|
||||
$company = CostbenefitprojectionHelper::getId('intervention',$recordId,'id','company');
|
||||
if (!$user->authorise('core.options', 'com_costbenefitprojection'))
|
||||
{
|
||||
// make absolutely sure that this intervention can be edited
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($user->id);
|
||||
if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($company,$companies))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// now check the access by sharing
|
||||
if (!CostbenefitprojectionHelper::checkIntervetionAccess($recordId,null,$company))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Access check.
|
||||
$access = ($user->authorise('intervention.access', 'com_costbenefitprojection.intervention.' . (int) $recordId) && $user->authorise('intervention.access', 'com_costbenefitprojection'));
|
||||
if (!$access)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
// The record has been set. Check the record permissions.
|
||||
$permission = $user->authorise('intervention.edit', 'com_costbenefitprojection.intervention.' . (int) $recordId);
|
||||
if (!$permission && !is_null($permission))
|
||||
{
|
||||
if ($user->authorise('intervention.edit.own', 'com_costbenefitprojection.intervention.' . $recordId))
|
||||
{
|
||||
// Now test the owner is the user.
|
||||
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
|
||||
if (empty($ownerId))
|
||||
{
|
||||
// Need to do a lookup from the model.
|
||||
$record = $this->getModel()->getItem($recordId);
|
||||
|
||||
if (empty($record))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$ownerId = $record->created_by;
|
||||
}
|
||||
|
||||
// If the owner matches 'me' then allow.
|
||||
if ($ownerId == $user->id)
|
||||
{
|
||||
if ($user->authorise('intervention.edit.own', 'com_costbenefitprojection'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Since there is no permission, revert to the component permissions.
|
||||
return $user->authorise('intervention.edit', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL arguments to append to an item redirect.
|
||||
*
|
||||
* @param integer $recordId The primary key id for the item.
|
||||
* @param string $urlVar The name of the URL variable for the id.
|
||||
*
|
||||
* @return string The arguments to append to the redirect URL.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
|
||||
{
|
||||
$tmpl = $this->input->get('tmpl');
|
||||
$layout = $this->input->get('layout', 'edit', 'string');
|
||||
|
||||
$ref = $this->input->get('ref', 0, 'string');
|
||||
$refid = $this->input->get('refid', 0, 'int');
|
||||
|
||||
// Setup redirect info.
|
||||
|
||||
$append = '';
|
||||
|
||||
if ($refid)
|
||||
{
|
||||
$append .= '&ref='.(string)$ref.'&refid='.(int)$refid;
|
||||
}
|
||||
elseif ($ref)
|
||||
{
|
||||
$append .= '&ref='.(string)$ref;
|
||||
}
|
||||
|
||||
if ($tmpl)
|
||||
{
|
||||
$append .= '&tmpl=' . $tmpl;
|
||||
}
|
||||
|
||||
if ($layout)
|
||||
{
|
||||
$append .= '&layout=' . $layout;
|
||||
}
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
$append .= '&' . $urlVar . '=' . $recordId;
|
||||
}
|
||||
|
||||
return $append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to run batch operations.
|
||||
*
|
||||
* @param object $model The model.
|
||||
*
|
||||
* @return boolean True if successful, false otherwise and internal error is set.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function batch($model = null)
|
||||
{
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
// Set the model
|
||||
$model = $this->getModel('Intervention', '', array());
|
||||
|
||||
// Preset the redirect
|
||||
$this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=interventions' . $this->getRedirectToListAppend(), false));
|
||||
|
||||
return parent::batch($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cancel an edit.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
*
|
||||
* @return boolean True if access level checks pass, false otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function cancel($key = null)
|
||||
{
|
||||
// get the referal details
|
||||
$this->ref = $this->input->get('ref', 0, 'word');
|
||||
$this->refid = $this->input->get('refid', 0, 'int');
|
||||
|
||||
$cancel = parent::cancel($key);
|
||||
|
||||
if ($cancel)
|
||||
{
|
||||
if ($this->refid)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid;
|
||||
|
||||
// Redirect to the item screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
elseif ($this->ref)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref;
|
||||
|
||||
// Redirect to the list screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Redirect to the items screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_list, false
|
||||
)
|
||||
);
|
||||
}
|
||||
return $cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save a record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return boolean True if successful, false otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function save($key = null, $urlVar = null)
|
||||
{
|
||||
// get the referal details
|
||||
$this->ref = $this->input->get('ref', 0, 'word');
|
||||
$this->refid = $this->input->get('refid', 0, 'int');
|
||||
|
||||
if ($this->ref || $this->refid)
|
||||
{
|
||||
// to make sure the item is checkedin on redirect
|
||||
$this->task = 'save';
|
||||
}
|
||||
|
||||
$saved = parent::save($key, $urlVar);
|
||||
|
||||
if ($this->refid && $saved)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid;
|
||||
|
||||
// Redirect to the item screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
elseif ($this->ref && $saved)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref;
|
||||
|
||||
// Redirect to the list screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
return $saved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that allows child controller access to model data
|
||||
* after the data has been saved.
|
||||
*
|
||||
* @param JModel &$model The data model object.
|
||||
* @param array $validData The validated data.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function postSaveHook(JModelLegacy $model, $validData = array())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,329 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage scaling_factor.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import Joomla controllerform library
|
||||
jimport('joomla.application.component.controllerform');
|
||||
|
||||
/**
|
||||
* Scaling_factor Controller
|
||||
*/
|
||||
class CostbenefitprojectionControllerScaling_factor extends JControllerForm
|
||||
{
|
||||
/**
|
||||
* Current or most recently performed task.
|
||||
*
|
||||
* @var string
|
||||
* @since 12.2
|
||||
* @note Replaces _task.
|
||||
*/
|
||||
protected $task;
|
||||
|
||||
public function __construct($config = array())
|
||||
{
|
||||
$this->view_list = 'cpanel'; // safeguard for setting the return view listing to the default site view.
|
||||
parent::__construct($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can add a new record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowAdd($data = array())
|
||||
{
|
||||
// Access check.
|
||||
$access = JFactory::getUser()->authorise('scaling_factor.access', 'com_costbenefitprojection');
|
||||
if (!$access)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// In the absense of better information, revert to the component permissions.
|
||||
return JFactory::getUser()->authorise('scaling_factor.create', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can edit an existing record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key.
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function allowEdit($data = array(), $key = 'id')
|
||||
{
|
||||
// get user object.
|
||||
$user = JFactory::getUser();
|
||||
// get record id.
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
if (!$user->authorise('core.options', 'com_costbenefitprojection'))
|
||||
{
|
||||
// make absolutely sure that this scaling factor can be edited
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($user->id);
|
||||
$company = CostbenefitprojectionHelper::getId('scaling_factor',$recordId,'id','company');
|
||||
if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($company,$companies))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Access check.
|
||||
$access = ($user->authorise('scaling_factor.access', 'com_costbenefitprojection.scaling_factor.' . (int) $recordId) && $user->authorise('scaling_factor.access', 'com_costbenefitprojection'));
|
||||
if (!$access)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
// The record has been set. Check the record permissions.
|
||||
$permission = $user->authorise('scaling_factor.edit', 'com_costbenefitprojection.scaling_factor.' . (int) $recordId);
|
||||
if (!$permission && !is_null($permission))
|
||||
{
|
||||
if ($user->authorise('scaling_factor.edit.own', 'com_costbenefitprojection.scaling_factor.' . $recordId))
|
||||
{
|
||||
// Now test the owner is the user.
|
||||
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
|
||||
if (empty($ownerId))
|
||||
{
|
||||
// Need to do a lookup from the model.
|
||||
$record = $this->getModel()->getItem($recordId);
|
||||
|
||||
if (empty($record))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$ownerId = $record->created_by;
|
||||
}
|
||||
|
||||
// If the owner matches 'me' then allow.
|
||||
if ($ownerId == $user->id)
|
||||
{
|
||||
if ($user->authorise('scaling_factor.edit.own', 'com_costbenefitprojection'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Since there is no permission, revert to the component permissions.
|
||||
return $user->authorise('scaling_factor.edit', $this->option);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URL arguments to append to an item redirect.
|
||||
*
|
||||
* @param integer $recordId The primary key id for the item.
|
||||
* @param string $urlVar The name of the URL variable for the id.
|
||||
*
|
||||
* @return string The arguments to append to the redirect URL.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
|
||||
{
|
||||
$tmpl = $this->input->get('tmpl');
|
||||
$layout = $this->input->get('layout', 'edit', 'string');
|
||||
|
||||
$ref = $this->input->get('ref', 0, 'string');
|
||||
$refid = $this->input->get('refid', 0, 'int');
|
||||
|
||||
// Setup redirect info.
|
||||
|
||||
$append = '';
|
||||
|
||||
if ($refid)
|
||||
{
|
||||
$append .= '&ref='.(string)$ref.'&refid='.(int)$refid;
|
||||
}
|
||||
elseif ($ref)
|
||||
{
|
||||
$append .= '&ref='.(string)$ref;
|
||||
}
|
||||
|
||||
if ($tmpl)
|
||||
{
|
||||
$append .= '&tmpl=' . $tmpl;
|
||||
}
|
||||
|
||||
if ($layout)
|
||||
{
|
||||
$append .= '&layout=' . $layout;
|
||||
}
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
$append .= '&' . $urlVar . '=' . $recordId;
|
||||
}
|
||||
|
||||
return $append;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to run batch operations.
|
||||
*
|
||||
* @param object $model The model.
|
||||
*
|
||||
* @return boolean True if successful, false otherwise and internal error is set.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public function batch($model = null)
|
||||
{
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
|
||||
// Set the model
|
||||
$model = $this->getModel('Scaling_factor', '', array());
|
||||
|
||||
// Preset the redirect
|
||||
$this->setRedirect(JRoute::_('index.php?option=com_costbenefitprojection&view=scaling_factors' . $this->getRedirectToListAppend(), false));
|
||||
|
||||
return parent::batch($model);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to cancel an edit.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
*
|
||||
* @return boolean True if access level checks pass, false otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function cancel($key = null)
|
||||
{
|
||||
// get the referal details
|
||||
$this->ref = $this->input->get('ref', 0, 'word');
|
||||
$this->refid = $this->input->get('refid', 0, 'int');
|
||||
|
||||
$cancel = parent::cancel($key);
|
||||
|
||||
if ($cancel)
|
||||
{
|
||||
if ($this->refid)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid;
|
||||
|
||||
// Redirect to the item screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
elseif ($this->ref)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref;
|
||||
|
||||
// Redirect to the list screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Redirect to the items screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . '&view=' . $this->view_list, false
|
||||
)
|
||||
);
|
||||
}
|
||||
return $cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save a record.
|
||||
*
|
||||
* @param string $key The name of the primary key of the URL variable.
|
||||
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
|
||||
*
|
||||
* @return boolean True if successful, false otherwise.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function save($key = null, $urlVar = null)
|
||||
{
|
||||
// get the referal details
|
||||
$this->ref = $this->input->get('ref', 0, 'word');
|
||||
$this->refid = $this->input->get('refid', 0, 'int');
|
||||
|
||||
if ($this->ref || $this->refid)
|
||||
{
|
||||
// to make sure the item is checkedin on redirect
|
||||
$this->task = 'save';
|
||||
}
|
||||
|
||||
$saved = parent::save($key, $urlVar);
|
||||
|
||||
if ($this->refid && $saved)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid;
|
||||
|
||||
// Redirect to the item screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
elseif ($this->ref && $saved)
|
||||
{
|
||||
$redirect = '&view='.(string)$this->ref;
|
||||
|
||||
// Redirect to the list screen.
|
||||
$this->setRedirect(
|
||||
JRoute::_(
|
||||
'index.php?option=' . $this->option . $redirect, false
|
||||
)
|
||||
);
|
||||
}
|
||||
return $saved;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that allows child controller access to model data
|
||||
* after the data has been saved.
|
||||
*
|
||||
* @param JModel &$model The data model object.
|
||||
* @param array $validData The validated data.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 11.1
|
||||
*/
|
||||
protected function postSaveHook(JModelLegacy $model, $validData = array())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage costbenefitprojection.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// Set the component css/js
|
||||
$document = JFactory::getDocument();
|
||||
$document->addStyleSheet('components/com_costbenefitprojection/assets/css/site.css');
|
||||
$document->addScript('components/com_costbenefitprojection/assets/js/site.js');
|
||||
|
||||
// Require helper files
|
||||
JLoader::register('CostbenefitprojectionHelper', dirname(__FILE__) . '/helpers/costbenefitprojection.php');
|
||||
JLoader::register('CostbenefitprojectionHelperRoute', dirname(__FILE__) . '/helpers/route.php');
|
||||
|
||||
// import joomla controller library
|
||||
jimport('joomla.application.component.controller');
|
||||
|
||||
// Get an instance of the controller prefixed by Costbenefitprojection
|
||||
$controller = JControllerLegacy::getInstance('Costbenefitprojection');
|
||||
|
||||
// Perform the request task
|
||||
$jinput = JFactory::getApplication()->input;
|
||||
$controller->execute($jinput->get('task', null, 'CMD'));
|
||||
|
||||
// Redirect if set by the controller
|
||||
$controller->redirect();
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage headercheck.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
class HeaderCheck
|
||||
{
|
||||
function js_loaded($script_name)
|
||||
{
|
||||
// UIkit check point
|
||||
if (strpos($script_name,'uikit') !== false)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$getTemplateName = $app->getTemplate('template')->template;
|
||||
|
||||
if (strpos($getTemplateName,'yoo') !== false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$document = JFactory::getDocument();
|
||||
$head_data = $document->getHeadData();
|
||||
foreach (array_keys($head_data['scripts']) as $script)
|
||||
{
|
||||
if (stristr($script, $script_name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function css_loaded($script_name)
|
||||
{
|
||||
// UIkit check point
|
||||
if (strpos($script_name,'uikit') !== false)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$getTemplateName = $app->getTemplate('template')->template;
|
||||
|
||||
if (strpos($getTemplateName,'yoo') !== false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$document = JFactory::getDocument();
|
||||
$head_data = $document->getHeadData();
|
||||
|
||||
foreach (array_keys($head_data['styleSheets']) as $script)
|
||||
{
|
||||
if (stristr($script, $script_name))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @version 1.0.0
|
||||
* @package Detecting negative numbers
|
||||
* @license GNU General Public License <http://www.gnu.org/copyleft/gpl.html>
|
||||
*
|
||||
**/
|
||||
|
||||
// No direct access.
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Detecting negative numbers
|
||||
**/
|
||||
|
||||
class Expression
|
||||
{
|
||||
protected $expression;
|
||||
protected $result;
|
||||
|
||||
public function __construct($expression)
|
||||
{
|
||||
$this->expression = $expression;
|
||||
}
|
||||
|
||||
public function evaluate()
|
||||
{
|
||||
$this->result = eval("return ".$this->expression.";");
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getResult()
|
||||
{
|
||||
return $this->result;
|
||||
}
|
||||
}
|
||||
|
||||
class NegativeFinder
|
||||
{
|
||||
protected $expressionObj;
|
||||
|
||||
public function __construct(Expression $expressionObj)
|
||||
{
|
||||
$this->expressionObj = $expressionObj;
|
||||
}
|
||||
|
||||
|
||||
public function isItNegative()
|
||||
{
|
||||
$result = $this->expressionObj->evaluate()->getResult();
|
||||
|
||||
if($this->hasMinusSign($result))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function hasMinusSign($value)
|
||||
{
|
||||
return (substr(strval($value), 0, 1) == "-");
|
||||
}
|
||||
}
|
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage route.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// Component Helper
|
||||
jimport('joomla.application.component.helper');
|
||||
jimport('joomla.application.categories');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Route Helper
|
||||
**/
|
||||
abstract class CostbenefitprojectionHelperRoute
|
||||
{
|
||||
protected static $lookup;
|
||||
|
||||
/**
|
||||
* @param int The route of the Cpanel
|
||||
*/
|
||||
public static function getCpanelRoute($id = 0, $catid = 0)
|
||||
{
|
||||
if ($id > 0)
|
||||
{
|
||||
// Initialize the needel array.
|
||||
$needles = array(
|
||||
'cpanel' => array((int) $id)
|
||||
);
|
||||
// Create the link
|
||||
$link = 'index.php?option=com_costbenefitprojection&view=cpanel&id='. $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initialize the needel array.
|
||||
$needles = array();
|
||||
//Create the link but don't add the id.
|
||||
$link = 'index.php?option=com_costbenefitprojection&view=cpanel';
|
||||
}
|
||||
if ($catid > 1)
|
||||
{
|
||||
$categories = JCategories::getInstance('costbenefitprojection.cpanel');
|
||||
$category = $categories->get($catid);
|
||||
if ($category)
|
||||
{
|
||||
$needles['category'] = array_reverse($category->getPath());
|
||||
$needles['categories'] = $needles['category'];
|
||||
$link .= '&catid='.$catid;
|
||||
}
|
||||
}
|
||||
|
||||
if ($item = self::_findItem($needles))
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int The route of the Publicresults
|
||||
*/
|
||||
public static function getPublicresultsRoute($id = 0, $catid = 0)
|
||||
{
|
||||
if ($id > 0)
|
||||
{
|
||||
// Initialize the needel array.
|
||||
$needles = array(
|
||||
'publicresults' => array((int) $id)
|
||||
);
|
||||
// Create the link
|
||||
$link = 'index.php?option=com_costbenefitprojection&view=publicresults&id='. $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initialize the needel array.
|
||||
$needles = array();
|
||||
//Create the link but don't add the id.
|
||||
$link = 'index.php?option=com_costbenefitprojection&view=publicresults';
|
||||
}
|
||||
if ($catid > 1)
|
||||
{
|
||||
$categories = JCategories::getInstance('costbenefitprojection.publicresults');
|
||||
$category = $categories->get($catid);
|
||||
if ($category)
|
||||
{
|
||||
$needles['category'] = array_reverse($category->getPath());
|
||||
$needles['categories'] = $needles['category'];
|
||||
$link .= '&catid='.$catid;
|
||||
}
|
||||
}
|
||||
|
||||
if ($item = self::_findItem($needles))
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int The route of the Createaccount
|
||||
*/
|
||||
public static function getCreateaccountRoute($id = 0, $catid = 0)
|
||||
{
|
||||
if ($id > 0)
|
||||
{
|
||||
// Initialize the needel array.
|
||||
$needles = array(
|
||||
'createaccount' => array((int) $id)
|
||||
);
|
||||
// Create the link
|
||||
$link = 'index.php?option=com_costbenefitprojection&view=createaccount&id='. $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initialize the needel array.
|
||||
$needles = array();
|
||||
//Create the link but don't add the id.
|
||||
$link = 'index.php?option=com_costbenefitprojection&view=createaccount';
|
||||
}
|
||||
if ($catid > 1)
|
||||
{
|
||||
$categories = JCategories::getInstance('costbenefitprojection.createaccount');
|
||||
$category = $categories->get($catid);
|
||||
if ($category)
|
||||
{
|
||||
$needles['category'] = array_reverse($category->getPath());
|
||||
$needles['categories'] = $needles['category'];
|
||||
$link .= '&catid='.$catid;
|
||||
}
|
||||
}
|
||||
|
||||
if ($item = self::_findItem($needles))
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int The route of the Companyresults
|
||||
*/
|
||||
public static function getCompanyresultsRoute($id = 0, $catid = 0)
|
||||
{
|
||||
if ($id > 0)
|
||||
{
|
||||
// Initialize the needel array.
|
||||
$needles = array(
|
||||
'companyresults' => array((int) $id)
|
||||
);
|
||||
// Create the link
|
||||
$link = 'index.php?option=com_costbenefitprojection&view=companyresults&id='. $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initialize the needel array.
|
||||
$needles = array();
|
||||
//Create the link but don't add the id.
|
||||
$link = 'index.php?option=com_costbenefitprojection&view=companyresults';
|
||||
}
|
||||
if ($catid > 1)
|
||||
{
|
||||
$categories = JCategories::getInstance('costbenefitprojection.companyresults');
|
||||
$category = $categories->get($catid);
|
||||
if ($category)
|
||||
{
|
||||
$needles['category'] = array_reverse($category->getPath());
|
||||
$needles['categories'] = $needles['category'];
|
||||
$link .= '&catid='.$catid;
|
||||
}
|
||||
}
|
||||
|
||||
if ($item = self::_findItem($needles))
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int The route of the Combinedresults
|
||||
*/
|
||||
public static function getCombinedresultsRoute($id = 0, $catid = 0)
|
||||
{
|
||||
if ($id > 0)
|
||||
{
|
||||
// Initialize the needel array.
|
||||
$needles = array(
|
||||
'combinedresults' => array((int) $id)
|
||||
);
|
||||
// Create the link
|
||||
$link = 'index.php?option=com_costbenefitprojection&view=combinedresults&id='. $id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Initialize the needel array.
|
||||
$needles = array();
|
||||
//Create the link but don't add the id.
|
||||
$link = 'index.php?option=com_costbenefitprojection&view=combinedresults';
|
||||
}
|
||||
if ($catid > 1)
|
||||
{
|
||||
$categories = JCategories::getInstance('costbenefitprojection.combinedresults');
|
||||
$category = $categories->get($catid);
|
||||
if ($category)
|
||||
{
|
||||
$needles['category'] = array_reverse($category->getPath());
|
||||
$needles['categories'] = $needles['category'];
|
||||
$link .= '&catid='.$catid;
|
||||
}
|
||||
}
|
||||
|
||||
if ($item = self::_findItem($needles))
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL route for costbenefitprojection category from a category ID and language
|
||||
*
|
||||
* @param mixed $catid The id of the items's category either an integer id or a instance of JCategoryNode
|
||||
* @param mixed $language The id of the language being used.
|
||||
*
|
||||
* @return string The link to the contact
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public static function getCategoryRoute_keep_for_later($catid, $language = 0)
|
||||
{
|
||||
if ($catid instanceof JCategoryNode)
|
||||
{
|
||||
$id = $catid->id;
|
||||
$category = $catid;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception('First parameter must be JCategoryNode');
|
||||
}
|
||||
|
||||
$views = array();
|
||||
$view = $views[$category->extension];
|
||||
|
||||
if ($id < 1 || !($category instanceof JCategoryNode))
|
||||
{
|
||||
$link = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
//Create the link
|
||||
$link = 'index.php?option=com_costbenefitprojection&view='.$view.'&category='.$category->slug;
|
||||
|
||||
$needles = array(
|
||||
$view => array($id),
|
||||
'category' => array($id)
|
||||
);
|
||||
|
||||
if ($language && $language != "*" && JLanguageMultilang::isEnabled())
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('a.sef AS sef')
|
||||
->select('a.lang_code AS lang_code')
|
||||
->from('#__languages AS a');
|
||||
|
||||
$db->setQuery($query);
|
||||
$langs = $db->loadObjectList();
|
||||
foreach ($langs as $lang)
|
||||
{
|
||||
if ($language == $lang->lang_code)
|
||||
{
|
||||
$link .= '&lang='.$lang->sef;
|
||||
$needles['language'] = $language;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($item = self::_findItem($needles,'category'))
|
||||
{
|
||||
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($category)
|
||||
{
|
||||
$catids = array_reverse($category->getPath());
|
||||
$needles = array(
|
||||
'category' => $catids
|
||||
);
|
||||
if ($item = self::_findItem($needles,'category'))
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
elseif ($item = self::_findItem(null, 'category'))
|
||||
{
|
||||
$link .= '&Itemid='.$item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
protected static function _findItem($needles = null,$type = null)
|
||||
{
|
||||
$app = JFactory::getApplication();
|
||||
$menus = $app->getMenu('site');
|
||||
$language = isset($needles['language']) ? $needles['language'] : '*';
|
||||
|
||||
// Prepare the reverse lookup array.
|
||||
if (!isset(self::$lookup[$language]))
|
||||
{
|
||||
self::$lookup[$language] = array();
|
||||
|
||||
$component = JComponentHelper::getComponent('com_costbenefitprojection');
|
||||
|
||||
$attributes = array('component_id');
|
||||
$values = array($component->id);
|
||||
|
||||
if ($language != '*')
|
||||
{
|
||||
$attributes[] = 'language';
|
||||
$values[] = array($needles['language'], '*');
|
||||
}
|
||||
|
||||
$items = $menus->getItems($attributes, $values);
|
||||
|
||||
foreach ($items as $item)
|
||||
{
|
||||
if (isset($item->query) && isset($item->query['view']))
|
||||
{
|
||||
$view = $item->query['view'];
|
||||
|
||||
if (!isset(self::$lookup[$language][$view]))
|
||||
{
|
||||
self::$lookup[$language][$view] = array();
|
||||
}
|
||||
|
||||
if (isset($item->query['id']))
|
||||
{
|
||||
/**
|
||||
* Here it will become a bit tricky
|
||||
* language != * can override existing entries
|
||||
* language == * cannot override existing entries
|
||||
*/
|
||||
if (!isset(self::$lookup[$language][$view][$item->query['id']]) || $item->language != '*')
|
||||
{
|
||||
self::$lookup[$language][$view][$item->query['id']] = $item->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($needles)
|
||||
{
|
||||
foreach ($needles as $view => $ids)
|
||||
{
|
||||
if (isset(self::$lookup[$language][$view]))
|
||||
{
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
if (isset(self::$lookup[$language][$view][(int) $id]))
|
||||
{
|
||||
return self::$lookup[$language][$view][(int) $id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($type)
|
||||
{
|
||||
// Check if the global menu item has been set.
|
||||
$params = JComponentHelper::getParams('com_costbenefitprojection');
|
||||
if ($item = $params->get($type.'_menu', 0))
|
||||
{
|
||||
return $item;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the active menuitem matches the requested language
|
||||
$active = $menus->getActive();
|
||||
|
||||
if ($active
|
||||
&& $active->component == 'com_costbenefitprojection'
|
||||
&& ($language == '*' || in_array($active->language, array('*', $language)) || !JLanguageMultilang::isEnabled()))
|
||||
{
|
||||
return $active->id;
|
||||
}
|
||||
|
||||
// If not found, return language specific home link
|
||||
$default = $menus->getDefault($language);
|
||||
|
||||
return !empty($default->id) ? $default->id : null;
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
||||
COM_COSTBENEFITPROJECTION="Cost Benefit Projection"
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage appnotice.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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('JPATH_BASE') or die('Restricted access');
|
||||
|
||||
$manifest = CostbenefitprojectionHelper::manifest();
|
||||
$contributors = CostbenefitprojectionHelper::getContributors();
|
||||
|
||||
?>
|
||||
<div class="uk-panel">
|
||||
<img alt="<?php echo JText::_('COM_COSTBENEFITPROJECTION_VAST_DEVELOPMENT_METHOD'); ?>" src="<?php echo JRoute::_('media/com_costbenefitprojection/images/cbp_box.png'); ?>">
|
||||
<p class="uk-text-bold uk-text-contrast">
|
||||
<i class="uk-icon-cog uk-icon-spin"></i>
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_GIZ_COST_BENEFIT_PROJECTION_TOOL'); ?>
|
||||
</p>
|
||||
<ul class="uk-list uk-list-line">
|
||||
<li><i class="uk-icon-bolt"></i> <?php echo JText::_('COM_COSTBENEFITPROJECTION_CURRENT_INSTALLED_VERSION'); ?> <em><?php echo $manifest->version; ?></em></li>
|
||||
<li><i class="uk-icon-rocket"></i> <?php echo JText::_('COM_COSTBENEFITPROJECTION_RELEASE_DATE'); ?> <em><?php echo $manifest->creationDate; ?></em></li>
|
||||
<li><i class="uk-icon-copyright"></i> <?php echo JText::_('COM_COSTBENEFITPROJECTION_COPYRIGHT_GIZ'); ?></li>
|
||||
<li><i class="uk-icon-legal"></i> <?php echo JText::_('COM_COSTBENEFITPROJECTION_LICENSE_A_TARGET_BLANK_HREFHTTPSWWWGNUORGLICENSESGPLTWOZEROHTMLGNUGPLA_COMMERCIAL'); ?></li>
|
||||
<?php if(CostbenefitprojectionHelper::checkArray($contributors)): ?>
|
||||
<?php foreach($contributors as $contributor): ?>
|
||||
<li><i class="uk-icon-stack-overflow"></i> <?php echo $contributor['title']; ?><br /><?php echo $contributor['name']; ?></li>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<li><i class="uk-icon-code"></i> <?php echo JText::_('COM_COSTBENEFITPROJECTION_APPLICATION_DEVELOPER'); ?><br /><a href="<?php echo $manifest->authorUrl; ?>" target="_blank"><?php echo $manifest->author; ?></a></li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage age_groups_percentages_fullwidth.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'age_groups_note'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="form-vertical">
|
||||
<?php foreach($fields as $field): ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $form->getLabel($field); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $form->getInput($field); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage age_groups_percentages_left.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'percentmale'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage age_groups_percentages_right.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'percentfemale'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage causerisk_selection_fullwidth.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'causesrisks',
|
||||
'cause_risk_selection_note'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="form-vertical">
|
||||
<?php foreach($fields as $field): ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $form->getLabel($field); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $form->getInput($field); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage details_above.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = array(
|
||||
'name',
|
||||
'user',
|
||||
'department'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="form-inline form-inline-header">
|
||||
<?php foreach($fields as $field){
|
||||
echo $form->renderField($field);
|
||||
} ?>
|
||||
</div>
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage details_left.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'per',
|
||||
'email',
|
||||
'country',
|
||||
'service_provider',
|
||||
'datayear'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage details_right.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'working_days',
|
||||
'total_salary',
|
||||
'total_healthcare',
|
||||
'productivity_losses',
|
||||
'males',
|
||||
'females',
|
||||
'medical_turnovers_males',
|
||||
'medical_turnovers_females',
|
||||
'turnover_comment',
|
||||
'sick_leave_males',
|
||||
'sick_leave_females'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage details_under.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = array(
|
||||
'not_required'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="form-inline form-inline-header">
|
||||
<?php foreach($fields as $field){
|
||||
echo $form->renderField($field);
|
||||
} ?>
|
||||
</div>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage interventions_fullwidth.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// set the defaults
|
||||
$items = $displayData->vwdinterventions;
|
||||
$user = JFactory::getUser();
|
||||
$id = $displayData->item->id;
|
||||
$edit = "index.php?option=com_costbenefitprojection&view=interventions&task=intervention.edit";
|
||||
$ref = ($id) ? "&ref=company&refid=".$id : "";
|
||||
$new = "index.php?option=com_costbenefitprojection&view=intervention&layout=edit".$ref;
|
||||
$can = CostbenefitprojectionHelper::getActions('intervention');
|
||||
|
||||
?>
|
||||
<div class="form-vertical">
|
||||
<?php if ($can->get('intervention.create')): ?>
|
||||
<a class="btn btn-small btn-success" href="<?php echo $new; ?>"><span class="icon-new icon-white"></span> <?php echo JText::_('COM_COSTBENEFITPROJECTION_NEW'); ?></a><br /><br />
|
||||
<?php endif; ?>
|
||||
<?php if (CostbenefitprojectionHelper::checkArray($items)): ?>
|
||||
<table class="footable table data interventions metro-blue" data-filter="#filter_interventions" data-page-size="20">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-toggle="true">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_NAME_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="phone">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COMPANY_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="phone">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_TYPE_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="phone,tablet">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COVERAGE_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="phone,tablet">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_DESCRIPTION_LABEL'); ?>
|
||||
</th>
|
||||
<th width="10" data-hide="phone,tablet">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_STATUS'); ?>
|
||||
</th>
|
||||
<th width="5" data-type="numeric" data-hide="phone,tablet">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_ID'); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($items as $i => $item): ?>
|
||||
<?php
|
||||
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0;
|
||||
$userChkOut = JFactory::getUser($item->checked_out);
|
||||
$canDo = CostbenefitprojectionHelper::getActions('intervention',$item,'interventions');
|
||||
?>
|
||||
<tr>
|
||||
<td class="nowrap">
|
||||
<?php if ($canDo->get('intervention.edit')): ?>
|
||||
<a href="<?php echo $edit; ?>&id=<?php echo $item->id; ?>&ref=company&refid=<?php echo $id; ?>"><?php echo $displayData->escape($item->name); ?></a>
|
||||
<?php if ($item->checked_out): ?>
|
||||
<?php echo JHtml::_('jgrid.checkedout', $i, $userChkOut->name, $item->checked_out_time, 'interventions.', $canCheckin); ?>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<div class="name"><?php echo $displayData->escape($item->name); ?></div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $displayData->escape($item->company_name); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo JText::_($item->type); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $displayData->escape($item->coverage); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $displayData->escape($item->description); ?>
|
||||
</td>
|
||||
<?php if ($item->published == 1):?>
|
||||
<td class="center" data-value="1">
|
||||
<span class="status-metro status-published" title="<?php echo JText::_('PUBLISHED'); ?>">
|
||||
<?php echo JText::_('PUBLISHED'); ?>
|
||||
</span>
|
||||
</td>
|
||||
<?php elseif ($item->published == 0):?>
|
||||
<td class="center" data-value="2">
|
||||
<span class="status-metro status-inactive" title="<?php echo JText::_('INACTIVE'); ?>">
|
||||
<?php echo JText::_('INACTIVE'); ?>
|
||||
</span>
|
||||
</td>
|
||||
<?php elseif ($item->published == 2):?>
|
||||
<td class="center" data-value="3">
|
||||
<span class="status-metro status-archived" title="<?php echo JText::_('ARCHIVED'); ?>">
|
||||
<?php echo JText::_('ARCHIVED'); ?>
|
||||
</span>
|
||||
</td>
|
||||
<?php elseif ($item->published == -2):?>
|
||||
<td class="center" data-value="4">
|
||||
<span class="status-metro status-trashed" title="<?php echo JText::_('ARCHIVED'); ?>">
|
||||
<?php echo JText::_('ARCHIVED'); ?>
|
||||
</span>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td class="nowrap center hidden-phone">
|
||||
<?php echo $item->id; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot class="hide-if-no-paging">
|
||||
<tr>
|
||||
<td colspan="7">
|
||||
<div class="pagination pagination-centered"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<div class="alert alert-no-items">
|
||||
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage publishing.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'created',
|
||||
'created_by',
|
||||
'modified',
|
||||
'modified_by'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage publlshing.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'published',
|
||||
'ordering',
|
||||
'access',
|
||||
'version',
|
||||
'hits',
|
||||
'id'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage scaling_factors_fullwidth.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// set the defaults
|
||||
$items = $displayData->vwcscaling_factors;
|
||||
$user = JFactory::getUser();
|
||||
$id = $displayData->item->id;
|
||||
$edit = "index.php?option=com_costbenefitprojection&view=scaling_factors&task=scaling_factor.edit";
|
||||
|
||||
?>
|
||||
<div class="form-vertical">
|
||||
<?php if (CostbenefitprojectionHelper::checkArray($items)): ?>
|
||||
<table class="footable table data scaling_factors metro-blue" data-filter="#filter_scaling_factors" data-page-size="20">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-toggle="true">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTOR_CAUSERISK_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="phone">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTOR_COMPANY_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="phone">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTOR_YLD_SCALING_FACTOR_MALES_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="phone,tablet">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTOR_YLD_SCALING_FACTOR_FEMALES_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="phone,tablet">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTOR_MORTALITY_SCALING_FACTOR_MALES_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="phone,tablet">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTOR_MORTALITY_SCALING_FACTOR_FEMALES_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="all">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTOR_PRESENTEEISM_SCALING_FACTOR_MALES_LABEL'); ?>
|
||||
</th>
|
||||
<th data-hide="all">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTOR_PRESENTEEISM_SCALING_FACTOR_FEMALES_LABEL'); ?>
|
||||
</th>
|
||||
<th width="10" data-hide="phone,tablet">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTOR_STATUS'); ?>
|
||||
</th>
|
||||
<th width="5" data-type="numeric" data-hide="phone,tablet">
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTOR_ID'); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($items as $i => $item): ?>
|
||||
<?php
|
||||
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0;
|
||||
$userChkOut = JFactory::getUser($item->checked_out);
|
||||
$canDo = CostbenefitprojectionHelper::getActions('scaling_factor',$item,'scaling_factors');
|
||||
?>
|
||||
<tr>
|
||||
<td class="nowrap">
|
||||
<?php if ($canDo->get('scaling_factor.edit')): ?>
|
||||
<a href="<?php echo $edit; ?>&id=<?php echo $item->id; ?>&ref=company&refid=<?php echo $id; ?>"><?php echo $displayData->escape($item->causerisk_name); ?></a>
|
||||
<?php if ($item->checked_out): ?>
|
||||
<?php echo JHtml::_('jgrid.checkedout', $i, $userChkOut->name, $item->checked_out_time, 'scaling_factors.', $canCheckin); ?>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<div class="name"><?php echo $displayData->escape($item->causerisk_name); ?></div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $displayData->escape($item->company_name); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $displayData->escape($item->yld_scaling_factor_males); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $displayData->escape($item->yld_scaling_factor_females); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $displayData->escape($item->mortality_scaling_factor_males); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $displayData->escape($item->mortality_scaling_factor_females); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $displayData->escape($item->presenteeism_scaling_factor_males); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo $displayData->escape($item->presenteeism_scaling_factor_females); ?>
|
||||
</td>
|
||||
<?php if ($item->published == 1):?>
|
||||
<td class="center" data-value="1">
|
||||
<span class="status-metro status-published" title="<?php echo JText::_('PUBLISHED'); ?>">
|
||||
<?php echo JText::_('PUBLISHED'); ?>
|
||||
</span>
|
||||
</td>
|
||||
<?php elseif ($item->published == 0):?>
|
||||
<td class="center" data-value="2">
|
||||
<span class="status-metro status-inactive" title="<?php echo JText::_('INACTIVE'); ?>">
|
||||
<?php echo JText::_('INACTIVE'); ?>
|
||||
</span>
|
||||
</td>
|
||||
<?php elseif ($item->published == 2):?>
|
||||
<td class="center" data-value="3">
|
||||
<span class="status-metro status-archived" title="<?php echo JText::_('ARCHIVED'); ?>">
|
||||
<?php echo JText::_('ARCHIVED'); ?>
|
||||
</span>
|
||||
</td>
|
||||
<?php elseif ($item->published == -2):?>
|
||||
<td class="center" data-value="4">
|
||||
<span class="status-metro status-trashed" title="<?php echo JText::_('ARCHIVED'); ?>">
|
||||
<?php echo JText::_('ARCHIVED'); ?>
|
||||
</span>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td class="nowrap center hidden-phone">
|
||||
<?php echo $item->id; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot class="hide-if-no-paging">
|
||||
<tr>
|
||||
<td colspan="10">
|
||||
<div class="pagination pagination-centered"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php else: ?>
|
||||
<div class="alert alert-no-items">
|
||||
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
@@ -0,0 +1,438 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage companydetails.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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('JPATH_BASE') or die('Restricted access');
|
||||
|
||||
// set som user permissions
|
||||
$user = JFactory::getUser();
|
||||
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $displayData->checked_out == $user->id || $displayData->checked_out == 0;
|
||||
$userChkOut = JFactory::getUser($displayData->checked_out);
|
||||
$canDo = CostbenefitprojectionHelper::getActions('company',$displayData,'companies');
|
||||
// setup the cause risk list
|
||||
$causesrisks = '<div class="uk-alert">'.JText::_('COM_COSTBENEFITPROJECTION_NO_CAUSERISK_SELECTED').'</div>';
|
||||
if (isset($displayData->causesrisks) && CostbenefitprojectionHelper::checkArray($displayData->causesrisks))
|
||||
{
|
||||
$causesrisks = '';
|
||||
$body = '';
|
||||
$head = array();
|
||||
foreach ($displayData->causesrisks as $id)
|
||||
{
|
||||
// get cause risk details
|
||||
$getValues = array('name','description','ref');
|
||||
$details = CostbenefitprojectionHelper::getCauseRiskDetails($id,$getValues);
|
||||
if (CostbenefitprojectionHelper::checkObject($details))
|
||||
{
|
||||
// build the dl list
|
||||
$row = '<tr>';
|
||||
foreach ($details as $title => $value)
|
||||
{
|
||||
// fix the ref display
|
||||
if ('ref' == $title)
|
||||
{
|
||||
$key = explode('.0',$value);
|
||||
$sort = explode('.',$value);
|
||||
$value = implode('.',$key);
|
||||
$sort = implode('',$key);
|
||||
// now set
|
||||
$row .= '<td data-value="'.$sort.'">' . $value . '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$row .= '<td>' . $value . '</td>';
|
||||
}
|
||||
}
|
||||
$row .= '</tr>';
|
||||
$body .= $row;
|
||||
}
|
||||
}
|
||||
$head = '<th data-toggle="true">'.implode('</th><th data-hide="phone,tablet">', array_map('setHeaderString',array_keys((array)$details))).'</th>';
|
||||
$causesrisks .= '<table class="footable metro-blue" data-page-size="10"><thead><tr>'.$head.'</li></tr></thead><tbody>'.$body.'</tbody><tfoot class="hide-if-no-paging"><tr><td colspan="3"><div class="pagination pagination-centered"></div></td></tr></tfoot></table>';
|
||||
}
|
||||
// setup the age groups display
|
||||
$agepercents = '<div class="uk-panel uk-width-1-1"><div class="uk-alert">'.JText::_('COM_COSTBENEFITPROJECTION_NO_AGE_GROUPS_HAS_BEEN_SET').'</div></div>';
|
||||
$agepercents_numbers = '<div class="uk-panel uk-width-1-1"><div class="uk-alert">'.JText::_('COM_COSTBENEFITPROJECTION_NO_AGE_GROUPS_HAS_BEEN_SET').'</div></div>';
|
||||
$genderArray = array('male','female');
|
||||
// loading option var
|
||||
$both = 0;
|
||||
foreach ($genderArray as $gender)
|
||||
{
|
||||
// setup the related gender age groups
|
||||
if (isset($displayData->{'percent'.$gender}) && CostbenefitprojectionHelper::checkString($displayData->{'percent'.$gender}))
|
||||
{
|
||||
// load chart builder
|
||||
$chart = new Chartbuilder('PieChart');
|
||||
$i = 0;
|
||||
$data = array();
|
||||
$rowArray = array();
|
||||
$rowArray_numbers = array();
|
||||
$dataset = json_decode($displayData->{'percent'.$gender});
|
||||
foreach ($dataset as $key => &$set)
|
||||
{
|
||||
if ('age' == $key)
|
||||
{
|
||||
$type = 'string';
|
||||
$percent = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$type = 'number';
|
||||
$percent = true;
|
||||
}
|
||||
// set header
|
||||
$data['cols'][$i] = array('id' => '', 'lable' => CostbenefitprojectionHelper::safeString($key,'Ww'), 'type' => $type);
|
||||
foreach ($set as $nr => $val)
|
||||
{
|
||||
if (!isset($rowArray_numbers[$nr]))
|
||||
{
|
||||
$rowArray_numbers[$nr] = '';
|
||||
}
|
||||
if ($percent)
|
||||
{
|
||||
$rowArray[$nr]['c'][] = array('v' => (int) $val);
|
||||
// set the table values
|
||||
$rowArray_numbers[$nr] .= '<td data-value="'.$val.'">' . $val . '%</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$rowArray[$nr]['c'][] = array('v' => $val, 'f' => JText::_('COM_COSTBENEFITPROJECTION_AGE').' '.$val);
|
||||
// set the table values
|
||||
$rowArray_numbers[$nr] .= '<td>'.JText::_('COM_COSTBENEFITPROJECTION_AGE').' '. $val . '</td>';
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$data['rows'] = $rowArray;
|
||||
$string = json_encode($data);
|
||||
$chart->load($string);
|
||||
$title = ($gender == 'male') ? JText::_('COM_COSTBENEFITPROJECTION_MALES'):JText::_('COM_COSTBENEFITPROJECTION_FEMALES');
|
||||
$options = array('backgroundColor' => '#fafafa', 'title' => $title, 'height' => '500', 'width' => '500','is3D' => 'true', 'tabclickdraw' => 'charttab');
|
||||
echo $chart->draw('age_'.$gender.'_'.$displayData->id,$options);
|
||||
// set chart array
|
||||
$age[] = '<div id="age_'.$gender.'_'.$displayData->id.'" style="width: 100%;"></div>';
|
||||
$gen[$title] = '<tr>'.implode('</tr><tr>',$rowArray_numbers).'</tr>';
|
||||
$both++;
|
||||
}
|
||||
}
|
||||
|
||||
// now set the group percentages to the view
|
||||
if ($both)
|
||||
{
|
||||
// setup the chart
|
||||
$agepercents = '<div data-uk-grid-margin="" class="uk-grid" data-uk-grid-match="{target:\'.uk-panel\'}">';
|
||||
foreach ($age as $gender)
|
||||
{
|
||||
$agepercents .= '<div class="uk-width-medium-1-'.$both.'">';
|
||||
$agepercents .= '<div class="uk-panel uk-panel-box">';
|
||||
$agepercents .= $gender;
|
||||
$agepercents .= '</div>';
|
||||
$agepercents .= '</div>';
|
||||
}
|
||||
$agepercents .= '</div>';
|
||||
|
||||
// setup the table
|
||||
$agepercents_numbers = '<div data-uk-grid-margin="" class="uk-grid" data-uk-grid-match="{target:\'.uk-panel\'}">';
|
||||
foreach ($gen as $title => $body)
|
||||
{
|
||||
$agepercents_numbers .= '<div class="uk-width-medium-1-'.$both.'">';
|
||||
$agepercents_numbers .= '<div class="uk-panel">';
|
||||
$agepercents_numbers .= '<h3>'.$title.'</h3>';
|
||||
$agepercents_numbers .= '<table class="footable metro-blue toggle-circle" data-page-size="10">';
|
||||
$agepercents_numbers .= '<thead><tr><th>'.JText::_('COM_COSTBENEFITPROJECTION_AGE').'</th><th data-type="numeric">'.JText::_('COM_COSTBENEFITPROJECTION_PERCENT').'</th></tr></thead>';
|
||||
$agepercents_numbers .= '<tbody>'.$body.'</tbody>';
|
||||
$agepercents_numbers .= '<tfoot class="hide-if-no-paging"><tr><td colspan="10"><div class="pagination pagination-centered"></div></td></tr></tfoot>';
|
||||
$agepercents_numbers .= '</table>';
|
||||
$agepercents_numbers .= '</div>';
|
||||
$agepercents_numbers .= '</div>';
|
||||
}
|
||||
$agepercents_numbers .= '</div>';
|
||||
}
|
||||
// set scaling factors
|
||||
$scalingfactors = '<div class="uk-alert">'.JText::_('COM_COSTBENEFITPROJECTION_NO_SCALING_FACTORS_AVAILABLE_PLEASE_SELECT_A_CAUSERISK_TO_ACTIVATE').'</div>';
|
||||
if (isset($displayData->idCompanyScaling_factorD) && CostbenefitprojectionHelper::checkArray($displayData->idCompanyScaling_factorD))
|
||||
{
|
||||
// the values to display
|
||||
$keys = array(
|
||||
'causerisk_name' => JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK'), 'reference' => JText::_('COM_COSTBENEFITPROJECTION_REFERENCE'),
|
||||
'yld_scaling_factor_males' => JText::_('COM_COSTBENEFITPROJECTION_YLD_MALES'),'yld_scaling_factor_females' => JText::_('COM_COSTBENEFITPROJECTION_YLD_FEMALES'),
|
||||
'mortality_scaling_factor_males' => JText::_('COM_COSTBENEFITPROJECTION_MORTALITY_MALES'),'mortality_scaling_factor_females' => JText::_('COM_COSTBENEFITPROJECTION_MORTALITY_FEMALES'),
|
||||
'presenteeism_scaling_factor_males' => JText::_('COM_COSTBENEFITPROJECTION_PRESENTEEISM_MALES'),'presenteeism_scaling_factor_females' => JText::_('COM_COSTBENEFITPROJECTION_PRESENTEEISM_FEMALES'),
|
||||
'published' => JText::_('COM_COSTBENEFITPROJECTION_STATUS'),'id' => JText::_('ID'));
|
||||
$rows = array('published' => 'setPublised', 'causerisk_name' => 'setScalingFactorLink');
|
||||
// header switces
|
||||
$datahide = array(
|
||||
'reference' => ' data-hide="all"', 'id' => ' data-ignore="true" data-hide="all"',
|
||||
'yld_scaling_factor_males' => ' data-hide="phone,tablet"','yld_scaling_factor_females' => ' data-hide="phone,tablet"',
|
||||
'mortality_scaling_factor_males' => ' data-hide="phone,tablet"','mortality_scaling_factor_females' => ' data-hide="phone,tablet"',
|
||||
'presenteeism_scaling_factor_males' => ' data-hide="phone,tablet"','presenteeism_scaling_factor_females' => ' data-hide="phone,tablet"');
|
||||
$datatype = array(
|
||||
'yld_scaling_factor_males' => ' data-type="numeric"','yld_scaling_factor_females' => ' data-type="numeric"',
|
||||
'mortality_scaling_factor_males' => ' data-type="numeric"','mortality_scaling_factor_females' => ' data-type="numeric"',
|
||||
'presenteeism_scaling_factor_males' => ' data-type="numeric"','presenteeism_scaling_factor_females' => ' data-type="numeric"',
|
||||
'id' => ' data-type="numeric"');
|
||||
$datatoggle = array('causerisk_name' => ' data-toggle="true"');
|
||||
// set the body
|
||||
$body = '';
|
||||
foreach ($displayData->idCompanyScaling_factorD as $details)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkObject($details))
|
||||
{
|
||||
// build the dl list
|
||||
$body .= '<tr>';
|
||||
foreach ($keys as $key => $header)
|
||||
{
|
||||
if (array_key_exists($key, $rows))
|
||||
{
|
||||
// this should be save since all data passed is internal
|
||||
$body .= "{$rows[$key]($details)}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$body .= '<td>'. $details->$key.'</td>';
|
||||
}
|
||||
}
|
||||
$body .= '</tr>';
|
||||
}
|
||||
}
|
||||
// set the header dynamic
|
||||
$head = '';
|
||||
foreach ($keys as $key => $header)
|
||||
{
|
||||
$head .= '<th';
|
||||
if (array_key_exists($key, $datatoggle))
|
||||
{
|
||||
// this should be save since all data passed is internal
|
||||
$head .= $datatoggle[$key];
|
||||
}
|
||||
if (array_key_exists($key, $datatype))
|
||||
{
|
||||
// this should be save since all data passed is internal
|
||||
$head .= $datatype[$key];
|
||||
}
|
||||
if (array_key_exists($key, $datahide))
|
||||
{
|
||||
// this should be save since all data passed is internal
|
||||
$head .= $datahide[$key];
|
||||
}
|
||||
|
||||
$head .= '>'. $header.'</th>';
|
||||
}
|
||||
$scalingfactors = '<table class="footable metro-blue toggle-circle" data-page-size="10"><thead><tr>'.$head.'</tr></thead><tbody>'.$body.'</tbody><tfoot class="hide-if-no-paging"><tr><td colspan="10"><div class="pagination pagination-centered"></div></td></tr></tfoot></table>';
|
||||
}
|
||||
// set interventions
|
||||
$interventions = '<div class="uk-alert">'.JText::_('COM_COSTBENEFITPROJECTION_NO_INTERVENTIONS_SET').'</div>';
|
||||
if (isset($displayData->idCompanyInterventionE) && CostbenefitprojectionHelper::checkArray($displayData->idCompanyInterventionE))
|
||||
{
|
||||
// the values to display
|
||||
$keys = array(
|
||||
'id' => JText::_('ID'),'name' => JText::_('COM_COSTBENEFITPROJECTION_NAME'),
|
||||
'type' => JText::_('COM_COSTBENEFITPROJECTION_TYPE'),'coverage' => JText::_('COM_COSTBENEFITPROJECTION_COVERAGE'),
|
||||
'share' => JText::_('COM_COSTBENEFITPROJECTION_SHARE'),'description' => JText::_('COM_COSTBENEFITPROJECTION_DESCRIPTION'),
|
||||
'reference' => JText::_('COM_COSTBENEFITPROJECTION_REFERENCE'),
|
||||
'intervention' => JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION'),'published' => JText::_('COM_COSTBENEFITPROJECTION_STATUS'));
|
||||
$rows = array('published' => 'setPublised', 'intervention' => 'setIntervention', 'name' => 'setInterventionLink', 'type' => 'setInterventionType', 'share' => 'setInterventionShare');
|
||||
// header switces
|
||||
$datahide = array(
|
||||
'id' => ' data-ignore="true" data-hide="all"',
|
||||
'share' => ' data-hide="phone,tablet"','description' => ' data-hide="all"',
|
||||
'reference' => ' data-hide="all"',
|
||||
'intervention' => ' data-hide="all"');
|
||||
$datatype = array(
|
||||
'id' => ' data-type="numeric"', 'coverage' => ' data-type="numeric"');
|
||||
$datatoggle = array('name' => ' data-toggle="true"');
|
||||
// set the body
|
||||
$body = '';
|
||||
foreach ($displayData->idCompanyInterventionE as $details)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkObject($details))
|
||||
{
|
||||
// build the dl list
|
||||
$body .= '<tr>';
|
||||
foreach ($keys as $key => $header)
|
||||
{
|
||||
if (array_key_exists($key, $rows))
|
||||
{
|
||||
// this should be save since all data passed is internal
|
||||
$body .= "{$rows[$key]($details)}";
|
||||
}
|
||||
else
|
||||
{
|
||||
$body .= '<td>'. $details->$key.'</td>';
|
||||
}
|
||||
}
|
||||
$body .= '</tr>';
|
||||
}
|
||||
}
|
||||
// set the header dynamic
|
||||
$head = '';
|
||||
foreach ($keys as $key => $header)
|
||||
{
|
||||
$head .= '<th';
|
||||
if (array_key_exists($key, $datatoggle))
|
||||
{
|
||||
// this should be save since all data passed is internal
|
||||
$head .= $datatoggle[$key];
|
||||
}
|
||||
if (array_key_exists($key, $datatype))
|
||||
{
|
||||
// this should be save since all data passed is internal
|
||||
$head .= $datatype[$key];
|
||||
}
|
||||
if (array_key_exists($key, $datahide))
|
||||
{
|
||||
// this should be save since all data passed is internal
|
||||
$head .= $datahide[$key];
|
||||
}
|
||||
|
||||
$head .= '>'. $header.'</th>';
|
||||
}
|
||||
$interventions = '<table class="footable metro-blue toggle-circle" data-page-size="10"><thead><tr>'.$head.'</tr></thead><tbody>'.$body.'</tbody><tfoot class="hide-if-no-paging"><tr><td colspan="9"><div class="pagination pagination-centered"></div></td></tr></tfoot></table>';
|
||||
}
|
||||
|
||||
?>
|
||||
<?php if ($canDo->get('company.edit')): ?>
|
||||
<?php if ($displayData->checked_out): ?>
|
||||
<?php echo JHtml::_('jgrid.checkedout', $displayData->id, $userChkOut->name, $displayData->checked_out_time, 'company.', $canCheckin); ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($canDo->get('company.edit') && $canDo->get('company.delete')): ?>
|
||||
<div class="uk-button-group uk-width-1-1">
|
||||
<?php $canDeleteNow = ''; ?>
|
||||
<?php if ($displayData->checked_out && $canCheckin): ?>
|
||||
<a class="uk-button uk-button-primary uk-button-large uk-width-2-5" href="<?php echo JRoute::_('index.php?option=com_costbenefitprojection&view=company&task=company.edit&id=' . $displayData->id); ?>"><i class="uk-icon-pencil"></i><span class="uk-hidden-small"> <?php echo ($displayData->department ==1) ? JText::_('COM_COSTBENEFITPROJECTION_EDIT_BASIC_PROFILE') : JText::_('COM_COSTBENEFITPROJECTION_EDIT_ADVANCED_PROFILE'); ?></span></a>
|
||||
<?php elseif ($displayData->checked_out && !$canCheckin): ?>
|
||||
<?php $canDeleteNow = ' disabled'; ?>
|
||||
<button class="uk-button uk-button-large uk-width-2-5" type="button" disabled><i class="uk-icon-lock"></i><span class="uk-hidden-small"> <?php echo ($displayData->department ==1) ? JText::_('COM_COSTBENEFITPROJECTION_EDIT_BASIC_PROFILE') : JText::_('COM_COSTBENEFITPROJECTION_EDIT_ADVANCED_PROFILE'); ?></span></button>
|
||||
<?php else: ?>
|
||||
<a class="uk-button uk-button-primary uk-button-large uk-width-2-5" href="<?php echo JRoute::_('index.php?option=com_costbenefitprojection&view=company&task=company.edit&id=' . $displayData->id); ?>"><i class="uk-icon-pencil"></i><span class="uk-hidden-small"> <?php echo ($displayData->department ==1) ? JText::_('COM_COSTBENEFITPROJECTION_EDIT_BASIC_PROFILE') : JText::_('COM_COSTBENEFITPROJECTION_EDIT_ADVANCED_PROFILE'); ?></span></a>
|
||||
<?php endif; ?>
|
||||
<a class="uk-button uk-button-success uk-button-large uk-width-2-5" href="<?php echo JRoute::_('index.php?option=com_costbenefitprojection&view=company-results&id=' . $displayData->id); ?>"><i class="uk-icon-bar-chart"></i><span class="uk-hidden-small"> <?php echo JText::_('COM_COSTBENEFITPROJECTION_RESULTS'); ?></span></a>
|
||||
<button class="uk-button uk-button-danger uk-button-large uk-width-1-5" type="button"<?php echo $canDeleteNow; ?>><i class="uk-icon-trash"></i><span class="uk-hidden-small"> <?php echo JText::_('COM_COSTBENEFITPROJECTION_TRASH'); ?></span></a>
|
||||
</div>
|
||||
<?php elseif ($canDo->get('company.edit')): ?>
|
||||
<div class="uk-button-group uk-width-1-1">
|
||||
<?php if ($displayData->checked_out && $canCheckin): ?>
|
||||
<a class="uk-button uk-button-primary uk-button-large uk-width-1-2" href="<?php echo JRoute::_('index.php?option=com_costbenefitprojection&view=company&task=company.edit&id=' . $displayData->id); ?>"><i class="uk-icon-pencil"></i><span class="uk-hidden-small"> <?php echo ($displayData->department ==1) ? JText::_('COM_COSTBENEFITPROJECTION_EDIT_BASIC_PROFILE') : JText::_('COM_COSTBENEFITPROJECTION_EDIT_ADVANCED_PROFILE'); ?></span></a>
|
||||
<?php elseif ($displayData->checked_out && !$canCheckin): ?>
|
||||
<button class="uk-button uk-button-large uk-width-1-2" type="button" disabled><i class="uk-icon-lock"></i><span class="uk-hidden-small"> <?php echo ($displayData->department ==1) ? JText::_('COM_COSTBENEFITPROJECTION_EDIT_BASIC_PROFILE') : JText::_('COM_COSTBENEFITPROJECTION_EDIT_ADVANCED_PROFILE'); ?></span></button>
|
||||
<?php else: ?>
|
||||
<a class="uk-button uk-button-primary uk-button-large uk-width-1-2" href="<?php echo JRoute::_('index.php?option=com_costbenefitprojection&view=company&task=company.edit&id=' . $displayData->id); ?>"><i class="uk-icon-pencil"></i><span class="uk-hidden-small"> <?php echo ($displayData->department ==1) ? JText::_('COM_COSTBENEFITPROJECTION_EDIT_BASIC_PROFILE') : JText::_('COM_COSTBENEFITPROJECTION_EDIT_ADVANCED_PROFILE'); ?></span></a>
|
||||
<?php endif; ?>
|
||||
<a class="uk-button uk-button-success uk-button-large uk-width-1-2" href="<?php echo JRoute::_('index.php?option=com_costbenefitprojection&view=company-results&id=' . $displayData->id); ?>"><i class="uk-icon-bar-chart"></i><span class="uk-hidden-small"> <?php echo JText::_('COM_COSTBENEFITPROJECTION_RESULTS'); ?></span></a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<a class="uk-button uk-button-success uk-button-large uk-width-1-1" href="<?php echo JRoute::_('index.php?option=com_costbenefitprojection&view=company-results&id=' . $displayData->id); ?>"><i class="uk-icon-bar-chart"></i><span class="uk-hidden-small"> <?php echo JText::_('COM_COSTBENEFITPROJECTION_RESULTS'); ?></span></a>
|
||||
<?php endif; ?>
|
||||
<div class="uk-panel">
|
||||
<ul class="uk-tab uk-tab-grid uk-width-medium-1-1 uk-tab-bottom" data-uk-tab="{connect:'#company_tab_<?php echo $displayData->id; ?>', animation: 'scale'}">
|
||||
<li class="uk-width-medium-1-5 uk-active"><a href=""><?php echo JText::_('COM_COSTBENEFITPROJECTION_INFO'); ?></a></li>
|
||||
<li class="charttab uk-width-medium-1-5 <?php echo (2 == $displayData->department) ? '':'uk-disabled'; ?>"><a class="charttab" href=""><?php echo JText::_('COM_COSTBENEFITPROJECTION_AGE_GROUPS'); ?></a></li>
|
||||
<li class="footabletab uk-width-medium-1-5 <?php echo (2 == $displayData->department) ? '':'uk-disabled'; ?>"><a class="footabletab" href=""><?php echo JText::_('COM_COSTBENEFITPROJECTION_CAUSESRISKS'); ?></a></li>
|
||||
<li class="footabletab uk-width-medium-1-5 <?php echo (2 == $displayData->department) ? '':'uk-disabled'; ?>"><a class="footabletab" href=""><?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTORS'); ?></a></li>
|
||||
<li class="footabletab uk-width-medium-1-5 <?php echo (2 == $displayData->department) ? '':'uk-disabled'; ?>"><a class="footabletab" href=""><?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTIONS'); ?></a></li>
|
||||
</ul>
|
||||
|
||||
<ul id="company_tab_<?php echo $displayData->id; ?>" class="uk-switcher uk-margin">
|
||||
<li>
|
||||
<div data-uk-grid-margin="" class="uk-grid" data-uk-grid-match="{target:'.uk-panel'}">
|
||||
<div class="uk-width-medium-1-2">
|
||||
<div class="uk-panel uk-panel-box">
|
||||
<h3 class="uk-panel-title"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DETAILS'); ?></h3>
|
||||
<dl class="uk-description-list-line">
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_COMPANY_USER'); ?></dt><dd><?php echo JFactory::getUser($displayData->user)->name; ?></dd>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_COMPANY_EMAIL'); ?></dt><dd><?php echo $displayData->email; ?></dd>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_DEPARTMENT'); ?></dt><dd><?php echo ($displayData->department ==1) ? JText::_('COM_COSTBENEFITPROJECTION_BASIC') : JText::_('COM_COSTBENEFITPROJECTION_ADVANCED'); ?></dd>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_COUNTRY'); ?></dt><dd><?php echo $displayData->country_name; ?></dd>
|
||||
<?php if ($displayData->service_provider_publicname): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_SERVICE_PROVIDER'); ?></dt><dd><?php echo $displayData->service_provider_publicname; ?></dd>
|
||||
<?php else: ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_SERVICE_PROVIDER'); ?></dt><dd><?php echo $displayData->service_provider_name; ?></dd>
|
||||
<?php endif; if ($displayData->service_provider_publicnumber): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_SERVICE_PROVIDER_NUMBER'); ?></dt><dd><?php echo $displayData->service_provider_publicnumber; ?></dd>
|
||||
<?php endif; if ($displayData->service_provider_publicemail): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_SERVICE_PROVIDER_EMAIL'); ?></dt><dd><?php echo $displayData->service_provider_publicemail; ?></dd>
|
||||
<?php endif; if ($displayData->country_publicname): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_COUNTRY_CONTACT'); ?></dt><dd><?php echo $displayData->country_publicname; ?></dd>
|
||||
<?php endif; if ($displayData->country_publicname): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_COUNTRY_CONTACT_NUMBER'); ?></dt><dd><?php echo $displayData->country_publicnumber; ?></dd>
|
||||
<?php endif; if ($displayData->country_publicemail): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_COUNTRY_CONTACT_EMAIL'); ?></dt><dd><?php echo $displayData->country_publicemail; ?></dd>
|
||||
<?php endif; ?>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uk-width-medium-1-2">
|
||||
<div class="uk-panel uk-panel-box">
|
||||
<h3 class="uk-panel-title"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NUMBERS'); ?></h3>
|
||||
<dl class="uk-description-list-line">
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_DATA_YEAR'); ?></dt><dd><?php echo $displayData->datayear; ?></dd>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_WORKING_DAYS'); ?></dt><dd><?php echo $displayData->working_days; ?></dd>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_SALARY'); ?></dt><dd><?php echo costbenefitprojectionHelper::makeMoney($displayData->total_salary); ?></dd>
|
||||
<?php if ($displayData->total_healthcare && (2 == $displayData->department)): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_HEALTHCARE_COSTS'); ?></dt><dd><?php echo costbenefitprojectionHelper::makeMoney($displayData->total_healthcare); ?></dd>
|
||||
<?php endif; if ($displayData->productivity_losses && (2 == $displayData->department)): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_MEDICAL_TURNOVER_COST_FACTOR'); ?></dt><dd><?php echo $displayData->productivity_losses; ?></dd>
|
||||
<?php endif; ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_MALE_EMPLOYEES'); ?></dt><dd><?php echo $displayData->males; ?></dd>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_FEMALE_EMPLOYEES'); ?></dt><dd><?php echo $displayData->females; ?></dd>
|
||||
<?php if ($displayData->medical_turnovers_males && (2 == $displayData->department)): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_NUMBER_MEDICAL_TURNOVERS_MALE'); ?></dt><dd><?php echo $displayData->medical_turnovers_males; ?></dd>
|
||||
<?php endif; if ($displayData->medical_turnovers_females && (2 == $displayData->department)): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_NUMBER_MEDICAL_TURNOVERS_FEMALE'); ?></dt><dd><?php echo $displayData->medical_turnovers_females; ?></dd>
|
||||
<?php endif; if ($displayData->sick_leave_males && (2 == $displayData->department)): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_NUMBER_SICK_LEAVE_DAYS_MALES'); ?></dt><dd><?php echo $displayData->sick_leave_males; ?></dd>
|
||||
<?php endif; if ($displayData->sick_leave_females && (2 == $displayData->department)): ?>
|
||||
<dt><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_NUMBER_SICK_LEAVE_DAYS_FEMALES'); ?></dt><dd><?php echo $displayData->sick_leave_females; ?></dd>
|
||||
<?php endif; ?>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div data-uk-margin>
|
||||
<?php echo $agepercents_numbers; ?>
|
||||
<div class="uk-visible-large">
|
||||
<?php $chartsId = CostbenefitprojectionHelper::randomkey(3); ?>
|
||||
<button class="uk-button uk-width-1-1 charttab" data-uk-toggle="{target:'#<?php echo $chartsId; ?>'}"><?php echo JText::_('COM_COSTBENEFITPROJECTION_AGE_GROUP_CHARTS'); ?></button>
|
||||
<div id="<?php echo $chartsId; ?>" class="uk-hidden"><?php echo $agepercents; ?></div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="uk-panel uk-width-1-1">
|
||||
<?php echo $causesrisks; ?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="uk-panel uk-width-1-1">
|
||||
<?php echo $scalingfactors; ?>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="uk-panel uk-width-1-1">
|
||||
<?php if (1): ?>
|
||||
<a class="uk-button uk-button-small uk-button-success" href="index.php?option=com_costbenefitprojection&view=intervention&layout=edit&ref=cpanel"><i class="uk-icon-plus"></i> <?php echo JText::_('COM_COSTBENEFITPROJECTION_NEW'); ?></a><br /><br />
|
||||
<?php endif; ?>
|
||||
<?php echo $interventions; ?>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage databreakdownmalefemale.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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('JPATH_BASE') or die('Restricted access');
|
||||
|
||||
$builder = array(
|
||||
'cost' => array('yld' => 'YLD','death' => 'Death','costmoney_morbidity_'.$displayData->_tmpScale => 'Cost Morbidity','costmoney_presenteeism_'.$displayData->_tmpScale => 'Cost Presenteeism (due to morbidity)','costmoney_mortality_'.$displayData->_tmpScale => 'Cost Mortality'),
|
||||
'day' => array('yld' => 'YLD','death' => 'Death','morbidity_'.$displayData->_tmpScale => 'Days Lost Morbidity','presenteeism_'.$displayData->_tmpScale => 'Days Lost Presenteeism (due to morbidity)','days_lost_mortality_'.$displayData->_tmpScale => 'Days Lost Mortality')
|
||||
);
|
||||
$rounder = array(
|
||||
'cost' => array('yld','death'),
|
||||
'day' => array('yld','death','morbidity_'.$displayData->_tmpScale, 'presenteeism_'.$displayData->_tmpScale, 'days_lost_mortality_'.$displayData->_tmpScale)
|
||||
);
|
||||
|
||||
?>
|
||||
<?php if (isset($displayData->male) && isset($displayData->female) ): ?>
|
||||
<div class="uk-grid">
|
||||
<div style="float:left;">
|
||||
<ul class="uk-list uk-list-striped">
|
||||
<?php foreach ($displayData->male as $age => $values): ?>
|
||||
<li>
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_MALES_AGE_GROUP'); ?> <?php echo $age; ?>
|
||||
<?php foreach ($values as $key => $value): ?>
|
||||
<?php if (in_array($key, $rounder[$displayData->_tmpType])) { $value = round($value,3); } ?>
|
||||
<?php if (isset($builder[$displayData->_tmpType][$key])): ?>
|
||||
<br />↳ <?php echo $builder[$displayData->_tmpType][$key] ?>: <b><?php echo $value;?></b>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
<div style="float:left;">
|
||||
<ul class="uk-list uk-list-striped">
|
||||
<?php foreach ($displayData->female as $age => $values): ?>
|
||||
<li>
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_FEMALES_AGE_GROUP'); ?> <?php echo $age; ?>
|
||||
<?php foreach ($values as $key => $value): ?>
|
||||
<?php if (in_array($key, $rounder[$displayData->_tmpType])) { $value = round($value,3); } ?>
|
||||
<?php if (isset($builder[$displayData->_tmpType][$key])): ?>
|
||||
<br />↳ <?php echo $builder[$displayData->_tmpType][$key] ?>: <b><?php echo $value;?></b>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_UNAVAILABLE_AT_THIS_TIME'); ?>
|
||||
<?php endif; ?>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage details_above.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = array(
|
||||
'name',
|
||||
'company',
|
||||
'country',
|
||||
'type'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="form-inline form-inline-header">
|
||||
<?php foreach($fields as $field){
|
||||
echo $form->renderField($field);
|
||||
} ?>
|
||||
</div>
|
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage details_fullwidth.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'coverage',
|
||||
'duration',
|
||||
'share',
|
||||
'description',
|
||||
'reference'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="form-vertical">
|
||||
<?php foreach($fields as $field): ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $form->getLabel($field); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $form->getInput($field); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage details_under.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = array(
|
||||
'not_required'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="form-inline form-inline-header">
|
||||
<?php foreach($fields as $field){
|
||||
echo $form->renderField($field);
|
||||
} ?>
|
||||
</div>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage publishing.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'created',
|
||||
'created_by',
|
||||
'modified',
|
||||
'modified_by'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage publlshing.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'published',
|
||||
'ordering',
|
||||
'version',
|
||||
'hits',
|
||||
'id'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage settings_fullwidth.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'intervention'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="form-vertical">
|
||||
<?php foreach($fields as $field): ?>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<?php echo $form->getLabel($field); ?>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<?php echo $form->getInput($field); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage settings_left.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'interventions'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage details_above.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = array(
|
||||
'company',
|
||||
'country'
|
||||
);
|
||||
|
||||
?>
|
||||
<div class="form-inline form-inline-header">
|
||||
<?php foreach($fields as $field){
|
||||
echo $form->renderField($field);
|
||||
} ?>
|
||||
</div>
|
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage details_left.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'causerisk',
|
||||
'reference'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage details_right.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'yld_scaling_factor_males',
|
||||
'yld_scaling_factor_females',
|
||||
'mortality_scaling_factor_males',
|
||||
'mortality_scaling_factor_females',
|
||||
'presenteeism_scaling_factor_males',
|
||||
'presenteeism_scaling_factor_females',
|
||||
'health_scaling_factor'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage publishing.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'created',
|
||||
'created_by',
|
||||
'modified',
|
||||
'modified_by'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage publlshing.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$app = JFactory::getApplication();
|
||||
$form = $displayData->getForm();
|
||||
|
||||
$fields = $displayData->get('fields') ?: array(
|
||||
'published',
|
||||
'ordering',
|
||||
'version',
|
||||
'hits',
|
||||
'id'
|
||||
);
|
||||
|
||||
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
$field = is_array($field) ? $field : array($field);
|
||||
foreach ($field as $f)
|
||||
{
|
||||
if ($form->getField($f))
|
||||
{
|
||||
if (in_array($f, $hiddenFields))
|
||||
{
|
||||
$form->setFieldAttribute($f, 'type', 'hidden');
|
||||
}
|
||||
|
||||
echo $form->renderField($f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage ajax.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
jimport('joomla.application.component.helper');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Ajax Model
|
||||
*/
|
||||
class CostbenefitprojectionModelAjax extends JModelList
|
||||
{
|
||||
protected $app_params;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
// get params
|
||||
$this->app_params = JComponentHelper::getParams('com_costbenefitprojection');
|
||||
|
||||
}
|
||||
|
||||
// Used in company
|
||||
public function getCalculatedResult($id,$data)
|
||||
{
|
||||
return CostbenefitprojectionHelper::calculate($id,$data);
|
||||
}
|
||||
|
||||
// Used in intervention
|
||||
public function getInterventionBuildTable($idName,$oject,$cluster)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::isJson($oject) && CostbenefitprojectionHelper::checkString($idName))
|
||||
{
|
||||
$array = json_decode($oject, true);
|
||||
$targetHeaders = array(
|
||||
'causerisk' => JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK'),
|
||||
'cpe' => JText::_('COM_COSTBENEFITPROJECTION_COST_PER_EMPLOYEE'),
|
||||
'mbr' => JText::_('COM_COSTBENEFITPROJECTION_MORBIDITY_REDUCTION'),
|
||||
'mtr' => JText::_('COM_COSTBENEFITPROJECTION_MORTALITY_REDUCTION'));
|
||||
if (CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$table = '<table id="table_'.$idName.'" class="table" style="margin: 5px 0 20px;"><thead><tr>';
|
||||
$rows = array();
|
||||
foreach ($array as $header => $values)
|
||||
{
|
||||
$table .= '<th style="padding: 10px; text-align: center; border: 1px solid rgb(221, 221, 221);" scope="col">'.$targetHeaders[$header].'</th>';
|
||||
if (CostbenefitprojectionHelper::checkArray($values))
|
||||
{
|
||||
foreach ($values as $nr => $value)
|
||||
{
|
||||
if ($header == 'causerisk')
|
||||
{
|
||||
$value = CostbenefitprojectionHelper::getId('causerisk',$value,'id','name');
|
||||
}
|
||||
elseif ($cluster == 'ja')
|
||||
{
|
||||
$vc = $header.'_'.$nr;
|
||||
if (strpos($value, '&') !== false)
|
||||
{
|
||||
$value = '<input style="width:100px; color:red;" class="clusterintervention required eRrOr" id="'.$vc.'" placeholder="Only A Number" value="'.$value.'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
$value = '<input style="width:100px;" class="clusterintervention required" id="'.$vc.'" placeholder="Only A Number" value="'.$value.'">';
|
||||
}
|
||||
}
|
||||
// build rows
|
||||
if (!isset($rows[$nr]))
|
||||
{
|
||||
$rows[$nr] = '<td style="padding: 10px; text-align: center; border: 1px solid rgb(221, 221, 221);">'.$value.'</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$rows[$nr] .= '<td style="padding: 10px; text-align: center; border: 1px solid rgb(221, 221, 221);">'.$value.'</td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// close header start body
|
||||
$table .= '</tr></thead><tbody>';
|
||||
// add rows to table
|
||||
if (CostbenefitprojectionHelper::checkArray($rows))
|
||||
{
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$table .= '<tr>'.$row.'</tr>';
|
||||
}
|
||||
}
|
||||
// close the body and table
|
||||
$table .= '</tbody></table>';
|
||||
// return the table
|
||||
return $table;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getClusterData($idName,$cluster)
|
||||
{
|
||||
// we first build the json object from the cluster ids, then pass it to the builder
|
||||
$oject = '';
|
||||
$oject_table = '';
|
||||
if (CostbenefitprojectionHelper::isJson($cluster) && CostbenefitprojectionHelper::checkString($idName))
|
||||
{
|
||||
$array = json_decode($cluster, true);
|
||||
// get te set intervention data
|
||||
$interventions = array();
|
||||
if (CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
foreach ($array as $intervention)
|
||||
{
|
||||
$interventions[$intervention] = CostbenefitprojectionHelper::getVar('intervention', $intervention, 'id', 'intervention');
|
||||
}
|
||||
}
|
||||
// sort the data
|
||||
$bucket = array();
|
||||
if (CostbenefitprojectionHelper::checkArray($interventions))
|
||||
{
|
||||
foreach ($interventions as $inter => $set)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::isJson($set))
|
||||
{
|
||||
$set = json_decode($set, true);
|
||||
if (CostbenefitprojectionHelper::checkArray($set))
|
||||
{
|
||||
foreach ($set as $option => $values)
|
||||
{
|
||||
foreach ($values as $nr => $value)
|
||||
{
|
||||
$bucket[$inter][$nr][$option] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// combine the data
|
||||
$combine = array();
|
||||
if (CostbenefitprojectionHelper::checkArray($bucket))
|
||||
{
|
||||
foreach ($bucket as $pool)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkArray($pool))
|
||||
{
|
||||
foreach ($pool as $headers)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkArray($headers))
|
||||
{
|
||||
// check if this cause is already targeted
|
||||
if (isset($combine[$headers['causerisk']]))
|
||||
{
|
||||
// combine
|
||||
$temp = $combine[$headers['causerisk']];
|
||||
$temp['cpe'] = $this->combineValues($temp['cpe'], $headers['cpe']);
|
||||
$temp['mbr'] = $this->combineValues($temp['mbr'], $headers['mbr']);
|
||||
$temp['mtr'] = $this->combineValues($temp['mtr'], $headers['mtr']);
|
||||
// update the data
|
||||
$combine[$headers['causerisk']] = $temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
// set for first time
|
||||
$combine[$headers['causerisk']] = array(
|
||||
'cpe' => $headers['cpe'],
|
||||
'mbr' => $headers['mbr'],
|
||||
'mtr' => $headers['mtr']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// setup the object
|
||||
if (CostbenefitprojectionHelper::checkArray($combine))
|
||||
{
|
||||
$oject = array();
|
||||
foreach ($combine as $causerisk => $vals)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkArray($vals))
|
||||
{
|
||||
$oject['causerisk'][] = $causerisk;
|
||||
foreach ($vals as $header => $v)
|
||||
{
|
||||
// set placeholder
|
||||
$oject[$header][] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
// done at last
|
||||
$oject = json_encode($oject);
|
||||
}
|
||||
}
|
||||
// return the table and values
|
||||
return array('table' => $this->getInterventionBuildTable($idName,$oject,'ja'), 'values' => $oject);
|
||||
}
|
||||
|
||||
protected function combineValues($old,$new)
|
||||
{
|
||||
$old = trim($old);
|
||||
$new = trim($new);
|
||||
if ($old != $new)
|
||||
{
|
||||
if (strpos($old, '&') !== false)
|
||||
{
|
||||
$oldArray = array_map('trim',explode('&', $old));
|
||||
foreach ($oldArray as $nr => $oldValue)
|
||||
{
|
||||
if ($oldValue == $new)
|
||||
{
|
||||
unset($oldArray[$nr]);
|
||||
}
|
||||
}
|
||||
$old = implode(' & ', $oldArray);
|
||||
}
|
||||
return $old.' & '.$new;
|
||||
}
|
||||
return $new;
|
||||
}
|
||||
}
|
@@ -0,0 +1,594 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage combinedresults.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import the Joomla modellist library
|
||||
jimport('joomla.application.component.modellist');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Model for Combinedresults
|
||||
*/
|
||||
class CostbenefitprojectionModelCombinedresults extends JModelList
|
||||
{
|
||||
/**
|
||||
* Model user data.
|
||||
*
|
||||
* @var strings
|
||||
*/
|
||||
protected $user;
|
||||
protected $userId;
|
||||
protected $guest;
|
||||
protected $groups;
|
||||
protected $levels;
|
||||
protected $app;
|
||||
protected $input;
|
||||
protected $uikitComp;
|
||||
|
||||
/**
|
||||
* Method to build an SQL query to load the list data.
|
||||
*
|
||||
* @return string An SQL query
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
// Get the current user for authorisation checks
|
||||
$this->user = JFactory::getUser();
|
||||
$this->userId = $this->user->get('id');
|
||||
$this->guest = $this->user->get('guest');
|
||||
$this->groups = $this->user->get('groups');
|
||||
$this->authorisedGroups = $this->user->getAuthorisedGroups();
|
||||
$this->levels = $this->user->getAuthorisedViewLevels();
|
||||
$this->app = JFactory::getApplication();
|
||||
$this->input = $this->app->input;
|
||||
$this->initSet = true;
|
||||
|
||||
|
||||
$ids = (array) array_map('intval',explode('_', $this->input->get('cid', null, 'CMD')));
|
||||
if (!$this->user->authorise('core.options', 'com_costbenefitprojection') && CostbenefitprojectionHelper::checkArray($ids))
|
||||
{
|
||||
// make absolutely sure that these companies can be viewed
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($this->userId);
|
||||
foreach($ids as $nr => $pk)
|
||||
{
|
||||
if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($pk,$companies))
|
||||
{
|
||||
// remove if not found
|
||||
unset($ids[$nr]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// only continue if we have ids
|
||||
if (!CostbenefitprojectionHelper::checkArray($ids))
|
||||
{
|
||||
// redirect away if not a correct (TODO for now we go to default view)
|
||||
JError::raiseWarning(500, JText::_('No companies selected!'));
|
||||
$app = JFactory::getApplication();
|
||||
if ($app->isAdmin())
|
||||
{
|
||||
JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection');
|
||||
}
|
||||
else
|
||||
{
|
||||
JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection&view=cpanel');
|
||||
}
|
||||
}
|
||||
// Make sure all records load, since no pagination allowed.
|
||||
$this->setState('list.limit', 0);
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_company as a
|
||||
$query->select($db->quoteName(
|
||||
array('a.id','a.name','a.user','a.department','a.per','a.country','a.service_provider','a.datayear','a.working_days','a.total_salary','a.total_healthcare','a.productivity_losses','a.males','a.females','a.medical_turnovers_males','a.medical_turnovers_females','a.sick_leave_males','a.sick_leave_females','a.percentmale','a.percentfemale','a.causesrisks','a.published','a.access'),
|
||||
array('id','name','user','department','per','country','service_provider','datayear','working_days','total_salary','total_healthcare','productivity_losses','males','females','medical_turnovers_males','medical_turnovers_females','sick_leave_males','sick_leave_females','percentmale','percentfemale','causesrisks','published','access')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_company', 'a'));
|
||||
|
||||
// Get from #__costbenefitprojection_country as e
|
||||
$query->select($db->quoteName(
|
||||
array('e.id','e.name','e.alias','e.user','e.currency','e.datayear','e.worldzone','e.codethree','e.codetwo','e.working_days','e.presenteeism','e.medical_turnovers','e.sick_leave','e.healthcare','e.productivity_losses','e.publicname','e.publicemail','e.publicnumber','e.publicaddress','e.percentmale','e.percentfemale','e.causesrisks','e.maledeath','e.femaledeath','e.maleyld','e.femaleyld','e.access'),
|
||||
array('country_id','country_name','country_alias','country_user','country_currency','country_datayear','country_worldzone','country_codethree','country_codetwo','country_working_days','country_presenteeism','country_medical_turnovers','country_sick_leave','country_healthcare','country_productivity_losses','country_publicname','country_publicemail','country_publicnumber','country_publicaddress','country_percentmale','country_percentfemale','country_causesrisks','country_maledeath','country_femaledeath','country_maleyld','country_femaleyld','country_access')));
|
||||
$query->join('LEFT', ($db->quoteName('#__costbenefitprojection_country', 'e')) . ' ON (' . $db->quoteName('a.country') . ' = ' . $db->quoteName('e.id') . ')');
|
||||
|
||||
// Get from #__costbenefitprojection_currency as f
|
||||
$query->select($db->quoteName(
|
||||
array('f.id','f.name','f.alias','f.codethree','f.numericcode','f.symbol','f.thousands','f.decimalplace','f.decimalsymbol','f.positivestyle','f.negativestyle','f.published','f.access','f.ordering'),
|
||||
array('currency_id','currency_name','currency_alias','currency_codethree','currency_numericcode','currency_symbol','currency_thousands','currency_decimalplace','currency_decimalsymbol','currency_positivestyle','currency_negativestyle','currency_published','currency_access','currency_ordering')));
|
||||
$query->join('LEFT', ($db->quoteName('#__costbenefitprojection_currency', 'f')) . ' ON (' . $db->quoteName('e.currency') . ' = ' . $db->quoteName('f.codethree') . ')');
|
||||
// Check if $ids is an array with values.
|
||||
$array = $ids;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('a.id IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// return the query object
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of data items.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
// check if this user has permission to access items
|
||||
if (!$user->authorise('site.combinedresults.access', 'com_costbenefitprojection'))
|
||||
{
|
||||
JError::raiseWarning(500, JText::_('Not authorised!'));
|
||||
// redirect away if not a correct (TODO for now we go to default view)
|
||||
JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_costbenefitprojection&view=cpanel'));
|
||||
return false;
|
||||
}
|
||||
// load parent items
|
||||
$items = parent::getItems();
|
||||
|
||||
// Get the global params
|
||||
$globalParams = JComponentHelper::getParams('com_costbenefitprojection', true);
|
||||
|
||||
// Get the advanced encription.
|
||||
$advancedkey = CostbenefitprojectionHelper::getCryptKey('advanced');
|
||||
// Get the encription object.
|
||||
$advanced = new FOFEncryptAes($advancedkey, 256);
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Always create a slug for sef URL's
|
||||
$item->slug = (isset($item->alias)) ? $item->id.':'.$item->alias : $item->id;
|
||||
if (!empty($item->medical_turnovers_females) && $advancedkey && !is_numeric($item->medical_turnovers_females) && $item->medical_turnovers_females === base64_encode(base64_decode($item->medical_turnovers_females, true)))
|
||||
{
|
||||
// Decode medical_turnovers_females
|
||||
$item->medical_turnovers_females = rtrim($advanced->decryptString($item->medical_turnovers_females), "\0");
|
||||
}
|
||||
if (!empty($item->females) && $advancedkey && !is_numeric($item->females) && $item->females === base64_encode(base64_decode($item->females, true)))
|
||||
{
|
||||
// Decode females
|
||||
$item->females = rtrim($advanced->decryptString($item->females), "\0");
|
||||
}
|
||||
if (!empty($item->sick_leave_males) && $advancedkey && !is_numeric($item->sick_leave_males) && $item->sick_leave_males === base64_encode(base64_decode($item->sick_leave_males, true)))
|
||||
{
|
||||
// Decode sick_leave_males
|
||||
$item->sick_leave_males = rtrim($advanced->decryptString($item->sick_leave_males), "\0");
|
||||
}
|
||||
if (CostbenefitprojectionHelper::checkString($item->causesrisks))
|
||||
{
|
||||
// Decode causesrisks
|
||||
$item->causesrisks = json_decode($item->causesrisks, true);
|
||||
}
|
||||
if (!empty($item->medical_turnovers_males) && $advancedkey && !is_numeric($item->medical_turnovers_males) && $item->medical_turnovers_males === base64_encode(base64_decode($item->medical_turnovers_males, true)))
|
||||
{
|
||||
// Decode medical_turnovers_males
|
||||
$item->medical_turnovers_males = rtrim($advanced->decryptString($item->medical_turnovers_males), "\0");
|
||||
}
|
||||
if (!empty($item->total_salary) && $advancedkey && !is_numeric($item->total_salary) && $item->total_salary === base64_encode(base64_decode($item->total_salary, true)))
|
||||
{
|
||||
// Decode total_salary
|
||||
$item->total_salary = rtrim($advanced->decryptString($item->total_salary), "\0");
|
||||
}
|
||||
if (!empty($item->sick_leave_females) && $advancedkey && !is_numeric($item->sick_leave_females) && $item->sick_leave_females === base64_encode(base64_decode($item->sick_leave_females, true)))
|
||||
{
|
||||
// Decode sick_leave_females
|
||||
$item->sick_leave_females = rtrim($advanced->decryptString($item->sick_leave_females), "\0");
|
||||
}
|
||||
if (!empty($item->total_healthcare) && $advancedkey && !is_numeric($item->total_healthcare) && $item->total_healthcare === base64_encode(base64_decode($item->total_healthcare, true)))
|
||||
{
|
||||
// Decode total_healthcare
|
||||
$item->total_healthcare = rtrim($advanced->decryptString($item->total_healthcare), "\0");
|
||||
}
|
||||
if (!empty($item->males) && $advancedkey && !is_numeric($item->males) && $item->males === base64_encode(base64_decode($item->males, true)))
|
||||
{
|
||||
// Decode males
|
||||
$item->males = rtrim($advanced->decryptString($item->males), "\0");
|
||||
}
|
||||
if (CostbenefitprojectionHelper::checkString($item->country_causesrisks))
|
||||
{
|
||||
// Decode country_causesrisks
|
||||
$item->country_causesrisks = json_decode($item->country_causesrisks, true);
|
||||
}
|
||||
// Make sure the content prepare plugins fire on country_publicaddress.
|
||||
$item->country_publicaddress = JHtml::_('content.prepare',$item->country_publicaddress);
|
||||
// Checking if country_publicaddress has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->country_publicaddress,$this->uikitComp);
|
||||
// set the global causesrisks value.
|
||||
$this->a_causesrisks = $item->causesrisks;
|
||||
// set the global datayear value.
|
||||
$this->a_datayear = $item->datayear;
|
||||
// set the global datayear value.
|
||||
$this->e_datayear = $item->country_datayear;
|
||||
// set the global causesrisks value.
|
||||
$this->e_causesrisks = $item->country_causesrisks;
|
||||
// set countryCountryHealth_dataB to the $item object.
|
||||
$item->countryCountryHealth_dataB = $this->getCountryCountryHealth_dataBcbb_B($item->country);
|
||||
// set idCompanyScaling_factorC to the $item object.
|
||||
$item->idCompanyScaling_factorC = $this->getIdCompanyScaling_factorBcbb_C($item->id);
|
||||
// set idCompanyInterventionD to the $item object.
|
||||
$item->idCompanyInterventionD = $this->getIdCompanyInterventionBcbb_D($item->id);
|
||||
// set causesrisksIdCauseriskG to the $item object.
|
||||
$item->causesrisksIdCauseriskG = $this->getCausesrisksIdCauseriskBcbb_G($item->causesrisks);
|
||||
// set countryCountryHealth_dataBB to the $item object.
|
||||
$item->countryCountryHealth_dataBB = $this->getCountryCountryHealth_dataBcbb_BB($item->country);
|
||||
// set causesrisksIdCauseriskGG to the $item object.
|
||||
$item->causesrisksIdCauseriskGG = $this->getCausesrisksIdCauseriskBcbb_GG($item->country_causesrisks);
|
||||
// set countryCountryInterventionDD to the $item object.
|
||||
$item->countryCountryInterventionDD = $this->getCountryCountryInterventionBcbb_DD($item->country);
|
||||
}
|
||||
|
||||
// return items
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Health_data Objects.
|
||||
*
|
||||
* @return mixed An array of Health_data Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCountryCountryHealth_dataBcbb_B($country)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_health_data as b
|
||||
$query->select($db->quoteName(
|
||||
array('b.id','b.causerisk','b.year','b.maledeath','b.maleyld','b.femaledeath','b.femaleyld','b.published'),
|
||||
array('id','causerisk','year','maledeath','maleyld','femaledeath','femaleyld','published')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_health_data', 'b'));
|
||||
$query->where('b.country = ' . $db->quote($country));
|
||||
// Check if $this->a_causesrisks is an array with values.
|
||||
$array = $this->a_causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('b.causerisk IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$query->where('b.published = 1');
|
||||
$query->where('b.year = ' . $db->quote($this->a_datayear));
|
||||
$query->order('b.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Scaling_factor Objects.
|
||||
*
|
||||
* @return mixed An array of Scaling_factor Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getIdCompanyScaling_factorBcbb_C($id)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_scaling_factor as c
|
||||
$query->select($db->quoteName(
|
||||
array('c.id','c.causerisk','c.reference','c.yld_scaling_factor_males','c.yld_scaling_factor_females','c.mortality_scaling_factor_males','c.mortality_scaling_factor_females','c.presenteeism_scaling_factor_males','c.presenteeism_scaling_factor_females','c.health_scaling_factor','c.published'),
|
||||
array('id','causerisk','reference','yld_scaling_factor_males','yld_scaling_factor_females','mortality_scaling_factor_males','mortality_scaling_factor_females','presenteeism_scaling_factor_males','presenteeism_scaling_factor_females','health_scaling_factor','published')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_scaling_factor', 'c'));
|
||||
$query->where('c.company = ' . $db->quote($id));
|
||||
$query->where('c.published = 1');
|
||||
$query->order('c.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Make sure the content prepare plugins fire on reference.
|
||||
$item->reference = JHtml::_('content.prepare',$item->reference);
|
||||
// Checking if reference has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->reference,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Intervention Objects.
|
||||
*
|
||||
* @return mixed An array of Intervention Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getIdCompanyInterventionBcbb_D($id)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_intervention as d
|
||||
$query->select($db->quoteName(
|
||||
array('d.id','d.name','d.type','d.coverage','d.duration','d.share','d.description','d.reference','d.interventions','d.intervention','d.published','d.created_by','d.modified_by','d.created','d.modified'),
|
||||
array('id','name','type','coverage','duration','share','description','reference','interventions','intervention','published','created_by','modified_by','created','modified')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_intervention', 'd'));
|
||||
$query->where('d.company = ' . $db->quote($id));
|
||||
$query->where('d.published = 1');
|
||||
$query->order('d.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Make sure the content prepare plugins fire on reference.
|
||||
$item->reference = JHtml::_('content.prepare',$item->reference);
|
||||
// Checking if reference has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->reference,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Causerisk Objects.
|
||||
*
|
||||
* @return mixed An array of Causerisk Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCausesrisksIdCauseriskBcbb_G($causesrisks)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_causerisk as g
|
||||
$query->select($db->quoteName(
|
||||
array('g.id','g.name','g.ref','g.alias','g.description'),
|
||||
array('id','name','ref','alias','description')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_causerisk', 'g'));
|
||||
|
||||
// Check if $causesrisks is an array with values.
|
||||
$array = $causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('g.id IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Health_data Objects.
|
||||
*
|
||||
* @return mixed An array of Health_data Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCountryCountryHealth_dataBcbb_BB($country)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_health_data as bb
|
||||
$query->select($db->quoteName(
|
||||
array('bb.id','bb.asset_id','bb.causerisk','bb.year','bb.country','bb.maledeath','bb.maleyld','bb.femaledeath','bb.femaleyld','bb.published','bb.created_by','bb.modified_by','bb.created','bb.modified','bb.version','bb.hits','bb.ordering'),
|
||||
array('id','asset_id','causerisk','year','country','maledeath','maleyld','femaledeath','femaleyld','published','created_by','modified_by','created','modified','version','hits','ordering')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_health_data', 'bb'));
|
||||
$query->where('bb.country = ' . $db->quote($country));
|
||||
// Check if $this->e_causesrisks is an array with values.
|
||||
$array = $this->e_causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('bb.causerisk IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$query->where('bb.published = 1');
|
||||
$query->where('bb.year = ' . $db->quote($this->e_datayear));
|
||||
$query->order('bb.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Causerisk Objects.
|
||||
*
|
||||
* @return mixed An array of Causerisk Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCausesrisksIdCauseriskBcbb_GG($causesrisks)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_causerisk as gg
|
||||
$query->select($db->quoteName(
|
||||
array('gg.id','gg.name','gg.ref','gg.alias','gg.description'),
|
||||
array('id','name','ref','alias','description')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_causerisk', 'gg'));
|
||||
|
||||
// Check if $causesrisks is an array with values.
|
||||
$array = $causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('gg.id IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Make sure the content prepare plugins fire on description.
|
||||
$item->description = JHtml::_('content.prepare',$item->description);
|
||||
// Checking if description has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->description,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Intervention Objects.
|
||||
*
|
||||
* @return mixed An array of Intervention Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCountryCountryInterventionBcbb_DD($country)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_intervention as dd
|
||||
$query->select($db->quoteName(
|
||||
array('dd.id','dd.name','dd.type','dd.coverage','dd.duration','dd.share','dd.description','dd.reference','dd.interventions','dd.intervention','dd.published','dd.created_by','dd.modified_by','dd.created','dd.modified'),
|
||||
array('id','name','type','coverage','duration','share','description','reference','interventions','intervention','published','created_by','modified_by','created','modified')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_intervention', 'dd'));
|
||||
$query->where('dd.country = ' . $db->quote($country));
|
||||
$query->where('dd.published = 1');
|
||||
$query->order('dd.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkString($item->interventions))
|
||||
{
|
||||
// Decode interventions
|
||||
$item->interventions = json_decode($item->interventions, true);
|
||||
}
|
||||
// Make sure the content prepare plugins fire on description.
|
||||
$item->description = JHtml::_('content.prepare',$item->description);
|
||||
// Checking if description has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->description,$this->uikitComp);
|
||||
// Make sure the content prepare plugins fire on reference.
|
||||
$item->reference = JHtml::_('content.prepare',$item->reference);
|
||||
// Checking if reference has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->reference,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the uikit needed components
|
||||
*
|
||||
* @return mixed An array of objects on success.
|
||||
*
|
||||
*/
|
||||
public function getUikitComp()
|
||||
{
|
||||
if (isset($this->uikitComp) && CostbenefitprojectionHelper::checkArray($this->uikitComp))
|
||||
{
|
||||
return $this->uikitComp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,618 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage companyresults.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import Joomla modelitem library
|
||||
jimport('joomla.application.component.modelitem');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Companyresults Model
|
||||
*/
|
||||
class CostbenefitprojectionModelCompanyresults extends JModelItem
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = 'com_costbenefitprojection.companyresults';
|
||||
|
||||
/**
|
||||
* Model user data.
|
||||
*
|
||||
* @var strings
|
||||
*/
|
||||
protected $user;
|
||||
protected $userId;
|
||||
protected $guest;
|
||||
protected $groups;
|
||||
protected $levels;
|
||||
protected $app;
|
||||
protected $input;
|
||||
protected $uikitComp;
|
||||
|
||||
/**
|
||||
* @var object item
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$this->app = JFactory::getApplication();
|
||||
$this->input = $this->app->input;
|
||||
// Get the itme main id
|
||||
$id = $this->input->getInt('id', null);
|
||||
$this->setState('companyresults.id', $id);
|
||||
|
||||
// Load the parameters.
|
||||
$params = $this->app->getParams();
|
||||
$this->setState('params', $params);
|
||||
parent::populateState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get article data.
|
||||
*
|
||||
* @param integer $pk The id of the article.
|
||||
*
|
||||
* @return mixed Menu item data object on success, false on failure.
|
||||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
$this->user = JFactory::getUser();
|
||||
// check if this user has permission to access item
|
||||
if (!$this->user->authorise('site.companyresults.access', 'com_costbenefitprojection'))
|
||||
{
|
||||
JError::raiseWarning(500, JText::_('Not authorised!'));
|
||||
// redirect away if not a correct (TODO for now we go to default view)
|
||||
JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_costbenefitprojection&view=cpanel'));
|
||||
return false;
|
||||
}
|
||||
$this->userId = $this->user->get('id');
|
||||
$this->guest = $this->user->get('guest');
|
||||
$this->groups = $this->user->get('groups');
|
||||
$this->authorisedGroups = $this->user->getAuthorisedGroups();
|
||||
$this->levels = $this->user->getAuthorisedViewLevels();
|
||||
$this->initSet = true;
|
||||
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('companyresults.id');
|
||||
|
||||
if (!$this->user->authorise('core.options', 'com_costbenefitprojection'))
|
||||
{
|
||||
// make absolutely sure that this company can be viewed
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($this->userId);
|
||||
if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($pk,$companies))
|
||||
{
|
||||
JError::raiseWarning(500, JText::_('Access denied!'));
|
||||
// redirect away if not a correct (TODO for now we go to default view)
|
||||
$app = JFactory::getApplication();
|
||||
if ($app->isAdmin())
|
||||
{
|
||||
JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection');
|
||||
}
|
||||
else
|
||||
{
|
||||
JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection&view=cpanel');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->_item === null)
|
||||
{
|
||||
$this->_item = array();
|
||||
}
|
||||
|
||||
if (!isset($this->_item[$pk]))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
// Get the advanced encription.
|
||||
$advancedkey = CostbenefitprojectionHelper::getCryptKey('advanced');
|
||||
// Get the encription object.
|
||||
$advanced = new FOFEncryptAes($advancedkey, 256);
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_company as a
|
||||
$query->select($db->quoteName(
|
||||
array('a.id','a.name','a.user','a.department','a.per','a.country','a.service_provider','a.datayear','a.working_days','a.total_salary','a.total_healthcare','a.productivity_losses','a.males','a.females','a.medical_turnovers_males','a.medical_turnovers_females','a.sick_leave_males','a.sick_leave_females','a.percentmale','a.percentfemale','a.causesrisks','a.published','a.access'),
|
||||
array('id','name','user','department','per','country','service_provider','datayear','working_days','total_salary','total_healthcare','productivity_losses','males','females','medical_turnovers_males','medical_turnovers_females','sick_leave_males','sick_leave_females','percentmale','percentfemale','causesrisks','published','access')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_company', 'a'));
|
||||
|
||||
// Get from #__costbenefitprojection_country as e
|
||||
$query->select($db->quoteName(
|
||||
array('e.id','e.name','e.alias','e.user','e.currency','e.datayear','e.worldzone','e.codethree','e.codetwo','e.working_days','e.presenteeism','e.medical_turnovers','e.sick_leave','e.healthcare','e.productivity_losses','e.publicname','e.publicemail','e.publicnumber','e.publicaddress','e.percentmale','e.percentfemale','e.causesrisks','e.maledeath','e.femaledeath','e.maleyld','e.femaleyld','e.access'),
|
||||
array('country_id','country_name','country_alias','country_user','country_currency','country_datayear','country_worldzone','country_codethree','country_codetwo','country_working_days','country_presenteeism','country_medical_turnovers','country_sick_leave','country_healthcare','country_productivity_losses','country_publicname','country_publicemail','country_publicnumber','country_publicaddress','country_percentmale','country_percentfemale','country_causesrisks','country_maledeath','country_femaledeath','country_maleyld','country_femaleyld','country_access')));
|
||||
$query->join('LEFT', ($db->quoteName('#__costbenefitprojection_country', 'e')) . ' ON (' . $db->quoteName('a.country') . ' = ' . $db->quoteName('e.id') . ')');
|
||||
|
||||
// Get from #__costbenefitprojection_currency as f
|
||||
$query->select($db->quoteName(
|
||||
array('f.id','f.name','f.alias','f.codethree','f.numericcode','f.symbol','f.thousands','f.decimalplace','f.decimalsymbol','f.positivestyle','f.negativestyle','f.published','f.access','f.ordering'),
|
||||
array('currency_id','currency_name','currency_alias','currency_codethree','currency_numericcode','currency_symbol','currency_thousands','currency_decimalplace','currency_decimalsymbol','currency_positivestyle','currency_negativestyle','currency_published','currency_access','currency_ordering')));
|
||||
$query->join('LEFT', ($db->quoteName('#__costbenefitprojection_currency', 'f')) . ' ON (' . $db->quoteName('e.currency') . ' = ' . $db->quoteName('f.codethree') . ')');
|
||||
$query->where('a.id = ' . (int) $pk);
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
// Load the results as a stdClass object.
|
||||
$data = $db->loadObject();
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
// If no data is found redirect to default page and show warning.
|
||||
JError::raiseWarning(500, JText::_('COM_COSTBENEFITPROJECTION_NOT_FOUND_OR_ACCESS_DENIED'));
|
||||
JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection&view=cpanel');
|
||||
return false;
|
||||
}
|
||||
if (!empty($data->medical_turnovers_females) && $advancedkey && !is_numeric($data->medical_turnovers_females) && $data->medical_turnovers_females === base64_encode(base64_decode($data->medical_turnovers_females, true)))
|
||||
{
|
||||
// Decode medical_turnovers_females
|
||||
$data->medical_turnovers_females = rtrim($advanced->decryptString($data->medical_turnovers_females), "\0");
|
||||
}
|
||||
if (!empty($data->females) && $advancedkey && !is_numeric($data->females) && $data->females === base64_encode(base64_decode($data->females, true)))
|
||||
{
|
||||
// Decode females
|
||||
$data->females = rtrim($advanced->decryptString($data->females), "\0");
|
||||
}
|
||||
if (!empty($data->sick_leave_males) && $advancedkey && !is_numeric($data->sick_leave_males) && $data->sick_leave_males === base64_encode(base64_decode($data->sick_leave_males, true)))
|
||||
{
|
||||
// Decode sick_leave_males
|
||||
$data->sick_leave_males = rtrim($advanced->decryptString($data->sick_leave_males), "\0");
|
||||
}
|
||||
if (CostbenefitprojectionHelper::checkString($data->causesrisks))
|
||||
{
|
||||
// Decode causesrisks
|
||||
$data->causesrisks = json_decode($data->causesrisks, true);
|
||||
}
|
||||
if (!empty($data->medical_turnovers_males) && $advancedkey && !is_numeric($data->medical_turnovers_males) && $data->medical_turnovers_males === base64_encode(base64_decode($data->medical_turnovers_males, true)))
|
||||
{
|
||||
// Decode medical_turnovers_males
|
||||
$data->medical_turnovers_males = rtrim($advanced->decryptString($data->medical_turnovers_males), "\0");
|
||||
}
|
||||
if (!empty($data->total_salary) && $advancedkey && !is_numeric($data->total_salary) && $data->total_salary === base64_encode(base64_decode($data->total_salary, true)))
|
||||
{
|
||||
// Decode total_salary
|
||||
$data->total_salary = rtrim($advanced->decryptString($data->total_salary), "\0");
|
||||
}
|
||||
if (!empty($data->sick_leave_females) && $advancedkey && !is_numeric($data->sick_leave_females) && $data->sick_leave_females === base64_encode(base64_decode($data->sick_leave_females, true)))
|
||||
{
|
||||
// Decode sick_leave_females
|
||||
$data->sick_leave_females = rtrim($advanced->decryptString($data->sick_leave_females), "\0");
|
||||
}
|
||||
if (!empty($data->total_healthcare) && $advancedkey && !is_numeric($data->total_healthcare) && $data->total_healthcare === base64_encode(base64_decode($data->total_healthcare, true)))
|
||||
{
|
||||
// Decode total_healthcare
|
||||
$data->total_healthcare = rtrim($advanced->decryptString($data->total_healthcare), "\0");
|
||||
}
|
||||
if (!empty($data->males) && $advancedkey && !is_numeric($data->males) && $data->males === base64_encode(base64_decode($data->males, true)))
|
||||
{
|
||||
// Decode males
|
||||
$data->males = rtrim($advanced->decryptString($data->males), "\0");
|
||||
}
|
||||
if (CostbenefitprojectionHelper::checkString($data->country_causesrisks))
|
||||
{
|
||||
// Decode country_causesrisks
|
||||
$data->country_causesrisks = json_decode($data->country_causesrisks, true);
|
||||
}
|
||||
// Make sure the content prepare plugins fire on country_publicaddress.
|
||||
$data->country_publicaddress = JHtml::_('content.prepare',$data->country_publicaddress);
|
||||
// Checking if country_publicaddress has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($data->country_publicaddress,$this->uikitComp);
|
||||
// set the global causesrisks value.
|
||||
$this->a_causesrisks = $data->causesrisks;
|
||||
// set the global datayear value.
|
||||
$this->a_datayear = $data->datayear;
|
||||
// set the global datayear value.
|
||||
$this->e_datayear = $data->country_datayear;
|
||||
// set the global causesrisks value.
|
||||
$this->e_causesrisks = $data->country_causesrisks;
|
||||
// set countryCountryHealth_dataB to the $data object.
|
||||
$data->countryCountryHealth_dataB = $this->getCountryCountryHealth_dataEbbe_B($data->country);
|
||||
// set idCompanyScaling_factorC to the $data object.
|
||||
$data->idCompanyScaling_factorC = $this->getIdCompanyScaling_factorEbbe_C($data->id);
|
||||
// set idCompanyInterventionD to the $data object.
|
||||
$data->idCompanyInterventionD = $this->getIdCompanyInterventionEbbe_D($data->id);
|
||||
// set causesrisksIdCauseriskG to the $data object.
|
||||
$data->causesrisksIdCauseriskG = $this->getCausesrisksIdCauseriskEbbe_G($data->causesrisks);
|
||||
// set countryCountryHealth_dataBB to the $data object.
|
||||
$data->countryCountryHealth_dataBB = $this->getCountryCountryHealth_dataEbbe_BB($data->country);
|
||||
// set causesrisksIdCauseriskGG to the $data object.
|
||||
$data->causesrisksIdCauseriskGG = $this->getCausesrisksIdCauseriskEbbe_GG($data->country_causesrisks);
|
||||
// set countryCountryInterventionDD to the $data object.
|
||||
$data->countryCountryInterventionDD = $this->getCountryCountryInterventionEbbe_DD($data->country);
|
||||
|
||||
// set data object to item.
|
||||
$this->_item[$pk] = $data;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
if ($e->getCode() == 404)
|
||||
{
|
||||
// Need to go thru the error handler to allow Redirect to work.
|
||||
JError::raiseError(404, $e->getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError($e);
|
||||
$this->_item[$pk] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->_item[$pk];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Health_data Objects.
|
||||
*
|
||||
* @return mixed An array of Health_data Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCountryCountryHealth_dataEbbe_B($country)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_health_data as b
|
||||
$query->select($db->quoteName(
|
||||
array('b.id','b.causerisk','b.year','b.maledeath','b.maleyld','b.femaledeath','b.femaleyld','b.published'),
|
||||
array('id','causerisk','year','maledeath','maleyld','femaledeath','femaleyld','published')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_health_data', 'b'));
|
||||
$query->where('b.country = ' . $db->quote($country));
|
||||
// Check if $this->a_causesrisks is an array with values.
|
||||
$array = $this->a_causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('b.causerisk IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$query->where('b.published = 1');
|
||||
$query->where('b.year = ' . $db->quote($this->a_datayear));
|
||||
$query->order('b.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Scaling_factor Objects.
|
||||
*
|
||||
* @return mixed An array of Scaling_factor Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getIdCompanyScaling_factorEbbe_C($id)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_scaling_factor as c
|
||||
$query->select($db->quoteName(
|
||||
array('c.id','c.causerisk','c.reference','c.yld_scaling_factor_males','c.yld_scaling_factor_females','c.mortality_scaling_factor_males','c.mortality_scaling_factor_females','c.presenteeism_scaling_factor_males','c.presenteeism_scaling_factor_females','c.health_scaling_factor','c.published'),
|
||||
array('id','causerisk','reference','yld_scaling_factor_males','yld_scaling_factor_females','mortality_scaling_factor_males','mortality_scaling_factor_females','presenteeism_scaling_factor_males','presenteeism_scaling_factor_females','health_scaling_factor','published')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_scaling_factor', 'c'));
|
||||
$query->where('c.company = ' . $db->quote($id));
|
||||
$query->where('c.published = 1');
|
||||
$query->order('c.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Make sure the content prepare plugins fire on reference.
|
||||
$item->reference = JHtml::_('content.prepare',$item->reference);
|
||||
// Checking if reference has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->reference,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Intervention Objects.
|
||||
*
|
||||
* @return mixed An array of Intervention Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getIdCompanyInterventionEbbe_D($id)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_intervention as d
|
||||
$query->select($db->quoteName(
|
||||
array('d.id','d.name','d.type','d.coverage','d.duration','d.share','d.description','d.reference','d.intervention','d.published','d.created_by','d.modified_by','d.created','d.modified'),
|
||||
array('id','name','type','coverage','duration','share','description','reference','intervention','published','created_by','modified_by','created','modified')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_intervention', 'd'));
|
||||
$query->where('d.company = ' . $db->quote($id));
|
||||
$query->where('d.published = 1');
|
||||
$query->order('d.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Make sure the content prepare plugins fire on reference.
|
||||
$item->reference = JHtml::_('content.prepare',$item->reference);
|
||||
// Checking if reference has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->reference,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Causerisk Objects.
|
||||
*
|
||||
* @return mixed An array of Causerisk Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCausesrisksIdCauseriskEbbe_G($causesrisks)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_causerisk as g
|
||||
$query->select($db->quoteName(
|
||||
array('g.id','g.name','g.ref','g.alias','g.description'),
|
||||
array('id','name','ref','alias','description')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_causerisk', 'g'));
|
||||
|
||||
// Check if $causesrisks is an array with values.
|
||||
$array = $causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('g.id IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Health_data Objects.
|
||||
*
|
||||
* @return mixed An array of Health_data Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCountryCountryHealth_dataEbbe_BB($country)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_health_data as bb
|
||||
$query->select($db->quoteName(
|
||||
array('bb.id','bb.asset_id','bb.causerisk','bb.year','bb.country','bb.maledeath','bb.maleyld','bb.femaledeath','bb.femaleyld','bb.published','bb.created_by','bb.modified_by','bb.created','bb.modified','bb.version','bb.hits','bb.ordering'),
|
||||
array('id','asset_id','causerisk','year','country','maledeath','maleyld','femaledeath','femaleyld','published','created_by','modified_by','created','modified','version','hits','ordering')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_health_data', 'bb'));
|
||||
$query->where('bb.country = ' . $db->quote($country));
|
||||
// Check if $this->e_causesrisks is an array with values.
|
||||
$array = $this->e_causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('bb.causerisk IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$query->where('bb.published = 1');
|
||||
$query->where('bb.year = ' . $db->quote($this->e_datayear));
|
||||
$query->order('bb.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Causerisk Objects.
|
||||
*
|
||||
* @return mixed An array of Causerisk Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCausesrisksIdCauseriskEbbe_GG($causesrisks)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_causerisk as gg
|
||||
$query->select($db->quoteName(
|
||||
array('gg.id','gg.name','gg.ref','gg.alias','gg.description'),
|
||||
array('id','name','ref','alias','description')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_causerisk', 'gg'));
|
||||
|
||||
// Check if $causesrisks is an array with values.
|
||||
$array = $causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('gg.id IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Make sure the content prepare plugins fire on description.
|
||||
$item->description = JHtml::_('content.prepare',$item->description);
|
||||
// Checking if description has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->description,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Intervention Objects.
|
||||
*
|
||||
* @return mixed An array of Intervention Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCountryCountryInterventionEbbe_DD($country)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_intervention as dd
|
||||
$query->select($db->quoteName(
|
||||
array('dd.id','dd.name','dd.type','dd.coverage','dd.duration','dd.share','dd.description','dd.reference','dd.intervention','dd.published','dd.created_by','dd.modified_by','dd.created','dd.modified'),
|
||||
array('id','name','type','coverage','duration','share','description','reference','intervention','published','created_by','modified_by','created','modified')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_intervention', 'dd'));
|
||||
$query->where('dd.country = ' . $db->quote($country));
|
||||
$query->where('dd.published = 1');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Make sure the content prepare plugins fire on description.
|
||||
$item->description = JHtml::_('content.prepare',$item->description);
|
||||
// Checking if description has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->description,$this->uikitComp);
|
||||
// Make sure the content prepare plugins fire on reference.
|
||||
$item->reference = JHtml::_('content.prepare',$item->reference);
|
||||
// Checking if reference has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->reference,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the uikit needed components
|
||||
*
|
||||
* @return mixed An array of objects on success.
|
||||
*
|
||||
*/
|
||||
public function getUikitComp()
|
||||
{
|
||||
if (isset($this->uikitComp) && CostbenefitprojectionHelper::checkArray($this->uikitComp))
|
||||
{
|
||||
return $this->uikitComp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage cpanel.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import the Joomla modellist library
|
||||
jimport('joomla.application.component.modellist');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Model for Cpanel
|
||||
*/
|
||||
class CostbenefitprojectionModelCpanel extends JModelList
|
||||
{
|
||||
/**
|
||||
* Model user data.
|
||||
*
|
||||
* @var strings
|
||||
*/
|
||||
protected $user;
|
||||
protected $userId;
|
||||
protected $guest;
|
||||
protected $groups;
|
||||
protected $levels;
|
||||
protected $app;
|
||||
protected $input;
|
||||
protected $uikitComp;
|
||||
|
||||
/**
|
||||
* Method to build an SQL query to load the list data.
|
||||
*
|
||||
* @return string An SQL query
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
// Get the current user for authorisation checks
|
||||
$this->user = JFactory::getUser();
|
||||
$this->userId = $this->user->get('id');
|
||||
$this->guest = $this->user->get('guest');
|
||||
$this->groups = $this->user->get('groups');
|
||||
$this->authorisedGroups = $this->user->getAuthorisedGroups();
|
||||
$this->levels = $this->user->getAuthorisedViewLevels();
|
||||
$this->app = JFactory::getApplication();
|
||||
$this->input = $this->app->input;
|
||||
$this->initSet = true;
|
||||
// Make sure all records load, since no pagination allowed.
|
||||
$this->setState('list.limit', 0);
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_company as a
|
||||
$query->select($db->quoteName(
|
||||
array('a.id','a.asset_id','a.name','a.user','a.department','a.per','a.email','a.country','a.service_provider','a.datayear','a.working_days','a.total_salary','a.total_healthcare','a.productivity_losses','a.males','a.females','a.medical_turnovers_males','a.medical_turnovers_females','a.sick_leave_males','a.sick_leave_females','a.percentmale','a.percentfemale','a.causesrisks','a.not_required','a.published','a.checked_out','a.checked_out_time','a.created_by','a.modified_by','a.created','a.modified','a.version','a.hits','a.ordering'),
|
||||
array('id','asset_id','name','user','department','per','email','country','service_provider','datayear','working_days','total_salary','total_healthcare','productivity_losses','males','females','medical_turnovers_males','medical_turnovers_females','sick_leave_males','sick_leave_females','percentmale','percentfemale','causesrisks','not_required','published','checked_out','checked_out_time','created_by','modified_by','created','modified','version','hits','ordering')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_company', 'a'));
|
||||
|
||||
// Get from #__costbenefitprojection_country as b
|
||||
$query->select($db->quoteName(
|
||||
array('b.name','b.user','b.publicname','b.publicemail','b.publicnumber','b.publicaddress'),
|
||||
array('country_name','country_user','country_publicname','country_publicemail','country_publicnumber','country_publicaddress')));
|
||||
$query->join('LEFT', ($db->quoteName('#__costbenefitprojection_country', 'b')) . ' ON (' . $db->quoteName('a.country') . ' = ' . $db->quoteName('b.id') . ')');
|
||||
|
||||
// Get from #__costbenefitprojection_service_provider as c
|
||||
$query->select($db->quoteName(
|
||||
array('c.user','c.publicname','c.publicemail','c.publicnumber','c.publicaddress'),
|
||||
array('service_provider_user','service_provider_publicname','service_provider_publicemail','service_provider_publicnumber','service_provider_publicaddress')));
|
||||
$query->join('LEFT', ($db->quoteName('#__costbenefitprojection_service_provider', 'c')) . ' ON (' . $db->quoteName('a.service_provider') . ' = ' . $db->quoteName('c.id') . ')');
|
||||
|
||||
// Get from #__costbenefitprojection_currency as g
|
||||
$query->select($db->quoteName(
|
||||
array('g.id','g.name','g.codethree','g.numericcode','g.symbol','g.thousands','g.decimalplace','g.decimalsymbol','g.positivestyle','g.negativestyle'),
|
||||
array('currency_id','currency_name','currency_codethree','currency_numericcode','currency_symbol','currency_thousands','currency_decimalplace','currency_decimalsymbol','currency_positivestyle','currency_negativestyle')));
|
||||
$query->join('LEFT', ($db->quoteName('#__costbenefitprojection_currency', 'g')) . ' ON (' . $db->quoteName('b.currency') . ' = ' . $db->quoteName('g.codethree') . ')');
|
||||
|
||||
// Get from #__users as d
|
||||
$query->select($db->quoteName(
|
||||
array('d.name'),
|
||||
array('service_provider_name')));
|
||||
$query->join('LEFT', ($db->quoteName('#__users', 'd')) . ' ON (' . $db->quoteName('c.id') . ' = ' . $db->quoteName('d.id') . ')');
|
||||
$query->where('a.user = ' . (int) $this->userId);
|
||||
$query->order('a.ordering ASC');
|
||||
|
||||
// return the query object
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of data items.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
// check if this user has permission to access items
|
||||
if (!$user->authorise('site.cpanel.access', 'com_costbenefitprojection'))
|
||||
{
|
||||
JError::raiseWarning(500, JText::_('Not authorised!'));
|
||||
// redirect away if not a correct (TODO for now we go to default view)
|
||||
JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_costbenefitprojection&view=cpanel'));
|
||||
return false;
|
||||
}
|
||||
// load parent items
|
||||
$items = parent::getItems();
|
||||
|
||||
// Get the global params
|
||||
$globalParams = JComponentHelper::getParams('com_costbenefitprojection', true);
|
||||
|
||||
// Get the advanced encription.
|
||||
$advancedkey = CostbenefitprojectionHelper::getCryptKey('advanced');
|
||||
// Get the encription object.
|
||||
$advanced = new FOFEncryptAes($advancedkey, 256);
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Always create a slug for sef URL's
|
||||
$item->slug = (isset($item->alias)) ? $item->id.':'.$item->alias : $item->id;
|
||||
if (!empty($item->medical_turnovers_females) && $advancedkey && !is_numeric($item->medical_turnovers_females) && $item->medical_turnovers_females === base64_encode(base64_decode($item->medical_turnovers_females, true)))
|
||||
{
|
||||
// Decode medical_turnovers_females
|
||||
$item->medical_turnovers_females = rtrim($advanced->decryptString($item->medical_turnovers_females), "\0");
|
||||
}
|
||||
if (!empty($item->females) && $advancedkey && !is_numeric($item->females) && $item->females === base64_encode(base64_decode($item->females, true)))
|
||||
{
|
||||
// Decode females
|
||||
$item->females = rtrim($advanced->decryptString($item->females), "\0");
|
||||
}
|
||||
if (!empty($item->sick_leave_males) && $advancedkey && !is_numeric($item->sick_leave_males) && $item->sick_leave_males === base64_encode(base64_decode($item->sick_leave_males, true)))
|
||||
{
|
||||
// Decode sick_leave_males
|
||||
$item->sick_leave_males = rtrim($advanced->decryptString($item->sick_leave_males), "\0");
|
||||
}
|
||||
if (CostbenefitprojectionHelper::checkString($item->causesrisks))
|
||||
{
|
||||
// Decode causesrisks
|
||||
$item->causesrisks = json_decode($item->causesrisks, true);
|
||||
}
|
||||
if (!empty($item->medical_turnovers_males) && $advancedkey && !is_numeric($item->medical_turnovers_males) && $item->medical_turnovers_males === base64_encode(base64_decode($item->medical_turnovers_males, true)))
|
||||
{
|
||||
// Decode medical_turnovers_males
|
||||
$item->medical_turnovers_males = rtrim($advanced->decryptString($item->medical_turnovers_males), "\0");
|
||||
}
|
||||
if (!empty($item->total_salary) && $advancedkey && !is_numeric($item->total_salary) && $item->total_salary === base64_encode(base64_decode($item->total_salary, true)))
|
||||
{
|
||||
// Decode total_salary
|
||||
$item->total_salary = rtrim($advanced->decryptString($item->total_salary), "\0");
|
||||
}
|
||||
if (!empty($item->sick_leave_females) && $advancedkey && !is_numeric($item->sick_leave_females) && $item->sick_leave_females === base64_encode(base64_decode($item->sick_leave_females, true)))
|
||||
{
|
||||
// Decode sick_leave_females
|
||||
$item->sick_leave_females = rtrim($advanced->decryptString($item->sick_leave_females), "\0");
|
||||
}
|
||||
if (!empty($item->total_healthcare) && $advancedkey && !is_numeric($item->total_healthcare) && $item->total_healthcare === base64_encode(base64_decode($item->total_healthcare, true)))
|
||||
{
|
||||
// Decode total_healthcare
|
||||
$item->total_healthcare = rtrim($advanced->decryptString($item->total_healthcare), "\0");
|
||||
}
|
||||
if (!empty($item->males) && $advancedkey && !is_numeric($item->males) && $item->males === base64_encode(base64_decode($item->males, true)))
|
||||
{
|
||||
// Decode males
|
||||
$item->males = rtrim($advanced->decryptString($item->males), "\0");
|
||||
}
|
||||
// Make sure the content prepare plugins fire on country_publicaddress.
|
||||
$item->country_publicaddress = JHtml::_('content.prepare',$item->country_publicaddress);
|
||||
// Checking if country_publicaddress has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->country_publicaddress,$this->uikitComp);
|
||||
// Make sure the content prepare plugins fire on service_provider_publicaddress.
|
||||
$item->service_provider_publicaddress = JHtml::_('content.prepare',$item->service_provider_publicaddress);
|
||||
// Checking if service_provider_publicaddress has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->service_provider_publicaddress,$this->uikitComp);
|
||||
// set idCompanyScaling_factorD to the $item object.
|
||||
$item->idCompanyScaling_factorD = $this->getIdCompanyScaling_factorBdef_D($item->id);
|
||||
// set idCompanyInterventionE to the $item object.
|
||||
$item->idCompanyInterventionE = $this->getIdCompanyInterventionBdef_E($item->id);
|
||||
}
|
||||
|
||||
// return items
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Scaling_factor Objects.
|
||||
*
|
||||
* @return mixed An array of Scaling_factor Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getIdCompanyScaling_factorBdef_D($id)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_scaling_factor as d
|
||||
$query->select($db->quoteName(
|
||||
array('d.id','d.asset_id','d.company','d.causerisk','d.reference','d.yld_scaling_factor_males','d.yld_scaling_factor_females','d.mortality_scaling_factor_males','d.mortality_scaling_factor_females','d.presenteeism_scaling_factor_males','d.presenteeism_scaling_factor_females','d.published','d.checked_out','d.checked_out_time','d.created_by','d.modified_by','d.created','d.modified','d.version','d.hits','d.ordering'),
|
||||
array('id','asset_id','company','causerisk','reference','yld_scaling_factor_males','yld_scaling_factor_females','mortality_scaling_factor_males','mortality_scaling_factor_females','presenteeism_scaling_factor_males','presenteeism_scaling_factor_females','published','checked_out','checked_out_time','created_by','modified_by','created','modified','version','hits','ordering')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_scaling_factor', 'd'));
|
||||
$query->where('d.company = ' . $db->quote($id));
|
||||
|
||||
// Get from #__costbenefitprojection_causerisk as f
|
||||
$query->select($db->quoteName(
|
||||
array('f.name'),
|
||||
array('causerisk_name')));
|
||||
$query->join('LEFT', ($db->quoteName('#__costbenefitprojection_causerisk', 'f')) . ' ON (' . $db->quoteName('d.causerisk') . ' = ' . $db->quoteName('f.id') . ')');
|
||||
$query->order('d.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Make sure the content prepare plugins fire on reference.
|
||||
$item->reference = JHtml::_('content.prepare',$item->reference);
|
||||
// Checking if reference has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->reference,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Intervention Objects.
|
||||
*
|
||||
* @return mixed An array of Intervention Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getIdCompanyInterventionBdef_E($id)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_intervention as e
|
||||
$query->select($db->quoteName(
|
||||
array('e.id','e.name','e.type','e.coverage','e.duration','e.share','e.description','e.reference','e.interventions','e.intervention','e.not_required','e.published','e.checked_out','e.checked_out_time','e.created_by','e.modified_by','e.created','e.modified','e.version','e.hits','e.ordering'),
|
||||
array('id','name','type','coverage','duration','share','description','reference','interventions','intervention','not_required','published','checked_out','checked_out_time','created_by','modified_by','created','modified','version','hits','ordering')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_intervention', 'e'));
|
||||
$query->where('e.company = ' . $db->quote($id));
|
||||
$query->order('e.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkString($item->interventions))
|
||||
{
|
||||
// Decode interventions
|
||||
$item->interventions = json_decode($item->interventions, true);
|
||||
}
|
||||
// Make sure the content prepare plugins fire on description.
|
||||
$item->description = JHtml::_('content.prepare',$item->description);
|
||||
// Checking if description has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->description,$this->uikitComp);
|
||||
// Make sure the content prepare plugins fire on reference.
|
||||
$item->reference = JHtml::_('content.prepare',$item->reference);
|
||||
// Checking if reference has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->reference,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the uikit needed components
|
||||
*
|
||||
* @return mixed An array of objects on success.
|
||||
*
|
||||
*/
|
||||
public function getUikitComp()
|
||||
{
|
||||
if (isset($this->uikitComp) && CostbenefitprojectionHelper::checkArray($this->uikitComp))
|
||||
{
|
||||
return $this->uikitComp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage createaccount.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import the Joomla modellist library
|
||||
jimport('joomla.application.component.modellist');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Model for Createaccount
|
||||
*/
|
||||
class CostbenefitprojectionModelCreateaccount extends JModelList
|
||||
{
|
||||
/**
|
||||
* Model user data.
|
||||
*
|
||||
* @var strings
|
||||
*/
|
||||
protected $user;
|
||||
protected $userId;
|
||||
protected $guest;
|
||||
protected $groups;
|
||||
protected $levels;
|
||||
protected $app;
|
||||
protected $input;
|
||||
protected $uikitComp;
|
||||
|
||||
/**
|
||||
* Method to build an SQL query to load the list data.
|
||||
*
|
||||
* @return string An SQL query
|
||||
*/
|
||||
protected function getListQuery()
|
||||
{
|
||||
// Get the current user for authorisation checks
|
||||
$this->user = JFactory::getUser();
|
||||
$this->userId = $this->user->get('id');
|
||||
$this->guest = $this->user->get('guest');
|
||||
$this->groups = $this->user->get('groups');
|
||||
$this->authorisedGroups = $this->user->getAuthorisedGroups();
|
||||
$this->levels = $this->user->getAuthorisedViewLevels();
|
||||
$this->app = JFactory::getApplication();
|
||||
$this->input = $this->app->input;
|
||||
$this->initSet = true;
|
||||
// Make sure all records load, since no pagination allowed.
|
||||
$this->setState('list.limit', 0);
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_country as a
|
||||
$query->select($db->quoteName(
|
||||
array('a.id','a.user','a.name','a.publicname','a.publicemail','a.publicnumber','a.publicaddress'),
|
||||
array('id','user','name','publicname','publicemail','publicnumber','publicaddress')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_country', 'a'));
|
||||
$query->where('CHAR_LENGTH(a.causesrisks) > 5');
|
||||
$query->where('CHAR_LENGTH(a.percentfemale) > 5');
|
||||
$query->where('CHAR_LENGTH(a.percentmale) > 5');
|
||||
$query->where('CHAR_LENGTH(a.datayear) > 3');
|
||||
$query->where('CHAR_LENGTH(a.productivity_losses) > 0');
|
||||
$query->where('CHAR_LENGTH(a.sick_leave) > 0');
|
||||
$query->where('CHAR_LENGTH(a.medical_turnovers) > 0');
|
||||
$query->where('a.published = 1');
|
||||
$query->order('a.name ASC');
|
||||
|
||||
// return the query object
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of data items.
|
||||
*
|
||||
* @return mixed An array of data items on success, false on failure.
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
// check if this user has permission to access items
|
||||
if (!$user->authorise('site.createaccount.access', 'com_costbenefitprojection'))
|
||||
{
|
||||
JError::raiseWarning(500, JText::_('Not authorised!'));
|
||||
// redirect away if not a correct (TODO for now we go to default view)
|
||||
JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_costbenefitprojection&view=cpanel'));
|
||||
return false;
|
||||
}
|
||||
// load parent items
|
||||
$items = parent::getItems();
|
||||
|
||||
// Get the global params
|
||||
$globalParams = JComponentHelper::getParams('com_costbenefitprojection', true);
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Always create a slug for sef URL's
|
||||
$item->slug = (isset($item->alias)) ? $item->id.':'.$item->alias : $item->id;
|
||||
// Make sure the content prepare plugins fire on publicaddress.
|
||||
$item->publicaddress = JHtml::_('content.prepare',$item->publicaddress);
|
||||
// Checking if publicaddress has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->publicaddress,$this->uikitComp);
|
||||
// set idCountryService_providerB to the $item object.
|
||||
$item->idCountryService_providerB = $this->getIdCountryService_providerCace_B($item->id);
|
||||
}
|
||||
|
||||
// return items
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Service_provider Objects.
|
||||
*
|
||||
* @return mixed An array of Service_provider Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getIdCountryService_providerCace_B($id)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_service_provider as b
|
||||
$query->select($db->quoteName(
|
||||
array('b.id','b.user','b.publicname','b.publicemail','b.publicnumber','b.publicaddress'),
|
||||
array('id','user','publicname','publicemail','publicnumber','publicaddress')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_service_provider', 'b'));
|
||||
$query->where('b.country = ' . $db->quote($id));
|
||||
$query->where('b.published = 1');
|
||||
$query->order('b.publicname ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Make sure the content prepare plugins fire on publicaddress.
|
||||
$item->publicaddress = JHtml::_('content.prepare',$item->publicaddress);
|
||||
// Checking if publicaddress has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->publicaddress,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the uikit needed components
|
||||
*
|
||||
* @return mixed An array of objects on success.
|
||||
*
|
||||
*/
|
||||
public function getUikitComp()
|
||||
{
|
||||
if (isset($this->uikitComp) && CostbenefitprojectionHelper::checkArray($this->uikitComp))
|
||||
{
|
||||
return $this->uikitComp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,338 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage company.js
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
// Some Global Values
|
||||
jform_vvvvvvvvvv_required = false;
|
||||
jform_vvvvvvvvvw_required = false;
|
||||
jform_vvvvvvvvvx_required = false;
|
||||
jform_vvvvvvvvvy_required = false;
|
||||
jform_vvvvvvvvvz_required = false;
|
||||
jform_vvvvvvvvwa_required = false;
|
||||
jform_vvvvvvvvwb_required = false;
|
||||
|
||||
// Initial Script
|
||||
jQuery(document).ready(function()
|
||||
{
|
||||
var department_vvvvvvv = jQuery("#jform_department input[type='radio']:checked").val();
|
||||
vvvvvvv(department_vvvvvvv);
|
||||
|
||||
var department_vvvvvvw = jQuery("#jform_department input[type='radio']:checked").val();
|
||||
vvvvvvw(department_vvvvvvw);
|
||||
});
|
||||
|
||||
// the vvvvvvv function
|
||||
function vvvvvvv(department_vvvvvvv)
|
||||
{
|
||||
// set the function logic
|
||||
if (department_vvvvvvv == 2)
|
||||
{
|
||||
jQuery('#jform_causesrisks').closest('.control-group').show();
|
||||
if (jform_vvvvvvvvvv_required)
|
||||
{
|
||||
updateFieldRequired('causesrisks',0);
|
||||
jQuery('#jform_causesrisks').prop('required','required');
|
||||
jQuery('#jform_causesrisks').attr('aria-required',true);
|
||||
jQuery('#jform_causesrisks').addClass('required');
|
||||
jform_vvvvvvvvvv_required = false;
|
||||
}
|
||||
|
||||
jQuery('#jform_percentfemale').closest('.control-group').show();
|
||||
jQuery('#jform_percentmale').closest('.control-group').show();
|
||||
jQuery('#jform_productivity_losses').closest('.control-group').show();
|
||||
if (jform_vvvvvvvvvw_required)
|
||||
{
|
||||
updateFieldRequired('productivity_losses',0);
|
||||
jQuery('#jform_productivity_losses').prop('required','required');
|
||||
jQuery('#jform_productivity_losses').attr('aria-required',true);
|
||||
jQuery('#jform_productivity_losses').addClass('required');
|
||||
jform_vvvvvvvvvw_required = false;
|
||||
}
|
||||
|
||||
jQuery('#jform_medical_turnovers_females').closest('.control-group').show();
|
||||
if (jform_vvvvvvvvvx_required)
|
||||
{
|
||||
updateFieldRequired('medical_turnovers_females',0);
|
||||
jQuery('#jform_medical_turnovers_females').prop('required','required');
|
||||
jQuery('#jform_medical_turnovers_females').attr('aria-required',true);
|
||||
jQuery('#jform_medical_turnovers_females').addClass('required');
|
||||
jform_vvvvvvvvvx_required = false;
|
||||
}
|
||||
|
||||
jQuery('#jform_medical_turnovers_males').closest('.control-group').show();
|
||||
if (jform_vvvvvvvvvy_required)
|
||||
{
|
||||
updateFieldRequired('medical_turnovers_males',0);
|
||||
jQuery('#jform_medical_turnovers_males').prop('required','required');
|
||||
jQuery('#jform_medical_turnovers_males').attr('aria-required',true);
|
||||
jQuery('#jform_medical_turnovers_males').addClass('required');
|
||||
jform_vvvvvvvvvy_required = false;
|
||||
}
|
||||
|
||||
jQuery('#jform_sick_leave_females').closest('.control-group').show();
|
||||
if (jform_vvvvvvvvvz_required)
|
||||
{
|
||||
updateFieldRequired('sick_leave_females',0);
|
||||
jQuery('#jform_sick_leave_females').prop('required','required');
|
||||
jQuery('#jform_sick_leave_females').attr('aria-required',true);
|
||||
jQuery('#jform_sick_leave_females').addClass('required');
|
||||
jform_vvvvvvvvvz_required = false;
|
||||
}
|
||||
|
||||
jQuery('#jform_sick_leave_males').closest('.control-group').show();
|
||||
if (jform_vvvvvvvvwa_required)
|
||||
{
|
||||
updateFieldRequired('sick_leave_males',0);
|
||||
jQuery('#jform_sick_leave_males').prop('required','required');
|
||||
jQuery('#jform_sick_leave_males').attr('aria-required',true);
|
||||
jQuery('#jform_sick_leave_males').addClass('required');
|
||||
jform_vvvvvvvvwa_required = false;
|
||||
}
|
||||
|
||||
jQuery('#jform_total_healthcare').closest('.control-group').show();
|
||||
if (jform_vvvvvvvvwb_required)
|
||||
{
|
||||
updateFieldRequired('total_healthcare',0);
|
||||
jQuery('#jform_total_healthcare').prop('required','required');
|
||||
jQuery('#jform_total_healthcare').attr('aria-required',true);
|
||||
jQuery('#jform_total_healthcare').addClass('required');
|
||||
jform_vvvvvvvvwb_required = false;
|
||||
}
|
||||
|
||||
jQuery('#jform_turnover_comment').closest('.control-group').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery('#jform_causesrisks').closest('.control-group').hide();
|
||||
if (!jform_vvvvvvvvvv_required)
|
||||
{
|
||||
updateFieldRequired('causesrisks',1);
|
||||
jQuery('#jform_causesrisks').removeAttr('required');
|
||||
jQuery('#jform_causesrisks').removeAttr('aria-required');
|
||||
jQuery('#jform_causesrisks').removeClass('required');
|
||||
jform_vvvvvvvvvv_required = true;
|
||||
}
|
||||
jQuery('#jform_percentfemale').closest('.control-group').hide();
|
||||
jQuery('#jform_percentmale').closest('.control-group').hide();
|
||||
jQuery('#jform_productivity_losses').closest('.control-group').hide();
|
||||
if (!jform_vvvvvvvvvw_required)
|
||||
{
|
||||
updateFieldRequired('productivity_losses',1);
|
||||
jQuery('#jform_productivity_losses').removeAttr('required');
|
||||
jQuery('#jform_productivity_losses').removeAttr('aria-required');
|
||||
jQuery('#jform_productivity_losses').removeClass('required');
|
||||
jform_vvvvvvvvvw_required = true;
|
||||
}
|
||||
jQuery('#jform_medical_turnovers_females').closest('.control-group').hide();
|
||||
if (!jform_vvvvvvvvvx_required)
|
||||
{
|
||||
updateFieldRequired('medical_turnovers_females',1);
|
||||
jQuery('#jform_medical_turnovers_females').removeAttr('required');
|
||||
jQuery('#jform_medical_turnovers_females').removeAttr('aria-required');
|
||||
jQuery('#jform_medical_turnovers_females').removeClass('required');
|
||||
jform_vvvvvvvvvx_required = true;
|
||||
}
|
||||
jQuery('#jform_medical_turnovers_males').closest('.control-group').hide();
|
||||
if (!jform_vvvvvvvvvy_required)
|
||||
{
|
||||
updateFieldRequired('medical_turnovers_males',1);
|
||||
jQuery('#jform_medical_turnovers_males').removeAttr('required');
|
||||
jQuery('#jform_medical_turnovers_males').removeAttr('aria-required');
|
||||
jQuery('#jform_medical_turnovers_males').removeClass('required');
|
||||
jform_vvvvvvvvvy_required = true;
|
||||
}
|
||||
jQuery('#jform_sick_leave_females').closest('.control-group').hide();
|
||||
if (!jform_vvvvvvvvvz_required)
|
||||
{
|
||||
updateFieldRequired('sick_leave_females',1);
|
||||
jQuery('#jform_sick_leave_females').removeAttr('required');
|
||||
jQuery('#jform_sick_leave_females').removeAttr('aria-required');
|
||||
jQuery('#jform_sick_leave_females').removeClass('required');
|
||||
jform_vvvvvvvvvz_required = true;
|
||||
}
|
||||
jQuery('#jform_sick_leave_males').closest('.control-group').hide();
|
||||
if (!jform_vvvvvvvvwa_required)
|
||||
{
|
||||
updateFieldRequired('sick_leave_males',1);
|
||||
jQuery('#jform_sick_leave_males').removeAttr('required');
|
||||
jQuery('#jform_sick_leave_males').removeAttr('aria-required');
|
||||
jQuery('#jform_sick_leave_males').removeClass('required');
|
||||
jform_vvvvvvvvwa_required = true;
|
||||
}
|
||||
jQuery('#jform_total_healthcare').closest('.control-group').hide();
|
||||
if (!jform_vvvvvvvvwb_required)
|
||||
{
|
||||
updateFieldRequired('total_healthcare',1);
|
||||
jQuery('#jform_total_healthcare').removeAttr('required');
|
||||
jQuery('#jform_total_healthcare').removeAttr('aria-required');
|
||||
jQuery('#jform_total_healthcare').removeClass('required');
|
||||
jform_vvvvvvvvwb_required = true;
|
||||
}
|
||||
jQuery('#jform_turnover_comment').closest('.control-group').hide();
|
||||
}
|
||||
}
|
||||
|
||||
// the vvvvvvw function
|
||||
function vvvvvvw(department_vvvvvvw)
|
||||
{
|
||||
// set the function logic
|
||||
if (department_vvvvvvw == 1)
|
||||
{
|
||||
jQuery('.age_groups_note').closest('.control-group').show();
|
||||
jQuery('.cause_risk_selection_note').closest('.control-group').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery('.age_groups_note').closest('.control-group').hide();
|
||||
jQuery('.cause_risk_selection_note').closest('.control-group').hide();
|
||||
}
|
||||
}
|
||||
|
||||
// update required fields
|
||||
function updateFieldRequired(name,status)
|
||||
{
|
||||
var not_required = jQuery('#jform_not_required').val();
|
||||
|
||||
if(status == 1)
|
||||
{
|
||||
if (isSet(not_required) && not_required != 0)
|
||||
{
|
||||
not_required = not_required+','+name;
|
||||
}
|
||||
else
|
||||
{
|
||||
not_required = ','+name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isSet(not_required) && not_required != 0)
|
||||
{
|
||||
not_required = not_required.replace(','+name,'');
|
||||
}
|
||||
}
|
||||
|
||||
jQuery('#jform_not_required').val(not_required);
|
||||
}
|
||||
|
||||
// the isSet function
|
||||
function isSet(val)
|
||||
{
|
||||
if ((val != undefined) && (val != null) && 0 !== val.length){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
jQuery(document).ready(function()
|
||||
{
|
||||
var values_a = jQuery('#jform_percentmale').val();
|
||||
if (values_a)
|
||||
{
|
||||
values_a = jQuery.parseJSON(values_a);
|
||||
buildTable(values_a,'jform_percentmale');
|
||||
}
|
||||
|
||||
var values_b = jQuery('#jform_percentfemale').val();
|
||||
if (values_b)
|
||||
{
|
||||
values_b = jQuery.parseJSON(values_b);
|
||||
buildTable(values_b,'jform_percentfemale');
|
||||
}
|
||||
});
|
||||
|
||||
function buildTable(array,id){
|
||||
jQuery('#table_'+id).remove();
|
||||
jQuery('#'+id).closest('.control-group').append('<table style="margin: 5px 0 20px;" class="table" id="table_'+id+'">');
|
||||
jQuery('#table_'+id).append(tableHeader(array));
|
||||
jQuery('#table_'+id).append(tableBody(array));
|
||||
jQuery('#table_'+id).append('</table>');
|
||||
}
|
||||
|
||||
function tableHeader(array)
|
||||
{
|
||||
var header = '<thead><tr>';
|
||||
jQuery.each(array, function(key, value) {
|
||||
header += '<th style="padding: 10px; text-align: center; border: 1px solid rgb(221, 221, 221);">'+capitalizeFirstLetter(key)+'</th>';
|
||||
});
|
||||
header += '</tr></thead>';
|
||||
return header;
|
||||
}
|
||||
|
||||
function tableBody(array)
|
||||
{
|
||||
var body = '<tbody>';
|
||||
var rows = new Array();
|
||||
jQuery.each(array, function(key, value) {
|
||||
jQuery.each(value, function(i, line) {
|
||||
if( rows[i] === undefined ) {
|
||||
rows[i] = '<td style="padding: 10px; text-align: center; border: 1px solid rgb(221, 221, 221);">' + line + '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
rows[i] = rows[i] + '<td style="padding: 10px; text-align: center; border: 1px solid rgb(221, 221, 221);">' + line + '</td>';
|
||||
}
|
||||
});
|
||||
});
|
||||
// now load to body the rows
|
||||
jQuery.each(rows, function(a, row) {
|
||||
body += '<tr>' + row + '</tr>';
|
||||
});
|
||||
|
||||
body += '</tbody>';
|
||||
|
||||
return body;
|
||||
|
||||
}
|
||||
|
||||
function capitalizeFirstLetter(string) {
|
||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
function updateSelection(row)
|
||||
{
|
||||
var groupId = jQuery(row).find("select:first").attr("id");
|
||||
var percentValue = jQuery(row).find(".text_area:first").val();
|
||||
var arr = groupId.split('-');
|
||||
if (arr[1] != 1)
|
||||
{
|
||||
var selection = {};
|
||||
jQuery(row).find("select:first option").each(function()
|
||||
{
|
||||
// first get the values and text
|
||||
selection[jQuery(this).text()] = jQuery(this).val();
|
||||
});
|
||||
jQuery.each(AgeGroup, function(i, group){
|
||||
jQuery(row).find("select:first option[value='"+group+"']").remove();
|
||||
});
|
||||
if (percentValue)
|
||||
{
|
||||
var text = jQuery(row).find(".chzn-single:first span").text();
|
||||
jQuery(row).find("select:first").append(jQuery('<option>', {
|
||||
value: selection[text],
|
||||
text: text
|
||||
}));
|
||||
}
|
||||
jQuery(row).find("select:first").trigger("liszt:updated");
|
||||
|
||||
if (percentValue)
|
||||
{
|
||||
jQuery(row).find("select:first option:selected").val(selection[text]);
|
||||
jQuery(row).find(".chzn-single:first span").text(text);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,517 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form
|
||||
addrulepath="/administrator/components/com_costbenefitprojection/models/rules"
|
||||
addfieldpath="/administrator/components/com_costbenefitprojection/models/fields"
|
||||
>
|
||||
<fieldset name="details">
|
||||
<!-- Default Fields. -->
|
||||
<!-- Id Field. Type: Text (joomla) -->
|
||||
<field
|
||||
name="id"
|
||||
type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"
|
||||
description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"
|
||||
readonly="true"
|
||||
/>
|
||||
<!-- Date Created Field. Type: Calendar (joomla) -->
|
||||
<field
|
||||
name="created"
|
||||
type="calendar"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_CREATED_DATE_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_CREATED_DATE_DESC"
|
||||
size="22"
|
||||
format="%Y-%m-%d %H:%M:%S"
|
||||
filter="user_utc"
|
||||
/>
|
||||
<!-- User Created Field. Type: User (joomla) -->
|
||||
<field
|
||||
name="created_by"
|
||||
type="user"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_CREATED_BY_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_CREATED_BY_DESC"
|
||||
/>
|
||||
<!-- Published Field. Type: List (joomla) -->
|
||||
<field name="published" type="list" label="JSTATUS"
|
||||
description="JFIELD_PUBLISHED_DESC" class="chzn-color-state"
|
||||
filter="intval" size="1" default="1" >
|
||||
<option value="1">
|
||||
JPUBLISHED</option>
|
||||
<option value="0">
|
||||
JUNPUBLISHED</option>
|
||||
<option value="2">
|
||||
JARCHIVED</option>
|
||||
<option value="-2">
|
||||
JTRASHED</option>
|
||||
</field>
|
||||
<!-- Date Modified Field. Type: Calendar (joomla) -->
|
||||
<field name="modified" type="calendar" class="readonly"
|
||||
label="JGLOBAL_FIELD_MODIFIED_LABEL" description="COM_CONTENT_FIELD_MODIFIED_DESC"
|
||||
size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
|
||||
<!-- User Modified Field. Type: User (joomla) -->
|
||||
<field name="modified_by" type="user"
|
||||
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Access Field. Type: Accesslevel (joomla) -->
|
||||
<field name="access"
|
||||
type="accesslevel"
|
||||
label="JFIELD_ACCESS_LABEL"
|
||||
description="JFIELD_ACCESS_DESC"
|
||||
default="1"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Ordering Field. Type: Numbers (joomla) -->
|
||||
<field
|
||||
name="ordering"
|
||||
type="number"
|
||||
class="inputbox validate-ordering"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_ORDERING_LABEL"
|
||||
description=""
|
||||
default="0"
|
||||
size="6"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Version Field. Type: Text (joomla) -->
|
||||
<field
|
||||
name="version"
|
||||
type="text"
|
||||
class="readonly"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_VERSION_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_VERSION_DESC"
|
||||
size="6"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Dynamic Fields. -->
|
||||
<!-- Name Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="name"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_NAME_LABEL"
|
||||
size="40"
|
||||
maxlength="150"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_NAME_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="STRING"
|
||||
message="Error! Please add company name here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_NAME_HINT"
|
||||
/>
|
||||
<!-- Email Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="email"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_EMAIL_LABEL"
|
||||
size="10"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_EMAIL_DESCRIPTION"
|
||||
class="text_area"
|
||||
required="true"
|
||||
filter="STRING"
|
||||
validate="email"
|
||||
message="Error! Please add email address here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_EMAIL_HINT"
|
||||
/>
|
||||
<!-- User Field. Type: Memberuser. (custom) -->
|
||||
<field
|
||||
type="memberuser"
|
||||
name="user"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_USER_LABEL"
|
||||
required="false"
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_USER_HINT"
|
||||
/>
|
||||
<!-- Department Field. Type: Radio. (joomla) -->
|
||||
<field
|
||||
type="radio"
|
||||
name="department"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_DEPARTMENT_LABEL"
|
||||
class="btn-group"
|
||||
default="1"
|
||||
required="true">
|
||||
<!-- Option Set. -->
|
||||
<option value="1">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_BASIC</option>
|
||||
<option value="2">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_ADVANCED</option>
|
||||
</field>
|
||||
<!-- Country Field. Type: Countries. (custom) -->
|
||||
<field
|
||||
type="countries"
|
||||
name="country"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_COUNTRY_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_COUNTRY_DESCRIPTION"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
default="0"
|
||||
required="true"
|
||||
/>
|
||||
<!-- Service_provider Field. Type: Serviceprovider. (custom) -->
|
||||
<field
|
||||
type="serviceprovider"
|
||||
name="service_provider"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_SERVICE_PROVIDER_LABEL"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
default="0"
|
||||
required="true"
|
||||
button="true"
|
||||
/>
|
||||
<!-- Per Field. Type: Radio. (joomla) -->
|
||||
<field
|
||||
type="radio"
|
||||
name="per"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_PER_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_PER_DESCRIPTION"
|
||||
class="btn-group btn-group-yesno"
|
||||
default="1"
|
||||
required="true">
|
||||
<!-- Option Set. -->
|
||||
<option value="1">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_OPEN</option>
|
||||
<option value="0">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_LOCKED</option>
|
||||
</field>
|
||||
<!-- Percentfemale Field. Type: Repeatable. (joomla) -->
|
||||
<field
|
||||
type="repeatable"
|
||||
name="percentfemale"
|
||||
label="Set Females Age Groups Percent"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_PERCENTFEMALE_DESCRIPTION"
|
||||
id="percentfemale"
|
||||
class="percentfemales"
|
||||
select="COM_COSTBENEFITPROJECTION_COMPANY_PERCENTFEMALE_SELECT"
|
||||
icon="list"
|
||||
maximum="10">
|
||||
<fields name="percentfemale_fields" label="">
|
||||
<fieldset hidden="true" name="percentfemale_modal" repeat="true">
|
||||
<!-- Age Field. Type: List. (joomla) -->
|
||||
<field
|
||||
type="list"
|
||||
name="age"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_AGE_LABEL"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
filter="CMD">
|
||||
<!-- Option Set. -->
|
||||
<option value="15-19">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_FIFTEENNINETEEN</option>
|
||||
<option value="20-24">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_TWENTYTWENTY_FOUR</option>
|
||||
<option value="25-29">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_TWENTY_FIVETWENTY_NINE</option>
|
||||
<option value="30-34">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_THIRTYTHIRTY_FOUR</option>
|
||||
<option value="35-39">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_THIRTY_FIVETHIRTY_NINE</option>
|
||||
<option value="40-44">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_FORTYFORTY_FOUR</option>
|
||||
<option value="45-49">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_FORTY_FIVEFORTY_NINE</option>
|
||||
<option value="50-54">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_FIFTYFIFTY_FOUR</option>
|
||||
<option value="55-59">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_FIFTY_FIVEFIFTY_NINE</option>
|
||||
<option value="60-64">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_SIXTYSIXTY_FOUR</option>
|
||||
</field>
|
||||
<!-- Percent Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="percent"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_PERCENT_LABEL"
|
||||
size="10"
|
||||
maxlength="50"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
filter="FLOAT"
|
||||
message="Error! Please add percent here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_PERCENT_HINT"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</field>
|
||||
<!-- Medical_turnovers_females Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="medical_turnovers_females"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_MEDICAL_TURNOVERS_FEMALES_LABEL"
|
||||
size="20"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_MEDICAL_TURNOVERS_FEMALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="INT"
|
||||
message="Error! Please add total number of medical turnovers for females here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_MEDICAL_TURNOVERS_FEMALES_HINT"
|
||||
/>
|
||||
<!-- Females Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="females"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_FEMALES_LABEL"
|
||||
size="20"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_FEMALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="INT"
|
||||
message="Error! Please add total female employees here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_FEMALES_HINT"
|
||||
/>
|
||||
<!-- Sick_leave_males Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="sick_leave_males"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_SICK_LEAVE_MALES_LABEL"
|
||||
size="20"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_SICK_LEAVE_MALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="INT"
|
||||
message="Error! Please add total number of sick leave days for males here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_SICK_LEAVE_MALES_HINT"
|
||||
/>
|
||||
<!-- Causesrisks Field. Type: Causesriskscheck. (custom) -->
|
||||
<field
|
||||
type="causesriskscheck"
|
||||
name="causesrisks"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_CAUSESRISKS_LABEL"
|
||||
class="list_class"
|
||||
required="true"
|
||||
/>
|
||||
<!-- Age_groups_note Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="age_groups_note" label="COM_COSTBENEFITPROJECTION_COMPANY_AGE_GROUPS_NOTE_LABEL" description="COM_COSTBENEFITPROJECTION_COMPANY_AGE_GROUPS_NOTE_DESCRIPTION" class="alert alert-info age_groups_note" />
|
||||
<!-- Datayear Field. Type: Datayear. (custom) -->
|
||||
<field
|
||||
type="datayear"
|
||||
name="datayear"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_DATAYEAR_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_DATAYEAR_DESCRIPTION"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
default="0"
|
||||
/>
|
||||
<!-- Medical_turnovers_males Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="medical_turnovers_males"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_MEDICAL_TURNOVERS_MALES_LABEL"
|
||||
size="20"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_MEDICAL_TURNOVERS_MALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="INT"
|
||||
message="Error! Please add total number of medical turnovers for males here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_MEDICAL_TURNOVERS_MALES_HINT"
|
||||
/>
|
||||
<!-- Working_days Field. Type: Integer. (joomla) -->
|
||||
<field
|
||||
type="integer"
|
||||
name="working_days"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_WORKING_DAYS_LABEL"
|
||||
default="225"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_WORKING_DAYS_DESCRIPTION"
|
||||
class="text_area"
|
||||
required="true"
|
||||
first="200"
|
||||
last="365"
|
||||
step="1"
|
||||
/>
|
||||
<!-- Turnover_comment Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="turnover_comment"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_TURNOVER_COMMENT_LABEL"
|
||||
rows="8"
|
||||
cols="5"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_TURNOVER_COMMENT_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="HTML"
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_TURNOVER_COMMENT_HINT"
|
||||
/>
|
||||
<!-- Total_salary Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="total_salary"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_TOTAL_SALARY_LABEL"
|
||||
size="20"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_TOTAL_SALARY_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="integer"
|
||||
message="Error! Please add total salary here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_TOTAL_SALARY_HINT"
|
||||
/>
|
||||
<!-- Sick_leave_females Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="sick_leave_females"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_SICK_LEAVE_FEMALES_LABEL"
|
||||
size="20"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_SICK_LEAVE_FEMALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="INT"
|
||||
message="Error! Please add total number of sick leave days for females here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_SICK_LEAVE_FEMALES_HINT"
|
||||
/>
|
||||
<!-- Total_healthcare Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="total_healthcare"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_TOTAL_HEALTHCARE_LABEL"
|
||||
size="20"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_TOTAL_HEALTHCARE_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="integer"
|
||||
message="Error! Please add total healthcare costs here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_TOTAL_HEALTHCARE_HINT"
|
||||
/>
|
||||
<!-- Percentmale Field. Type: Repeatable. (joomla) -->
|
||||
<field
|
||||
type="repeatable"
|
||||
name="percentmale"
|
||||
label="Set Males Age Groups Percent"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_PERCENTMALE_DESCRIPTION"
|
||||
id="percentmale"
|
||||
class="percentmales"
|
||||
select="COM_COSTBENEFITPROJECTION_COMPANY_PERCENTMALE_SELECT"
|
||||
icon="list"
|
||||
maximum="10">
|
||||
<fields name="percentmale_fields" label="">
|
||||
<fieldset hidden="true" name="percentmale_modal" repeat="true">
|
||||
<!-- Age Field. Type: List. (joomla) -->
|
||||
<field
|
||||
type="list"
|
||||
name="age"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_AGE_LABEL"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
filter="CMD">
|
||||
<!-- Option Set. -->
|
||||
<option value="15-19">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_FIFTEENNINETEEN</option>
|
||||
<option value="20-24">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_TWENTYTWENTY_FOUR</option>
|
||||
<option value="25-29">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_TWENTY_FIVETWENTY_NINE</option>
|
||||
<option value="30-34">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_THIRTYTHIRTY_FOUR</option>
|
||||
<option value="35-39">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_THIRTY_FIVETHIRTY_NINE</option>
|
||||
<option value="40-44">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_FORTYFORTY_FOUR</option>
|
||||
<option value="45-49">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_FORTY_FIVEFORTY_NINE</option>
|
||||
<option value="50-54">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_FIFTYFIFTY_FOUR</option>
|
||||
<option value="55-59">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_FIFTY_FIVEFIFTY_NINE</option>
|
||||
<option value="60-64">
|
||||
COM_COSTBENEFITPROJECTION_COMPANY_SIXTYSIXTY_FOUR</option>
|
||||
</field>
|
||||
<!-- Percent Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="percent"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_PERCENT_LABEL"
|
||||
size="10"
|
||||
maxlength="50"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
filter="FLOAT"
|
||||
message="Error! Please add percent here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_PERCENT_HINT"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</field>
|
||||
<!-- Productivity_losses Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="productivity_losses"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_PRODUCTIVITY_LOSSES_LABEL"
|
||||
size="20"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_PRODUCTIVITY_LOSSES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="CMD"
|
||||
message="Error! Please add medical turnover cost factor here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_PRODUCTIVITY_LOSSES_HINT"
|
||||
/>
|
||||
<!-- Cause_risk_selection_note Field. Type: Note. A None Database Field. (joomla) -->
|
||||
<field type="note" name="cause_risk_selection_note" label="COM_COSTBENEFITPROJECTION_COMPANY_CAUSE_RISK_SELECTION_NOTE_LABEL" description="COM_COSTBENEFITPROJECTION_COMPANY_CAUSE_RISK_SELECTION_NOTE_DESCRIPTION" class="alert alert-info cause_risk_selection_note" />
|
||||
<!-- Males Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="males"
|
||||
label="COM_COSTBENEFITPROJECTION_COMPANY_MALES_LABEL"
|
||||
size="20"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_COMPANY_MALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="INT"
|
||||
message="Error! Please add total male employees here."
|
||||
hint="COM_COSTBENEFITPROJECTION_COMPANY_MALES_HINT"
|
||||
/>
|
||||
<!-- Not_required Field. Type: Hidden. (joomla) -->
|
||||
<field
|
||||
type="hidden"
|
||||
name="not_required"
|
||||
default="[]"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<!-- Access Control Fields. -->
|
||||
<fieldset name="accesscontrol">
|
||||
<!-- Asset Id Field. Type: Hidden (joomla) -->
|
||||
<field
|
||||
name="asset_id"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Rules Field. Type: Rules (joomla) -->
|
||||
<field
|
||||
name="rules"
|
||||
type="rules"
|
||||
label="Permissions in relation to this company"
|
||||
translate_label="false"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
class="inputbox"
|
||||
component="com_costbenefitprojection"
|
||||
section="company"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,326 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage intervention.js
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
// Some Global Values
|
||||
jform_vvvvvvyvwj_required = false;
|
||||
jform_vvvvvwavwk_required = false;
|
||||
|
||||
// Initial Script
|
||||
jQuery(document).ready(function()
|
||||
{
|
||||
var type_vvvvvvy = jQuery("#jform_type input[type='radio']:checked").val();
|
||||
vvvvvvy(type_vvvvvvy);
|
||||
|
||||
var type_vvvvvvz = jQuery("#jform_type input[type='radio']:checked").val();
|
||||
vvvvvvz(type_vvvvvvz);
|
||||
|
||||
var company_vvvvvwa = jQuery("#jform_company").val();
|
||||
vvvvvwa(company_vvvvvwa);
|
||||
});
|
||||
|
||||
// the vvvvvvy function
|
||||
function vvvvvvy(type_vvvvvvy)
|
||||
{
|
||||
// set the function logic
|
||||
if (type_vvvvvvy == 2)
|
||||
{
|
||||
jQuery('#jform_interventions').closest('.control-group').show();
|
||||
if (jform_vvvvvvyvwj_required)
|
||||
{
|
||||
updateFieldRequired('interventions',0);
|
||||
jQuery('#jform_interventions').prop('required','required');
|
||||
jQuery('#jform_interventions').attr('aria-required',true);
|
||||
jQuery('#jform_interventions').addClass('required');
|
||||
jform_vvvvvvyvwj_required = false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery('#jform_interventions').closest('.control-group').hide();
|
||||
if (!jform_vvvvvvyvwj_required)
|
||||
{
|
||||
updateFieldRequired('interventions',1);
|
||||
jQuery('#jform_interventions').removeAttr('required');
|
||||
jQuery('#jform_interventions').removeAttr('aria-required');
|
||||
jQuery('#jform_interventions').removeClass('required');
|
||||
jform_vvvvvvyvwj_required = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the vvvvvvz function
|
||||
function vvvvvvz(type_vvvvvvz)
|
||||
{
|
||||
// set the function logic
|
||||
if (type_vvvvvvz == 1)
|
||||
{
|
||||
jQuery('#jform_intervention').closest('.control-group').show();
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery('#jform_intervention').closest('.control-group').hide();
|
||||
}
|
||||
}
|
||||
|
||||
// the vvvvvwa function
|
||||
function vvvvvwa(company_vvvvvwa)
|
||||
{
|
||||
if (isSet(company_vvvvvwa) && company_vvvvvwa.constructor !== Array)
|
||||
{
|
||||
var temp_vvvvvwa = company_vvvvvwa;
|
||||
var company_vvvvvwa = [];
|
||||
company_vvvvvwa.push(temp_vvvvvwa);
|
||||
}
|
||||
else if (!isSet(company_vvvvvwa))
|
||||
{
|
||||
var company_vvvvvwa = [];
|
||||
}
|
||||
var company = company_vvvvvwa.some(company_vvvvvwa_SomeFunc);
|
||||
|
||||
|
||||
// set this function logic
|
||||
if (company)
|
||||
{
|
||||
jQuery('#jform_country').closest('.control-group').show();
|
||||
if (jform_vvvvvwavwk_required)
|
||||
{
|
||||
updateFieldRequired('country',0);
|
||||
jQuery('#jform_country').prop('required','required');
|
||||
jQuery('#jform_country').attr('aria-required',true);
|
||||
jQuery('#jform_country').addClass('required');
|
||||
jform_vvvvvwavwk_required = false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery('#jform_country').closest('.control-group').hide();
|
||||
if (!jform_vvvvvwavwk_required)
|
||||
{
|
||||
updateFieldRequired('country',1);
|
||||
jQuery('#jform_country').removeAttr('required');
|
||||
jQuery('#jform_country').removeAttr('aria-required');
|
||||
jQuery('#jform_country').removeClass('required');
|
||||
jform_vvvvvwavwk_required = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the vvvvvwa Some function
|
||||
function company_vvvvvwa_SomeFunc(company_vvvvvwa)
|
||||
{
|
||||
// set the function logic
|
||||
if (company_vvvvvwa == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// update required fields
|
||||
function updateFieldRequired(name,status)
|
||||
{
|
||||
var not_required = jQuery('#jform_not_required').val();
|
||||
|
||||
if(status == 1)
|
||||
{
|
||||
if (isSet(not_required) && not_required != 0)
|
||||
{
|
||||
not_required = not_required+','+name;
|
||||
}
|
||||
else
|
||||
{
|
||||
not_required = ','+name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isSet(not_required) && not_required != 0)
|
||||
{
|
||||
not_required = not_required.replace(','+name,'');
|
||||
}
|
||||
}
|
||||
|
||||
jQuery('#jform_not_required').val(not_required);
|
||||
}
|
||||
|
||||
// the isSet function
|
||||
function isSet(val)
|
||||
{
|
||||
if ((val != undefined) && (val != null) && 0 !== val.length){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
jQuery(document).ready(function()
|
||||
{
|
||||
var inter_type = jQuery("#jform_type input[type='radio']:checked").val();
|
||||
var interventions = jQuery('#jform_intervention').val();
|
||||
if (1 == inter_type && interventions) {
|
||||
getBuildTable(interventions,'jform_intervention','nee');
|
||||
} else if (2 == inter_type && interventions) {
|
||||
getBuildTable(interventions,'jform_interventions','ja');
|
||||
}
|
||||
jQuery('.save-modal-data').text('Done');
|
||||
});
|
||||
|
||||
function getClusterData(array,idName){
|
||||
var cluster = JSON.stringify(array);
|
||||
getClusterData_server(cluster,idName).done(function(result) {
|
||||
if(result.table){
|
||||
buildTable(result.table,idName);
|
||||
// ubdate the main set of values
|
||||
jQuery('#jform_intervention').val(result.values);
|
||||
} else {
|
||||
jQuery('#table_'+idName).remove();
|
||||
jQuery('#jform_intervention').val('');
|
||||
jQuery('.btn-wrapper').show();
|
||||
jQuery('#inputYYYNote').remove();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getClusterData_server(cluster,idName){
|
||||
var getUrl = "index.php?option=com_costbenefitprojection&task=ajax.getClusterData&format=json";
|
||||
if(token.length > 0 && cluster.length > 0 && idName.length > 0){
|
||||
var request = 'token='+token+'&idName='+idName+'&cluster='+cluster;
|
||||
}
|
||||
return jQuery.ajax({
|
||||
type: 'GET',
|
||||
url: getUrl,
|
||||
dataType: 'jsonp',
|
||||
data: request,
|
||||
jsonp: 'callback'
|
||||
});
|
||||
}
|
||||
|
||||
function getBuildTable_server(string,idName,cluster){
|
||||
var getUrl = "index.php?option=com_costbenefitprojection&task=ajax.interventionBuildTable&format=json";
|
||||
if(token.length > 0 && string.length > 0 && idName.length > 0){
|
||||
var request = 'token='+token+'&idName='+idName+'&oject='+string+'&cluster='+cluster;
|
||||
}
|
||||
return jQuery.ajax({
|
||||
type: 'GET',
|
||||
url: getUrl,
|
||||
dataType: 'jsonp',
|
||||
data: request,
|
||||
jsonp: 'callback'
|
||||
});
|
||||
}
|
||||
|
||||
function getBuildTable(intervention,idName,cluster){
|
||||
if ('ne' == cluster)
|
||||
{
|
||||
var intervention = JSON.stringify(intervention);
|
||||
cluster = 'nee';
|
||||
}
|
||||
getBuildTable_server(intervention,idName,cluster).done(function(result) {
|
||||
if(result){
|
||||
buildTable(result,idName);
|
||||
} else {
|
||||
jQuery('#table_'+idName).remove();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function buildTable(result,idName){
|
||||
jQuery('#table_'+idName).remove();
|
||||
jQuery('#'+idName).closest('.control-group').append(result);
|
||||
// check if we have cross match values
|
||||
if (jQuery(".eRrOr").length > 0){
|
||||
jQuery('.btn-wrapper').hide();
|
||||
if (jQuery('#inputYYYNote').length <= 0){
|
||||
jQuery('#system-message-container').append('<div id="inputYYYNote" class="alert alert-error"><p>Values cross match between selected interventions please update all in red!</p></div>');
|
||||
}
|
||||
} else {
|
||||
jQuery('.btn-wrapper').show();
|
||||
jQuery('#inputYYYNote').remove();
|
||||
}
|
||||
}
|
||||
|
||||
function updateSelection(row)
|
||||
{
|
||||
var groupId = jQuery(row).find("select:first").attr("id");
|
||||
var percentValue = jQuery(row).find(".text_area:first").val();
|
||||
var arr = groupId.split('-');
|
||||
if (arr[1] != 1)
|
||||
{
|
||||
var selection = {};
|
||||
jQuery(row).find("select:first option").each(function()
|
||||
{
|
||||
// first get the values and text
|
||||
selection[jQuery(this).text()] = jQuery(this).val();
|
||||
});
|
||||
jQuery.each(causerisk, function(i, group){
|
||||
jQuery(row).find("select:first option[value='"+group+"']").remove();
|
||||
});
|
||||
if (percentValue)
|
||||
{
|
||||
var text = jQuery(row).find(".chzn-single:first span").text();
|
||||
jQuery(row).find("select:first").append(jQuery('<option>', {
|
||||
value: selection[text],
|
||||
text: text
|
||||
}));
|
||||
}
|
||||
jQuery(row).find("select:first").trigger("liszt:updated");
|
||||
|
||||
if (percentValue)
|
||||
{
|
||||
jQuery(row).find("select:first option:selected").val(selection[text]);
|
||||
jQuery(row).find(".chzn-single:first span").text(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeFieldValue(id,value) {
|
||||
if(id.length > 0) {
|
||||
value = jQuery.trim(value);
|
||||
if (value.match(/[^0-9\.]/g) || !value){
|
||||
jQuery('#'+id).css({'color':'red'});
|
||||
jQuery('#'+id).removeClass('eRrOr');
|
||||
jQuery('#'+id).addClass('eRrOr');
|
||||
alert('Only numbers should be used, not ('+value+')');
|
||||
} else {
|
||||
// update value
|
||||
jQuery('#'+id).val(value);
|
||||
// we must also update the main set of values
|
||||
var mainset = jQuery('#jform_intervention').val();
|
||||
mainset = jQuery.parseJSON(mainset)
|
||||
var key = id.split('_');
|
||||
mainset[key[0]][key[1]] = value;
|
||||
mainset = JSON.stringify(mainset);
|
||||
jQuery('#jform_intervention').val(mainset);
|
||||
jQuery('#'+id).removeClass('eRrOr');
|
||||
jQuery('#'+id).css({'color':''});
|
||||
}
|
||||
// okay update the value
|
||||
if (jQuery(".eRrOr").length > 0){
|
||||
jQuery('.btn-wrapper').hide();
|
||||
if (jQuery('#inputYYYNote').length <= 0){
|
||||
jQuery('#system-message-container').append('<div id="inputYYYNote" class="alert alert-error"><p>Values cross match between selected interventions please update all in red!</p></div>');
|
||||
}
|
||||
} else {
|
||||
jQuery('.btn-wrapper').show();
|
||||
jQuery('#inputYYYNote').remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,289 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form
|
||||
addrulepath="/administrator/components/com_costbenefitprojection/models/rules"
|
||||
addfieldpath="/administrator/components/com_costbenefitprojection/models/fields"
|
||||
>
|
||||
<fieldset name="details">
|
||||
<!-- Default Fields. -->
|
||||
<!-- Id Field. Type: Text (joomla) -->
|
||||
<field
|
||||
name="id"
|
||||
type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"
|
||||
description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"
|
||||
readonly="true"
|
||||
/>
|
||||
<!-- Date Created Field. Type: Calendar (joomla) -->
|
||||
<field
|
||||
name="created"
|
||||
type="calendar"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_CREATED_DATE_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_CREATED_DATE_DESC"
|
||||
size="22"
|
||||
format="%Y-%m-%d %H:%M:%S"
|
||||
filter="user_utc"
|
||||
/>
|
||||
<!-- User Created Field. Type: User (joomla) -->
|
||||
<field
|
||||
name="created_by"
|
||||
type="user"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_CREATED_BY_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_CREATED_BY_DESC"
|
||||
/>
|
||||
<!-- Published Field. Type: List (joomla) -->
|
||||
<field name="published" type="list" label="JSTATUS"
|
||||
description="JFIELD_PUBLISHED_DESC" class="chzn-color-state"
|
||||
filter="intval" size="1" default="1" >
|
||||
<option value="1">
|
||||
JPUBLISHED</option>
|
||||
<option value="0">
|
||||
JUNPUBLISHED</option>
|
||||
<option value="2">
|
||||
JARCHIVED</option>
|
||||
<option value="-2">
|
||||
JTRASHED</option>
|
||||
</field>
|
||||
<!-- Date Modified Field. Type: Calendar (joomla) -->
|
||||
<field name="modified" type="calendar" class="readonly"
|
||||
label="JGLOBAL_FIELD_MODIFIED_LABEL" description="COM_CONTENT_FIELD_MODIFIED_DESC"
|
||||
size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
|
||||
<!-- User Modified Field. Type: User (joomla) -->
|
||||
<field name="modified_by" type="user"
|
||||
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Ordering Field. Type: Numbers (joomla) -->
|
||||
<field
|
||||
name="ordering"
|
||||
type="number"
|
||||
class="inputbox validate-ordering"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_ORDERING_LABEL"
|
||||
description=""
|
||||
default="0"
|
||||
size="6"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Version Field. Type: Text (joomla) -->
|
||||
<field
|
||||
name="version"
|
||||
type="text"
|
||||
class="readonly"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_VERSION_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_VERSION_DESC"
|
||||
size="6"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Dynamic Fields. -->
|
||||
<!-- Name Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="name"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_NAME_LABEL"
|
||||
size="40"
|
||||
maxlength="150"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_NAME_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="STRING"
|
||||
message="Error! Please add intervention name here."
|
||||
hint="COM_COSTBENEFITPROJECTION_INTERVENTION_NAME_HINT"
|
||||
/>
|
||||
<!-- Company Field. Type: Company. (custom) -->
|
||||
<field
|
||||
type="company"
|
||||
name="company"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_COMPANY_LABEL"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
default="0"
|
||||
button="true"
|
||||
/>
|
||||
<!-- Type Field. Type: Radio. (joomla) -->
|
||||
<field
|
||||
type="radio"
|
||||
name="type"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_TYPE_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_TYPE_DESCRIPTION"
|
||||
class="btn-group"
|
||||
default="1"
|
||||
required="true">
|
||||
<!-- Option Set. -->
|
||||
<option value="1">
|
||||
COM_COSTBENEFITPROJECTION_INTERVENTION_SINGLE</option>
|
||||
<option value="2">
|
||||
COM_COSTBENEFITPROJECTION_INTERVENTION_CLUSTER</option>
|
||||
</field>
|
||||
<!-- Coverage Field. Type: Integer. (joomla) -->
|
||||
<field
|
||||
type="integer"
|
||||
name="coverage"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_COVERAGE_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_COVERAGE_DESCRIPTION"
|
||||
required="true"
|
||||
first="10"
|
||||
last="100"
|
||||
step="10"
|
||||
/>
|
||||
<!-- Description Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="description"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_DESCRIPTION_LABEL"
|
||||
rows="11"
|
||||
cols="10"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_DESCRIPTION_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="HTML"
|
||||
hint="COM_COSTBENEFITPROJECTION_INTERVENTION_DESCRIPTION_HINT"
|
||||
/>
|
||||
<!-- Reference Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="reference"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_REFERENCE_LABEL"
|
||||
rows="10"
|
||||
cols="5"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_REFERENCE_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="HTML"
|
||||
hint="COM_COSTBENEFITPROJECTION_INTERVENTION_REFERENCE_HINT"
|
||||
/>
|
||||
<!-- Intervention Field. Type: Repeatable. (joomla) -->
|
||||
<field
|
||||
type="repeatable"
|
||||
name="intervention"
|
||||
label="Set Intervention"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_INTERVENTION_DESCRIPTION"
|
||||
id="intervention"
|
||||
class="interventions"
|
||||
select="COM_COSTBENEFITPROJECTION_INTERVENTION_INTERVENTION_SELECT"
|
||||
icon="list"
|
||||
maximum="100">
|
||||
<fields name="intervention_fields" label="">
|
||||
<fieldset hidden="true" name="intervention_modal" repeat="true">
|
||||
<!-- Causerisk Field. Type: Causesrisks. (custom) -->
|
||||
<field
|
||||
type="causesrisks"
|
||||
name="causerisk"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_CAUSERISK_LABEL"
|
||||
class="list_class causewidth"
|
||||
multiple="false"
|
||||
default="0"
|
||||
button="false"
|
||||
/>
|
||||
<!-- Cpe Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="cpe"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_CPE_LABEL"
|
||||
size="10"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_CPE_DESCRIPTION"
|
||||
class="text_area"
|
||||
filter="INT"
|
||||
/>
|
||||
<!-- Mbr Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="mbr"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_MBR_LABEL"
|
||||
size="10"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_MBR_DESCRIPTION"
|
||||
class="text_area"
|
||||
filter="INT"
|
||||
/>
|
||||
<!-- Mtr Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="mtr"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_MTR_LABEL"
|
||||
size="10"
|
||||
maxlength="50"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_MTR_DESCRIPTION"
|
||||
class="text_area"
|
||||
filter="INT"
|
||||
/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</field>
|
||||
<!-- Country Field. Type: Countries. (custom) -->
|
||||
<field
|
||||
type="countries"
|
||||
name="country"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_COUNTRY_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_COUNTRY_DESCRIPTION"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
default="0"
|
||||
required="true"
|
||||
/>
|
||||
<!-- Share Field. Type: List. (joomla) -->
|
||||
<field
|
||||
type="list"
|
||||
name="share"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_SHARE_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_INTERVENTION_SHARE_DESCRIPTION"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
filter="INT"
|
||||
required="true"
|
||||
default="3">
|
||||
<!-- Option Set. -->
|
||||
<option value="3">
|
||||
COM_COSTBENEFITPROJECTION_INTERVENTION_ALL_SERVICE_PROVIDERS_AND_ADMIN</option>
|
||||
<option value="2">
|
||||
COM_COSTBENEFITPROJECTION_INTERVENTION_ONLY_MY_SERVICE_PROVIDER</option>
|
||||
<option value="1">
|
||||
COM_COSTBENEFITPROJECTION_INTERVENTION_ONLY_ME</option>
|
||||
</field>
|
||||
<!-- Interventions Field. Type: Interventions. (custom) -->
|
||||
<field
|
||||
type="interventions"
|
||||
name="interventions"
|
||||
label="COM_COSTBENEFITPROJECTION_INTERVENTION_INTERVENTIONS_LABEL"
|
||||
class="list_class"
|
||||
multiple="true"
|
||||
required="true"
|
||||
button="false"
|
||||
/>
|
||||
<!-- Duration Field. Type: Hidden. (joomla) -->
|
||||
<field
|
||||
type="hidden"
|
||||
name="duration"
|
||||
default="1"
|
||||
/>
|
||||
<!-- Not_required Field. Type: Hidden. (joomla) -->
|
||||
<field
|
||||
type="hidden"
|
||||
name="not_required"
|
||||
default="[]"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<!-- Access Control Fields. -->
|
||||
<fieldset name="accesscontrol">
|
||||
<!-- Asset Id Field. Type: Hidden (joomla) -->
|
||||
<field
|
||||
name="asset_id"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Rules Field. Type: Rules (joomla) -->
|
||||
<field
|
||||
name="rules"
|
||||
type="rules"
|
||||
label="Permissions in relation to this intervention"
|
||||
translate_label="false"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
class="inputbox"
|
||||
component="com_costbenefitprojection"
|
||||
section="intervention"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
@@ -0,0 +1,118 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage scaling_factor.js
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
// Some Global Values
|
||||
jform_vvvvvvxvwi_required = false;
|
||||
|
||||
// Initial Script
|
||||
jQuery(document).ready(function()
|
||||
{
|
||||
var company_vvvvvvx = jQuery("#jform_company").val();
|
||||
vvvvvvx(company_vvvvvvx);
|
||||
});
|
||||
|
||||
// the vvvvvvx function
|
||||
function vvvvvvx(company_vvvvvvx)
|
||||
{
|
||||
if (isSet(company_vvvvvvx) && company_vvvvvvx.constructor !== Array)
|
||||
{
|
||||
var temp_vvvvvvx = company_vvvvvvx;
|
||||
var company_vvvvvvx = [];
|
||||
company_vvvvvvx.push(temp_vvvvvvx);
|
||||
}
|
||||
else if (!isSet(company_vvvvvvx))
|
||||
{
|
||||
var company_vvvvvvx = [];
|
||||
}
|
||||
var company = company_vvvvvvx.some(company_vvvvvvx_SomeFunc);
|
||||
|
||||
|
||||
// set this function logic
|
||||
if (company)
|
||||
{
|
||||
jQuery('#jform_country').closest('.control-group').show();
|
||||
if (jform_vvvvvvxvwi_required)
|
||||
{
|
||||
updateFieldRequired('country',0);
|
||||
jQuery('#jform_country').prop('required','required');
|
||||
jQuery('#jform_country').attr('aria-required',true);
|
||||
jQuery('#jform_country').addClass('required');
|
||||
jform_vvvvvvxvwi_required = false;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery('#jform_country').closest('.control-group').hide();
|
||||
if (!jform_vvvvvvxvwi_required)
|
||||
{
|
||||
updateFieldRequired('country',1);
|
||||
jQuery('#jform_country').removeAttr('required');
|
||||
jQuery('#jform_country').removeAttr('aria-required');
|
||||
jQuery('#jform_country').removeClass('required');
|
||||
jform_vvvvvvxvwi_required = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the vvvvvvx Some function
|
||||
function company_vvvvvvx_SomeFunc(company_vvvvvvx)
|
||||
{
|
||||
// set the function logic
|
||||
if (company_vvvvvvx == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// update required fields
|
||||
function updateFieldRequired(name,status)
|
||||
{
|
||||
var not_required = jQuery('#jform_not_required').val();
|
||||
|
||||
if(status == 1)
|
||||
{
|
||||
if (isSet(not_required) && not_required != 0)
|
||||
{
|
||||
not_required = not_required+','+name;
|
||||
}
|
||||
else
|
||||
{
|
||||
not_required = ','+name;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isSet(not_required) && not_required != 0)
|
||||
{
|
||||
not_required = not_required.replace(','+name,'');
|
||||
}
|
||||
}
|
||||
|
||||
jQuery('#jform_not_required').val(not_required);
|
||||
}
|
||||
|
||||
// the isSet function
|
||||
function isSet(val)
|
||||
{
|
||||
if ((val != undefined) && (val != null) && 0 !== val.length){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@@ -0,0 +1,264 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<form
|
||||
addrulepath="/administrator/components/com_costbenefitprojection/models/rules"
|
||||
addfieldpath="/administrator/components/com_costbenefitprojection/models/fields"
|
||||
>
|
||||
<fieldset name="details">
|
||||
<!-- Default Fields. -->
|
||||
<!-- Id Field. Type: Text (joomla) -->
|
||||
<field
|
||||
name="id"
|
||||
type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"
|
||||
description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"
|
||||
readonly="true"
|
||||
/>
|
||||
<!-- Date Created Field. Type: Calendar (joomla) -->
|
||||
<field
|
||||
name="created"
|
||||
type="calendar"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_CREATED_DATE_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_CREATED_DATE_DESC"
|
||||
size="22"
|
||||
format="%Y-%m-%d %H:%M:%S"
|
||||
filter="user_utc"
|
||||
/>
|
||||
<!-- User Created Field. Type: User (joomla) -->
|
||||
<field
|
||||
name="created_by"
|
||||
type="user"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_CREATED_BY_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_CREATED_BY_DESC"
|
||||
/>
|
||||
<!-- Published Field. Type: List (joomla) -->
|
||||
<field name="published" type="list" label="JSTATUS"
|
||||
description="JFIELD_PUBLISHED_DESC" class="chzn-color-state"
|
||||
filter="intval" size="1" default="1" >
|
||||
<option value="1">
|
||||
JPUBLISHED</option>
|
||||
<option value="0">
|
||||
JUNPUBLISHED</option>
|
||||
<option value="2">
|
||||
JARCHIVED</option>
|
||||
<option value="-2">
|
||||
JTRASHED</option>
|
||||
</field>
|
||||
<!-- Date Modified Field. Type: Calendar (joomla) -->
|
||||
<field name="modified" type="calendar" class="readonly"
|
||||
label="JGLOBAL_FIELD_MODIFIED_LABEL" description="COM_CONTENT_FIELD_MODIFIED_DESC"
|
||||
size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
|
||||
<!-- User Modified Field. Type: User (joomla) -->
|
||||
<field name="modified_by" type="user"
|
||||
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
|
||||
class="readonly"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Ordering Field. Type: Numbers (joomla) -->
|
||||
<field
|
||||
name="ordering"
|
||||
type="number"
|
||||
class="inputbox validate-ordering"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_ORDERING_LABEL"
|
||||
description=""
|
||||
default="0"
|
||||
size="6"
|
||||
required="false"
|
||||
/>
|
||||
<!-- Version Field. Type: Text (joomla) -->
|
||||
<field
|
||||
name="version"
|
||||
type="text"
|
||||
class="readonly"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_VERSION_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_VERSION_DESC"
|
||||
size="6"
|
||||
readonly="true"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Dynamic Fields. -->
|
||||
<!-- Causerisk Field. Type: Causesrisks. (custom) -->
|
||||
<field
|
||||
type="causesrisks"
|
||||
name="causerisk"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_CAUSERISK_LABEL"
|
||||
description="JFIELD_TITLE_DESC"
|
||||
class="list_class span12"
|
||||
multiple="false"
|
||||
default="0"
|
||||
/>
|
||||
<!-- Company Field. Type: Company. (custom) -->
|
||||
<field
|
||||
type="company"
|
||||
name="company"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_COMPANY_LABEL"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
default="0"
|
||||
button="true"
|
||||
/>
|
||||
<!-- Yld_scaling_factor_males Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="yld_scaling_factor_males"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_YLD_SCALING_FACTOR_MALES_LABEL"
|
||||
size="10"
|
||||
maxlength="10"
|
||||
default="1"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_YLD_SCALING_FACTOR_MALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="CMD"
|
||||
message="Error! Please add scaling factor for males here."
|
||||
hint="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_YLD_SCALING_FACTOR_MALES_HINT"
|
||||
/>
|
||||
<!-- Yld_scaling_factor_females Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="yld_scaling_factor_females"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_YLD_SCALING_FACTOR_FEMALES_LABEL"
|
||||
size="10"
|
||||
maxlength="10"
|
||||
default="1"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_YLD_SCALING_FACTOR_FEMALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="CMD"
|
||||
message="Error! Please add scaling factor for females here."
|
||||
hint="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_YLD_SCALING_FACTOR_FEMALES_HINT"
|
||||
/>
|
||||
<!-- Mortality_scaling_factor_males Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="mortality_scaling_factor_males"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_MORTALITY_SCALING_FACTOR_MALES_LABEL"
|
||||
size="10"
|
||||
maxlength="10"
|
||||
default="1"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_MORTALITY_SCALING_FACTOR_MALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="CMD"
|
||||
message="Error! Please add scaling factor for males here."
|
||||
hint="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_MORTALITY_SCALING_FACTOR_MALES_HINT"
|
||||
/>
|
||||
<!-- Mortality_scaling_factor_females Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="mortality_scaling_factor_females"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_MORTALITY_SCALING_FACTOR_FEMALES_LABEL"
|
||||
size="10"
|
||||
maxlength="10"
|
||||
default="1"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_MORTALITY_SCALING_FACTOR_FEMALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="CMD"
|
||||
message="Error! Please add scaling factor for females here."
|
||||
hint="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_MORTALITY_SCALING_FACTOR_FEMALES_HINT"
|
||||
/>
|
||||
<!-- Presenteeism_scaling_factor_males Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="presenteeism_scaling_factor_males"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_PRESENTEEISM_SCALING_FACTOR_MALES_LABEL"
|
||||
size="10"
|
||||
maxlength="10"
|
||||
default="1"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_PRESENTEEISM_SCALING_FACTOR_MALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="CMD"
|
||||
message="Error! Please add scaling factor for males here."
|
||||
hint="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_PRESENTEEISM_SCALING_FACTOR_MALES_HINT"
|
||||
/>
|
||||
<!-- Presenteeism_scaling_factor_females Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="presenteeism_scaling_factor_females"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_PRESENTEEISM_SCALING_FACTOR_FEMALES_LABEL"
|
||||
size="10"
|
||||
maxlength="10"
|
||||
default="1"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_PRESENTEEISM_SCALING_FACTOR_FEMALES_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="CMD"
|
||||
message="Error! Please add scaling factor for females here."
|
||||
hint="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_PRESENTEEISM_SCALING_FACTOR_FEMALES_HINT"
|
||||
/>
|
||||
<!-- Reference Field. Type: Textarea. (joomla) -->
|
||||
<field
|
||||
type="textarea"
|
||||
name="reference"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_REFERENCE_LABEL"
|
||||
rows="10"
|
||||
cols="5"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_REFERENCE_DESCRIPTION"
|
||||
class="text_area span12"
|
||||
filter="HTML"
|
||||
hint="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_REFERENCE_HINT"
|
||||
/>
|
||||
<!-- Country Field. Type: Countries. (custom) -->
|
||||
<field
|
||||
type="countries"
|
||||
name="country"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_COUNTRY_LABEL"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_COUNTRY_DESCRIPTION"
|
||||
class="list_class"
|
||||
multiple="false"
|
||||
default="0"
|
||||
required="true"
|
||||
/>
|
||||
<!-- Health_scaling_factor Field. Type: Text. (joomla) -->
|
||||
<field
|
||||
type="text"
|
||||
name="health_scaling_factor"
|
||||
label="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_HEALTH_SCALING_FACTOR_LABEL"
|
||||
size="10"
|
||||
maxlength="10"
|
||||
default="1"
|
||||
description="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_HEALTH_SCALING_FACTOR_DESCRIPTION"
|
||||
class="text_area"
|
||||
readonly="false"
|
||||
disabled="false"
|
||||
required="true"
|
||||
filter="CMD"
|
||||
message="Error! Please add scaling factor for health here."
|
||||
hint="COM_COSTBENEFITPROJECTION_SCALING_FACTOR_HEALTH_SCALING_FACTOR_HINT"
|
||||
/>
|
||||
</fieldset>
|
||||
|
||||
<!-- Access Control Fields. -->
|
||||
<fieldset name="accesscontrol">
|
||||
<!-- Asset Id Field. Type: Hidden (joomla) -->
|
||||
<field
|
||||
name="asset_id"
|
||||
type="hidden"
|
||||
filter="unset"
|
||||
/>
|
||||
<!-- Rules Field. Type: Rules (joomla) -->
|
||||
<field
|
||||
name="rules"
|
||||
type="rules"
|
||||
label="Permissions in relation to this scaling_factor"
|
||||
translate_label="false"
|
||||
filter="rules"
|
||||
validate="rules"
|
||||
class="inputbox"
|
||||
component="com_costbenefitprojection"
|
||||
section="scaling_factor"
|
||||
/>
|
||||
</fieldset>
|
||||
</form>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,965 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage intervention.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// import Joomla modelform library
|
||||
jimport('joomla.application.component.modeladmin');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Intervention Model
|
||||
*/
|
||||
class CostbenefitprojectionModelIntervention extends JModelAdmin
|
||||
{
|
||||
/**
|
||||
* @var string The prefix to use with controller messages.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_COSTBENEFITPROJECTION';
|
||||
|
||||
/**
|
||||
* The type alias for this content type.
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2
|
||||
*/
|
||||
public $typeAlias = 'com_costbenefitprojection.intervention';
|
||||
|
||||
/**
|
||||
* Returns a Table object, always creating it
|
||||
*
|
||||
* @param type $type The table type to instantiate
|
||||
* @param string $prefix A prefix for the table class name. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return JTable A database object
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getTable($type = 'intervention', $prefix = 'CostbenefitprojectionTable', $config = array())
|
||||
{
|
||||
return JTable::getInstance($type, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a single record.
|
||||
*
|
||||
* @param integer $pk The id of the primary key.
|
||||
*
|
||||
* @return mixed Object on success, false on failure.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
if ($item = parent::getItem($pk))
|
||||
{
|
||||
if (!empty($item->params))
|
||||
{
|
||||
// Convert the params field to an array.
|
||||
$registry = new Registry;
|
||||
$registry->loadString($item->params);
|
||||
$item->params = $registry->toArray();
|
||||
}
|
||||
|
||||
if (!empty($item->metadata))
|
||||
{
|
||||
// Convert the metadata field to an array.
|
||||
$registry = new Registry;
|
||||
$registry->loadString($item->metadata);
|
||||
$item->metadata = $registry->toArray();
|
||||
}
|
||||
|
||||
if (!empty($item->interventions))
|
||||
{
|
||||
// JSON Decode interventions.
|
||||
$item->interventions = json_decode($item->interventions);
|
||||
}
|
||||
|
||||
if (!empty($item->id))
|
||||
{
|
||||
$item->tags = new JHelperTags;
|
||||
$item->tags->getTagIds($item->id, 'com_costbenefitprojection.intervention');
|
||||
}
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
* @param array $data Data for the form.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return mixed A JForm object on success, false on failure
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = array(), $loadData = true)
|
||||
{ // Get the form.
|
||||
$form = $this->loadForm('com_costbenefitprojection.intervention', 'intervention', array('control' => 'jform', 'load_data' => $loadData));
|
||||
|
||||
if (empty($form))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$jinput = JFactory::getApplication()->input;
|
||||
|
||||
// The front end calls this model and uses a_id to avoid id clashes so we need to check for that first.
|
||||
if ($jinput->get('a_id'))
|
||||
{
|
||||
$id = $jinput->get('a_id', 0, 'INT');
|
||||
}
|
||||
// The back end uses id so we use that the rest of the time and set it to 0 by default.
|
||||
else
|
||||
{
|
||||
$id = $jinput->get('id', 0, 'INT');
|
||||
}
|
||||
|
||||
$user = JFactory::getUser();
|
||||
|
||||
// Check for existing item.
|
||||
// Modify the form based on Edit State access controls.
|
||||
if ($id != 0 && (!$user->authorise('intervention.edit.state', 'com_costbenefitprojection.intervention.' . (int) $id))
|
||||
|| ($id == 0 && !$user->authorise('intervention.edit.state', 'com_costbenefitprojection')))
|
||||
{
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('ordering', 'disabled', 'true');
|
||||
$form->setFieldAttribute('published', 'disabled', 'true');
|
||||
// Disable fields while saving.
|
||||
$form->setFieldAttribute('ordering', 'filter', 'unset');
|
||||
$form->setFieldAttribute('published', 'filter', 'unset');
|
||||
}
|
||||
// If this is a new item insure the greated by is set.
|
||||
if (0 == $id)
|
||||
{
|
||||
// Set the created_by to this user
|
||||
$form->setValue('created_by', null, $user->id);
|
||||
}
|
||||
// Modify the form based on Edit Creaded By access controls.
|
||||
if (!$user->authorise('core.edit.created_by', 'com_costbenefitprojection'))
|
||||
{
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('created_by', 'disabled', 'true');
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('created_by', 'readonly', 'true');
|
||||
// Disable fields while saving.
|
||||
$form->setFieldAttribute('created_by', 'filter', 'unset');
|
||||
}
|
||||
// Modify the form based on Edit Creaded Date access controls.
|
||||
if (!$user->authorise('core.edit.created', 'com_costbenefitprojection'))
|
||||
{
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('created', 'disabled', 'true');
|
||||
// Disable fields while saving.
|
||||
$form->setFieldAttribute('created', 'filter', 'unset');
|
||||
}
|
||||
// Only load these values if no id is found
|
||||
if (0 == $id)
|
||||
{
|
||||
// Set redirected field name
|
||||
$redirectedField = $jinput->get('ref', null, 'STRING');
|
||||
// Set redirected field value
|
||||
$redirectedValue = $jinput->get('refid', 0, 'INT');
|
||||
if (0 != $redirectedValue && $redirectedField)
|
||||
{
|
||||
// Now set the local-redirected field default value
|
||||
$form->setValue($redirectedField, null, $redirectedValue);
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the script that have to be included on the form
|
||||
*
|
||||
* @return string script files
|
||||
*/
|
||||
public function getScript()
|
||||
{
|
||||
return 'administrator/components/com_costbenefitprojection/models/forms/intervention.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function canDelete($record)
|
||||
{
|
||||
if (!empty($record->id))
|
||||
{
|
||||
if ($record->published != -2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$user = JFactory::getUser();
|
||||
// The record has been set. Check the record permissions.
|
||||
return $user->authorise('intervention.delete', 'com_costbenefitprojection.intervention.' . (int) $record->id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can have its state edited.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function canEditState($record)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$recordId = (!empty($record->id)) ? $record->id : 0;
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
// The record has been set. Check the record permissions.
|
||||
$permission = $user->authorise('intervention.edit.state', 'com_costbenefitprojection.intervention.' . (int) $recordId);
|
||||
if (!$permission && !is_null($permission))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// In the absense of better information, revert to the component permissions.
|
||||
return $user->authorise('intervention.edit.state', 'com_costbenefitprojection');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can edit an existing record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key.
|
||||
*
|
||||
* @return boolean
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function allowEdit($data = array(), $key = 'id')
|
||||
{
|
||||
// Check specific edit permission then general edit permission.
|
||||
$user = JFactory::getUser();
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
// get company id
|
||||
$company = CostbenefitprojectionHelper::getId('intervention',$recordId,'id','company');
|
||||
if (!$user->authorise('core.options', 'com_costbenefitprojection'))
|
||||
{
|
||||
// make absolutely sure that this intervention can be edited
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($user->id);
|
||||
if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($company,$companies))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// now check the access by sharing
|
||||
if (!CostbenefitprojectionHelper::checkIntervetionAccess($recordId,null,$company))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return $user->authorise('intervention.edit', 'com_costbenefitprojection.intervention.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('intervention.edit', 'com_costbenefitprojection');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and sanitise the table data prior to saving.
|
||||
*
|
||||
* @param JTable $table A JTable object.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function prepareTable($table)
|
||||
{
|
||||
$date = JFactory::getDate();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
if (isset($table->name))
|
||||
{
|
||||
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
|
||||
}
|
||||
|
||||
if (isset($table->alias) && empty($table->alias))
|
||||
{
|
||||
$table->generateAlias();
|
||||
}
|
||||
|
||||
if (empty($table->id))
|
||||
{
|
||||
$table->created = $date->toSql();
|
||||
// set the user
|
||||
if ($table->created_by == 0 || empty($table->created_by))
|
||||
{
|
||||
$table->created_by = $user->id;
|
||||
}
|
||||
// Set ordering to the last item if not set
|
||||
if (empty($table->ordering))
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('MAX(ordering)')
|
||||
->from($db->quoteName('#__costbenefitprojection_intervention'));
|
||||
$db->setQuery($query);
|
||||
$max = $db->loadResult();
|
||||
|
||||
$table->ordering = $max + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->modified = $date->toSql();
|
||||
$table->modified_by = $user->id;
|
||||
}
|
||||
|
||||
if (!empty($table->id))
|
||||
{
|
||||
// Increment the items version number.
|
||||
$table->version++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data that should be injected in the form.
|
||||
*
|
||||
* @return mixed The data for the form.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function loadFormData()
|
||||
{
|
||||
// Check the session for previously entered form data.
|
||||
$data = JFactory::getApplication()->getUserState('com_costbenefitprojection.edit.intervention.data', array());
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
$data = $this->getItem();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to validate the form data.
|
||||
*
|
||||
* @param JForm $form The form to validate against.
|
||||
* @param array $data The data to validate.
|
||||
* @param string $group The name of the field group to validate.
|
||||
*
|
||||
* @return mixed Array of filtered data if valid, false otherwise.
|
||||
*
|
||||
* @see JFormRule
|
||||
* @see JFilterInput
|
||||
* @since 12.2
|
||||
*/
|
||||
public function validate($form, $data, $group = null)
|
||||
{
|
||||
// check if the not_required field is set
|
||||
if (CostbenefitprojectionHelper::checkString($data['not_required']))
|
||||
{
|
||||
$requiredFields = (array) explode(',',(string) $data['not_required']);
|
||||
$requiredFields = array_unique($requiredFields);
|
||||
// now change the required field attributes value
|
||||
foreach ($requiredFields as $requiredField)
|
||||
{
|
||||
// make sure there is a string value
|
||||
if (CostbenefitprojectionHelper::checkString($requiredField))
|
||||
{
|
||||
// change to false
|
||||
$form->setFieldAttribute($requiredField, 'required', 'false');
|
||||
// also clear the data set
|
||||
$data[$requiredField] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::validate($form, $data, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the unique fields of this table.
|
||||
*
|
||||
* @return mixed An array of field names, boolean false if none is set.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
protected function getUniqeFields()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to perform batch operations on an item or a set of items.
|
||||
*
|
||||
* @param array $commands An array of commands to perform.
|
||||
* @param array $pks An array of item ids.
|
||||
* @param array $contexts An array of item contexts.
|
||||
*
|
||||
* @return boolean Returns true on success, false on failure.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function batch($commands, $pks, $contexts)
|
||||
{
|
||||
// Sanitize ids.
|
||||
$pks = array_unique($pks);
|
||||
JArrayHelper::toInteger($pks);
|
||||
|
||||
// Remove any values of zero.
|
||||
if (array_search(0, $pks, true))
|
||||
{
|
||||
unset($pks[array_search(0, $pks, true)]);
|
||||
}
|
||||
|
||||
if (empty($pks))
|
||||
{
|
||||
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$done = false;
|
||||
|
||||
// Set some needed variables.
|
||||
$this->user = JFactory::getUser();
|
||||
$this->table = $this->getTable();
|
||||
$this->tableClassName = get_class($this->table);
|
||||
$this->contentType = new JUcmType;
|
||||
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
|
||||
$this->canDo = CostbenefitprojectionHelper::getActions('intervention');
|
||||
$this->batchSet = true;
|
||||
|
||||
if (!$this->canDo->get('core.batch'))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->type == false)
|
||||
{
|
||||
$type = new JUcmType;
|
||||
$this->type = $type->getTypeByAlias($this->typeAlias);
|
||||
}
|
||||
|
||||
$this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags');
|
||||
|
||||
if (!empty($commands['move_copy']))
|
||||
{
|
||||
$cmd = JArrayHelper::getValue($commands, 'move_copy', 'c');
|
||||
|
||||
if ($cmd == 'c')
|
||||
{
|
||||
$result = $this->batchCopy($commands, $pks, $contexts);
|
||||
|
||||
if (is_array($result))
|
||||
{
|
||||
foreach ($result as $old => $new)
|
||||
{
|
||||
$contexts[$new] = $contexts[$old];
|
||||
}
|
||||
$pks = array_values($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$done = true;
|
||||
}
|
||||
|
||||
if (!$done)
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear the cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch copy items to a new category or current.
|
||||
*
|
||||
* @param integer $values The new values.
|
||||
* @param array $pks An array of row IDs.
|
||||
* @param array $contexts An array of item contexts.
|
||||
*
|
||||
* @return mixed An array of new IDs on success, boolean false on failure.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function batchCopy($values, $pks, $contexts)
|
||||
{
|
||||
if (empty($this->batchSet))
|
||||
{
|
||||
// Set some needed variables.
|
||||
$this->user = JFactory::getUser();
|
||||
$this->table = $this->getTable();
|
||||
$this->tableClassName = get_class($this->table);
|
||||
$this->contentType = new JUcmType;
|
||||
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
|
||||
$this->canDo = CostbenefitprojectionHelper::getActions('intervention');
|
||||
}
|
||||
|
||||
if (!$this->canDo->get('intervention.create') && !$this->canDo->get('intervention.batch'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// set company array
|
||||
$company = array();
|
||||
foreach ($pks as $nr => $pk)
|
||||
{
|
||||
$company[$pk] = CostbenefitprojectionHelper::getId('intervention',$pk,'id','company');
|
||||
// check based on sharing option
|
||||
if (!CostbenefitprojectionHelper::checkIntervetionAccess($pk,null,$company))
|
||||
{
|
||||
unset($pks[$nr]);
|
||||
}
|
||||
}
|
||||
if (empty($pks))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
return false;
|
||||
}
|
||||
// admin can all
|
||||
if (!$this->user->authorise('core.options', 'com_costbenefitprojection'))
|
||||
{
|
||||
// make absolutely sure that this intervention can be copied
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($this->user->id);
|
||||
if (CostbenefitprojectionHelper::checkArray($companies))
|
||||
{
|
||||
foreach ($pks as $nr => $pk)
|
||||
{
|
||||
if (!in_array($company[$pk],$companies))
|
||||
{
|
||||
unset($pks[$nr]);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($pks))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// get list of uniqe fields
|
||||
$uniqeFields = $this->getUniqeFields();
|
||||
// remove move_copy from array
|
||||
unset($values['move_copy']);
|
||||
|
||||
// make sure published is set
|
||||
if (!isset($values['published']))
|
||||
{
|
||||
$values['published'] = 0;
|
||||
}
|
||||
elseif (isset($values['published']) && !$this->canDo->get('intervention.edit.state'))
|
||||
{
|
||||
$values['published'] = 0;
|
||||
}
|
||||
|
||||
$newIds = array();
|
||||
|
||||
// Parent exists so let's proceed
|
||||
while (!empty($pks))
|
||||
{
|
||||
// Pop the first ID off the stack
|
||||
$pk = array_shift($pks);
|
||||
|
||||
$this->table->reset();
|
||||
|
||||
// only allow copy if user may edit this item.
|
||||
|
||||
if (!$this->user->authorise('intervention.edit', $contexts[$pk]))
|
||||
|
||||
{
|
||||
|
||||
// Not fatal error
|
||||
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// Check that the row actually exists
|
||||
if (!$this->table->load($pk))
|
||||
{
|
||||
if ($error = $this->table->getError())
|
||||
{
|
||||
// Fatal error
|
||||
$this->setError($error);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not fatal error
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->table->name = $this->generateUniqe('name',$this->table->name);
|
||||
|
||||
// insert all set values
|
||||
if (CostbenefitprojectionHelper::checkArray($values))
|
||||
{
|
||||
foreach ($values as $key => $value)
|
||||
{
|
||||
if (strlen($value) > 0 && isset($this->table->$key))
|
||||
{
|
||||
$this->table->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update all uniqe fields
|
||||
if (CostbenefitprojectionHelper::checkArray($uniqeFields))
|
||||
{
|
||||
foreach ($uniqeFields as $uniqeField)
|
||||
{
|
||||
$this->table->$uniqeField = $this->generateUniqe($uniqeField,$this->table->$uniqeField);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the ID because we are making a copy
|
||||
$this->table->id = 0;
|
||||
|
||||
// TODO: Deal with ordering?
|
||||
// $this->table->ordering = 1;
|
||||
|
||||
// Check the row.
|
||||
if (!$this->table->check())
|
||||
{
|
||||
$this->setError($this->table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($this->type))
|
||||
{
|
||||
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
|
||||
}
|
||||
|
||||
// Store the row.
|
||||
if (!$this->table->store())
|
||||
{
|
||||
$this->setError($this->table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the new item ID
|
||||
$newId = $this->table->get('id');
|
||||
|
||||
// Add the new ID to the array
|
||||
$newIds[$pk] = $newId;
|
||||
}
|
||||
|
||||
// Clean the cache
|
||||
$this->cleanCache();
|
||||
|
||||
return $newIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch move items to a new category
|
||||
*
|
||||
* @param integer $value The new category ID.
|
||||
* @param array $pks An array of row IDs.
|
||||
* @param array $contexts An array of item contexts.
|
||||
*
|
||||
* @return boolean True if successful, false otherwise and internal error is set.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function batchMove($values, $pks, $contexts)
|
||||
{
|
||||
if (empty($this->batchSet))
|
||||
{
|
||||
// Set some needed variables.
|
||||
$this->user = JFactory::getUser();
|
||||
$this->table = $this->getTable();
|
||||
$this->tableClassName = get_class($this->table);
|
||||
$this->contentType = new JUcmType;
|
||||
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
|
||||
$this->canDo = CostbenefitprojectionHelper::getActions('intervention');
|
||||
}
|
||||
|
||||
if (!$this->canDo->get('intervention.edit') && !$this->canDo->get('intervention.batch'))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
return false;
|
||||
}
|
||||
|
||||
// set company array
|
||||
$company = array();
|
||||
foreach ($pks as $nr => $pk)
|
||||
{
|
||||
$company[$pk] = CostbenefitprojectionHelper::getId('intervention',$pk,'id','company');
|
||||
// check based on sharing option
|
||||
if (!CostbenefitprojectionHelper::checkIntervetionAccess($pk,null,$company[$pk]))
|
||||
{
|
||||
unset($pks[$nr]);
|
||||
}
|
||||
}
|
||||
if (empty($pks))
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', 0));
|
||||
return false;
|
||||
}
|
||||
// admin can all
|
||||
if (!$this->user->authorise('core.options', 'com_costbenefitprojection'))
|
||||
{
|
||||
// make absolutely sure that this intervention can be moved
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($this->user->id);
|
||||
if (CostbenefitprojectionHelper::checkArray($companies))
|
||||
{
|
||||
foreach ($pks as $nr => $pk)
|
||||
{
|
||||
if (!in_array($company[$pk],$companies))
|
||||
{
|
||||
unset($pks[$nr]);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($pks))
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', 0));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', 0));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure published only updates if user has the permission.
|
||||
if (isset($values['published']) && !$this->canDo->get('intervention.edit.state'))
|
||||
{
|
||||
unset($values['published']);
|
||||
}
|
||||
// remove move_copy from array
|
||||
unset($values['move_copy']);
|
||||
|
||||
// Parent exists so we proceed
|
||||
foreach ($pks as $pk)
|
||||
{
|
||||
if (!$this->user->authorise('intervention.edit', $contexts[$pk]))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that the row actually exists
|
||||
if (!$this->table->load($pk))
|
||||
{
|
||||
if ($error = $this->table->getError())
|
||||
{
|
||||
// Fatal error
|
||||
$this->setError($error);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not fatal error
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// insert all set values.
|
||||
if (CostbenefitprojectionHelper::checkArray($values))
|
||||
{
|
||||
foreach ($values as $key => $value)
|
||||
{
|
||||
// Do special action for access.
|
||||
if ('access' == $key && strlen($value) > 0)
|
||||
{
|
||||
$this->table->$key = $value;
|
||||
}
|
||||
elseif (strlen($value) > 0 && isset($this->table->$key))
|
||||
{
|
||||
$this->table->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check the row.
|
||||
if (!$this->table->check())
|
||||
{
|
||||
$this->setError($this->table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($this->type))
|
||||
{
|
||||
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
|
||||
}
|
||||
|
||||
// Store the row.
|
||||
if (!$this->table->store())
|
||||
{
|
||||
$this->setError($this->table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean the cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the form data.
|
||||
*
|
||||
* @param array $data The form data.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
$input = JFactory::getApplication()->input;
|
||||
$filter = JFilterInput::getInstance();
|
||||
|
||||
// set the metadata to the Item Data
|
||||
if (isset($data['metadata']) && isset($data['metadata']['author']))
|
||||
{
|
||||
$data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
|
||||
|
||||
$metadata = new JRegistry;
|
||||
$metadata->loadArray($data['metadata']);
|
||||
$data['metadata'] = (string) $metadata;
|
||||
}
|
||||
|
||||
// Set the interventions string to JSON string.
|
||||
if (isset($data['interventions']))
|
||||
{
|
||||
$data['interventions'] = (string) json_encode($data['interventions']);
|
||||
}
|
||||
|
||||
// Set the Params Items to data
|
||||
if (isset($data['params']) && is_array($data['params']))
|
||||
{
|
||||
$params = new JRegistry;
|
||||
$params->loadArray($data['params']);
|
||||
$data['params'] = (string) $params;
|
||||
}
|
||||
|
||||
// Alter the uniqe field for save as copy
|
||||
if ($input->get('task') == 'save2copy')
|
||||
{
|
||||
// Automatic handling of other uniqe fields
|
||||
$uniqeFields = $this->getUniqeFields();
|
||||
if (CostbenefitprojectionHelper::checkArray($uniqeFields))
|
||||
{
|
||||
foreach ($uniqeFields as $uniqeField)
|
||||
{
|
||||
$data[$uniqeField] = $this->generateUniqe($uniqeField,$data[$uniqeField]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parent::save($data))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate a uniqe value.
|
||||
*
|
||||
* @param string $field name.
|
||||
* @param string $value data.
|
||||
*
|
||||
* @return string New value.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
protected function generateUniqe($field,$value)
|
||||
{
|
||||
|
||||
// set field value uniqe
|
||||
$table = $this->getTable();
|
||||
|
||||
while ($table->load(array($field => $value)))
|
||||
{
|
||||
$value = JString::increment($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to change the title & alias.
|
||||
*
|
||||
* @param string $title The title.
|
||||
*
|
||||
* @return array Contains the modified title and alias.
|
||||
*
|
||||
*/
|
||||
protected function _generateNewTitle($title)
|
||||
{
|
||||
|
||||
// Alter the title
|
||||
$table = $this->getTable();
|
||||
|
||||
while ($table->load(array('title' => $title)))
|
||||
{
|
||||
$title = JString::increment($title);
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
}
|
@@ -0,0 +1,534 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage publicresults.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import Joomla modelitem library
|
||||
jimport('joomla.application.component.modelitem');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Publicresults Model
|
||||
*/
|
||||
class CostbenefitprojectionModelPublicresults extends JModelItem
|
||||
{
|
||||
/**
|
||||
* Model context string.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_context = 'com_costbenefitprojection.publicresults';
|
||||
|
||||
/**
|
||||
* Model user data.
|
||||
*
|
||||
* @var strings
|
||||
*/
|
||||
protected $user;
|
||||
protected $userId;
|
||||
protected $guest;
|
||||
protected $groups;
|
||||
protected $levels;
|
||||
protected $app;
|
||||
protected $input;
|
||||
protected $uikitComp;
|
||||
|
||||
/**
|
||||
* @var object item
|
||||
*/
|
||||
protected $item;
|
||||
|
||||
/**
|
||||
* Method to auto-populate the model state.
|
||||
*
|
||||
* Note. Calling getState in this method will result in recursion.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function populateState()
|
||||
{
|
||||
$this->app = JFactory::getApplication();
|
||||
$this->input = $this->app->input;
|
||||
// Get the itme main id
|
||||
$id = $this->input->getInt('id', null);
|
||||
$this->setState('publicresults.id', $id);
|
||||
|
||||
// Load the parameters.
|
||||
$params = $this->app->getParams();
|
||||
$this->setState('params', $params);
|
||||
parent::populateState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get article data.
|
||||
*
|
||||
* @param integer $pk The id of the article.
|
||||
*
|
||||
* @return mixed Menu item data object on success, false on failure.
|
||||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
$this->user = JFactory::getUser();
|
||||
// check if this user has permission to access item
|
||||
if (!$this->user->authorise('site.publicresults.access', 'com_costbenefitprojection'))
|
||||
{
|
||||
JError::raiseWarning(500, JText::_('Not authorised!'));
|
||||
// redirect away if not a correct (TODO for now we go to default view)
|
||||
JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_costbenefitprojection&view=cpanel'));
|
||||
return false;
|
||||
}
|
||||
$this->userId = $this->user->get('id');
|
||||
$this->guest = $this->user->get('guest');
|
||||
$this->groups = $this->user->get('groups');
|
||||
$this->authorisedGroups = $this->user->getAuthorisedGroups();
|
||||
$this->levels = $this->user->getAuthorisedViewLevels();
|
||||
$this->initSet = true;
|
||||
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('publicresults.id');
|
||||
|
||||
if (!$pk)
|
||||
{
|
||||
JError::raiseWarning(500, JText::_('No Direct Access Allowed!'));
|
||||
// redirect away if not a correct (TODO for now we go to default view)
|
||||
JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection&view=cpanel');
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->_item === null)
|
||||
{
|
||||
$this->_item = array();
|
||||
}
|
||||
|
||||
if (!isset($this->_item[$pk]))
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_country as a
|
||||
$query->select($db->quoteName(
|
||||
array('a.id','a.currency','a.datayear','a.percentmale','a.percentfemale','a.causesrisks','a.published'),
|
||||
array('country','currency','datayear','percentmale','percentfemale','causesrisks','published')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_country', 'a'));
|
||||
|
||||
// Get from #__costbenefitprojection_country as e
|
||||
$query->select($db->quoteName(
|
||||
array('e.id','e.name','e.alias','e.user','e.currency','e.datayear','e.worldzone','e.codethree','e.codetwo','e.working_days','e.presenteeism','e.medical_turnovers','e.sick_leave','e.healthcare','e.productivity_losses','e.publicname','e.publicemail','e.publicnumber','e.publicaddress','e.percentmale','e.percentfemale','e.causesrisks','e.maledeath','e.femaledeath','e.maleyld','e.femaleyld','e.access'),
|
||||
array('country_id','country_name','country_alias','country_user','country_currency','country_datayear','country_worldzone','country_codethree','country_codetwo','country_working_days','country_presenteeism','country_medical_turnovers','country_sick_leave','country_healthcare','country_productivity_losses','country_publicname','country_publicemail','country_publicnumber','country_publicaddress','country_percentmale','country_percentfemale','country_causesrisks','country_maledeath','country_femaledeath','country_maleyld','country_femaleyld','country_access')));
|
||||
$query->join('LEFT', ($db->quoteName('#__costbenefitprojection_country', 'e')) . ' ON (' . $db->quoteName('a.id') . ' = ' . $db->quoteName('e.id') . ')');
|
||||
|
||||
// Get from #__costbenefitprojection_currency as f
|
||||
$query->select($db->quoteName(
|
||||
array('f.id','f.name','f.alias','f.codethree','f.numericcode','f.symbol','f.thousands','f.decimalplace','f.decimalsymbol','f.positivestyle','f.negativestyle','f.published','f.access','f.ordering'),
|
||||
array('currency_id','currency_name','currency_alias','currency_codethree','currency_numericcode','currency_symbol','currency_thousands','currency_decimalplace','currency_decimalsymbol','currency_positivestyle','currency_negativestyle','currency_published','currency_access','currency_ordering')));
|
||||
$query->join('LEFT', ($db->quoteName('#__costbenefitprojection_currency', 'f')) . ' ON (' . $db->quoteName('e.currency') . ' = ' . $db->quoteName('f.codethree') . ')');
|
||||
$query->where('a.id = ' . (int) $pk);
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
// Load the results as a stdClass object.
|
||||
$data = $db->loadObject();
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
// If no data is found redirect to default page and show warning.
|
||||
JError::raiseWarning(500, JText::_('COM_COSTBENEFITPROJECTION_NOT_FOUND_OR_ACCESS_DENIED'));
|
||||
JFactory::getApplication()->redirect('index.php?option=com_costbenefitprojection&view=cpanel');
|
||||
return false;
|
||||
}
|
||||
if (CostbenefitprojectionHelper::checkString($data->country_causesrisks))
|
||||
{
|
||||
// Decode country_causesrisks
|
||||
$data->country_causesrisks = json_decode($data->country_causesrisks, true);
|
||||
}
|
||||
// Make sure the content prepare plugins fire on country_publicaddress.
|
||||
$data->country_publicaddress = JHtml::_('content.prepare',$data->country_publicaddress);
|
||||
// Checking if country_publicaddress has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($data->country_publicaddress,$this->uikitComp);
|
||||
// set the global causesrisks value.
|
||||
$this->a_causesrisks = $data->causesrisks;
|
||||
// set the global datayear value.
|
||||
$this->a_datayear = $data->datayear;
|
||||
// set the global datayear value.
|
||||
$this->e_datayear = $data->country_datayear;
|
||||
// set the global causesrisks value.
|
||||
$this->e_causesrisks = $data->country_causesrisks;
|
||||
// set idCountryHealth_dataB to the $data object.
|
||||
$data->idCountryHealth_dataB = $this->getIdCountryHealth_dataDadd_B($data->country);
|
||||
// set causesrisksIdCauseriskG to the $data object.
|
||||
$data->causesrisksIdCauseriskG = $this->getCausesrisksIdCauseriskDadd_G($data->causesrisks);
|
||||
// set idCountryHealth_dataBB to the $data object.
|
||||
$data->idCountryHealth_dataBB = $this->getIdCountryHealth_dataDadd_BB($data->country);
|
||||
// set causesrisksIdCauseriskGG to the $data object.
|
||||
$data->causesrisksIdCauseriskGG = $this->getCausesrisksIdCauseriskDadd_GG($data->country_causesrisks);
|
||||
// set idCountryInterventionDD to the $data object.
|
||||
$data->idCountryInterventionDD = $this->getIdCountryInterventionDadd_DD($data->country);
|
||||
|
||||
// set data object to item.
|
||||
$this->_item[$pk] = $data;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
if ($e->getCode() == 404)
|
||||
{
|
||||
// Need to go thru the error handler to allow Redirect to work.
|
||||
JError::raiseError(404, $e->getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError($e);
|
||||
$this->_item[$pk] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the sum class knows this is a public request
|
||||
$this->_item[$pk]->id = 0;
|
||||
$this->_item[$pk]->public = true;
|
||||
// set the male/female number
|
||||
$employees = $this->input->get('employees', 0, 'INT');
|
||||
if ($employees)
|
||||
{
|
||||
$this->_item[$pk]->males = round($employees / 2);
|
||||
$this->_item[$pk]->females = round($employees / 2);
|
||||
}
|
||||
// set total salary
|
||||
$this->_item[$pk]->total_salary = $this->input->get('salary', 0, 'INT');
|
||||
|
||||
return $this->_item[$pk];
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Health_data Objects.
|
||||
*
|
||||
* @return mixed An array of Health_data Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getIdCountryHealth_dataDadd_B($id)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_health_data as b
|
||||
$query->select($db->quoteName(
|
||||
array('b.id','b.causerisk','b.year','b.maledeath','b.maleyld','b.femaledeath','b.femaleyld','b.published'),
|
||||
array('id','causerisk','year','maledeath','maleyld','femaledeath','femaleyld','published')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_health_data', 'b'));
|
||||
$query->where('b.country = ' . $db->quote($id));
|
||||
// Check if $this->a_causesrisks is an array with values.
|
||||
$array = $this->a_causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('b.causerisk IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$query->where('b.published = 1');
|
||||
$query->where('b.year = ' . $db->quote($this->a_datayear));
|
||||
$query->order('b.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Causerisk Objects.
|
||||
*
|
||||
* @return mixed An array of Causerisk Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCausesrisksIdCauseriskDadd_G($causesrisks)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_causerisk as g
|
||||
$query->select($db->quoteName(
|
||||
array('g.id','g.name','g.ref','g.alias','g.description'),
|
||||
array('id','name','ref','alias','description')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_causerisk', 'g'));
|
||||
|
||||
// Check if $causesrisks is an array with values.
|
||||
$array = $causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('g.id IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Health_data Objects.
|
||||
*
|
||||
* @return mixed An array of Health_data Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getIdCountryHealth_dataDadd_BB($id)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_health_data as bb
|
||||
$query->select($db->quoteName(
|
||||
array('bb.id','bb.asset_id','bb.causerisk','bb.year','bb.country','bb.maledeath','bb.maleyld','bb.femaledeath','bb.femaleyld','bb.published','bb.created_by','bb.modified_by','bb.created','bb.modified','bb.version','bb.hits','bb.ordering'),
|
||||
array('id','asset_id','causerisk','year','country','maledeath','maleyld','femaledeath','femaleyld','published','created_by','modified_by','created','modified','version','hits','ordering')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_health_data', 'bb'));
|
||||
$query->where('bb.country = ' . $db->quote($id));
|
||||
// Check if $this->e_causesrisks is an array with values.
|
||||
$array = $this->e_causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('bb.causerisk IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$query->where('bb.published = 1');
|
||||
$query->where('bb.year = ' . $db->quote($this->e_datayear));
|
||||
$query->order('bb.ordering ASC');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadObjectList();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Causerisk Objects.
|
||||
*
|
||||
* @return mixed An array of Causerisk Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCausesrisksIdCauseriskDadd_GG($causesrisks)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_causerisk as gg
|
||||
$query->select($db->quoteName(
|
||||
array('gg.id','gg.name','gg.ref','gg.alias','gg.description'),
|
||||
array('id','name','ref','alias','description')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_causerisk', 'gg'));
|
||||
|
||||
// Check if $causesrisks is an array with values.
|
||||
$array = $causesrisks;
|
||||
if (isset($array) && CostbenefitprojectionHelper::checkArray($array))
|
||||
{
|
||||
$query->where('gg.id IN (' . implode(',', $array) . ')');
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Make sure the content prepare plugins fire on description.
|
||||
$item->description = JHtml::_('content.prepare',$item->description);
|
||||
// Checking if description has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->description,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get an array of Intervention Objects.
|
||||
*
|
||||
* @return mixed An array of Intervention Objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getIdCountryInterventionDadd_DD($id)
|
||||
{
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_intervention as dd
|
||||
$query->select($db->quoteName(
|
||||
array('dd.id','dd.name','dd.type','dd.coverage','dd.duration','dd.share','dd.description','dd.reference','dd.interventions','dd.intervention','dd.published','dd.created_by','dd.modified_by','dd.created','dd.modified'),
|
||||
array('id','name','type','coverage','duration','share','description','reference','interventions','intervention','published','created_by','modified_by','created','modified')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_intervention', 'dd'));
|
||||
$query->where('dd.country = ' . $db->quote($id));
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
// check if there was data returned
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
if (CostbenefitprojectionHelper::checkString($item->interventions))
|
||||
{
|
||||
// Decode interventions
|
||||
$item->interventions = json_decode($item->interventions, true);
|
||||
}
|
||||
// Make sure the content prepare plugins fire on description.
|
||||
$item->description = JHtml::_('content.prepare',$item->description);
|
||||
// Checking if description has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->description,$this->uikitComp);
|
||||
// Make sure the content prepare plugins fire on reference.
|
||||
$item->reference = JHtml::_('content.prepare',$item->reference);
|
||||
// Checking if reference has uikit components that must be loaded.
|
||||
$this->uikitComp = CostbenefitprojectionHelper::getUikitComp($item->reference,$this->uikitComp);
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Custom Method
|
||||
*
|
||||
* @return mixed An array of objects on success, false on failure.
|
||||
*
|
||||
*/
|
||||
public function getCountries()
|
||||
{
|
||||
|
||||
if (!isset($this->initSet) || !$this->initSet)
|
||||
{
|
||||
$this->user = JFactory::getUser();
|
||||
$this->userId = $this->user->get('id');
|
||||
$this->guest = $this->user->get('guest');
|
||||
$this->groups = $this->user->get('groups');
|
||||
$this->authorisedGroups = $this->user->getAuthorisedGroups();
|
||||
$this->levels = $this->user->getAuthorisedViewLevels();
|
||||
$this->initSet = true;
|
||||
}
|
||||
|
||||
// Get the global params
|
||||
$globalParams = JComponentHelper::getParams('com_costbenefitprojection', true);
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Get from #__costbenefitprojection_country as a
|
||||
$query->select($db->quoteName(
|
||||
array('a.id','a.name','a.published'),
|
||||
array('id','name','published')));
|
||||
$query->from($db->quoteName('#__costbenefitprojection_country', 'a'));
|
||||
$query->where('a.published = 1');
|
||||
$query->where('a.datayear > 2000');
|
||||
|
||||
// Reset the query using our newly populated query object.
|
||||
$db->setQuery($query);
|
||||
$items = $db->loadObjectList();
|
||||
|
||||
if (empty($items))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Convert the parameter fields into objects.
|
||||
foreach ($items as $nr => &$item)
|
||||
{
|
||||
// Always create a slug for sef URL's
|
||||
$item->slug = (isset($item->alias)) ? $item->id.':'.$item->alias : $item->id;
|
||||
}
|
||||
// return items
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the uikit needed components
|
||||
*
|
||||
* @return mixed An array of objects on success.
|
||||
*
|
||||
*/
|
||||
public function getUikitComp()
|
||||
{
|
||||
if (isset($this->uikitComp) && CostbenefitprojectionHelper::checkArray($this->uikitComp))
|
||||
{
|
||||
return $this->uikitComp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,919 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage scaling_factor.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// import Joomla modelform library
|
||||
jimport('joomla.application.component.modeladmin');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection Scaling_factor Model
|
||||
*/
|
||||
class CostbenefitprojectionModelScaling_factor extends JModelAdmin
|
||||
{
|
||||
/**
|
||||
* @var string The prefix to use with controller messages.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected $text_prefix = 'COM_COSTBENEFITPROJECTION';
|
||||
|
||||
/**
|
||||
* The type alias for this content type.
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2
|
||||
*/
|
||||
public $typeAlias = 'com_costbenefitprojection.scaling_factor';
|
||||
|
||||
/**
|
||||
* Returns a Table object, always creating it
|
||||
*
|
||||
* @param type $type The table type to instantiate
|
||||
* @param string $prefix A prefix for the table class name. Optional.
|
||||
* @param array $config Configuration array for model. Optional.
|
||||
*
|
||||
* @return JTable A database object
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getTable($type = 'scaling_factor', $prefix = 'CostbenefitprojectionTable', $config = array())
|
||||
{
|
||||
return JTable::getInstance($type, $prefix, $config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get a single record.
|
||||
*
|
||||
* @param integer $pk The id of the primary key.
|
||||
*
|
||||
* @return mixed Object on success, false on failure.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getItem($pk = null)
|
||||
{
|
||||
if ($item = parent::getItem($pk))
|
||||
{
|
||||
if (!empty($item->params))
|
||||
{
|
||||
// Convert the params field to an array.
|
||||
$registry = new Registry;
|
||||
$registry->loadString($item->params);
|
||||
$item->params = $registry->toArray();
|
||||
}
|
||||
|
||||
if (!empty($item->metadata))
|
||||
{
|
||||
// Convert the metadata field to an array.
|
||||
$registry = new Registry;
|
||||
$registry->loadString($item->metadata);
|
||||
$item->metadata = $registry->toArray();
|
||||
}
|
||||
|
||||
if (!empty($item->id))
|
||||
{
|
||||
$item->tags = new JHelperTags;
|
||||
$item->tags->getTagIds($item->id, 'com_costbenefitprojection.scaling_factor');
|
||||
}
|
||||
}
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the record form.
|
||||
*
|
||||
* @param array $data Data for the form.
|
||||
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||
*
|
||||
* @return mixed A JForm object on success, false on failure
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function getForm($data = array(), $loadData = true)
|
||||
{ // Get the form.
|
||||
$form = $this->loadForm('com_costbenefitprojection.scaling_factor', 'scaling_factor', array('control' => 'jform', 'load_data' => $loadData));
|
||||
|
||||
if (empty($form))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$jinput = JFactory::getApplication()->input;
|
||||
|
||||
// The front end calls this model and uses a_id to avoid id clashes so we need to check for that first.
|
||||
if ($jinput->get('a_id'))
|
||||
{
|
||||
$id = $jinput->get('a_id', 0, 'INT');
|
||||
}
|
||||
// The back end uses id so we use that the rest of the time and set it to 0 by default.
|
||||
else
|
||||
{
|
||||
$id = $jinput->get('id', 0, 'INT');
|
||||
}
|
||||
|
||||
$user = JFactory::getUser();
|
||||
|
||||
// Check for existing item.
|
||||
// Modify the form based on Edit State access controls.
|
||||
if ($id != 0 && (!$user->authorise('scaling_factor.edit.state', 'com_costbenefitprojection.scaling_factor.' . (int) $id))
|
||||
|| ($id == 0 && !$user->authorise('scaling_factor.edit.state', 'com_costbenefitprojection')))
|
||||
{
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('ordering', 'disabled', 'true');
|
||||
$form->setFieldAttribute('published', 'disabled', 'true');
|
||||
// Disable fields while saving.
|
||||
$form->setFieldAttribute('ordering', 'filter', 'unset');
|
||||
$form->setFieldAttribute('published', 'filter', 'unset');
|
||||
}
|
||||
// If this is a new item insure the greated by is set.
|
||||
if (0 == $id)
|
||||
{
|
||||
// Set the created_by to this user
|
||||
$form->setValue('created_by', null, $user->id);
|
||||
}
|
||||
// Modify the form based on Edit Creaded By access controls.
|
||||
if (!$user->authorise('core.edit.created_by', 'com_costbenefitprojection'))
|
||||
{
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('created_by', 'disabled', 'true');
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('created_by', 'readonly', 'true');
|
||||
// Disable fields while saving.
|
||||
$form->setFieldAttribute('created_by', 'filter', 'unset');
|
||||
}
|
||||
// Modify the form based on Edit Creaded Date access controls.
|
||||
if (!$user->authorise('core.edit.created', 'com_costbenefitprojection'))
|
||||
{
|
||||
// Disable fields for display.
|
||||
$form->setFieldAttribute('created', 'disabled', 'true');
|
||||
// Disable fields while saving.
|
||||
$form->setFieldAttribute('created', 'filter', 'unset');
|
||||
}
|
||||
// Only load these values if no id is found
|
||||
if (0 == $id)
|
||||
{
|
||||
// Set redirected field name
|
||||
$redirectedField = $jinput->get('ref', null, 'STRING');
|
||||
// Set redirected field value
|
||||
$redirectedValue = $jinput->get('refid', 0, 'INT');
|
||||
if (0 != $redirectedValue && $redirectedField)
|
||||
{
|
||||
// Now set the local-redirected field default value
|
||||
$form->setValue($redirectedField, null, $redirectedValue);
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the script that have to be included on the form
|
||||
*
|
||||
* @return string script files
|
||||
*/
|
||||
public function getScript()
|
||||
{
|
||||
return 'administrator/components/com_costbenefitprojection/models/forms/scaling_factor.js';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can be deleted.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function canDelete($record)
|
||||
{
|
||||
if (!empty($record->id))
|
||||
{
|
||||
if ($record->published != -2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$user = JFactory::getUser();
|
||||
// The record has been set. Check the record permissions.
|
||||
return $user->authorise('scaling_factor.delete', 'com_costbenefitprojection.scaling_factor.' . (int) $record->id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to test whether a record can have its state edited.
|
||||
*
|
||||
* @param object $record A record object.
|
||||
*
|
||||
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function canEditState($record)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$recordId = (!empty($record->id)) ? $record->id : 0;
|
||||
|
||||
if ($recordId)
|
||||
{
|
||||
// The record has been set. Check the record permissions.
|
||||
$permission = $user->authorise('scaling_factor.edit.state', 'com_costbenefitprojection.scaling_factor.' . (int) $recordId);
|
||||
if (!$permission && !is_null($permission))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// In the absense of better information, revert to the component permissions.
|
||||
return $user->authorise('scaling_factor.edit.state', 'com_costbenefitprojection');
|
||||
}
|
||||
|
||||
/**
|
||||
* Method override to check if you can edit an existing record.
|
||||
*
|
||||
* @param array $data An array of input data.
|
||||
* @param string $key The name of the key for the primary key.
|
||||
*
|
||||
* @return boolean
|
||||
* @since 2.5
|
||||
*/
|
||||
protected function allowEdit($data = array(), $key = 'id')
|
||||
{
|
||||
// Check specific edit permission then general edit permission.
|
||||
$user = JFactory::getUser();
|
||||
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||
if (!$user->authorise('core.options', 'com_costbenefitprojection'))
|
||||
{
|
||||
// make absolutely sure that this scaling factor can be edited
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($user->id);
|
||||
$company = CostbenefitprojectionHelper::getId('scaling_factor',$recordId,'id','company');
|
||||
if (!CostbenefitprojectionHelper::checkArray($companies) || !in_array($company,$companies))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $user->authorise('scaling_factor.edit', 'com_costbenefitprojection.scaling_factor.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('scaling_factor.edit', 'com_costbenefitprojection');
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare and sanitise the table data prior to saving.
|
||||
*
|
||||
* @param JTable $table A JTable object.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function prepareTable($table)
|
||||
{
|
||||
$date = JFactory::getDate();
|
||||
$user = JFactory::getUser();
|
||||
|
||||
if (isset($table->name))
|
||||
{
|
||||
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
|
||||
}
|
||||
|
||||
if (isset($table->alias) && empty($table->alias))
|
||||
{
|
||||
$table->generateAlias();
|
||||
}
|
||||
|
||||
if (empty($table->id))
|
||||
{
|
||||
$table->created = $date->toSql();
|
||||
// set the user
|
||||
if ($table->created_by == 0 || empty($table->created_by))
|
||||
{
|
||||
$table->created_by = $user->id;
|
||||
}
|
||||
// Set ordering to the last item if not set
|
||||
if (empty($table->ordering))
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('MAX(ordering)')
|
||||
->from($db->quoteName('#__costbenefitprojection_scaling_factor'));
|
||||
$db->setQuery($query);
|
||||
$max = $db->loadResult();
|
||||
|
||||
$table->ordering = $max + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->modified = $date->toSql();
|
||||
$table->modified_by = $user->id;
|
||||
}
|
||||
|
||||
if (!empty($table->id))
|
||||
{
|
||||
// Increment the items version number.
|
||||
$table->version++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the data that should be injected in the form.
|
||||
*
|
||||
* @return mixed The data for the form.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
protected function loadFormData()
|
||||
{
|
||||
// Check the session for previously entered form data.
|
||||
$data = JFactory::getApplication()->getUserState('com_costbenefitprojection.edit.scaling_factor.data', array());
|
||||
|
||||
if (empty($data))
|
||||
{
|
||||
$data = $this->getItem();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to validate the form data.
|
||||
*
|
||||
* @param JForm $form The form to validate against.
|
||||
* @param array $data The data to validate.
|
||||
* @param string $group The name of the field group to validate.
|
||||
*
|
||||
* @return mixed Array of filtered data if valid, false otherwise.
|
||||
*
|
||||
* @see JFormRule
|
||||
* @see JFilterInput
|
||||
* @since 12.2
|
||||
*/
|
||||
public function validate($form, $data, $group = null)
|
||||
{
|
||||
// check if the not_required field is set
|
||||
if (CostbenefitprojectionHelper::checkString($data['not_required']))
|
||||
{
|
||||
$requiredFields = (array) explode(',',(string) $data['not_required']);
|
||||
$requiredFields = array_unique($requiredFields);
|
||||
// now change the required field attributes value
|
||||
foreach ($requiredFields as $requiredField)
|
||||
{
|
||||
// make sure there is a string value
|
||||
if (CostbenefitprojectionHelper::checkString($requiredField))
|
||||
{
|
||||
// change to false
|
||||
$form->setFieldAttribute($requiredField, 'required', 'false');
|
||||
// also clear the data set
|
||||
$data[$requiredField] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
return parent::validate($form, $data, $group);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the unique fields of this table.
|
||||
*
|
||||
* @return mixed An array of field names, boolean false if none is set.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
protected function getUniqeFields()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to perform batch operations on an item or a set of items.
|
||||
*
|
||||
* @param array $commands An array of commands to perform.
|
||||
* @param array $pks An array of item ids.
|
||||
* @param array $contexts An array of item contexts.
|
||||
*
|
||||
* @return boolean Returns true on success, false on failure.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
public function batch($commands, $pks, $contexts)
|
||||
{
|
||||
// Sanitize ids.
|
||||
$pks = array_unique($pks);
|
||||
JArrayHelper::toInteger($pks);
|
||||
|
||||
// Remove any values of zero.
|
||||
if (array_search(0, $pks, true))
|
||||
{
|
||||
unset($pks[array_search(0, $pks, true)]);
|
||||
}
|
||||
|
||||
if (empty($pks))
|
||||
{
|
||||
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
|
||||
return false;
|
||||
}
|
||||
|
||||
$done = false;
|
||||
|
||||
// Set some needed variables.
|
||||
$this->user = JFactory::getUser();
|
||||
$this->table = $this->getTable();
|
||||
$this->tableClassName = get_class($this->table);
|
||||
$this->contentType = new JUcmType;
|
||||
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
|
||||
$this->canDo = CostbenefitprojectionHelper::getActions('scaling_factor');
|
||||
$this->batchSet = true;
|
||||
|
||||
if (!$this->canDo->get('core.batch'))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->type == false)
|
||||
{
|
||||
$type = new JUcmType;
|
||||
$this->type = $type->getTypeByAlias($this->typeAlias);
|
||||
}
|
||||
|
||||
$this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags');
|
||||
|
||||
if (!empty($commands['move_copy']))
|
||||
{
|
||||
$cmd = JArrayHelper::getValue($commands, 'move_copy', 'c');
|
||||
|
||||
if ($cmd == 'c')
|
||||
{
|
||||
$result = $this->batchCopy($commands, $pks, $contexts);
|
||||
|
||||
if (is_array($result))
|
||||
{
|
||||
foreach ($result as $old => $new)
|
||||
{
|
||||
$contexts[$new] = $contexts[$old];
|
||||
}
|
||||
$pks = array_values($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$done = true;
|
||||
}
|
||||
|
||||
if (!$done)
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clear the cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch copy items to a new category or current.
|
||||
*
|
||||
* @param integer $values The new values.
|
||||
* @param array $pks An array of row IDs.
|
||||
* @param array $contexts An array of item contexts.
|
||||
*
|
||||
* @return mixed An array of new IDs on success, boolean false on failure.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function batchCopy($values, $pks, $contexts)
|
||||
{
|
||||
if (empty($this->batchSet))
|
||||
{
|
||||
// Set some needed variables.
|
||||
$this->user = JFactory::getUser();
|
||||
$this->table = $this->getTable();
|
||||
$this->tableClassName = get_class($this->table);
|
||||
$this->contentType = new JUcmType;
|
||||
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
|
||||
$this->canDo = CostbenefitprojectionHelper::getActions('scaling_factor');
|
||||
}
|
||||
|
||||
if (!$this->canDo->get('scaling_factor.create') && !$this->canDo->get('scaling_factor.batch'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->user->authorise('core.options', 'com_costbenefitprojection'))
|
||||
{
|
||||
// make absolutely sure that this scaling factor can be copied
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($this->user->id);
|
||||
if (CostbenefitprojectionHelper::checkArray($companies))
|
||||
{
|
||||
foreach ($pks as $nr => $pk)
|
||||
{
|
||||
$company = CostbenefitprojectionHelper::getId('scaling_factor',$pk,'id','company');
|
||||
if (!in_array($company,$companies))
|
||||
{
|
||||
unset($pks[$nr]);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($pks))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// get list of uniqe fields
|
||||
$uniqeFields = $this->getUniqeFields();
|
||||
// remove move_copy from array
|
||||
unset($values['move_copy']);
|
||||
|
||||
// make sure published is set
|
||||
if (!isset($values['published']))
|
||||
{
|
||||
$values['published'] = 0;
|
||||
}
|
||||
elseif (isset($values['published']) && !$this->canDo->get('scaling_factor.edit.state'))
|
||||
{
|
||||
$values['published'] = 0;
|
||||
}
|
||||
|
||||
$newIds = array();
|
||||
|
||||
// Parent exists so let's proceed
|
||||
while (!empty($pks))
|
||||
{
|
||||
// Pop the first ID off the stack
|
||||
$pk = array_shift($pks);
|
||||
|
||||
$this->table->reset();
|
||||
|
||||
// only allow copy if user may edit this item.
|
||||
|
||||
if (!$this->user->authorise('scaling_factor.edit', $contexts[$pk]))
|
||||
|
||||
{
|
||||
|
||||
// Not fatal error
|
||||
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
// Check that the row actually exists
|
||||
if (!$this->table->load($pk))
|
||||
{
|
||||
if ($error = $this->table->getError())
|
||||
{
|
||||
// Fatal error
|
||||
$this->setError($error);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not fatal error
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->table->causerisk = $this->generateUniqe('causerisk',$this->table->causerisk);
|
||||
|
||||
// insert all set values
|
||||
if (CostbenefitprojectionHelper::checkArray($values))
|
||||
{
|
||||
foreach ($values as $key => $value)
|
||||
{
|
||||
if (strlen($value) > 0 && isset($this->table->$key))
|
||||
{
|
||||
$this->table->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// update all uniqe fields
|
||||
if (CostbenefitprojectionHelper::checkArray($uniqeFields))
|
||||
{
|
||||
foreach ($uniqeFields as $uniqeField)
|
||||
{
|
||||
$this->table->$uniqeField = $this->generateUniqe($uniqeField,$this->table->$uniqeField);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset the ID because we are making a copy
|
||||
$this->table->id = 0;
|
||||
|
||||
// TODO: Deal with ordering?
|
||||
// $this->table->ordering = 1;
|
||||
|
||||
// Check the row.
|
||||
if (!$this->table->check())
|
||||
{
|
||||
$this->setError($this->table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($this->type))
|
||||
{
|
||||
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
|
||||
}
|
||||
|
||||
// Store the row.
|
||||
if (!$this->table->store())
|
||||
{
|
||||
$this->setError($this->table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the new item ID
|
||||
$newId = $this->table->get('id');
|
||||
|
||||
// Add the new ID to the array
|
||||
$newIds[$pk] = $newId;
|
||||
}
|
||||
|
||||
// Clean the cache
|
||||
$this->cleanCache();
|
||||
|
||||
return $newIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch move items to a new category
|
||||
*
|
||||
* @param integer $value The new category ID.
|
||||
* @param array $pks An array of row IDs.
|
||||
* @param array $contexts An array of item contexts.
|
||||
*
|
||||
* @return boolean True if successful, false otherwise and internal error is set.
|
||||
*
|
||||
* @since 12.2
|
||||
*/
|
||||
protected function batchMove($values, $pks, $contexts)
|
||||
{
|
||||
if (empty($this->batchSet))
|
||||
{
|
||||
// Set some needed variables.
|
||||
$this->user = JFactory::getUser();
|
||||
$this->table = $this->getTable();
|
||||
$this->tableClassName = get_class($this->table);
|
||||
$this->contentType = new JUcmType;
|
||||
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
|
||||
$this->canDo = CostbenefitprojectionHelper::getActions('scaling_factor');
|
||||
}
|
||||
|
||||
if (!$this->canDo->get('scaling_factor.edit') && !$this->canDo->get('scaling_factor.batch'))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!$this->user->authorise('core.options', 'com_costbenefitprojection'))
|
||||
{
|
||||
// make absolutely sure that this scaling factor can be moved
|
||||
$companies = CostbenefitprojectionHelper::hisCompanies($this->user->id);
|
||||
if (CostbenefitprojectionHelper::checkArray($companies))
|
||||
{
|
||||
foreach ($pks as $nr => $pk)
|
||||
{
|
||||
$company = CostbenefitprojectionHelper::getId('scaling_factor',$pk,'id','company');
|
||||
if (!in_array($company,$companies))
|
||||
{
|
||||
unset($pks[$nr]);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($pks))
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', 0));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', 0));
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// make sure published only updates if user has the permission.
|
||||
if (isset($values['published']) && !$this->canDo->get('scaling_factor.edit.state'))
|
||||
{
|
||||
unset($values['published']);
|
||||
}
|
||||
// remove move_copy from array
|
||||
unset($values['move_copy']);
|
||||
|
||||
// Parent exists so we proceed
|
||||
foreach ($pks as $pk)
|
||||
{
|
||||
if (!$this->user->authorise('scaling_factor.edit', $contexts[$pk]))
|
||||
{
|
||||
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that the row actually exists
|
||||
if (!$this->table->load($pk))
|
||||
{
|
||||
if ($error = $this->table->getError())
|
||||
{
|
||||
// Fatal error
|
||||
$this->setError($error);
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not fatal error
|
||||
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// insert all set values.
|
||||
if (CostbenefitprojectionHelper::checkArray($values))
|
||||
{
|
||||
foreach ($values as $key => $value)
|
||||
{
|
||||
// Do special action for access.
|
||||
if ('access' == $key && strlen($value) > 0)
|
||||
{
|
||||
$this->table->$key = $value;
|
||||
}
|
||||
elseif (strlen($value) > 0 && isset($this->table->$key))
|
||||
{
|
||||
$this->table->$key = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Check the row.
|
||||
if (!$this->table->check())
|
||||
{
|
||||
$this->setError($this->table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!empty($this->type))
|
||||
{
|
||||
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
|
||||
}
|
||||
|
||||
// Store the row.
|
||||
if (!$this->table->store())
|
||||
{
|
||||
$this->setError($this->table->getError());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean the cache
|
||||
$this->cleanCache();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save the form data.
|
||||
*
|
||||
* @param array $data The form data.
|
||||
*
|
||||
* @return boolean True on success.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function save($data)
|
||||
{
|
||||
$input = JFactory::getApplication()->input;
|
||||
$filter = JFilterInput::getInstance();
|
||||
|
||||
// set the metadata to the Item Data
|
||||
if (isset($data['metadata']) && isset($data['metadata']['author']))
|
||||
{
|
||||
$data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
|
||||
|
||||
$metadata = new JRegistry;
|
||||
$metadata->loadArray($data['metadata']);
|
||||
$data['metadata'] = (string) $metadata;
|
||||
}
|
||||
|
||||
// Set the Params Items to data
|
||||
if (isset($data['params']) && is_array($data['params']))
|
||||
{
|
||||
$params = new JRegistry;
|
||||
$params->loadArray($data['params']);
|
||||
$data['params'] = (string) $params;
|
||||
}
|
||||
|
||||
// Alter the uniqe field for save as copy
|
||||
if ($input->get('task') == 'save2copy')
|
||||
{
|
||||
// Automatic handling of other uniqe fields
|
||||
$uniqeFields = $this->getUniqeFields();
|
||||
if (CostbenefitprojectionHelper::checkArray($uniqeFields))
|
||||
{
|
||||
foreach ($uniqeFields as $uniqeField)
|
||||
{
|
||||
$data[$uniqeField] = $this->generateUniqe($uniqeField,$data[$uniqeField]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (parent::save($data))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to generate a uniqe value.
|
||||
*
|
||||
* @param string $field name.
|
||||
* @param string $value data.
|
||||
*
|
||||
* @return string New value.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
protected function generateUniqe($field,$value)
|
||||
{
|
||||
|
||||
// set field value uniqe
|
||||
$table = $this->getTable();
|
||||
|
||||
while ($table->load(array($field => $value)))
|
||||
{
|
||||
$value = JString::increment($value);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to change the title & alias.
|
||||
*
|
||||
* @param string $title The title.
|
||||
*
|
||||
* @return array Contains the modified title and alias.
|
||||
*
|
||||
*/
|
||||
protected function _generateNewTitle($title)
|
||||
{
|
||||
|
||||
// Alter the title
|
||||
$table = $this->getTable();
|
||||
|
||||
while ($table->load(array('title' => $title)))
|
||||
{
|
||||
$title = JString::increment($title);
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
}
|
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage router.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
/**
|
||||
* Routing class from com_costbenefitprojection
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
class CostbenefitprojectionRouter extends JComponentRouterBase
|
||||
{
|
||||
/**
|
||||
* Build the route for the com_costbenefitprojection component
|
||||
*
|
||||
* @param array &$query An array of URL arguments
|
||||
*
|
||||
* @return array The URL arguments to use to assemble the subsequent URL.
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public function build(&$query)
|
||||
{
|
||||
$segments = array();
|
||||
|
||||
// Get a menu item based on Itemid or currently active
|
||||
$params = JComponentHelper::getParams('com_costbenefitprojection');
|
||||
|
||||
if (empty($query['Itemid']))
|
||||
{
|
||||
$menuItem = $this->menu->getActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
$menuItem = $this->menu->getItem($query['Itemid']);
|
||||
}
|
||||
|
||||
$mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
|
||||
$mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
|
||||
|
||||
if (isset($query['view']))
|
||||
{
|
||||
$view = $query['view'];
|
||||
|
||||
if (empty($query['Itemid']))
|
||||
{
|
||||
$segments[] = $query['view'];
|
||||
}
|
||||
|
||||
unset($query['view']);
|
||||
}
|
||||
|
||||
// Are we dealing with a item that is attached to a menu item?
|
||||
if (isset($view) && ($mView == $view) and (isset($query['id'])) and ($mId == (int) $query['id']))
|
||||
{
|
||||
unset($query['view']);
|
||||
unset($query['catid']);
|
||||
unset($query['id']);
|
||||
return $segments;
|
||||
}
|
||||
|
||||
if (isset($view) && isset($query['id']) && ($view == 'company' || $view == 'scaling_factor' || $view == 'intervention' || $view == 'cpanel' || $view == 'publicresults' || $view == 'createaccount' || $view == 'companyresults' || $view == 'combinedresults'))
|
||||
{
|
||||
if ($mId != (int) $query['id'] || $mView != $view)
|
||||
{
|
||||
if (($view == 'company' || $view == 'scaling_factor' || $view == 'intervention' || $view == 'cpanel' || $view == 'publicresults' || $view == 'createaccount' || $view == 'companyresults' || $view == 'combinedresults'))
|
||||
{
|
||||
$segments[] = $view;
|
||||
$id = explode(':', $query['id']);
|
||||
if (count($id) == 2)
|
||||
{
|
||||
$segments[] = $id[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$segments[] = $id[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($query['id']);
|
||||
}
|
||||
|
||||
$total = count($segments);
|
||||
|
||||
for ($i = 0; $i < $total; $i++)
|
||||
{
|
||||
$segments[$i] = str_replace(':', '-', $segments[$i]);
|
||||
}
|
||||
|
||||
return $segments;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the segments of a URL.
|
||||
*
|
||||
* @param array &$segments The segments of the URL to parse.
|
||||
*
|
||||
* @return array The URL attributes to be used by the application.
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public function parse(&$segments)
|
||||
{
|
||||
//var_dump($segments);
|
||||
//$app = JFactory::getApplication();
|
||||
//$menu = $app->getMenu();
|
||||
//$item = $menu->getActive();
|
||||
|
||||
$count = count($segments);
|
||||
$vars = array();
|
||||
|
||||
//var_dump($item->query['view']);
|
||||
//Handle View and Identifier
|
||||
switch($segments[0])
|
||||
{
|
||||
case 'company':
|
||||
$vars['view'] = 'company';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $this->getVar('company', $segments[$count-1], 'alias', 'id');
|
||||
if($id)
|
||||
{
|
||||
$vars['id'] = $id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'scaling_factor':
|
||||
$vars['view'] = 'scaling_factor';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $this->getVar('scaling_factor', $segments[$count-1], 'alias', 'id');
|
||||
if($id)
|
||||
{
|
||||
$vars['id'] = $id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'intervention':
|
||||
$vars['view'] = 'intervention';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $this->getVar('intervention', $segments[$count-1], 'alias', 'id');
|
||||
if($id)
|
||||
{
|
||||
$vars['id'] = $id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'cpanel':
|
||||
$vars['view'] = 'cpanel';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $this->getVar('cpanel', $segments[$count-1], 'alias', 'id');
|
||||
if($id)
|
||||
{
|
||||
$vars['id'] = $id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'publicresults':
|
||||
$vars['view'] = 'publicresults';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $this->getVar('publicresults', $segments[$count-1], 'alias', 'id');
|
||||
if($id)
|
||||
{
|
||||
$vars['id'] = $id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'createaccount':
|
||||
$vars['view'] = 'createaccount';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $this->getVar('createaccount', $segments[$count-1], 'alias', 'id');
|
||||
if($id)
|
||||
{
|
||||
$vars['id'] = $id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'companyresults':
|
||||
$vars['view'] = 'companyresults';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $this->getVar('companyresults', $segments[$count-1], 'alias', 'id');
|
||||
if($id)
|
||||
{
|
||||
$vars['id'] = $id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'combinedresults':
|
||||
$vars['view'] = 'combinedresults';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = $this->getVar('combinedresults', $segments[$count-1], 'alias', 'id');
|
||||
if($id)
|
||||
{
|
||||
$vars['id'] = $id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'costbenefitprojection')
|
||||
{
|
||||
if(!$where)
|
||||
{
|
||||
$where = JFactory::getUser()->id;
|
||||
}
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select($db->quoteName(array($what)));
|
||||
if ('categories' == $table || 'category' == $table)
|
||||
{
|
||||
$query->from($db->quoteName('#__categories'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$query->from($db->quoteName('#__'.$main.'_'.$table));
|
||||
}
|
||||
if (is_numeric($where))
|
||||
{
|
||||
$query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where);
|
||||
}
|
||||
elseif (is_string($where))
|
||||
{
|
||||
$query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadResult();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function CostbenefitprojectionBuildRoute(&$query)
|
||||
{
|
||||
$router = new CostbenefitprojectionRouter;
|
||||
|
||||
return $router->build($query);
|
||||
}
|
||||
|
||||
function CostbenefitprojectionParseRoute($segments)
|
||||
{
|
||||
$router = new ContentRouter;
|
||||
|
||||
return $router->parse($segments);
|
||||
}
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// set the active tabs based on interventions
|
||||
if (isset($this->results->interventions) && CostbenefitprojectionHelper::checkArray($this->results->interventions))
|
||||
{
|
||||
$savings = 'uk-active ';
|
||||
$details = '';
|
||||
}
|
||||
else
|
||||
{
|
||||
$savings = '';
|
||||
$details = 'uk-active ';
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div id="loading" style="height:300px; width:100%">
|
||||
<h1 style="text-align:center;" ><?php echo JText::_('COM_COSTBENEFITPROJECTION_PLEASE_WAIT'); ?></h1>
|
||||
<div style="margin:0 auto; width:180px; height:24px; padding: 5px;">
|
||||
<img width="180" height="24" src="<?php echo JRoute::_('media/com_costbenefitprojection/images/load.gif'); ?>" alt="......." title="........"/>
|
||||
</div>
|
||||
</div>
|
||||
<div id="main_costbenefitprojection" style="display:none;">
|
||||
<div class="uk-alert uk-width-1-2"><h4><i class="uk-icon-gears"></i> <?php echo JText::_('COM_COSTBENEFITPROJECTION_COMBINED_RESULTS_OF'); ?> (<?php echo $this->names; ?>)</h4></div>
|
||||
<!-- SCALE SWITCH -->
|
||||
<div class="uk-clearfix"><div class="uk-float-right"><button class="uk-button switch footabletab" type="button" onclick="controlSwitch()"><i class="switch-icon uk-icon-toggle-off"></i> <span class="switch-text"><?php echo JText::_('COM_COSTBENEFITPROJECTION_SCALING_FACTORS'); ?></span></button></div></div>
|
||||
<div class="main clearfix">
|
||||
<ul data-uk-switcher="{connect:'#results'}" class="uk-subnav uk-subnav-pill">
|
||||
<li class="<?php echo $savings; ?>uk-text-small"><a href="#"> <?php echo JText::_('COM_COSTBENEFITPROJECTION_ANNUAL_SAVINGS'); ?></a></li>
|
||||
<li class="<?php echo $details; ?>uk-text-small" data-uk-dropdown="{mode:'hover'}">
|
||||
<a href="#"> <?php echo JText::_('COM_COSTBENEFITPROJECTION_MORE_DETAILS'); ?></a>
|
||||
|
||||
<div class="uk-dropdown uk-dropdown-small">
|
||||
<ul data-uk-switcher="{connect:'#table-chart'}" class="uk-nav uk-nav-dropdown">
|
||||
<li class="<?php echo $savings; ?>"><a href=""><?php echo JText::_('COM_COSTBENEFITPROJECTION_TABLES'); ?></a></li>
|
||||
<li class="<?php echo $details; ?>"><a href=""><?php echo JText::_('COM_COSTBENEFITPROJECTION_CHARTS'); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="uk-switcher uk-margin" id="results">
|
||||
<li id="results-one" class="uk-active">
|
||||
<!-- Intervention Cost Benefit -->
|
||||
<?php echo $this->loadTemplate('chart_intervention_cost_benefit_save'); ?>
|
||||
</li>
|
||||
<li>
|
||||
<ul class="uk-switcher uk-margin" id="table-chart">
|
||||
<li class="">
|
||||
<ul id="table-switch" data-uk-tab="{connect:'#tables'}" class="uk-tab">
|
||||
<li class="uk-text-small footabletab"><a href="#"><?php echo JText::_('COM_COSTBENEFITPROJECTION_WORK_DAYS_LOST_SUMMARY'); ?></a></li>
|
||||
<li class="uk-text-small footabletab"><a href="#"><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST_SUMMARY'); ?></a></li>
|
||||
<li class="uk-active uk-text-small footabletab"><a href="#"><?php echo JText::_('COM_COSTBENEFITPROJECTION_CALCULATED_COSTS_IN_DETAIL'); ?></a></li>
|
||||
<li class="uk-text-small footabletab"><a href="#"><?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_NET_BENEFIT'); ?></a></li>
|
||||
</ul>
|
||||
<ul id="tables" class="uk-switcher uk-margin">
|
||||
<li class="">
|
||||
<!-- Work Days Lost Summary -->
|
||||
<?php echo $this->loadTemplate('table_work_days_lost_summary'); ?>
|
||||
</li>
|
||||
<li class="">
|
||||
<!-- Cost Summary -->
|
||||
<?php echo $this->loadTemplate('table_cost_summary'); ?>
|
||||
</li>
|
||||
<li class="uk-active">
|
||||
<!-- Calculated Costs in Detail -->
|
||||
<?php echo $this->loadTemplate('table_calculated_cost_in_detail'); ?>
|
||||
</li>
|
||||
<li class="">
|
||||
<!-- Intervention Net Benefit -->
|
||||
<?php echo $this->loadTemplate('table_intervention_net_benefit'); ?>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="uk-active">
|
||||
<ul data-uk-tab="{connect:'#charts'}" class="uk-tab">
|
||||
<li class="uk-text-small"><a href="#"><?php echo JText::_('COM_COSTBENEFITPROJECTION_WORK_DAYS_LOST'); ?></a></li>
|
||||
<li class="uk-text-small"><a href="#"><?php echo JText::_('COM_COSTBENEFITPROJECTION_WORK_DAYS_LOST_PERCENT'); ?></a></li>
|
||||
<li class="uk-active uk-text-small"><a href="#"><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST'); ?></a></li>
|
||||
<li class="uk-text-small"><a href="#"><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST_PERCENT'); ?></a></li>
|
||||
<li class="uk-text-small"><a href="#"><?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COST_BENEFIT'); ?></a></li>
|
||||
</ul>
|
||||
<ul id="charts" class="uk-switcher uk-margin">
|
||||
<li class="">
|
||||
<!-- Work days Lost -->
|
||||
<?php echo $this->loadTemplate('chart_work_days_lost'); ?>
|
||||
</li>
|
||||
<li class="">
|
||||
<!-- Work days Lost Percent -->
|
||||
<?php echo $this->loadTemplate('chart_work_days_lost_percent'); ?>
|
||||
</li>
|
||||
<li class="uk-active">
|
||||
<!-- Costs -->
|
||||
<?php echo $this->loadTemplate('chart_cost'); ?>
|
||||
</li>
|
||||
<li class="">
|
||||
<!-- Cost Percent -->
|
||||
<?php echo $this->loadTemplate('chart_cost_percent'); ?>
|
||||
</li>
|
||||
<li class="">
|
||||
<!-- Intervention Cost Benefit -->
|
||||
<?php echo $this->loadTemplate('chart_intervention_cost_benefit'); ?>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<script>
|
||||
var height = 0;
|
||||
var width = 0;
|
||||
var url = 0;
|
||||
|
||||
// page loading pause
|
||||
jQuery(window).load(function() {
|
||||
jQuery('#loading').fadeOut( 'fast', function() {
|
||||
jQuery('#main_costbenefitprojection').fadeIn( 'fast', function() {
|
||||
jQuery('li.uk-active .footable').trigger('footable_resize');
|
||||
});
|
||||
});
|
||||
});
|
||||
// resize table on default/include/one click
|
||||
jQuery('[data-uk-switcher]').on('uk.switcher.show', function(event, area){
|
||||
jQuery('li.uk-active .footable').trigger('footable_resize');
|
||||
});
|
||||
// resize table on tab click
|
||||
jQuery('[data-uk-tab]').on('uk.switcher.show', function(event, area){
|
||||
jQuery('li.uk-active .footable').trigger('footable_resize');
|
||||
});
|
||||
// foo table trigger on click
|
||||
jQuery('.footabletab').click(function(e){
|
||||
// use setTimeout() to execute
|
||||
setTimeout( resizeFooTable, 200);
|
||||
});
|
||||
// funtion to resize the foo table
|
||||
function resizeFooTable() {
|
||||
jQuery('.footable').trigger('footable_resize');
|
||||
}
|
||||
jQuery(function () {
|
||||
jQuery('table.data').footable().bind('footable_filtering', function(e){
|
||||
var selected = jQuery(this).prev('p').find('.filter-status').find(':selected').text();
|
||||
if (selected && selected.length > 0){
|
||||
e.filter += (e.filter && e.filter.length > 0) ? ' ' + selected : selected;
|
||||
e.clear = !e.filter;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* The PDF generator funtions */
|
||||
function getImgData(chartContainer) {
|
||||
var chartArea = chartContainer.getElementsByTagName('svg')[0].parentNode;
|
||||
var svg = chartArea.innerHTML;
|
||||
var doc = chartContainer.ownerDocument;
|
||||
var canvas = doc.createElement('canvas');
|
||||
canvas.setAttribute('width', chartArea.offsetWidth);
|
||||
canvas.setAttribute('height', chartArea.offsetHeight);
|
||||
|
||||
|
||||
canvas.setAttribute(
|
||||
'style',
|
||||
'position: absolute; ' +
|
||||
'top: ' + (-chartArea.offsetHeight * 2) + 'px;' +
|
||||
'left: ' + (-chartArea.offsetWidth * 2) + 'px;');
|
||||
doc.body.appendChild(canvas);
|
||||
canvg(canvas, svg);
|
||||
var imgData = canvas.toDataURL("image/png");
|
||||
canvas.parentNode.removeChild(canvas);
|
||||
return imgData;
|
||||
}
|
||||
jQuery.download = function(url, dataOne, dataTwo, method){
|
||||
//url and data options required
|
||||
if( url && dataOne ){
|
||||
//split params into form inputs
|
||||
var input = '<input type="hidden" name="<?php echo 'key'; ?>" value="'+ dataOne +'" />';
|
||||
if(dataTwo){
|
||||
input += '<input type="hidden" name="<?php echo 'text'; ?>" value="'+ dataTwo +'" />';
|
||||
}
|
||||
//send request
|
||||
jQuery('<form action="'+ url +'" method="'+ (method||'post') +'">'+input+'</form>')
|
||||
.appendTo('body').submit().remove();
|
||||
};
|
||||
};
|
||||
function getPDF(chartContainer,text) {
|
||||
var doc = chartContainer.ownerDocument;
|
||||
var img = doc.createElement('img');
|
||||
img.src = getImgData(chartContainer);
|
||||
var url = 'index.php?option=com_costbenefitprojection&view=cp&format=pdf';
|
||||
var data = img.src;
|
||||
jQuery.download(url,data,text );
|
||||
}
|
||||
|
||||
/* The Excel generator funtions */
|
||||
jQuery.exel = function(url, data, title){
|
||||
//url and data options required
|
||||
if( url && data ){
|
||||
//split params into form inputs
|
||||
var input = '<input type="hidden" name="csv_text" value="'+ data +'" />';
|
||||
if(title){
|
||||
input += '<input type="hidden" name="title" value="'+ title +'" />';
|
||||
}
|
||||
//send request
|
||||
jQuery('<form action="'+ url +'" method="post">'+input+'</form>')
|
||||
.appendTo('body').submit().remove();
|
||||
};
|
||||
};
|
||||
|
||||
function getEXEL(theTable,theTitle){
|
||||
var title = theTitle;
|
||||
var url = 'index.php?option=com_costbenefitprojection&view=cp&format=csv';
|
||||
var data = jQuery(theTable).table2excel();
|
||||
jQuery.exel(url,data,title);
|
||||
}
|
||||
|
||||
// Switch for Scaling factors
|
||||
function controlSwitch(){
|
||||
if ( jQuery(".switch").hasClass("on") ) {
|
||||
jQuery(".switch").removeClass("on uk-button-primary");
|
||||
jQuery(".switch-icon").removeClass("uk-icon-toggle-on");
|
||||
jQuery(".switch-icon").addClass("uk-icon-toggle-off");
|
||||
jQuery(".unscaled").css( "display", "table" );
|
||||
jQuery(".scaled").css( "display", "none" );
|
||||
} else {
|
||||
jQuery(".switch").addClass("on uk-button-primary");
|
||||
jQuery(".switch-icon").removeClass("uk-icon-toggle-off");
|
||||
jQuery(".switch-icon").addClass("uk-icon-toggle-on");
|
||||
jQuery(".scaled").css( "display", "table" );
|
||||
jQuery(".unscaled").css( "display", "none" );
|
||||
};
|
||||
}
|
||||
</script>
|
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default_chart_cost.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
// set scaled array
|
||||
$scaled = array('unscaled','scaled');
|
||||
// check if items are set
|
||||
if(isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)){
|
||||
foreach ($scaled as $scale){
|
||||
$i =0;
|
||||
$rowArray = array();
|
||||
foreach ($this->results->items as $key => &$item){
|
||||
$rowArray[] = array('c' => array(
|
||||
array('v' => $item->details->name),
|
||||
array('v' => $item->{'subtotal_cost_morbidity_'.$scale}, 'f' => $item->{'subtotal_costmoney_morbidity_'.$scale}),
|
||||
array('v' => $item->{'subtotal_cost_presenteeism_'.$scale}, 'f' => $item->{'subtotal_costmoney_presenteeism_'.$scale}),
|
||||
array('v' => $item->{'subtotal_cost_mortality_'.$scale}, 'f' => $item->{'subtotal_costmoney_mortality_'.$scale}),
|
||||
array('v' => $item->{'subtotal_cost_'.$scale}, 'f' => $item->{'subtotal_costmoney_'.$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_MORBIDITY'), 'type' => 'number'),
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_PRESENTEEISM_MORBIDITY'), 'type' => 'number'),
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_MORTALITY'), 'type' => 'number'),
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_TOTAL_COST'), 'type' => 'number')
|
||||
),
|
||||
'rows' => $rowArray
|
||||
);
|
||||
|
||||
$height = ($i * 110)+10;
|
||||
$title = JText::sprintf('COM_COSTBENEFITPROJECTION_COST_IN_S', $this->item->currency_name);
|
||||
$chart->load(json_encode($data));
|
||||
$options = array( '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('c_'.$scale, $options);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="view_c">
|
||||
<div style="margin:0 auto; width: <?php echo $this->Chart['width']; ?>px; height: 100%;">
|
||||
<h1><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST'); ?></h1>
|
||||
|
||||
<?php if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) : ?>
|
||||
<?php foreach ($scaled as $scale) :?>
|
||||
<div id="c_<?php echo $scale; ?>" class="<?php echo $scale; ?>" style="display: <?php echo ($scale == 'unscaled') ? 'table' : 'none'; ?>;"></div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="uk-alert uk-alert-warning alert alert-warning"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NO_CAUSERISK_SELECTED'); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default_chart_cost_percent.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
// set scaled array
|
||||
$scaled = array('unscaled','scaled');
|
||||
// check if items are set
|
||||
if(isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)){
|
||||
foreach ($scaled as $scale){
|
||||
$i =0;
|
||||
$rowArray = array();
|
||||
foreach ($this->results->items as $key => &$item){
|
||||
$rowArray[] = array('c' => array(
|
||||
array('v' => $item->details->name),
|
||||
array('v' => round(($item->{'subtotal_cost_'.$scale} / $this->results->totals->{'total_cost_'.$scale})*100), 'f' => (float)round(($item->{'subtotal_cost_'.$scale} / $this->results->totals->{'total_cost_'.$scale})*100,3).'%')
|
||||
));
|
||||
$i++;
|
||||
}
|
||||
|
||||
usort($rowArray, function($b, $a) {
|
||||
return $a['c'][1]['v'] - $b['c'][1]['v'];
|
||||
});
|
||||
|
||||
$data = array(
|
||||
'cols' => array(
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK_FACTOR'), 'type' => 'string'),
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_PERCENT_OF_TOTAL_COST'), 'type' => 'number')
|
||||
),
|
||||
'rows' => $rowArray
|
||||
);
|
||||
|
||||
$height = ($i * 70)+100;
|
||||
$chart->load(json_encode($data));
|
||||
$options = array( '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' => JText::_('COM_COSTBENEFITPROJECTION__OF_ALL_HEALTHCARE_COSTS_CAUSED_BY_THE_CAUSERISK_FACTOR'), 'titleTextStyle' => $this->Chart['hAxis']['titleTextStyle']));
|
||||
|
||||
echo $chart->draw('cp_'.$scale, $options);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="view_cp">
|
||||
<div style="margin:0 auto; width: <?php echo $this->Chart['width']; ?>px; height: 100%;">
|
||||
<h1><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST_PERCENT'); ?></h1>
|
||||
<?php if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) : ?>
|
||||
<?php foreach ($scaled as $scale) :?>
|
||||
<div id="cp_<?php echo $scale; ?>" class="<?php echo $scale; ?>" style="display: <?php echo ($scale == 'unscaled') ? 'table' : 'none'; ?>;"></div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="uk-alert uk-alert-warning alert alert-warning"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NO_CAUSERISK_SELECTED'); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default_chart_intervention_cost_benefit.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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->annual_cost, 'f' => $item->annual_costmoney),
|
||||
array('v' => $item->{'annual_benefit_'.$scale}, 'f' => $item->{'annualmoney_benefit_'.$scale}),
|
||||
array('v' => $item->{'net_benefit_'.$scale}, 'f' => $item->{'netmoney_benefit_'.$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_ANNUAL_COST_OF_INTERVENTION'), 'type' => 'number'),
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_ANNUAL_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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="view_icb">
|
||||
<div style="margin:0 auto; width: <?php echo $this->Chart['width']; ?>px; height: 100%;">
|
||||
<h1><?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_COST_BENEFIT'); ?></h1>
|
||||
<?php if (isset($this->results->interventions) && CostbenefitprojectionHelper::checkArray($this->results->interventions)) : ?>
|
||||
<?php $intervention_number = 0; ?>
|
||||
<?php foreach ($this->results->interventions as $intervention): ?>
|
||||
<?php if (isset($intervention->items)): ?>
|
||||
<?php foreach ($scaled as $scale) :?>
|
||||
<div id="icb_<?php echo $intervention_number; ?>_<?php echo $scale; ?>" class="<?php echo $scale; ?>" style="display: <?php echo ($scale == 'unscaled') ? 'box' : 'none'; ?>;"></div>
|
||||
<?php $intervention_number++; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="uk-alert uk-alert-warning alert alert-warning"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NO_INTERVENTION_SELECTED'); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default_chart_intervention_cost_benefit_save.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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) && $intervention->nr_found)
|
||||
{
|
||||
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->annual_cost, 'f' => $item->annual_costmoney),
|
||||
array('v' => $item->{'annual_benefit_'.$scale}, 'f' => $item->{'annualmoney_benefit_'.$scale}),
|
||||
array('v' => $item->{'net_benefit_'.$scale}, 'f' => $item->{'netmoney_benefit_'.$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_ANNUAL_COST_OF_INTERVENTION'), 'type' => 'number'),
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_ANNUAL_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('save_'.$intervention_number.'_'.$scale, $options);
|
||||
$intervention_number++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$no_intervention[] = $intervention->name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php if (isset($this->results->interventions) && CostbenefitprojectionHelper::checkArray($this->results->interventions)): ?>
|
||||
<?php if(isset($no_intervention) && is_array($no_intervention)): ?>
|
||||
<div class="uk-alert" data-uk-alert>
|
||||
<a href="" class="uk-alert-close uk-close"></a>
|
||||
<p>The intervention<?php
|
||||
$no_intervention = array_unique($no_intervention);
|
||||
$size = sizeof($no_intervention);
|
||||
if($size > 1){ echo 's';}
|
||||
$a = 0;
|
||||
foreach($no_intervention as $name){
|
||||
if($a){
|
||||
echo ', <strong>'.$name.'</strong>';
|
||||
} else {
|
||||
echo ' named <strong>'.$name.'</strong>';
|
||||
}
|
||||
$a++;
|
||||
}
|
||||
|
||||
?> has no effect on your selected causes/risks</p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div id="chartSAVE">
|
||||
<?php if (isset($this->results->interventions) && CostbenefitprojectionHelper::checkArray($this->results->interventions)) : ?>
|
||||
<?php $intervention_number = 0; ?>
|
||||
<?php foreach ($this->results->interventions as $intervention): ?>
|
||||
<?php if (isset($intervention->items)): ?>
|
||||
<?php foreach ($scaled as $scale) :?>
|
||||
<div id="save_<?php echo $intervention_number; ?>_<?php echo $scale; ?>" class="chart <?php echo $scale; ?>" style="height:100%; width:100%; display: <?php echo ($scale == 'unscaled') ? 'box' : 'none'; ?>;"></div>
|
||||
<?php $intervention_number++; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="uk-alert uk-alert-warning alert alert-warning"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NO_INTERVENTIONS_SELECTED_PLEASE_SELECT_AN_INTERVENTIONS'); ?></div>
|
||||
<?php endif; ?>
|
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default_chart_work_days_lost.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
// set scaled array
|
||||
$scaled = array('unscaled','scaled');
|
||||
// check if items are set
|
||||
if(isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)){
|
||||
foreach ($scaled as $scale){
|
||||
$i =0;
|
||||
$rowArray = array();
|
||||
foreach ($this->results->items as $key => &$item){
|
||||
$rowArray[$i] = array('c' => array(
|
||||
array('v' => $item->details->name),
|
||||
array('v' => (float)round($item->{'subtotal_morbidity_'.$scale}, 2)),
|
||||
array('v' => (float)round($item->{'subtotal_presenteeism_'.$scale}, 2)),
|
||||
array('v' => (float)round($item->{'subtotal_days_lost_mortality_'.$scale}, 2)),
|
||||
array('v' => (float)round($item->{'subtotal_days_lost_'.$scale}, 2))
|
||||
));
|
||||
$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_MORBIDITY'), 'type' => 'number'),
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_PRESENTEEISM_MORBIDITY'), 'type' => 'number'),
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_MORTALITY'), 'type' => 'number'),
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_TOTAL_DAYS_LOST'), 'type' => 'number')
|
||||
),
|
||||
'rows' => $rowArray
|
||||
);
|
||||
|
||||
$height = ($i * 110)+50;
|
||||
$chart->load(json_encode($data));
|
||||
$options = array( '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' => JText::_('COM_COSTBENEFITPROJECTION_NUMBER_OF_WORK_DAYS_LOST'), 'titleTextStyle' => $this->Chart['hAxis']['titleTextStyle']));
|
||||
|
||||
echo $chart->draw('wdl_'.$scale, $options);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="view_wdl">
|
||||
<div style="margin:0 auto; width: <?php echo $this->Chart['width']; ?>px; height: 100%;">
|
||||
<h1><?php echo JText::_('COM_COSTBENEFITPROJECTION_WORK_DAYS_LOST'); ?></h1>
|
||||
<?php if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) : ?>
|
||||
<?php foreach ($scaled as $scale) :?>
|
||||
<div id="wdl_<?php echo $scale; ?>" class="<?php echo $scale; ?>" style="display: <?php echo ($scale == 'unscaled') ? 'box' : 'none'; ?>;"></div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="uk-alert uk-alert-warning alert alert-warning"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NO_CAUSERISK_SELECTED'); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default_chart_work_days_lost_percent.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
// set scaled array
|
||||
$scaled = array('unscaled','scaled');
|
||||
// check if items are set
|
||||
if(isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)){
|
||||
foreach ($scaled as $scale){
|
||||
$i =0;
|
||||
$rowArray = array();
|
||||
foreach ($this->results->items as $key => &$item){
|
||||
$rowArray[$i] = array('c' => array(
|
||||
array('v' => $item->details->name),
|
||||
array('v' => round(($item->{'subtotal_days_lost_'.$scale} / $this->results->totals->{'total_days_lost_'.$scale})*100), 'f' => (float)round(($item->{'subtotal_days_lost_'.$scale} / $this->results->totals->{'total_days_lost_'.$scale})*100,3).'%')
|
||||
));
|
||||
$i++;
|
||||
}
|
||||
|
||||
usort($rowArray, function($b, $a) {
|
||||
return $a['c'][1]['v'] - $b['c'][1]['v'];
|
||||
});
|
||||
|
||||
$data = array(
|
||||
'cols' => array(
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK_FACTOR'), 'type' => 'string'),
|
||||
array('id' => '', 'label' => JText::_('COM_COSTBENEFITPROJECTION_PERCENT_OF_TOTAL_DAYS_LOST'), 'type' => 'number')
|
||||
),
|
||||
'rows' => $rowArray
|
||||
);
|
||||
|
||||
$height = ($i * 70)+30;
|
||||
$chart->load(json_encode($data));
|
||||
$options = array( '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' => JText::_('COM_COSTBENEFITPROJECTION__OF_WORK_DAYS_LOST_DUE_TO_THE_CAUSERISK_FACTOR'), 'titleTextStyle' => $this->Chart['hAxis']['titleTextStyle']));
|
||||
|
||||
echo $chart->draw('wdlp_'.$scale, $options);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div id="view_wdlp">
|
||||
<div style="margin:0 auto; width: <?php echo $this->Chart['width']; ?>px; height: 100%;">
|
||||
<h1><?php echo JText::_('COM_COSTBENEFITPROJECTION_WORK_DAY_LOST_PERCENT'); ?></h1>
|
||||
<?php if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) : ?>
|
||||
<?php foreach ($scaled as $scale) :?>
|
||||
<div id="wdlp_<?php echo $scale; ?>" class="<?php echo $scale; ?>" style="display: <?php echo ($scale == 'unscaled') ? 'box' : 'none'; ?>;"></div>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="uk-alert uk-alert-warning alert alert-warning"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NO_CAUSERISK_SELECTED'); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default_table_calculated_cost_in_detail.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$scaled = array('unscaled','scaled');
|
||||
|
||||
?>
|
||||
<div id="view_ccid">
|
||||
<h1><?php echo JText::_('COM_COSTBENEFITPROJECTION_CALCULATED_COSTS_IN_DETAIL'); ?></h1>
|
||||
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_COSTS_DUE_TO_PRESENTEEISM_LOST_PRODUCTIVITY_DUE_TO_SICKNESSBRDISEASE_COSTS_DUE_TO_PRESENTEEISM'); ?>
|
||||
<?php if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) : ?>
|
||||
<?php foreach ($scaled as $scale): ?>
|
||||
<table id="theTableCCID_<?php echo $scale; ?>" class="footable table data metro-blue <?php echo $scale; ?>" style="display: <?php echo ($scale == 'unscaled') ? 'table' : 'none'; ?>;" data-page-size="50">
|
||||
<thead>
|
||||
<tr >
|
||||
<th data-toggle="true"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DISEASERISK_FACTOR'); ?></th>
|
||||
<th width="20%" data-hide="phone"><?php echo JText::_('COM_COSTBENEFITPROJECTION_COSTS_MALE_EMPLOYEES'); ?></th>
|
||||
<th width="20%" data-hide="phone"><?php echo JText::_('COM_COSTBENEFITPROJECTION_COSTS_FEMALE_EMPLOYEES'); ?></th>
|
||||
<th width="25%"><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_COSTS'); ?></th>
|
||||
<th data-hide="all"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DATA'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->results->items as $i => &$item): ?>
|
||||
<tr>
|
||||
<th data-value='<?php echo $item->details->alias; ?>' scope="row"><?php echo $item->details->name; ?></th>
|
||||
<td data-value='<?php echo $item->{'male_cost_'.$scale}; ?>' ><?php echo $item->{'male_costmoney_'.$scale}; ?></td>
|
||||
<td data-value='<?php echo $item->{'female_cost_'.$scale}; ?>' ><?php echo $item->{'female_costmoney_'.$scale}; ?></td>
|
||||
<td data-value='<?php echo $item->{'subtotal_cost_'.$scale}; ?>' ><?php echo $item->{'subtotal_costmoney_'.$scale}; ?></td>
|
||||
<td data-value='0' ><?php $item->_tmpType = 'cost'; $item->_tmpScale = $scale; echo JLayoutHelper::render('databreakdownmalefemale', $item); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th scope="row"><?php echo JText::_('TOTALS'); ?></th>
|
||||
<td><?php echo $this->results->totals->{'males_costmoney_'.$scale}; ?></td>
|
||||
<td><?php echo $this->results->totals->{'females_costmoney_'.$scale}; ?></td>
|
||||
<td><?php echo $this->results->totals->{'total_costmoney_'.$scale}; ?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="uk-alert uk-alert-warning alert alert-warning"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NO_DISEASERISK_SELECTED'); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default_table_cost_summary.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$scaled = array('unscaled','scaled');
|
||||
|
||||
?>
|
||||
<div id="view_cs">
|
||||
<h1><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST_SUMMARY'); ?></h1>
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_COSTS_AND_CONTRIBUTION_OF_MORBIDITY_MORTALITY_AND_RISK_FACTORS'); ?>
|
||||
<?php if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) : ?>
|
||||
<?php foreach ($scaled as $scale): ?>
|
||||
<table id="theTableCS_<?php echo $scale; ?>" class="footable table data metro-blue <?php echo $scale; ?>" style="display: <?php echo ($scale == 'unscaled') ? 'table' : 'none'; ?>;" data-page-size="50">
|
||||
<thead>
|
||||
<tr >
|
||||
<th data-toggle="true"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DISEASERISK_FACTOR'); ?></th>
|
||||
<th width="13%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST_MORBIDITY'); ?></th>
|
||||
<th width="13%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST_PRESENTEEISM_DUE_TO_MORBIDITY'); ?></th>
|
||||
<th width="13%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST_MORTALITY'); ?></th>
|
||||
<th width="13%" data-hide="phone"><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_COST_PER_DISEASERISK_FACTOR'); ?></th>
|
||||
<th width="13%"><?php echo JText::_('COM_COSTBENEFITPROJECTION_PERCENT_OF_TOTAL_COST'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->results->items as $i => &$item): ?>
|
||||
<tr>
|
||||
<th data-value='<?php echo $item->details->alias; ?>' scope="row"><?php echo $item->details->name; ?></th>
|
||||
<td data-value='<?php echo $item->{'subtotal_cost_morbidity_'.$scale}; ?>' ><?php echo $item->{'subtotal_costmoney_morbidity_'.$scale}; ?></td>
|
||||
<td data-value='<?php echo $item->{'subtotal_cost_presenteeism_'.$scale}; ?>' ><?php echo $item->{'subtotal_costmoney_presenteeism_'.$scale}; ?></td>
|
||||
<td data-value='<?php echo $item->{'subtotal_cost_mortality_'.$scale}; ?>' ><?php echo $item->{'subtotal_costmoney_mortality_'.$scale}; ?></td>
|
||||
<td data-value='<?php echo $item->{'subtotal_cost_'.$scale}; ?>' ><?php echo $item->{'subtotal_costmoney_'.$scale}; ?></td>
|
||||
<td data-value='<?php echo ($item->{'subtotal_cost_'.$scale} / $this->results->totals->{'total_cost_'.$scale})*100; ?>' ><?php echo round(($item->{'subtotal_cost_'.$scale} / $this->results->totals->{'total_cost_'.$scale})*100,3).'%'; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th scope="row"><?php echo JText::_('TOTALS'); ?></th>
|
||||
|
||||
<td><?php echo $this->results->totals->{'total_costmoney_morbidity_'.$scale}; ?></td>
|
||||
<td><?php echo $this->results->totals->{'total_costmoney_presenteeism_'.$scale}; ?></td>
|
||||
<td><?php echo $this->results->totals->{'total_costmoney_mortality_'.$scale}; ?></td>
|
||||
<td><?php echo $this->results->totals->{'total_costmoney_'.$scale}; ?></td>
|
||||
<td><?php echo round(($this->results->totals->{'total_cost_'.$scale} / $this->results->totals->{'total_cost_'.$scale})*100,3).'%'; ?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="uk-alert uk-alert-warning alert alert-warning"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NO_DISEASERISK_SELECTED'); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default_table_intervention_net_benefit.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$scaled = array('unscaled','scaled');
|
||||
|
||||
?>
|
||||
<div id="view_inb">
|
||||
<h1><?php echo JText::_('COM_COSTBENEFITPROJECTION_INTERVENTION_NET_BENEFIT'); ?></h1>
|
||||
<?php if(isset($this->results->interventions) && CostbenefitprojectionHelper::checkArray($this->results->interventions)): ?>
|
||||
<?php foreach ($this->results->interventions as $intervention) :?>
|
||||
<?php if (isset($intervention->items)): ?>
|
||||
<?php echo JText::sprintf("COM_COSTBENEFITPROJECTION_INTERVENTIONS_NAME_S", $intervention->name); ?> |
|
||||
<?php
|
||||
if($intervention->duration > 1){
|
||||
echo JText::sprintf("COM_COSTBENEFITPROJECTION_DURATION_S_YEARS", $intervention->duration);
|
||||
} else {
|
||||
echo JText::sprintf('COM_COSTBENEFITPROJECTION_DURATION_S_YEAR', $intervention->duration);
|
||||
}
|
||||
?> |
|
||||
<?php echo JText::sprintf('COM_COSTBENEFITPROJECTION_COVERAGE_S', round($intervention->coverage)); ?>%
|
||||
|
||||
<?php foreach ($scaled as $scale): ?>
|
||||
<table id="tableINT_<?php echo $intervention->id ?>_<?php echo $scale; ?>"
|
||||
class="footable table data metro-blue <?php echo $scale; ?>"
|
||||
style="display: <?php echo ($scale == 'unscaled') ? 'table' : 'none'; ?>;"
|
||||
data-page-size="50" >
|
||||
<thead>
|
||||
<tr >
|
||||
<th data-toggle="true"><?php echo JText::_('COM_COSTBENEFITPROJECTION_CAUSERISK_FACTOR'); ?></th>
|
||||
<th width="8%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_CONTRIBUTION_TO_COSTS'); ?></th>
|
||||
<th width="8%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_ANNUAL_COST_PER_EMPLOYEE'); ?></th>
|
||||
<th width="5%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_REDUCTION_IN_MORBIDITY_COSTS'); ?></th>
|
||||
<th width="5%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_REDUCTION_IN_MORTALITY_COST'); ?></th>
|
||||
<th width="11%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST_OF_PROBLEM'); ?></th>
|
||||
<th width="11%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_ANNUAL_COST_OF_INTERVENTION'); ?></th>
|
||||
<th width="11%" data-hide="phone"><?php echo JText::_('COM_COSTBENEFITPROJECTION_ANNUAL_BENEFIT'); ?></th>
|
||||
<th width="5%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_COST_BENEFIT_RATIO'); ?></th>
|
||||
<th width="11%"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NET_BENEFIT'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if(isset($intervention->items) && is_object($intervention->items) || is_array($intervention->items)):?>
|
||||
<?php foreach ($intervention->items as $key => &$item): ?>
|
||||
<tr>
|
||||
<th data-value='<?php echo $item->name; ?>' scope="row"><?php echo $item->name; ?></th>
|
||||
<td data-value='<?php echo $item->{'contribution_to_cost_'.$scale}; ?>' ><?php echo round($item->{'contribution_to_cost_'.$scale}, 3); ?>%</td>
|
||||
<td data-value='<?php echo $item->cpe; ?>' ><?php echo $item->annual_costmoney_per_employee; ?></td>
|
||||
<td data-value='<?php echo $item->mbr; ?>' ><?php echo $item->mbr; ?>%</td>
|
||||
<td data-value='<?php echo $item->mtr; ?>' ><?php echo $item->mtr; ?>%</td>
|
||||
<td data-value='<?php echo $item->{'cost_of_problem_'.$scale}; ?>' ><?php echo $item->{'costmoney_of_problem_'.$scale}; ?></td>
|
||||
<td data-value='<?php echo $item->annual_cost; ?>' ><?php echo $item->annual_costmoney; ?></td>
|
||||
<td data-value='<?php echo $item->{'annual_benefit_'.$scale}; ?>' ><?php echo $item->{'annualmoney_benefit_'.$scale}; ?></td>
|
||||
<td data-value='<?php echo $item->{'benefit_ratio_'.$scale}; ?>' >1:<?php echo round($item->{'benefit_ratio_'.$scale},3); ?></td>
|
||||
<td data-value='<?php echo $item->{'net_benefit_'.$scale}; ?>' ><?php echo $item->{'netmoney_benefit_'.$scale}; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th scope="row"><?php echo JText::_('TOTALS'); ?></th>
|
||||
<td><?php echo $intervention->totals->{'contribution_to_cost_'.$scale}; ?>%</td>
|
||||
<td><?php echo $intervention->totals->annual_costmoney_per_employee; ?></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><?php echo $intervention->totals->{'costmoney_of_problem_'.$scale}; ?></td>
|
||||
<td><?php echo $intervention->totals->annual_costmoney; ?></td>
|
||||
<td><?php echo $intervention->totals->{'annualmoney_benefit_'.$scale}; ?></td>
|
||||
<td></td>
|
||||
<td><?php echo $intervention->totals->{'netmoney_benefit_'.$scale}; ?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="uk-alert uk-alert-warning alert alert-warning"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NO_INTERVENTION_SELECTED'); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage default_table_work_days_lost_summary.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
$scaled = array('unscaled','scaled');
|
||||
|
||||
?>
|
||||
<div id="view_wdls">
|
||||
<h1><?php echo JText::_('COM_COSTBENEFITPROJECTION_WORK_DAYS_LOST_SUMMARY'); ?></h1>
|
||||
|
||||
<?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_DAYS_LOST_AND_CONTRIBUTION_OF_MORBIDITY_MORTALITY_AND_RISK_FACTORS'); ?>
|
||||
<?php if (isset($this->results->items) && CostbenefitprojectionHelper::checkObject($this->results->items)) : ?>
|
||||
<?php foreach ($scaled as $scale): ?>
|
||||
<table id="theTableWDLS_<?php echo $scale; ?>" class="footable table data metro-blue <?php echo $scale; ?>" style="display: <?php echo ($scale == 'unscaled') ? 'table' : 'none'; ?>;" data-page-size="50">
|
||||
<thead>
|
||||
<tr >
|
||||
<th data-toggle="true"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DISEASERISK_FACTOR'); ?></th>
|
||||
<th width="11%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DAYS_LOST_MORBIDITY'); ?></th>
|
||||
<th width="11%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DAYS_LOST_PRESENTEEISM_DUE_TO_MORBIDITY'); ?></th>
|
||||
<th width="11%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DAYS_LOST_MORTALITY'); ?></th>
|
||||
<th width="11%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DAYS_LOST_MALE_EMPLOYEES'); ?></th>
|
||||
<th width="11%" data-hide="phone,tablet"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DAYS_LOST_FEMALE_EMPLOYEES'); ?></th>
|
||||
<th width="11%" data-hide="phone"><?php echo JText::_('COM_COSTBENEFITPROJECTION_TOTAL_DAYS_LOST_PER_DISEASERISK_FACTOR'); ?></th>
|
||||
<th width="11%"><?php echo JText::_('COM_COSTBENEFITPROJECTION_PERCENT_OF_TOTAL_DAYS_LOST'); ?></th>
|
||||
<th width="11%"><?php echo JText::_('COM_COSTBENEFITPROJECTION_PERCENT_OF_ESTIMATED_BURDEN'); ?></th>
|
||||
<th data-hide="all"><?php echo JText::_('COM_COSTBENEFITPROJECTION_DATA'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($this->results->items as $i => &$item): ?>
|
||||
<tr>
|
||||
<th data-value='<?php echo $item->details->alias; ?>' scope="row"><?php echo $item->details->name; ?></th>
|
||||
<td data-value='<?php echo $item->{'subtotal_morbidity_'.$scale}; ?>' ><?php echo round($item->{'subtotal_morbidity_'.$scale},3); ?></td>
|
||||
<td data-value='<?php echo $item->{'subtotal_presenteeism_'.$scale}; ?>' ><?php echo round($item->{'subtotal_presenteeism_'.$scale},3); ?></td>
|
||||
<td data-value='<?php echo $item->{'subtotal_days_lost_mortality_'.$scale}; ?>' ><?php echo round($item->{'subtotal_days_lost_mortality_'.$scale},3); ?></td>
|
||||
<td data-value='<?php echo $item->{'male_days_lost_'.$scale}; ?>' ><?php echo round($item->{'male_days_lost_'.$scale},3); ?></td>
|
||||
<td data-value='<?php echo $item->{'female_days_lost_'.$scale}; ?>' ><?php echo round($item->{'female_days_lost_'.$scale},3); ?></td>
|
||||
<td data-value='<?php echo $item->{'subtotal_days_lost_'.$scale}; ?>' ><?php echo round($item->{'subtotal_days_lost_'.$scale},3); ?></td>
|
||||
<td data-value='<?php echo ($item->{'subtotal_days_lost_'.$scale} / $this->results->totals->{'total_days_lost_'.$scale})*100; ?>' ><?php echo round(($item->{'subtotal_days_lost_'.$scale} / $this->results->totals->{'total_days_lost_'.$scale})*100,3).'%'; ?></td>
|
||||
<td data-value='<?php echo $item->subtotal_estimated_burden; ?>' ><?php echo round($item->subtotal_estimated_burden,3).'%'; ?></td>
|
||||
<td data-value='0' ><?php $item->_tmpType = 'day'; $item->_tmpScale = $scale; echo JLayoutHelper::render('databreakdownmalefemale', $item); ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th scope="row"><?php echo JText::_('TOTALS'); ?></th>
|
||||
<td><?php echo round($this->results->totals->{'total_morbidity_'.$scale},3); ?></td>
|
||||
<td><?php echo round($this->results->totals->{'total_presenteeism_'.$scale},3); ?></td>
|
||||
<td><?php echo round($this->results->totals->{'total_days_lost_mortality_'.$scale},3); ?></td>
|
||||
<td><?php echo round($this->results->totals->{'males_days_lost_'.$scale},3); ?></td>
|
||||
<td><?php echo round($this->results->totals->{'females_days_lost_'.$scale},3); ?></td>
|
||||
<td><?php echo round($this->results->totals->{'total_days_lost_'.$scale},3); ?></td>
|
||||
<td><?php echo round(($this->results->totals->{'total_days_lost_'.$scale} / $this->results->totals->{'total_days_lost_'.$scale})*100,3).'%'; ?></td>
|
||||
<td><?php echo round($this->results->totals->total_estimated_burden,3).'%'; ?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<div class="uk-alert uk-alert-warning alert alert-warning"><?php echo JText::_('COM_COSTBENEFITPROJECTION_NO_DISEASERISK_SELECTED'); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage view.html.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import Joomla view library
|
||||
jimport('joomla.application.component.view');
|
||||
|
||||
/**
|
||||
* Costbenefitprojection View class for the Combinedresults
|
||||
*/
|
||||
class CostbenefitprojectionViewCombinedresults extends JViewLegacy
|
||||
{
|
||||
// Overwriting JView display method
|
||||
function display($tpl = null)
|
||||
{
|
||||
// get combined params of both component and menu
|
||||
$this->app = JFactory::getApplication();
|
||||
$this->params = $this->app->getParams();
|
||||
$this->menu = $this->app->getMenu()->getActive();
|
||||
// get the user object
|
||||
$this->user = JFactory::getUser();
|
||||
// Initialise variables.
|
||||
$this->items = $this->get('Items');
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
JError::raiseWarning(500, implode("\n", $errors));
|
||||
return false;
|
||||
}
|
||||
// check if the data was returned
|
||||
if ($this->items)
|
||||
{
|
||||
// combine the results
|
||||
$this->results = CostbenefitprojectionHelper::combine($this->items);
|
||||
// set the companies names
|
||||
$this->names = $this->results->companiesNames;
|
||||
$this->item = new stdClass();
|
||||
$this->item->currency_name = $this->results->currencyDetails->currency_name;
|
||||
}
|
||||
else
|
||||
{
|
||||
// int all as false
|
||||
$this->results = false;
|
||||
// set the companies names
|
||||
$this->names = JText::_('COM_COSTBENEFITPROJECTION_NONE_LOADED');
|
||||
$this->item = new stdClass();
|
||||
$this->item->currency_name = '';
|
||||
}
|
||||
|
||||
// Set the toolbar
|
||||
$this->addToolBar();
|
||||
|
||||
// set the document
|
||||
$this->_prepareDocument();
|
||||
|
||||
parent::display($tpl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the document
|
||||
*/
|
||||
protected function _prepareDocument()
|
||||
{
|
||||
|
||||
// always make sure jquery is loaded.
|
||||
JHtml::_('jquery.framework');
|
||||
// Load the header checker class.
|
||||
require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' );
|
||||
// Initialize the header checker.
|
||||
$HeaderCheck = new HeaderCheck;
|
||||
|
||||
// Load uikit options.
|
||||
$uikit = $this->params->get('uikit_load');
|
||||
// Set script size.
|
||||
$size = $this->params->get('uikit_min');
|
||||
// Set css style.
|
||||
$style = $this->params->get('uikit_style');
|
||||
|
||||
// The uikit css.
|
||||
if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
|
||||
{
|
||||
$this->document->addStyleSheet(JURI::root(true) .'/media/com_costbenefitprojection/uikit/css/uikit'.$style.$size.'.css');
|
||||
}
|
||||
// The uikit js.
|
||||
if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
|
||||
{
|
||||
$this->document->addScript(JURI::root(true) .'/media/com_costbenefitprojection/uikit/js/uikit'.$size.'.js');
|
||||
}
|
||||
|
||||
// Load the needed uikit components in this view.
|
||||
$uikitComp = $this->get('UikitComp');
|
||||
if ($uikit != 2 && isset($uikitComp) && CostbenefitprojectionHelper::checkArray($uikitComp))
|
||||
{
|
||||
// load just in case.
|
||||
jimport('joomla.filesystem.file');
|
||||
// loading...
|
||||
foreach ($uikitComp as $class)
|
||||
{
|
||||
foreach (CostbenefitprojectionHelper::$uk_components[$class] as $name)
|
||||
{
|
||||
// check if the CSS file exists.
|
||||
if (JFile::exists(JPATH_ROOT.'/media/com_costbenefitprojection/uikit/css/components/'.$name.$style.$size.'.css'))
|
||||
{
|
||||
// load the css.
|
||||
$this->document->addStyleSheet(JURI::root(true) .'/media/com_costbenefitprojection/uikit/css/components/'.$name.$style.$size.'.css');
|
||||
}
|
||||
// check if the JavaScript file exists.
|
||||
if (JFile::exists(JPATH_ROOT.'/media/com_costbenefitprojection/uikit/js/components/'.$name.$size.'.js'))
|
||||
{
|
||||
// load the js.
|
||||
$this->document->addScript(JURI::root(true) .'/media/com_costbenefitprojection/uikit/js/components/'.$name.$size.'.js');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add the google chart builder class.
|
||||
require_once JPATH_COMPONENT_ADMINISTRATOR.'/helpers/chartbuilder.php';
|
||||
// load the google chart js.
|
||||
$this->document->addScript(JURI::root(true) .'/media/com_costbenefitprojection/js/google.jsapi.js');
|
||||
$this->document->addScript('https://canvg.googlecode.com/svn/trunk/rgbcolor.js');
|
||||
$this->document->addScript('https://canvg.googlecode.com/svn/trunk/canvg.js');
|
||||
|
||||
// Add the CSS for Footable.
|
||||
$this->document->addStyleSheet(JURI::root() .'media/com_costbenefitprojection/footable/css/footable.core.min.css');
|
||||
|
||||
// Use the Metro Style
|
||||
if (!isset($this->fooTableStyle) || 0 == $this->fooTableStyle)
|
||||
{
|
||||
$this->document->addStyleSheet(JURI::root() .'media/com_costbenefitprojection/footable/css/footable.metro.min.css');
|
||||
}
|
||||
// Use the Legacy Style.
|
||||
elseif (isset($this->fooTableStyle) && 1 == $this->fooTableStyle)
|
||||
{
|
||||
$this->document->addStyleSheet(JURI::root() .'media/com_costbenefitprojection/footable/css/footable.standalone.min.css');
|
||||
}
|
||||
|
||||
// Add the JavaScript for Footable
|
||||
$this->document->addScript(JURI::root() .'media/com_costbenefitprojection/footable/js/footable.js');
|
||||
$this->document->addScript(JURI::root() .'media/com_costbenefitprojection/footable/js/footable.sort.js');
|
||||
$this->document->addScript(JURI::root() .'media/com_costbenefitprojection/footable/js/footable.filter.js');
|
||||
$this->document->addScript(JURI::root() .'media/com_costbenefitprojection/footable/js/footable.paginate.js');
|
||||
// add custom css
|
||||
$this->document->addStyleSheet(JURI::root(true) ."/administrator/components/com_costbenefitprojection/assets/css/dashboard.css");
|
||||
// add custom js
|
||||
$this->document->addScript(JURI::root(true) .'/media/com_costbenefitprojection/js/chartMenu.js');
|
||||
// set chart stuff
|
||||
$this->Chart['backgroundColor'] = $this->params->get('admin_chartbackground');
|
||||
$this->Chart['width'] = $this->params->get('admin_mainwidth');
|
||||
$this->Chart['chartArea'] = array('top' => $this->params->get('admin_chartareatop'), 'left' => $this->params->get('admin_chartarealeft'), 'width' => $this->params->get('site_chartareawidth').'%');
|
||||
$this->Chart['legend'] = array( 'textStyle' => array('fontSize' => $this->params->get('site_legendtextstylefontsize'), 'color' => $this->params->get('site_legendtextstylefontcolor')));
|
||||
$this->Chart['vAxis'] = array('textStyle' => array('color' => $this->params->get('site_vaxistextstylefontcolor')));
|
||||
$this->Chart['hAxis']['textStyle'] = array('color' => $this->params->get('site_haxistextstylefontcolor'));
|
||||
$this->Chart['hAxis']['titleTextStyle'] = array('color' => $this->params->get('site_haxistitletextstylefontcolor'));
|
||||
// add the document default css file
|
||||
$this->document->addStyleSheet(JURI::root(true) .'/components/com_costbenefitprojection/assets/css/combinedresults.css');
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting the toolbar
|
||||
*/
|
||||
protected function addToolBar()
|
||||
{
|
||||
// adding the joomla toolbar to the front
|
||||
JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php');
|
||||
|
||||
// set help url for this view if found
|
||||
$help_url = CostbenefitprojectionHelper::getHelpUrl('combinedresults');
|
||||
if (CostbenefitprojectionHelper::checkString($help_url))
|
||||
{
|
||||
JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url);
|
||||
}
|
||||
// now initiate the toolbar
|
||||
$this->toolbar = JToolbar::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a value for output in a view script.
|
||||
*
|
||||
* @param mixed $var The output to escape.
|
||||
*
|
||||
* @return mixed The escaped value.
|
||||
*/
|
||||
public function escape($var, $sorten = false, $length = 40)
|
||||
{
|
||||
// use the helper htmlEscape method instead.
|
||||
return CostbenefitprojectionHelper::htmlEscape($var, $this->_charset, $sorten, $length);
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage submitbutton.js
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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.
|
||||
/------------------------------------------------------------------------------------------------------*/
|
||||
|
||||
Joomla.submitbutton = function(task)
|
||||
{
|
||||
if (task == ''){
|
||||
return false;
|
||||
} else {
|
||||
var isValid=true;
|
||||
var action = task.split('.');
|
||||
if (action[1] != 'cancel' && action[1] != 'close'){
|
||||
var forms = $$('form.form-validate');
|
||||
for (var i=0;i<forms.length;i++){
|
||||
if (!document.formvalidator.isValid(forms[i])){
|
||||
isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isValid){
|
||||
Joomla.submitform(task);
|
||||
return true;
|
||||
} else {
|
||||
alert(Joomla.JText._('company, some values are not acceptable.','Some values are unacceptable'));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,328 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage edit.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
JHtml::_('behavior.tooltip');
|
||||
JHtml::_('behavior.formvalidation');
|
||||
JHtml::_('formbehavior.chosen', 'select');
|
||||
JHtml::_('behavior.keepalive');
|
||||
JHtml::_('behavior.tabstate');
|
||||
JHtml::_('behavior.calendar');
|
||||
$componentParams = JComponentHelper::getParams('com_costbenefitprojection');
|
||||
?>
|
||||
<?php echo $this->toolbar->render(); ?>
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_costbenefitprojection&layout=edit&id='.(int) $this->item->id.$this->referral); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
|
||||
|
||||
<?php echo JLayoutHelper::render('company.details_above', $this); ?><div class="form-horizontal">
|
||||
|
||||
<?php echo JHtml::_('bootstrap.startTabSet', 'companyTab', array('active' => 'details')); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'companyTab', 'details', JText::_('COM_COSTBENEFITPROJECTION_COMPANY_DETAILS', true)); ?>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
<div class="span6">
|
||||
<?php echo JLayoutHelper::render('company.details_left', $this); ?>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<?php echo JLayoutHelper::render('company.details_right', $this); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'companyTab', 'age_groups_percentages', JText::_('COM_COSTBENEFITPROJECTION_COMPANY_AGE_GROUPS_PERCENTAGES', true)); ?>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
<div class="span6">
|
||||
<?php echo JLayoutHelper::render('company.age_groups_percentages_left', $this); ?>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<?php echo JLayoutHelper::render('company.age_groups_percentages_right', $this); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
<div class="span12">
|
||||
<?php echo JLayoutHelper::render('company.age_groups_percentages_fullwidth', $this); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'companyTab', 'causerisk_selection', JText::_('COM_COSTBENEFITPROJECTION_COMPANY_CAUSERISK_SELECTION', true)); ?>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
</div>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
<div class="span12">
|
||||
<?php echo JLayoutHelper::render('company.causerisk_selection_fullwidth', $this); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
|
||||
<?php if ($this->canDo->get('scaling_factor.access')) : ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'companyTab', 'scaling_factors', JText::_('COM_COSTBENEFITPROJECTION_COMPANY_SCALING_FACTORS', true)); ?>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
</div>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
<div class="span12">
|
||||
<?php echo JLayoutHelper::render('company.scaling_factors_fullwidth', $this); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->canDo->get('intervention.access')) : ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'companyTab', 'interventions', JText::_('COM_COSTBENEFITPROJECTION_COMPANY_INTERVENTIONS', true)); ?>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
</div>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
<div class="span12">
|
||||
<?php echo JLayoutHelper::render('company.interventions_fullwidth', $this); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->canDo->get('company.delete') || $this->canDo->get('company.edit.created_by') || $this->canDo->get('company.edit.state') || $this->canDo->get('company.edit.created')) : ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'companyTab', 'publishing', JText::_('COM_COSTBENEFITPROJECTION_COMPANY_PUBLISHING', true)); ?>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
<div class="span6">
|
||||
<?php echo JLayoutHelper::render('company.publishing', $this); ?>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<?php echo JLayoutHelper::render('company.publlshing', $this); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($this->canDo->get('core.admin')) : ?>
|
||||
<?php echo JHtml::_('bootstrap.addTab', 'companyTab', 'permissions', JText::_('COM_COSTBENEFITPROJECTION_COMPANY_PERMISSION', true)); ?>
|
||||
<div class="row-fluid form-horizontal-desktop">
|
||||
<div class="span12">
|
||||
<fieldset class="adminform">
|
||||
<div class="adminformlist">
|
||||
<?php foreach ($this->form->getFieldset('accesscontrol') as $field): ?>
|
||||
<div>
|
||||
<?php echo $field->label; echo $field->input;?>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
|
||||
|
||||
<div>
|
||||
<input type="hidden" name="task" value="company.edit" />
|
||||
<?php echo JHtml::_('form.token'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
<?php echo JLayoutHelper::render('company.details_under', $this); ?>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
// #jform_department listeners for department_vvvvvvv function
|
||||
jQuery('#jform_department').on('keyup',function()
|
||||
{
|
||||
var department_vvvvvvv = jQuery("#jform_department input[type='radio']:checked").val();
|
||||
vvvvvvv(department_vvvvvvv);
|
||||
|
||||
});
|
||||
jQuery('#adminForm').on('change', '#jform_department',function (e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var department_vvvvvvv = jQuery("#jform_department input[type='radio']:checked").val();
|
||||
vvvvvvv(department_vvvvvvv);
|
||||
|
||||
});
|
||||
|
||||
// #jform_department listeners for department_vvvvvvw function
|
||||
jQuery('#jform_department').on('keyup',function()
|
||||
{
|
||||
var department_vvvvvvw = jQuery("#jform_department input[type='radio']:checked").val();
|
||||
vvvvvvw(department_vvvvvvw);
|
||||
|
||||
});
|
||||
jQuery('#adminForm').on('change', '#jform_department',function (e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var department_vvvvvvw = jQuery("#jform_department input[type='radio']:checked").val();
|
||||
vvvvvvw(department_vvvvvvw);
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
jQuery('#adminForm').on('change', '#jform_causesrisks',function (e)
|
||||
{
|
||||
// first we build the checked array
|
||||
checkedArray = [];
|
||||
jQuery('#jform_causesrisks input[type=checkbox]').each(function()
|
||||
{
|
||||
if (jQuery(this).is(':checked'))
|
||||
{
|
||||
checkedArray.push(jQuery(jQuery("label[for='"+jQuery(this).prop('id')+"']").html()).prop('id'));
|
||||
}
|
||||
});
|
||||
// now we check if child is checked and uncheck perant
|
||||
jQuery('#jform_causesrisks input[type=checkbox]').each(function()
|
||||
{
|
||||
if (jQuery(this).is(':checked'))
|
||||
{
|
||||
var checing = jQuery(jQuery("label[for='"+jQuery(this).prop('id')+"']").html()).prop('id');
|
||||
// first remove this checkd item from array
|
||||
checkedArrayChecker = jQuery.grep(checkedArray, function(value) {
|
||||
return value != checing;
|
||||
});
|
||||
// now uncheck the perant checkboxes
|
||||
jQuery.each( checkedArrayChecker,function(index,value)
|
||||
{
|
||||
if (checing.indexOf(value) >= 0)
|
||||
{
|
||||
var block = jQuery('label > span#'+value).closest('li').find('input').prop('id');
|
||||
jQuery('#'+block).prop('checked', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// add the calculator button
|
||||
var cal_button = ' <a class="btn btn-small btn-success" href="https://www.staffhealthcbp.com/download/Productivity_Losses_Calculator_V1.xlsx"> <span class="icon-download icon-white"></span> Calculator </a>';
|
||||
jQuery('#jform_productivity_losses').closest('.controls').append(cal_button);jQuery('input.form-field-repeatable').on('weready', function(e, value){
|
||||
if ("jform_percentmale" == e.currentTarget.id)
|
||||
{
|
||||
calPercent('male');
|
||||
}
|
||||
else if("jform_percentfemale" == e.currentTarget.id)
|
||||
{
|
||||
calPercent('female');
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('input.form-field-repeatable').on('value-update', function(e, value){
|
||||
if (value)
|
||||
{
|
||||
buildTable(value,e.currentTarget.id);
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('input.form-field-repeatable').on('row-add', function(e, row) {
|
||||
if ("jform_percentmale" == e.currentTarget.id)
|
||||
{
|
||||
setSelection('male');
|
||||
updateSelection(row);
|
||||
}
|
||||
else if("jform_percentfemale" == e.currentTarget.id)
|
||||
{
|
||||
setSelection('female');
|
||||
updateSelection(row);
|
||||
}
|
||||
});
|
||||
|
||||
jQuery('input.form-field-repeatable').on('row-remove', function(e, row) {
|
||||
if ("jform_percentmale" == e.currentTarget.id)
|
||||
{
|
||||
calPercent('male');
|
||||
}
|
||||
else if("jform_percentfemale" == e.currentTarget.id)
|
||||
{
|
||||
calPercent('female');
|
||||
}
|
||||
});
|
||||
|
||||
var AgeGroup = new Array;
|
||||
function setSelection(gender)
|
||||
{
|
||||
AgeGroup.length = 0;
|
||||
<?php $fieldNrs = range(1,9,1); ?>
|
||||
<?php foreach($fieldNrs as $fieldNr): ?>
|
||||
// get options
|
||||
var age_<?php echo $fieldNr ?> = jQuery("#jform_percent"+gender+"_fields_age-<?php echo $fieldNr ?> option:selected").val();
|
||||
if (age_<?php echo $fieldNr ?>)
|
||||
{
|
||||
AgeGroup.push(age_<?php echo $fieldNr ?>);
|
||||
}
|
||||
<?php endforeach; ?>
|
||||
}
|
||||
|
||||
<?php $fieldNrs = range(1,10,1); ?>
|
||||
jQuery('#jform_percentmale_modal').on('show.bs.modal', function (e) {
|
||||
<?php foreach($fieldNrs as $fieldNr): ?>jQuery('#jform_percentmale_modal').on('change', '#jform_percentmale_fields_percent-<?php echo $fieldNr ?>',function () {
|
||||
// calculate
|
||||
calPercent('male');
|
||||
});
|
||||
jQuery('#jform_percentmale_fields_percent-<?php echo $fieldNr ?>').on('keyup',function() {
|
||||
// calculate
|
||||
calPercent('male');
|
||||
});
|
||||
<?php endforeach; ?>
|
||||
});
|
||||
jQuery('#jform_percentfemale_modal').on('show.bs.modal', function (e) {
|
||||
<?php foreach($fieldNrs as $fieldNr): ?>jQuery('#jform_percentfemale_modal').on('change', '#jform_percentfemale_fields_percent-<?php echo $fieldNr ?>',function () {
|
||||
// calculate
|
||||
calPercent('female');
|
||||
});
|
||||
jQuery('#jform_percentfemale_fields_percent-<?php echo $fieldNr ?>').on('keyup',function() {
|
||||
// calculate
|
||||
calPercent('female');
|
||||
});
|
||||
<?php endforeach; ?>
|
||||
});
|
||||
|
||||
var Percent = new Array;
|
||||
function calPercent(gender)
|
||||
{
|
||||
Percent.length = 0;
|
||||
<?php foreach($fieldNrs as $fieldNr): ?>
|
||||
// get options
|
||||
var age_<?php echo $fieldNr ?> = jQuery("#jform_percent"+gender+"_fields_percent-<?php echo $fieldNr ?>").val();
|
||||
if (age_<?php echo $fieldNr ?> && age_<?php echo $fieldNr ?>.match(/^\d+$/))
|
||||
{
|
||||
Percent.push(age_<?php echo $fieldNr ?>);
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery("#jform_percent"+gender+"_fields_percent-<?php echo $fieldNr ?>").val('');
|
||||
}
|
||||
<?php endforeach; ?>
|
||||
var total = 0;
|
||||
for (var i = 0; i < Percent.length; i++) {
|
||||
total += Percent[i] << 0;
|
||||
}
|
||||
if (total != 100)
|
||||
{
|
||||
jQuery('#jform_percent'+gender+'_modal .save-modal-data').hide();
|
||||
jQuery('#jform_percent'+gender+'_total').remove();
|
||||
jQuery('#jform_percent'+gender+'_modal .modal-footer').append('<span id="jform_percent'+gender+'_total" style="color:red;"><small>(Must be 100%)</small> Total: '+total+'%</span>');
|
||||
}
|
||||
else
|
||||
{
|
||||
jQuery('#jform_percent'+gender+'_total').remove();
|
||||
jQuery('.save-modal-data').text('Done 100%');
|
||||
jQuery('#jform_percent'+gender+'_modal .save-modal-data').show();
|
||||
}
|
||||
}
|
||||
</script>
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
/*----------------------------------------------------------------------------------| www.giz.de |----/
|
||||
Deutsche Gesellschaft für International Zusammenarbeit (GIZ) Gmb
|
||||
/-------------------------------------------------------------------------------------------------------/
|
||||
|
||||
@version 3.3.8
|
||||
@build 10th March, 2016
|
||||
@created 15th June, 2012
|
||||
@package Cost Benefit Projection
|
||||
@subpackage view.html.php
|
||||
@author Llewellyn van der Merwe <http://www.vdm.io>
|
||||
@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');
|
||||
|
||||
// import Joomla view library
|
||||
jimport('joomla.application.component.view');
|
||||
|
||||
/**
|
||||
* Company View class
|
||||
*/
|
||||
class CostbenefitprojectionViewCompany extends JViewLegacy
|
||||
{
|
||||
/**
|
||||
* display method of View
|
||||
* @return void
|
||||
*/
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
JError::raiseError(500, implode('<br />', $errors));
|
||||
return false;
|
||||
}
|
||||
|
||||
// Assign the variables
|
||||
$this->form = $this->get('Form');
|
||||
$this->item = $this->get('Item');
|
||||
$this->script = $this->get('Script');
|
||||
$this->state = $this->get('State');
|
||||
// get action permissions
|
||||
$this->canDo = CostbenefitprojectionHelper::getActions('company',$this->item);
|
||||
// get input
|
||||
$jinput = JFactory::getApplication()->input;
|
||||
$this->ref = $jinput->get('ref', 0, 'word');
|
||||
$this->refid = $jinput->get('refid', 0, 'int');
|
||||
$this->referral = '';
|
||||
if ($this->refid)
|
||||
{
|
||||
// return to the item that refered to this item
|
||||
$this->referral = '&ref='.(string)$this->ref.'&refid='.(int)$this->refid;
|
||||
}
|
||||
elseif($this->ref)
|
||||
{
|
||||
// return to the list view that refered to this item
|
||||
$this->referral = '&ref='.(string)$this->ref;
|
||||
}
|
||||
|
||||
// Get Linked view data
|
||||
$this->vwcscaling_factors = $this->get('Vwcscaling_factors');
|
||||
|
||||
// Get Linked view data
|
||||
$this->vwdinterventions = $this->get('Vwdinterventions');
|
||||
|
||||
// Set the toolbar
|
||||
$this->addToolBar();
|
||||
|
||||
// Display the template
|
||||
parent::display($tpl);
|
||||
|
||||
// Set the document
|
||||
$this->setDocument();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Setting the toolbar
|
||||
*/
|
||||
protected function addToolBar()
|
||||
{
|
||||
// adding the joomla edit toolbar to the front
|
||||
JLoader::register('JToolbarHelper', JPATH_ADMINISTRATOR.'/includes/toolbar.php');
|
||||
JFactory::getApplication()->input->set('hidemainmenu', true);
|
||||
$user = JFactory::getUser();
|
||||
$userId = $user->id;
|
||||
$isNew = $this->item->id == 0;
|
||||
|
||||
JToolbarHelper::title( JText::_($isNew ? 'COM_COSTBENEFITPROJECTION_COMPANY_NEW' : 'COM_COSTBENEFITPROJECTION_COMPANY_EDIT'), 'pencil-2 article-add');
|
||||
// Built the actions for new and existing records.
|
||||
if ($this->refid || $this->ref)
|
||||
{
|
||||
if ($this->canDo->get('company.create') && $isNew)
|
||||
{
|
||||
// We can create the record.
|
||||
JToolBarHelper::save('company.save', 'JTOOLBAR_SAVE');
|
||||
}
|
||||
elseif ($this->canDo->get('company.edit'))
|
||||
{
|
||||
// We can save the record.
|
||||
JToolBarHelper::save('company.save', 'JTOOLBAR_SAVE');
|
||||
}
|
||||
if ($isNew)
|
||||
{
|
||||
// Do not creat but cancel.
|
||||
JToolBarHelper::cancel('company.cancel', 'JTOOLBAR_CANCEL');
|
||||
}
|
||||
else
|
||||
{
|
||||
// We can close it.
|
||||
JToolBarHelper::cancel('company.cancel', 'JTOOLBAR_CLOSE');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($isNew)
|
||||
{
|
||||
// For new records, check the create permission.
|
||||
if ($this->canDo->get('company.create'))
|
||||
{
|
||||
JToolBarHelper::apply('company.apply', 'JTOOLBAR_APPLY');
|
||||
JToolBarHelper::save('company.save', 'JTOOLBAR_SAVE');
|
||||
JToolBarHelper::custom('company.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
|
||||
};
|
||||
JToolBarHelper::cancel('company.cancel', 'JTOOLBAR_CANCEL');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->canDo->get('company.edit'))
|
||||
{
|
||||
// We can save the new record
|
||||
JToolBarHelper::apply('company.apply', 'JTOOLBAR_APPLY');
|
||||
JToolBarHelper::save('company.save', 'JTOOLBAR_SAVE');
|
||||
// We can save this record, but check the create permission to see
|
||||
// if we can return to make a new one.
|
||||
if ($this->canDo->get('company.create'))
|
||||
{
|
||||
JToolBarHelper::custom('company.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
|
||||
}
|
||||
}
|
||||
$canVersion = ($this->canDo->get('core.version') && $this->canDo->get('company.version'));
|
||||
if ($this->state->params->get('save_history', 1) && $this->canDo->get('company.edit') && $canVersion)
|
||||
{
|
||||
JToolbarHelper::versions('com_costbenefitprojection.company', $this->item->id);
|
||||
}
|
||||
if ($this->canDo->get('company.create'))
|
||||
{
|
||||
JToolBarHelper::custom('company.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
|
||||
}
|
||||
JToolBarHelper::cancel('company.cancel', 'JTOOLBAR_CLOSE');
|
||||
}
|
||||
}
|
||||
JToolbarHelper::divider();
|
||||
// set help url for this view if found
|
||||
$help_url = CostbenefitprojectionHelper::getHelpUrl('company');
|
||||
if (CostbenefitprojectionHelper::checkString($help_url))
|
||||
{
|
||||
JToolbarHelper::help('COM_COSTBENEFITPROJECTION_HELP_MANAGER', false, $help_url);
|
||||
}
|
||||
// now initiate the toolbar
|
||||
$this->toolbar = JToolbar::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a value for output in a view script.
|
||||
*
|
||||
* @param mixed $var The output to escape.
|
||||
*
|
||||
* @return mixed The escaped value.
|
||||
*/
|
||||
public function escape($var)
|
||||
{
|
||||
if(strlen($var) > 30)
|
||||
{
|
||||
// use the helper htmlEscape method instead and shorten the string
|
||||
return CostbenefitprojectionHelper::htmlEscape($var, $this->_charset, true, 30);
|
||||
}
|
||||
// use the helper htmlEscape method instead.
|
||||
return CostbenefitprojectionHelper::htmlEscape($var, $this->_charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to set up the document properties
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setDocument()
|
||||
{
|
||||
$isNew = ($this->item->id < 1);
|
||||
$document = JFactory::getDocument();
|
||||
$document->setTitle(JText::_($isNew ? 'COM_COSTBENEFITPROJECTION_COMPANY_NEW' : 'COM_COSTBENEFITPROJECTION_COMPANY_EDIT'));
|
||||
// we need this to fix the form display
|
||||
$document->addStyleSheet(JURI::root()."administrator/templates/isis/css/template.css");
|
||||
$document->addScript(JURI::root()."administrator/templates/isis/js/template.js");
|
||||
// the default style of this view
|
||||
$document->addStyleSheet(JURI::root()."components/com_costbenefitprojection/assets/css/company.css");
|
||||
|
||||
// Add the CSS for Footable.
|
||||
$document->addStyleSheet(JURI::root() .'media/com_costbenefitprojection/footable/css/footable.core.min.css');
|
||||
|
||||
// Use the Metro Style
|
||||
if (!isset($this->fooTableStyle) || 0 == $this->fooTableStyle)
|
||||
{
|
||||
$document->addStyleSheet(JURI::root() .'media/com_costbenefitprojection/footable/css/footable.metro.min.css');
|
||||
}
|
||||
// Use the Legacy Style.
|
||||
elseif (isset($this->fooTableStyle) && 1 == $this->fooTableStyle)
|
||||
{
|
||||
$document->addStyleSheet(JURI::root() .'media/com_costbenefitprojection/footable/css/footable.standalone.min.css');
|
||||
}
|
||||
|
||||
// Add the JavaScript for Footable
|
||||
$document->addScript(JURI::root() .'media/com_costbenefitprojection/footable/js/footable.js');
|
||||
$document->addScript(JURI::root() .'media/com_costbenefitprojection/footable/js/footable.sort.js');
|
||||
$document->addScript(JURI::root() .'media/com_costbenefitprojection/footable/js/footable.filter.js');
|
||||
$document->addScript(JURI::root() .'media/com_costbenefitprojection/footable/js/footable.paginate.js');
|
||||
|
||||
$footable = "jQuery(document).ready(function() { jQuery(function () { jQuery('.footable').footable(); }); jQuery('.nav-tabs').on('click', 'li', function() { setTimeout(tableFix, 10); }); }); function tableFix() { jQuery('.footable').trigger('footable_resize'); }";
|
||||
$document->addScriptDeclaration($footable);
|
||||
|
||||
// default javascript of this view
|
||||
$document->addScript(JURI::root().$this->script);
|
||||
$document->addScript(JURI::root(). "components/com_costbenefitprojection/views/company/submitbutton.js");
|
||||
JText::script('view not acceptable. Error');
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user