Customers
This commit is contained in:
@@ -11,6 +11,15 @@
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.site-menu-sub > li{
|
||||
margin-left:30px;
|
||||
padding-left:10px;
|
||||
}
|
||||
.site-menu-sub > li :hover{
|
||||
background-color:#463238;
|
||||
color:gold;
|
||||
}
|
||||
|
||||
/*********TABLES************/
|
||||
|
||||
.table-blueish-header{
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
* Time: 14:19
|
||||
*/
|
||||
|
||||
dbo.customersInit = function (){
|
||||
dbo.customersInit = function () {
|
||||
|
||||
if ( dbo.customersModel !== undefined ) {
|
||||
|
||||
} else {
|
||||
dbo.customersModel = {
|
||||
|
||||
customers : ko.observableArray( [] ),
|
||||
customer : ko.observable(),
|
||||
archive: ko.observable( true ),
|
||||
customers: ko.observableArray( [] ),
|
||||
customer : ko.observable(),
|
||||
archive : ko.observable( false ),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.customersModel;
|
||||
@@ -24,9 +24,8 @@ dbo.customersInit = function (){
|
||||
|
||||
newCustomer: function () {
|
||||
var vm = dbo.customersModel;
|
||||
|
||||
dbo.editCostomerModal.newEditCostumer( false, function () {
|
||||
vm.refreshCostumers();
|
||||
dbo.editCustomerModal.newEditCustomer( false, function () {
|
||||
vm.refreshCustomers();
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -35,15 +34,15 @@ dbo.customersInit = function (){
|
||||
|
||||
vm.archive( !vm.archive() );
|
||||
|
||||
vm.refreshCostumers();
|
||||
vm.refreshCustomers();
|
||||
},
|
||||
|
||||
editCostumer: function () {
|
||||
editCustomer: function () {
|
||||
var customer = this;
|
||||
var vm = dbo.customersModel;
|
||||
|
||||
dbo.editCostumerModal.newEditCostumer( customer, function () {
|
||||
vm.refreshCostumers();
|
||||
dbo.editCustomerModal.newEditCustomer( customer, function () {
|
||||
vm.refreshCustomers();
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -53,12 +52,12 @@ dbo.customersInit = function (){
|
||||
|
||||
var status = self.archive == 'F' ? 'T' : 'F';
|
||||
|
||||
dbo.customerDataService.archiveCostumer( self.id, status, function () {
|
||||
vm.refreshCostumers();
|
||||
dbo.customerDataService.archiveCustomer( self.id, status, function () {
|
||||
vm.refreshCustomers();
|
||||
} );
|
||||
},
|
||||
|
||||
removeCostumer: function () {
|
||||
removeCustomer: function () {
|
||||
var vm = dbo.customersModel;
|
||||
var self = this;
|
||||
|
||||
@@ -72,14 +71,14 @@ dbo.customersInit = function (){
|
||||
}, function ( response ) {
|
||||
console.log( response );
|
||||
if ( response ) {
|
||||
dbo.customerDataService.removeUser( self.id, function ( data ) {
|
||||
dbo.customerDataService.removeCustomer( self.id, function ( data ) {
|
||||
if ( data.result ) {
|
||||
tellMe( {
|
||||
title : 'opdrachtgever verwijderd',
|
||||
message : 'de opdrachtgever is succesvol verwijderd',
|
||||
modalClass: 'modal-success'
|
||||
}, function () {
|
||||
vm.refreshCostumers();
|
||||
vm.refreshCustomers();
|
||||
} );
|
||||
} else {
|
||||
tellMe( {
|
||||
|
||||
@@ -16,7 +16,7 @@ dbo.usersInit = function () {
|
||||
users : ko.observableArray( [] ),
|
||||
user : ko.observable(),
|
||||
roles : ko.observableArray( [] ),
|
||||
archive: ko.observable( true ),
|
||||
archive: ko.observable( false ),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.usersModel;
|
||||
|
||||
@@ -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;
|
||||
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' ) );
|
||||
|
||||
} );
|
||||
Reference in New Issue
Block a user