diff --git a/mirzaev/skillparts/system/config/web.php.example b/mirzaev/skillparts/system/config/web.php.example index f4e1296..4326101 100644 --- a/mirzaev/skillparts/system/config/web.php.example +++ b/mirzaev/skillparts/system/config/web.php.example @@ -99,9 +99,9 @@ $config = [ 'profile/geolocation/' => 'profile/geolocation-', 'orders' => 'order/index', 'orders/' => 'order/index', - 'orders/<_key:[^/]+>/' => 'order/', - 'orders/supply/<_key:[^/]+>/' => 'order/supply-', - 'orders/supply/<_key:[^/]+>//' => 'order/supply--', + 'orders//' => 'order/', + 'orders/supply//' => 'order/supply-', + 'orders/supply///' => 'order/supply--', 'invoices/' => 'invoice/index', 'invoices//' => 'invoice/', 'verify/send' => 'verify/send', diff --git a/mirzaev/skillparts/system/controllers/AuthenticationController.php b/mirzaev/skillparts/system/controllers/AuthenticationController.php index cc0a3c8..0db15ef 100644 --- a/mirzaev/skillparts/system/controllers/AuthenticationController.php +++ b/mirzaev/skillparts/system/controllers/AuthenticationController.php @@ -44,11 +44,14 @@ class AuthenticationController extends Controller // Фильтрация $target = match ($target) { - 'menu' => 'menu', + 'panel' => 'panel', 'main' => 'main', default => 'main' }; + // Рендер для всплывающей панели + $panel = $target === 'panel'; + if (yii::$app->request->isPost) { // AJAX-POST-запрос @@ -72,15 +75,13 @@ class AuthenticationController extends Controller // Инициализация $notifications_button = $this->renderPartial('/notification/button'); - $notifications_panel_full = true; - $notifications_panel = $this->renderPartial('/notification/panel', compact('notifications_panel_full')); + $notifications_panel = $this->renderPartial('/notification/panel', ['notifications_panel_full' => true]); // Запись ответа $return = [ - $target => $this->renderPartial('/account/panel/authenticated', compact( + 'menu' => $this->renderPartial('/account/panel/authenticated', compact( 'notifications_button', - 'notifications_panel', - 'notifications_panel_full' + 'notifications_panel' )), '_csrf' => yii::$app->request->getCsrfToken() ]; @@ -131,7 +132,7 @@ class AuthenticationController extends Controller yii::$app->response->statusCode = 400; return [ - $target => $this->renderPartial('/account/index', compact('model')), + $target => $this->renderPartial('/account/index', compact('model', 'panel')), 'redirect' => '/authentication', '_csrf' => yii::$app->request->getCsrfToken() ]; @@ -141,7 +142,7 @@ class AuthenticationController extends Controller if (!yii::$app->user->isGuest) { yii::$app->response->redirect('/'); } else { - return $this->render('/account/index'); + return $this->render('/account/index', compact('model', 'panel')); } } } diff --git a/mirzaev/skillparts/system/controllers/OrderController.php b/mirzaev/skillparts/system/controllers/OrderController.php index 08f3188..5cbd570 100644 --- a/mirzaev/skillparts/system/controllers/OrderController.php +++ b/mirzaev/skillparts/system/controllers/OrderController.php @@ -19,6 +19,7 @@ use app\models\connection\Dellin; use app\models\Invoice; use app\models\Notification; use app\models\Settings; +use app\models\Supply; use app\models\SupplyEdgeProduct; use Codeception\PHPUnit\ResultPrinter\HTML; @@ -561,15 +562,20 @@ class OrderController extends Controller /** * Чтение инстанции поставки в заказе (order_edge_supply) * - * @param int $_key Ключ записи в коллекции order_edge_supply + * @param string $catn Артикул поставки * * @return string|array|null */ - public function actionSupplyRead(int $_key): string|array|null + public function actionSupplyRead(string $catn): string|array|null { // Инициализация $buffer = []; + if ($supply = OrderEdgeSupply::searchBySupplyCatn($catn)) { + // Удалось найти инстанцию поставки + + } + if ($order_edge_supply = OrderEdgeSupply::searchById($_id = OrderEdgeSupply::collectionName() . '/' . $_key)) { // Удалось найти инстанцию поставки @@ -661,17 +667,24 @@ class OrderController extends Controller /** * Запись статуса поставки в заказе (order_edge_supply) * - * @param int $_key Ключ записи в коллекции order_edge_supply + * @param string $catn Артикул поставки * * @return string|array|null */ - public function actionSupplyWriteStts(int $_key): string|array|null + public function actionSupplyWriteStts(string $catn): string|array|null { // Инициализация - $stts = yii::$app->request->post('stts') ?? yii::$app->request->get('stts'); + $stts = yii::$app->request->post('stts') ?? yii::$app->request->get('stts') ?? ''; $buffer = []; - if ($order_edge_supply = OrderEdgeSupply::searchById($_id = OrderEdgeSupply::collectionName() . '/' . $_key)) { + if ($supply = OrderEdgeSupply::searchBySupplyCatn($_id = Supply::collectionName() . '/' . $catn)) { + // Удалось найти инстанцию поставки + + var_dump($supply); + + } + + if ($order_edge_supply = OrderEdgeSupply::searchById($_id = OrderEdgeSupply::collectionName() . '/' . $catn)) { // Удалось найти инстанцию поставки // Запись в буфер изначальных данных @@ -711,17 +724,17 @@ class OrderController extends Controller /** * Запись цены поставки в заказе (order_edge_supply) * - * @param int $_key Ключ записи в коллекции order_edge_supply + * @param string $catn Артикул поставки * * @return string|array|null */ - public function actionSupplyEditCost(int $_key): string|array|null + public function actionSupplyEditCost(int $catn): string|array|null { // Инициализация $cost = yii::$app->request->post('cost') ?? yii::$app->request->get('cost'); $buffer = []; - if ($order_edge_supply = OrderEdgeSupply::searchById($_id = OrderEdgeSupply::collectionName() . '/' . $_key)) { + if ($order_edge_supply = OrderEdgeSupply::searchById($_id = OrderEdgeSupply::collectionName() . '/' . $catn)) { // Удалось найти инстанцию поставки // Запись в буфер изначальных данных diff --git a/mirzaev/skillparts/system/controllers/RegistrationController.php b/mirzaev/skillparts/system/controllers/RegistrationController.php index cf97c53..39347ca 100644 --- a/mirzaev/skillparts/system/controllers/RegistrationController.php +++ b/mirzaev/skillparts/system/controllers/RegistrationController.php @@ -19,16 +19,24 @@ class RegistrationController extends Controller // Инициализация $model = new AccountForm(yii::$app->request->post('AccountForm') ?? yii::$app->request->get('AccountForm')); $type = yii::$app->request->post('type') ?? yii::$app->request->get('type'); + $target = yii::$app->request->post('target') ?? yii::$app->request->get('target'); $model->scenario = $model::SCENARIO_REGISTRATION; + // Фильтрация + $target = match ($target) { + 'panel' => 'panel', + 'main' => 'main', + default => 'main' + }; + + // Рендер для всплывающей панели + $panel = $target === 'panel'; + if (yii::$app->request->isPost) { // POST-запрос yii::$app->response->format = Response::FORMAT_JSON; - // Валидация формы - if (!empty($errors = ActiveForm::validate($model))) return $errors; - if ($type === 'registration' && (!yii::$app->user->isGuest || $model->registration())) { // Данные прошли проверку и аккаунт был создан @@ -43,7 +51,7 @@ class RegistrationController extends Controller $model->scenario = $model::SCENARIO_REGISTRATION; return [ - 'main' => $this->renderPartial('/account/index', compact('model') + ['registration' => true]), + $target => $this->renderPartial('/account/index', compact('model', 'panel') + ['registration' => true]), 'redirect' => '/registration', '_csrf' => yii::$app->request->getCsrfToken() ]; @@ -51,8 +59,7 @@ class RegistrationController extends Controller // Инициализация $notifications_button = $this->renderPartial('/notification/button'); - $notifications_panel_full = true; - $notifications_panel = $this->renderPartial('/notification/panel', compact('notifications_panel_full')); + $notifications_panel = $this->renderPartial('/notification/panel', ['notifications_panel_full' => true]); // Запись ответа $return = [ @@ -108,7 +115,7 @@ class RegistrationController extends Controller yii::$app->response->statusCode = 400; return [ - 'main' => $this->renderPartial('/account/index', compact('model') + ['registration' => true]), + $target => $this->renderPartial('/account/index', compact('model', 'panel') + ['registration' => true]), 'redirect' => '/registration', '_csrf' => yii::$app->request->getCsrfToken() ]; @@ -118,7 +125,7 @@ class RegistrationController extends Controller if (!yii::$app->user->isGuest) { yii::$app->response->redirect('/'); } else { - return $this->render('/account/index', compact('model') + ['registration' => true]); + return $this->render('/account/index', compact('model', 'panel') + ['registration' => true]); } } } diff --git a/mirzaev/skillparts/system/models/Order.php b/mirzaev/skillparts/system/models/Order.php index 6af90b8..147db59 100644 --- a/mirzaev/skillparts/system/models/Order.php +++ b/mirzaev/skillparts/system/models/Order.php @@ -337,6 +337,17 @@ class Order extends Document implements DocumentInterface return $limit === 1 ? $return[0] ?? null : $return; } + // /** + // * Объеденить дубликаты поставок + // * + // * @return array Данные заказа + // */ + // public function mergeDuplicateSupplies(array $order): array { + // foreach ($orders as $order) { + + // } + // } + /** * Поиск содержимого заказа * @@ -444,6 +455,7 @@ class Order extends Document implements DocumentInterface foreach ($connections as &$connection_for_check) { if ($connection == $connection_for_check) { // Найден дубликат + // Запись в реестр $registry[$key] = [ 'catn' => $connection_for_check['supply']['catn'], @@ -456,7 +468,6 @@ class Order extends Document implements DocumentInterface $connection['amount'] = count($connection['order_edge_supply']); } - // Инициализация дополнительных данных foreach ($connections as $key => &$connection) { // Перебор поставок @@ -620,6 +631,27 @@ class Order extends Document implements DocumentInterface return $connections; } + /** + * Проверка на то, что все поставки подтверждены + * + * @param array $order_edge_supply Поставки + * + * @return bool Статус подтверждения всех поставок (true если все и false если хотя бы одна из них не подтверждена) + */ + public static function checkSuppliesStts(array $order_edge_supply): bool { + foreach ($order_edge_supply as $edge) { + // Перебор поставок + + if (empty($edge['stts']) || $edge['stts'] !== 'accepted') { + // Найдена неподтверждённая поставка + + return false; + } + } + + return true; + } + /** * @return DocumentInterface[] */ diff --git a/mirzaev/skillparts/system/views/account/index.php b/mirzaev/skillparts/system/views/account/index.php index 9a48e40..09b5cef 100644 --- a/mirzaev/skillparts/system/views/account/index.php +++ b/mirzaev/skillparts/system/views/account/index.php @@ -19,12 +19,12 @@ use app\models\AccountForm; - +
Регистрация

Регистрация

- +
Аутентификация

Аутентификация

- field($model, 'mail', ['enableLabel' => false, 'options' => ['class' => 'mb-2'], 'errorOptions' => ['class' => 'help-block help-block-error px-2 small']])->textInput(['autofocus' => true, 'placeholder' => $model->getAttributeLabel('mail')]) ?> - field($model, 'pswd', ['enableLabel' => false, 'errorOptions' => ['class' => 'help-block help-block-error px-2 small']])->passwordInput(['placeholder' => $model->getAttributeLabel('pswd')]) ?> + field($model, 'mail', ['enableLabel' => false, 'options' => ['class' => 'mb-2'], 'inputOptions' => ['class' => 'form-control button_clean', 'errorOptions' => ['class' => 'help-block help-block-error px-2 small']]])->textInput(['autofocus' => true, 'placeholder' => $model->getAttributeLabel('mail')]) ?> + field($model, 'pswd', ['enableLabel' => false, 'inputOptions' => ['class' => 'form-control button_clean'], 'errorOptions' => ['class' => 'help-block help-block-error px-2 small']])->passwordInput(['placeholder' => $model->getAttributeLabel('pswd')]) ?>
'submitAuthentication', 'onclick' => 'authentication(this.parentElement.parentElement, \'' . $target . '\');', 'class' => 'flex-grow-1 mr-2 btn btn-primary button_clean']) ?> @@ -77,7 +77,7 @@ use app\models\AccountForm; '{endLabel}
'])->checkbox()->label($model->getAttributeLabel('auto'), ['class' => 'w-100 m-0']) ?> - 'submitRegistration', 'onclick' => 'return registration_start(this.parentElement);', 'class' => 'col-12 ml-auto btn btn-success btn-sm button_clean']) ?> + 'submitRegistration', 'onclick' => 'return registration_start(this.parentElement, \'' . $target . '\');', 'class' => 'col-12 ml-auto btn btn-success btn-sm button_clean']) ?>