diversen dashboard

This commit is contained in:
2020-01-17 12:04:29 +01:00
parent 69766f7a63
commit 20fc96a8fd
6 changed files with 196 additions and 63 deletions
@@ -42,16 +42,68 @@ class DashboardController extends MY_Controller {
$available += $project['budgetAvailable'];
}
$outstandings = $this->Invoices_model-> getTotalsOutstandingPerProject();
$outstandings = $this->Invoices_model->getTotalsOutstandingPerProject(FALSE);
$this->json( [
'totalOwp' => round( $totalOwp, 0 ),
'revenuesThisYear' => $this->getRevenuesThisYear(),
'currentFinancialYear' => round( $currentFinancialYear ),
'owpNextyear' => round( $totalOwp - $currentFinancialYear ),
'revenuesNextyear' => round( $totalOwp / 0.4 ),
'revenuesNextyear' => round( $currentFinancialYear / 0.4 ),
'totalRevenues' => round( $totalRevenues ),
'outstandings' => $outstandings
'outstandings' => $this->getInvoiceOverview(),
'costsToPay' => $this->reservations()
] );
}
private function getRevenuesThisYear()
{
$year = date('Y');
$sql = QEmployeeHours::fire( FALSE, $year );
$query = $this->db->query( $sql );
$result = $query->result();
$totalRevenue = 0;
foreach($result as $revenue)
{
$totalRevenue += $revenue->revenues;
}
return $totalRevenue;
}
private function getInvoiceOverview( )
{
$projects = Project::whereArchive('F')->get();
foreach($projects as $project)
{
$invoiceOverview = new InvoiceOverview( $project, date('Y') );
$invoiceOverviews[] = $invoiceOverview->getProjectDetails();
}
return $invoiceOverviews;
}
private function reservations()
{
$sql = ReservationTotals::fire();
$query = $this->db->query( $sql );
$results = $query->result();
$costsToPay = 0;
foreach($results as $result)
{
$toPay = $result->other_revenue - $result->costs + $result->saldoToPay;
$costsToPay += $toPay;
}
return $costsToPay;
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
{
parent::__construct();
$this->version = '1.00.12';
$this->version = '1.00.30';
$this->load->library( 'beheer/session/RetrieveUserSession' );
@@ -35,7 +35,8 @@ class Invoices_model extends MY_Model {
JOIN invoices INV
ON INV.id = PAY.invoice_id
WHERE INV.project_id = {$projectID}
) AS payed
) AS payed,
PRJ.archive
FROM invoices INV
JOIN projects PRJ
ON PRJ.id = INV.project_id
@@ -55,7 +56,7 @@ class Invoices_model extends MY_Model {
return $invoiceDetails;
}
public function getTotalsOutstandingPerProject()
public function getTotalsOutstandingPerProject($archive = TRUE)
{
$this->sql = "
SELECT
@@ -102,9 +103,12 @@ class Invoices_model extends MY_Model {
FROM
projectcosts
GROUP BY
project_id) Q4 ON Q4.project_id = PRJ.id
GROUP BY
PRJ.id ";
project_id) Q4 ON Q4.project_id = PRJ.id ";
if( $archive == FALSE ) $this->sql .= "WHERE PRJ.archive = 'F' ";
$this->sql .= "
GROUP BY
PRJ.id ";
$outstandings = $this->get_query_result();
+43 -3
View File
@@ -35,11 +35,13 @@
<br>
<h4>
<span class="db-panel-label">Omzet komende jaar:</span>
<span class="db-panel-data"><strong data-bind="text:revenuesNextyear"></strong></span>
<span class="db-panel-data">
<strong data-bind="text:revenuesNextyear"></strong>
</span>
</h4>
<h4>
<span class="db-panel-label">Omzet totaal gerealiseerd lopend jaar:</span>
<span class="db-panel-data"><strong data-bind="text:owpThisYear"></strong></span>
<span class="db-panel-data"><strong data-bind="text:revenuesThisYear"></strong></span>
</h4>
</div>
</div>
@@ -51,13 +53,51 @@
<div class="db-panel-heading">
<h3 class="db-panel-title">
Facturatie
<span style="margin-left:10px;display:none"
class="glyphicon glyphicon-question-sign pointer"
data-bind="click:invoiceOverview"></span>
<div class="facturation-overview-holder">
<!-- ko if:showInvoiceOverview -->
<div class="facturation-overview" data-bind="click:invoiceOverview">
<table class="table">
<thead>
<tr>
<th>project</th>
<th>gefactureerd</th>
<th>betaald</th>
<th>te betalen</th>
</tr>
</thead>
<tbody data-bind="foreach:billingOverview">
<tr>
<td>
<span data-bind="text:project"></span>
</td>
<td>
<span data-bind="text:invoiced"></span>
</td>
<td>
<span data-bind="text:payedcosts"></span>
</td>
<td>
<span data-bind="text:openCosts"></span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- /ko -->
</div>
</h3>
</div>
<div class="db-panel-body" data-bind="width:owp">
<br>
<h4>
<span class="db-panel-label">Openstaande facturen (incl btw):</span>
<span class="db-panel-data"><strong data-bind="text:outstanding"></strong></span>
<span class="db-panel-data">
<strong data-bind="text:openInvoices">
</strong>
</span>
</h4>
<h4>
<span class="db-panel-label">Nog te factureren (incl btw):</span>