diff --git a/commands/GETSettings.php b/commands/GETSettings.php new file mode 100644 index 0000000..e1fada4 --- /dev/null +++ b/commands/GETSettings.php @@ -0,0 +1,36 @@ +first(); + if ($setting) { + return [ + 'status' => 'success', + 'name' => $setting['name'], + 'code' => $setting['code'], + 'value' => $setting['value'], + ]; + } else { + return [ + 'status' => 'error', + 'more' => 'Setting not found', + ]; + } + } else { + $settings = Settings::all(); + return [ + 'status' => 'success', + 'settings' => $settings, + ]; + } + } +} \ No newline at end of file diff --git a/commands/POSTDeleteData.php b/commands/POSTDeleteData.php new file mode 100644 index 0000000..6066cd0 --- /dev/null +++ b/commands/POSTDeleteData.php @@ -0,0 +1,86 @@ +first(); + $exchange_orders = ExchangeOrders::where('shift_id', '=', $input['shift_id'])->get(); + $exchange_items = ExchangeItems::where('shift_id', '=', $input['shift_id'])->get(); + $exchange_actions = ExchangeActions::where('shift_id', '=', $input['shift_id'])->get(); + $exchange_deleted = ExchangeDeleted::where('shift_id', '=', $input['shift_id'])->get(); + if ($exchange_shift) { + $exchange_shift = ExchangeShifts::find($input['shift_id']); + $exchange_shift->delete(); + } + if ($exchange_orders) { + foreach ($exchange_orders as $key => $exchange_order) { + $order = ExchangeOrders::find($exchange_order['id']); + $order->delete(); + } + } + if ($exchange_items) { + foreach ($exchange_items as $key => $exchange_item) { + $item = ExchangeItems::find($exchange_item['id']); + $item->delete(); + } + } + if ($exchange_actions) { + foreach ($exchange_actions as $key => $exchange_action) { + $action = ExchangeActions::find($exchange_action['id']); + $action->delete(); + } + } + if ($exchange_deleted) { + foreach ($exchange_deleted as $key => $exchange_delete) { + $delete = ExchangeDeleted::find($exchange_delete['id']); + $delete->delete(); + } + } + function dirDel($dir) { + $d = opendir($dir); + while (($entry = readdir($d)) !== false) { + if ($entry != "." && $entry != "..") { + if (is_dir($dir . "/" . $entry)) { + dirDel($dir . "/" . $entry); + } else { + unlink($dir . "/" . $entry); + } + } + } + closedir($d); + rmdir($dir); + } + $cache_dir = __DIR__ . "\\..\\..\\..\\Cache\\"; + dirDel($cache_dir); + return [ + 'status' => 'success', + 'message' => 'Данные удалены', + ]; + + } else { + return [ + 'status' => 'error', + 'message' => 'Check input data', + ]; + } + } else { + return [ + 'status' => 'error', + 'message' => 'Check input data', + ]; + } + } +} \ No newline at end of file diff --git a/composer.json b/composer.json index 0b0501f..66e956e 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "hrc-admin/hello-world", - "version": "2.11", + "version": "2.12", "require": { "horeca/admin-php-module-core": "dev-master" }, diff --git a/database/migrations/2022_02_01_014430_delete_settings_frontend_folder.php b/database/migrations/2022_02_01_014430_delete_settings_frontend_folder.php new file mode 100644 index 0000000..a5670eb --- /dev/null +++ b/database/migrations/2022_02_01_014430_delete_settings_frontend_folder.php @@ -0,0 +1,42 @@ +where('code', 11)->first(); + if (!$check_setting) { + $setting = new Settings; + $setting->name = 'Удаление смен'; + $setting->value = '0'; + $setting->code = 11; + $setting->is_common = 1; + $setting->save(); + } + } +} diff --git a/module.ini b/module.ini index 48175fa..9cb601b 100644 --- a/module.ini +++ b/module.ini @@ -1,5 +1,5 @@ [info] name=V1 -version=2.11 +version=2.12 [build] -version=2.11 +version=2.12 diff --git a/web/controllers/market.js b/web/controllers/market.js new file mode 100644 index 0000000..ececf1b --- /dev/null +++ b/web/controllers/market.js @@ -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(); + } +})(); \ No newline at end of file diff --git a/web/controllers/modules.js b/web/controllers/modules.js new file mode 100644 index 0000000..09bcb64 --- /dev/null +++ b/web/controllers/modules.js @@ -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(); + } +})(); \ No newline at end of file diff --git a/web/controllers/settings.js b/web/controllers/settings.js new file mode 100644 index 0000000..627061e --- /dev/null +++ b/web/controllers/settings.js @@ -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(); + } +})(); \ No newline at end of file diff --git a/web/controllers/shifts.js b/web/controllers/shifts.js index a3d903f..07c8c39 100644 --- a/web/controllers/shifts.js +++ b/web/controllers/shifts.js @@ -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) { diff --git a/web/controllers/terminals.js b/web/controllers/terminals.js new file mode 100644 index 0000000..cdf2766 --- /dev/null +++ b/web/controllers/terminals.js @@ -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(); + }); + }; + } +})(); \ No newline at end of file diff --git a/web/controllers/user_logs.js b/web/controllers/user_logs.js new file mode 100644 index 0000000..dab0f6f --- /dev/null +++ b/web/controllers/user_logs.js @@ -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(); + } +})(); \ No newline at end of file diff --git a/web/controllers/users.js b/web/controllers/users.js new file mode 100644 index 0000000..6e26cdf --- /dev/null +++ b/web/controllers/users.js @@ -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(); + } +})(); \ No newline at end of file diff --git a/web/menu_min.js b/web/menu_min.js index 2931d12..a4594c2 100644 --- a/web/menu_min.js +++ b/web/menu_min.js @@ -37,5 +37,37 @@ item: [ url: 'app.reports' } ] + }, + { + name: 'Терминалы', + acl: 'terminals', + url: 'app.terminals', + icon: 'desktop_windows', + order: 100 + }, + { + name: 'Пользователи', + acl: 'users', + icon: 'account_box', + order: 101, + items: [ + { + name: 'Управление', + acl: 'users', + url: 'app.users' + }, + { + name: 'Логи', + acl: 'users', + url: 'app.user_logs' + } + ] + }, + { + name: 'Настройки', + acl: 'settings', + url: 'app.settings', + icon: 'settings', + order: 102 } ]; \ No newline at end of file diff --git a/web/routes_min.js b/web/routes_min.js index 8e55618..596dc92 100644 --- a/web/routes_min.js +++ b/web/routes_min.js @@ -45,4 +45,36 @@ data: {title: 'Отчеты'}, controller: 'ReportsCtrl', resolve: ['scripts/controllers/reports.js', 'moment', 'datetimepicker', 'select2'] +}, +{ + code: 'app.users', + url: '/users', + templateUrl: '../views/users/index.html', + data: {title: 'Пользователи'}, + controller: 'UsersCtrl', + resolve: ['scripts/controllers/users.js'] +}, +{ + code: 'app.settings', + url: '/settings', + templateUrl: '../views/settings/index.html', + data: {title: 'Настройки'}, + controller: 'SettingsCtrl', + resolve: ['scripts/controllers/settings.js'] +}, +{ + code: 'app.terminals', + url: '/terminals', + templateUrl: '../views/terminals/index.html', + data: { title : 'Терминалы' }, + controller: 'TerminalsCtrl', + resolve: ['scripts/controllers/terminals.js'] +}, +{ + code: 'app.user_logs', + url: '/logs', + templateUrl: '../views/users/logs.html', + data: { title : 'Логи пользователей' }, + controller: 'UserLogCtrl', + resolve: ['scripts/controllers/user_logs.js'] } \ No newline at end of file diff --git a/web/views/modules/index.html b/web/views/modules/index.html new file mode 100644 index 0000000..6590f48 --- /dev/null +++ b/web/views/modules/index.html @@ -0,0 +1,34 @@ +
+
+
+

Доступные обновления модулей

+

Нет доступных обновлений

+ +
+
+
+ + + + + + + + + + + + +
Выбрать все
+ + {{ module.name }} +
У вас установлена версия {{ module.version }}. + Обновите до {{ module.l_version }} +
+
+
+ +
+
+
+
\ No newline at end of file diff --git a/web/views/modules/items/activate.html b/web/views/modules/items/activate.html new file mode 100644 index 0000000..6af1452 --- /dev/null +++ b/web/views/modules/items/activate.html @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/web/views/modules/marketplace.html b/web/views/modules/marketplace.html new file mode 100644 index 0000000..fc8747e --- /dev/null +++ b/web/views/modules/marketplace.html @@ -0,0 +1,29 @@ +
+

Дополнительные модули

+ +
+
+
+
+ +
+
+
+ {{ module.name }} +
+ Автор: {{ module.author }} +
+

{{ module.description }}

+
+
+ +
+
+
+
+
+
+ + \ No newline at end of file diff --git a/web/views/settings/index.html b/web/views/settings/index.html new file mode 100644 index 0000000..a2c7e70 --- /dev/null +++ b/web/views/settings/index.html @@ -0,0 +1,57 @@ +
+
+
+ + + + + + + + + + + + + +
ПараметрЗначение
{{ setting.name }} + +
+
+
+
+ +
+
+
+

Импорт реализации

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

Перенос кодов

+
+
+ +
+
+
\ No newline at end of file diff --git a/web/views/shifts/index.html b/web/views/shifts/index.html index 290f1fd..341ef30 100644 --- a/web/views/shifts/index.html +++ b/web/views/shifts/index.html @@ -59,6 +59,7 @@ По отделам По внешним заказам Восстановить смену + Удалить смену diff --git a/web/views/terminals/edit.html b/web/views/terminals/edit.html new file mode 100644 index 0000000..fbfe39e --- /dev/null +++ b/web/views/terminals/edit.html @@ -0,0 +1,50 @@ + \ No newline at end of file diff --git a/web/views/terminals/equipment.html b/web/views/terminals/equipment.html new file mode 100644 index 0000000..319b49f --- /dev/null +++ b/web/views/terminals/equipment.html @@ -0,0 +1,118 @@ + \ No newline at end of file diff --git a/web/views/terminals/index.html b/web/views/terminals/index.html new file mode 100644 index 0000000..a742c18 --- /dev/null +++ b/web/views/terminals/index.html @@ -0,0 +1,74 @@ +
+
+ +
+ +
+

+ +

+

+ +

+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
IDТипКод рабочей группыКод рабочего местаСтатусПоследняя активность
{{ terminal.key }}{{ terminal.soft }}{{ terminal.work_group }}{{ terminal.work_code }} + + {{ terminal.last_activity }} + +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/web/views/terminals/logs.html b/web/views/terminals/logs.html new file mode 100644 index 0000000..4708cfe --- /dev/null +++ b/web/views/terminals/logs.html @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/web/views/terminals/reports/delete.html b/web/views/terminals/reports/delete.html new file mode 100644 index 0000000..27c91da --- /dev/null +++ b/web/views/terminals/reports/delete.html @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/web/views/users/create.html b/web/views/users/create.html new file mode 100644 index 0000000..0e5510b --- /dev/null +++ b/web/views/users/create.html @@ -0,0 +1,27 @@ + \ No newline at end of file diff --git a/web/views/users/edit.html b/web/views/users/edit.html new file mode 100644 index 0000000..9f37643 --- /dev/null +++ b/web/views/users/edit.html @@ -0,0 +1,51 @@ + \ No newline at end of file diff --git a/web/views/users/index.html b/web/views/users/index.html new file mode 100644 index 0000000..228a12d --- /dev/null +++ b/web/views/users/index.html @@ -0,0 +1,58 @@ +
+
+ +
+ +
+ +
+ +
+

+

+
+
+ +
+
+
+ + + + + + + + + + + + + + + +
IDЛогинИмя
{{ user.id }}{{ user.login }}{{ user.name }}
+
+
+
+ + + + + + \ No newline at end of file diff --git a/web/views/users/logs.html b/web/views/users/logs.html new file mode 100644 index 0000000..21f3178 --- /dev/null +++ b/web/views/users/logs.html @@ -0,0 +1,33 @@ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Log IDUserModuleAction typeActionOld valueNew valueВремя
{{log.id}}{{log.user}}{{log.module}}{{log.action_type}}{{log.action}}{{log.old_value}}{{log.new_value}}{{log.time}}
+
+
+
\ No newline at end of file