v.2.22
Редактор карты зала Электронные заказы Отчет по удалениям
This commit is contained in:
@@ -200,10 +200,25 @@
|
||||
$scope.selectedMenuElement = {};
|
||||
$scope.selectMenuNavigationStack = [];
|
||||
|
||||
$scope.enterCount = function(orderId, itemId) {
|
||||
$('#edit-selectmenuitem').modal('hide');
|
||||
$('#edit-item-count').modal('toggle');
|
||||
$scope.itemId = itemId;
|
||||
$scope.enterCount = function(item, orderId, itemId) {
|
||||
$('#edit-item-count').modal('toggle');
|
||||
$scope.itemId = item.id;
|
||||
$scope.orderId = orderId;
|
||||
console.log(item);
|
||||
};
|
||||
|
||||
|
||||
$scope.updateCount = function(item, count) {
|
||||
item.item_count = parseFloat(count);
|
||||
smartRequest.post('v1/orderitem', {
|
||||
task: 'update',
|
||||
id: $scope.itemId,
|
||||
order_id: $scope.orderId,
|
||||
item_count: item.item_count
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
$scope.getOrder($scope.orderId);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getOrder = function(orderId, newOrder) {
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
};
|
||||
|
||||
$scope.reportDelete = function() {
|
||||
smartRequest.get('report/deleted?start_date=' + encodeURIComponent($scope.start_date) + '&end_date=' + encodeURIComponent($scope.end_date), function(data) {
|
||||
smartRequest.get('v1/datareport?type=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;
|
||||
|
||||
235
web/controllers/roommap.js
Normal file
235
web/controllers/roommap.js
Normal file
@@ -0,0 +1,235 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app', ['angular.drag.resize', 'ng-context-menu'])
|
||||
.controller('RoommapCtrl', RoommapCtrl);
|
||||
|
||||
RoommapCtrl.$inject = ['$scope', 'smartRequest', 'Notification', '$http'];
|
||||
|
||||
function RoommapCtrl($scope, smartRequest, Notification, $http) {
|
||||
$scope.places = [];
|
||||
$scope.tables = [];
|
||||
$scope.newTables = [];
|
||||
$scope.newTables2 = [];
|
||||
$scope.roommap = [];
|
||||
$scope.newElement = 0;
|
||||
$('#create_table').hide();
|
||||
$('#create_place').show();
|
||||
$('#places').show();
|
||||
$('#background').hide();
|
||||
$('#save_tables').hide();
|
||||
$('#save_places').hide();
|
||||
$('#back').hide();
|
||||
|
||||
|
||||
$scope.getRoomMap = function () {
|
||||
smartRequest.get('v1/roommap?type=full', function (data) {
|
||||
$('#back').hide();
|
||||
$('#save_tables').hide();
|
||||
$('#save_places').hide();
|
||||
$scope.roommap = data.roommap;
|
||||
Notification.success(data.status);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getRoomMap();
|
||||
|
||||
$scope.alignTables = function () {
|
||||
$scope.tables.forEach(function (table) {
|
||||
var newArr = [];
|
||||
var goal = table.x;
|
||||
$scope.tables.forEach(function (el) {
|
||||
var middle = Math.abs(goal - el.x);
|
||||
if (middle <= 15) {
|
||||
newArr.push(el);
|
||||
}
|
||||
});
|
||||
let xSum = 0;
|
||||
const len = newArr.length;
|
||||
let item = null;
|
||||
for (let i = 0; i < len; i++) {
|
||||
item = newArr[i];
|
||||
xSum = item.x + xSum;
|
||||
}
|
||||
const averageX = Math.round(xSum / len);
|
||||
newArr.forEach(function (el) {
|
||||
$scope.tables.forEach((elem) => elem.id === el.id ? elem.x = averageX : elem.x = elem.x);
|
||||
});
|
||||
});
|
||||
$scope.tables.forEach(function (table) {
|
||||
var newArr = [];
|
||||
var goal = table.y;
|
||||
$scope.tables.forEach(function (el) {
|
||||
var middle = Math.abs(goal - el.y);
|
||||
if (middle <= 15) {
|
||||
newArr.push(el);
|
||||
}
|
||||
});
|
||||
let ySum = 0;
|
||||
const len = newArr.length;
|
||||
let item = null;
|
||||
for (let i = 0; i < len; i++) {
|
||||
item = newArr[i];
|
||||
ySum = item.y + ySum;
|
||||
}
|
||||
const averageY = Math.round(ySum / len);
|
||||
newArr.forEach(function (el) {
|
||||
$scope.tables.forEach((elem) => elem.id === el.id ? elem.y = averageY : elem.y = elem.y);
|
||||
});
|
||||
});
|
||||
$('#save_tables').show();
|
||||
$('#back').show();
|
||||
return $scope.tables;
|
||||
};
|
||||
|
||||
$scope.getTables = function (place_id) {
|
||||
|
||||
$('#places').hide();
|
||||
$('#background').show();
|
||||
$('#create_table').show();
|
||||
$('#create_place').hide();
|
||||
$('#back').show();
|
||||
$scope.maxWidth = 1024;
|
||||
$scope.windowHeight = window.innerHeight - (document.getElementById('view').clientHeight - document.getElementById('tables').clientHeight);
|
||||
$scope.screenHeight = screen.height;
|
||||
$scope.windowWidth = window.innerWidth;
|
||||
$scope.screenWidth = 69;
|
||||
|
||||
smartRequest.get('v1/roommap?type=place&id=' + place_id, function (data) {
|
||||
$scope.place = data.place;
|
||||
$scope.place_id = data.place_id;
|
||||
Notification.success(data.status);
|
||||
$scope.left = document.getElementById('tables').getBoundingClientRect().left;
|
||||
$scope.top = parseInt(document.getElementById('view').clientHeight) - parseInt(document.getElementById('background_1').offsetHeight) - 2;
|
||||
$scope.percentWidth = document.getElementById('tables').clientWidth / 1024;
|
||||
$scope.percentHeight = document.getElementById('tables').clientHeight / 768;
|
||||
$scope.tables = data.tables;
|
||||
console.log($scope.tables);
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.getCoords = function ($event, $index, table_id, place) {
|
||||
switch ($event.which) {
|
||||
case 1:
|
||||
var id = '#table_' + $index;
|
||||
$scope.element = $(id);
|
||||
$scope.parentOffset = $scope.element.offset();
|
||||
var parentPos = document.getElementById('tables').getBoundingClientRect(),
|
||||
childrenPos = document.getElementById('table_' + $index).getBoundingClientRect(),
|
||||
relativePos = {};
|
||||
|
||||
relativePos.top = childrenPos.top - parentPos.top,
|
||||
relativePos.right = childrenPos.right - parentPos.right,
|
||||
relativePos.bottom = childrenPos.bottom - parentPos.bottom,
|
||||
relativePos.left = childrenPos.left - parentPos.left;
|
||||
|
||||
$('#save_tables').show();
|
||||
|
||||
$scope.tables[$index].width = Math.round(document.getElementById('table_' + $index).offsetWidth / $scope.percentWidth),
|
||||
$scope.tables[$index].height = Math.round(document.getElementById('table_' + $index).offsetHeight / $scope.percentHeight),
|
||||
$scope.tables[$index].x = Math.round(relativePos.top / $scope.percentHeight),
|
||||
$scope.tables[$index].y = Math.round(relativePos.left / $scope.percentWidth);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.deleteTable = function (table_id) {
|
||||
delete $scope.tables.splice(table_id, 1);
|
||||
$('#save_tables').show();
|
||||
return $scope.tables;
|
||||
};
|
||||
|
||||
$scope.duplicateTable = function (index, place) {
|
||||
$scope.newTable = {};
|
||||
$scope.lastEl = $scope.tables.length;
|
||||
$scope.newTable.id = $scope.tables[$scope.lastEl - 1].id + 1,
|
||||
$scope.newTable.place_id = $scope.tables[index].place_id,
|
||||
$scope.newTable.table_id = $scope.tables[$scope.lastEl - 1].table_id + 1,
|
||||
$scope.newTable.name = $scope.tables[index].name,
|
||||
$scope.newTable.width = $scope.tables[index].width,
|
||||
$scope.newTable.height = $scope.tables[index].height,
|
||||
$scope.newTable.x = $scope.tables[index].x + 50,
|
||||
$scope.newTable.y = $scope.tables[index].y + 50;
|
||||
$scope.tables.push($scope.newTable);
|
||||
$('#save_tables').show();
|
||||
return $scope.tables;
|
||||
};
|
||||
|
||||
$scope.editTable = function ($index, table) {
|
||||
$('#table-edit').modal('show');
|
||||
$scope.tableWidth = table.width;
|
||||
$scope.tableHeight = table.height;
|
||||
$scope.tableName = table.name;
|
||||
$scope.tableId = table.table_id;
|
||||
$scope.tableIndex = $index;
|
||||
|
||||
$('#save_tables').show();
|
||||
return $scope.tables;
|
||||
};
|
||||
|
||||
$scope.saveTable = function (index, id, name, width, height) {
|
||||
$('#table-edit').modal('toggle');
|
||||
$scope.tables[index].width = width,
|
||||
$scope.tables[index].height = height,
|
||||
$scope.tables[index].name = name,
|
||||
$scope.tables[index].table_id = id;
|
||||
|
||||
$('#save_tables').show();
|
||||
return $scope.tables;
|
||||
};
|
||||
|
||||
$scope.back = function () {
|
||||
$('#places').show();
|
||||
$('#background').hide();
|
||||
$('#create_table').hide();
|
||||
$('#create_place').show();
|
||||
$('#save_tables').hide();
|
||||
$('#back').hide();
|
||||
$scope.tables = [];
|
||||
};
|
||||
|
||||
$scope.saveTables = function (place_id, tables) {
|
||||
console.log(tables);
|
||||
|
||||
smartRequest.post('v1/roommap', {
|
||||
type: 'table',
|
||||
action: 'savetables',
|
||||
place_id: place_id,
|
||||
tables: JSON.stringify(tables),
|
||||
}, function (data) {
|
||||
$scope.tables = [];
|
||||
Notification.success(data.message);
|
||||
$scope.back();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.deletePlace = function (index) {
|
||||
console.log(index);
|
||||
delete $scope.roommap.splice(index, 1);
|
||||
$('#save_places').show();
|
||||
return $scope.roommap;
|
||||
};
|
||||
|
||||
$scope.editPlace = function (index) {
|
||||
|
||||
};
|
||||
|
||||
$scope.savePlace = function (index) {
|
||||
|
||||
};
|
||||
|
||||
$scope.savePlaces = function (places) {
|
||||
console.log(places);
|
||||
smartRequest.post('v1/roommap', {
|
||||
type: 'place',
|
||||
action: 'saveplaces',
|
||||
places: JSON.stringify(places),
|
||||
}, function (data) {
|
||||
Notification.success(data.message);
|
||||
/*$scope.getRoomMap();*/
|
||||
});
|
||||
};
|
||||
}
|
||||
})();
|
||||
@@ -111,7 +111,7 @@
|
||||
};
|
||||
|
||||
$scope.reportDelete = function (shift) {
|
||||
smartRequest.get('report/deleted?shift_id=' + shift.id, function (data) {
|
||||
smartRequest.get('v1/datareport?type=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;
|
||||
|
||||
Reference in New Issue
Block a user