employeehours

This commit is contained in:
2018-01-31 21:56:13 +01:00
parent 05c165c9ed
commit b634d0b139
24 changed files with 700 additions and 85 deletions
+6 -3
View File
@@ -19,6 +19,7 @@ $( function () {
remarks : ko.observable(),
rate : ko.observable(),
kvk_number : ko.observable(),
iban : ko.observable(),
callback : null,
init: function () {
@@ -50,7 +51,8 @@ $( function () {
website : vm.website(),
remarks : vm.remarks(),
rate : vm.rate(),
kvk_number : vm.kvk_number()
kvk_number : vm.kvk_number(),
iban : vm.iban()
}
dbo.externalDataService.saveExternal( submitDATA, function ( data ) {
@@ -97,6 +99,7 @@ $( function () {
vm.remarks( external.remarks || '' );
vm.rate( external.rate || 0 );
vm.kvk_number( external.kvk_number || '' );
vm.iban( external.iban || '' );
},
showExternalModal: function () {
@@ -107,12 +110,12 @@ $( function () {
$( "#external-modal" ).modal( 'hide' );
},
validateNumber : function ( ) {
validateNumber: function () {
var vm = dbo.editExternalModal;
vm.rate( dbo.helpers.validateNumber( vm.rate(), false ) );
}
};
};
dbo.editExternalModal.init();
+2
View File
@@ -80,6 +80,7 @@ $( function () {
modalClass: 'modal-success'
}, function(){
vm.hideOfferModal();
vm.callback();
} );
} else {
tellMe( {
@@ -106,6 +107,7 @@ $( function () {
} );
}else{
vm.hideOfferModal();
vm.callback();
}
} );
},
+96 -22
View File
@@ -27,6 +27,7 @@ $( function () {
projectID : null,
callback : null,
customerID : ko.observable( null ),
projectnumber : ko.observable(),
projectleaderID : ko.observable(),
archive : ko.observable( false ),
startdate : ko.observable( null ),
@@ -105,6 +106,15 @@ $( function () {
} );
},
setHourtype: function ( status ) {
if ( !this.inEdit() ) return;
var vm = dbo.editProjectModal;
this.hourtype_id( status );
vm.saveProjecthour( this );
},
editProjecthour: function () {
var self = this;
var vm = dbo.editProjectModal;
@@ -179,6 +189,7 @@ $( function () {
projectemployee_id: null,
hourdate : null,
hours : 0,
hourtype_id : 1,
inEdit : true
};
@@ -318,8 +329,8 @@ $( function () {
} );
},
saveProjecthour: function () {
var self = this;
saveProjecthour: function ( self = false ) {
if ( !self ) self = this;
if ( !self.projectemployee_id() ) return;
@@ -327,6 +338,7 @@ $( function () {
id : self.id,
projectemployee_id: self.projectemployee_id(),
hourdate : self.hourdate(),
hourtype_id : self.hourtype_id(),
hours : self.hours()
};
@@ -346,7 +358,8 @@ $( function () {
external_id: self.external_id(),
description: self.description(),
date : self.date(),
costs : self.costs()
costs : self.costs(),
payed : self.payed()
};
dbo.projectDataService.saveProjectcost( submitDATA, function ( data ) {
@@ -502,6 +515,7 @@ $( function () {
vm.customerID( data.customer_id );
vm.startdate( dbo.helpers.mysql2date( data.startdate ) );
vm.enddate( dbo.helpers.mysql2date( data.enddate ) );
vm.projectnumber( data.projectnumber );
vm.projectEmployees.removeAll();
vm.projecthours.removeAll();
@@ -522,6 +536,7 @@ $( function () {
} );
vm.offers.removeAll();
$.each( data.offers, function ( i, p ) {
vm.offers.push( new dbo.offersService.Offer( p ) );
} );
@@ -533,8 +548,8 @@ $( function () {
vm.busy = false;
dbo.charts.drawHoursVsBudget(340, 230, 'hours-vs-budget');
dbo.charts.drawInvoicesVsPayed(36000, 24000, 11000, 'invoice-vs-payed');
dbo.charts.drawHoursVsBudget( 340, 230, 'hours-vs-budget' );
dbo.charts.drawInvoicesVsPayed( 36000, 24000, 11000, 'invoice-vs-payed' );
} );
},
@@ -550,25 +565,50 @@ $( function () {
},
Projecthour: function ( data, fullname ) {
var self = this;
var vm = dbo.editProjectModal;
var inEdit = sessionStorage.Projecthour == data.id;
if ( !inEdit ) inEdit = data.inEdit || false;
this.id = data.id;
this.fullname = ko.observable( fullname );
this.projectemployee_id = ko.observable( data.projectemployee_id );
this.hourdate = ko.observable( dbo.helpers.mysql2date( data.hourdate ) );
this.hours = ko.observable( data.hours );
this.inEdit = ko.observable( inEdit );
self.id = data.id;
self.fullname = ko.observable( fullname );
self.projectemployee_id = ko.observable( data.projectemployee_id );
self.hourdate = ko.observable( dbo.helpers.mysql2date( data.hourdate ) );
self.hours = ko.observable( data.hours );
self.hourtype_id = ko.observable( data.hourtype_id );
self.inEdit = ko.observable( inEdit );
self.revenue = ko.pureComputed( function () {
if ( !self.projectemployee_id() ) return 0;
var tarif = dbo.helpers.findArrayElement( 'id', 'tarif', self.projectemployee_id(), vm.projectEmployees() )();
if ( isNaN( tarif ) ) return 0;
if ( isNaN( self.hours() ) ) return 0;
if ( self.hourtype_id() != 1 ) return 0;
return (tarif * self.hours()).toFixed( 0 );
} );
},
Projectcost: function ( data ) {
this.id = data.id;
this.external_id = ko.observable( data.external_id );
this.contactperson = ko.observable( data.external ? data.external.contactperson : '' );
this.description = ko.observable( data.description );
this.date = ko.observable( dbo.helpers.mysql2date( data.date ) );
this.costs = ko.observable( data.costs );
this.inEdit = ko.observable( data.inEdit || false );
var self = this;
self.id = data.id;
self.external_id = ko.observable( data.external_id );
self.contactperson = ko.observable( data.external ? data.external.contactperson : '' );
self.description = ko.observable( data.description );
self.date = ko.observable( dbo.helpers.mysql2date( data.date ) );
self.costs = ko.observable( data.costs );
self.payed = ko.observable( data.payed );
self.inEdit = ko.observable( data.inEdit || false );
this.toPay = ko.pureComputed( function () {
if ( isNaN( self.costs() ) ) return 0;
if ( isNaN( self.payed() ) ) return 0;
return self.costs() - self.payed();
} )
},
Invoice: function ( data ) {
@@ -581,8 +621,8 @@ $( function () {
self.project_id = ko.observable( data.project_id );
self.invoicenumber = ko.observable( data.invoicenumber );
self.invoicedate = ko.observable( dbo.helpers.mysql2date( data.invoicedate ) );
self.invoiceamount = ko.observable( data.invoiceamount.toFixed( 2 ) );
self.forecastamount = ko.observable( data.forecastamount.toFixed( 2 ) );
self.invoiceamount = ko.observable( data.invoiceamount.toFixed( 0 ) );
self.forecastamount = ko.observable( data.forecastamount.toFixed( 0 ) );
self.forecastdate = ko.observable( dbo.helpers.mysql2date( data.forecastdate ) );
self.vat_id = ko.observable( data.vat_id );
@@ -592,7 +632,7 @@ $( function () {
if ( !self.vat_id() ) return self.invoiceamount();
return (Number( self.invoiceamount() ) + (self.invoiceamount() *
(dbo.helpers.findArrayElement( 'id', 'vatrate', self.vat_id(), this.vats() ) / 100))).toFixed( 2 );
(dbo.helpers.findArrayElement( 'id', 'vatrate', self.vat_id(), this.vats() ) / 100))).toFixed( 0 );
}, dbo.editProjectModal );
self.showPayments = ko.observable( data.showPayments || false );
@@ -608,7 +648,7 @@ $( function () {
$.each( self.payments(), function ( i, p ) {
payed += Number( p.paymentamount() );
} );
return (self.inclBtw() - payed).toFixed( 2 );
return (self.inclBtw() - payed).toFixed( 0 );
} );
},
@@ -624,6 +664,40 @@ $( function () {
}
};
dbo.editProjectModal.totalHours = ko.pureComputed( function () {
var vm = dbo.editProjectModal;
var totalHours = 0
$.each( vm.projecthours(), function ( i, p ) {
if ( p.hourtype_id() == 1 ) {
totalHours += Number( p.hours() );
}
} );
return totalHours;
} );
dbo.editProjectModal.totalRevenue = ko.pureComputed( function () {
var vm = dbo.editProjectModal;
var totalRevenue = 0
$.each( vm.projecthours(), function ( i, p ) {
if ( p.hourtype_id() == 1 ) {
totalRevenue += Number( p.revenue() );
}
} );
return totalRevenue.toFixed( 0 );
} );
dbo.editProjectModal.totalBudget = ko.pureComputed( function () {
var vm = dbo.editProjectModal;
var totalBudget = 0;
$.each( vm.projectEmployees(), function ( i, p ) {
totalBudget += Number( p.budget() );
} );
return totalBudget;
} );
ko.applyBindings( dbo.editProjectModal, document.getElementById( 'project-modal' ) );
} );