From f6d090f2503cb61237afd3855ec8dcaf8ea4eec1 Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Thu, 18 Jan 2024 01:41:58 +0700 Subject: [PATCH] fix #31 fix #35 fix #39 fix #40 fix #41 fix #42 fix #43 fix #47 fix #49 --- README.md | 11 +-- mirzaev/ebala/system/controllers/account.php | 12 ++- mirzaev/ebala/system/controllers/core.php | 2 +- mirzaev/ebala/system/controllers/market.php | 15 ++-- mirzaev/ebala/system/controllers/session.php | 17 ++-- mirzaev/ebala/system/controllers/task.php | 82 ++++++++++--------- mirzaev/ebala/system/controllers/worker.php | 18 ++-- mirzaev/ebala/system/models/account.php | 12 +-- mirzaev/ebala/system/models/core.php | 65 +++++++++++++++ mirzaev/ebala/system/models/task.php | 4 +- .../public/css/pages/administrators.css | 6 -- .../ebala/system/public/css/pages/markets.css | 16 ++-- .../system/public/css/pages/operators.css | 4 - .../ebala/system/public/css/pages/tasks.css | 20 ++++- .../ebala/system/public/css/pages/workers.css | 18 ++-- mirzaev/ebala/system/public/js/markets.js | 4 +- mirzaev/ebala/system/views/elements/chat.html | 2 +- .../system/views/elements/lists/market.html | 6 +- .../views/elements/lists/task/passed.html | 2 +- .../system/views/elements/lists/worker.html | 14 ++-- .../ebala/system/views/elements/markets.html | 2 +- .../ebala/system/views/elements/tasks.html | 4 +- .../ebala/system/views/elements/workers.html | 2 +- mirzaev/ebala/system/views/lists/markets.html | 2 +- mirzaev/ebala/system/views/lists/workers.html | 2 +- .../system/views/pages/entry/market.html | 4 +- 26 files changed, 218 insertions(+), 128 deletions(-) diff --git a/README.md b/README.md index b841141..b682cfd 100755 --- a/README.md +++ b/README.md @@ -1,10 +1,5 @@ # Ebala -### Site for providing outsourced employees to retail stores +Site-registry of tasks for outsourced employees -My customer uses this development to process thousands of applications throughout Krasnoyarsk and neighboring cities.
-**9 000 000** Russian rubles pass through the site every **week** 🀟. - -For this project I received **600 000** Russian rubles. At the current exchange rate this is **$6000**.
-If I had not been lazy and submitted the order a few months ago, it would have been **$8000** πŸ˜₯ (super sad). - -I did not sign any documents prohibiting the dissemination of information. You can use the code under the **WTFPL** license 🀝 (read ./LICENSE) \ No newline at end of file +From this project i earned **700 000** Russian rubles
+*As long as commits appear in the repository, this means that i continue paid development* diff --git a/mirzaev/ebala/system/controllers/account.php b/mirzaev/ebala/system/controllers/account.php index aa1419c..d8fadb9 100755 --- a/mirzaev/ebala/system/controllers/account.php +++ b/mirzaev/ebala/system/controllers/account.php @@ -163,10 +163,14 @@ final class account extends core 'errors' => self::parse_only_text($this->errors) ]; - if ($password) $return['clipboard'] = <<getKey()} - ΠŸΠ°Ρ€ΠΎΠ»ΡŒ: {$parameters['password']} - TEXT; + if ($password) $return['clipboard'] = match ($account->type) { + 'worker' => 'НомСр: ' . model::worker($account->getId())?->number, + 'market' => 'Π˜Π΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€: ' . model::market($account->getId())?->id, + 'operator' => "Π˜Π΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€: {$account->getKey()}", + 'administrator' => "Π˜Π΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€: {$account->getKey()}", + default => "Π˜Π΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€: {$account->getKey()}" + } + . "\nΠŸΠ°Ρ€ΠΎΠ»ΡŒ: {$parameters['password']}"; // ГСнСрация ΠΎΡ‚Π²Π΅Ρ‚Π° echo json_encode($return); diff --git a/mirzaev/ebala/system/controllers/core.php b/mirzaev/ebala/system/controllers/core.php index ec40780..a813d89 100755 --- a/mirzaev/ebala/system/controllers/core.php +++ b/mirzaev/ebala/system/controllers/core.php @@ -150,7 +150,7 @@ class core extends controller $buffer = []; // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° для Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° для Π³Π΅Π½Π΅Ρ€Π°Ρ†ΠΈΠΈ прСдставлСния - foreach ($this->view->accounts as $vendor) $buffer[] = ['account' => $vendor, 'market' => account::market($vendor->getId(), errors: $this->errors['account'])]; + foreach ($this->view->accounts as $account) $buffer[] = ['account' => $account, 'market' => account::market($account->getId(), errors: $this->errors['account'])]; // Π—Π°ΠΏΠΈΡΡŒ Π² Π³Π»ΠΎΠ±Π°Π»ΡŒΠ½ΡƒΡŽ ΠΏΠ΅Ρ€Π΅ΠΌΠ΅Π½Π½ΡƒΡŽ ΠΈΠ· Π±ΡƒΡ„Π΅Ρ€Π° $this->view->accounts = $buffer; diff --git a/mirzaev/ebala/system/controllers/market.php b/mirzaev/ebala/system/controllers/market.php index de8895f..9c8f00e 100755 --- a/mirzaev/ebala/system/controllers/market.php +++ b/mirzaev/ebala/system/controllers/market.php @@ -144,6 +144,7 @@ final class market extends core a.commentary IN TOKENS(@search, 'text_ru') || a.address IN TOKENS(@search, 'text_ru') || STARTS_WITH(a._key, @search) + || STARTS_WITH(a.id, @search) || STARTS_WITH(a.name.first, @search) || STARTS_WITH(a.name.second, @search) || STARTS_WITH(a.name.last, @search) @@ -152,6 +153,7 @@ final class market extends core || STARTS_WITH(a.number, @search) || STARTS_WITH(a.mail, @search) || (LENGTH(@search) > 5 && LEVENSHTEIN_MATCH(a._key, TOKENS(@search, 'text_en')[0], 2, true)) + || (LENGTH(@search) > 2 && LEVENSHTEIN_MATCH(a.id, TOKENS(@search, 'text_en')[0], 1, true)) || (LENGTH(@search) > 3 && LEVENSHTEIN_MATCH(a.name.first, TOKENS(@search, 'text_ru')[0], 2, true)) || (LENGTH(@search) > 3 && LEVENSHTEIN_MATCH(a.name.second, TOKENS(@search, 'text_ru')[0], 2, true)) || (LENGTH(@search) > 3 && LEVENSHTEIN_MATCH(a.name.last, TOKENS(@search, 'text_ru')[0], 2, true)) @@ -274,8 +276,8 @@ final class market extends core ]; } - // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€Π° Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° (ΠΊΠ»ΡŽΡ‡ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π° инстанции Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° Π² Π±Π°Π·Π΅ Π΄Π°Π½Π½Ρ‹Ρ…) - $_key = preg_replace('/.+\//', '', $account ?? ''); + // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€Π° ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° + $id = model::id(); // Π—Π°ΠΏΠΈΡΡŒ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΎΠ² ΠΎΡ‚Π²Π΅Ρ‚Π° header('Content-Type: application/json'); @@ -289,7 +291,7 @@ final class market extends core echo json_encode( [ 'clipboard' => empty($this->errors['account']) ? << self::parse_only_text($this->errors['account']) @@ -307,6 +309,7 @@ final class market extends core // Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° $market = model::create( data: [ + 'id' => $id, 'name' => [ 'first' => $parameters['market_name_first'], 'second' => $parameters['market_name_second'], @@ -350,7 +353,7 @@ final class market extends core // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ администратора ΠΈΠ»ΠΈ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€Π° // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° - $market = model::read('d._key == "' . $parameters['id'] . '"', return: '{ name: d.name, number: d.number, mail: d.mail, type: d.type, city: d.city, district: d.district, address: d.address}')->getAll(); + $market = model::read('d.id == "' . $parameters['id'] . '"', return: '{ name: d.name, number: d.number, mail: d.mail, type: d.type, city: d.city, district: d.district, address: d.address}')->getAll(); if (!empty($market)) { // НайдСны Π΄Π°Π½Π½Ρ‹Π΅ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° @@ -390,7 +393,7 @@ final class market extends core // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ администратора ΠΈΠ»ΠΈ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€Π° // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° - $market = model::read('d._key == "' . $parameters['id'] . '"'); + $market = model::read('d.id == "' . $parameters['id'] . '"'); if (!empty($market)) { // НайдСн ΠΌΠ°Π³Π°Π·ΠΈΠ½ @@ -472,7 +475,7 @@ final class market extends core // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€Π° ΠΈΠ»ΠΈ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… ΠΌΠ°Π³Π°Π·ΠΈΠ½ΠΎΠ² - $this->view->markets = model::read(filter: 'd.active == true', amount: 10000, return: '{ _key: d._key, name: d.name }'); + $this->view->markets = model::read(filter: 'd.active == true', amount: 10000, return: '{ id: d.id, name: d.name }'); // УнивСрсализация if ($this->view->markets instanceof _document) $this->view->markets = [$this->view->markets]; diff --git a/mirzaev/ebala/system/controllers/session.php b/mirzaev/ebala/system/controllers/session.php index b1b5058..7e4d95e 100755 --- a/mirzaev/ebala/system/controllers/session.php +++ b/mirzaev/ebala/system/controllers/session.php @@ -8,6 +8,7 @@ namespace mirzaev\ebala\controllers; use mirzaev\ebala\controllers\core, mirzaev\ebala\controllers\traits\errors, mirzaev\ebala\models\account, + mirzaev\ebala\models\worker, mirzaev\ebala\models\market; // Π‘ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠ° для ArangoDB @@ -76,11 +77,11 @@ final class session extends core } // Поиск Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° - $account = account::read('d.number == "' . $parameters['worker'] . '"', amount: 1); + $worker = worker::read('d.number == "' . $parameters['worker'] . '"', amount: 1); // ГСнСрация ΠΎΡ‚Π²Π΅Ρ‚Π° ΠΏΠΎ Π·Π°ΠΏΡ€Π°ΡˆΠΈΠ²Π°Π΅ΠΌΡ‹ΠΌ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Π°ΠΌ foreach ($return as $parameter) match ($parameter) { - 'exist' => $buffer['exist'] = isset($account), + 'exist' => $buffer['exist'] = isset($worker), 'account' => (function () use ($parameters, $remember, &$buffer) { // Π—Π°ΠΏΠΈΡΡŒ Π² Π±ΡƒΡ„Π΅Ρ€ сСссии if ($remember) $this->session->write(['entry' => ['number' => $parameters['worker']]], $this->errors); @@ -370,7 +371,7 @@ final class session extends core // Π—Π°ΠΏΡ€ΠΎΡˆΠ΅Π½ΠΎ Π·Π°ΠΏΠΎΠΌΠΈΠ½Π°Π½ΠΈΠ΅ // Π—Π°ΠΏΠΈΡΡŒ Π² cookie - setcookie('entry__key', $parameters['market'], [ + setcookie('entry_id', $parameters['market'], [ 'expires' => strtotime('+1 day'), 'path' => '/', 'secure' => true, @@ -379,15 +380,15 @@ final class session extends core ]); } - // Поиск Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° - $account = account::read('d._key == "' . $parameters['market'] . '"', amount: 1); + // Поиск ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° + $market = market::read('d.id == "' . $parameters['market'] . '"', amount: 1); // ГСнСрация ΠΎΡ‚Π²Π΅Ρ‚Π° ΠΏΠΎ Π·Π°ΠΏΡ€Π°ΡˆΠΈΠ²Π°Π΅ΠΌΡ‹ΠΌ ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€Π°ΠΌ foreach ($return as $parameter) match ($parameter) { - 'exist' => $buffer['exist'] = isset($account), + 'exist' => $buffer['exist'] = isset($market), 'account' => (function () use ($parameters, $remember, &$buffer) { // Π—Π°ΠΏΠΈΡΡŒ Π² Π±ΡƒΡ„Π΅Ρ€ сСссии - if ($remember) $this->session->write(['entry' => ['_key' => $parameters['market']]], $this->errors); + if ($remember) $this->session->write(['entry' => ['id' => $parameters['market']]], $this->errors); // Поиск Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° ΠΈ запись Π² Π±ΡƒΡ„Π΅Ρ€ Π²Ρ‹Π²ΠΎΠ΄Π° $buffer['account'] = (new account($this->session, 'market', $this->errors))?->instance() instanceof _document; @@ -429,7 +430,7 @@ final class session extends core // Π—Π°ΠΏΠΈΡΡŒ Π² Π±ΡƒΡ„Π΅Ρ€ сСссии if (!in_array('account', $return, true) && ($remember ?? false)) - $this->session->write(['entry' => ['_key' => $parameters['market']]]); + $this->session->write(['entry' => ['id' => $parameters['market']]]); } /** diff --git a/mirzaev/ebala/system/controllers/task.php b/mirzaev/ebala/system/controllers/task.php index 0a54940..065e38c 100755 --- a/mirzaev/ebala/system/controllers/task.php +++ b/mirzaev/ebala/system/controllers/task.php @@ -48,10 +48,10 @@ final class task extends core $this->errors['tasks'] ??= []; // Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ строк - for ($i = 0, $parameters['cashiers'] = (int) $parameters['cashiers']; $i < $parameters['cashiers']; ++$i) model::create(work: 'ΠšΠ°ΡΡΠΈΡ€', market: $this->account->type === 'market' ? account::market($this->account->getId())?->getKey() : null, start: $parameters['start'], end: $parameters['end'], date: $parameters['date'], errors: $this->errors['tasks']); - for ($i = 0, $parameters['displayers'] = (int) $parameters['displayers']; $i < $parameters['displayers']; ++$i) model::create(work: 'Π’Ρ‹ΠΊΠ»Π°Π΄Ρ‡ΠΈΠΊ', market: $this->account->type === 'market' ? account::market($this->account->getId())?->getKey() : null, start: $parameters['start'], end: $parameters['end'], date: $parameters['date'], errors: $this->errors['tasks']); - for ($i = 0, $parameters['loaders'] = (int) $parameters['loaders']; $i < $parameters['loaders']; ++$i) model::create(work: 'Π“Ρ€ΡƒΠ·Ρ‡ΠΈΠΊ', market: $this->account->type === 'market' ? account::market($this->account->getId())?->getKey() : null, start: $parameters['start'], end: $parameters['end'], date: $parameters['date'], errors: $this->errors['tasks']); - for ($i = 0, $parameters['gastronomes'] = (int) $parameters['gastronomes']; $i < $parameters['gastronomes']; ++$i) model::create(work: 'Гастроном', market: $this->account->type === 'market' ? account::market($this->account->getId())?->getKey() : null, start: $parameters['start'], end: $parameters['end'], date: $parameters['date'], errors: $this->errors['tasks']); + for ($i = 0, $parameters['cashiers'] = (int) $parameters['cashiers']; $i < $parameters['cashiers']; ++$i) model::create(work: 'ΠšΠ°ΡΡΠΈΡ€', market: $this->account->type === 'market' ? account::market($this->account->getId())?->id : null, start: $parameters['start'], end: $parameters['end'], date: $parameters['date'], errors: $this->errors['tasks']); + for ($i = 0, $parameters['displayers'] = (int) $parameters['displayers']; $i < $parameters['displayers']; ++$i) model::create(work: 'Π’Ρ‹ΠΊΠ»Π°Π΄Ρ‡ΠΈΠΊ', market: $this->account->type === 'market' ? account::market($this->account->getId())?->id : null, start: $parameters['start'], end: $parameters['end'], date: $parameters['date'], errors: $this->errors['tasks']); + for ($i = 0, $parameters['loaders'] = (int) $parameters['loaders']; $i < $parameters['loaders']; ++$i) model::create(work: 'Π“Ρ€ΡƒΠ·Ρ‡ΠΈΠΊ', market: $this->account->type === 'market' ? account::market($this->account->getId())?->id : null, start: $parameters['start'], end: $parameters['end'], date: $parameters['date'], errors: $this->errors['tasks']); + for ($i = 0, $parameters['gastronomes'] = (int) $parameters['gastronomes']; $i < $parameters['gastronomes']; ++$i) model::create(work: 'Гастроном', market: $this->account->type === 'market' ? account::market($this->account->getId())?->id : null, start: $parameters['start'], end: $parameters['end'], date: $parameters['date'], errors: $this->errors['tasks']); // Π—Π°ΠΏΠΈΡΡŒ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΎΠ² ΠΎΡ‚Π²Π΅Ρ‚Π° header('Content-Type: application/json'); @@ -205,11 +205,11 @@ final class task extends core // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… для Π³Π΅Π½Π΅Ρ€Π°Ρ†ΠΈΠΈ HTML-Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π° с Ρ‚Π°Π±Π»ΠΈΡ†Π΅ΠΉ if ($_SERVER['INTERFACE'] === 'worker') - $this->view->rows = model::list(before: 'FILTER task.worker == "' . account::worker($this->account->getId())?->getKey() . '"' . " && ($filters)"); + $this->view->rows = model::list(before: 'FILTER task.worker == "' . account::worker($this->account->getId())?->id . '"' . " && ($filters)"); else if ($_SERVER['INTERFACE'] === 'operator') $this->view->rows = model::list(before: "FILTER ($filters)"); else if ($_SERVER['INTERFACE'] === 'market') - $this->view->rows = model::list(before: 'FILTER task.market == "' . account::market($this->account->getId())?->getKey() . '"' . " && ($filters)"); + $this->view->rows = model::list(before: 'FILTER task.market == "' . account::market($this->account->getId())?->id . '"' . " && ($filters)"); else if ($_SERVER['INTERFACE'] === 'administrator') $this->view->rows = model::list(before: "FILTER ($filters)"); else $this->view->rows = []; @@ -234,10 +234,12 @@ final class task extends core || (LENGTH(@search) > 6 && LEVENSHTEIN_MATCH(task._key, TOKENS(@search, 'text_en')[0], 2, true)) || (LENGTH(@search) > 6 && LEVENSHTEIN_MATCH(task.worker, TOKENS(@search, 'text_en')[0], 2, true)) || (LENGTH(@search) > 6 && LEVENSHTEIN_MATCH(task.market, TOKENS(@search, 'text_en')[0], 2, true)) -AQL; + AQL; // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… для Π³Π΅Π½Π΅Ρ€Π°Ρ†ΠΈΠΈ HTML-Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π° с Ρ‚Π°Π±Π»ΠΈΡ†Π΅ΠΉ - if ($_SERVER['INTERFACE'] === 'worker') + if ($_SERVER['INTERFACE'] === 'worker') { + // Π‘ΠΎΡ‚Ρ€ΡƒΠ΄Π½ΠΈΠΊ + $this->view->rows = model::list( before: sprintf( <<session->buffer['worker']['tasks']['page'], target: empty($search) ? model::COLLECTION : 'registry_tasks', - binds: ['worker' => account::worker($this->account->getId())?->getKey()] + (empty($search) ? [] : ['search' => $search]) + binds: ['worker' => account::worker($this->account->getId())?->id] + (empty($search) ? [] : ['search' => $search]) ); - else if ($_SERVER['INTERFACE'] === 'market') + } else if ($_SERVER['INTERFACE'] === 'market') { + // Магазин + $this->view->rows = model::list( before: sprintf( <<session->buffer['market']['tasks']['page'], target: empty($search) ? model::COLLECTION : 'registry_tasks', - binds: ['market' => account::market($this->account->getId())?->getKey()] + (empty($search) ? [] : ['search' => $search]) + binds: ['market' => account::market($this->account->getId())?->id] + (empty($search) ? [] : ['search' => $search]) ); - else if ($_SERVER['INTERFACE'] === 'operator') + } else if ($_SERVER['INTERFACE'] === 'operator') { + // ΠžΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€ + $this->view->rows = model::list( before: sprintf( << $search ] ); - else if ($_SERVER['INTERFACE'] === 'administrator') + } else if ($_SERVER['INTERFACE'] === 'administrator') { + // Администратор + $this->view->rows = model::list( before: sprintf( << $search ] ); - else $this->view->rows = []; + } else $this->view->rows = []; - // Π—Π°ΠΏΠΈΡΡŒ Π² cookie (Ρ‚ΠΎΠ»ΡŒΠΊΠΎ Ρ‚Π°ΠΊΠΈΠΌ ΠΌΠ΅Ρ‚ΠΎΠ΄ΠΎΠΌ ΠΌΠΎΠΆΠ½ΠΎ Π·Π°ΠΏΠΈΡΠ°Ρ‚ΡŒ "hostonly: true") + // Π—Π°ΠΏΠΈΡΡŒ Π² cookie setcookie( 'tasks_page', (string) $this->session->buffer[$_SERVER['INTERFACE']]['tasks']['page'], @@ -503,7 +511,7 @@ AQL; // НайдСна заявка // Заявка Π½Π΅ ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ‚ Π·Π°ΠΏΡ€ΠΎΡΠΈΠ²ΡˆΠ΅ΠΌΡƒ ΠΌΠ°Π³Π°Π·ΠΈΠ½Ρƒ? - if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->getKey()) + if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->id) throw new exception('Π’Ρ‹ Π½Π΅ Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·ΠΎΠ²Π°Π½Ρ‹ для рСдактирования этой заявки'); // Заявка ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½Π°? @@ -557,14 +565,14 @@ AQL; } else { // Π—Π°ΠΏΠΈΡΠ°Ρ‚ΡŒ Π½ΠΎΠ²ΠΎΠ³ΠΎ сотрудника - if (($worker = worker::read('d._key == "' . $parameters['worker'] . '" && d.active == true', amount: 1)) instanceof _document) { + if (($worker = worker::read('d.id == "' . $parameters['worker'] . '" && d.active == true', amount: 1)) instanceof _document) { // НайдСн сотрудник (Π·Π°ΠΏΡ€Π°ΡˆΠΈΠ²Π°Π΅ΠΌΡ‹ΠΉ для записи сотрудник сущСствуСт Π² Π±Π°Π·Π΅ Π΄Π°Π½Π½Ρ‹Ρ…) if ($task->worker !== $parameters['worker']) { // Π˜Π΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ Π·Π°ΠΏΡ€Π°ΡˆΠΈΠ²Π°Π΅ΠΌΠΎΠ³ΠΎ сотрудника Π½Π΅ Ρ€Π°Π²Π΅Π½ Π°ΠΊΡ‚ΡƒΠ°Π»ΡŒΠ½ΠΎΠΌΡƒ // Π—Π°ΠΏΠΈΡΡŒ сотрудника - $task->worker = $worker->getKey(); + $task->worker = $worker->id; // БнятиС с ΠΏΡƒΠ±Π»ΠΈΠΊΠ°Ρ†ΠΈΠΈ $task->published = false; @@ -653,14 +661,14 @@ AQL; } else { // Π—Π°ΠΏΠΈΡΠ°Ρ‚ΡŒ Π½ΠΎΠ²Ρ‹ΠΉ ΠΌΠ°Π³Π°Π·ΠΈΠ½ - if (($market = market::read('d._key == "' . $parameters['market'] . '" && d.active == true', amount: 1)) instanceof _document) { + if (($market = market::read('d.id == "' . $parameters['market'] . '" && d.active == true', amount: 1)) instanceof _document) { // НайдСн ΠΌΠ°Π³Π°Π·ΠΈΠ½ (Π·Π°ΠΏΡ€Π°ΡˆΠΈΠ²Π°Π΅ΠΌΡ‹ΠΉ для записи ΠΌΠ°Π³Π°Π·ΠΈΠ½ сущСствуСт Π² Π±Π°Π·Π΅ Π΄Π°Π½Π½Ρ‹Ρ…) if ($task->market !== $parameters['market']) { // Π˜Π΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ Π·Π°ΠΏΡ€Π°ΡˆΠΈΠ²Π°Π΅ΠΌΠΎΠ³ΠΎ сотрудника Π½Π΅ Ρ€Π°Π²Π΅Π½ Π°ΠΊΡ‚ΡƒΠ°Π»ΡŒΠ½ΠΎΠΌΡƒ // Π—Π°ΠΏΠΈΡΡŒ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° - $task->market = $market->getKey(); + $task->market = $market->id; if (_core::update($task)) { // Записано ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ Π² Π±Π°Π·Ρƒ Π΄Π°Π½Π½Ρ‹Ρ… @@ -757,7 +765,7 @@ AQL; )->getAll(); // Заявка Π½Π΅ ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ‚ Π·Π°ΠΏΡ€ΠΎΡΠΈΠ²ΡˆΠ΅ΠΌΡƒ ΠΌΠ°Π³Π°Π·ΠΈΠ½Ρƒ? - if ($this->account->type === 'market' and $this->view->task['market'] !== account::market($this->account->getId())?->getKey()) + if ($this->account->type === 'market' and $this->view->task['market'] !== account::market($this->account->getId())?->id) throw new exception('Π’Ρ‹ Π½Π΅ Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·ΠΎΠ²Π°Π½Ρ‹ для чтСния этой заявки'); // Π£Π΄Π°Π»Π΅Π½ΠΈΠ΅ Π΄Π°Π½Π½Ρ‹Ρ… ΠΈΠ· Π²Ρ‹Π΄Π°Ρ‡ΠΈ @@ -892,9 +900,9 @@ AQL; // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… сотрудника $this->view->worker = worker::read( - 'd._key == "' . $parameters['worker'] . '"', + 'd.id == "' . $parameters['worker'] . '"', return: $this->account->type === 'market' - ? '{_key: d._key, created: d.created, updated: d.updated, name: d.name, number: d.number, mail: d.mail, birth: d.birth, rating: d.rating}' + ? '{id: d.id, created: d.created, updated: d.updated, name: d.name, number: d.number, mail: d.mail, birth: d.birth, rating: d.rating}' : 'd' )->getAll(); @@ -1011,7 +1019,7 @@ AQL; // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ администратора ΠΈΠ»ΠΈ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€Π° // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… - $this->view->market = market::read('d._key == "' . $parameters['market'] . '"')?->getAll(); + $this->view->market = market::read('d.id == "' . $parameters['market'] . '"')?->getAll(); if (!empty($this->view->market)) { // НайдСны Π΄Π°Π½Π½Ρ‹Π΅ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° @@ -1210,7 +1218,7 @@ AQL; $task = model::read('d._key == "' . $parameters['task'] . '"'); // Заявка Π½Π΅ ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ‚ Π·Π°ΠΏΡ€ΠΎΡΠΈΠ²ΡˆΠ΅ΠΌΡƒ ΠΌΠ°Π³Π°Π·ΠΈΠ½Ρƒ? - if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->getKey()) + if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->id) throw new exception('Π’Ρ‹ Π½Π΅ Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·ΠΎΠ²Π°Π½Ρ‹ для заявлСния ΠΎ ΠΏΡ€ΠΎΠ±Π»Π΅ΠΌΠ΅ с этой заявкой'); // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Ρ‚Ρ‹ @@ -1329,7 +1337,7 @@ AQL; $task = model::read('d._key == "' . $parameters['task'] . '"'); // Заявка Π½Π΅ ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ‚ Π·Π°ΠΏΡ€ΠΎΡΠΈΠ²ΡˆΠ΅ΠΌΡƒ ΠΌΠ°Π³Π°Π·ΠΈΠ½Ρƒ? - if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->getKey()) + if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->id) throw new exception('Π’Ρ‹ Π½Π΅ Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·ΠΎΠ²Π°Π½Ρ‹ для Π·Π°Π²Π΅Ρ€ΡˆΠ΅Π½ΠΈΡ этой заявки'); // Заявка Π·Π°Π²Π΅Ρ€ΡˆΠ΅Π½Π°? @@ -1552,7 +1560,7 @@ AQL; $task = model::read('d._key == "' . $parameters['task'] . '"'); // Заявка Π½Π΅ ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ‚ Π·Π°ΠΏΡ€ΠΎΡΠΈΠ²ΡˆΠ΅ΠΌΡƒ ΠΌΠ°Π³Π°Π·ΠΈΠ½Ρƒ? - if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->getKey()) + if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->id) throw new exception('Π’Ρ‹ Π½Π΅ Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·ΠΎΠ²Π°Π½Ρ‹ для рСдактирования Ρ‚ΠΈΠΏΠ° Ρ€Π°Π±ΠΎΡ‚Ρ‹ этой заявки'); // Заявка ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½Π°? @@ -1665,7 +1673,7 @@ AQL; $task = model::read('d._key == "' . $parameters['task'] . '"'); // Заявка Π½Π΅ ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ‚ Π·Π°ΠΏΡ€ΠΎΡΠΈΠ²ΡˆΠ΅ΠΌΡƒ ΠΌΠ°Π³Π°Π·ΠΈΠ½Ρƒ? - if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->getKey()) + if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->id) throw new exception('Π’Ρ‹ Π½Π΅ Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·ΠΎΠ²Π°Π½Ρ‹ для чтСния ΠΏΠ°Ρ€Π°ΠΌΠ΅Ρ‚Ρ€ΠΎΠ² этой заявки'); if ($task instanceof _document) { @@ -1828,7 +1836,7 @@ AQL; $task = model::read('d._key == "' . $parameters['task'] . '"'); // Заявка Π½Π΅ ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ‚ Π·Π°ΠΏΡ€ΠΎΡΠΈΠ²ΡˆΠ΅ΠΌΡƒ ΠΌΠ°Π³Π°Π·ΠΈΠ½Ρƒ? - if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->getKey()) + if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->id) throw new exception('Π’Ρ‹ Π½Π΅ Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·ΠΎΠ²Π°Π½Ρ‹ для рСдактирования Ρ‚ΠΈΠΏΠ° Ρ€Π°Π±ΠΎΡ‚Ρ‹ этой заявки'); // Заявка ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½Π°? @@ -1947,7 +1955,7 @@ AQL; $task = model::read('d._key == "' . $parameters['task'] . '"'); // Заявка Π½Π΅ ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ‚ Π·Π°ΠΏΡ€ΠΎΡΠΈΠ²ΡˆΠ΅ΠΌΡƒ ΠΌΠ°Π³Π°Π·ΠΈΠ½Ρƒ? - if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->getKey()) + if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->id) throw new exception('Π’Ρ‹ Π½Π΅ Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·ΠΎΠ²Π°Π½Ρ‹ для рСдактирования описания этой заявки'); // Заявка ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½Π°? @@ -2056,7 +2064,7 @@ AQL; $task = model::read('d._key == "' . $parameters['task'] . '"'); // Заявка Π½Π΅ ΠΏΡ€ΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ‚ Π·Π°ΠΏΡ€ΠΎΡΠΈΠ²ΡˆΠ΅ΠΌΡƒ ΠΌΠ°Π³Π°Π·ΠΈΠ½Ρƒ? - if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->getKey()) + if ($this->account->type === 'market' and $task->market !== account::market($this->account->getId())?->id) throw new exception('Π’Ρ‹ Π½Π΅ Π°Π²Ρ‚ΠΎΡ€ΠΈΠ·ΠΎΠ²Π°Π½Ρ‹ для рСдактирования Π΄Π°Ρ‚Ρ‹ ΠΈ Π²Ρ€Π΅ΠΌΠ΅Π½ΠΈ этой заявки'); // Заявка ΠΏΠΎΠ΄Ρ‚Π²Π΅Ρ€ΠΆΠ΄Π΅Π½Π°? @@ -2447,7 +2455,7 @@ AQL; if ( $this->account->type === 'operator' || $this->account->type === 'administrator' - || ($this->account->type === 'worker' && $task->worker === account::worker($this->account->getId())?->getKey()) + || ($this->account->type === 'worker' && $task->worker === account::worker($this->account->getId())?->id) ) { // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ (Ссли сотрудник, Ρ‚ΠΎ Π½Π°Π·Π½Π°Ρ‡Π΅Π½ Π½Π° эту заявку) @@ -2513,7 +2521,7 @@ AQL; if ( $this->account->type === 'operator' || $this->account->type === 'administrator' - || ($this->account->type === 'market' && $task->market === account::market($this->account->getId())?->getKey()) + || ($this->account->type === 'market' && $task->market === account::market($this->account->getId())?->id) ) { // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ (Ссли ΠΌΠ°Π³Π°Π·ΠΈΠ½, Ρ‚ΠΎ Π½Π°Π·Π½Π°Ρ‡Π΅Π½ Π½Π° эту заявку) @@ -2664,7 +2672,7 @@ AQL; if ( $this->account->type === 'operator' || $this->account->type === 'administrator' - || ($this->account->type === 'worker' && $task->worker === account::worker($this->account->getId())?->getKey()) + || ($this->account->type === 'worker' && $task->worker === account::worker($this->account->getId())?->id) ) { // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ (Ссли сотрудник, Ρ‚ΠΎ Π½Π°Π·Π½Π°Ρ‡Π΅Π½ Π½Π° эту заявку) @@ -2678,7 +2686,7 @@ AQL; 'from' => [ '_key' => $this->account->getKey(), 'type' => $this->account->type - ], + ] + ($this->account->type === 'worker' ? ['id' => $task->worker] : []), 'type' => $parameters['type'] ?? 'message', 'text' => $parameters['text'], 'readed' => [$this->account->getKey() => 0], @@ -2736,7 +2744,7 @@ AQL; if ( $this->account->type === 'operator' || $this->account->type === 'administrator' - || ($this->account->type === 'market' && $task->market === account::market($this->account->getId())?->getKey()) + || ($this->account->type === 'market' && $task->market === account::market($this->account->getId())?->id) ) { // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ (Ссли ΠΌΠ°Π³Π°Π·ΠΈΠ½, Ρ‚ΠΎ Π½Π°Π·Π½Π°Ρ‡Π΅Π½ Π½Π° эту заявку) @@ -2750,7 +2758,7 @@ AQL; 'from' => [ '_key' => $this->account->getKey(), 'type' => $this->account->type - ], + ] + ($this->account->type === 'market' ? ['id' => $task->market] : []), 'type' => $parameters['type'] ?? 'message', 'text' => $parameters['text'], 'readed' => [$this->account->getKey() => 0], diff --git a/mirzaev/ebala/system/controllers/worker.php b/mirzaev/ebala/system/controllers/worker.php index 5575e2e..62a5903 100755 --- a/mirzaev/ebala/system/controllers/worker.php +++ b/mirzaev/ebala/system/controllers/worker.php @@ -147,6 +147,7 @@ final class worker extends core || a.department.address IN TOKENS(@search, 'text_ru') || a.requisites IN TOKENS(@search, 'text_ru') || STARTS_WITH(a._key, @search) + || STARTS_WITH(a.id, @search) || STARTS_WITH(a.name.first, @search) || STARTS_WITH(a.name.second, @search) || STARTS_WITH(a.name.last, @search) @@ -161,6 +162,7 @@ final class worker extends core || STARTS_WITH(a.requisites, @search) || STARTS_WITH(a.tax, @search) || (LENGTH(@search) > 5 && LEVENSHTEIN_MATCH(a._key, TOKENS(@search, 'text_en')[0], 2, true)) + || (LENGTH(@search) > 4 && LEVENSHTEIN_MATCH(a.id, TOKENS(@search, 'text_en')[0], 1, true)) || (LENGTH(@search) > 3 && LEVENSHTEIN_MATCH(a.name.first, TOKENS(@search, 'text_ru')[0], 2, true)) || (LENGTH(@search) > 3 && LEVENSHTEIN_MATCH(a.name.second, TOKENS(@search, 'text_ru')[0], 2, true)) || (LENGTH(@search) > 3 && LEVENSHTEIN_MATCH(a.name.last, TOKENS(@search, 'text_ru')[0], 2, true)) @@ -269,7 +271,7 @@ final class worker extends core 'second' => $parameters['account_name_second'], 'last' => $parameters['account_name_last'] ], - 'number' => $parameters['account_number'] === 0 ? '' : $parameters['account_number'], + 'number' => $parameters['account_number'], 'mail' => $parameters['account_mail'], 'password' => sodium_crypto_pwhash_str( $parameters['account_password'], @@ -293,9 +295,6 @@ final class worker extends core ]; } - // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€Π° Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° (ΠΊΠ»ΡŽΡ‡ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π° инстанции Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° Π² Π±Π°Π·Π΅ Π΄Π°Π½Π½Ρ‹Ρ…) - $_key = preg_replace('/.+\//', '', $account ?? ''); - // Π—Π°ΠΏΠΈΡΡŒ Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΎΠ² ΠΎΡ‚Π²Π΅Ρ‚Π° header('Content-Type: application/json'); header('Content-Encoding: none'); @@ -308,7 +307,7 @@ final class worker extends core echo json_encode( [ 'clipboard' => empty($this->errors['account']) ? << self::parse_only_text($this->errors['account']) @@ -326,12 +325,13 @@ final class worker extends core // Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ сотрудника $worker = model::create( data: [ + 'id' => model::id(), 'name' => [ 'first' => $parameters['worker_name_first'], 'second' => $parameters['worker_name_second'], 'last' => $parameters['worker_name_last'] ], - 'number' => $parameters['worker_number'] === 0 ? '' : $parameters['worker_number'], + 'number' => $parameters['worker_number'], 'mail' => $parameters['worker_mail'], 'birth' => $parameters['worker_birth'], 'passport' => $parameters['worker_passport'], @@ -380,7 +380,7 @@ final class worker extends core // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ администратора ΠΈΠ»ΠΈ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€Π° // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… сотрудника - $worker = model::read('d._key == "' . $parameters['id'] . '"', return: '{ name: d.name, number: d.number, mail: d.mail, birth: d.birth, passport: d.passport, issued: d.issued, department: d.department, requisites: d.requisites, payment: d.payment, tax: d.tax, city: d.city, district: d.district, address: d.address, hiring: d.hiring}')->getAll(); + $worker = model::read('d.id == "' . $parameters['id'] . '"', return: '{ name: d.name, number: d.number, mail: d.mail, birth: d.birth, passport: d.passport, issued: d.issued, department: d.department, requisites: d.requisites, payment: d.payment, tax: d.tax, city: d.city, district: d.district, address: d.address, hiring: d.hiring}')->getAll(); if (!empty($worker)) { // НайдСны Π΄Π°Π½Π½Ρ‹Π΅ сотрудника @@ -420,7 +420,7 @@ final class worker extends core // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ администратора ΠΈΠ»ΠΈ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€Π° // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… сотрудника - $worker = model::read('d._key == "' . $parameters['id'] . '"'); + $worker = model::read('d.id == "' . $parameters['id'] . '"'); if (!empty($worker)) { // НайдСн сотрудник @@ -515,7 +515,7 @@ final class worker extends core // Авторизован Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€Π° ΠΈΠ»ΠΈ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·Π°Ρ†ΠΈΡ Π΄Π°Π½Π½Ρ‹Ρ… сотрудников - $this->view->workers = model::read(filter: 'd.active == true', amount: 10000, return: '{ _key: d._key, name: d.name }'); + $this->view->workers = model::read(filter: 'd.active == true', amount: 10000, return: '{ id: d.id, name: d.name }'); // УнивСрсализация if ($this->view->workers instanceof _document) $this->view->workers = [$this->view->workers]; diff --git a/mirzaev/ebala/system/models/account.php b/mirzaev/ebala/system/models/account.php index 1a5e147..12d7518 100755 --- a/mirzaev/ebala/system/models/account.php +++ b/mirzaev/ebala/system/models/account.php @@ -129,13 +129,13 @@ final class account extends core throw new exception('НСизвСстная ошибка Π½Π° этапС ΠΏΡ€ΠΎΠ²Π΅Ρ€ΠΊΠΈ пароля'); } } else throw new exception('НС Π½Π°ΠΉΠ΄Π΅Π½ ΠΏΠ°Ρ€ΠΎΠ»ΡŒ Π² Π±ΡƒΡ„Π΅Ρ€Π΅ сСссии'); - } else if (!empty($session->buffer['market']['entry']['_key'])) { + } else if (!empty($session->buffer['market']['entry']['id'])) { // НайдСн ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ ΠΌΠ°Π³Π°Π·ΠΈΠ½Π° Π² Π±ΡƒΡ„Π΅Ρ€Π΅ сСссии if (!empty($session->buffer['market']['entry']['password'])) { // НайдСн ΠΏΠ°Ρ€ΠΎΠ»ΡŒ Π² Π±ΡƒΡ„Π΅Ρ€Π΅ сСссии - if (($account = self::read('d._key == "' . $session->buffer['market']['entry']['_key'] . '" && d.type == "market"', amount: 1)) instanceof _document) { + if (($account = market::account(market::read('d.id == "' . $session->buffer['market']['entry']['id'] . '"', amount: 1)?->getId())) instanceof _document) { // НайдСн Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚ (ΠΈΠ³Π½ΠΎΡ€ΠΈΡ€ΡƒΡŽΡ‚ΡΡ ошибки) if (sodium_crypto_pwhash_str_verify($account->password, $session->buffer['market']['entry']['password'])) { @@ -286,7 +286,7 @@ final class account extends core RETURN e ) FILTER d._id == e[0]._to && d.active == true - SORT d.created DESC, d._key DESC + SORT d.created DESC, d.id DESC LIMIT 1 RETURN d AQL, @@ -316,7 +316,7 @@ final class account extends core * * Π˜Ρ‰Π΅Ρ‚ связь Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° с сотрудником, Ссли Π½Π΅ Π½Π°Ρ…ΠΎΠ΄ΠΈΡ‚, Ρ‚ΠΎ создаёт Π΅Ρ‘ * - * @param string $worker Π˜Π΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ инстанции Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π° Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° Π² Π±Π°Π·Π΅ Π΄Π°Π½Π½Ρ‹Ρ… + * @param string $account Π˜Π΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ инстанции Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π° Π°ΠΊΠΊΠ°ΡƒΠ½Ρ‚Π° Π² Π±Π°Π·Π΅ Π΄Π°Π½Π½Ρ‹Ρ… * @param string $target Π˜Π΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ инстанции Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Π° Ρ†Π΅Π»ΠΈ Π² Π±Π°Π·Π΅ Π΄Π°Π½Π½Ρ‹ (подразумСваСтся сотрудник ΠΈΠ»ΠΈ ΠΌΠ°Π³Π°Π·ΠΈΠ½) * @param string $type Π’ΠΈΠΏ ΠΏΠΎΠ΄ΠΊΠ»ΡŽΡ‡Π΅Π½ΠΈΡ (worker|market) * @param array &$errors РССстр ошибок @@ -342,11 +342,11 @@ final class account extends core LIMIT 1 RETURN d AQL, - self::COLLECTION . '_edge_' . worker::COLLECTION, + self::COLLECTION . "_edge_$type", $account, $target )) instanceof _document - || $id = document::write(static::$arangodb->session, self::COLLECTION . "_edge_$type", [ + || document::write(static::$arangodb->session, self::COLLECTION . "_edge_$type", [ '_from' => $account, '_to' => $target ]) diff --git a/mirzaev/ebala/system/models/core.php b/mirzaev/ebala/system/models/core.php index 4307093..45f2105 100755 --- a/mirzaev/ebala/system/models/core.php +++ b/mirzaev/ebala/system/models/core.php @@ -132,6 +132,71 @@ class core extends model return null; } + /** + * Count documents in ArangoDB + * + * @param ?string $collection ΠšΠΎΠ»Π»Π΅ΠΊΡ†ΠΈΡ для подсчёта + * @param array &$errors РССстр ошибок + * + * @return int|null ΠšΠΎΠ»ΠΈΡ‡Π΅ΡΡ‚Π²ΠΎ Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚ΠΎΠ² Π² Π±Π°Π·Π΅ Π΄Π°Π½Π½Ρ‹Ρ…, Ссли Π½Π°ΠΉΠ΄Π΅Π½Ρ‹ + */ + public static function count(?string $collection = null, array &$errors = []): int|null { + try { + if (collection::init(static::$arangodb->session, static::COLLECTION)) { + // Π˜Π½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Π½Π° коллСкция + + // Exit (success) + return collection::search( + static::$arangodb->session, + sprintf( + <<<'AQL' + RETURN LENGTH(%s) + AQL, + $collection ?? static::COLLECTION + ) + ); + } else throw new exception('НС ΡƒΠ΄Π°Π»ΠΎΡΡŒ ΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ ΠΊΠΎΠ»Π»Π΅ΠΊΡ†ΠΈΡŽ'); + } catch (exception $e) { + // Π—Π°ΠΏΠΈΡΡŒ Π² рССстр ошибок + $errors[] = [ + 'text' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'stack' => $e->getTrace() + ]; + } + + // Exit (fail) + return null; + } + + /** + * Π‘Π³Π΅Π½Π΅Ρ€ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ + * + * @param array &$errors РССстр ошибок + * + * @return int Π‘Π²ΠΎΠ±ΠΎΠ΄Π½Ρ‹ΠΉ ΠΈΠ΄Π΅Π½Ρ‚ΠΈΡ„ΠΈΠΊΠ°Ρ‚ΠΎΡ€ (подразумСваСтся) + */ + public static function id(array &$errors = []): int + { + try { + if (collection::init(static::$arangodb->session, static::COLLECTION)) + return static::count(static::COLLECTION, $errors) ?? 0; + else throw new exception('НС ΡƒΠ΄Π°Π»ΠΎΡΡŒ ΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΠΎΠ²Π°Ρ‚ΡŒ ΠΊΠΎΠ»Π»Π΅ΠΊΡ†ΠΈΡŽ'); + } catch (exception $e) { + // Π—Π°ΠΏΠΈΡΡŒ Π² рССстр ошибок + $errors[] = [ + 'text' => $e->getMessage(), + 'file' => $e->getFile(), + 'line' => $e->getLine(), + 'stack' => $e->getTrace() + ]; + } + + return 0; + } + + /** * Delete from ArangoDB * diff --git a/mirzaev/ebala/system/models/task.php b/mirzaev/ebala/system/models/task.php index 58ee7ca..691f196 100755 --- a/mirzaev/ebala/system/models/task.php +++ b/mirzaev/ebala/system/models/task.php @@ -145,8 +145,8 @@ final class task extends core << div.row > span[data-column="account"] { text-align: center; } -section#administrators.panel.list - > div.row:nth-of-type(1) - > span[data-column="account"] { - margin-top: 6px; -} - section#administrators.panel.list > div.row > span[data-column="name"] { min-width: 130px; width: 130px; diff --git a/mirzaev/ebala/system/public/css/pages/markets.css b/mirzaev/ebala/system/public/css/pages/markets.css index a30db18..3f04bff 100755 --- a/mirzaev/ebala/system/public/css/pages/markets.css +++ b/mirzaev/ebala/system/public/css/pages/markets.css @@ -30,18 +30,22 @@ section#markets.panel.list } section#markets.panel.list > div.row > span:is([data-column="account"], [data-column="market"]) { - min-width: 102px; - width: 102px; font-weight: bold; +} + +section#markets.panel.list > div.row:nth-of-type(1) > span[data-column="account"] { text-align: center; } -section#workers.panel.list > div.row:nth-of-type(1) > span[data-column="account"] { - margin-top: 6px; +section#markets.panel.list > div.row > span[data-column="account"] { + min-width: 102px; + width: 102px; + text-align: center; } -section#workers.panel.list > div.row:nth-of-type(1) > span[data-column="market"] { - margin-top: 0px; +section#markets.panel.list > div.row > span[data-column="market"] { + min-width: 67px; + width: 67px; } section#markets.panel.list > div.row > span[data-column="name"] { diff --git a/mirzaev/ebala/system/public/css/pages/operators.css b/mirzaev/ebala/system/public/css/pages/operators.css index cf40791..4563162 100755 --- a/mirzaev/ebala/system/public/css/pages/operators.css +++ b/mirzaev/ebala/system/public/css/pages/operators.css @@ -32,10 +32,6 @@ section#operators.panel.list > div.row > span[data-column="account"] { text-align: center; } -section#operators.panel.list > div.row:nth-of-type(1) > span[data-column="account"] { - margin-top: 6px; -} - section#operators.panel.list > div.row > span[data-column="name"] { min-width: 130px; width: 130px; diff --git a/mirzaev/ebala/system/public/css/pages/tasks.css b/mirzaev/ebala/system/public/css/pages/tasks.css index fab5498..96cdd79 100755 --- a/mirzaev/ebala/system/public/css/pages/tasks.css +++ b/mirzaev/ebala/system/public/css/pages/tasks.css @@ -34,14 +34,26 @@ section#tasks.panel.list > div.row > span[data-column="date"] { font-weight: bold; } -section#tasks.panel.list > div.row > span:is([data-column="worker"], [data-column="market"]) { - min-width: 102px; - width: 102px; +section#tasks.panel.list > div.row > span:is([data-column="market"], [data-column="worker"]) { font-weight: bold; } +section#tasks.panel.list > div.row:nth-of-type(1) > span[data-column="market"] { + text-align: center; +} section#tasks.panel.list > div.row:nth-of-type(1) > span[data-column="worker"] { - margin-top: 8px; + margin-top: 8px; +} + +section#tasks.panel.list > div.row > span[data-column="market"] { + min-width: 67px; + width: 67px; + text-align: right; +} + +section#tasks.panel.list > div.row > span[data-column="worker"] { + min-width: 67px; + width: 67px; } section#tasks.panel.list > div.row > span[data-column="name"] { diff --git a/mirzaev/ebala/system/public/css/pages/workers.css b/mirzaev/ebala/system/public/css/pages/workers.css index 3250cba..004b430 100755 --- a/mirzaev/ebala/system/public/css/pages/workers.css +++ b/mirzaev/ebala/system/public/css/pages/workers.css @@ -32,18 +32,26 @@ section#workers.panel.list } section#workers.panel.list > div.row > span:is([data-column="account"], [data-column="worker"]) { - min-width: 102px; - width: 102px; font-weight: bold; - text-align: center; } section#workers.panel.list > div.row:nth-of-type(1) > span[data-column="account"] { - margin-top: 6px; + text-align: center; } section#workers.panel.list > div.row:nth-of-type(1) > span[data-column="worker"] { - margin-top: 8px; + margin-top: 8px; +} + +section#workers.panel.list > div.row > span[data-column="account"] { + min-width: 102px; + width: 102px; + text-align: center; +} + +section#workers.panel.list > div.row > span[data-column="worker"] { + min-width: 67px; + width: 67px; } section#workers.panel.list > div.row > span[data-column="name"] { diff --git a/mirzaev/ebala/system/public/js/markets.js b/mirzaev/ebala/system/public/js/markets.js index ded5f64..f53b8de 100644 --- a/mirzaev/ebala/system/public/js/markets.js +++ b/mirzaev/ebala/system/public/js/markets.js @@ -275,7 +275,7 @@ if (typeof window.markets !== "function") { "Content-Type": "application/x-www-form-urlencoded", }, body: - `market_name_first=${market_name_first.value}&market_name_second=${market_name_second.value}&market_name_last=${market_name_last.value}&market_number=${market_number.mask.unmaskedValue}&market_mail=${market_mail.value}&market_type=${market_type.value}&market_city=${market_city.value}&market_district=${market_district.value}&market_address=${market_address.value}&account_name_first=${account_name_first.value}&account_name_second=${account_name_second.value}&account_name_last=${account_name_last.value}&account_number=${account_number.unmaskedValue}&account_mail=${account_mail.value}&account_password=${account_password.value}&account_commentary=${account_commentary.value}`, + `market_name_first=${market_name_first.value}&market_name_second=${market_name_second.value}&market_name_last=${market_name_last.value}&market_number=${market_number.mask.unmaskedValue}&market_mail=${market_mail.value}&market_type=${market_type.value}&market_city=${market_city.value}&market_district=${market_district.value}&market_address=${market_address.value}&account_name_first=${account_name_first.value}&account_name_second=${account_name_second.value}&account_name_last=${account_name_last.value}&account_number=${account_number.mask.unmaskedValue}&account_mail=${account_mail.value}&account_password=${account_password.value}&account_commentary=${account_commentary.value}`, }) .then((response) => response.json()) .then((data) => { @@ -1159,7 +1159,7 @@ if (typeof window.markets !== "function") { this.body.wrap.remove(); // Π£Π΄Π°Π»Π΅Π½ΠΈΠ΅ статуса Π°ΠΊΡ‚ΠΈΠ²Π½ΠΎΠΉ строки - row.removeAttribute("data-selected"); + // row.removeAttribute("data-selected"); // Π­Ρ‚ΠΎ ΠΎΠΊΠ½ΠΎ создания строки, Π΅Ρ‘ Π΅Ρ‰Ρ‘ Π½Π΅ сущСствуСт // ДСинициализация быстрых дСйствий ΠΏΠΎ ΠΊΠ½ΠΎΠΏΠΊΠ°ΠΌ document.removeEventListener("keydown", this.buttons); diff --git a/mirzaev/ebala/system/views/elements/chat.html b/mirzaev/ebala/system/views/elements/chat.html index 766bcdc..46e103a 100644 --- a/mirzaev/ebala/system/views/elements/chat.html +++ b/mirzaev/ebala/system/views/elements/chat.html @@ -1,7 +1,7 @@
{% for message in messages %}
-

{{ message.from._key }} {{ message.from.type|account_type_to_russian }} {{ message.date|date('H:i d.m.Y') }}

+

{{ message.from.id ?? message.from._key }} {{ message.from.type|account_type_to_russian }} {{ message.date|date('H:i d.m.Y') }}

{{ message.text }}

{% endfor %} diff --git a/mirzaev/ebala/system/views/elements/lists/market.html b/mirzaev/ebala/system/views/elements/lists/market.html index 10be0f8..899f8ec 100644 --- a/mirzaev/ebala/system/views/elements/lists/market.html +++ b/mirzaev/ebala/system/views/elements/lists/market.html @@ -1,5 +1,5 @@ -{% for key, data in market | filter((data, key) => key != '_key') -%} +{% for key, data in market | filter((data, key) => key != 'id') -%} {% if key == 'created' or key == 'updated' %} {{ data.label }}:{{ data.value is empty ? 'Никогда' : data.value|date('Y.m.d H:i:s') }} @@ -7,10 +7,10 @@ {{ data.label }}:{{ data.value }} {% elseif key == 'mail' %} -{{ data.label }}:{{ +{{ data.label }}:{{ data.value }} {% elseif key == 'name' %} - {{ data.label }}:{% if data.value.first is not empty %}{{ data.value.first }}{% endif %}{% if data.value.second is not empty %} {{ data.value.second }}{% endif %}{% if data.value.last is not empty %} {{ data.value.last }}{% endif %} + {{ data.label }}:{% if data.value.first is not empty %}{{ data.value.first }}{% endif %}{% if data.value.second is not empty %} {{ data.value.second }}{% endif %}{% if data.value.last is not empty %} {{ data.value.last }}{% endif %} {% else %} {{ data.label }}:{% if data.value is same as(true) %}Π”Π°{% elseif data.value is same as(false) %}НСт{% elseif data.value is empty %}{% else %}{{ data.value }}{% endif %} {% endif %} diff --git a/mirzaev/ebala/system/views/elements/lists/task/passed.html b/mirzaev/ebala/system/views/elements/lists/task/passed.html index 2eaa69f..34b2e75 100644 --- a/mirzaev/ebala/system/views/elements/lists/task/passed.html +++ b/mirzaev/ebala/system/views/elements/lists/task/passed.html @@ -2,7 +2,7 @@ {% for key, data in task | filter((data, key) => key != '_key') -%} {% if (key == 'created' or key == 'updated' or key == 'start' or key == 'end') %} {{ data.label }}:{{ data.value is empty ? 'Никогда' : - data.value|date('d.m.Y H:i', ) }} + data.value|date('d.m.Y H:i') }} {% elseif key == 'confirmed' or key == 'hided' %} {{ data.label }}:{% if data.value is same as(true) %}Π”Π°{% elseif data.value is same as(false) or data.value is empty %}НСт{% else %}{{ data.value }}{% endif %} diff --git a/mirzaev/ebala/system/views/elements/lists/worker.html b/mirzaev/ebala/system/views/elements/lists/worker.html index 0099125..29b6762 100644 --- a/mirzaev/ebala/system/views/elements/lists/worker.html +++ b/mirzaev/ebala/system/views/elements/lists/worker.html @@ -1,21 +1,21 @@ -{% for key, data in worker | filter((data, key) => key != '_key') -%} +{% for key, data in worker | filter((data, key) => key != 'id') -%} {% if key == 'created' or key == 'updated' %} -{{ data.label }}:{{ data.value is empty ? 'Никогда' : +{{ data.label }}:{{ data.value is empty ? 'Никогда' : data.value|date('Y.m.d H:i:s') }} {% elseif key == 'hiring' or key == 'birth' or key == 'issued' %} -{{ data.label }}:{{ data.value|date('Y.m.d') }} +{{ data.label }}:{{ data.value|date('Y.m.d') }} {% elseif key == 'number' %} -{{ data.label }}:{{ +{{ data.label }}:{{ data.value }} {% elseif key == 'mail' %} {{ data.label }}:{{ data.value }} {% elseif key == 'name' %} - {{ data.label }}:{% if data.value.first is not empty %}{{ data.value.first }}{% endif %}{% if data.value.second is not empty %} {{ data.value.second }}{% endif %}{% if data.value.last is not empty %} {{ data.value.last }}{% endif %} + {{ data.label }}:{% if data.value.first is not empty %}{{ data.value.first }}{% endif %}{% if data.value.second is not empty %} {{ data.value.second }}{% endif %}{% if data.value.last is not empty %} {{ data.value.last }}{% endif %} {% elseif key == 'department' %} -{{ data.label }}:{{ (data.value.number ~ ' ' ~ data.value.address)|trim }} +{{ data.label }}:{{ (data.value.number ~ ' ' ~ data.value.address)|trim }} {% else %} -{{ data.label }}:{% if data.value is same as(true) %}Π”Π°{% elseif data.value is same as(false) %}НСт{% elseif data.value is empty %}{% else %}{{ data.value }}{% endif %} +{{ data.label }}:{% if data.value is same as(true) %}Π”Π°{% elseif data.value is same as(false) %}НСт{% elseif data.value is empty %}{% else %}{{ data.value }}{% endif %} {% endif %} {% endfor %} diff --git a/mirzaev/ebala/system/views/elements/markets.html b/mirzaev/ebala/system/views/elements/markets.html index 2cdf904..dfb1187 100644 --- a/mirzaev/ebala/system/views/elements/markets.html +++ b/mirzaev/ebala/system/views/elements/markets.html @@ -2,7 +2,7 @@ {% for row in rows %}
{{ row.account._key }} - {{ row.market._key }} + {{ row.market.id }} {% if row.market.name.first is not empty %}{{ row.market.name.first|slice(0, 1)|upper }}.{% endif %}{% if row.market.name.last is not empty %} {{ row.market.name.last|slice(0, 1)|upper }}.{% endif %}{% if row.market.name.second is not empty %} {{ row.market.name.second }}{% endif %} {{ row.market.number|storaged_number_to_readable }} {{ row.market.mail }} diff --git a/mirzaev/ebala/system/views/elements/tasks.html b/mirzaev/ebala/system/views/elements/tasks.html index 1934af2..2070e0d 100644 --- a/mirzaev/ebala/system/views/elements/tasks.html +++ b/mirzaev/ebala/system/views/elements/tasks.html @@ -10,7 +10,7 @@ }} {{ - row.worker._key }} + row.worker.id }} {% if row.worker.name.first is not empty %}{{ @@ -27,7 +27,7 @@ row.task.generated.hours }} {{ - row.market._key }} + row.market.id }} {% if row.market.city is not null %}{{ row.market.city }}, {% endif diff --git a/mirzaev/ebala/system/views/elements/workers.html b/mirzaev/ebala/system/views/elements/workers.html index 34d533c..b54635f 100644 --- a/mirzaev/ebala/system/views/elements/workers.html +++ b/mirzaev/ebala/system/views/elements/workers.html @@ -5,7 +5,7 @@ {{ row.account._key }} {{ - row.worker._key }} + row.worker.id }} {% if row.worker.name.first is not empty %}{{ diff --git a/mirzaev/ebala/system/views/lists/markets.html b/mirzaev/ebala/system/views/lists/markets.html index 26b7c19..b37e53e 100644 --- a/mirzaev/ebala/system/views/lists/markets.html +++ b/mirzaev/ebala/system/views/lists/markets.html @@ -1,5 +1,5 @@ {% for market in markets %} - {% endfor %} diff --git a/mirzaev/ebala/system/views/lists/workers.html b/mirzaev/ebala/system/views/lists/workers.html index d1e8a59..e30aca6 100644 --- a/mirzaev/ebala/system/views/lists/workers.html +++ b/mirzaev/ebala/system/views/lists/workers.html @@ -1,5 +1,5 @@ {% for worker in workers %} - diff --git a/mirzaev/ebala/system/views/pages/entry/market.html b/mirzaev/ebala/system/views/pages/entry/market.html index 48d78c9..202d5f0 100755 --- a/mirzaev/ebala/system/views/pages/entry/market.html +++ b/mirzaev/ebala/system/views/pages/entry/market.html @@ -25,8 +25,8 @@ class="icon arrow right"> {% for account in accounts %} - + {% endfor %}