2018-05-23 12:26:51 +00:00
|
|
|
import ngModule from '../../module';
|
2018-03-14 10:36:57 +00:00
|
|
|
|
|
|
|
class Controller {
|
2018-03-28 13:07:48 +00:00
|
|
|
constructor($http, $filter, $state, $scope, $translate, vnApp) {
|
|
|
|
this.$http = $http;
|
|
|
|
this.$state = $state;
|
|
|
|
this.$scope = $scope;
|
|
|
|
this.$translate = $translate;
|
|
|
|
this.vnApp = vnApp;
|
2018-03-14 10:36:57 +00:00
|
|
|
this.creditClassification = {
|
|
|
|
started: $filter('date')(new Date(), 'yyyy-MM-dd HH:mm')
|
|
|
|
};
|
2018-03-28 13:07:48 +00:00
|
|
|
}
|
|
|
|
|
2018-08-09 10:54:29 +00:00
|
|
|
onSubmit() {
|
2018-03-28 13:07:48 +00:00
|
|
|
if (this.$scope.form.$invalid)
|
2018-07-09 11:01:46 +00:00
|
|
|
return this.vnApp.showError(this.$translate.instant('Some fields are invalid'));
|
2018-03-28 13:07:48 +00:00
|
|
|
|
|
|
|
let query = `/client/api/creditClassifications/createWithInsurance`;
|
|
|
|
let data = this.creditClassification;
|
|
|
|
data.clientFk = this.client.id;
|
|
|
|
|
2018-07-10 06:23:32 +00:00
|
|
|
this.$http.post(query, data).then(res => {
|
|
|
|
if (res.data) {
|
|
|
|
this.card.reload();
|
2018-05-23 12:26:51 +00:00
|
|
|
this.$state.go('client.card.creditInsurance.index');
|
2018-07-10 06:23:32 +00:00
|
|
|
}
|
2018-03-28 13:07:48 +00:00
|
|
|
});
|
2018-03-14 10:36:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-28 13:07:48 +00:00
|
|
|
Controller.$inject = ['$http', '$filter', '$state', '$scope', '$translate', 'vnApp'];
|
2018-03-14 10:36:57 +00:00
|
|
|
|
2018-05-23 12:26:51 +00:00
|
|
|
ngModule.component('vnClientCreditInsuranceCreate', {
|
|
|
|
template: require('./index.html'),
|
2018-03-14 10:36:57 +00:00
|
|
|
controller: Controller,
|
2018-07-10 06:23:32 +00:00
|
|
|
require: {
|
|
|
|
card: '^vnClientCard'
|
|
|
|
},
|
2018-03-14 10:36:57 +00:00
|
|
|
bindings: {
|
|
|
|
client: '<'
|
|
|
|
}
|
|
|
|
});
|