diff --git a/application/controllers/reports/EmployeeHoursController.php b/application/controllers/reports/EmployeeHoursController.php index abc74c5..df900cb 100644 --- a/application/controllers/reports/EmployeeHoursController.php +++ b/application/controllers/reports/EmployeeHoursController.php @@ -43,5 +43,15 @@ class EmployeeHoursController extends MY_Controller { $this->json( $monthlyhours ); } + public function getMonthlyEmployeehours( $month, $year ) + { + $sql = QEmployeeHours::fire( $month, $year ); + + $query = $this->db->query( $sql ); + + $result = $query->result(); + + $this->json( $result ); + } } \ No newline at end of file diff --git a/application/models/eloquent/queries/ProjecthoursPerEmployeePerMonth.php b/application/models/eloquent/queries/ProjecthoursPerEmployeePerMonth.php index 03e43a6..2304d68 100644 --- a/application/models/eloquent/queries/ProjecthoursPerEmployeePerMonth.php +++ b/application/models/eloquent/queries/ProjecthoursPerEmployeePerMonth.php @@ -46,6 +46,7 @@ class ProjecthoursPerEmployeePerMonth extends BaseModel { ->join( 'projectemployees AS PEM', 'PEM.id', '=', 'projecthours.projectemployee_id' ) ->join( 'projects AS PRJ', 'PRJ.id', '=', 'PEM.project_id' ) ->where( 'PEM.user_id', '=', $employeeID ) + ->where( 'projecthours.hourtype_id', '=', 1) ->groupBy('PRJ.id') ->groupBy('PEM.tarif') ->groupBy('PRJ.projectname') diff --git a/application/models/eloquent/queries/QEmployeeHours.php b/application/models/eloquent/queries/QEmployeeHours.php new file mode 100644 index 0000000..4c3a046 --- /dev/null +++ b/application/models/eloquent/queries/QEmployeeHours.php @@ -0,0 +1,59 @@ + + +
+
+ +
+
+ +
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/application/views/partials/_js.php b/application/views/partials/_js.php index 92c4246..de4dcec 100644 --- a/application/views/partials/_js.php +++ b/application/views/partials/_js.php @@ -70,6 +70,7 @@ + diff --git a/application/views/reports/employeehours/employeemonthhours_view.php b/application/views/reports/employeehours/employeemonthhours_view.php new file mode 100644 index 0000000..e104855 --- /dev/null +++ b/application/views/reports/employeehours/employeemonthhours_view.php @@ -0,0 +1,70 @@ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
medewerker
uren declarabel
uren niet declarabel
uren indirect
totaal bestede uren
uren target(1.600 jaar)
aandeel uren besteed tov target
bezettingsgraad totaal
aantal gewerkte uren
bezettingsgraad t.o.v. target
factureerbare uren
omzet
gemiddeld tarief
%%
totaal%%%
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/public/js/lib/dataservices/employeehoursDataService.js b/public/js/lib/dataservices/employeehoursDataService.js index fd71de8..3bc7689 100644 --- a/public/js/lib/dataservices/employeehoursDataService.js +++ b/public/js/lib/dataservices/employeehoursDataService.js @@ -14,6 +14,13 @@ dbo.employeehoursDataService = { } ); }, + getMonthlyEmployeehours : function(month, $year, callback){ + $.getJSON( 'index.php/reports/employeehoursController/getMonthlyEmployeehours/' + month + '/' + $year ) + .done( function ( data ) { + callback( data ); + } ); + }, + getHourtypes: function ( callback ) { $.getJSON( 'index.php/projects/employeehoursController/getHourtypes' ) .done( function ( data ) { diff --git a/public/js/lib/modules/reports/employeeHours.js b/public/js/lib/modules/reports/employeeHours.js new file mode 100644 index 0000000..b8ffd68 --- /dev/null +++ b/public/js/lib/modules/reports/employeeHours.js @@ -0,0 +1,161 @@ +/** + * Created by Pensare Software. + * User: Theo Weijmer + * Date: 01/03/2018 + * Time: 11:06 + */ + +dbo.employeehoursreportInit = function () { + + if ( dbo.employeeHoursreportModel !== undefined ) { + dbo.employeeHoursreportModel.initModule(); + } else { + + dbo.employeeHoursreportModel = { + + months : ko.observableArray( [ + {monthID: 1, monthName: 'jan'}, + {monthID: 2, monthName: 'febr'}, + {monthID: 3, monthName: 'mrt'}, + {monthID: 4, monthName: 'apr'}, + {monthID: 5, monthName: 'mei'}, + {monthID: 6, monthName: 'juni'}, + {monthID: 7, monthName: 'juli'}, + {monthID: 8, monthName: 'aug'}, + {monthID: 9, monthName: 'sept'}, + {monthID: 10, monthName: 'okt'}, + {monthID: 11, monthName: 'nov'}, + {monthID: 12, monthName: 'dec'} + ] ), + month : ko.observable(), + selectedMonthID : ko.observable(), + years : ko.observableArray( [] ), + selectedYear : ko.observable(), + employees : ko.observableArray( [] ), + profitablehoursTotaal : ko.observable(), + nonprofitablehoursTotaal : ko.observable(), + nonprojecthoursTotaal : ko.observable(), + totalhoursTotaal : ko.observable(), + targetTotaal : ko.observable(), + occupancyRateTotalTotaal : ko.observable(), + occupancyRateHoursTotaal : ko.observable(), + occupancyRateInvoiceTotaal: ko.observable(), + revenuesTotaal : ko.observable(), + averageDayRateTotaal : ko.observable(), + initialize : null, + + init: function () { + var vm = dbo.employeeHoursreportModel; + + vm.initialize = true; + dbo.reportsDataService.getUsedYears( function ( data ) { + vm.years.removeAll(); + _.each( data, function ( p ) { + vm.years.push( {id: p.year, year: p.year} ); + } ); + + vm.selectedYear( (new Date()).getFullYear() ); + vm.selectedMonthID( 1 ); + + vm.initialize = false; + + vm.initModule(); + } ); + }, + + initModule: function () { + var vm = dbo.employeeHoursreportModel; + + vm.refreshTab(); + }, + + setActivetab: function ( tab ) { + var vm = dbo.employeeHoursreportModel; + + vm.selectedMonthID( tab ); + + vm.refreshTab(); + }, + + refreshTab: function () { + var vm = dbo.employeeHoursreportModel; + + if ( vm.initialize ) return; + + vm.profitablehoursTotaal( 0 ); + vm.nonprofitablehoursTotaal( 0 ); + vm.nonprojecthoursTotaal( 0 ); + vm.totalhoursTotaal( 0 ); + vm.targetTotaal( 0 ); + vm.occupancyRateTotalTotaal( 0 ); + vm.occupancyRateHoursTotaal( 0 ); + vm.occupancyRateInvoiceTotaal( 0 ); + vm.revenuesTotaal( 0 ); + vm.averageDayRateTotaal( 0 ); + + dbo.employeehoursDataService.getMonthlyEmployeehours( vm.selectedMonthID(), vm.selectedYear(), function ( data ) { + vm.employees.removeAll(); + var chartData = {}; + chartData.revenues = []; + chartData.hours = []; + chartData.averageRate = []; + chartData.labels = []; + _.each( data, function ( p ) { + vm.employees.push( new vm.Employee( p ) ); + + vm.profitablehoursTotaal( vm.profitablehoursTotaal() + Number( p.profitablehours ) ); + vm.nonprofitablehoursTotaal( vm.nonprofitablehoursTotaal() + Number( p.nonprofitablehours ) ); + vm.nonprojecthoursTotaal( vm.nonprojecthoursTotaal() + Number( p.nonprojecthours ) ); + vm.totalhoursTotaal( vm.totalhoursTotaal() + Number( p.totalhours ) ); + vm.targetTotaal( Math.round( vm.targetTotaal() + Number( p.targethours / 12 ) ) ); + vm.revenuesTotaal( Number( vm.revenuesTotaal() ) + Number( p.revenues ) ); + + chartData.labels.push( p.fullname ); + chartData.revenues.push( p.revenues ); + chartData.averageRate.push( Math.round( (p.revenues / p.profitablehours) * 8 ) ) + chartData.hours.push( p.totalhours ); + } ); + vm.occupancyRateTotalTotaal( Math.round( (vm.totalhoursTotaal() / vm.targetTotaal()) * 100 ) ); + vm.occupancyRateHoursTotaal( Math.round( (vm.profitablehoursTotaal() / vm.totalhoursTotaal() ) * 100 ) ); + vm.occupancyRateInvoiceTotaal( Math.round( (vm.profitablehoursTotaal() / vm.targetTotaal()) * 100 ) ); + vm.averageDayRateTotaal( Math.round( Number( vm.revenuesTotaal() ) / Number( vm.profitablehoursTotaal() ) ) * 8 ); + vm.revenuesTotaal( dbo.helpers.thousandSeparator( vm.revenuesTotaal() ) ); + + dbo.charts.drawPie( 'revenues-per-month', chartData.revenues, chartData.labels, 'omzet per medewerker' ); + dbo.charts.drawPie( 'hours-per-month', chartData.hours, chartData.labels, 'uren per medewerker' ); + dbo.charts.drawHoursChart( 'average-rate', chartData.averageRate, chartData.labels, 'gemiddeld tarief', '#78be4b' ); + } ); + }, + + UniqueEmployee: function ( data ) { + var vm = dbo.employeeHoursreportModel; + var self = this; + + self.id = data.id; + self.fullname = data.fullname; + self.slug = data.slug; + }, + + Employee: function ( data ) { + this.fullname = data.fullname; + this.profitablehours = data.profitablehours; + this.nonprofitablehours = data.nonprofitablehours; + this.nonprojecthours = data.nonprojecthours; + this.totalhours = data.totalhours; + this.target = Math.round( data.targethours / 12 ); + this.occupancyRateTotal = Math.round( (data.totalhours / (data.targethours / 12)) * 100 ); + this.occupancyRateHours = Math.round( (data.profitablehours / data.totalhours ) * 100 ); + this.occupancyRateInvoice = Math.round( (data.profitablehours / (data.targethours / 12)) * 100 ); + this.revenues = dbo.helpers.thousandSeparator( data.revenues ); + this.averageDayRate = Math.round( (data.revenues / data.profitablehours) * 8 ); + } + + } + + dbo.employeeHoursreportModel.init(); + + ko.applyBindings( dbo.employeeHoursreportModel, document.getElementById( "EMPLOYEEHOURSREPORT" ) ); + + + } +} \ No newline at end of file diff --git a/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js b/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js index ae6915d..269ba8d 100644 --- a/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js +++ b/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js @@ -212,7 +212,6 @@ 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;