diversen dashboard
This commit is contained in:
@@ -42,16 +42,68 @@ class DashboardController extends MY_Controller {
|
|||||||
$available += $project['budgetAvailable'];
|
$available += $project['budgetAvailable'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$outstandings = $this->Invoices_model-> getTotalsOutstandingPerProject();
|
$outstandings = $this->Invoices_model->getTotalsOutstandingPerProject(FALSE);
|
||||||
|
|
||||||
$this->json( [
|
$this->json( [
|
||||||
'totalOwp' => round( $totalOwp, 0 ),
|
'totalOwp' => round( $totalOwp, 0 ),
|
||||||
|
'revenuesThisYear' => $this->getRevenuesThisYear(),
|
||||||
'currentFinancialYear' => round( $currentFinancialYear ),
|
'currentFinancialYear' => round( $currentFinancialYear ),
|
||||||
'owpNextyear' => round( $totalOwp - $currentFinancialYear ),
|
'owpNextyear' => round( $totalOwp - $currentFinancialYear ),
|
||||||
'revenuesNextyear' => round( $totalOwp / 0.4 ),
|
'revenuesNextyear' => round( $currentFinancialYear / 0.4 ),
|
||||||
'totalRevenues' => round( $totalRevenues ),
|
'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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->version = '1.00.12';
|
$this->version = '1.00.30';
|
||||||
|
|
||||||
$this->load->library( 'beheer/session/RetrieveUserSession' );
|
$this->load->library( 'beheer/session/RetrieveUserSession' );
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,8 @@ class Invoices_model extends MY_Model {
|
|||||||
JOIN invoices INV
|
JOIN invoices INV
|
||||||
ON INV.id = PAY.invoice_id
|
ON INV.id = PAY.invoice_id
|
||||||
WHERE INV.project_id = {$projectID}
|
WHERE INV.project_id = {$projectID}
|
||||||
) AS payed
|
) AS payed,
|
||||||
|
PRJ.archive
|
||||||
FROM invoices INV
|
FROM invoices INV
|
||||||
JOIN projects PRJ
|
JOIN projects PRJ
|
||||||
ON PRJ.id = INV.project_id
|
ON PRJ.id = INV.project_id
|
||||||
@@ -55,7 +56,7 @@ class Invoices_model extends MY_Model {
|
|||||||
return $invoiceDetails;
|
return $invoiceDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotalsOutstandingPerProject()
|
public function getTotalsOutstandingPerProject($archive = TRUE)
|
||||||
{
|
{
|
||||||
$this->sql = "
|
$this->sql = "
|
||||||
SELECT
|
SELECT
|
||||||
@@ -102,9 +103,12 @@ class Invoices_model extends MY_Model {
|
|||||||
FROM
|
FROM
|
||||||
projectcosts
|
projectcosts
|
||||||
GROUP BY
|
GROUP BY
|
||||||
project_id) Q4 ON Q4.project_id = PRJ.id
|
project_id) Q4 ON Q4.project_id = PRJ.id ";
|
||||||
GROUP BY
|
if( $archive == FALSE ) $this->sql .= "WHERE PRJ.archive = 'F' ";
|
||||||
PRJ.id ";
|
|
||||||
|
$this->sql .= "
|
||||||
|
GROUP BY
|
||||||
|
PRJ.id ";
|
||||||
|
|
||||||
$outstandings = $this->get_query_result();
|
$outstandings = $this->get_query_result();
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,13 @@
|
|||||||
<br>
|
<br>
|
||||||
<h4>
|
<h4>
|
||||||
<span class="db-panel-label">Omzet komende jaar:</span>
|
<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>
|
||||||
<h4>
|
<h4>
|
||||||
<span class="db-panel-label">Omzet totaal gerealiseerd lopend jaar:</span>
|
<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>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -51,13 +53,51 @@
|
|||||||
<div class="db-panel-heading">
|
<div class="db-panel-heading">
|
||||||
<h3 class="db-panel-title">
|
<h3 class="db-panel-title">
|
||||||
Facturatie
|
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>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="db-panel-body" data-bind="width:owp">
|
<div class="db-panel-body" data-bind="width:owp">
|
||||||
<br>
|
<br>
|
||||||
<h4>
|
<h4>
|
||||||
<span class="db-panel-label">Openstaande facturen (incl btw):</span>
|
<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>
|
||||||
<h4>
|
<h4>
|
||||||
<span class="db-panel-label">Nog te factureren (incl btw):</span>
|
<span class="db-panel-label">Nog te factureren (incl btw):</span>
|
||||||
|
|||||||
@@ -49,3 +49,15 @@
|
|||||||
float: right;
|
float: right;
|
||||||
margin-top: 10px;
|
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;
|
||||||
|
}
|
||||||
@@ -7,69 +7,94 @@
|
|||||||
|
|
||||||
dbo.dashboardInit = function () {
|
dbo.dashboardInit = function () {
|
||||||
|
|
||||||
if ( dbo.dashboardModel !== undefined ) {
|
if (dbo.dashboardModel !== undefined) {
|
||||||
|
|
||||||
dbo.dashboardModel.init();
|
dbo.dashboardModel.init()
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dbo.dashboardModel = {
|
dbo.dashboardModel = {
|
||||||
|
|
||||||
|
owpThisYear : ko.observable(null),
|
||||||
owpThisYear : ko.observable( null ),
|
owpNextYear : ko.observable(null),
|
||||||
owpNextYear : ko.observable( null ),
|
owpTotal : ko.observable(null),
|
||||||
owpTotal : ko.observable( null ),
|
revenuesNextyear : ko.observable(null),
|
||||||
revenuesNextyear : ko.observable( null ),
|
totalRevenues : ko.observable(null),
|
||||||
totalRevenues : ko.observable( null ),
|
outstanding : ko.observable(null),
|
||||||
outstanding : ko.observable( null ),
|
toInvoice : ko.observable(null),
|
||||||
toInvoice : ko.observable( null ),
|
openCosts : ko.observable(null),
|
||||||
openCosts : ko.observable( null ),
|
revenues : ko.observable(null),
|
||||||
revenues : ko.observable( null ),
|
revenues : ko.observable(null),
|
||||||
revenues : ko.observable( null ),
|
revenueCurrentYear : ko.observable(null),
|
||||||
revenueCurrentYear: ko.observable( null ),
|
revenuesThisYear : ko.observable(null),
|
||||||
|
billingOverview : ko.observableArray([]),
|
||||||
|
showInvoiceOverview: ko.observable(false),
|
||||||
|
openInvoices : ko.observable(null),
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
var self = dbo.dashboardModel;
|
var self = dbo.dashboardModel
|
||||||
dbo.dashboardDataservice.getOwhp( function ( data ) {
|
dbo.dashboardDataservice.getOwhp(function (data) {
|
||||||
var outstandings = self.getOutstandingTotal( data.outstandings );
|
var outstandings = self.getOutstandingTotal(data.outstandings)
|
||||||
var revCurYear = Number( data.currentFinancialYear ) + Number( data.totalOwp );
|
var revCurYear = Number(data.currentFinancialYear) + Number(data.totalOwp)
|
||||||
|
|
||||||
self.owpThisYear( dbo.helpers.thousandSeparator( data.currentFinancialYear ) );
|
self.owpThisYear(dbo.helpers.thousandSeparator(data.currentFinancialYear))
|
||||||
self.owpNextYear( dbo.helpers.thousandSeparator( data.owpNextyear ) );
|
self.owpNextYear(dbo.helpers.thousandSeparator(data.owpNextyear))
|
||||||
self.owpTotal( dbo.helpers.thousandSeparator( data.totalOwp ) );
|
self.owpTotal(dbo.helpers.thousandSeparator(data.totalOwp))
|
||||||
self.revenuesNextyear( dbo.helpers.thousandSeparator( data.revenuesNextyear ) );
|
self.revenuesNextyear(dbo.helpers.thousandSeparator(data.revenuesNextyear))
|
||||||
self.totalRevenues( dbo.helpers.thousandSeparator( data.totalRevenues ) );
|
self.totalRevenues(dbo.helpers.thousandSeparator(data.totalRevenues))
|
||||||
self.outstanding( dbo.helpers.thousandSeparator( outstandings.open ) );
|
self.openInvoices(dbo.helpers.thousandSeparator(outstandings.openInvoices))
|
||||||
self.toInvoice( dbo.helpers.thousandSeparator( outstandings.toInvoice ) );
|
self.toInvoice(dbo.helpers.thousandSeparator(outstandings.toInvoice))
|
||||||
self.openCosts( dbo.helpers.thousandSeparator( outstandings.openCosts ) );
|
|
||||||
self.revenues( dbo.helpers.thousandSeparator( outstandings.revenues ) );
|
self.revenues(dbo.helpers.thousandSeparator(outstandings.revenues))
|
||||||
self.revenueCurrentYear( dbo.helpers.thousandSeparator( revCurYear ) );
|
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 ) {
|
getOutstandingTotal: function (data) {
|
||||||
var open = 0;
|
var self = dbo.dashboardModel
|
||||||
var toInvoice = 0;
|
var openInvoices = 0
|
||||||
var costs = 0;
|
var toInvoice = 0
|
||||||
var openCosts = 0;
|
var costs = 0
|
||||||
_.each( data, function ( p ) {
|
var openCosts = 0
|
||||||
open += Number( p.invoiced ) - Number( p.payment );
|
|
||||||
toInvoice += Number( p.revenues ) - Number( p.invoiced );
|
_.each(data, function (p) {
|
||||||
costs += Number( p.costs );
|
openInvoices += Number(p.invoiceToPay.replace('.', ''))
|
||||||
openCosts += Number( p.costs ) - Number( p.payedcosts )
|
toInvoice += Number(p.needInvoice.replace('.', ''))
|
||||||
} );
|
})
|
||||||
var revenues = (Number( open ) + Number( toInvoice ) - Number( openCosts )) / 1.21;
|
|
||||||
|
var revenues = (Number(open) + Number(toInvoice) - Number(openCosts)) / 1.21
|
||||||
return {
|
return {
|
||||||
open : open,
|
openInvoices: openInvoices,
|
||||||
toInvoice: toInvoice,
|
toInvoice : toInvoice,
|
||||||
costs : costs,
|
costs : costs,
|
||||||
revenues : Math.round( revenues ),
|
revenues : Math.round(revenues),
|
||||||
openCosts: openCosts
|
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'))
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user