diversen dashboard
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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,7 +103,10 @@ class Invoices_model extends MY_Model {
|
||||
FROM
|
||||
projectcosts
|
||||
GROUP BY
|
||||
project_id) Q4 ON Q4.project_id = 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 ";
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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,
|
||||
openInvoices: openInvoices,
|
||||
toInvoice : toInvoice,
|
||||
costs : costs,
|
||||
revenues : Math.round( revenues ),
|
||||
openCosts: openCosts
|
||||
};
|
||||
revenues : Math.round(revenues),
|
||||
openCosts : openCosts
|
||||
}
|
||||
};
|
||||
},
|
||||
invoiceOverview : function () {
|
||||
var self = dbo.dashboardModel
|
||||
|
||||
dbo.dashboardModel.init();
|
||||
|
||||
ko.applyBindings( dbo.dashboardModel, document.getElementById( 'DASHBOARD' ) );
|
||||
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()
|
||||
|
||||
ko.applyBindings(dbo.dashboardModel, document.getElementById('DASHBOARD'))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user