employeehours report
This commit is contained in:
@@ -15,15 +15,18 @@ dbo.reportsDataService = {
|
||||
} );
|
||||
},
|
||||
|
||||
getRecapProjects: function(callback){
|
||||
$.getJSON( 'index.php/reports/employeeHoursController/recapProjects' )
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
},
|
||||
|
||||
getEmployeeHours: function ( employeeID, year, callback ) {
|
||||
$.getJSON( 'index.php/reports/EmployeeHoursController/getMonthlyEmployeeHoursPerProject/' + employeeID + '/' + year )
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} )
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
|
||||
// getHoursPerEmployee
|
||||
|
||||
}
|
||||
@@ -11,6 +11,10 @@ dbo.helpers = {
|
||||
return re.test( email.toLowerCase() );
|
||||
},
|
||||
|
||||
thousandSeparator: function ( x ) {
|
||||
return x.toString().replace( /\B(?=(\d{3})+(?!\d))/g, "." );
|
||||
},
|
||||
|
||||
validateNumber: function ( input, point = true ) {
|
||||
var validNumbers = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', ','];
|
||||
var pointTaken = false;
|
||||
@@ -83,9 +87,9 @@ dbo.helpers = {
|
||||
return newDate;
|
||||
},
|
||||
|
||||
numberWithPoints :function(myNumber) {
|
||||
if( ! myNumber) return 0;
|
||||
numberWithPoints: function ( myNumber ) {
|
||||
if ( !myNumber ) return 0;
|
||||
|
||||
return myNumber.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
||||
return myNumber.toString().replace( /\B(?=(\d{3})+(?!\d))/g, "." );
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,21 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
|
||||
dbo.monthlyEmployeeHoursModel = {
|
||||
|
||||
uniqueEmployees: ko.observableArray( [] ),
|
||||
sluggy : ko.observable( 'euro' ),
|
||||
years : ko.observableArray( [] ),
|
||||
selectedYear : ko.observable(),
|
||||
currentTab : false,
|
||||
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( [] ),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.monthlyEmployeeHoursModel;
|
||||
@@ -38,12 +48,63 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
|
||||
initModule: function () {
|
||||
var vm = dbo.monthlyEmployeeHoursModel;
|
||||
vm.totalBudget( 0 );
|
||||
vm.totalCosts( 0 );
|
||||
vm.totalAvailableBudget( 0 );
|
||||
vm.totalSaldo( 0 );
|
||||
vm.totalWorkInProgress( 0 );
|
||||
vm.totalEmployeeRevenues( 0 );
|
||||
vm.totalPerEmployee.removeAll();
|
||||
vm.totalInvoicedYear.removeAll();
|
||||
dbo.userDataService.getUniqueProjectEmployees( function ( data ) {
|
||||
vm.uniqueEmployees.removeAll();
|
||||
$.each( data, function ( i, p ) {
|
||||
vm.uniqueEmployees.push( new vm.UniqueEmployee( p ) )
|
||||
} );
|
||||
} );
|
||||
dbo.reportsDataService.getRecapProjects( function ( data ) {
|
||||
vm.recap.removeAll();
|
||||
vm.uniqueYears.removeAll();
|
||||
$.each( data, function ( i, p ) {
|
||||
if ( i == 0 ) {
|
||||
$.each( p.invoiced, function ( y, q ) {
|
||||
vm.uniqueYears.push( {year: q.year} );
|
||||
} );
|
||||
}
|
||||
vm.recap.push( new vm.Project( p ) )
|
||||
} );
|
||||
vm.totalBudget( dbo.helpers.thousandSeparator( vm.totalBudget() ) );
|
||||
vm.totalCosts( dbo.helpers.thousandSeparator( vm.totalCosts() ) );
|
||||
vm.totalAvailableBudget( dbo.helpers.thousandSeparator( vm.totalAvailableBudget() ) );
|
||||
vm.totalSaldo( dbo.helpers.thousandSeparator( vm.totalSaldo() ) );
|
||||
vm.totalWorkInProgress( dbo.helpers.thousandSeparator( vm.totalWorkInProgress() ) );
|
||||
vm.totalEmployeeRevenues( dbo.helpers.thousandSeparator( vm.totalEmployeeRevenues() ) );
|
||||
_.each( vm.totalPerEmployee(), function ( p ) {
|
||||
p.totalRevenue( dbo.helpers.thousandSeparator( p.totalRevenue() ) );
|
||||
} );
|
||||
_.each( vm.totalInvoicedYear(), function ( p ) {
|
||||
p.totalInvoiced( dbo.helpers.thousandSeparator( p.totalInvoiced() ) );
|
||||
} );
|
||||
var chartData = [];
|
||||
var chartLabels = [];
|
||||
_.each( vm.totalPerEmployee(), function ( p ) {
|
||||
chartData.push( Number( p.totalRevenue().replace( '.', '' ) ) );
|
||||
chartLabels.push( p.fullname );
|
||||
} );
|
||||
var chartDataProjects = [];
|
||||
var chartLabelsProjects = [];
|
||||
var chartDataOwh = [];
|
||||
var chartColorOwh = [];
|
||||
_.each( vm.recap(), function ( p ) {
|
||||
chartDataProjects.push( Number( p.totalEmployeeRevenues.replace( '.', '' ) ) );
|
||||
chartLabelsProjects.push( p.projectname );
|
||||
chartDataOwh.push( Number( p.workInProgress.replace( '.', '' ) ) );
|
||||
chartColorOwh.push( Number( p.workInProgress.replace( '.', '' ) ) < 0 ? '#d53d24' : '#78be4b' );
|
||||
} );
|
||||
dbo.charts.drawPie( 'recap-revenues', chartData, chartLabels, 'omzet per medewerker' );
|
||||
dbo.charts.drawPie( 'recap-revenues-project', chartDataProjects, chartLabelsProjects, 'omzet per project' );
|
||||
dbo.charts.drawHoursChart( 'recap-owh', chartDataOwh, chartLabelsProjects, 'onderhandenwerk per project', chartColorOwh );
|
||||
} );
|
||||
},
|
||||
|
||||
refreshTab: function () {
|
||||
@@ -103,7 +164,6 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
vm.currentTab.totalTotal( vm.currentTab.totalTotal() + q.totalyear );
|
||||
vm.currentTab.totalTotalOtheryears( vm.currentTab.totalTotalOtheryears() + q.totalotheryears );
|
||||
|
||||
|
||||
vm.currentTab.totalJanuariRevenue( vm.currentTab.totalJanuariRevenue() + q.januariRevenue );
|
||||
vm.currentTab.totalFebruariRevenue( vm.currentTab.totalFebruariRevenue() + q.februariRevenue );
|
||||
vm.currentTab.totalMaartRevenue( vm.currentTab.totalMaartRevenue() + q.maartRevenue );
|
||||
@@ -149,10 +209,10 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
setActivetab: function ( tab ) {
|
||||
var vm = dbo.monthlyEmployeeHoursModel;
|
||||
|
||||
console.log( 'inside' );
|
||||
$.each( vm.uniqueEmployees(), function ( i, p ) {
|
||||
if ( tab == p.slug ) {
|
||||
vm.currentTab = p;
|
||||
|
||||
vm.refreshTab();
|
||||
}
|
||||
} )
|
||||
@@ -210,6 +270,84 @@ dbo.monthlyemployeehoursInit = function () {
|
||||
|
||||
Detail: function ( data ) {
|
||||
this.test = data;
|
||||
},
|
||||
|
||||
Project: function ( data ) {
|
||||
var vm = dbo.monthlyEmployeeHoursModel;
|
||||
var self = this;
|
||||
|
||||
self.projectnumber = data.projectnumber;
|
||||
self.instroom = data.instroom;
|
||||
self.uitstroom = data.uitstroom;
|
||||
self.projectname = data.projectname;
|
||||
self.name = data.name;
|
||||
self.revenues = dbo.helpers.thousandSeparator( data.budget );
|
||||
self.hours = data.hours;
|
||||
self.totalEmpoloyeeRevenues = 0;
|
||||
self.externCosts = dbo.helpers.thousandSeparator( data.projectcosts );
|
||||
self.budget = dbo.helpers.thousandSeparator( data.budget );
|
||||
self.budgetAvailable = dbo.helpers.thousandSeparator( data.budgetAvailable );
|
||||
self.saldo = dbo.helpers.thousandSeparator( data.saldo );
|
||||
|
||||
self.employees = ko.observableArray( [] );
|
||||
$.each( data.employees, function ( i, p ) {
|
||||
self.employees.push( new vm.Employee( p ) );
|
||||
if ( !self.totalEmployeeRevenues ) self.totalEmployeeRevenues = 0;
|
||||
} );
|
||||
self.totalEmployeeRevenues = data.projectEuros;
|
||||
vm.totalEmployeeRevenues( vm.totalEmployeeRevenues() + Number( self.totalEmployeeRevenues ) );
|
||||
self.totalEmployeeRevenues = dbo.helpers.thousandSeparator( self.totalEmployeeRevenues );
|
||||
self.totalEmployeeHours = data.projectHours;
|
||||
self.workInProgress = dbo.helpers.thousandSeparator( data.workInProgress );
|
||||
|
||||
self.invoiced = ko.observableArray( [] );
|
||||
$.each( data.invoiced, function ( i, p ) {
|
||||
self.invoiced.push( {invoiced: dbo.helpers.thousandSeparator( p.invoiced )} );
|
||||
} );
|
||||
|
||||
vm.setTotals( data );
|
||||
},
|
||||
|
||||
setTotals: function ( data ) {
|
||||
var vm = dbo.monthlyEmployeeHoursModel;
|
||||
|
||||
vm.totalBudget( vm.totalBudget() + Number( data.budget ) );
|
||||
vm.totalCosts( vm.totalCosts() + Number( data.projectcosts ) );
|
||||
vm.totalAvailableBudget( vm.totalAvailableBudget() + Number( data.budgetAvailable ) );
|
||||
vm.totalSaldo( vm.totalSaldo() + Number( data.saldo ) );
|
||||
vm.totalWorkInProgress( vm.totalWorkInProgress() + Number( data.workInProgress ) );
|
||||
|
||||
var hasTotalEmployees = true;
|
||||
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 )} );
|
||||
}
|
||||
var a = _.find( vm.totalPerEmployee(), function ( o ) {
|
||||
return o.id == p.id
|
||||
} );
|
||||
a.totalRevenue( a.totalRevenue() + p.revenues );
|
||||
} );
|
||||
|
||||
var hasTotalsOwpYear = true;
|
||||
if ( vm.totalInvoicedYear().length == 0 ) hasTotalsOwpYear = false;
|
||||
_.each( data.invoiced, function ( p ) {
|
||||
if ( !hasTotalsOwpYear ) {
|
||||
vm.totalInvoicedYear.push( {year: p.year, totalInvoiced: ko.observable( 0 )} );
|
||||
}
|
||||
var a = _.find( vm.totalInvoicedYear(), function ( o ) {
|
||||
return o.year == p.year
|
||||
} );
|
||||
a.totalInvoiced( a.totalInvoiced() + Number( p.invoiced ) );
|
||||
} );
|
||||
},
|
||||
|
||||
Employee: function ( data ) {
|
||||
this.fullname = data.fullname;
|
||||
this.revenues = dbo.helpers.thousandSeparator( data.revenues );
|
||||
this.hours = data.hours;
|
||||
this.budget = data.budget;
|
||||
this.availableHours = data.availableHours;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
|
||||
dbo.charts = {
|
||||
|
||||
monthLabels : ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
|
||||
pieColors : ['#ffcf30', '#06b2dc', '#048a44', '#a63305', '#a0c03b', '#ffcb22', '#89c540', '#f77c01', '#1094f6', '#6733ba'],
|
||||
barColor : ['#f3a921', '#f2770c', '#72221a', '#04843b', '#d63f2e', '#fec220'],
|
||||
monthLabels: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
|
||||
charts : [],
|
||||
|
||||
drawHoursVsBudget: function ( hours, budget, element ) {
|
||||
var ctx = document.getElementById( element ).getContext( '2d' );
|
||||
@@ -54,9 +57,7 @@ dbo.charts = {
|
||||
labels : ["offerte", "facturen", "betaald"],
|
||||
datasets: [{
|
||||
data : [offer, invoice, payed],
|
||||
backgroundColor: [
|
||||
'#f3a921', '#f2770c', '#72221a'
|
||||
]
|
||||
backgroundColor: dbo.charts.barColor
|
||||
}]
|
||||
},
|
||||
options: {
|
||||
@@ -81,8 +82,7 @@ dbo.charts = {
|
||||
} );
|
||||
},
|
||||
|
||||
drawHoursChart: function (element, chartData, labels, title, colors) {
|
||||
console.log( chartData );
|
||||
drawHoursChart: function ( element, chartData, labels, title, colors ) {
|
||||
var ctx = document.getElementById( element ).getContext( '2d' );
|
||||
|
||||
var myChart = new Chart( ctx, {
|
||||
@@ -104,7 +104,7 @@ dbo.charts = {
|
||||
}]
|
||||
},
|
||||
legend : {
|
||||
display: false,
|
||||
display : false,
|
||||
fontColor: '#ffffff',
|
||||
},
|
||||
title : {
|
||||
@@ -114,8 +114,43 @@ dbo.charts = {
|
||||
fontColor: '#ffffff'
|
||||
}
|
||||
}
|
||||
|
||||
} );
|
||||
},
|
||||
|
||||
drawPie: function ( element, data, chartLabels, title ) {
|
||||
var ctx = document.getElementById( element ).getContext( '2d' );
|
||||
dbo.charts.charts[element] = new Chart( ctx, {
|
||||
type : 'doughnut',
|
||||
data : {
|
||||
datasets: [{
|
||||
data : data,
|
||||
backgroundColor: dbo.charts.pieColors,
|
||||
borderColor : dbo.charts.pieColors,
|
||||
label : chartLabels
|
||||
}],
|
||||
labels : chartLabels
|
||||
},
|
||||
options: {
|
||||
title : {
|
||||
display : true,
|
||||
text : title,
|
||||
fontSize : 16,
|
||||
fontColor: '#ffffff'
|
||||
},
|
||||
legend : {
|
||||
display: false
|
||||
},
|
||||
legendCallback: function ( chart ) {
|
||||
var text = '';
|
||||
_.each( chart.data.labels, function ( p, i ) {
|
||||
text += '<div><div style="float:left;width:15px;height:15px;border-radius:50%;background-color:' + dbo.charts.pieColors[i] + '"></div><div style="margin-left:10px;float:left;color:#ffffff;">' + p + '</div></div><br />'
|
||||
} );
|
||||
|
||||
return text;
|
||||
}
|
||||
}
|
||||
} );
|
||||
document.getElementById( element + '-legends' ).innerHTML = dbo.charts.charts[element].generateLegend();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user