2018-05-23 12:26:51 +00:00
|
|
|
import ngModule from '../../module';
|
2017-12-04 07:17:29 +00:00
|
|
|
|
2018-05-11 09:16:16 +00:00
|
|
|
class Controller {
|
|
|
|
constructor($http, $scope, $state) {
|
|
|
|
this.$http = $http;
|
|
|
|
this.$scope = $scope;
|
|
|
|
this.$state = $state;
|
|
|
|
}
|
|
|
|
|
|
|
|
onSubmit() {
|
2019-10-24 22:53:53 +00:00
|
|
|
this.$http.get(`Recoveries/${this.$state.params.id}/hasActiveRecovery`).then(res => {
|
2018-05-11 09:16:16 +00:00
|
|
|
let activeRecovery = res.data;
|
|
|
|
if (activeRecovery)
|
|
|
|
this.$scope.confirmation.show();
|
|
|
|
else
|
|
|
|
this.addCredit();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-10-17 07:28:38 +00:00
|
|
|
cancel() {
|
2018-07-25 11:37:27 +00:00
|
|
|
this.goToIndex();
|
|
|
|
}
|
|
|
|
|
2018-05-11 09:16:16 +00:00
|
|
|
returnDialog(response) {
|
2019-10-30 15:57:14 +00:00
|
|
|
if (response === 'accept')
|
2018-05-21 09:59:23 +00:00
|
|
|
this.addCredit();
|
2018-05-11 09:16:16 +00:00
|
|
|
}
|
|
|
|
|
2018-07-25 11:37:27 +00:00
|
|
|
goToIndex() {
|
|
|
|
this.$state.go('client.card.credit.index');
|
|
|
|
}
|
|
|
|
|
2018-05-11 09:16:16 +00:00
|
|
|
addCredit() {
|
|
|
|
this.$scope.watcher.submit().then(
|
|
|
|
() => {
|
2018-07-25 11:37:27 +00:00
|
|
|
this.goToIndex();
|
2018-05-11 09:16:16 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Controller.$inject = ['$http', '$scope', '$state'];
|
|
|
|
|
2017-12-04 07:17:29 +00:00
|
|
|
ngModule.component('vnClientCreditCreate', {
|
2018-05-23 12:26:51 +00:00
|
|
|
template: require('./index.html'),
|
2018-05-11 09:16:16 +00:00
|
|
|
controller: Controller,
|
2017-12-04 07:17:29 +00:00
|
|
|
bindings: {
|
|
|
|
client: '<'
|
|
|
|
}
|
|
|
|
});
|