Update RestoreShift frontend
This commit is contained in:
miroman-afk
2022-01-13 15:43:04 +03:00
parent f964aca7a9
commit 61d8b4e1d2
18 changed files with 1973 additions and 126 deletions

View File

@@ -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,
];
}
}

352
web/controllers/clients.js Normal file
View File

@@ -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();
}
}
)();

124
web/controllers/reports.js Normal file
View File

@@ -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($('<div/>').append($(elem).clone()).html());
};
$scope.update();
}
})();

186
web/controllers/shifts.js Normal file
View File

@@ -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($('<div/>').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();
}
})();

View File

@@ -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'
}
]
}
];

View File

@@ -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']
}

View File

@@ -0,0 +1,29 @@
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Редактирование клиента</h5>
</div>
<div class="modal-body p-lg">
<form role="form" class="ng-pristine ng-valid container">
<div class="form-group row">
<div class="col-sm-12">
<span>Группа: </span>
<select name="group" class="form-control input-c" ng-options="opt.id as opt.name for opt in groups" ng-model="currentGroup"></select>
<span>Имя: </span><input class="form-control" placeholder="Название" type="text" ng-model="contextElement.name">
<span>Телефон: </span><input class="form-control" type="text" ng-model="contextElement.phone" ui-mask="+375 (99) 999-99-99">
<span>Адрес: </span><input class="form-control" placeholder="Введите email" type="text" ng-model="contextElement.address">
<span>Email: </span><input class="form-control" placeholder="Введите адрес" type="text" ng-model="contextElement.email">
<span>Штрих код: </span><input class="form-control" placeholder="Введите штрих код" type="text" ng-model="contextElement.barcode">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn danger p-x-md pull-left" data-toggle="modal" data-target="#client-confirm-delete"><i class="material-icons">&#xE872;</i></button>
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal">Отмена</button>
<button type="button" class="btn success p-x-md" ng-click="updateClient()">Сохранить</button>
</div>
</div>
</div>

View File

@@ -0,0 +1,21 @@
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Редактирование группы</h5>
</div>
<div class="modal-body p-lg">
<form role="form" class="ng-pristine ng-valid container">
<div class="form-group row">
<div class="col-sm-12"><input class="form-control" placeholder="Название" type="text" ng-model="contextElement.name"></div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn danger p-x-md pull-left" data-toggle="modal" data-target="#group-confirm-delete"><i class="material-icons">&#xE872;</i></button>
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal">Отмена</button>
<button type="button" class="btn success p-x-md" ng-click="updateGroup()">Сохранить</button>
</div>
</div>
</div>

View File

@@ -0,0 +1,330 @@
<div id="container-floating">
<div class="nd1 nds" data-toggle="tooltip" data-placement="left" title="Сформировать файл" ng-click="createClientFile()" style="background-color: #3c80f6" onmouseenter="$(this).tooltip('show')">
<i class="material-icons">cloud_download</i>
</div>
<div id="floating-button" data-toggle="tooltip" data-placement="left" title="Действия" onmouseenter="$(this).tooltip('show')">
<p class="plus"><i class="material-icons">&#xE5D2;</i></p>
<p class="edit"><i class="material-icons">&#xE5CD;</i></p>
</div>
</div>
<div class="app-body-inner">
<div class="row-col row-col-xs b-b">
<div class="col-sm-3 b-r">
<div class="row-col">
<div class="row-row">
<div class="row-body scrollable hover">
<div class="row-inner">
<div class="nav nav-pills nav-stacked m-t-sm menus">
<a class="nav-link no_selection" ng-repeat="group in groups" sglclick="openGroup(group)" ios-dblclick="editGroup(group)"
ng-class="group.id == currentGroup ? 'bold-line' : ''">
<span ng-class="group.id == currentGroup ? 'bold' : ''">{{ group.name }}</span>
</a>
</div>
</div>
</div>
</div>
<div class="p-a text-center">
<a class="btn btn-md btn-outline rounded b-info text-info" ng-click="openFormCreateGroup()">
<i class="fa fa-plus fa-fw m-r-xs"></i>Группа
</a>
<p></p>
<a class="btn btn-md btn-outline rounded b-info text-info" ng-click="openFormCreateBarcode()">
<i class="fa fa-plus fa-fw m-r-xs"></i>Дисконтные карты
</a>
</div>
</div>
</div>
<div class="col-sm-3 light bg b-r">
<div class="row-col">
<div class="p-a-xs b-b">
<div class="input-group">
<span class="input-group-addon no-border no-bg">
<i class="fa fa-search"></i>
</span>
<input type="text" class="form-control no-border no-bg" placeholder="Поиск гостей..." ng-keyup="clientsSearch()"
ng-model="search.query">
<span class="input-group-addon no-border no-bg search-clear" ng-click="clearSearchInput()">
<i class="fa fa-times"></i>
</span>
</div>
</div>
<div class="row-row">
<div class="row-body scrollable hover">
<div class="row-inner">
<div class="list">
<div class="list-item pointer no_selection" ng-repeat="client in clients"
sglclick="openClientInfo(client)" ios-dblclick="editClient(client, currentGroup)"
ng-class="client.id == currentClientId ? 'active' : ''">
<div class="list-left">
<span class="w-30">
<i class="material-icons" style="font-size: 30px;">person</i>
</span>
</div>
<div class="list-body">
{{client.name}}
<small class="block text-muted">{{ client.phone }}</small>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="p-a text-center">
<div class="btn-group" role="group">
<a class="btn btn-md btn-outline rounded b-info text-info" ng-class="{disabled:currentPage === 1}" ng-click="pager(currentPage=currentPage-1)"><</a>
<a class="btn btn-md btn-outline rounded b-info text-info" ng-class="{disabled:currentPage}">{{currentPage}}/{{pages}}</a>
<a class="btn btn-md btn-outline rounded b-info text-info" ng-class="{disabled:currentPage === pages}" ng-click="pager(currentPage=currentPage+1)">></a>
</div>
</div>
<div class="text-center">
<a class="btn btn-md btn-outline rounded b-info text-info" ng-click="openFormCreateClient()">
<i class="fa fa-plus fa-fw m-r-xs"></i>Гость
</a>
<p></p>
</div>
</div>
</div>
<div class="col-sm-7">
<div class="padding" ng-if="currentClientId > 0">
<div class="box">
<div class="box-header">
<h2 class="text-center">{{currentClient.name}}</h2>
<h3 class="text-muted m-t">
<div class="col-sm-4 text-center">{{currentClient.info.address}}</div>
<div class="col-sm-4 text-center">{{currentClient.info.phone}}</div>
<div class="col-sm-4 text-center">{{currentClient.info.email}}</div>
</h3>
</div>
<div class="box-body b-t m-t">
{{currentClient.info.order_count}} заказов на сумму {{currentClient.info.order_sum}}
<hr>
<div class="table-responsive" ng-if="orders.length > 0">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Открыт</th>
<th>Закрыт</th>
<th class="text-right">Сумма заказа</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="order in orders" ng-click="getItems(order)">
<td>{{ order.opened }}</td>
<td>{{ order.closed }}</td>
<td class="text-right">{{ order.sum }} BYN</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="padding" ng-if="isCreateNewGroup">
<div class="box">
<div class="box-header">
<h3>Создание новой группы</h3>
</div>
<div class="box-tool">
<div class="pull-right">
<a class="btn btn-sm white" ng-click="closeCard()">
<i class="material-icons">clear</i>
</a>
</div>
</div>
<form name="createGroupForm" ng-submit="createGroup()">
<div class="box-body">
<div class="form-group row">
<label class="col-sm-3 form-control-label">Название</label>
<div class="col-sm-9">
<input type="text" class="form-control" ng-model="newGroup.name" required>
</div>
</div>
</div>
<div class="dker p-a">
<div class="row">
<div class="col-sm-12">
<button type="submit" class="btn success p-x-md pull-right" ng-disabled="createGroupForm.$invalid">Создать</button>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="padding" ng-if="isCreateNewBarcode">
<div class="box">
<div class="box-header">
<h3>Создание дисконтных карт</h3>
</div>
<div class="box-tool">
<div class="pull-right">
<a class="btn btn-sm white" ng-click="closeCard()">
<i class="material-icons">clear</i>
</a>
</div>
</div>
<form name="createBarcodeForm" ng-submit="createBarcode()">
<div class="box-body">
<div class="form-group row">
<label class="col-sm-3 form-control-label">Выберите группу</label>
<div class="col-sm-9">
<select ng-model="newBarcode.group_id" class="form-control" ng-required="true">
<option ng-repeat="group in groups" value="{{ group.id }}">{{group.name}}</option>
</select>
</div>
</div>
</div>
<div class="box-body">
<div class="form-group row">
<label class="col-sm-3 form-control-label">Первый штрих код</label>
<div class="col-sm-9">
<input type="text" class="form-control" ng-model="newBarcode.start" placeholder="200000000001" required>
</div>
</div>
</div>
<div class="box-body">
<div class="form-group row">
<label class="col-sm-3 form-control-label">Последний штрих код</label>
<div class="col-sm-9">
<input type="text" class="form-control" ng-model="newBarcode.end" placeholder="200000000999" required>
</div>
</div>
</div>
<div class="dker p-a">
<div class="row">
<div class="col-sm-12">
<button type="submit" class="btn success p-x-md pull-right" ng-disabled="createBarcodeForm.$invalid">Создать</button>
</div>
</div>
</div>
</form>
</div>
</div>
<div class="padding" ng-if="isCreateNewClient">
<div class="box">
<div class="box-header">
<h3>Создание нового гостя</h3>
</div>
<div class="box-tool">
<div class="pull-right">
<a class="btn btn-sm white" ng-click="">
<i class="material-icons">clear</i>
</a>
</div>
</div>
<form name="createClientForm" ng-submit="createClient()">
<div class="box-body">
<div class="form-group row">
<label class="col-sm-3 form-control-label">Имя</label>
<div class="col-sm-9">
<input type="text" class="form-control" ng-model="newClient.name" required>
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 form-control-label">Телефон</label>
<div class="col-sm-9">
<input type="text" class="form-control" ng-model="newClient.phone" ui-mask="+375 (99) 999-99-99">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 form-control-label">Адрес</label>
<div class="col-sm-9">
<input type="text" class="form-control" ng-model="newClient.address">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 form-control-label">Email</label>
<div class="col-sm-9">
<input type="text" class="form-control" ng-model="newClient.email">
</div>
</div>
<div class="form-group row">
<label class="col-sm-3 form-control-label">Штрих код</label>
<div class="col-sm-9">
<input type="text" class="form-control" ng-model="newClient.barcode">
</div>
</div>
<div class="form-group form-group-inline row">
<label class="col-sm-3 form-group-label" for="specialPriceCheck">Скидка по себестоимости </label>
<div class="col-sm-9">
<input class="form-group-input" type="checkbox" value="" id="specialPriceCheck" ng-model="newClient.special_price">
</div>
</div>
</div>
<div class="dker p-a">
<div class="row">
<div class="col-sm-12">
<button type="submit" class="btn success p-x-md pull-right" ng-disabled="createClientForm.$invalid">Создать</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="edit-client" data-backdrop="true" ng-if="!readonlyMode">
<div ui-include="'../views/clients/edit_client.html'"></div>
</div>
<div class="modal fade" id="edit-group" data-backdrop="true" ng-if="!readonlyMode">
<div ui-include="'../views/clients/edit_group.html'"></div>
</div>
<div id="group-confirm-delete" class="modal confirm-box" data-backdrop="true" style="z-index: 1052">
<div class="bottom white b-b" style="height: 90px">
<div class="confirm-box-body p-lg">
<p>Вы действительно хотите удалить группу?</p>
</div>
<div class="confirm-box-footer">
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal">Нет</button>
<button type="button" class="btn danger p-x-md" ng-click="removeGroup()">Да</button>
</div>
</div>
</div>
<div id="client-confirm-delete" class="modal confirm-box" data-backdrop="true" style="z-index: 1052">
<div class="bottom white b-b" style="height: 90px">
<div class="confirm-box-body p-lg">
<p>Вы действительно хотите удалить клиента?</p>
</div>
<div class="confirm-box-footer">
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal">Нет</button>
<button type="button" class="btn danger p-x-md" ng-click="removeClient()">Да</button>
</div>
</div>
</div>
<div class="modal fade" id="order" data-backdrop="true">
<div ui-include="'../views/clients/order.html'"></div>
</div>

View File

@@ -0,0 +1,36 @@
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h5 class="modal-title">История заказа</h5>
<span class="text-muted">{{order.opened}} - {{order.closed}}</span>
</div>
<div class="modal-body p-lg">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Блюдо</th>
<th>Количество</th>
<th class="text-right">Сумма, BYN</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in order.items">
<td>{{item.name}}</td>
<td>{{item.count}}</td>
<td class="text-right">{{item.amount}}</td>
</tr>
</tbody>
<thead>
<tr>
<th colspan="2"></th>
<th class="text-right">Итого: {{ order.amount | curr }} BYN</th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,148 @@
<div class="padding">
<div class="box">
<div class="padding">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="single">Отчет</label>
<select id="single" class="form-control select2" ui-jp="select2" ui-options="{theme: 'bootstrap'}" ng-model="report_id">
<optgroup label="Основные">
<option value="statistics">По статистике</option>
<option value="realisation">По реализации</option>
<option value="deleted">По удалениям</option>
<option value="pay">По отделам и видам оплат</option>
<option value="staff">По персоналу</option>
<option value="out">По внешним заказам</option>
</optgroup>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>С</label>
<div class='input-group date' ui-jp="datetimepicker" ui-options="{
format: 'DD.MM.YYYY',
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
}">
<input type='text' class="form-control" ng-model="start_date" />
<span class="input-group-addon">
<i class="material-icons">&#xE916;</i>
</span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>По</label>
<div class='input-group date' ui-jp="datetimepicker" ui-options="{
format: 'DD.MM.YYYY',
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
}">
<input type='text' class="form-control" ng-model="end_date" />
<span class="input-group-addon">
<i class="material-icons">&#xE916;</i>
</span>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button class="btn info btn-block" ng-click="createReport()">Создать отчет
</button>
</div>
</div>
</div>
</div>
<div class="box">
<div class="padding">
<h4>История</h4>
<hr/>
<div class="table-responsive">
<table class="table table-bordered m-a-0">
<thead>
<th>Отчет</th>
<th>С</th>
<th>По</th>
<th style="width: 70px">
<i class="material-icons">&#xE3E7;</i>
</th>
</thead>
<tbody>
<tr ng-repeat="report in history">
<td>{{ report.name }}</td>
<td>{{ report.start_date }}</td>
<td>{{ report.end_date }}</td>
<td>
<button class="btn btn-sm white" ng-click="archiveReport(report.type, report.start_date, report.end_date)">
<i class="material-icons">&#xE85C;</i>
</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="modal fade" id="report-delete" data-backdrop="true">
<div ui-include="'../views/reports/items/deleted.html'"></div>
</div>
<div class="modal fade" id="report-realisation" data-backdrop="true">
<div ui-include="'../views/reports/items/realisation.html'"></div>
</div>
<div class="modal fade" id="report-statistic" data-backdrop="true">
<div ui-include="'../views/reports/items/statistic.html'"></div>
</div>
<div class="modal fade" id="report-staff" data-backdrop="true">
<div ui-include="'../views/reports/items/staff.html'"></div>
</div>
<div class="modal fade" id="report-payment" data-backdrop="true">
<div ui-include="'../views/reports/items/payment.html'"></div>
</div>
<div class="modal fade" id="report-out" data-backdrop="true">
<div ui-include="'../views/out.html'"></div>
</div>
<script type="text/javascript" src="/libs/js/moment/locale/ru.js"></script>
<script type="text/javascript">
$('.date').on('dp.change', function () {
$(this).find('input').trigger('change');
});
</script>

View File

@@ -0,0 +1,65 @@
<div class="modal-dialog modal-lg">
<div class="modal-content" id="reportDeleted">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<button class="btn btn-icon white" ng-click="printElem('#reportDeleted')">
<i class="fa fa-print"></i>
</button>
<h4 class="modal-title">{{globals.currentUser.organization.name}}</h4>
<h5 class="modal-title">Отчет по удалениям</h5>
<span class="text-muted">{{start_date}} - {{end_date}}</span>
</div>
<div class="modal-body p-lg">
<div class="table-responsive" ng-if="report_delete.length > 0">
<table class="table table-bordered" ng-repeat="report in report_delete">
<thead>
<th>Смена#{{ report.shift_id }} Заказ #{{ report.order_code }}. {{ report.time }}</th>
</thead>
<tbody>
<tr ng-repeat="item in report.items">
<td>
<h6>{{ item.dish_name }}
<small>
(<strong>{{ item.count }}</strong> на сумму
<strong>{{ item.sum | curr }} BYN</strong>)
</small>
</h6>
<p>
Удалил:
<strong>{{ item.who }}</strong>
<br/> Подтвердил:
<strong>{{ item.approved }}</strong>
<br/> Причина:
<strong>{{ item.reason }}</strong>
</p>
</td>
</tr>
</tbody>
</table>
<hr/>
<table class="table table-bordered">
<tbody>
<tr>
<td>
<strong>Итого</strong>
</td>
<td style="text-align: right">
<strong>{{ report_delete.total_count }}</strong> удалений</td>
<td style="text-align: right">на сумму
<strong>{{ report_delete.total_sum | curr }} BYN</strong>
</td>
</tr>
</tbody>
</table>
</div>
<div ng-if="report_delete.length == 0">
<p>Удаления отсутствуют</p>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,46 @@
<div class="modal-dialog modal-lg">
<div class="modal-content" id="reportPayment">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<button class="btn btn-icon white" ng-click="printElem('#reportPayment')">
<i class="fa fa-print"></i>
</button>
<h4 class="modal-title">{{globals.currentUser.organization.name}}</h4>
<h5 class="modal-title">Отчет по отделам и видам оплат</h5>
<span class="text-muted">{{start_date}} - {{end_date}}</span>
</div>
<div class="modal-body p-lg">
<div class="col-md-6" ng-repeat="printer in printers">
<div class="table-responsive">
<table class="table table-border">
<thead>
<th colspan="2">{{printer.name}}</th>
</thead>
<tbody>
<tr ng-if="printer.cash > 0">
<td>Наличный расчет:</td>
<td class="text-right">{{printer.cash | curr}}</td>
</tr>
<tr ng-if="printer.credit > 0">
<td>Кредитными картами:</td>
<td class="text-right">{{printer.credit | curr}}</td>
</tr>
<tr ng-if="printer.clearing > 0">
<td>Безналичный расчет: </td>
<td class="text-right">{{printer.clearing | curr}}</td>
</tr>
<tr ng-if="printer.self_pay > 0">
<td>По ранее полученному авансу: </td>
<td class="text-right"> {{printer.self_pay | curr}}</td>
</tr>
</tbody>
<thead>
<th colspan="2">Итого: {{printer.total | curr}} BYN</th>
</thead>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,72 @@
<div class="modal-dialog modal-lg">
<div class="modal-content" id="reportRealisation">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<button class="btn btn-icon white" ng-click="printElem('#reportRealisation')">
<i class="fa fa-print"></i>
</button>
<h4 class="modal-title">{{globals.currentUser.organization.name}}</h4>
<h5 class="modal-title">Отчет по реализации</h5>
<span class="text-muted">{{start_date}} - {{end_date}}</span>
</div>
<div class="modal-body p-lg">
<div class="table-responsive" ng-if="report_realisation.length > 0">
<table class="table table-bordered" ng-repeat="printer in report_realisation">
<thead>
<th style="width: 70%">{{ printer.name }}</th>
<th style="width: 10%; text-align: right">{{ printer.count }}</th>
<th style="width: 20%; text-align: right">{{ printer.sum | curr}} BYN</th>
</thead>
<tbody>
<tr ng-repeat="item in printer.items">
<td>{{ item.name }}</td>
<td style="text-align: right">{{ item.count }}</td>
<td style="text-align: right">{{ item.sum | curr}}</td>
</tr>
</tbody>
</table>
<div ng-if="return_printers.length > 0">
<hr>
<table class="table table-bordered" ng-repeat="ret_print in return_printers">
<thead>
<th style="width: 70%">{{ ret_print.name }} (возврат)</th>
<th style="width: 10%; text-align: right">-{{ ret_print.count }}</th>
<th style="width: 20%; text-align: right">{{ ret_print.sum | curr }} BYN</th>
</thead>
<tbody>
<tr ng-repeat="item in ret_print.items">
<td>{{ item.name }}</td>
<td style="text-align: right">-{{ item.count }}</td>
<td style="text-align: right">{{ item.sum | curr}}</td>
</tr>
</tbody>
</table>
</div>
<hr>
<table class="table table-bordered">
<tbody>
<tr>
<td>
<strong>Итого</strong>
</td>
<td style="text-align: right">
<strong>{{ report_realisation.total_count }}</strong> позиций</td>
<td style="text-align: right">на сумму
<strong>{{ report_realisation.total_sum | curr}} BYN</strong>
</td>
</tr>
</tbody>
</table>
</div>
<div ng-if="report_realisation.length == 0">
<p>Реализация отсутсвует</p>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,50 @@
<div class="modal-dialog modal-lg">
<div class="modal-content" id="reportStaff">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<button class="btn btn-icon white" ng-click="printElem('#reportStaff')">
<i class="fa fa-print"></i>
</button>
<h4 class="modal-title">{{globals.currentUser.organization.name}}</h4>
<h5 class="modal-title">Отчет по персоналу</h5>
<span class="text-muted">{{start_date}} - {{end_date}}</span>
</div>
<div class="modal-body p-lg">
<div class="col-md-6" ng-repeat="staff in staffs">
<div class="table-responsive">
<table class="table table-border">
<thead>
<th>{{ staff.name }}</th>
</thead>
<tbody>
<tr ng-if="staff.input_count > 0">
<td>{{staff.input_count}} внесений в кассу на сумму {{staff.input_sum | curr}} BYN</td>
</tr>
<tr ng-if="staff.output_count > 0">
<td>{{staff.output_count}} выдач из кассы на сумму {{staff.output_sum | curr}} BYN</td>
</tr>
<tr ng-if="staff.payment_count > 0">
<td>{{staff.payment_count}} платежных документов на сумму {{staff.payment_sum | curr}} BYN</td>
</tr>
<tr ng-if="staff.opened_count > 0">
<td>Открыто {{staff.opened_count}} документов на сумму {{staff.opened_sum | curr}} BYN</td>
</tr>
<tr ng-if="staff.input_presale_count > 0">
<td>Внесено {{staff.input_presale_count}} авансов на сумму {{staff.input_presale_sum | curr} BYN</td>
</tr>
<tr ng-if="staff.output_presale_count > 0">
<td>Выдано {{staff.output_presale_count}} авансов на сумму {{staff.output_presale_sum | curr}} BYN</td>
</tr>
<tr ng-if="staff.correct_count > 0">
<td>Внесено {{staff.correct_count}} корекций на сумму {{staff.correct_sum | curr}} BYN</td>
</tr>
<tr ng-if="staff.return_count > 0">
<td>{{staff.return_count}} возвратов на сумму {{staff.return_sum | curr}} BYN</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,136 @@
<div class="modal-dialog modal-lg">
<div class="modal-content" id="reportStatistic">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<button class="btn btn-icon white" ng-click="printElem('#reportStatistic')">
<i class="fa fa-print"></i>
</button>
<h4 class="modal-title">{{globals.currentUser.organization.name}}</h4>
<h5 class="modal-title">Отчет по Статистике</h5>
<span class="text-muted">{{start_date}} - {{end_date}}</span>
</div>
<div class="modal-body p-lg">
<div class="table-responsive">
<table class="table table-bordered">
<tbody>
<tr>
<td colspan="2">
<strong>Реализация</strong>
</td>
</tr>
<tr>
<td>Количество заказов</td>
<td style="text-align: right">{{ statistic.orders_count }}</td>
</tr>
<tr>
<td>Сумма заказов (без скидки) <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.total_sum | curr}}</td>
</tr>
<tr>
<td>Скидка <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.discount_sum | curr}}</td>
</tr>
<tr>
<td>Итоговоя сумма <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.orders_sum | curr}}</td>
</tr>
<tr>
<td>Отложенных заказы</td>
<td style="text-align: right">{{ statistic.wait_count }}</td>
</tr>
<tr>
<td>Отложено на сумму <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.wait_sum | curr}}</td>
</tr>
<tr>
<td colspan="2">
<strong>Возвраты</strong>
</td>
</tr>
<tr>
<td>Количество возвратов</td>
<td style="text-align: right">{{ statistic.return_count }}</td>
</tr>
<tr>
<td>Сумма возвратов <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.return_sum | curr }}</td>
</tr>
<tr>
<td colspan="2">
<strong>Статистика</strong>
</td>
</tr>
<tr>
<td>Количество гостей</td>
<td style="text-align: right">{{ statistic.clients_count }}</td>
</tr>
<tr>
<td>Средний чек <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.avg_order_sum | curr}}</td>
</tr>
<tr>
<td>Средний чек на 1-го гостя <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.avg_order_client_sum | curr}}</td>
</tr>
<tr>
<td colspan="2">
<strong>Авансы</strong>
</td>
</tr>
<tr>
<td>Количество авансов полученных</td>
<td style="text-align: right">{{ statistic.in_presale_count }}</td>
</tr>
<tr>
<td>Сумма авансов полученных <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.in_presale_sum | curr}}</td>
</tr>
<tr>
<td>Количество авансов возвращенных</td>
<td style="text-align: right">{{ statistic.out_presale_count }}</td>
</tr>
<tr>
<td>Сумма авансов возвращенных <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.out_presale_sum | curr}}</td>
</tr>
<tr>
<td colspan="2">
<strong>Формы оплаты</strong>
</td>
</tr>
<tr>
<td>Наличный расчет <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.cash | curr}}</td>
</tr>
<tr>
<td>Наличный расчет (отложенные) <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.wait_sum | curr}}</td>
</tr>
<tr>
<td>Безналичный расчет <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.clearing | curr}}</td>
</tr>
<tr>
<td>Кредитными картами <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.credit | curr}}</td>
</tr>
<tr>
<td>Питание штата <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.self | curr}}</td>
</tr>
<tr>
<td>По ранее полученному авансу <strong>BYN</strong></td>
<td style="text-align: right">{{ statistic.presale | curr}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>

119
web/views/shifts/index.html Normal file
View File

@@ -0,0 +1,119 @@
<div id="container-floating">
<div class="nd3 nds" data-toggle="tooltip" data-placement="left" title="Повторно выгрузить" ng-click="add()" style="background-color: #3c80f6" onmouseenter="$(this).tooltip('show')">
<i class="material-icons">&#xE145;</i>
</div>
<div class="nd1 nds" data-toggle="tooltip" data-placement="left" title="Обновить" ng-click="update()" style="background-color: #d3a411"
onmouseenter="$(this).tooltip('show')">
<i class="material-icons">&#xE5D5;</i>
</div>
<div id="floating-button" data-toggle="tooltip" data-placement="left" title="Действия" onmouseenter="$(this).tooltip('show')">
<p class="plus">
<i class="material-icons">&#xE5D2;</i>
</p>
<p class="edit">
<i class="material-icons">&#xE5CD;</i>
</p>
</div>
</div>
<div class="padding">
<div class="box">
<div class="table-responsive">
<table class="table table-bordered m-a-0">
<thead>
<tr>
<th>ID</th>
<th>Открыта</th>
<th>Закрыта</th>
<th>Выручка, BYN</th>
<th style="width: 80px">
<i class="material-icons">&#xE3E7;</i>
</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="(index, shift) in shifts">
<td>{{ shift.id }}</td>
<td>
{{ shift.opened }} <br>
<small class="text-muted">{{ shift.open }}</small>
</td>
<td>
{{ shift.closed }} <br>
<small class="text-muted">{{ shift.close }}</small>
</td>
<td>{{ shift.sum | curr}}</td>
<td>
<div class="dropdown inline" style="margin-top: -5px; position: absolute;">
<button class="btn white dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="padding: 0.2rem 0.4rem">
<i class="material-icons">&#xE5D2;</i>
</button>
<div class="dropdown-menu pull-right dropdown-menu-scale">
<a class="dropdown-item" ng-click="reportStatistic(shift)">По статистике</a>
<a class="dropdown-item" ng-click="reportRealisation(shift)">По реализации</a>
<a class="dropdown-item" ng-click="reportDelete(shift)">По удалениям</a>
<a class="dropdown-item" ng-click="reportStaff(shift)">По персоналу</a>
<a class="dropdown-item" ng-click="reportPay(shift)">По отделам</a>
<a class="dropdown-item" ng-click="reportOut(shift)">По внешним заказам</a>
<a class="dropdown-item" ng-click="restoreShift(shift)">Восстановить смену</a>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<footer class="dker p-a">
<div class="row">
<div class="col-sm-12 text-center">
<ul class="pagination pagination-sm m-a-0">
<li>
<a ng-click="prevPage()" ng-class="currentPage == 1 ? 'disabled' : ''">
<i class="fa fa-chevron-left"></i>
</a>
</li>
<li ng-class="page == currentPage ? 'active' : ''" ng-repeat="page in pages" ng-click="showPage(page)">
<a href>{{ page }}</a>
</li>
<li>
<a ng-click="nextPage()" ng-class="currentPage == countOfPages ? 'disabled' : ''">
<i class="fa fa-chevron-right"></i>
</a>
</li>
</ul>
</div>
</div>
</footer>
</div>
</div>
<div class="modal fade" id="report-delete" data-backdrop="true">
<div ui-include="'../views/reports/items/deleted.html'"></div>
</div>
<div class="modal fade" id="report-realisation" data-backdrop="true">
<div ui-include="'../views/reports/items/realisation.html'"></div>
</div>
<div class="modal fade" id="report-statistic" data-backdrop="true">
<div ui-include="'../views/reports/items/statistic.html'"></div>
</div>
<div class="modal fade" id="report-staff" data-backdrop="true">
<div ui-include="'../views/reports/items/staff.html'"></div>
</div>
<div class="modal fade" id="report-payment" data-backdrop="true">
<div ui-include="'../views/reports/items/payment.html'"></div>
</div>
<div class="modal fade" id="report-out" data-backdrop="true">
<div ui-include="'../views/out.html'"></div>
</div>
<div class="modal fade" id="reImport" data-backdrop="true">
<div ui-include="'../views/shifts/reimport.html'"></div>
</div>

View File

@@ -0,0 +1,65 @@
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Выберите диапазон дат для повторной выгрузки файлов реализаций</h5>
</div>
<div class="modal-body text-center p-lg" style="height: 366px">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>С</label>
<div class='input-group date' ui-jp="datetimepicker" ui-options="{
format: 'DD.MM.YYYY',
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
}">
<input type='text' class="form-control" ng-model="start_date" />
<span class="input-group-addon">
<i class="material-icons">&#xE916;</i>
</span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>По</label>
<div class='input-group date' ui-jp="datetimepicker" ui-options="{
format: 'DD.MM.YYYY',
icons: {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down',
previous: 'fa fa-chevron-left',
next: 'fa fa-chevron-right',
today: 'fa fa-screenshot',
clear: 'fa fa-trash',
close: 'fa fa-remove'
}
}">
<input type='text' class="form-control" ng-model="end_date" />
<span class="input-group-addon">
<i class="material-icons">&#xE916;</i>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn dark-white p-x-md" data-dismiss="modal">Отмена</button>
<button type="button" class="btn success p-x-md" ng-click="create()">Создать запрос</button>
</div>
</div>
</div>