diversen
This commit is contained in:
@@ -13,12 +13,15 @@ $( function () {
|
||||
projectEmployees: ko.observableArray( [] ),
|
||||
customers : ko.observableArray( [] ),
|
||||
users : ko.observableArray( [] ),
|
||||
payments : 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,
|
||||
@@ -36,11 +39,31 @@ $( function () {
|
||||
vm.customers( data );
|
||||
dbo.userDataService.getAllUsers( 'F', function ( data ) {
|
||||
vm.users( data );
|
||||
vm.refreshProject();
|
||||
dbo.externalDataService.getAllExternals( 'F', function ( data ) {
|
||||
dbo.vatDataService.getVats( 'F', function ( data ) {
|
||||
vm.vats( data )
|
||||
vm.refreshProject();
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
},
|
||||
|
||||
togglePayments: function () {
|
||||
this.showPayment( !this.showPayment() );
|
||||
|
||||
var showPayments = sessionStorage.showPayments || [];
|
||||
|
||||
if ( this.showPayment() ) {
|
||||
showPayments.push( this.id );
|
||||
} else {
|
||||
var index = showPayments.indexOf( this.id );
|
||||
showPayments.splice( index, 1 );
|
||||
}
|
||||
|
||||
sessionStorage.setItem( "showPayment", showPayments );
|
||||
},
|
||||
|
||||
editProjectemployee: function () {
|
||||
var self = this;
|
||||
var vm = dbo.editProjectModal;
|
||||
@@ -85,6 +108,25 @@ $( function () {
|
||||
service.newOffer( vm.projectID, vm.customerID() );
|
||||
},
|
||||
|
||||
newInvoice: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
|
||||
var invoice = {
|
||||
id : 0,
|
||||
project_id : vm.projectID,
|
||||
invoicenumber : '',
|
||||
invoicedate : null,
|
||||
invoiceamount : 0,
|
||||
forecastamount: 0,
|
||||
forecastdate : null,
|
||||
inEdit : true,
|
||||
showPayments : false,
|
||||
payments : []
|
||||
}
|
||||
|
||||
vm.invoices.push( new vm.Invoice( invoice ) );
|
||||
},
|
||||
|
||||
newPayment: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
|
||||
@@ -113,6 +155,21 @@ $( function () {
|
||||
vm.projecthours.push( new vm.Projecthour( projecthour ) );
|
||||
},
|
||||
|
||||
newProjectcost: function () {
|
||||
var vm = dbo.editProjectModal;
|
||||
|
||||
var projectcost = {
|
||||
id : 0,
|
||||
external_id: null,
|
||||
description: '',
|
||||
date : null,
|
||||
costs : 0,
|
||||
inEdit : true
|
||||
};
|
||||
|
||||
vm.projectcosts.push( new vm.Projectcost( projectcost ) );
|
||||
},
|
||||
|
||||
editOffer: function () {
|
||||
var service = dbo.offersService;
|
||||
service.vm = dbo.editProjectModal;
|
||||
@@ -406,14 +463,19 @@ $( function () {
|
||||
} );
|
||||
} );
|
||||
|
||||
vm.projectcosts.removeAll();
|
||||
$.each( data.projectcosts, function ( i, p ) {
|
||||
vm.projectcosts.push( new vm.Projectcost( p ) );
|
||||
} );
|
||||
|
||||
vm.offers.removeAll();
|
||||
vm.payments.removeAll();
|
||||
$.each( data.offers, function ( i, p ) {
|
||||
vm.offers.push( new dbo.offersService.Offer( p ) );
|
||||
} );
|
||||
|
||||
$.each( p.payments, function ( z, q ) {
|
||||
vm.payments.push( new vm.Payment( q, p ) );
|
||||
} );
|
||||
vm.invoices.removeAll();
|
||||
$.each( data.invoices, function ( i, p ) {
|
||||
vm.invoices.push( new vm.Invoice( p ) );
|
||||
} );
|
||||
|
||||
vm.busy = false;
|
||||
@@ -432,18 +494,6 @@ $( function () {
|
||||
self.inEdit = ko.observable( sessionStorage.editEmployee == data.id );
|
||||
},
|
||||
|
||||
Payment: function ( data, offer = false ) {
|
||||
var inEdit = sessionStorage.editPayment == data.id;
|
||||
if ( !inEdit ) inEdit = data.inEdit || false;
|
||||
|
||||
this.id = data.id;
|
||||
this.offer_id = ko.observable( data.offer_id );
|
||||
this.offernumber = ko.observable( offer ? offer.offernumber : null );
|
||||
this.paymentdate = ko.observable( dbo.helpers.mysql2date( data.paymentdate ) );
|
||||
this.paymentamount = ko.observable( data.paymentamount );
|
||||
this.inEdit = ko.observable( inEdit );
|
||||
},
|
||||
|
||||
Projecthour: function ( data, fullname ) {
|
||||
var inEdit = sessionStorage.editPayment == data.id;
|
||||
if ( !inEdit ) inEdit = data.inEdit || false;
|
||||
@@ -454,6 +504,58 @@ $( function () {
|
||||
this.hourdate = ko.observable( dbo.helpers.mysql2date( data.hourdate ) );
|
||||
this.hours = ko.observable( data.hours );
|
||||
this.inEdit = ko.observable( inEdit );
|
||||
},
|
||||
|
||||
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 );
|
||||
},
|
||||
|
||||
Invoice: function ( data ) {
|
||||
var vm = dbo.editProjectModal;
|
||||
var self = this;
|
||||
var inEdit = sessionStorage.editInvoice == data.id;
|
||||
if ( !inEdit ) inEdit = data.inEdit || false;
|
||||
|
||||
self.id = data.id;
|
||||
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.forecastdate = ko.observable( dbo.helpers.mysql2date( data.forecastdate ) );
|
||||
self.vat_id = ko.observable( data.vat_id );
|
||||
|
||||
self.inEdit = ko.observable( inEdit );
|
||||
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)
|
||||
|
||||
self.payments = ko.observableArray( [] );
|
||||
$.each( data.payments, function ( i, p ) {
|
||||
self.payments.push( new vm.Payment( p, self.invoicenumber ) );
|
||||
} );
|
||||
},
|
||||
|
||||
Payment: function ( data, invoicenumber = '' ) {
|
||||
var inEdit = sessionStorage.editPayment == data.id;
|
||||
if ( !inEdit ) inEdit = data.inEdit || false;
|
||||
|
||||
this.id = data.id;
|
||||
this.invoicenumber = ko.observable( invoicenumber );
|
||||
this.paymentdate = ko.observable( dbo.helpers.mysql2date( data.paymentdate ) );
|
||||
this.paymentamount = ko.observable( data.paymentamount );
|
||||
this.inEdit = ko.observable( inEdit );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user