diff --git a/commands/TopDishes.php b/commands/TopDishes.php index 1ce6c8a..ee0105a 100644 --- a/commands/TopDishes.php +++ b/commands/TopDishes.php @@ -4,6 +4,7 @@ namespace App\Commands; use App\Component\Models\Dishes; use App\Component\Models\OnlineItems; +use App\Component\Models\Terminal; use App\Console\Commands\HRCCommand; use App\Console\Commands\HRCCommandInterface; @@ -11,7 +12,12 @@ class TopDishes extends HRCCommand implements HRCCommandInterface { protected $signature = 'gettopdishes'; public function command($input, $output = null) { - + $terminal = Terminal::where('soft', '=', 1)->where('is_active', '=', 1)->first(); + if ($terminal) { + $terminalKey = $terminal['key']; + } else { + $terminalKey = 0; + } $info = OnlineItems::where('menu_code', '>', 0)->get()->unique('menu_code'); $count = OnlineItems::where('menu_code', '>', 0)->count(); if ($count > 0) { @@ -58,7 +64,7 @@ class TopDishes extends HRCCommand implements HRCCommandInterface { return [ 'status' => 'success', 'dishes' => $sorted, - // 'info' => $info, + 'terminal' => $terminalKey, // 'test' => $dishes, // 'count' => $dishCount, ]; @@ -66,7 +72,7 @@ class TopDishes extends HRCCommand implements HRCCommandInterface { return [ 'status' => 'success', 'dishes' => [], - // 'info' => $info, + 'terminal' => $terminalKey, // 'test' => $dishes, // 'count' => $dishCount, ]; diff --git a/web/controllers/dashboard.js b/web/controllers/dashboard.js index 40520b5..6e0574e 100644 --- a/web/controllers/dashboard.js +++ b/web/controllers/dashboard.js @@ -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; diff --git a/web/views/dashboard/dashboard.html b/web/views/dashboard/dashboard.html index 3bbbef3..38a478c 100644 --- a/web/views/dashboard/dashboard.html +++ b/web/views/dashboard/dashboard.html @@ -1,5 +1,5 @@
-
diff --git a/web/views/shifts/images/350.gif b/web/views/shifts/images/350.gif deleted file mode 100644 index e191307..0000000 Binary files a/web/views/shifts/images/350.gif and /dev/null differ diff --git a/web/views/shifts/preload_1.html b/web/views/shifts/preload_1.html deleted file mode 100644 index 06c54b8..0000000 --- a/web/views/shifts/preload_1.html +++ /dev/null @@ -1,22 +0,0 @@ - - - \ No newline at end of file