This commit is contained in:
2018-01-31 11:10:17 +01:00
parent f3bf0c9f80
commit 05c165c9ed
27 changed files with 724 additions and 265 deletions
+12 -1
View File
@@ -229,10 +229,21 @@
.project-page-header > h3{
color:#fff;
margin-top:10px;
margin-left:30px;
margin-left:20px;
}
.project-page > .container{
background-color: #fff;
}
.graph-holder{
padding:10px 10px;
background-color: #4c4c4c;
background-image: -webkit-gradient(radial, 50% 50%,0,50% 50%,200, from(rgb(22, 20, 17)), to(rgb(76, 76, 76)));
background-image: -webkit-radial-gradient(50% 50%, rgb(76, 76, 76), rgb(22, 20, 17));
background-image: -moz-radial-gradient(50% 50%, rgb(76, 76, 76), rgb(22, 20, 17));
background-image: -o-radial-gradient(50% 50%, rgb(76, 76, 76), rgb(22, 20, 17));
background-image: -ms-radial-gradient(50% 50%, rgb(76, 76, 76), rgb(22, 20, 17));
background-image: radial-gradient(50% 50%, rgb(76, 76, 76), rgb(22, 20, 17));
border-radius: 15px;
}
@@ -22,7 +22,14 @@ dbo.projectDataService = {
},
getpayMents: function ( projectID, callback ) {
$.getJSON( 'index.php/projects/projectsController/getP ayments/' + projectID )
$.getJSON( 'index.php/projects/projectsController/getPayments/' + projectID )
.done( function ( data ) {
callback( data );
} );
},
getAvailableEmployees: function ( projectID, callback ) {
$.getJSON( 'index.php/projects/projectsController/getAvailableEmployees/' + projectID )
.done( function ( data ) {
callback( data );
} );
@@ -40,6 +47,13 @@ dbo.projectDataService = {
} );
},
createProject: function ( offerID, callback ) {
$.getJSON( 'index.php/projects/projectsController/creatProjectFromOffer/' + offerID )
.done( function ( data ) {
callback( data );
} );
},
addProjectemployee: function ( projectID, callback ) {
$.get( 'index.php/projects/projectsController/addProjectemployee/' + projectID, function () {
callback();
@@ -57,6 +71,13 @@ dbo.projectDataService = {
$.post( 'index.php/projects/projectsController/saveProjectemployee', submitDATA );
},
saveInvoice: function ( submitDATA, callback ) {
$.post( 'index.php/projects/projectsController/saveInvoice', submitDATA )
.done( function ( data ) {
callback( data );
} );
},
savePayment: function ( submitDATA, callback ) {
$.post( 'index.php/projects/projectsController/savePayment', submitDATA )
.done( function ( data ) {
@@ -71,6 +92,13 @@ dbo.projectDataService = {
} );
},
saveProjectcost: function ( submitDATA, callback ) {
$.post( 'index.php/projects/projectsController/saveProjectcost', submitDATA )
.done( function ( data ) {
callback( data );
} );
},
archiveProject: function ( userID, status, callback ) {
$.get( 'index.php/projects/projectsController/archiveProject/' + userID + '/' + status )
.done( function () {
+6 -3
View File
@@ -52,14 +52,17 @@ dbo.helpers = {
},
findArrayElement: function ( toFind, element, value, array ) {
console.log( array );
// console.log( toFind );
// console.log( element );
// console.log( value );
// console.log( array );
if ( !Array.isArray( array ) ) return null;
console.log( value );
var foundValue = null
$.each( array, function ( i, p ) {
if ( p[toFind] == value ) foundValue = p[element];
} );
console.log( foundValue );
// console.log( foundValue );
return foundValue;
},
+42 -23
View File
@@ -62,32 +62,51 @@ $( function () {
}
dbo.offerDataService.saveOffer( submitDATA, function ( data ) {
if ( data.success ) {
if ( data.createProject ) {
tellMe( {
title : 'offer aangemaakt',
message : 'de offer is succesvol opgeslagen',
modalClass: 'modal-success'
}, function () {
vm.hideOfferModal();
if ( typeof(vm.callback) == 'function' ) vm.callback();
title : 'project aanmaken',
message : 'De offerte is goedgekeurt maar nog niet gekoppeld aan een project, wilt u een project aanmaken?',
notify : true,
noText : 'Nee, maak geen project aan',
yesText : 'Ja, maak een project aan',
modalClass: 'modal-warning'
}, function ( response ) {
if ( response ) {
dbo.projectDataService.createProject( data.offerID, function ( data ) {
if ( data.success ) {
tellMe( {
title : 'project aangemaakt',
message : 'er is een project aangemaakt met nummer: ' + data.projectnumber,
modalClass: 'modal-success'
}, function(){
vm.hideOfferModal();
} );
} else {
tellMe( {
title : 'fout project aanmaken',
message : 'helaas kon het project niet aangemaakt worden',
modalClass: 'modal-danger'
} );
}
} );
}
} )
} else if ( !data.success ) {
var errorMessage = '<ul>';
$.each( data.messages, function ( i, p ) {
if ( p[0] ) {
errorMessage += '<li>' + i + ': ' + p[0] + '</li>';
}
} );
return;
errorMessage += '</ul>';
tellMe( {
title : 'fout opslaan offerte',
message : errorMessage,
modalClass: 'modal-danger'
} );
}else{
vm.hideOfferModal();
}
var errorMessage = '<ul>';
$.each( data.messages, function ( i, p ) {
if ( p[0] ) {
errorMessage += '<li>' + i + ': ' + p[0] + '</li>';
}
} );
errorMessage += '</ul>';
tellMe( {
title : 'fout aanmaken offer',
message : errorMessage,
modalClass: 'modal-danger'
} );
} );
},
+150 -83
View File
@@ -9,28 +9,29 @@ $( 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( [] ),
showProject : ko.observable( false ),
projectID : null,
callback : null,
customerID : ko.observable( null ),
projectleaderID : ko.observable(),
archive : ko.observable( false ),
startdate : ko.observable( null ),
enddate : ko.observable( null ),
busy : false,
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( [] ),
showProject : ko.observable( false ),
projectID : null,
callback : null,
customerID : ko.observable( null ),
projectleaderID : ko.observable(),
archive : ko.observable( false ),
startdate : ko.observable( null ),
enddate : ko.observable( null ),
busy : false,
init: function () {
var vm = dbo.editProjectModal;
@@ -40,9 +41,13 @@ $( function () {
dbo.userDataService.getAllUsers( 'F', function ( data ) {
vm.users( data );
dbo.externalDataService.getAllExternals( 'F', function ( data ) {
vm.externals( data );
dbo.vatDataService.getVats( 'F', function ( data ) {
vm.vats( data )
vm.refreshProject();
vm.vats( data );
vm.refreshAvailableEmployees( function () {
vm.refreshProject();
} );
} );
} );
} );
@@ -50,11 +55,11 @@ $( function () {
},
togglePayments: function () {
this.showPayment( !this.showPayment() );
this.showPayments( !this.showPayments() );
var showPayments = sessionStorage.showPayments || [];
if ( this.showPayment() ) {
if ( this.showPayments() ) {
showPayments.push( this.id );
} else {
var index = showPayments.indexOf( this.id );
@@ -76,10 +81,22 @@ $( function () {
} );
},
editPayment: function () {
editInvoice: function () {
var self = this;
var vm = dbo.editProjectModal;
$.each( vm.payments(), function ( i, p ) {
$.each( vm.invoices(), function ( i, p ) {
if ( p.id == self.id ) {
p.inEdit( !p.inEdit() );
} else {
p.inEdit( false );
}
} );
},
editPayment: function ( parent ) {
var self = this;
$.each( parent.payments(), function ( i, p ) {
console.log( p.invoice_id(), ' ', parent.id );
if ( p.id == self.id ) {
p.inEdit( !p.inEdit() );
} else {
@@ -100,6 +117,18 @@ $( function () {
} );
},
editProjectcosts: function () {
var self = this;
var vm = dbo.editProjectModal;
$.each( vm.projectcosts(), function ( i, p ) {
if ( p.id == self.id ) {
p.inEdit( !p.inEdit() );
} else {
p.inEdit( false );
}
} );
},
newOffer: function () {
var vm = dbo.editProjectModal;
var service = dbo.offersService;
@@ -129,16 +158,17 @@ $( function () {
newPayment: function () {
var vm = dbo.editProjectModal;
var self = this;
console.log( self );
var payment = {
id : 0,
offernumber : '',
invoice_id : self.id,
paymentdate : null,
paymentamount: 0,
inEdit : true
};
vm.payments.push( new vm.Payment( payment ) );
self.payments.push( new vm.Payment( payment ) );
},
newProjecthour: function () {
@@ -241,25 +271,44 @@ $( function () {
}
timeout = setTimeout( function () {
var submitDATA = {
id : self.id,
user_id : self.employeeID(),
tarif : self.tarif() ? self.tarif().toString().replace( ',', '.' ) : 0,
budget : self.budget() ? self.budget().toString().replace( ',', '.' ) : 0,
startdate: self.startdate()
id : self.id,
user_id: self.employeeID(),
tarif : self.tarif() ? self.tarif().toString().replace( ',', '.' ) : 0,
budget : self.budget() ? self.budget().toString().replace( ',', '.' ) : 0
}
dbo.projectDataService.saveProjectemployee( submitDATA );
dbo.projectDataService.saveProjectemployee( submitDATA, function () {
vm.refreshAvailableEmployees();
} );
}, 400 );
},
saveInvoice: function () {
var self = this;
var submitDATA = {
id : self.id,
project_id : self.project_id(),
invoicenumber : self.invoicenumber(),
invoicedate : self.invoicedate(),
invoiceamount : self.invoiceamount(),
forecastamount: self.forecastamount(),
forecastdate : self.forecastdate(),
vat_id : self.vat_id()
};
dbo.projectDataService.saveInvoice( submitDATA, function ( data ) {
if ( data.success ) self.id = data.invoiceID;
} );
},
savePayment: function () {
var self = this;
if ( !self.offer_id() ) return;
var submitDATA = {
id : self.id,
offer_id : self.offer_id(),
invoice_id : self.invoice_id(),
paymentdate : self.paymentdate(),
paymentamount: self.paymentamount()
};
@@ -287,6 +336,24 @@ $( function () {
} );
},
saveProjectcosts: function () {
var vm = dbo.editProjectModal;
var self = this;
var submitDATA = {
id : self.id,
project_id : vm.projectID,
external_id: self.external_id(),
description: self.description(),
date : self.date(),
costs : self.costs()
};
dbo.projectDataService.saveProjectcost( submitDATA, function ( data ) {
if ( data.success ) self.id = data.projectcostID;
} );
},
removeProjectemployee: function () {
var vm = dbo.editProjectModal;
var self = this;
@@ -303,13 +370,7 @@ $( function () {
if ( response ) {
dbo.projectDataService.removeProjectemployee( self.id, function ( data ) {
if ( data.result ) {
tellMe( {
title : 'projectmedewerker verwijderd',
message : 'de projectmedewerker is succesvol verwijderd',
modalClass: 'modal-success'
}, function () {
vm.refreshProject();
} );
vm.refreshProject();
} else {
tellMe( {
title : 'fout bij verwijderen projectmedewerker',
@@ -338,13 +399,7 @@ $( function () {
if ( response ) {
dbo.offerDataService.removeOffer( self.id, function ( data ) {
if ( data.result ) {
tellMe( {
title : 'offerte verwijderd',
message : 'de offerte is succesvol verwijderd',
modalClass: 'modal-success'
}, function () {
vm.refreshProject();
} );
vm.refreshProject();
} else {
tellMe( {
title : 'fout bij verwijderen offerte',
@@ -373,13 +428,7 @@ $( function () {
if ( response ) {
dbo.projectDataService.removePayment( self.id, function ( data ) {
if ( data.result ) {
tellMe( {
title : 'betaling verwijderd',
message : 'de betaling is succesvol verwijderd',
modalClass: 'modal-success'
}, function () {
vm.refreshProject();
} );
vm.refreshProject();
} else {
tellMe( {
title : 'fout bij verwijderen betaling',
@@ -408,13 +457,7 @@ $( function () {
if ( response ) {
dbo.projectDataService.removeProjecthour( self.id, function ( data ) {
if ( data.result ) {
tellMe( {
title : 'projectuur verwijderd',
message : 'de projectuur is succesvol verwijderd',
modalClass: 'modal-success'
}, function () {
vm.refreshProject();
} );
vm.refreshProject();
} else {
tellMe( {
title : 'fout bij verwijderen projectuur',
@@ -436,7 +479,17 @@ $( function () {
},
validateNumber: function ( field ) {
this[field]( dbo.helpers.validateNumber( this[field](), false ) );
this[field]( dbo.helpers.validateNumber( this[field](), true ) );
},
refreshAvailableEmployees: function ( callback ) {
var vm = dbo.editProjectModal;
dbo.projectDataService.getAvailableEmployees( vm.projectID, function ( data ) {
vm.availableEmployees( data );
if ( typeof(callback) == 'function' ) callback();
} );
},
refreshProject: function () {
@@ -479,6 +532,9 @@ $( function () {
} );
vm.busy = false;
dbo.charts.drawHoursVsBudget(340, 230, 'hours-vs-budget');
dbo.charts.drawInvoicesVsPayed(36000, 24000, 11000, 'invoice-vs-payed');
} );
},
@@ -490,12 +546,11 @@ $( function () {
self.fullname = ko.observable( data.user ? data.user.fullname : '#NB' );
self.tarif = ko.observable( data.tarif ? data.tarif.toString().replace( '.', ',' ) : 0 );
self.budget = ko.observable( data.budget ? data.budget.toString().replace( '.', ',' ) : 0 );
self.startdate = ko.observable( dbo.helpers.mysql2date( data.startdate ) );
self.inEdit = ko.observable( sessionStorage.editEmployee == data.id );
},
Projecthour: function ( data, fullname ) {
var inEdit = sessionStorage.editPayment == data.id;
var inEdit = sessionStorage.Projecthour == data.id;
if ( !inEdit ) inEdit = data.inEdit || false;
this.id = data.id;
@@ -526,33 +581,43 @@ $( 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( 2 ) );
self.forecastamount = ko.observable( data.forecastamount.toFixed( 2 ) );
self.forecastdate = ko.observable( dbo.helpers.mysql2date( data.forecastdate ) );
self.vat_id = ko.observable( data.vat_id );
self.inEdit = ko.observable( inEdit );
self.inclBtw = ko.pureComputed( 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.editProjectModal );
self.showPayments = ko.observable( data.showPayments || false );
self.inclBtw = ko.pureComputed(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.editProjectModal)
if ( sessionStorage.showPayment == data.id ) self.showPayments( true );
self.payments = ko.observableArray( [] );
$.each( data.payments, function ( i, p ) {
self.payments.push( new vm.Payment( p, self.invoicenumber ) );
} );
self.outstanding = ko.pureComputed( function () {
var payed = 0
$.each( self.payments(), function ( i, p ) {
payed += Number( p.paymentamount() );
} );
return (self.inclBtw() - payed).toFixed( 2 );
} );
},
Payment: function ( data, invoicenumber = '' ) {
Payment: function ( data ) {
var inEdit = sessionStorage.editPayment == data.id;
if ( !inEdit ) inEdit = data.inEdit || false;
this.id = data.id;
this.invoicenumber = ko.observable( invoicenumber );
this.invoice_id = ko.observable( data.invoice_id );
this.paymentdate = ko.observable( dbo.helpers.mysql2date( data.paymentdate ) );
this.paymentamount = ko.observable( data.paymentamount );
this.inEdit = ko.observable( inEdit );
@@ -560,4 +625,6 @@ $( function () {
};
ko.applyBindings( dbo.editProjectModal, document.getElementById( 'project-modal' ) );
} );
} );
+81
View File
@@ -0,0 +1,81 @@
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 30/01/2018
* Time: 16:03
*/
dbo.charts = {
drawHoursVsBudget : function(hours, budget, element){
var ctx = document.getElementById( element ).getContext( '2d' );
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["uren", "budget"],
datasets: [{
data: [hours, budget],
backgroundColor: [
'#f3a921', '#f2770c'
]
}]
},
options: {
maintainAspectRatio: false,
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
},
legend:{
display : false,
},
title: {
display: true,
text: 'Uren vs budget',
fontSize:16,
fontColor: '#b2b2b2'
}
}
});
},
drawInvoicesVsPayed : function(offer, invoice, payed, element){
var ctx = document.getElementById( element ).getContext( '2d' );
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["offerte", "facturen", "betaald"],
datasets: [{
data: [offer, invoice, payed],
backgroundColor: [
'#f3a921', '#f2770c', '#72221a'
]
}]
},
options: {
maintainAspectRatio: false,
scales: {
yAxes: [{
ticks: {
beginAtZero:true
}
}]
},
legend:{
display : false,
},
title: {
display: true,
text: 'offerte vs facuren vs betalingen',
fontSize:16,
fontColor: '#b2b2b2'
}
}
});
}
}
+1 -1
View File
@@ -13,7 +13,7 @@ dbo.offersService = {
newOffer: function (projectID=false, customerID=false) {
var service = dbo.offersService;
dbo.editOfferModal.newEditOffer( false, projectID, customerID, function () {
dbo.editOfferModal.newEditOffer( false, projectID, customerID, true, function () {
service.refreshOffers();
} );
},
+16
View File
File diff suppressed because one or more lines are too long