-Force update button on dashboard
This commit is contained in:
miroman-afk
2022-01-29 02:42:54 +03:00
parent da51b6ca63
commit 70f5640505
5 changed files with 183 additions and 26 deletions

View File

@@ -277,6 +277,179 @@
});
};
$scope.updateData = function () {
smartRequest.get('dashboard/online/updatetime', function (data) {
$scope.update_time = data.updated;
});
smartRequest.get('dashboard/online/updatetime', function (data) {
$scope.update_time = data.updated;
});
smartRequest.get('dashboard/online/info', function (data) {
$scope.shiftInfo = data;
});
smartRequest.get('dashboard/online/payments', function (data) {
$scope.payments.labels = data.payments.map(payment => payment.name);
$scope.payments.data = data.payments.map(payment => payment.value);
});
smartRequest.get('dashboard/online/orders', function (data) {
var total = data.wait_count + data.closed_count + data.deleted_count + data.returned_count;
$scope.orders_closed.percent = $scope.calcPercentageForGroupOrders(total, data.closed_count);
$scope.orders_closed.total = data.closed_count;
$scope.orders_closed.sum = data.closed_sum;
$scope.orders_waited.percent = $scope.calcPercentageForGroupOrders(total, data.wait_count);
$scope.orders_waited.total = data.wait_count;
$scope.orders_waited.sum = data.wait_sum;
$scope.orders_deleted.percent = $scope.calcPercentageForGroupOrders(total, data.deleted_count);
$scope.orders_deleted.total = data.deleted_count;
$scope.orders_deleted.sum = data.deleted_sum;
$scope.orders_returned.percent = $scope.calcPercentageForGroupOrders(total, data.returned_count);
$scope.orders_returned.total = data.returned_count;
$scope.orders_returned.sum = data.returned_sum;
});
smartRequest.get('dashboard/online/middle', function (data) {
$scope.middle = data.middle_check;
});
smartRequest.get('dashboard/online/total', function (data) {
$scope.total = data.total;
});
smartRequest.get('dashboard/online/staff', function (data) {
$scope.personals = data.staff;
});
smartRequest.get('v1/topdishes', function (data) {
$scope.dishes = data.dishes;
$scope.terminalId = data.terminal;
if ($scope.terminalId > 0) {
smartRequest.post('settings/update/force', {
task: 'online',
terminal: $scope.terminalId,
}, function(data) {
});
}
});
smartRequest.get('dashboard/online/folders', function (data) {
$scope.folders.labels = data.folders.map(folder => folder.name);
$scope.folders.data = data.folders.map(folder => Math.roundClearNG(folder.count));
});
smartRequest.get('dashboard/online/printers', function (data) {
$scope.printers.labels = [];
$scope.printers.data = [];
for (var i = 0; i < data.printers.length; i++) {
$scope.printers.labels.push(data.printers[i].name);
$scope.printers.data.push(Math.roundClearNG(data.printers[i].count, -2));
}
});
smartRequest.get('dashboard/online/tables', function (data) {
$scope.tables = data.tables;
});
smartRequest.get('dashboard/online/menu', function (data) {
$scope.menus.labels = [];
$scope.menus.data = [];
for (var i = 0; i < data.menus.length; i++) {
$scope.menus.labels.push(data.menus[i].menu_name);
$scope.menus.data.push(Math.roundClearNG(data.menus[i].count, -2));
}
});
smartRequest.get('dashboard/online/profit', function (data) {
$scope.profit = data.profit;
});
smartRequest.get('dashboard/online/guests', function (data) {
$scope.guests = data.guestsCount;
$scope.namedGuests = data.namedGuests;
$scope.sumNamedGuests = data.totalSum;
});
smartRequest.get('dashboard/online/deleted', function (data) {
$scope.deleted = Math.roundNG(data.count, -2);
$scope.deleted_sum = Math.roundNG(data.sum, -2);
});
smartRequest.get('dashboard/online/discount', function (data) {
$scope.discounts = Math.roundNG(data.count, -2);
$scope.discounts_sum = Math.roundNG(data.sum, -2);
$scope.tot_disc_sum = Math.roundNG(data.total_sum, -2);
});
smartRequest.get('dashboard/online/guests/median', function (data) {
$scope.medianGuests.labels = [];
$scope.medianGuests.data = [[]];
var tempData = [];
var tempTime = [];
for (var i = 0; i < data.data.length; i++) {
var newDate = $scope.getMomentDate(data.data[i].time);
tempData.push(parseInt(data.data[i].count));
tempTime.push(newDate);
var indexTime = $scope.getIntervals(tempTime[i], $scope.medianGuests.labels);
if (indexTime == -1) {
$scope.medianGuests.labels.push(tempTime[i]);
$scope.medianGuests.data[0].push(tempData[i]);
} else {
$scope.medianGuests.data[0][indexTime] += tempData[i];
}
}
});
smartRequest.get('dashboard/online/finance/median', function (data) {
$scope.medianFinance.labels = [];
$scope.medianFinance.data = [[], [], []];
var tempSum = [];
var tempTotalCost = [];
var tempProffit = [];
var tempTime = [];
for (var i = 0; i < data.data.length; i++) {
var newDate = $scope.getMomentDate(data.data[i].time);
tempSum.push(data.data[i].sum);
tempTotalCost.push(data.data[i].totalCost);
var proffit = parseFloat((tempSum[i] - tempTotalCost[i]).toFixed(2));
tempProffit.push(proffit);
tempTime.push(newDate);
var indexTime = $scope.getIntervals(tempTime[i], $scope.medianFinance.labels);
$scope.fillMedianFinance(indexTime, tempTime[i], tempSum[i], tempTotalCost[i], tempProffit[i]);
}
for (var i = 0; i < $scope.medianFinance.data.length; i++) {
for (var j = 0; j < $scope.medianFinance.data[i].length; j++) {
var data = $scope.medianFinance.data[i][j];
data = Math.round(data * 100) / 100;
$scope.medianFinance.data[i][j] = data;
}
}
});
$scope.checkUpdate();
};
$scope.update = function () {
smartRequest.get('dashboard/online/updatetime', function (data) {
$scope.update_time = data.updated;