Monthly hours and revenues per employee report
This commit is contained in:
@@ -15,21 +15,23 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
|
||||
dbo.monthlyEmployeeHoursModel = {
|
||||
|
||||
uniqueEmployees : ko.observableArray( [] ),
|
||||
uniqueYears : ko.observableArray( [] ),
|
||||
sluggy : ko.observable( 'euro' ),
|
||||
years : ko.observableArray( [] ),
|
||||
selectedYear : ko.observable(),
|
||||
currentTab : false,
|
||||
recap : ko.observableArray( [] ),
|
||||
totalPerEmployee : ko.observableArray( [] ),
|
||||
totalEmployeeRevenues: ko.observable(),
|
||||
totalBudget : ko.observable(),
|
||||
totalCosts : ko.observable(),
|
||||
totalAvailableBudget : ko.observable(),
|
||||
totalSaldo : ko.observable(),
|
||||
totalWorkInProgress : ko.observable(),
|
||||
totalInvoicedYear : ko.observableArray( [] ),
|
||||
uniqueEmployees : ko.observableArray( [] ),
|
||||
uniqueYears : ko.observableArray( [] ),
|
||||
sluggy : ko.observable( 'euro' ),
|
||||
years : ko.observableArray( [] ),
|
||||
selectedYear : ko.observable(),
|
||||
currentTab : false,
|
||||
recap : ko.observableArray( [] ),
|
||||
totalPerEmployee : ko.observableArray( [] ),
|
||||
totalEmployeeRevenues : ko.observable(),
|
||||
totalEmployeeHours : ko.observable(),
|
||||
totalEmployeeAvailableHours: ko.observable(),
|
||||
totalBudget : ko.observable(),
|
||||
totalCosts : ko.observable(),
|
||||
totalAvailableBudget : ko.observable(),
|
||||
totalSaldo : ko.observable(),
|
||||
totalWorkInProgress : ko.observable(),
|
||||
totalInvoicedYear : ko.observableArray( [] ),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.monthlyEmployeeHoursModel;
|
||||
@@ -54,6 +56,8 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
vm.totalSaldo( 0 );
|
||||
vm.totalWorkInProgress( 0 );
|
||||
vm.totalEmployeeRevenues( 0 );
|
||||
vm.totalEmployeeHours( 0 );
|
||||
vm.totalEmployeeAvailableHours( 0 );
|
||||
vm.totalPerEmployee.removeAll();
|
||||
vm.totalInvoicedYear.removeAll();
|
||||
dbo.userDataService.getUniqueProjectEmployees( function ( data ) {
|
||||
@@ -79,6 +83,7 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
vm.totalSaldo( dbo.helpers.thousandSeparator( vm.totalSaldo() ) );
|
||||
vm.totalWorkInProgress( dbo.helpers.thousandSeparator( vm.totalWorkInProgress() ) );
|
||||
vm.totalEmployeeRevenues( dbo.helpers.thousandSeparator( vm.totalEmployeeRevenues() ) );
|
||||
vm.totalEmployeeHours( dbo.helpers.thousandSeparator( vm.totalEmployeeHours() ) );
|
||||
_.each( vm.totalPerEmployee(), function ( p ) {
|
||||
p.totalRevenue( dbo.helpers.thousandSeparator( p.totalRevenue() ) );
|
||||
} );
|
||||
@@ -112,8 +117,6 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
|
||||
if ( vm.currentTab == false ) return;
|
||||
|
||||
console.log( vm.currentTab );
|
||||
|
||||
dbo.reportsDataService.getEmployeeHours( vm.currentTab.id, vm.selectedYear(), function ( data ) {
|
||||
vm.currentTab.myData( data );
|
||||
vm.currentTab.totalJanuari( 0 );
|
||||
@@ -293,12 +296,17 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
$.each( data.employees, function ( i, p ) {
|
||||
self.employees.push( new vm.Employee( p ) );
|
||||
if ( !self.totalEmployeeRevenues ) self.totalEmployeeRevenues = 0;
|
||||
if ( !self.totalEmployeeHours ) self.totalEmployeeHours = 0;
|
||||
} );
|
||||
self.totalEmployeeRevenues = data.projectEuros;
|
||||
vm.totalEmployeeRevenues( vm.totalEmployeeRevenues() + Number( self.totalEmployeeRevenues ) );
|
||||
self.totalEmployeeRevenues = dbo.helpers.thousandSeparator( self.totalEmployeeRevenues );
|
||||
self.totalEmployeeHours = data.projectHours;
|
||||
self.hoursAvailable = data.hoursAvailable;
|
||||
vm.totalEmployeeRevenues( vm.totalEmployeeRevenues() + Number( self.totalEmployeeRevenues ) );
|
||||
vm.totalEmployeeHours( vm.totalEmployeeHours() + Number( self.totalEmployeeHours ) );
|
||||
vm.totalEmployeeAvailableHours( vm.totalEmployeeAvailableHours() + Number( self.hoursAvailable ) );
|
||||
self.totalEmployeeRevenues = dbo.helpers.thousandSeparator( self.totalEmployeeRevenues );
|
||||
self.workInProgress = dbo.helpers.thousandSeparator( data.workInProgress );
|
||||
self.hoursAvailable = data.hoursAvailable;
|
||||
|
||||
self.invoiced = ko.observableArray( [] );
|
||||
$.each( data.invoiced, function ( i, p ) {
|
||||
@@ -321,12 +329,20 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
if ( vm.totalPerEmployee().length == 0 ) hasTotalEmployees = false;
|
||||
_.each( data.employees, function ( p ) {
|
||||
if ( !hasTotalEmployees ) {
|
||||
vm.totalPerEmployee.push( {id: p.id, fullname: p.fullname, totalRevenue: ko.observable( 0 )} );
|
||||
vm.totalPerEmployee.push( {
|
||||
id : p.id,
|
||||
fullname : p.fullname,
|
||||
totalRevenue : ko.observable( 0 ),
|
||||
totalHours : ko.observable( 0 ),
|
||||
totalAvailableHours: ko.observable( 0 )
|
||||
} );
|
||||
}
|
||||
var a = _.find( vm.totalPerEmployee(), function ( o ) {
|
||||
return o.id == p.id
|
||||
} );
|
||||
a.totalRevenue( a.totalRevenue() + p.revenues );
|
||||
a.totalRevenue( a.totalRevenue() + Number( p.revenues ) );
|
||||
a.totalHours( a.totalHours() + Number( p.hours ) );
|
||||
a.totalAvailableHours( a.totalAvailableHours() + Number( p.availableHours ) );
|
||||
} );
|
||||
|
||||
var hasTotalsOwpYear = true;
|
||||
|
||||
Reference in New Issue
Block a user