|
|
|
@ -39,9 +39,12 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
|
|
|
|
|
})
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
app.controller('bdPrizeRootCtrl', ['$scope', '$http', '$uibModal', 'commonDialog', function ($scope, $http, $uibModal, commonDialog) {
|
|
|
|
|
app.controller('bdPrizeRootCtrl', ['$scope', '$http', '$uibModal', 'commonDialog','$filter', function ($scope, $http, $uibModal, commonDialog,$filter) {
|
|
|
|
|
$scope.params = {year: new Date().getFullYear()};
|
|
|
|
|
$scope.generate = {};
|
|
|
|
|
$scope.availableYears = [new Date().getFullYear() - 1, new Date().getFullYear()];
|
|
|
|
|
$scope.kpiRanges = [{value: 1, label: '0-50%'}, {value: 2, label: '50%~80%'}, {value: 3, label: '80%~100%'},
|
|
|
|
|
{value: 4, label: '100%-120%'}, {value: 5, label: '>=120%'}];
|
|
|
|
|
$scope.initMonth = function (year) {
|
|
|
|
|
$scope.params.year = year;
|
|
|
|
|
$scope.months = [];
|
|
|
|
@ -72,27 +75,37 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
|
|
|
|
|
};
|
|
|
|
|
$scope.getYearReports(new Date().getFullYear());
|
|
|
|
|
$scope.generateReport = function () {
|
|
|
|
|
if (!$scope.generate.month) {
|
|
|
|
|
commonDialog.alert({
|
|
|
|
|
type: 'error', title: 'Error', content: 'Select a month first!'
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
commonDialog.confirm({
|
|
|
|
|
title: 'Warning',
|
|
|
|
|
content: 'This operation will clear the result of last month generated before. Are you sure?'
|
|
|
|
|
}).then(function () {
|
|
|
|
|
$http.post('/sys/bd_prize/generate_record', null, {timeout: 60000}).then(function () {
|
|
|
|
|
$scope.generate.status = {};
|
|
|
|
|
var params = {month: $filter('date')($scope.generate.month, 'yyyy-MM')};
|
|
|
|
|
$http.post('/sys/bd_prize/generate_record/'+params.month, null, {timeout: 60000}).then(function (resp) {
|
|
|
|
|
$scope.generate.status = null;
|
|
|
|
|
commonDialog.alert({title: 'Success', content: 'Generate Finished', type: 'success'});
|
|
|
|
|
$scope.getYearReports($scope.params.year);
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'})
|
|
|
|
|
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
|
|
|
|
|
$scope.generate.status = null;
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
$scope.loadRateConfigs = function () {
|
|
|
|
|
$http.get('/sys/bd_prize/config/rates').then(function (resp) {
|
|
|
|
|
$scope.bd_rate_configs = resp.data;
|
|
|
|
|
$scope.bd_rate_ranges = [];
|
|
|
|
|
var rangeStart = [];
|
|
|
|
|
$scope.kpi_ranges = [];
|
|
|
|
|
var kpiStart = [];
|
|
|
|
|
angular.forEach($scope.bd_rate_configs, function (cfg) {
|
|
|
|
|
if (rangeStart.indexOf(cfg.rate_from) < 0) {
|
|
|
|
|
rangeStart.push(cfg.rate_from);
|
|
|
|
|
$scope.bd_rate_ranges.push(cfg);
|
|
|
|
|
if (kpiStart.indexOf(cfg.kpi_range) < 0) {
|
|
|
|
|
kpiStart.push(cfg.kpi_range);
|
|
|
|
|
$scope.kpi_ranges.push(cfg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
@ -136,7 +149,10 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
|
|
|
|
|
value: 3,
|
|
|
|
|
label: '>=7 Months'
|
|
|
|
|
}];
|
|
|
|
|
$scope.filter = {bd_level: 1, months: 1};
|
|
|
|
|
$scope.kpiRanges = [{value: 1, label: '0-50%'}, {value: 2, label: '50%~80%'}, {value: 3, label: '80%~100%'},
|
|
|
|
|
{value: 4, label: '100%-120%'}, {value: 5, label: '>=120%'}];
|
|
|
|
|
$scope.clientRate = [{value: 0.6, label: '0.6-0.79'}, {value: 0.8, label: '0.8-2.0'}];
|
|
|
|
|
$scope.filter = {bd_level: 1,rate_from:0.6};
|
|
|
|
|
$scope.rates = rates;
|
|
|
|
|
$scope.submitRates = function () {
|
|
|
|
|
var validation = null;
|
|
|
|
@ -191,7 +207,7 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
|
|
|
|
|
app.controller('bdCommissionConfigCtrl', ['$scope', '$state', '$http', '$filter', 'monModal', function ($scope, $state, $http, $filter, monModal) {
|
|
|
|
|
$scope.monModal = monModal;
|
|
|
|
|
$scope.params = {year: new Date().getFullYear()};
|
|
|
|
|
$scope.bdtypes = [{id: 1, label: 'Leader'}, {id: 2, label: 'Manager'}, {id: 3, label: 'Director'}];
|
|
|
|
|
$scope.bdtypes = [{id: 1, label: 'BD Manager'}, {id: 2, label: 'KA Manager'}, {id: 3, label: 'Sydney GM'},{id: 4, label: 'COO'},{id: 5, label: 'NJ Department'}];
|
|
|
|
|
// $scope.bdmon;
|
|
|
|
|
// $scope.newSwitch;
|
|
|
|
|
$scope.initMonth = function (year) {
|
|
|
|
@ -209,6 +225,34 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
|
|
|
|
|
var end = $filter('date')(new Date(), 'yyyy-MM');
|
|
|
|
|
return start <= mon && end >= mon
|
|
|
|
|
};
|
|
|
|
|
$scope.getBDLevels = function () {
|
|
|
|
|
$http.get('/sys/bd_prize/config/bd_levels').then(function (resp) {
|
|
|
|
|
$scope.bds = resp.data;
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
$scope.getBDLevels();
|
|
|
|
|
$scope.chooseLastConfig = function (mon) {
|
|
|
|
|
var index = $scope.months.indexOf(mon);
|
|
|
|
|
if(index == 0){
|
|
|
|
|
var year = new Date().getFullYear();
|
|
|
|
|
year--;
|
|
|
|
|
mon = year + '-12';
|
|
|
|
|
}else {
|
|
|
|
|
mon = $scope.months[index-1];
|
|
|
|
|
}
|
|
|
|
|
$http.get('/sys/bd_prize/commission/le_ma/' + mon).then(function (resp) {
|
|
|
|
|
$scope.bdlm = [];
|
|
|
|
|
angular.forEach(resp.data,function (e) {
|
|
|
|
|
var bdC = {};
|
|
|
|
|
bdC.commission_start_amount = e.commission_start_amount;
|
|
|
|
|
bdC.commission_end_amount = e.commission_end_amount;
|
|
|
|
|
bdC.bd_commission_rate = e.bd_commission_rate;
|
|
|
|
|
bdC.bd_type = e.bd_type;
|
|
|
|
|
$scope.bdlm.push(bdC);
|
|
|
|
|
});
|
|
|
|
|
$scope.listConfig = true;
|
|
|
|
|
})
|
|
|
|
|
};
|
|
|
|
|
$scope.listCurrentMonBDCommission = function (mon) {
|
|
|
|
|
$http.get('/sys/bd_prize/commission/le_ma/' + mon).then(function (resp) {
|
|
|
|
|
$scope.bdlm = resp.data;
|
|
|
|
@ -266,6 +310,24 @@ define(['angular', '../../analysis/bd/analysis-bd'], function (angular) {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$scope.submitBdCommmissionConfig = function (mon, bds) {
|
|
|
|
|
$scope.check = true;
|
|
|
|
|
$scope.errmsg = null;
|
|
|
|
|
angular.forEach(bds, function (data, index) {
|
|
|
|
|
if(data.get_prize){
|
|
|
|
|
if (!data.kpi_amount) {
|
|
|
|
|
$scope.errmsg = "BD kpi Amount not be null";
|
|
|
|
|
$scope.check = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if ($scope.check) {
|
|
|
|
|
$http.post('/sys/bd_prize/commission/kpi/update/' + mon, bds).then(function (resp) {
|
|
|
|
|
$scope.$close();
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}]);
|
|
|
|
|
app.controller('bdPrizeMonthReportCtrl', ['$scope', '$http', 'report', function ($scope, $http, report) {
|
|
|
|
|
$scope.report = report.data;
|
|
|
|
|