diff --git a/application/controllers/dashboard/DashboardController.php b/application/controllers/dashboard/DashboardController.php
index 1fa1efc..e3b768f 100644
--- a/application/controllers/dashboard/DashboardController.php
+++ b/application/controllers/dashboard/DashboardController.php
@@ -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;
+ }
+
}
diff --git a/application/core/MY_Controller.php b/application/core/MY_Controller.php
index edfb98d..746efd9 100644
--- a/application/core/MY_Controller.php
+++ b/application/core/MY_Controller.php
@@ -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' );
diff --git a/application/models/projects/Invoices_model.php b/application/models/projects/Invoices_model.php
index 3c28eff..7d08cd2 100644
--- a/application/models/projects/Invoices_model.php
+++ b/application/models/projects/Invoices_model.php
@@ -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();
diff --git a/application/views/pages/dashboard_view.php b/application/views/pages/dashboard_view.php
index a28bfa6..073f838 100644
--- a/application/views/pages/dashboard_view.php
+++ b/application/views/pages/dashboard_view.php
@@ -35,11 +35,13 @@
Omzet komende jaar:
-
+
+
+
Omzet totaal gerealiseerd lopend jaar:
-
+
@@ -51,13 +53,51 @@
Facturatie
+
+
+
+
+
+
+
+ | project |
+ gefactureerd |
+ betaald |
+ te betalen |
+
+
+
+
+ |
+
+ |
+
+
+ |
+
+
+ |
+
+
+ |
+
+
+
+
+
+
Openstaande facturen (incl btw):
-
+
+
+
+
Nog te factureren (incl btw):
diff --git a/public/css/dashboard.css b/public/css/dashboard.css
index 5cd8648..74c97cf 100644
--- a/public/css/dashboard.css
+++ b/public/css/dashboard.css
@@ -49,3 +49,15 @@
float: right;
margin-top: 10px;
}
+.facturation-overview-holder {
+ position: relative;
+}
+.facturation-overview {
+ position: absolute;
+ background-color: #a2c3ed;
+ font-size: 12px;
+ color: #000;
+ top: -40px;
+ border: 2px solid #000;
+ border-radius: 20px;
+}
\ No newline at end of file
diff --git a/public/js/lib/modules/dashboard/dashboardModule.js b/public/js/lib/modules/dashboard/dashboardModule.js
index 8b5b8de..0c34ab7 100644
--- a/public/js/lib/modules/dashboard/dashboardModule.js
+++ b/public/js/lib/modules/dashboard/dashboardModule.js
@@ -7,69 +7,94 @@
dbo.dashboardInit = function () {
- if ( dbo.dashboardModel !== undefined ) {
+ if (dbo.dashboardModel !== undefined) {
- dbo.dashboardModel.init();
+ dbo.dashboardModel.init()
} else {
dbo.dashboardModel = {
-
- owpThisYear : ko.observable( null ),
- owpNextYear : ko.observable( null ),
- owpTotal : ko.observable( null ),
- revenuesNextyear : ko.observable( null ),
- totalRevenues : ko.observable( null ),
- outstanding : ko.observable( null ),
- toInvoice : ko.observable( null ),
- openCosts : ko.observable( null ),
- revenues : ko.observable( null ),
- revenues : ko.observable( null ),
- revenueCurrentYear: ko.observable( null ),
+ owpThisYear : ko.observable(null),
+ owpNextYear : ko.observable(null),
+ owpTotal : ko.observable(null),
+ revenuesNextyear : ko.observable(null),
+ totalRevenues : ko.observable(null),
+ outstanding : ko.observable(null),
+ toInvoice : ko.observable(null),
+ openCosts : ko.observable(null),
+ revenues : ko.observable(null),
+ revenues : ko.observable(null),
+ revenueCurrentYear : ko.observable(null),
+ revenuesThisYear : ko.observable(null),
+ billingOverview : ko.observableArray([]),
+ showInvoiceOverview: ko.observable(false),
+ openInvoices : ko.observable(null),
init: function () {
- var self = dbo.dashboardModel;
- dbo.dashboardDataservice.getOwhp( function ( data ) {
- var outstandings = self.getOutstandingTotal( data.outstandings );
- var revCurYear = Number( data.currentFinancialYear ) + Number( data.totalOwp );
+ var self = dbo.dashboardModel
+ dbo.dashboardDataservice.getOwhp(function (data) {
+ var outstandings = self.getOutstandingTotal(data.outstandings)
+ var revCurYear = Number(data.currentFinancialYear) + Number(data.totalOwp)
- self.owpThisYear( dbo.helpers.thousandSeparator( data.currentFinancialYear ) );
- self.owpNextYear( dbo.helpers.thousandSeparator( data.owpNextyear ) );
- self.owpTotal( dbo.helpers.thousandSeparator( data.totalOwp ) );
- self.revenuesNextyear( dbo.helpers.thousandSeparator( data.revenuesNextyear ) );
- self.totalRevenues( dbo.helpers.thousandSeparator( data.totalRevenues ) );
- self.outstanding( dbo.helpers.thousandSeparator( outstandings.open ) );
- self.toInvoice( dbo.helpers.thousandSeparator( outstandings.toInvoice ) );
- self.openCosts( dbo.helpers.thousandSeparator( outstandings.openCosts ) );
- self.revenues( dbo.helpers.thousandSeparator( outstandings.revenues ) );
- self.revenueCurrentYear( dbo.helpers.thousandSeparator( revCurYear ) );
- } );
+ self.owpThisYear(dbo.helpers.thousandSeparator(data.currentFinancialYear))
+ self.owpNextYear(dbo.helpers.thousandSeparator(data.owpNextyear))
+ self.owpTotal(dbo.helpers.thousandSeparator(data.totalOwp))
+ self.revenuesNextyear(dbo.helpers.thousandSeparator(data.revenuesNextyear))
+ self.totalRevenues(dbo.helpers.thousandSeparator(data.totalRevenues))
+ self.openInvoices(dbo.helpers.thousandSeparator(outstandings.openInvoices))
+ self.toInvoice(dbo.helpers.thousandSeparator(outstandings.toInvoice))
+
+ self.revenues(dbo.helpers.thousandSeparator(outstandings.revenues))
+ self.revenueCurrentYear(dbo.helpers.thousandSeparator(revCurYear))
+ self.revenuesThisYear(dbo.helpers.thousandSeparator(data.revenuesThisYear))
+ })
+ dbo.reservationsDataservice.getReservations(function(data){
+ var openCosts = 0
+ $.each(data, function(i,p){
+ openCosts += Number(p.other_revenue) - Number(p.payed);
+ })
+ self.openCosts(dbo.helpers.thousandSeparator(openCosts))
+ })
},
- getOutstandingTotal: function ( data ) {
- var open = 0;
- var toInvoice = 0;
- var costs = 0;
- var openCosts = 0;
- _.each( data, function ( p ) {
- open += Number( p.invoiced ) - Number( p.payment );
- toInvoice += Number( p.revenues ) - Number( p.invoiced );
- costs += Number( p.costs );
- openCosts += Number( p.costs ) - Number( p.payedcosts )
- } );
- var revenues = (Number( open ) + Number( toInvoice ) - Number( openCosts )) / 1.21;
+ getOutstandingTotal: function (data) {
+ var self = dbo.dashboardModel
+ var openInvoices = 0
+ var toInvoice = 0
+ var costs = 0
+ var openCosts = 0
+
+ _.each(data, function (p) {
+ openInvoices += Number(p.invoiceToPay.replace('.', ''))
+ toInvoice += Number(p.needInvoice.replace('.', ''))
+ })
+
+ var revenues = (Number(open) + Number(toInvoice) - Number(openCosts)) / 1.21
return {
- open : open,
- toInvoice: toInvoice,
- costs : costs,
- revenues : Math.round( revenues ),
- openCosts: openCosts
- };
+ openInvoices: openInvoices,
+ toInvoice : toInvoice,
+ costs : costs,
+ revenues : Math.round(revenues),
+ openCosts : openCosts
+ }
+ },
+ invoiceOverview : function () {
+ var self = dbo.dashboardModel
+
+ self.showInvoiceOverview(!self.showInvoiceOverview())
+ },
+ Billing : function (data) {
+ console.log(data)
+ self.project = data.projectnumber + ' ' + data.projectname
+ self.invoiced = dbo.helpers.thousandSeparator(data.invoiced)
+ self.payedcosts = dbo.helpers.thousandSeparator(data.payedcosts)
+ self.openCosts = dbo.helpers.thousandSeparator(Number(data.invoiced) - Number(data.payedcosts))
+ self.archive = data.archive
}
- };
+ }
- dbo.dashboardModel.init();
+ dbo.dashboardModel.init()
- ko.applyBindings( dbo.dashboardModel, document.getElementById( 'DASHBOARD' ) );
+ ko.applyBindings(dbo.dashboardModel, document.getElementById('DASHBOARD'))
}
-};
+}