1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-10 06:08:34 +02:00
bitwarden-browser/src/app/organization/organizationBillingController.js

81 lines
3.1 KiB
JavaScript
Raw Normal View History

2017-04-06 19:13:54 +02:00
angular
.module('bit.organization')
2017-04-08 22:42:05 +02:00
.controller('organizationBillingController', function ($scope, apiService, $state, $uibModal) {
2017-04-06 22:52:25 +02:00
$scope.charges = [];
$scope.paymentSource = null;
$scope.plan = null;
$scope.subscription = null;
$scope.loading = true;
2017-04-06 19:13:54 +02:00
2017-04-06 22:52:25 +02:00
$scope.$on('$viewContentLoaded', function () {
apiService.organizations.getBilling({ id: $state.params.orgId }, function (org) {
$scope.loading = false;
$scope.plan = {
name: org.Plan,
type: org.PlanType,
2017-04-10 16:43:18 +02:00
seats: org.Seats
2017-04-06 22:52:25 +02:00
};
$scope.subscription = {
trialEndDate: org.Subscription.TrialEndDate,
nextBillDate: org.Subscription.NextBillDate,
cancelNext: org.Subscription.CancelAtNextBillDate,
status: org.Subscription.Status
};
if (org.Subscription.Items) {
$scope.subscription.items = [];
for (var i = 0; i < org.Subscription.Items.length; i++) {
$scope.subscription.items.push({
amount: org.Subscription.Items[i].Amount,
name: org.Subscription.Items[i].Name,
interval: org.Subscription.Items[i].Interval,
qty: org.Subscription.Items[i].Quantity
});
}
}
if (org.PaymentSource) {
$scope.paymentSource = {
type: org.PaymentSource.Type,
description: org.PaymentSource.Description,
cardBrand: org.PaymentSource.CardBrand
};
}
var charges = [];
for (var i = 0; i < org.Charges.length; i++) {
charges.push({
date: org.Charges[i].CreatedDate,
paymentSource: org.Charges[i].PaymentSource ? org.Charges[i].PaymentSource.Description : '-',
amount: org.Charges[i].Amount,
status: org.Charges[i].Status,
failureMessage: org.Charges[i].FailureMessage,
refunded: org.Charges[i].Refunded,
partiallyRefunded: org.Charges[i].PartiallyRefunded,
refundedAmount: org.Charges[i].RefundedAmount
});
}
$scope.charges = charges;
});
});
$scope.changePayment = function () {
2017-04-08 22:42:05 +02:00
var modal = $uibModal.open({
animation: true,
templateUrl: 'app/organization/views/organizationBillingChangePayment.html',
controller: 'organizationBillingChangePaymentController'
});
2017-04-06 22:52:25 +02:00
2017-04-08 22:42:05 +02:00
modal.result.then(function () {
// TODO: reload
});
2017-04-06 22:52:25 +02:00
};
$scope.cancel = function () {
};
2017-04-06 19:13:54 +02:00
});