projecten

This commit is contained in:
2018-01-18 08:45:09 +01:00
parent 00246f49f7
commit 970aa53971
25 changed files with 689 additions and 285 deletions
+48
View File
@@ -0,0 +1,48 @@
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/01/2018
* Time: 16:28
*/
dbo.commentModel = {
comment : ko.observable(),
commentID: null,
callback : null,
options : {
// disable wrapping content with paragraphs
// instead <br> will be used
enter : $.FroalaEditor.ENTER_DIV,
key : 'zc1QXIa2QZe1UOXATEX==',
// we like gray!
theme : 'gray',
toolbarButtons: ['bold', 'italic', 'underline']
},
showComment: function ( commentID, callback ) {
var vm = dbo.commentModel;
vm.callback = callback;
vm.commentID = commentID;
$( "#comment-modal" ).modal( 'show' );
dbo.commentsDataService.getComment( vm.commentID, function ( data ) {
vm.comment( data.comment );
} );
},
saveComment: function () {
var vm = dbo.commentModel;
dbo.commentsDataService.saveComment( vm.commentID, vm.comment(), function () {
$( "#comment-modal" ).modal( 'hide' );
vm.callback();
} );
}
}
ko.applyBindings( dbo.commentModel, document.getElementById( 'comment-modal' ) );
+130
View File
@@ -0,0 +1,130 @@
/**
* Created by Pensare Software.
* Customer: Theo Weijmer
* Date: 25/12/2017
* Time: 17:32
*/
$( function () {
dbo.editCustomerModal = {
id : null,
name : ko.observable(),
address : ko.observable(),
postcode : ko.observable(),
place : ko.observable(),
contactperson: ko.observable(),
email : ko.observable(),
website : ko.observable(),
remarks : ko.observable(),
callback : null,
init: function () {
},
newEditCustomer: function ( customer, callback ) {
var vm = dbo.editCustomerModal;
vm.callback = typeof(callback) == 'function' ? callback : null;
vm.showCustomerModal();
vm.setCustomer( customer );
},
saveCustomer: function () {
var vm = dbo.editCustomerModal;
if ( vm.formValid == false ) return;
var submitDATA = {
id : vm.id,
name : vm.name(),
address : vm.address(),
postcode : vm.postcode(),
place : vm.place(),
contactperson: vm.contactperson(),
email : vm.email(),
website : vm.website(),
remarks : vm.remarks(),
}
dbo.customerDataService.saveCustomer( submitDATA, function ( data ) {
if ( data.success ) {
tellMe( {
title : 'opdrachtgever aangemaakt',
message : 'opdrachtgever is succesvol opgeslagen',
modalClass: 'modal-success'
}, function () {
vm.hideCustomerModal();
if ( typeof(vm.callback) == 'function' ) vm.callback();
} );
return;
}
var errorMessage = '<ul>';
$.each( data.messages, function ( i, p ) {
if ( p[0] ) {
errorMessage += '<li>' + i + ': ' + p[0] + '</li>';
}
} );
errorMessage += '</ul>';
tellMe( {
title : 'fout aanmaken opdrachtgever',
message : errorMessage,
modalClass: 'modal-danger'
} );
} );
},
setCustomer: function ( customer ) {
var vm = dbo.editCustomerModal;
vm.id = customer.id || 0;
vm.name( customer.name || '' );
vm.address( customer.address || '' );
vm.postcode( customer.postcode || '' );
vm.place( customer.place || '' );
vm.contactperson( customer.contactperson || '' );
vm.email( customer.email || '' );
vm.website( customer.website || '' );
vm.remarks( customer.remarks || '' );
},
showCustomerModal: function () {
$( "#customer-modal" ).modal( 'show' );
},
hideCustomerModal: function () {
$( "#customer-modal" ).modal( 'hide' );
}
};
dbo.editCustomerModal.init();
dbo.editCustomerModal.nameInvalid = ko.pureComputed( function () {
if ( !this.name() ) return true;
if ( this.name().length < 2 ) return true;
return false;
}, dbo.editCustomerModal );
dbo.editCustomerModal.emailInvalid = ko.pureComputed( function () {
if ( !this.email() ) return false;
return !dbo.helpers.validateEmail( this.email() );
}, dbo.editCustomerModal );
dbo.editCustomerModal.formValid = ko.pureComputed( function () {
if ( this.nameInvalid() ) return false;
if ( this.emailInvalid() ) return false;
return true;
}, dbo.editCustomerModal )
ko.applyBindings( dbo.editCustomerModal, document.getElementById( 'customer-modal' ) );
} );
+142
View File
@@ -0,0 +1,142 @@
/**
* Created by Pensare Software.
* External: Theo Weijmer
* Date: 25/12/2017
* Time: 17:32
*/
$( function () {
dbo.editExternalModal = {
id : null,
name : ko.observable(),
address : ko.observable(),
postcode : ko.observable(),
place : ko.observable(),
contactperson: ko.observable(),
email : ko.observable(),
website : ko.observable(),
remarks : ko.observable(),
rate : ko.observable(),
kvk_number : ko.observable(),
callback : null,
init: function () {
},
newEditExternal: function ( external, callback ) {
var vm = dbo.editExternalModal;
vm.callback = typeof(callback) == 'function' ? callback : null;
vm.showExternalModal();
vm.setExternal( external );
},
saveExternal: function () {
var vm = dbo.editExternalModal;
if ( vm.formValid == false ) return;
var submitDATA = {
id : vm.id,
name : vm.name(),
address : vm.address(),
postcode : vm.postcode(),
place : vm.place(),
contactperson: vm.contactperson(),
email : vm.email(),
website : vm.website(),
remarks : vm.remarks(),
rate : vm.rate(),
kvk_number : vm.kvk_number()
}
dbo.externalDataService.saveExternal( submitDATA, function ( data ) {
if ( data.success ) {
tellMe( {
title : 'externe aangemaakt',
message : 'externe is succesvol opgeslagen',
modalClass: 'modal-success'
}, function () {
vm.hideExternalModal();
if ( typeof(vm.callback) == 'function' ) vm.callback();
} );
return;
}
var errorMessage = '<ul>';
$.each( data.messages, function ( i, p ) {
if ( p[0] ) {
errorMessage += '<li>' + i + ': ' + p[0] + '</li>';
}
} );
errorMessage += '</ul>';
tellMe( {
title : 'fout aanmaken externe',
message : errorMessage,
modalClass: 'modal-danger'
} );
} );
},
setExternal: function ( external ) {
var vm = dbo.editExternalModal;
vm.id = (external.id || 0);
vm.name( external.name || '' );
vm.address( external.address || '' );
vm.postcode( external.postcode || '' );
vm.place( external.place || '' );
vm.contactperson( external.contactperson || '' );
vm.email( external.email || '' );
vm.website( external.website || '' );
vm.remarks( external.remarks || '' );
vm.rate( external.rate || 0 );
vm.kvk_number( external.kvk_number || '' );
},
showExternalModal: function () {
$( "#external-modal" ).modal( 'show' );
},
hideExternalModal: function () {
$( "#external-modal" ).modal( 'hide' );
},
validateNumber : function ( ) {
var vm = dbo.editExternalModal;
vm.rate( dbo.helpers.validateNumber( vm.rate(), false ) );
}
};
dbo.editExternalModal.init();
dbo.editExternalModal.contactpersonInvalid = ko.pureComputed( function () {
if ( !this.contactperson() ) return true;
if ( this.contactperson().length < 2 ) return true;
return false;
}, dbo.editExternalModal );
dbo.editExternalModal.emailInvalid = ko.pureComputed( function () {
if ( !this.email() ) return false;
return !dbo.helpers.validateEmail( this.email() );
}, dbo.editExternalModal );
dbo.editExternalModal.formValid = ko.pureComputed( function () {
if ( this.contactpersonInvalid() ) return false;
if ( this.emailInvalid() ) return false;
return true;
}, dbo.editExternalModal )
ko.applyBindings( dbo.editExternalModal, document.getElementById( 'external-modal' ) );
} );
+185
View File
@@ -0,0 +1,185 @@
/**
* Created by Pensare Software.
* Offer: Theo Weijmer
* Date: 25/12/2017
* Time: 17:32
*/
$( function () {
dbo.editOfferModal = {
id : null,
projects : ko.observableArray( [] ),
customers : ko.observableArray( [] ),
users : ko.observableArray( [] ),
startdate : ko.observable(),
acceptance_chance: ko.observable(),
accepteddate : ko.observable(),
rejectdate : ko.observable(),
customer_id : ko.observable(),
project_id : ko.observable(),
offernumber : ko.observable(),
offerleader_id : ko.observable(),
own_revenue : ko.observable(),
other_revenue : ko.observable(),
init: function () {
var vm = dbo.editOfferModal;
dbo.editOfferModal.refreshCustomers();
dbo.editOfferModal.refreshUsers();
},
newEditOffer: function ( offer, callback ) {
var vm = dbo.editOfferModal;
vm.callback = typeof(callback) == 'function' ? callback : null;
vm.showOfferModal();
vm.setOffer( offer );
},
getCustomerProjects: function () {
var vm = dbo.editOfferModal;
},
saveOffer: function () {
var vm = dbo.editOfferModal;
if ( vm.formValid == false ) return;
var submitDATA = {
id : vm.id,
project_id : vm.project_id(),
customer_id : vm.customer_id(),
offerleader_id : vm.offerleader_id(),
offernumber : vm.offernumber(),
own_revenue : vm.own_revenue(),
other_revenue : vm.other_revenue(),
startdate : vm.startdate(),
acceptance_chance: vm.acceptance_chance(),
accepteddate : vm.accepteddate(),
rejectdate : vm.rejectdate(),
}
dbo.offerDataService.saveOffer( submitDATA, function ( data ) {
if ( data.success ) {
tellMe( {
title : 'offer aangemaakt',
message : 'de offer is succesvol opgeslagen',
modalClass: 'modal-success'
}, function () {
vm.hideOfferModal();
if ( typeof(vm.callback) == 'function' ) vm.callback();
} );
return;
}
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'
} );
} );
},
setOffer: function ( offer ) {
var vm = dbo.editOfferModal;
vm.id = offer.id || 0;
vm.customer_id( offer.customer_id || null );
vm.project_id( offer.project_id || null );
vm.offerleader_id( offer.offerleader_id || null );
vm.offernumber( offer.offernumber || null );
vm.startdate( offer.startdate || null );
vm.acceptance_chance( offer.acceptance_chance || 0 );
vm.accepteddate( offer.accepteddate || null );
vm.rejectdate( offer.rejectdate || null );
vm.own_revenue( offer.own_revenue || 0 );
vm.other_revenue( offer.other_revenue || 0 )
},
showOfferModal: function () {
$( "#offer-modal" ).modal( 'show' );
},
hideOfferModal: function () {
$( "#offer-modal" ).modal( 'hide' );
},
validateNumber: function () {
var vm = dbo.editOfferModal;
vm.acceptance_chance( dbo.helpers.validateNumber( vm.acceptance_chance(), false ) );
},
addCustomer: function () {
var vm = dbo.editOfferModal;
dbo.editCustomerModal.newEditCustomer( false, function () {
vm.refreshCustomers();
} );
},
addUser:function(){
var vm = dbo.editOfferModal;
dbo.editUserModal.newEditUser( false, function () {
vm.refreshUsers();
} );
},
refreshCustomers: function () {
var vm = dbo.editOfferModal;
dbo.customerDataService.getAllCustomers( 'F', function ( data ) {
vm.customers( data );
} );
},
refreshUsers: function () {
var vm = dbo.editOfferModal;
dbo.userDataService.getAllUsers( 'F', function ( data ) {
vm.users( data );
} );
},
resetDate: function ( field ) {
var vm = dbo.editOfferModal;
vm[field]( null );
}
};
dbo.editOfferModal.init();
dbo.editOfferModal.offerDateValid = ko.pureComputed( function () {
if ( !this.startdate() ) return false;
if ( this.startdate().length != 10 ) return false;
return true;
}, dbo.editOfferModal );
dbo.editOfferModal.chance = ko.pureComputed( function () {
if ( this.acceptance_chance() < 0 ) return this.acceptance_chance( 0 );
if ( this.acceptance_chance() > 100 ) return this.acceptance_chance( 100 );
}, dbo.editOfferModal );
dbo.editOfferModal.formValid = ko.pureComputed( function () {
if ( !this.offernumber() ) return false;
if ( !this.customer_id() ) return false;
if ( !this.offerleader_id() ) return false;
if ( !this.offerDateValid() ) return false;
return true;
}, dbo.editOfferModal )
ko.applyBindings( dbo.editOfferModal, document.getElementById( 'offer-modal' ) );
} );
+102
View File
@@ -0,0 +1,102 @@
/**
* Created by Pensare Software.
* Offer: Theo Weijmer
* Date: 25/12/2017
* Time: 17:32
*/
$( function () {
dbo.editProjectModal = {
offers : ko.observableArray( [] ),
projectEmployees: ko.observableArray( [] ),
customers : ko.observableArray( [] ),
showProject : ko.observable( false ),
projectID : null,
callback : null,
customerID : ko.observable( null ),
archive : ko.observable( false ),
startdate : ko.observable( null ),
enddate : ko.observable( null ),
init: function () {
var vm = dbo.editProjectModal;
vm.refreshProject();
dbo.customerDataService.getAllCustomers( 'F', function ( data ) {
vm.customers( data );
} );
},
addProject: function ( callback ) {
var vm = dbo.editProjectModal;
vm.callback = callback;
dbo.projectDataService.addProject( function ( data ) {
vm.projectID = data;
vm.showProject( true );
vm.init();
} );
},
addProjectEmployee: function () {
var vm = dbo.editProjectModal;
dbo.projectDataService.addProjectemployee( function ( projectID ) {
vm.projectID = projectID;
vm.refreshProject();
} );
},
saveCustomerID: function () {
},
closeProject: function () {
var vm = dbo.editProjectModal;
vm.showProject( false );
},
refreshProject: function () {
var vm = dbo.editProjectModal;
dbo.projectDataService.getProject( vm.projectID, function ( data ) {
vm.Project( data );
} );
},
Project: function ( data ) {
var vm = dbo.editProjectModal;
var self = this;
vm.id = data.id;
vm.customerID( data.customer_id );
vm.startdate( data.startdate );
vm.enddate( data.enddate );
self.projectEmployees = ko.observableArray( [] );
$.each( data.employees, function ( i, p ) {
self.projectEmployees.push( new vm.Projectemployee( p ) );
} );
},
Projectemployee: function ( data ) {
var self = this;
self.id = data.id;
self.employee_id = data.employee_id;
self.fullname = data.user ? data.user.fullname : '#NB';
self.tarif = data.tarif;
self.budget = data.budget;
self.startdate = dbo.helpers.mysql2date( data.startdate );
self.enddate = dbo.helpers.mysql2date( data.enddate );
}
};
ko.applyBindings( dbo.editProjectModal, document.getElementById( 'project-modal' ) );
} );
+154
View File
@@ -0,0 +1,154 @@
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 25/12/2017
* Time: 17:32
*/
$( function () {
dbo.editUserModal = {
id : null,
roles : ko.observableArray( [] ),
firstname : ko.observable(),
lastname : ko.observable(),
middlename: ko.observable(),
username : ko.observable(),
email : ko.observable(),
role : ko.observable(),
callback : null,
init: function () {
var vm = dbo.editUserModal;
dbo.rolesDataservice.getAllRoles( 'F', function ( data ) {
vm.roles( data );
} );
},
newEditUser: function ( user, callback ) {
var vm = dbo.editUserModal;
vm.callback = typeof(callback) == 'function' ? callback : null;
vm.showUserModal();
vm.setUser( user );
},
setRole: function () {
var vm = dbo.editUserModal;
vm.role( this.rolelevel );
},
saveUser: function () {
var vm = dbo.editUserModal;
if ( vm.formValid == false ) return;
var submitDATA = {
id : vm.id,
firstname : vm.firstname(),
middlename: vm.middlename(),
lastname : vm.lastname(),
username : vm.username(),
email : vm.email(),
role : vm.role()
}
dbo.userDataService.saveUser( submitDATA, function ( data ) {
if ( data.success ) {
tellMe( {
title : 'gebruiker aangemaakt',
message : 'gebuiker is succesvol opgeslagen',
modalClass: 'modal-success'
}, function(){
vm.hideUserModal();
if( typeof(vm.callback) == 'function') vm.callback();
} );
return;
}
var errorMessage = '<ul>';
$.each( data.messages, function ( i, p ) {
if ( p[0] ) {
errorMessage += '<li>' + i + ': ' + p[0] + '</li>';
}
} );
errorMessage += '</ul>';
tellMe( {
title : 'fout aanmaken gebruiker',
message : errorMessage,
modalClass: 'modal-danger'
} );
} );
},
setUser: function ( user ) {
var vm = dbo.editUserModal;
var role = isNaN( user.role ) ? null : user.role;
vm.id = user.id || 0;
vm.firstname( user.firstname || '' );
vm.lastname( user.lastname || '' );
vm.middlename( user.middlename || '' );
vm.username( user.username || '' );
vm.email( user.email || '' );
vm.role( user.role || null );
},
showUserModal: function () {
$( "#user-modal" ).modal( 'show' );
},
hideUserModal: function () {
$( "#user-modal" ).modal( 'hide' );
}
};
dbo.editUserModal.init();
dbo.editUserModal.lastnameInvalid = ko.pureComputed( function () {
if ( !this.lastname() ) return true;
if ( this.lastname().length < 2 ) return true;
return false;
}, dbo.editUserModal );
dbo.editUserModal.firstnameInvalid = ko.pureComputed( function () {
if ( !this.firstname() ) return true;
if ( this.firstname().length < 2 ) return true;
return false;
}, dbo.editUserModal );
dbo.editUserModal.usernameInvalid = ko.pureComputed( function () {
if ( !this.username() ) return true;
if ( this.username().length < 4 ) return true;
return false;
}, dbo.editUserModal );
dbo.editUserModal.emailInvalid = ko.pureComputed( function () {
if ( !this.email() ) return true;
return !dbo.helpers.validateEmail( this.email() );
}, dbo.editUserModal );
dbo.editUserModal.formValid = ko.pureComputed( function () {
if ( this.firstnameInvalid() ) return false;
if ( this.lastnameInvalid() ) return false;
if ( this.usernameInvalid() ) return false;
if ( this.emailInvalid() ) return false;
return true;
}, dbo.editUserModal )
ko.applyBindings( dbo.editUserModal, document.getElementById( 'user-modal' ) );
} );