dashboard

This commit is contained in:
2019-11-13 08:09:28 +01:00
parent 92a460f0ff
commit f185d467fb
7 changed files with 244 additions and 21 deletions
@@ -0,0 +1,54 @@
<?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
] );
}
}