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
+4
View File
@@ -22,6 +22,10 @@
text-align: right;
}
.align-center{
text-align: center;
}
.site-menu-sub > li {
margin-left: 30px;
padding-left: 10px;
@@ -0,0 +1,38 @@
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 31/01/2018
* Time: 20:41
*/
dbo.employeehoursDataService = {
getEmployeehours: function ( $month, $year, callback ) {
$.getJSON( 'index.php/projects/employeehoursController/getEmployeehours/' + $month + '/' + $year )
.done( function ( data ) {
callback( data );
} );
},
getHourtypes: function ( callback ) {
$.getJSON( 'index.php/projects/employeehoursController/getHourtypes' )
.done( function ( data ) {
callback( data );
} );
},
saveEmployeehour: function ( submitDATA, callback ) {
$.post( 'index.php/projects/employeehoursController/saveEmployeehour', submitDATA, 'json' )
.done( function ( data ) {
callback( data );
} );
},
removeEmployeehour: function ( employeehourID, callback ) {
$.getJSON( 'index.php/projects/employeehoursController/removeEmployeehour/' + employeehourID )
.done( function ( data ) {
callback( data );
} )
}
};
+4
View File
@@ -81,5 +81,9 @@ dbo.helpers = {
var newDate = dateParts[2] + '-' + dateParts[1] + '-' + dateParts[0];
return newDate;
},
numberWithPoints :function(myNumber) {
return myNumber.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
}
+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' ) );
} );
@@ -0,0 +1,180 @@
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 05/01/2018
* Time: 15:54
*/
dbo.employeehoursInit = function () {
if ( dbo.employeehoursModel !== undefined ) {
dbo.employeehoursModel.refreshHours();
} else {
dbo.employeehoursModel = {
employeehours: ko.observableArray( [] ),
archive : ko.observable( false ),
months : ko.observableArray( [] ),
years : ko.observableArray( [] ),
hourtypes : ko.observableArray( [] ),
employees : ko.observableArray( [] ),
selectedYear : ko.observable(),
selectedMonth: ko.observable(),
busy : false,
init: function () {
var vm = dbo.employeehoursModel;
vm.createMonths();
vm.createYears();
var d = new Date();
vm.selectedMonth( d.getMonth() + 1 );
vm.selectedYear( d.getFullYear() );
dbo.employeehoursDataService.getHourtypes( function ( data ) {
vm.hourtypes( data );
dbo.userDataService.getAllUsers( 'F', function ( data ) {
vm.employees( data );
vm.refreshEmployeehours();
} );
} );
},
newEmployeehour: function () {
var vm = dbo.employeehoursModel;
var employeehour = {
id : 0,
employee_id: null,
hourdate : null,
hourtype_id: null,
hours : 0,
inEdit : true
};
vm.employeehours.push( new vm.Employeehour( employeehour ) );
},
toggleArchive: function () {
var vm = dbo.employeeemployeehoursModel;
vm.archive( !vm.archive() );
vm.refreshHours();
},
saveEmployeehours: function () {
var self = this;
if ( !self.employee_id() ) return;
if ( !self.hourtype_id() ) return;
if ( !self.hourdate() ) return;
var submitDATA = {
id : self.id,
employee_id: self.employee_id(),
hourdate : self.hourdate(),
hourtype_id: self.hourtype_id(),
hours : self.hours()
};
dbo.employeehoursDataService.saveEmployeehour( submitDATA, function ( data ) {
self.id = data.employeehourID;
} );
},
editEmployeehour: function () {
this.inEdit( !this.inEdit() );
},
removeEmployeehour: function () {
var vm = dbo.employeehoursModel;
var self = this;
tellMe( {
title : 'verwijderen uren',
message : 'weet u zeker dat u deze uren wilt verwijderen, dit kan niet ongedaan worden gemaakt',
notify : true,
noText : 'nee verwijder de uren niet',
yesText : 'ja verwijder de uren',
modalClass: 'modal-warning'
}, function ( response ) {
if ( response ) {
dbo.employeehoursDataService.removeEmployeehour( self.id, function ( data ) {
if ( data.result ) {
vm.refreshEmployeehours();
} else {
tellMe( {
title : 'fout bij verwijderen uren',
message : 'de uren konden niet worden verwijderd',
modalClass: 'modal-danger'
} );
}
} );
}
} );
},
createMonths: function () {
var vm = dbo.employeehoursModel;
var months = [
{id: 1, monthName: 'januari'},
{id: 2, monthName: 'februari'},
{id: 3, monthName: 'maart'},
{id: 4, monthName: 'april'},
{id: 5, monthName: 'mei'},
{id: 6, monthName: 'juni'},
{id: 7, monthName: 'juli'},
{id: 8, monthName: 'augustus'},
{id: 9, monthName: 'september'},
{id: 10, monthName: 'oktober'},
{id: 11, monthName: 'november'},
{id: 12, monthName: 'december'},
]
vm.months( months );
},
createYears: function () {
var vm = dbo.employeehoursModel;
var years = [{id: 2015}, {id: 2016}, {id: 2017}, {id: 2018}];
vm.years( years );
},
refreshEmployeehours: function () {
var vm = dbo.employeehoursModel;
vm.employeehours.removeAll();
dbo.employeehoursDataService.getEmployeehours( vm.selectedMonth(), vm.selectedYear(), function ( data ) {
$.each( data, function ( i, p ) {
vm.employeehours.push( new vm.Employeehour( p ) );
} );
} );
},
validateNumber: function ( field ) {
this[field]( dbo.helpers.validateNumber( this[field](), true ) );
},
Employeehour: function ( data ) {
var vm = dbo.employeehoursModel;
this.id = data.id;
this.employee_id = ko.observable( data.employee_id );
this.hourtype_id = ko.observable( data.hourtype_id );
this.hourdate = ko.observable( data.hourdate );
this.hours = ko.observable( data.hours );
this.inEdit = ko.observable( data.inEdit || false );
}
};
dbo.employeehoursModel.init();
ko.applyBindings( dbo.employeehoursModel, document.getElementById( 'EMPLOYEEHOURS' ) );
}
}
@@ -9,7 +9,7 @@
dbo.projectsInit = function () {
if ( dbo.projectsModel !== undefined ) {
dbo.projectsModel.refreshProjects();
} else {
dbo.projectsModel = {
@@ -129,10 +129,9 @@ dbo.projectsInit = function () {
self.revenues = ko.observableArray( [] );
$.each( data.offers, function ( i, p ) {
if ( p.accepteddate ) {
self.totalOwnrevenue += p.totalOwnrevenue;
self.totalOtherrevenue += p.totalOtherrevenue;
self.totalOwnrevenue += Number( p.own_revenue );
self.totalOtherrevenue += Number( p.other_revenue );
}
self.revenues.push( new vm.Revenue( p ) );
} );
},