diversen opmerkingen

This commit is contained in:
2018-07-29 10:11:02 +02:00
parent cecbfd83fb
commit 30535f7048
34 changed files with 11883 additions and 82 deletions
@@ -9,6 +9,7 @@ dbo.authorisationInit = function () {
if ( dbo.authorisationModel !== undefined ) {
dbo.authorisationModel.refreshPageAuthorisations();
} else {
dbo.authorisationModel = {
@@ -22,10 +23,53 @@ dbo.authorisationInit = function () {
},
refreshPageAuthorisations: function () {
var vm = dbo.authorisationModel;
vm.initPages = true;
vm.roles.removeAll();
dbo.authorisationDataService.getRoleAuthorisations( function ( data ) {
console.log( data );
_.each( data, function ( p ) {
vm.roles.push( new vm.Role( p ) );
} )
} );
},
Role: function ( data ) {
var vm = dbo.authorisationModel;
var self = this;
self.roleID = data.id;
self.rolename = data.rolename;
self.pages = ko.observableArray( [] );
_.each( data.pagesAccess, function ( p ) {
self.pages.push( new vm.Page( p, self.pages() ) );
} );
vm.initPages = false;
},
Page: function ( data, pages ) {
var vm = dbo.authorisationModel;
var self = this;
if ( vm.initPages ) {
self.pageID = data.id;
self.pagename = data.pagename;
self.typePage = data.typepage;
self.pageAccess = ko.observableArray( [] );
self.pageAccess.push( {access: ko.observable( data.pageaccess == 'T' ? true : false )} );
}else{
_.each(pages, function(p){
console.log( pages );
console.log( data.id, '- -', p.pageID );
if( data.id == p.pageID) {
p.pageAccess.push( {access: ko.observable( data.pageaccess == 'T' ? true : false )} );
}
})
}
}
};
@@ -0,0 +1,105 @@
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 15/07/2018
* Time: 10:50
*/
dbo.authorisationInit = function() {
new Vue( {
el : "#AUTHORISATION",
data : {
roles: [],
pages: []
},
created: function () {
var self = this;
var srv = dbo.autorisationService;
srv.createRoles( function ( data ) {
console.log( data.pages );
self.roles = data.roles;
self.pages = data.pages;
} );
},
methods: {
toggleAccess: function ( pageIndex, roleIndex ) {
var page = this.pages[pageIndex];
var access = page.accessPages[roleIndex];
page.accessPages[roleIndex].access = !page.accessPages[roleIndex].access;
var submitDATA = {
pageID : page.pageID,
roleLevel: access.roleLevel,
access : page.accessPages[roleIndex].access ? 'T' : 'F'
}
dbo.authorisationDataService.toggleAuhorisation( submitDATA );
}
}
} );
};
dbo.autorisationService = {
roles : [],
pages : [],
initPages: true,
createRoles: function ( callback ) {
var srv = dbo.autorisationService;
dbo.authorisationDataService.getRoleAuthorisations( function ( data ) {
_.each( data, function ( p ) {
srv.roles.push( new srv.Role( p ) );
} );
_.each( data, function ( p ) {
_.each( p.pagesAccess, function ( q ) {
if ( srv.initPages ) {
srv.pages.push( new srv.Page( q ) );
} else {
_.each( srv.pages, function ( s ) {
if ( s.pageID == q.id ) {
s.accessPages.push( new srv.Access( q ) )
}
} );
}
} );
srv.initPages = false;
} );
} );
callback( srv );
},
Role: function ( data ) {
this.roleID = data.id;
this.rolename = data.rolename;
},
Page: function ( data ) {
var srv = dbo.autorisationService;
if ( srv.initPages ) {
this.pageID = data.id;
this.pagename = data.pagename;
this.typePage = data.typepage;
this.accessPages = [];
this.accessPages.push( new srv.Access( data ) );
}
},
Access: function ( data ) {
this.access = data.pageaccess == 'T' ? true : false;
this.roleLevel = data.rolelevel;
}
}
+81 -3
View File
@@ -10,11 +10,22 @@ $( function () {
dbo.loginModel = {
username: ko.observable( '' ),
password: ko.observable( '' ),
username : ko.observable( '' ),
password : ko.observable( '' ),
email : ko.observable(),
showPasswordRequest: ko.observable( false ),
login: function () {
dbo.loginService.login();
},
requestPassword: function () {
dbo.loginService.requestPassword();
},
togglePasswordrequest: function () {
var vm = dbo.loginModel
vm.showPasswordRequest( !vm.showPasswordRequest() );
}
}
@@ -37,7 +48,22 @@ dbo.loginService = {
self.notifyWrongPassword();
} );
} );
},
requestPassword: function () {
var ds = dbo.loginDataservice;
var self = dbo.loginService;
var vm = dbo.loginModel;
self.validateRequestInput( function ( submitDATA ) {
if ( !submitDATA ) return self.notifyWrongRequest();
ds.requestPassword( submitDATA, function ( data ) {
return self.notifyWrongRequest( data.result );
if ( data.result == 'SEND-SUCCESS' ) vm.showPasswordRequest( false );
} );
} );
},
validateInput: function ( callback ) {
@@ -48,7 +74,21 @@ dbo.loginService = {
var submitDATA = {
username: vm.username(),
password: vm.password
password: vm.password()
}
return callback( submitDATA );
},
validateRequestInput: function ( callback ) {
var vm = dbo.loginModel;
if ( vm.username().length < 2 ) return callback( false );
if ( !dbo.helpers.validateEmail( vm.email() ) ) return callback( false );
var submitDATA = {
username: vm.username(),
email : vm.email()
}
return callback( submitDATA );
@@ -59,6 +99,38 @@ dbo.loginService = {
title : 'Login fout',
message: 'Gebruikersnaam / wachtwoord komen niet overeen'
} );
},
notifyWrongRequest: function ( type = false ) {
var message = '';
var title = '';
var modalClass = '';
console.log( type );
if ( !type || type == 'WRONG-CREDENTIAL' ) {
title = 'credentials fout';
message = 'Fout bij gebruikersnaam / emailadres invoer';
modalClass = 'modal-danger';
}
else if ( type == 'SEND-FAILLURE' ) {
title = 'Fout bij verzneden email';
message = 'email kon niet verzonden worden neem contact op met de helpdesk';
modalClass = 'modal-danger';
}
else if ( type == 'SEND-SUCCESS' ) {
title = 'mail succesvol verzonden';
message = ' er is een email verzonden, kijk in uw postvak, mocht u de mail daar niet aantreffen kijk dan in uw spanfolder';
modalClass = 'modal-succes';
}else{
title = 'Fout bij verzneden email';
message = ' er is een onbekende fout opgetreden neem contact op met de helpdesk';
modalClass = 'modal-danger';
}
tellMe( {
title : title,
message : message,
modalClass: modalClass
} );
}
};
@@ -69,6 +141,12 @@ dbo.loginDataservice = {
$.post( 'index.php/login/', submitDATA, function ( data ) {
callback( data );
} );
},
requestPassword: function ( submitDATA, callback ) {
$.post( 'index.php/login/requestPassword', submitDATA, function ( data ) {
callback( data );
} );
}
};
+1
View File
@@ -48,6 +48,7 @@ $( function () {
vm[page]( true );
var func = page.toLowerCase() + 'Init';
window.dbo[func]();
},
@@ -126,7 +126,9 @@ dbo.employeehoursreportInit = function () {
vm.occupancyRateTotalTotaal( Math.round( (vm.totalhoursTotaal() / vm.targetTotaal()) * 1000 ) / 10 );
vm.occupancyRateHoursTotaal( Math.round( (vm.profitablehoursTotaal() / vm.totalhoursTotaal()) * 1000 ) / 10 );
vm.occupancyRateInvoiceTotaal( Math.round( (vm.profitablehoursTotaal() / vm.targetTotaal()) * 1000 ) / 10 );
vm.averageDayRateTotaal( Math.round( Number( vm.revenuesTotaal() ) / Number( vm.profitablehoursTotaal() ) ) * 8 );
console.log( Number( vm.revenuesTotaal() ) );
console.log( Number( vm.profitablehoursTotaal() ) );
vm.averageDayRateTotaal( Math.round( (Number( vm.revenuesTotaal() ) / Number( vm.profitablehoursTotaal()) * 8 ) ) );
vm.revenuesTotaal( dbo.helpers.thousandSeparator( vm.revenuesTotaal() ) );
// dbo.charts.drawPie( 'revenues-per-month', chartData.revenues, chartData.labels, 'omzet per medewerker' );
@@ -64,8 +64,6 @@ dbo.monthlyemployeehoursInit = function () {
vm.totalEmployeeHours( 0 );
vm.totalEmployeeAvailableHours( 0 );
vm.totalOwp( 0 );
vm.totalCurrentFinancialYear( 0 );
vm.totalNextFinancialYear( 0 );
vm.totalPerEmployee.removeAll();
vm.totalInvoicedYear.removeAll();
dbo.userDataService.getUniqueProjectEmployees( function ( data ) {
@@ -9,6 +9,8 @@ dbo.reservationsInit = function () {
if ( dbo.reservationsModel !== undefined ) {
dbo.reservationsModel.refreshReservations();
} else {
dbo.reservationsModel = {