v.2.12
-Add new setting "Delete shift" -Move "Shift" frontend to V1 module
This commit is contained in:
51
web/controllers/market.js
Normal file
51
web/controllers/market.js
Normal file
@@ -0,0 +1,51 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app')
|
||||
.controller('MarketCtrl', MarketCtrl);
|
||||
|
||||
MarketCtrl.$inject = ['$scope', 'smartRequest', '$location', 'Notification'];
|
||||
function MarketCtrl($scope, smartRequest, $location, Notification) {
|
||||
|
||||
$scope.key = '';
|
||||
|
||||
$scope.getListModules = function () {
|
||||
smartRequest.get('settings/pay/modules', function (data) {
|
||||
$scope.modules = data.modules;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showModuleActivate = function (id) {
|
||||
$scope.selectedModule = $scope.getModulerById(id);
|
||||
$('#activate-module').modal();
|
||||
};
|
||||
|
||||
$scope.activateModule = function () {
|
||||
$('#btn-activated').prop('disabled', false);
|
||||
smartRequest.post('settings/activate/module', {
|
||||
key: $scope.key,
|
||||
module: $scope.selectedModule.name,
|
||||
}, function(data) {
|
||||
if (data.message == 'Активация прошла успешно') {
|
||||
Notification.success(data.message);
|
||||
$location.path('/');
|
||||
} else {
|
||||
Notification.error(data.message);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getModulerById = function(id) {
|
||||
var res;
|
||||
$scope.modules.forEach(function (item) {
|
||||
if (item.id == id) {
|
||||
res = item;
|
||||
return;
|
||||
}
|
||||
});
|
||||
return res;
|
||||
};
|
||||
|
||||
$scope.getListModules();
|
||||
}
|
||||
})();
|
||||
62
web/controllers/modules.js
Normal file
62
web/controllers/modules.js
Normal file
@@ -0,0 +1,62 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app')
|
||||
.controller('ModulesCtrl', ModulesCtrl);
|
||||
|
||||
ModulesCtrl.$inject = ['$scope', 'smartRequest', '$location', 'Notification'];
|
||||
function ModulesCtrl($scope, smartRequest, $location, Notification) {
|
||||
$scope.modules = [];
|
||||
$scope.isAllSelected = false;
|
||||
|
||||
$scope.getListModules = function () {
|
||||
smartRequest.get('settings/modules', function (data) {
|
||||
$scope.modules = data.modules.modules;
|
||||
|
||||
$scope.modules.forEach(function (el) {
|
||||
el.selected = false;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.toggleAll = function () {
|
||||
var toggleStatus = !$scope.isAllSelected;
|
||||
angular.forEach($scope.modules, function (itm) { itm.selected = toggleStatus; });
|
||||
$scope.isAllSelected = toggleStatus;
|
||||
};
|
||||
|
||||
$scope.optionToggled = function () {
|
||||
$scope.isAllSelected = $scope.modules.every(function (itm) { return itm.selected; });
|
||||
};
|
||||
|
||||
$scope.updateModules = function () {
|
||||
$scope.buttonDownload(true);
|
||||
smartRequest.post('settings/update/modules', {
|
||||
'modules': JSON.stringify($scope.toObject($scope.getSelectedModules()))
|
||||
}, function(data) {
|
||||
Notification.success('Модули обновлены');
|
||||
$scope.getListModules();
|
||||
$scope.buttonDownload(false);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getSelectedModules = function () {
|
||||
return $scope.modules.filter(function (el) {
|
||||
return el.selected;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.toObject = function (arr) {
|
||||
var rv = {};
|
||||
for (var i = 0; i < arr.length; i++)
|
||||
rv[i] = arr[i];
|
||||
return rv;
|
||||
};
|
||||
|
||||
$scope.buttonDownload = function(toggle) {
|
||||
$('#btn-download').prop('disabled', toggle);
|
||||
};
|
||||
|
||||
$scope.getListModules();
|
||||
}
|
||||
})();
|
||||
49
web/controllers/settings.js
Normal file
49
web/controllers/settings.js
Normal file
@@ -0,0 +1,49 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app')
|
||||
.controller('SettingsCtrl', SettingsCtrl);
|
||||
|
||||
SettingsCtrl.$inject = ['$scope', 'smartRequest', 'Notification'];
|
||||
function SettingsCtrl($scope, smartRequest, Notification) {
|
||||
$scope.settings = [];
|
||||
$scope.terminalKey = '';
|
||||
$scope.menuCode = '';
|
||||
|
||||
$scope.listSettings = function () {
|
||||
$scope.settings = [];
|
||||
|
||||
smartRequest.get('settings/all?global=0', function (data) {
|
||||
$scope.settings = $scope.settings.concat(data.settings);
|
||||
});
|
||||
|
||||
smartRequest.get('v1/settings', function (data) {
|
||||
$scope.settings = $scope.settings.concat(data.settings);
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
$scope.onSettingChange = function (setting) {
|
||||
if (setting.value.length > 0) {
|
||||
smartRequest.post('settings/update', {
|
||||
code: setting.code,
|
||||
value: setting.value
|
||||
});
|
||||
Notification.success('Настройки обновлены');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.getRealisation = function() {
|
||||
smartRequest.get('sync/realisation?terminal=' + $scope.terminalKey + '&menu=' + $scope.menuCode, function(data) {
|
||||
});
|
||||
};
|
||||
|
||||
$scope.switchDishes = function() {
|
||||
smartRequest.get('sync/replace/dishes', function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
};
|
||||
|
||||
$scope.listSettings();
|
||||
}
|
||||
})();
|
||||
@@ -48,6 +48,30 @@
|
||||
$scope.countOfPages = data.pages;
|
||||
$scope.pages = $scope.makePages();
|
||||
});
|
||||
smartRequest.get('v1/settings?code=11', function (data) {
|
||||
$scope.delete_shift_value = data.value;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.deleteShift = function (shift) {
|
||||
$('#preload-modal').modal();
|
||||
Notification.primary('Дождитесь удаления! Страница обновится автоматически.');
|
||||
smartRequest.post('v1/deletedata', {
|
||||
value: 'delete_shift',
|
||||
shift_id: shift.id
|
||||
}, function (data) {
|
||||
$scope.status = data.status;
|
||||
$scope.message = data.message;
|
||||
if (data.status == 'success') {
|
||||
Notification.success(data.message);
|
||||
setTimeout(function() {
|
||||
location.reload();
|
||||
}, 1000);
|
||||
}
|
||||
if ($scope.status == 'error') {
|
||||
Notification.error(data.message);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.reportDelete = function (shift) {
|
||||
|
||||
183
web/controllers/terminals.js
Normal file
183
web/controllers/terminals.js
Normal file
@@ -0,0 +1,183 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app')
|
||||
.controller('TerminalsCtrl', TerminalsCtrl);
|
||||
|
||||
TerminalsCtrl.$inject = ['$scope', 'smartRequest', 'Notification'];
|
||||
function TerminalsCtrl($scope, smartRequest, Notification) {
|
||||
$scope.terminals = [];
|
||||
$scope.tasks = [];
|
||||
$scope.printers = [];
|
||||
|
||||
$scope.settings = {
|
||||
sizes: [56, 80],
|
||||
speeds: [4800, 9600, 19200, 38400, 57600, 115200],
|
||||
types: ['COM', 'LAN', 'Windows'],
|
||||
com_ports: ['COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9', 'COM10']
|
||||
};
|
||||
|
||||
$scope.terminal_id = 0;
|
||||
$scope.active_tasks = [];
|
||||
|
||||
$scope.terminalLogs = [];
|
||||
|
||||
$scope.update = function () {
|
||||
smartRequest.get('settings/terminals', function (data) {
|
||||
$scope.terminals = data.terminals;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.update();
|
||||
|
||||
$scope.onLicence = function (key, active) {
|
||||
if (active === false) {
|
||||
smartRequest.post('licence/reject', {
|
||||
'key': key
|
||||
},
|
||||
function () {
|
||||
$scope.update();
|
||||
},
|
||||
function () {
|
||||
$scope.update();
|
||||
});
|
||||
}
|
||||
else {
|
||||
smartRequest.post('licence/apply', {
|
||||
'key': key
|
||||
},
|
||||
function () {
|
||||
$scope.update();
|
||||
},
|
||||
function () {
|
||||
$scope.update();
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$scope.isTaskActive = function (task) {
|
||||
for (var i = 0; i < $scope.active_tasks.length; i++) {
|
||||
if (task.code == $scope.active_tasks[i].code) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
$scope.editTerminal = function (id) {
|
||||
$scope.terminal_id = id;
|
||||
|
||||
smartRequest.get('settings/update/list', function (data) {
|
||||
for (var i = 0; i < data.update_list.length; i++) {
|
||||
data.update_list[i].active = false;
|
||||
data.update_list[i].period = parseInt(data.update_list[i].default);
|
||||
}
|
||||
|
||||
$scope.all_tasks = data.update_list;
|
||||
});
|
||||
|
||||
smartRequest.get('settings/update/active?terminal=' + id, function (data) {
|
||||
for (var i = 0; i < data.update_list.length; i++) {
|
||||
data.update_list[i].active = true;
|
||||
data.update_list[i].period = parseInt(data.update_list[i].period);
|
||||
}
|
||||
|
||||
$scope.active_tasks = data.update_list;
|
||||
$('#edit-terminal').modal();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getEquipment = function (id) {
|
||||
smartRequest.get('v1/equipment?terminal=' + id, function (data) {
|
||||
$scope.printers = data.printers;
|
||||
$scope.groups = data.printer_groups;
|
||||
$scope.terminal_id = id;
|
||||
});
|
||||
$('#equipment').modal();
|
||||
};
|
||||
|
||||
$scope.updateEquipment = function (printer) {
|
||||
smartRequest.post('v1/printers', {
|
||||
terminal: $scope.terminal_id,
|
||||
id: printer.id,
|
||||
name: printer.name,
|
||||
ip_address: printer.ip,
|
||||
com_port: printer.com_port,
|
||||
type: printer.type,
|
||||
speed: printer.speed,
|
||||
group: printer.printer_group,
|
||||
template: printer.template,
|
||||
size: printer.size,
|
||||
driver: printer.driver,
|
||||
more: printer.more
|
||||
|
||||
}, function(data) {
|
||||
Notification.success('Данные принтера сохранены');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updateFiscal = function (fiscal) {
|
||||
smartRequest.post('v1/fiscals', {
|
||||
terminal: $scope.terminal_id,
|
||||
pass: fiscal.password,
|
||||
ip: fiscal.ip
|
||||
}, function(data) {
|
||||
Notification.success('Данные ФР изменены');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.addTask = function () {
|
||||
smartRequest.get('settings/equipment/task?terminal=' + $scope.terminal_id, function (data) {
|
||||
Notification.success('Задача запушена');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.objectHasProperty = function (object, name) {
|
||||
return object.hasOwnProperty(name);
|
||||
};
|
||||
|
||||
$scope.changeTask = function (task) {
|
||||
if (task.active) {
|
||||
smartRequest.post('settings/update/enable', {
|
||||
terminal: $scope.terminal_id,
|
||||
task: task.code,
|
||||
period: task.period
|
||||
});
|
||||
}
|
||||
else {
|
||||
smartRequest.post('settings/update/disable', {
|
||||
terminal: $scope.terminal_id,
|
||||
task: task.code
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.changePeriod = function (task) {
|
||||
if (task.active) {
|
||||
smartRequest.post('settings/update/enable', {
|
||||
terminal: $scope.terminal_id,
|
||||
task: task.code,
|
||||
period: task.period
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.runTask = function (task) {
|
||||
smartRequest.post('settings/update/force', {
|
||||
terminal: $scope.terminal_id,
|
||||
task: task.code
|
||||
}, function (data) {
|
||||
Notification.success('Задача запушена');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.showLogs = function (terminal_key) {
|
||||
smartRequest.get('settings/terminal/logs?terminal=' + terminal_key, function (data) {
|
||||
$scope.terminalLogs = data.logs;
|
||||
$('#logs').modal();
|
||||
});
|
||||
};
|
||||
}
|
||||
})();
|
||||
19
web/controllers/user_logs.js
Normal file
19
web/controllers/user_logs.js
Normal file
@@ -0,0 +1,19 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app')
|
||||
.controller('UserLogCtrl', UserLogCtrl);
|
||||
|
||||
UserLogCtrl.$inject = ['$scope', 'smartRequest', '$rootScope'];
|
||||
function UserLogCtrl($scope, smartRequest, $rootScope) {
|
||||
$scope.logs = [];
|
||||
|
||||
$scope.getLogs = function() {
|
||||
smartRequest.get('log/user/list', function(data) {
|
||||
$scope.logs = data.logs;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getLogs();
|
||||
}
|
||||
})();
|
||||
104
web/controllers/users.js
Normal file
104
web/controllers/users.js
Normal file
@@ -0,0 +1,104 @@
|
||||
(function() {
|
||||
'use strict';
|
||||
angular
|
||||
.module('app')
|
||||
.controller('UsersCtrl', UsersCtrl);
|
||||
|
||||
UsersCtrl.$inject = ['$scope', 'smartRequest', '$rootScope'];
|
||||
function UsersCtrl($scope, smartRequest, $rootScope) {
|
||||
$scope.users = [];
|
||||
$scope.currentUser = {};
|
||||
$scope.newUser = {};
|
||||
|
||||
$scope.update = function() {
|
||||
smartRequest.get('settings/users/list', function(data) {
|
||||
$scope.users = data.users;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.edit = function(user) {
|
||||
$scope.currentUser = user;
|
||||
$scope.allRights = [];
|
||||
|
||||
smartRequest.get('right/all', function(data) {
|
||||
$scope.allRights = data.rights;
|
||||
|
||||
smartRequest.get('right/user?id=' + $scope.currentUser.id, function(data) {
|
||||
for (var i = 0; i < $scope.allRights.length; i++) {
|
||||
$scope.allRights[i].is_active = false;
|
||||
|
||||
for (var j = 0; j < data.rights.length; j++) {
|
||||
if($scope.allRights[i].code === data.rights[j].code) {
|
||||
$scope.allRights[i].is_active = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$scope.currentUser.rights = $scope.allRights;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('#edit-user').modal();
|
||||
};
|
||||
|
||||
$scope.save = function() {
|
||||
$('#edit-user').modal('toggle');
|
||||
|
||||
smartRequest.post('settings/users/edit', {
|
||||
id: $scope.currentUser.id,
|
||||
name: $scope.currentUser.name,
|
||||
login: $scope.currentUser.login,
|
||||
password: $scope.currentUser.password
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.delete = function() {
|
||||
$('#edit-user').modal('toggle');
|
||||
$('#edit-user-confirm-delete').modal('toggle');
|
||||
|
||||
smartRequest.post('settings/users/delete', {
|
||||
id: $scope.currentUser.id
|
||||
}, function(data) {
|
||||
$scope.currentUser = {};
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.add = function() {
|
||||
$scope.newUser = {};
|
||||
|
||||
$('#new-user').modal();
|
||||
};
|
||||
|
||||
$scope.create = function() {
|
||||
$('#new-user').modal('toggle');
|
||||
|
||||
smartRequest.post('settings/users/add', {
|
||||
name: $scope.newUser.name,
|
||||
login: $scope.newUser.login,
|
||||
password: $scope.newUser.password
|
||||
}, function(data) {
|
||||
$scope.update();
|
||||
});
|
||||
};
|
||||
|
||||
$scope.onRight = function(code) {
|
||||
smartRequest.post('right/toggle', {
|
||||
id: $scope.currentUser.id,
|
||||
code: code
|
||||
}, function(data) {
|
||||
smartRequest.get('right/list', function(data) {
|
||||
$rootScope.globals.currentUser.rights = data.rights;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.update();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user