2017-06-03 11:01:47 +00:00
|
|
|
import ngModule from '../module';
|
2017-01-31 13:13:06 +00:00
|
|
|
|
2018-05-23 12:26:51 +00:00
|
|
|
class Controller {
|
2018-07-18 10:21:08 +00:00
|
|
|
constructor($http, $state) {
|
|
|
|
this.$state = $state;
|
2018-03-09 15:44:18 +00:00
|
|
|
this.$http = $http;
|
|
|
|
}
|
|
|
|
_getClientDebt(clientFk) {
|
|
|
|
this.$http.get(`/client/api/Clients/${clientFk}/getDebt`)
|
|
|
|
.then(response => {
|
|
|
|
this.clientDebt = response.data.debt;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_getClient(clientFk) {
|
|
|
|
this.$http.get(`/client/api/Clients/${clientFk}/card`)
|
|
|
|
.then(response => {
|
|
|
|
Object.assign(this.client, response.data);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-07-18 10:21:08 +00:00
|
|
|
goToClientTickets() {
|
|
|
|
this.$state.go('ticket.index', {q: `{"clientFk": ${this.client.id}}`});
|
|
|
|
}
|
|
|
|
|
2018-03-09 15:44:18 +00:00
|
|
|
$onChanges(changes) {
|
|
|
|
if (changes.client && this.client) {
|
|
|
|
this._getClient(this.client.id);
|
|
|
|
this._getClientDebt(this.client.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-05-31 06:57:25 +00:00
|
|
|
|
2018-07-18 10:21:08 +00:00
|
|
|
Controller.$inject = ['$http', '$state'];
|
2018-03-09 15:44:18 +00:00
|
|
|
|
2018-02-12 12:16:49 +00:00
|
|
|
ngModule.component('vnClientDescriptor', {
|
2018-05-23 12:26:51 +00:00
|
|
|
template: require('./index.html'),
|
2017-01-31 13:13:06 +00:00
|
|
|
bindings: {
|
2018-02-12 12:16:49 +00:00
|
|
|
client: '<'
|
2018-03-09 15:44:18 +00:00
|
|
|
},
|
2018-05-23 12:26:51 +00:00
|
|
|
controller: Controller
|
2017-06-03 11:01:47 +00:00
|
|
|
});
|