Diversen nav opmerkingen

This commit is contained in:
2018-05-03 19:54:32 +02:00
parent 6bc0b37f06
commit 860c5db95a
18 changed files with 405 additions and 143 deletions
@@ -14,8 +14,12 @@ dbo.employeeTargetDataService = {
} );
},
addEmployeeTarget: function ( employeeID, callback ) {
$.post()
saveEmployeeTarget: function ( submitDATA, callback ) {
$.post( 'index.php/beheer/employeetargetController/saveEmployeeTarget', submitDATA, function () {
}, 'json' )
.done( function ( data ) {
callback( data );
} );
}
+6
View File
@@ -91,5 +91,11 @@ dbo.helpers = {
if ( !myNumber ) return 0;
return myNumber.toString().replace( /\B(?=(\d{3})+(?!\d))/g, "." );
},
isNumeric: function ( n ) {
return !isNaN( parseFloat( n ) ) && isFinite( n );
}
}
+75 -18
View File
@@ -11,12 +11,20 @@ $( function () {
employeeTargets: ko.observableArray( [] ),
employeeID : null,
months : ko.observableArray( [] ),
years : ko.observableArray( [] ),
targetLength : [],
newTarget : ko.observable( true ),
busy : false,
init: function ( employeeID ) {
var vm = dbo.employeeTargetModel;
vm.employeeID = employeeID;
vm.months( dbo.monthArray );
vm.years( dbo.years );
vm.showModal();
vm.refreshEmployeeTargets();
@@ -28,55 +36,104 @@ $( function () {
addEmployeeTarget: function () {
var vm = dbo.employeeTargetModel;
var targetLength = vm.employeeTargets().length;
var lastDate = null
if ( targetLength > 0 )
var lastDate = vm.employeeTargets[targetLength - 1].enddate();
var lastYear = dbo.currentYear;
var lastMonth = dbo.currentMonth;
var data = {
startdate: lastDate,
enddate : null,
target : 0
id : 0,
user_id : vm.employeeID,
startyear : lastYear,
startmonth: lastMonth,
endyear : null,
endmonth : null,
target : 0
}
vm.employeeTargets.push( new vm.Employeetarget( data ) );
vm.employeeTargets.push( new vm.Employeetarget( data, (vm.targetLength - 1), false ) );
},
checkNumeric: function () {
this.target( dbo.helpers.validateNumber( this.target() ) );
},
saveEmployeeTarget: function () {
// if
var vm = dbo.employeeTargetModel;
var self = this;
var submitDATA = {
id : self.id,
user_id : vm.employeeID,
startmonth: self.startmonth(),
startyear : self.startyear(),
endmonth : self.endmonth() || 0,
endyear : self.endyear() || 0,
target : self.target()
}
dbo.employeeTargetDataService.saveEmployeeTarget( submitDATA, function ( data ) {
if ( !data.success ) return self.saved( false );
self.saved( true );
self.id = data.targetID;
} );
},
setUnsaved: function () {
var vm = dbo.employeeTargetModel;
if ( vm.busy ) return;
this.saved( false );
},
refreshEmployeeTargets: function () {
var vm = dbo.employeeTargetModel;
vm.busy = true;
dbo.employeeTargetDataService.getEmployeeTargets( vm.employeeID, function ( data ) {
vm.employeeTargets.removeAll();
var targetLength = data.length
var i=0;
vm.targetLength = data.length
var i = 0;
_.each( data, function ( p ) {
vm.employeeTargets.push( new vm.Employeetarget( p, targetLength, i ) );
vm.employeeTargets.push( new vm.Employeetarget( p, i, true ) );
i++;
} );
vm.busy = false;
} );
},
Employeetarget: function ( data, targetLength, i ) {
Employeetarget: function ( data, i, saved ) {
var vm = dbo.employeeTargetModel;
var self = this;
vm.newTarget( true );
self.id = data.id;
self.startyear = ko.observable( data.startyear );
self.startmonth = ko.observable( data.startmonth );
self.endyear = ko.observable( data.endyear );
self.endmonth = ko.observable( data.endmonth );
self.target = ko.observable( data.target );
self.saved = ko.observable( saved );
self.changeAble = ko.pureComputed( function () {
if(i == (targetLength - 1))
self.changeable = ko.pureComputed( function () {
if ( i == (vm.targetLength - 1) ) return true;
return true;
return false;
} );
self.validTarget = ko.pureComputed( function () {
if ( !self.endmonth() && !self.endyear() ) return true;
if ( !self.endmonth() || !self.endyear() ) return false;
if ( self.endyear() == self.startyear() && self.endmonth() > self.startmonth() ) return true;
if ( self.endyear() > self.startyear() && self.endmonth() ) return true;
return false;
} );
if ( ! self.endmonth() ) vm.newTarget( false );
if ( ! self.endyear() ) vm.newTarget( false );
}
};
+17 -27
View File
@@ -51,19 +51,14 @@ dbo.employeehoursreportInit = 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( 0 );
vm.selectedYear( (new Date()).getFullYear() );
vm.selectedMonthID( 0 );
vm.validYear( true );
vm.initialize = false;
vm.initialize = false;
vm.initModule();
} );
vm.initModule();
},
initModule: function () {
@@ -73,18 +68,13 @@ dbo.employeehoursreportInit = function () {
},
checkYear: function () {
var vm = dbo.monthlyEmployeeHoursModel;
if ( timeout ) {
clearTimeout( timeout );
timeout = null;
}
timeout = setTimeout( function () {
vm.validYear( true );
if ( !Number.isInteger( Number( vm.selectedYear() ) ) ) return vm.validYear( false );
if ( Number( vm.selectedYear() ) > 2100 ) return vm.validYear( false );
if ( Number( vm.selectedYear() ) < 2000 ) return vm.validYear( false );
vm.initModule();
}, 700 );
var vm = dbo.employeeHoursreportModel;
if ( !Number.isInteger( Number( vm.selectedYear() ) ) ) return vm.validYear( false );
if ( Number( vm.selectedYear() ) > 2100 ) return vm.validYear( false );
if ( Number( vm.selectedYear() ) < 2000 ) return vm.validYear( false );
vm.validYear( true );
vm.initModule();
},
setActivetab: function ( tab ) {
@@ -125,7 +115,7 @@ dbo.employeehoursreportInit = function () {
vm.nonprofitablehoursTotaal( Math.round( vm.nonprofitablehoursTotaal() + Number( p.nonprofitablehours ) ) );
vm.nonprojecthoursTotaal( Math.round( vm.nonprojecthoursTotaal() + Number( p.nonprojecthours ) ) );
vm.totalhoursTotaal( Math.round( vm.totalhoursTotaal() + Number( p.totalhours ) ) );
vm.targetTotaal( Math.round( vm.targetTotaal() + Number( p.targethours / 12 ) ) );
vm.targetTotaal( Math.round( vm.targetTotaal() + Number( p.targethours ) ) );
vm.revenuesTotaal( Number( vm.revenuesTotaal() ) + Number( p.revenues ) );
chartData.labels.push( p.fullname );
@@ -135,7 +125,7 @@ dbo.employeehoursreportInit = function () {
} );
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.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() ) );
@@ -160,10 +150,10 @@ dbo.employeehoursreportInit = function () {
this.nonprofitablehours = data.nonprofitablehours;
this.nonprojecthours = data.nonprojecthours;
this.totalhours = Math.round( data.totalhours );
this.target = Math.round( data.targethours / 12 );
this.occupancyRateTotal = Math.round( (data.totalhours / (data.targethours / 12)) * 100 );
this.target = dbo.helpers.numberWithPoints( Math.round( data.targethours ) );
this.occupancyRateTotal = Math.round( (data.totalhours / data.targethours) * 100 );
this.occupancyRateHours = Math.round( (data.profitablehours / data.totalhours) * 100 );
this.occupancyRateInvoice = Math.round( (data.profitablehours / (data.targethours / 12)) * 100 );
this.occupancyRateInvoice = Math.round( (data.profitablehours / data.targethours) * 100 );
this.revenues = dbo.helpers.thousandSeparator( data.revenues );
this.averageDayRate = Math.round( (data.revenues / data.profitablehours) * 8 );
}
@@ -23,24 +23,17 @@ dbo.outgoinginvoicesInit = function () {
months : ko.observableArray( dbo.monthArray ),
totalToInvoice : ko.observable(),
totalToInvoiceFuture: ko.observable(),
initialize : null,
validYear : ko.observable(),
init: function () {
var vm = dbo.outgoinginvoicesModel;
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( 0 );
vm.validYear(true);
vm.selectedYear( (new Date()).getFullYear() );
vm.selectedMonthID( 0 );
vm.initialize = false;
vm.initModule();
} );
vm.initModule();
},
setActivetab: function ( tab ) {
@@ -55,6 +48,16 @@ dbo.outgoinginvoicesInit = function () {
vm.refreshInvoiceDetails();
},
checkYear: function () {
var vm = dbo.outgoinginvoicesModel;
if ( !Number.isInteger( Number( vm.selectedYear() ) ) ) return vm.validYear( false );
if ( Number( vm.selectedYear() ) > 2100 ) return vm.validYear( false );
if ( Number( vm.selectedYear() ) < 2000 ) return vm.validYear( false );
vm.validYear( true );
vm.initModule();
},
refreshInvoiceDetails: function () {
var vm = dbo.outgoinginvoicesModel;
+26 -4
View File
@@ -12,10 +12,14 @@ dbo.reservationsInit = function () {
} else {
dbo.reservationsModel = {
projects : ko.observableArray( [] ),
reservation: ko.observable(),
payed : ko.observable(),
saldo : ko.observable(),
projects : ko.observableArray( [] ),
costs : ko.observable(),
reservation : ko.observable(),
payed : ko.observable(),
saldo : ko.observable(),
saldoToPay : ko.observable(),
otherRevenue : ko.observable(),
saldoInvoices: ko.observable(),
init: function () {
var vm = dbo.reservationsModel;
@@ -29,17 +33,25 @@ dbo.reservationsInit = function () {
dbo.reservationsDataservice.getReservations( function ( data ) {
vm.projects.removeAll();
vm.costs( 0 );
vm.reservation( 0 );
vm.payed( 0 );
vm.saldo( 0 );
vm.saldoToPay( 0 );
vm.otherRevenue( 0 );
vm.saldoInvoices( 0 );
_.each( data, function ( p ) {
vm.projects.push( new vm.Project( p ) );
} );
vm.costs( dbo.helpers.numberWithPoints( vm.costs() ) );
vm.reservation( dbo.helpers.numberWithPoints( vm.reservation() ) );
vm.payed( dbo.helpers.numberWithPoints( vm.payed() ) );
vm.saldo( dbo.helpers.numberWithPoints( vm.saldo() ) );
vm.saldoToPay( dbo.helpers.numberWithPoints( vm.saldoToPay() ) );
vm.otherRevenue( dbo.helpers.numberWithPoints( vm.otherRevenue() ) );
vm.saldoInvoices( dbo.helpers.numberWithPoints( vm.saldoInvoices() ) );
} );
},
@@ -52,14 +64,22 @@ dbo.reservationsInit = function () {
var self = this;
self.projectnumber = data.projectnumber;
self.costs = dbo.helpers.numberWithPoints( data.costs );
self.reservation = dbo.helpers.numberWithPoints( data.reservation );
self.payed = dbo.helpers.numberWithPoints( data.payed );
self.saldo = dbo.helpers.numberWithPoints( data.saldo );
self.saldoToPay = dbo.helpers.numberWithPoints( data.saldoToPay );
self.otherRevenue = dbo.helpers.numberWithPoints( data.other_revenue );
self.saldoInvoices = dbo.helpers.numberWithPoints( data.other_revenue - data.costs );
self.showExternals = ko.observable( false );
vm.costs( Number( vm.costs() ) + Number( data.costs ) );
vm.reservation( Number( vm.reservation() ) + Number( data.reservation ) );
vm.payed( Number( vm.payed() ) + Number( data.payed ) );
vm.saldo( Number( vm.saldo() ) + Number( data.saldo ) );
vm.saldoToPay( Number( vm.saldoToPay() ) + Number( data.saldoToPay ) );
vm.otherRevenue( Number( vm.otherRevenue() ) + Number( data.other_revenue ) );
vm.saldoInvoices( Number( vm.saldoInvoices() ) + Number( data.other_revenue - data.costs ) )
self.externals = ko.observableArray( [] );
_.each( data.externals, function ( p ) {
@@ -71,9 +91,11 @@ dbo.reservationsInit = function () {
var self = this;
self.externalName = data.external;
self.costs = dbo.helpers.numberWithPoints( data.costs );
self.reservation = dbo.helpers.numberWithPoints( data.reservation );
self.payed = dbo.helpers.numberWithPoints( data.payed );
self.saldo = dbo.helpers.numberWithPoints( data.saldo );
self.saldoToPay = dbo.helpers.numberWithPoints( data.saldoToPay );
}