Initial commit: apps.supersamsev.ru
This commit is contained in:
commit
54475e7d3d
17284 files changed
+98268
No files matched your search
@@ -0,0 +1,139 @@
|
||||
supersamApp.controller('FasadStatisticsController', [
|
||||
'$scope',
|
||||
'$http',
|
||||
'$timeout',
|
||||
'config',
|
||||
'$filter',
|
||||
function($scope,
|
||||
$http,
|
||||
$timeout,
|
||||
config,
|
||||
$filter) {
|
||||
var fasadStatistics;
|
||||
fasadStatistics = (function() {
|
||||
class fasadStatistics {
|
||||
constructor() {
|
||||
var i, len, ref, sheet;
|
||||
this.getStatisticsData = this.getStatisticsData.bind(this);
|
||||
this.getBorderDimensionLabel = this.getBorderDimensionLabel.bind(this);
|
||||
$scope.utilities.showContentOnLoad();
|
||||
config.sortFields = {
|
||||
statistics_sheets: {
|
||||
field: 'label',
|
||||
direction: 'asc'
|
||||
},
|
||||
statistics_borders: {
|
||||
field: 'label',
|
||||
direction: 'asc'
|
||||
},
|
||||
statistics_clients: {
|
||||
field: 'name',
|
||||
direction: 'asc'
|
||||
}
|
||||
};
|
||||
ref = config.sheets;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
sheet = ref[i];
|
||||
if (config.statistics.data[sheet.id] && config.statistics.data[sheet.id].total_decimal) {
|
||||
sheet.total_decimal = angular.copy(config.statistics.data[sheet.id].total_decimal);
|
||||
} else {
|
||||
sheet.total_decimal = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getStatisticsData() {
|
||||
var dataToSend;
|
||||
if (!this.isLoading) {
|
||||
this.isLoading = true;
|
||||
dataToSend = {
|
||||
year: config.statistics.year,
|
||||
select: config.statistics.select,
|
||||
showEmptyRows: this.showEmptyRows
|
||||
};
|
||||
return $http({
|
||||
method: 'POST',
|
||||
url: config.urls.fasadGetStatisticsData,
|
||||
data: dataToSend,
|
||||
timeout: 30000
|
||||
}).then((response) => {
|
||||
var border, data, i, j, len, len1, ref, ref1, results, sheet;
|
||||
this.isLoading = false;
|
||||
if (response.data) {
|
||||
data = response.data;
|
||||
if (data.status && (data.status === "success")) {
|
||||
config.statistics = data.statistics;
|
||||
if (config.statistics.select === 'sheets') {
|
||||
ref = config.sheets;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
sheet = ref[i];
|
||||
if (config.statistics.data[sheet.id] && config.statistics.data[sheet.id].total_decimal) {
|
||||
sheet.total_decimal = angular.copy(config.statistics.data[sheet.id].total_decimal);
|
||||
} else {
|
||||
sheet.total_decimal = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (config.statistics.select === 'borders') {
|
||||
ref1 = config.borders;
|
||||
results = [];
|
||||
for (j = 0, len1 = ref1.length; j < len1; j++) {
|
||||
border = ref1[j];
|
||||
if (config.statistics.data[border.id] && config.statistics.data[border.id].total_decimal) {
|
||||
results.push(border.total_decimal = angular.copy(config.statistics.data[border.id].total_decimal));
|
||||
} else {
|
||||
results.push(border.total_decimal = 0);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
} else {
|
||||
config.statistics.data = false;
|
||||
if (data.warning) {
|
||||
toastr.warning(data.warning);
|
||||
}
|
||||
if (data.error) {
|
||||
return toastr.warning(data.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).catch(() => {
|
||||
config.statistics.data = false;
|
||||
this.isLoading = false;
|
||||
return toastr.error(config.global_labels.defaultErrorMessage.value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
getBorderDimensionLabel(heightId) {
|
||||
var i, label, len, ref, selectedHeight, v;
|
||||
label = "";
|
||||
ref = config.borderDimensions;
|
||||
for (i = 0, len = ref.length; i < len; i++) {
|
||||
v = ref[i];
|
||||
if (v.id === heightId) {
|
||||
selectedHeight = v;
|
||||
}
|
||||
}
|
||||
if (selectedHeight) {
|
||||
label = selectedHeight.label;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
fasadStatistics.prototype.isLoading = false;
|
||||
|
||||
fasadStatistics.prototype.showEmptyRows = true;
|
||||
|
||||
return fasadStatistics;
|
||||
|
||||
}).call(this);
|
||||
$scope.config = config;
|
||||
$scope.utilities = new UtilitiesClass(config,
|
||||
$filter,
|
||||
$timeout);
|
||||
return $scope.statistics = new fasadStatistics();
|
||||
}
|
||||
]);
|
||||
Reference in new issue
Block a user