From 61d8b4e1d21cea780705bd87b2cb5c3d282e16b1 Mon Sep 17 00:00:00 2001 From: miroman-afk <74014189+miroman-afk@users.noreply.github.com> Date: Thu, 13 Jan 2022 15:43:04 +0300 Subject: [PATCH] v2.5 Update RestoreShift frontend --- commands/POSTRestoreShift.php | 271 +++++++++-------- web/controllers/clients.js | 352 +++++++++++++++++++++++ web/controllers/reports.js | 124 ++++++++ web/controllers/shifts.js | 186 ++++++++++++ web/menu_min.js | 25 ++ web/routes_min.js | 24 ++ web/views/clients/edit_client.html | 29 ++ web/views/clients/edit_group.html | 21 ++ web/views/clients/index.html | 330 +++++++++++++++++++++ web/views/clients/order.html | 36 +++ web/views/reports/index.html | 148 ++++++++++ web/views/reports/items/deleted.html | 65 +++++ web/views/reports/items/payment.html | 46 +++ web/views/reports/items/realisation.html | 72 +++++ web/views/reports/items/staff.html | 50 ++++ web/views/reports/items/statistic.html | 136 +++++++++ web/views/shifts/index.html | 119 ++++++++ web/views/shifts/reimport.html | 65 +++++ 18 files changed, 1973 insertions(+), 126 deletions(-) create mode 100644 web/controllers/clients.js create mode 100644 web/controllers/reports.js create mode 100644 web/controllers/shifts.js create mode 100644 web/views/clients/edit_client.html create mode 100644 web/views/clients/edit_group.html create mode 100644 web/views/clients/index.html create mode 100644 web/views/clients/order.html create mode 100644 web/views/reports/index.html create mode 100644 web/views/reports/items/deleted.html create mode 100644 web/views/reports/items/payment.html create mode 100644 web/views/reports/items/realisation.html create mode 100644 web/views/reports/items/staff.html create mode 100644 web/views/reports/items/statistic.html create mode 100644 web/views/shifts/index.html create mode 100644 web/views/shifts/reimport.html diff --git a/commands/POSTRestoreShift.php b/commands/POSTRestoreShift.php index e4b4028..550f4b3 100644 --- a/commands/POSTRestoreShift.php +++ b/commands/POSTRestoreShift.php @@ -34,142 +34,161 @@ class POSTRestoreShift extends HRCCommand implements HRCCommandInterface { closedir($d); rmdir($dir); } - $shift_id = 4; + $shift_id = $input['shift_id']; $cache_dir = __DIR__ . "\\..\\..\\..\\Cache\\"; dirDel($cache_dir); - $terminal_updates_old = TerminalUpdate::where('method', '=', 'online')->get(); - foreach ($terminal_updates_old as $key => $terminal_online) { - $old_date = date_create($terminal_online['next_at']); - date_modify($old_date, '+1 hour'); - $new_date = date_format($old_date, 'Y-m-d H:i:s'); - $new_terminal_online = TerminalUpdate::find($terminal_online['id']); - $new_terminal_online->next_at = $new_date; - $new_terminal_online->save(); - } - $terminal_updates_new = TerminalUpdate::where('method', '=', 'online')->get(); - $exchange_shifts = ExchangeShifts::where('id', '=', $shift_id)->get(); + $nowTime = time(); + $update = true; + + $exchange_shifts = ExchangeShifts::where('id', '=', $shift_id)->first(); $exchange_orders = ExchangeOrders::where('shift_id', '=', $shift_id)->get(); $exchange_items = ExchangeItems::where('shift_id', '=', $shift_id)->get(); $exchange_actions = ExchangeActions::where('shift_id', '=', $shift_id)->get(); $exchange_deleted = ExchangeDeleted::where('shift_id', '=', $shift_id)->get(); - - //clear shifts - Shifts::truncate(); - foreach ($exchange_shifts as $key => $exchange_shift) { - $shift = new Shifts; - $shift->opened = $exchange_shift['opened']; - $shift->closed = $exchange_shift['closed']; - $shift->who_open = $exchange_shift['who_open']; - $shift->who_close = $exchange_shift['who_close']; - $shift->z_number = $exchange_shift['id']; - $shift->save(); + $terminal_online = TerminalUpdate::where('method', 'online')->where('terminal_id', $exchange_shifts['terminal_id'])->first(); + $baseTime = date_create($terminal_online['next_at']); + $baseTime = date_format($baseTime, 'U'); + $old_date = date_create($terminal_online['next_at']); + date_modify($old_date, '+1 hour'); + $new_date = date_format($old_date, 'Y-m-d H:i:s'); + if (($nowTime + 3600) >= $baseTime) { + $new_terminal_online = TerminalUpdate::find($terminal_online['id']); + $new_terminal_online->next_at = $new_date; + $new_terminal_online->save(); } - //clear shift_online_orders - ShiftOnlineOrders::truncate(); - foreach ($exchange_orders as $key => $exchange_order) { - $shift_online_order = new ShiftOnlineOrders; - $shift_online_order->cash = $exchange_order["cash"]; - $shift_online_order->check_number = $exchange_order["check_number"]; - $shift_online_order->clearing = $exchange_order["clearing"]; - $shift_online_order->client_code = $exchange_order["client_code"]; - $shift_online_order->client_count = $exchange_order["clients_count"]; - if ($exchange_order["closed"] == '0000-00-00 00:00:00') { - $exchange_order["closed"] = '1970-01-01 00:00:00'; - } - $shift_online_order->closed = $exchange_order["closed"]; - $shift_online_order->code = $exchange_order["code"]; - $shift_online_order->credit = $exchange_order["credit"]; - $shift_online_order->full_sum = $exchange_order["full_sum"]; - $shift_online_order->guid = $exchange_order["guid"]; - $shift_online_order->is_block = $exchange_order["is_block"]; - $shift_online_order->is_closed = $exchange_order["is_closed"]; - $shift_online_order->is_deleted = $exchange_order["is_deleted"]; - $shift_online_order->is_edit = $exchange_order["is_edit"]; - $shift_online_order->is_printed = $exchange_order["is_printed"]; - $shift_online_order->is_returned = $exchange_order["is_returned"]; - $shift_online_order->is_self = $exchange_order["is_self"]; - $shift_online_order->is_waited = $exchange_order["is_waited"]; - if ($exchange_order["manual_discount"] == '') { - $exchange_order["manual_discount"] = 0; + + if ($update) { + $online_shift = Shifts::first(); + if ($online_shift['z_number'] != $shift_id) { + //clear shifts + Shifts::truncate(); + $shift = new Shifts; + $shift->opened = $exchange_shifts['opened']; + $shift->closed = $exchange_shifts['closed']; + $shift->who_open = $exchange_shifts['who_open']; + $shift->who_close = $exchange_shifts['who_close']; + $shift->z_number = $exchange_shifts['id']; + $shift->save(); + + //clear shift_online_orders + ShiftOnlineOrders::truncate(); + foreach ($exchange_orders as $key => $exchange_order) { + $shift_online_order = new ShiftOnlineOrders; + $shift_online_order->cash = $exchange_order["cash"]; + $shift_online_order->check_number = $exchange_order["check_number"]; + $shift_online_order->clearing = $exchange_order["clearing"]; + $shift_online_order->client_code = $exchange_order["client_code"]; + $shift_online_order->client_count = $exchange_order["clients_count"]; + if ($exchange_order["closed"] == '0000-00-00 00:00:00') { + $exchange_order["closed"] = '1970-01-01 00:00:00'; + } + $shift_online_order->closed = $exchange_order["closed"]; + $shift_online_order->code = $exchange_order["code"]; + $shift_online_order->credit = $exchange_order["credit"]; + $shift_online_order->full_sum = $exchange_order["full_sum"]; + $shift_online_order->guid = $exchange_order["guid"]; + $shift_online_order->is_block = $exchange_order["is_block"]; + $shift_online_order->is_closed = $exchange_order["is_closed"]; + $shift_online_order->is_deleted = $exchange_order["is_deleted"]; + $shift_online_order->is_edit = $exchange_order["is_edit"]; + $shift_online_order->is_printed = $exchange_order["is_printed"]; + $shift_online_order->is_returned = $exchange_order["is_returned"]; + $shift_online_order->is_self = $exchange_order["is_self"]; + $shift_online_order->is_waited = $exchange_order["is_waited"]; + if ($exchange_order["manual_discount"] == '') { + $exchange_order["manual_discount"] = 0; + } else { + $exchange_order["manual_discount"] = $exchange_order["manual_discount"] + 0; + } + $shift_online_order->manual_discount = $exchange_order["manual_discount"]; + $shift_online_order->opened = $exchange_order["opened"]; + $shift_online_order->order_sum = $exchange_order["order_sum"]; + $shift_online_order->params_code = $exchange_order["params_id"]; + $shift_online_order->place_name = $exchange_order["place_name"]; + $shift_online_order->presale = $exchange_order["presale"]; + $shift_online_order->sale_sum = $exchange_order["sale_sum"]; + $shift_online_order->self = $exchange_order["self"]; + $shift_online_order->table_name = $exchange_order["table_name"]; + $shift_online_order->table_place = $exchange_order["table_place"]; + $shift_online_order->terminal_id = $exchange_order["terminal_id"]; + $shift_online_order->version_type = $exchange_order["version_type"]; + $shift_online_order->who_close = $exchange_order["who_close"]; + $shift_online_order->who_open = $exchange_order["who_open"]; + $shift_online_order->save(); + } + + ShiftOnlineItems::truncate(); + foreach ($exchange_items as $key => $exchange_item) { + $shift_online_item = new ShiftOnlineItems; + $shift_online_item->code = $exchange_item["code"]; + $shift_online_item->cof = $exchange_item["cof"]; + $shift_online_item->count = $exchange_item["count"]; + $shift_online_item->count_real = $exchange_item["count_real"]; + $shift_online_item->count_return = $exchange_item["count_return"]; + $shift_online_item->dish_code = $exchange_item["dishes_code"]; + $shift_online_item->menu_code = $exchange_item["menu_code"]; + $shift_online_item->modificator_code = $exchange_item["modificator_code"]; + $shift_online_item->order_code = $exchange_item["order_code"]; + $shift_online_item->parent_id = $exchange_item["parent_id"]; + $shift_online_item->real_price = $exchange_item["real_price"]; + $shift_online_item->sale_price = $exchange_item["sale_price"]; + $shift_online_item->special_price = $exchange_item["special_price"]; + $shift_online_item->terminal_id = $exchange_item["terminal_id"]; + $shift_online_item->units_code = $exchange_item["units_id"]; + $shift_online_item->save(); + } + + ShiftOnlineActions::truncate(); + foreach ($exchange_actions as $key => $exchange_action) { + $shift_online_action = new ShiftOnlineActions; + $shift_online_action->type_action = $exchange_action["action_type"]; + $shift_online_action->more = $exchange_action["more"]; + $shift_online_action->order_code = $exchange_action["order_code"]; + $shift_online_action->order_position = $exchange_action["order_position"]; + $shift_online_action->reason = $exchange_action["reason"]; + $shift_online_action->terminal_id = $exchange_action["terminal_id"]; + $shift_online_action->time = $exchange_action["time"]; + $shift_online_action->value = $exchange_action["value"]; + $shift_online_action->who = $exchange_action["who"]; + $shift_online_action->workcode = $exchange_action["work_code"]; + $shift_online_action->workgroup = $exchange_action["work_group"]; + $shift_online_action->save(); + } + + ShiftOnlineDeleted::truncate(); + foreach ($exchange_deleted as $key => $exchange_deleted_item) { + $shift_online_deleted_item = new ShiftOnlineDeleted; + $shift_online_deleted_item->code = $exchange_deleted_item["code"]; + $shift_online_deleted_item->count = $exchange_deleted_item["count"]; + $shift_online_deleted_item->dishes_code = $exchange_deleted_item["dishes_code"]; + $shift_online_deleted_item->item_id = $exchange_deleted_item["item_id"]; + $shift_online_deleted_item->menu_code = $exchange_deleted_item["menu_code"]; + $shift_online_deleted_item->order_code = $exchange_deleted_item["order_code"]; + $shift_online_deleted_item->real_price = $exchange_deleted_item["real_price"]; + $shift_online_deleted_item->sale_price = $exchange_deleted_item["sale_price"]; + $shift_online_deleted_item->terminal_id = $exchange_deleted_item["terminal_id"]; + $shift_online_deleted_item->units_id = $exchange_deleted_item["units_id"]; + $shift_online_deleted_item->save(); + } + + return [ + 'status' => 'success', + 'message' => 'Смена восстановлена', + ]; } else { - $exchange_order["manual_discount"] = $exchange_order["manual_discount"] + 0; + return [ + 'status' => 'error', + 'more' => 'Смена уже восстановлена', + 'stop_at' => 'Stop at check z_number', + ]; } - $shift_online_order->manual_discount = $exchange_order["manual_discount"]; - $shift_online_order->opened = $exchange_order["opened"]; - $shift_online_order->order_sum = $exchange_order["order_sum"]; - $shift_online_order->params_code = $exchange_order["params_id"]; - $shift_online_order->place_name = $exchange_order["place_name"]; - $shift_online_order->presale = $exchange_order["presale"]; - $shift_online_order->sale_sum = $exchange_order["sale_sum"]; - $shift_online_order->self = $exchange_order["self"]; - $shift_online_order->table_name = $exchange_order["table_name"]; - $shift_online_order->table_place = $exchange_order["table_place"]; - $shift_online_order->terminal_id = $exchange_order["terminal_id"]; - $shift_online_order->version_type = $exchange_order["version_type"]; - $shift_online_order->who_close = $exchange_order["who_close"]; - $shift_online_order->who_open = $exchange_order["who_open"]; - $shift_online_order->save(); + } else { + return [ + 'status' => 'error', + 'more' => 'Смена уже восстановлена', + 'stop_at' => 'Stop at check time', + ]; } - - ShiftOnlineItems::truncate(); - foreach ($exchange_items as $key => $exchange_item) { - $shift_online_item = new ShiftOnlineItems; - $shift_online_item->code = $exchange_item["code"]; - $shift_online_item->cof = $exchange_item["cof"]; - $shift_online_item->count = $exchange_item["count"]; - $shift_online_item->count_real = $exchange_item["count_real"]; - $shift_online_item->count_return = $exchange_item["count_return"]; - $shift_online_item->dish_code = $exchange_item["dishes_code"]; - $shift_online_item->menu_code = $exchange_item["menu_code"]; - $shift_online_item->modificator_code = $exchange_item["modificator_code"]; - $shift_online_item->order_code = $exchange_item["order_code"]; - $shift_online_item->parent_id = $exchange_item["parent_id"]; - $shift_online_item->real_price = $exchange_item["real_price"]; - $shift_online_item->sale_price = $exchange_item["sale_price"]; - $shift_online_item->special_price = $exchange_item["special_price"]; - $shift_online_item->terminal_id = $exchange_item["terminal_id"]; - $shift_online_item->units_code = $exchange_item["units_id"]; - $shift_online_item->save(); - } - - ShiftOnlineActions::truncate(); - foreach ($exchange_actions as $key => $exchange_action) { - $shift_online_action = new ShiftOnlineActions; - $shift_online_action->type_action = $exchange_action["action_type"]; - $shift_online_action->more = $exchange_action["more"]; - $shift_online_action->order_code = $exchange_action["order_code"]; - $shift_online_action->order_position = $exchange_action["order_position"]; - $shift_online_action->reason = $exchange_action["reason"]; - $shift_online_action->terminal_id = $exchange_action["terminal_id"]; - $shift_online_action->time = $exchange_action["time"]; - $shift_online_action->value = $exchange_action["value"]; - $shift_online_action->who = $exchange_action["who"]; - $shift_online_action->workcode = $exchange_action["work_code"]; - $shift_online_action->workgroup = $exchange_action["work_group"]; - $shift_online_action->save(); - } - - ShiftOnlineDeleted::truncate(); - foreach ($exchange_deleted as $key => $exchange_deleted_item) { - $shift_online_deleted_item = new ShiftOnlineDeleted; - $shift_online_deleted_item->code = $exchange_deleted_item["code"]; - $shift_online_deleted_item->count = $exchange_deleted_item["count"]; - $shift_online_deleted_item->dishes_code = $exchange_deleted_item["dishes_code"]; - $shift_online_deleted_item->item_id = $exchange_deleted_item["item_id"]; - $shift_online_deleted_item->menu_code = $exchange_deleted_item["menu_code"]; - $shift_online_deleted_item->order_code = $exchange_deleted_item["order_code"]; - $shift_online_deleted_item->real_price = $exchange_deleted_item["real_price"]; - $shift_online_deleted_item->sale_price = $exchange_deleted_item["sale_price"]; - $shift_online_deleted_item->terminal_id = $exchange_deleted_item["terminal_id"]; - $shift_online_deleted_item->units_id = $exchange_deleted_item["units_id"]; - $shift_online_deleted_item->save(); - } - - return [ - 'status' => 'success', - 'terminal_old' => $terminal_updates_old, - 'terminal_new' => $terminal_updates_new, - ]; } } \ No newline at end of file diff --git a/web/controllers/clients.js b/web/controllers/clients.js new file mode 100644 index 0000000..877010a --- /dev/null +++ b/web/controllers/clients.js @@ -0,0 +1,352 @@ +(function() { + 'use strict'; + angular + .module('app') + .controller('ClientsCtrl', ClientsCtrl); + + ClientsCtrl.$inject = ['$scope', 'smartRequest', 'Notification', '$rootScope', '$timeout']; + function ClientsCtrl($scope, smartRequest, Notification, $rootScope, $timeout) { + $scope.clients = []; + $scope.groups = []; + $scope.statuses = []; + $scope.filedate = ''; + $scope.currentGroupId = 0; + $scope.currentClientId = 0; + + $scope.currentClient = {}; + + $scope.orders = []; + $scope.order = {}; + + $scope.isCreateNewGroup = false; + $scope.newGroup = {}; + $scope.newBarcode = {}; + + $scope.isCreateNewClient = false; + $scope.newClient = {}; + + $scope.search = { + query: '' + }; + + var promise = 0; + + $scope.clientsSearch = function() { + + } + + $scope.update = function() { + smartRequest.get('client/list?page=' + $scope.currentPage, function(data) { + $scope.clients = data.clients; + $scope.countOfPages = data.pages; + $scope.pages = $scope.makePages(); + }); + }; + + $scope.getGroups = function() { + smartRequest.get('v1/clientgroup', function(data) { + $scope.groups = data.groups; + $scope.filedate = data.filedate; + $scope.openGroup({id: 0}); + }); + }; + + + $scope.openGroup = function(group) { + if (typeof group === 'object') { + $scope.currentGroup = group.id; + } else { + $scope.currentGroup = group; + } + $scope.currentPage = 1; + smartRequest.get('v1/clients?group_id=' + $scope.currentGroup + '&page=' + $scope.currentPage, function(data) { + $scope.clients = data.clients; + $scope.pages = data.pages; + $scope.currentGroup = data.currentGroup; + $scope.total = data.total; + }); + }; + + $scope.editGroup = function (group) { + $scope.contextElement = group; + + $('#edit-group').modal('toggle'); + console.log(group); + }; + + $scope.updateGroup = function () { + $('#edit-group').modal('toggle'); + + smartRequest.post('v1/clientgroup', { + id: $scope.contextElement.id, + name: $scope.contextElement.name, + task: 'update' + }, function (data) { + if (data.status == 'success') { + Notification.success(data.message); + } + if (data.error_message) { + Notification.error(data.error_message); + } + }); + }; + + $scope.removeGroup = function () { + $('#group-confirm-delete').modal('toggle'); + $('#edit-group').modal('toggle'); + + smartRequest.post('v1/clientgroup', { + id: $scope.contextElement.id, + task: 'delete' + }, function (data) { + $scope.getGroups(); + if (data.message) { + Notification.success(data.message); + } + if (data.error_message) { + Notification.error(data.error_message); + } + }); + }; + + $scope.editClient = function (client, group) { + $scope.contextElement = client; + + $('#edit-client').modal('toggle'); + console.log(client); + console.log(group); + }; + + $scope.updateClient = function () { + $('#edit-client').modal('toggle'); + + smartRequest.post('v1/client', { + id: $scope.contextElement.id, + name: $scope.contextElement.name, + group_id: $scope.contextElement.client_group, + phone: $scope.contextElement.phone, + address: $scope.contextElement.address, + email: $scope.contextElement.email, + barcode: $scope.contextElement.barcode, + task: 'update' + }, function (data) { + if (data.status == 'success') { + Notification.success(data.message); + $scope.openGroup($scope.contextElement.client_group); + } + if (data.error_message) { + Notification.error(data.error_message); + } + }); + }; + + $scope.removeClient = function () { + $('#client-confirm-delete').modal('toggle'); + $('#edit-client').modal('toggle'); + + smartRequest.post('v1/client', { + id: $scope.contextElement.id, + task: 'delete' + }, function (data) { + $scope.getGroups(); + $scope.openGroup($scope.currentGroup); + if (data.message) { + Notification.success(data.message); + } + if (data.error_message) { + Notification.error(data.error_message); + } + }); + }; + + $scope.pager = function(currentPage) { + smartRequest.get('v1/clients?group_id=' + $scope.currentGroup + '&page=' + $scope.currentPage, function(data) { + $scope.clients = data.clients; + $scope.pages = data.pages; + $scope.currentGroup = data.currentGroup; + $scope.total = data.total; + }); + }; + + $scope.getClients = function() { + if ($scope.search.query.length === 0) { + $scope.openGroup({id: $scope.currentGroupId}); + } + else { + smartRequest.post('client/search', { + name: $scope.search.query + }, + function (data) { + $scope.clients = data.clients; + }); + } + }; + + $scope.openFormCreateGroup = function() { + $scope.currentClientId = 0; + $scope.isCreateNewClient = false; + $scope.isCreateNewBarcode = false; + $scope.isCreateNewGroup = !$scope.isCreateNewGroup; + }; + + $scope.openFormCreateClient = function() { + $scope.currentClientId = 0; + $scope.isCreateNewGroup = false; + $scope.isCreateNewBarcode = false; + $scope.isCreateNewClient = !$scope.isCreateNewClient; + }; + + $scope.openFormCreateBarcode = function() { + $scope.currentClientId = 0; + $scope.isCreateNewGroup = false; + $scope.isCreateNewClient = false; + $scope.isCreateNewBarcode = !$scope.isCreateNewBarcode; + smartRequest.get('v1/clientgroup', function(data) { + $scope.groups = data.groups; + }); + }; + + $scope.createGroup = function() { + smartRequest.post('client/group/create', { + name: $scope.newGroup.name + }, function (data) { + $scope.getGroups(); + $scope.closeCard(); + }); + }; + + $scope.createClient = function() { + smartRequest.post('v1/createclient/', { + name: $scope.newClient.name, + group_id: $scope.currentGroup, + phone: $scope.newClient.phone, + address: $scope.newClient.address, + email: $scope.newClient.email, + barcode: $scope.newClient.barcode, + is_special_price: $scope.newClient.special_price + }, function(data) { + $scope.pager($scope.currentGroup); + $scope.closeCard(); + }); + }; + + $scope.createBarcode = function() { + console.log($scope.newBarcode.group_id); + smartRequest.post('v1/createbarcode/', { + group_id: $scope.newBarcode.group_id, + start: $scope.newBarcode.start, + end: $scope.newBarcode.end, + }, function(data) { + $scope.getGroups(); + $scope.closeCard(); + }); + }; + + $scope.closeCard = function() { + $scope.isCreateNewGroup = false; + $scope.isCreateNewClient = false; + $scope.isCreateNewBarcode = false; + $scope.currentClientId = 0; + }; + + $scope.openClientInfo = function(client) { + $scope.currentClientId = client.id; + $scope.isCreateNewGroup = false; + $scope.isCreateNewClient = false; + $scope.isCreateNewBarcode = false; + + smartRequest.get('client/client/info?id=' + $scope.currentClientId, function(data) { + $scope.currentClient = data.client; + + smartRequest.get('client/orders?client_id=' + $scope.currentClient.id, function(data) { + $scope.orders = data.orders; + }); + }); + }; + + $scope.getItems = function(order) { + smartRequest.get('client/order?order_id=' + order.id, function(data) { + $scope.order = data; + $('#order').modal('toggle'); + }); + }; + + var mergeFiles = function (statuses) { + if (statuses == 4) { + smartRequest.get('v1/clientfile?complete=1', function(data) { + $scope.filedate = data.filedate; + $scope.filename = data.filename; + $scope.terminalkey = data.terminalKey; + $scope.downloadClientFile(); + $scope.statuses = []; + }); + } + }; + + $scope.createClientFile = function(count) { + smartRequest.get('v1/clientfile?th=1', function(data) { + if(data.status == 'success') { + $scope.statuses.push(data.status); + console.log($scope.statuses); + $scope.statusCount = $scope.statuses.length; + mergeFiles($scope.statusCount); + } + }); + smartRequest.get('v1/clientfile?th=2', function(data) { + if(data.status == 'success') { + $scope.statuses.push(data.status); + console.log($scope.statuses); + $scope.statusCount = $scope.statuses.length; + mergeFiles($scope.statusCount); + } + }); + smartRequest.get('v1/clientfile?th=3', function(data) { + if(data.status == 'success') { + $scope.statuses.push(data.status); + console.log($scope.statuses); + $scope.statusCount = $scope.statuses.length; + mergeFiles($scope.statusCount); + } + }); + smartRequest.get('v1/clientfile?th=4', function(data) { + if(data.status == 'success') { + $scope.statuses.push(data.status); + console.log($scope.statuses); + $scope.statusCount = $scope.statuses.length; + mergeFiles($scope.statusCount); + } + }); + }; + + + $scope.downloadClientFile = function() { + smartRequest.get('v1/clientgroup', function(data) { + window.open(window.location.protocol + '//' + window.location.hostname + '/Exchange/' + $scope.terminalkey +'/'+ $scope.filename); + }); + }; + + $scope.clientsSearch = function () { + if (promise) { + $timeout.cancel(promise); + } + promise = $timeout(function () { + if ($scope.search.query.length === 0) { + $scope.getGroups(); + } + else { + $scope.groups = []; + } + + $scope.getClients(); + }, 300); + }; + + $scope.clearSearchInput = function () { + $scope.search.query = ''; + $scope.clientsSearch(); + }; + + $scope.getGroups(); + } +} +)(); \ No newline at end of file diff --git a/web/controllers/reports.js b/web/controllers/reports.js new file mode 100644 index 0000000..80e67b2 --- /dev/null +++ b/web/controllers/reports.js @@ -0,0 +1,124 @@ +(function() { + 'use strict'; + angular + .module('app') + .controller('ReportsCtrl', ReportsCtrl); + + ReportsCtrl.$inject = ['$scope', 'smartRequest']; + function ReportsCtrl($scope, smartRequest) { + var date = new Date(); + + var formatted = ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth() + 1)).slice(-2) + '.' + date.getFullYear(); + + date.setDate(date.getDate() - 1); + + var formatted_yesterday = ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth() + 1)).slice(-2) + '.' + date.getFullYear(); + + $scope.report_delete = []; + $scope.report_realisation = []; + $scope.start_date = formatted_yesterday; + $scope.end_date = formatted; + $scope.report_id = 'realisation'; + $scope.history = []; + $scope.statistic = {}; + $scope.staffs = []; + $scope.printers = []; + + $scope.update = function() { + smartRequest.get('report/history', function(data) { + $scope.history = data.reports; + }); + }; + + $scope.reportDelete = function() { + smartRequest.get('report/deleted?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) { + $scope.report_delete = data.deleted; + $scope.report_delete.total_sum = data.total_sum; + $scope.report_delete.total_count = data.total_count; + $('#report-delete').modal(); + }, function(data) { + $scope.update(); + }); + }; + + $scope.reportRealisation = function() { + smartRequest.get('report/realisation?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) { + $scope.report_realisation = data.printers; + $scope.return_printers = data.ret_prints; + $scope.report_realisation.total_count = data.total_count; + $scope.report_realisation.total_sum = data.total_sum; + $('#report-realisation').modal(); + }, function(data) { + $scope.update(); + }); + }; + + $scope.reportStatistic = function() { + smartRequest.get('report/statistics?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) { + $scope.statistic = data.statistic; + $('#report-statistic').modal(); + }, function(data) { + $scope.update(); + }); + }; + + $scope.reportStaff = function() { + smartRequest.get('report/staff?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) { + $scope.staffs = data.staffs; + $('#report-staff').modal(); + }, function(data) { + $scope.update(); + }); + }; + + $scope.reportPay = function() { + smartRequest.get('report/payment?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) { + $scope.printers = data.printers; + $('#report-payment').modal(); + }, function(data) { + $scope.update(); + }); + }; + + $scope.reportOut = function () { + smartRequest.get('v1/outorders?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function (data) { + $scope.orders = data.orders; + $scope.total = data.total; + $('#report-out').modal(); + }, function (data) { + $scope.update(); + }); + }; + + $scope.createReport = function() { + switch ($scope.report_id) { + case 'deleted': $scope.reportDelete(); break; + case 'realisation': $scope.reportRealisation(); break; + case 'statistics': $scope.reportStatistic(); break; + case 'staff': $scope.reportStaff(); break; + case 'pay': $scope.reportPay(); break; + case 'out': $scope.reportOut(); break; + } + }; + + $scope.archiveReport = function(type, start_date, end_date) { + $scope.report_id = type; + $scope.start_date = start_date; + $scope.end_date = end_date; + $scope.createReport(); + }; + + $scope.popup = function(data) { + var mywindow = window.open(); + mywindow.document.write(data); + mywindow.print(); + mywindow.close(); + }; + + $scope.printElem = function(elem) { + $scope.popup($('
').append($(elem).clone()).html()); + }; + + $scope.update(); + } +})(); \ No newline at end of file diff --git a/web/controllers/shifts.js b/web/controllers/shifts.js new file mode 100644 index 0000000..52d62ac --- /dev/null +++ b/web/controllers/shifts.js @@ -0,0 +1,186 @@ +(function () { + 'use strict'; + angular + .module('app') + .controller('ShiftsCtrl', ShiftsCtrl); + + ShiftsCtrl.$inject = ['$scope', '$filter', 'smartRequest', 'Notification']; + function ShiftsCtrl($scope, $filter, smartRequest, Notification) { + var date = new Date(); + var formatted = ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth() + 1)).slice(-2) + '.' + date.getFullYear(); + date.setDate(date.getDate() - 1); + var formatted_yesterday = ('0' + date.getDate()).slice(-2) + '.' + ('0' + (date.getMonth() + 1)).slice(-2) + '.' + date.getFullYear(); + + $scope.start_date = formatted; + $scope.end_date = formatted_yesterday; + $scope.response = false; + $scope.shifts = []; + $scope.report_delete = []; + $scope.countOfPages = 1; + $scope.currentPage = 1; + $scope.statistic = {}; + $scope.staffs = []; + + $scope.add = function() { + $scope.reImport = {}; + $('#reImport').modal(); + }; + + $scope.create = function() { + var start_date = document.getElementById("startDate").value; + var end_date = document.getElementById("endDate").value; + console.log(start_date, end_date); + smartRequest.get('v1/import?start_date=' + encodeURIComponent(start_date) + '&end_date=' + encodeURIComponent(end_date), function(data) { + $scope.response = data.message; + if (data.message == 'shifts not found') { + Notification.error('Смены не найдены'); + } else { + Notification.success('Задача создана'); + $scope.update(); + } + }); + $('#reImport').modal('toggle'); + }; + + $scope.update = function () { + smartRequest.get('shift/list?page=' + $scope.currentPage, function (data) { + $scope.shifts = data.shifts; + $scope.countOfPages = data.pages; + $scope.pages = $scope.makePages(); + }); + }; + + $scope.reportDelete = function (shift) { + smartRequest.get('report/deleted?shift_id=' + shift.id, function (data) { + $scope.report_delete = data.deleted; + $scope.report_delete.total_sum = data.total_sum; + $scope.report_delete.total_count = data.total_count; + + $scope.start_date = shift.opened; + $scope.end_date = shift.closed; + + $('#report-delete').modal(); + }); + }; + + $scope.reportRealisation = function (shift) { + smartRequest.get('report/realisation?shift_id=' + shift.id, function (data) { + + $scope.report_realisation = data.printers; + $scope.return_printers = data.ret_prints; + + $scope.report_realisation.total_count = data.total_count; + $scope.report_realisation.total_sum = data.total_sum; + + $scope.start_date = shift.opened; + $scope.end_date = shift.closed; + + $('#report-realisation').modal(); + }); + }; + + $scope.reportStatistic = function (shift) { + smartRequest.get('report/statistics?shift_id=' + shift.id, function (data) { + $scope.statistic = data.statistic; + $scope.start_date = shift.opened; + $scope.end_date = shift.closed; + + $('#report-statistic').modal(); + }); + }; + + $scope.reportStaff = function (shift) { + smartRequest.get('report/staff?shift_id=' + shift.id, function (data) { + $scope.staffs = data.staffs; + $scope.start_date = shift.opened; + $scope.end_date = shift.closed; + + $('#report-staff').modal(); + }); + }; + + $scope.reportPay = function (shift) { + smartRequest.get('report/payment?shift_id=' + shift.id, function (data) { + + $scope.printers = data.printers; + $scope.start_date = shift.opened; + $scope.end_date = shift.closed; + + $('#report-payment').modal(); + }, function (data) { + $scope.update(); + }); + }; + + $scope.reportOut = function (shift) { + smartRequest.get('v1/outorders?shift_id=' + shift.id, function (data) { + $scope.response = data.message; + if (data.message == 'false') { + Notification.error('Внешние заказы не найдены'); + } else { + $scope.orders = data.orders; + $scope.shift = data.shift; + $scope.total = data.total; + + $('#report-out').modal(); + } + + }, function (data) { + $scope.update(); + }); + }; + + $scope.restoreShift = function (shift) { + smartRequest.post('v1/restoreshift', { + shift_id: shift.id + }, function (data) { + $scope.status = data.status; + $scope.response = data.message; + if (data.status == 'success') { + Notification.success(data.message); + console.log(data.status); + console.log(data.message); + setTimeout(function() { + location.reload(); + }, 2000); + } + if ($scope.status == 'error') { + Notification.error(data.message); + } + }); + }; + + $scope.popup = function(data) { + var mywindow = window.open(); + mywindow.document.write(data); + + mywindow.print(); + mywindow.close(); + }; + + $scope.printElem = function(elem) { + $scope.popup($('
').append($(elem).clone()).html()); + }; + + $scope.makePages = function () { + return Array.from({ length: $scope.countOfPages }, (v, k) => k + 1); + }; + + $scope.showPage = function (index) { + $scope.currentPage = index; + $scope.update(); + }; + + $scope.nextPage = function () { + $scope.currentPage++; + $scope.update(); + }; + + $scope.prevPage = function () { + $scope.currentPage--; + $scope.update(); + }; + + $scope.update(); + } +})(); \ No newline at end of file diff --git a/web/menu_min.js b/web/menu_min.js index b82412d..2931d12 100644 --- a/web/menu_min.js +++ b/web/menu_min.js @@ -12,5 +12,30 @@ item: [ url: 'app.orders', icon: 'dashboard', order: 0 + }, + { + name: 'Гости', + acl: 'clients', + url: 'app.clients', + icon: 'group', + order: 40 + }, + { + name: 'Реализация', + acl: 'shifts,report', + icon: 'library_books', + order: 30, + items: [ + { + name: 'Смены', + acl: 'shifts', + url: 'app.shifts' + }, + { + name: 'Отчеты', + acl: 'reports', + url: 'app.reports' + } + ] } ]; \ No newline at end of file diff --git a/web/routes_min.js b/web/routes_min.js index 8be55d4..8e55618 100644 --- a/web/routes_min.js +++ b/web/routes_min.js @@ -21,4 +21,28 @@ data: { title : 'Eorders' }, controller: 'OrdersCtrl', resolve: ['scripts/controllers/orders.js'] +}, +{ + code: 'app.clients', + url: '/clients', + templateUrl: '../views/clients/index.html', + data: {title: 'Гости'}, + controller: 'ClientsCtrl', + resolve: ['scripts/controllers/clients.js'] +}, +{ + code: 'app.shifts', + url: '/shifts', + templateUrl: '../views/shifts/index.html', + data: {title: 'Смены'}, + controller: 'ShiftsCtrl', + resolve: ['scripts/controllers/shifts.js'] +}, +{ + code: 'app.reports', + url: '/reports', + templateUrl: '../views/reports/index.html', + data: {title: 'Отчеты'}, + controller: 'ReportsCtrl', + resolve: ['scripts/controllers/reports.js', 'moment', 'datetimepicker', 'select2'] } \ No newline at end of file diff --git a/web/views/clients/edit_client.html b/web/views/clients/edit_client.html new file mode 100644 index 0000000..dd28abe --- /dev/null +++ b/web/views/clients/edit_client.html @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/web/views/clients/edit_group.html b/web/views/clients/edit_group.html new file mode 100644 index 0000000..15484eb --- /dev/null +++ b/web/views/clients/edit_group.html @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/web/views/clients/index.html b/web/views/clients/index.html new file mode 100644 index 0000000..dcd618d --- /dev/null +++ b/web/views/clients/index.html @@ -0,0 +1,330 @@ +
+
+ cloud_download +
+
+

+

+
+
+ +
+
+ + + +
+
+
+
+ + + + + + + +
+
+ +
+
+
+
+
+
+ + person + +
+
+ {{client.name}} + {{ client.phone }} +
+
+
+ +
+
+
+ + +
+
+ +
+
+
+
+

{{currentClient.name}}

+

+
{{currentClient.info.address}}
+
{{currentClient.info.phone}}
+
{{currentClient.info.email}}
+

+
+
+ {{currentClient.info.order_count}} заказов на сумму {{currentClient.info.order_sum}} +
+
+ + + + + + + + + + + + + + + +
ОткрытЗакрытСумма заказа
{{ order.opened }}{{ order.closed }}{{ order.sum }} BYN
+
+
+
+
+ +
+
+
+

Создание новой группы

+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+

Создание дисконтных карт

+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+

Создание нового гостя

+
+ +
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+ + + + + + + + + + \ No newline at end of file diff --git a/web/views/clients/order.html b/web/views/clients/order.html new file mode 100644 index 0000000..ce47ea2 --- /dev/null +++ b/web/views/clients/order.html @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/web/views/reports/index.html b/web/views/reports/index.html new file mode 100644 index 0000000..938d7c5 --- /dev/null +++ b/web/views/reports/index.html @@ -0,0 +1,148 @@ +
+
+
+
+
+
+ + +
+
+
+ +
+
+
+ +
+ + + + +
+
+
+ +
+
+ +
+ + + + +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+

История

+ +
+ +
+ + + + + + + + + + + + + + + + +
ОтчетСПо + +
{{ report.name }}{{ report.start_date }}{{ report.end_date }} + +
+
+
+
+
+ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/views/reports/items/deleted.html b/web/views/reports/items/deleted.html new file mode 100644 index 0000000..c507b28 --- /dev/null +++ b/web/views/reports/items/deleted.html @@ -0,0 +1,65 @@ + \ No newline at end of file diff --git a/web/views/reports/items/payment.html b/web/views/reports/items/payment.html new file mode 100644 index 0000000..601ee09 --- /dev/null +++ b/web/views/reports/items/payment.html @@ -0,0 +1,46 @@ + \ No newline at end of file diff --git a/web/views/reports/items/realisation.html b/web/views/reports/items/realisation.html new file mode 100644 index 0000000..7ab776e --- /dev/null +++ b/web/views/reports/items/realisation.html @@ -0,0 +1,72 @@ + \ No newline at end of file diff --git a/web/views/reports/items/staff.html b/web/views/reports/items/staff.html new file mode 100644 index 0000000..466c576 --- /dev/null +++ b/web/views/reports/items/staff.html @@ -0,0 +1,50 @@ + \ No newline at end of file diff --git a/web/views/reports/items/statistic.html b/web/views/reports/items/statistic.html new file mode 100644 index 0000000..b34671d --- /dev/null +++ b/web/views/reports/items/statistic.html @@ -0,0 +1,136 @@ + \ No newline at end of file diff --git a/web/views/shifts/index.html b/web/views/shifts/index.html new file mode 100644 index 0000000..94ad56d --- /dev/null +++ b/web/views/shifts/index.html @@ -0,0 +1,119 @@ + +
+
+ +
+ +
+ +
+ +
+

+ +

+

+ +

+
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + +
IDОткрытаЗакрытаВыручка, BYN + +
{{ shift.id }} + {{ shift.opened }}
+ {{ shift.open }} +
+ {{ shift.closed }}
+ {{ shift.close }} +
{{ shift.sum | curr}} + +
+
+ +
+
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/web/views/shifts/reimport.html b/web/views/shifts/reimport.html new file mode 100644 index 0000000..8d8104b --- /dev/null +++ b/web/views/shifts/reimport.html @@ -0,0 +1,65 @@ + \ No newline at end of file