From 26b5876513c6ccdba5f191d1739ed33385204748 Mon Sep 17 00:00:00 2001 From: mirzaev Date: Sat, 25 Feb 2023 22:55:21 +1000 Subject: [PATCH] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=20=D0=B8=D0=BD?= =?UTF-8?q?=D1=82=D0=B5=D1=80=D1=84=D0=B5=D0=B9=D1=81=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=84=D0=BD=D0=B0=D1=81=D1=82=D0=B8=D0=BB=D0=B0,=20=D0=BD?= =?UTF-8?q?=D0=B0=D1=87=D0=B0=D1=82=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=20=D0=BD=D0=B0=D0=B4=203=D0=B4=20=D1=81=D0=B5=D1=82?= =?UTF-8?q?=D0=BA=D0=BE=D0=B9=20=D0=B8=20=D0=B5=D0=B2=D1=80=D0=BE=D1=88?= =?UTF-8?q?=D1=82=D0=B0=D0=BA=D0=B5=D1=82=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/calculator_controller.php | 63 ++- .../calculator/system/public/js/calculator.js | 388 +++++++++--------- .../views/calculators/elements/fences/1.html | 3 +- .../views/calculators/elements/fences/2.html | 3 +- .../system/views/calculators/menu.html | 10 +- .../system/views/calculators/profnastil.html | 170 ++++---- .../system/views/calculators/setka.html | 83 ++++ psalm.xml | 16 - 8 files changed, 439 insertions(+), 297 deletions(-) create mode 100644 mirzaev/zkmr/calculator/system/views/calculators/setka.html delete mode 100644 psalm.xml diff --git a/mirzaev/zkmr/calculator/system/controllers/calculator_controller.php b/mirzaev/zkmr/calculator/system/controllers/calculator_controller.php index d0ff1d9..dfb0979 100644 --- a/mirzaev/zkmr/calculator/system/controllers/calculator_controller.php +++ b/mirzaev/zkmr/calculator/system/controllers/calculator_controller.php @@ -134,14 +134,11 @@ final class calculator_controller extends core } /** - * Лазерная резка + * Профнастил * - * HTML-код с калькулятором лазерной резки + * HTML-код с калькулятором профнастила * * @param array $vars Параметры - * - * @todo 1. Заголовок калькулятора должен находиться внутри элемента калькулятора - * 2. Ограничение значений полей в зависимости от выбранной марки */ public function profnastil(array $vars = []): ?string { @@ -150,8 +147,6 @@ final class calculator_controller extends core // Инициализация данных калькулятора $vars['calculators'] = ['profnastil' => [ - 'company' => settings::read('default_buyer', $vars['errors']['calculators']), - 'complexity' => settings::read('default_complexity', $vars['errors']['calculators']), 'width' => (int) round((float) settings::read('default_width', $vars['errors']['calculators'])), 'height' => (int) round((float) settings::read('default_height', $vars['errors']['calculators'])), 'length' => (int) round((float) settings::read('default_length', $vars['errors']['calculators'])), @@ -165,6 +160,60 @@ final class calculator_controller extends core return $this->view->render(DIRECTORY_SEPARATOR . 'calculators' . DIRECTORY_SEPARATOR . 'profnastil.html', $vars); } + /** + * 3D-сетка + * + * HTML-код с калькулятором 3D-сетки + * + * @param array $vars Параметры + */ + public function setka(array $vars = []): ?string + { + // Инициализация журнала ошибок + $vars['errors'] = ['calculators' => []]; + + // Инициализация данных калькулятора + $vars['calculators'] = ['profnastil' => [ + 'width' => (int) round((float) settings::read('default_width', $vars['errors']['calculators'])), + 'height' => (int) round((float) settings::read('default_height', $vars['errors']['calculators'])), + 'length' => (int) round((float) settings::read('default_length', $vars['errors']['calculators'])), + 'amount' => (int) round((float) settings::read('default_amount', $vars['errors']['calculators'])), + 'type' => settings::read('default_type', $vars['errors']['calculators']), + 'holes' => (int) round((float) settings::read('default_holes', $vars['errors']['calculators'])), + 'diameter' => (float) settings::read('default_diameter', $vars['errors']['calculators']) + ]]; + + // Генерация представления + return $this->view->render(DIRECTORY_SEPARATOR . 'calculators' . DIRECTORY_SEPARATOR . 'setka.html', $vars); + } + + /** + * Евроштакет + * + * HTML-код с калькулятором евроштакета + * + * @param array $vars Параметры + */ + public function evroshtaket(array $vars = []): ?string + { + // Инициализация журнала ошибок + $vars['errors'] = ['calculators' => []]; + + // Инициализация данных калькулятора + $vars['calculators'] = ['profnastil' => [ + 'width' => (int) round((float) settings::read('default_width', $vars['errors']['calculators'])), + 'height' => (int) round((float) settings::read('default_height', $vars['errors']['calculators'])), + 'length' => (int) round((float) settings::read('default_length', $vars['errors']['calculators'])), + 'amount' => (int) round((float) settings::read('default_amount', $vars['errors']['calculators'])), + 'type' => settings::read('default_type', $vars['errors']['calculators']), + 'holes' => (int) round((float) settings::read('default_holes', $vars['errors']['calculators'])), + 'diameter' => (float) settings::read('default_diameter', $vars['errors']['calculators']) + ]]; + + // Генерация представления + return $this->view->render(DIRECTORY_SEPARATOR . 'calculators' . DIRECTORY_SEPARATOR . 'evroshtaket.html', $vars); + } + /** * Расчёт * diff --git a/mirzaev/zkmr/calculator/system/public/js/calculator.js b/mirzaev/zkmr/calculator/system/public/js/calculator.js index 20a925e..f6f114d 100644 --- a/mirzaev/zkmr/calculator/system/public/js/calculator.js +++ b/mirzaev/zkmr/calculator/system/public/js/calculator.js @@ -1,96 +1,92 @@ -'use strict'; +"use strict"; -let calculator = { +const calculator = { index: document.getElementById("calculator"), calculators: [], account: [], settings: { defaults: { - buyer: 'individual', - complexity: 'medium', - } + }, }, init() { // Инициализация калькулятора - this.generate.buyer(this.settings.defaults.buyer) + this.generate.menu() .then( - success => { - this.generate.complexity(this.settings.defaults.complexity) + () => { + this.authenticate(cookie.read("id")) .then( - success => { - this.generate.menu() - .then( - success => { - this.authenticate(cookie.read('id')) - .then( - success => { - // Запись данных аккаунта - this.account = success; + (success) => { + // Запись данных аккаунта + this.account = success; - if (this.account !== undefined && typeof this.account === 'object' && this.account.permissions !== undefined) { - // Найден аккаунт + if ( + this.account !== undefined && + typeof this.account === "object" && + this.account.permissions !== undefined + ) { + // Найден аккаунт - if (this.account.permissions.calculate == 1) { - // Разрешено использовать калькулятор + if (this.account.permissions.calculate == 1) { + // Разрешено использовать калькулятор - this.generate.result(); - } - } - } - ); - } - ); - } + this.generate.result(); + } + } + }, ); - } + }, ); - console.log('[КАЛЬКУЛЯТОР] Инициализирован'); + console.log("[КАЛЬКУЛЯТОР] Инициализирован"); }, - authenticate(id) { + async authenticate(id) { // Запрос и генерация HTML с данными о типе покупателя (юр. лицо и физ. лицо)' - return fetch('/account/data?id=' + id, { + return await fetch("/account/data?id=" + id, { method: "POST", - headers: { "content-type": "application/x-www-form-urlencoded" } + headers: { "content-type": "application/x-www-form-urlencoded" }, }).then((response) => { if (response.status === 200) { return response.json().then( - success => { - console.log('[КАЛЬКУЛЯТОР] Загружены данные пользователя: ' + id); + (success) => { + console.log("[КАЛЬКУЛЯТОР] Загружены данные пользователя: " + id); return success; }, - error => { - console.log('[КАЛЬКУЛЯТОР] [ОШИБКА] Не удалось загрузить данные пользователя: ' + id); - } + () => { + console.log( + "[КАЛЬКУЛЯТОР] [ОШИБКА] Не удалось загрузить данные пользователя: " + + id, + ); + }, ); } }); }, - calculate() { + async calculate() { // Запрос и генерация HTML с данными о рассчете со всех калькуляторов // Инициализация параметров - let cutting = document.getElementById('cutting'); - let discount = document.getElementById('discount'); + const cutting = document.getElementById("cutting"); + const discount = document.getElementById("discount"); // Инициализация буфера запроса - let query = { + const query = { calculators: {}, cutting: +cutting.value ?? 0, - discount: +discount.value ?? 0 + discount: +discount.value ?? 0, }; for (const number in this.calculators) { // Перебор калькуляторов // Инициализация буфера запроса для нового калькулятора - query['calculators'][number] = {}; + query["calculators"][number] = {}; // Инициализация типа калькулятора - query['calculators'][number]['calculator'] = this.calculators[number].getAttribute('data-calculator'); + query["calculators"][number]["calculator"] = this.calculators[number] + .getAttribute("data-calculator"); for (const buyer of this.index.querySelectorAll('input[name="buyer"]')) { // Перебор полей с параметрами типа заказчика @@ -99,51 +95,69 @@ let calculator = { // Найдено выбранное поле // Запись в буфер запроса - query['calculators'][number]['buyer'] = buyer.value; + query["calculators"][number]["buyer"] = buyer.value; } } - for (const complexity of this.index.querySelectorAll('input[name="complexity"]')) { + for ( + const complexity of this.index.querySelectorAll( + 'input[name="complexity"]', + ) + ) { // Перебор полей с параметрами сложности if (complexity.checked) { // Найдено выбранное поле // Запись в буфер запроса - query['calculators'][number]['complexity'] = complexity.value; + query["calculators"][number]["complexity"] = complexity.value; } } - for (const field of this.calculators[number].querySelectorAll('[data-calculator-parameter]')) { + for ( + const field of this.calculators[number].querySelectorAll( + "[data-calculator-parameter]", + ) + ) { // Перебор полей с параметрами - if (field.getAttribute('type') === 'checkbox') { + if (field.getAttribute("type") === "checkbox") { // Флажок // Запись в буфер запроса - query['calculators'][number][field.getAttribute('data-calculator-parameter')] = field.checked; - } else if (field.getAttribute('type') === 'text' || field.getAttribute('type') === 'number' || field.getAttribute('type') === 'range') { + query["calculators"][number][ + field.getAttribute("data-calculator-parameter") + ] = field.checked; + } else if ( + field.getAttribute("type") === "text" || + field.getAttribute("type") === "number" || + field.getAttribute("type") === "range" + ) { // Текстовое, цифровое поле или ползунок // Запись в буфер запроса - query['calculators'][number][field.getAttribute('data-calculator-parameter')] = field.value; + query["calculators"][number][ + field.getAttribute("data-calculator-parameter") + ] = field.value; } else { // Элемент с тегом - - + diff --git a/mirzaev/zkmr/calculator/system/views/calculators/elements/fences/2.html b/mirzaev/zkmr/calculator/system/views/calculators/elements/fences/2.html index dc29109..6c87982 100644 --- a/mirzaev/zkmr/calculator/system/views/calculators/elements/fences/2.html +++ b/mirzaev/zkmr/calculator/system/views/calculators/elements/fences/2.html @@ -2,7 +2,8 @@
diff --git a/mirzaev/zkmr/calculator/system/views/calculators/menu.html b/mirzaev/zkmr/calculator/system/views/calculators/menu.html index 3ce7566..b5c261c 100644 --- a/mirzaev/zkmr/calculator/system/views/calculators/menu.html +++ b/mirzaev/zkmr/calculator/system/views/calculators/menu.html @@ -1,6 +1,14 @@ diff --git a/mirzaev/zkmr/calculator/system/views/calculators/profnastil.html b/mirzaev/zkmr/calculator/system/views/calculators/profnastil.html index 11540c4..65b2542 100644 --- a/mirzaev/zkmr/calculator/system/views/calculators/profnastil.html +++ b/mirzaev/zkmr/calculator/system/views/calculators/profnastil.html @@ -1,99 +1,97 @@ -

Лазерная резка

+

Забор из профнастила

-
- -
- -
-
- -
- -
- -
-
- -
- -
- -
-
- - {% include 'calculators/elements/fences/1.html' %} - -
- -
- -
-
- +
+
- -
- - мм - x - - мм - x - - мм -
+
+
+
+
- -
- - шт - x - - мм -
+
+
+
+
- -
- - шт -
+
+
+ {% include 'calculators/elements/fences/1.html' %} + +
+
- -
- -
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + м +
+
+ +
+ +
+ + шт +
+
+ +
+ +
+ + шт +
+
diff --git a/mirzaev/zkmr/calculator/system/views/calculators/setka.html b/mirzaev/zkmr/calculator/system/views/calculators/setka.html new file mode 100644 index 0000000..51b0f1c --- /dev/null +++ b/mirzaev/zkmr/calculator/system/views/calculators/setka.html @@ -0,0 +1,83 @@ +

Забор из профнастила

+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + м +
+
+ +
+ +
+ + шт +
+
+ +
+ +
+ + шт +
+
+
diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index a78ce42..0000000 --- a/psalm.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - -