55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Created by Pensare Software.
|
|
* User: Theo Weijmer
|
|
* Date: 31/10/2019
|
|
* Time: 14:53
|
|
*/
|
|
|
|
class DashboardController extends MY_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function getOwhp()
|
|
{
|
|
$recapprojects = new Recapprojects( 'F', FALSE, FALSE );
|
|
|
|
$projects = $recapprojects->getProjects();
|
|
|
|
$currentFinancialYear = 0;
|
|
$totalRevenues = 0;
|
|
$totalOwp = 0;
|
|
$ownRevenue = 0;
|
|
$available = 0;
|
|
foreach ( $projects as $project )
|
|
{
|
|
$revenues = 0;
|
|
foreach ( $project['employees'] as $employee )
|
|
{
|
|
$revenues += $employee['revenues'];
|
|
}
|
|
$currentFinancialYear += $project['current_financial_year'];
|
|
|
|
$owp = $project['own_revenue'] - $revenues;
|
|
$owp = $owp > 0 ? $owp : 0;
|
|
$totalOwp += $owp;
|
|
|
|
$ownRevenue += $project['own_revenue'];
|
|
$totalRevenues += $revenues;
|
|
$available += $project['budgetAvailable'];
|
|
}
|
|
|
|
$this->json( [
|
|
'totalOwp' => $totalOwp,
|
|
'currentFinancialYear' => $currentFinancialYear,
|
|
'owpNextyear' => $totalOwp - $currentFinancialYear,
|
|
'revenuesNextyear' => $totalOwp / 0.4,
|
|
'totalRevenues' => $totalRevenues
|
|
] );
|
|
}
|
|
|
|
}
|