diversen nav opmerkingen

This commit is contained in:
2018-04-21 16:51:01 +02:00
parent 8e3649768b
commit 9187742658
18 changed files with 339 additions and 227 deletions
+67 -41
View File
@@ -9,44 +9,51 @@ $( function () {
var timeout;
dbo.editProjectModal = {
offers : ko.observableArray( [] ),
projectEmployees : ko.observableArray( [] ),
customers : ko.observableArray( [] ),
users : ko.observableArray( [] ),
invoices : ko.observableArray( [] ),
projecthours : ko.observableArray( [] ),
offerFiles : ko.observableArray( [] ),
offerComments : ko.observableArray( [] ),
projectFiles : ko.observableArray( [] ),
projectComments : ko.observableArray( [] ),
externals : ko.observableArray( [] ),
projectcosts : ko.observableArray( [] ),
vats : ko.observableArray( [] ),
availableEmployees: ko.observableArray( [] ),
forecasts : ko.observableArray( [] ),
reservations : ko.observableArray( [] ),
showProject : ko.observable( false ),
projectID : null,
callback : null,
customerID : ko.observable( null ),
projectnumber : ko.observable(),
projectleaderID : ko.observable(),
archive : ko.observable( false ),
startdate : ko.observable( null ),
enddate : ko.observable( null ),
projectname : ko.observable(),
busy : false,
ownRevenue : ko.observable(),
otherRevenue : ko.observable(),
projectname : ko.observable(),
years : ko.observableArray( dbo.years ),
months : ko.observableArray( dbo.monthArray ),
outstanding : ko.observable(),
toForecast : ko.observable(),
totalForecast : ko.observable(),
documents : ko.observableArray( [] ),
comments : ko.observableArray( [] ),
activeTab : ko.observable(),
offers : ko.observableArray( [] ),
projectEmployees : ko.observableArray( [] ),
customers : ko.observableArray( [] ),
users : ko.observableArray( [] ),
invoices : ko.observableArray( [] ),
projecthours : ko.observableArray( [] ),
offerFiles : ko.observableArray( [] ),
offerComments : ko.observableArray( [] ),
projectFiles : ko.observableArray( [] ),
projectComments : ko.observableArray( [] ),
externals : ko.observableArray( [] ),
projectcosts : ko.observableArray( [] ),
vats : ko.observableArray( [] ),
availableEmployees : ko.observableArray( [] ),
forecasts : ko.observableArray( [] ),
reservations : ko.observableArray( [] ),
showProject : ko.observable( false ),
projectID : null,
callback : null,
customerID : ko.observable( null ),
projectnumber : ko.observable(),
projectleaderID : ko.observable(),
archive : ko.observable( false ),
startdate : ko.observable( null ),
enddate : ko.observable( null ),
projectname : ko.observable(),
busy : false,
ownRevenue : ko.observable(),
otherRevenue : ko.observable(),
projectname : ko.observable(),
years : ko.observableArray( dbo.years ),
months : ko.observableArray( dbo.monthArray ),
outstanding : ko.observable(),
toForecast : ko.observable(),
totalForecast : ko.observable(),
documents : ko.observableArray( [] ),
comments : ko.observableArray( [] ),
activeTab : ko.observable(),
totalRevenues : ko.observable(),
totalInvoiced : ko.observable(),
outstanding : ko.observable(),
outstandingInvoices: ko.observable(),
payed : ko.observable(),
toForecast : ko.observable(),
toInvoice : 0,
init: function () {
var vm = dbo.editProjectModal;
@@ -488,6 +495,7 @@ $( function () {
dbo.projectDataService.saveForecast( submitDATA, function ( data ) {
if ( data.success ) self.id = data.forecastID;
vm.toForecasting();
} );
},
@@ -723,7 +731,12 @@ $( function () {
vm.enddate( dbo.helpers.mysql2date( data.enddate ) );
vm.projectnumber( data.projectnumber );
vm.projectname( data.projectname );
vm.outstanding( data.outstanding );
vm.totalRevenues( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalrevenue ) ) ) );
vm.totalInvoiced( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) );
vm.outstanding( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalrevenue ) ) - Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) );
vm.outstandingInvoices( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) - Math.round( Number( data.invoiceDetails.payed ) ) ) );
vm.payed( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.payed ) ) ) );
vm.toInvoice = Math.round( Number( data.invoiceDetails.totalrevenue ) ) - Math.round( Number( data.invoiceDetails.totalinvoiced ) );
vm.projectEmployees.removeAll();
vm.projecthours.removeAll();
@@ -746,8 +759,8 @@ $( function () {
vm.offers.removeAll();
_.each( data.offers, function ( p, i ) {
if ( i == 0 ) {
vm.ownRevenue( p.own_revenue );
vm.otherRevenue( p.other_revenue );
vm.ownRevenue( dbo.helpers.numberWithPoints( Math.round( Number( p.own_revenue ) ) ) );
vm.otherRevenue( dbo.helpers.numberWithPoints( Math.round( Number( p.other_revenue ) ) ) );
}
vm.offers.push( new dbo.offersService.Offer( p ) );
} );
@@ -762,6 +775,8 @@ $( function () {
vm.forecasts.push( new vm.Forecast( p ) );
} );
vm.toForecasting();
vm.reservations.removeAll();
_.each( data.reservations, function ( p ) {
vm.reservations.push( new vm.Reservation( p ) );
@@ -776,6 +791,17 @@ $( function () {
} );
},
toForecasting: function () {
var vm = dbo.editProjectModal;
console.log( vm.toInvoice );
vm.toForecast( vm.toInvoice );
_.each( vm.forecasts(), function ( p ) {
console.log( p.forecastamount );
vm.toForecast( vm.toForecast() - Number( p.forecastamount() ) );
} );
vm.toForecast( dbo.helpers.numberWithPoints( Number( vm.toForecast() ) ) );
},
Projectemployee: function ( data ) {
var self = this;