(function () { 'use strict'; angular .module('app') .controller('MarketCtrl', MarketCtrl); MarketCtrl.$inject = ['$scope', 'smartRequest', '$location', 'Notification']; function MarketCtrl($scope, smartRequest, $location, Notification) { $scope.key = ''; $scope.getListModules = function () { smartRequest.get('settings/pay/modules', function (data) { $scope.modules = data.modules; }); }; $scope.showModuleActivate = function (id) { $scope.selectedModule = $scope.getModulerById(id); $('#activate-module').modal(); }; $scope.activateModule = function () { $('#btn-activated').prop('disabled', false); smartRequest.post('settings/activate/module', { key: $scope.key, module: $scope.selectedModule.name, }, function(data) { if (data.message == 'Активация прошла успешно') { Notification.success(data.message); $location.path('/'); } else { Notification.error(data.message); } }); }; $scope.getModulerById = function(id) { var res; $scope.modules.forEach(function (item) { if (item.id == id) { res = item; return; } }); return res; }; $scope.getListModules(); } })();