Исправления и начало добавления рассчёта доставки

This commit is contained in:
Arsen Mirzaev Tatyano-Muradovich 2021-04-13 07:21:31 +10:00
parent fe0453f91b
commit d4bc3e2263
12 changed files with 802 additions and 175 deletions

View File

@ -26,7 +26,8 @@
"carono/yii2-1c-exchange": "^0.3.1",
"yiisoft/yii2-imagine": "*",
"mirzaev/yii2-arangodb": ">=2.1.x-dev",
"mirzaev/yii2-arangodb-sessions": ">=1.1.x-dev"
"mirzaev/yii2-arangodb-sessions": ">=1.1.x-dev",
"guzzlehttp/guzzle": "^7.3"
},
"require-dev": {
"codeception/codeception": ">=4.1",

398
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "ccecbc4681132b24e370af7c3db52dd8",
"content-hash": "281d5a604bec47375e20427f528690c7",
"packages": [
{
"name": "bower-asset/bootstrap",
@ -471,6 +471,239 @@
},
"time": "2020-06-29T00:56:53+00:00"
},
{
"name": "guzzlehttp/guzzle",
"version": "7.3.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "7008573787b430c1c1f650e3722d9bba59967628"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628",
"reference": "7008573787b430c1c1f650e3722d9bba59967628",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.4",
"guzzlehttp/psr7": "^1.7 || ^2.0",
"php": "^7.2.5 || ^8.0",
"psr/http-client": "^1.0"
},
"provide": {
"psr/http-client-implementation": "1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.4.1",
"ext-curl": "*",
"php-http/client-integration-tests": "^3.0",
"phpunit/phpunit": "^8.5.5 || ^9.3.5",
"psr/log": "^1.1"
},
"suggest": {
"ext-curl": "Required for CURL handler support",
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
"psr/log": "Required for using the Log middleware"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "7.3-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://sagikazarmark.hu"
}
],
"description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"psr-18",
"psr-7",
"rest",
"web service"
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/7.3.0"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://github.com/alexeyshockov",
"type": "github"
},
{
"url": "https://github.com/gmponos",
"type": "github"
}
],
"time": "2021-03-23T11:33:13+00:00"
},
{
"name": "guzzlehttp/promises",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d",
"reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d",
"shasum": ""
},
"require": {
"php": ">=5.5"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.4 || ^5.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
"source": "https://github.com/guzzle/promises/tree/1.4.1"
},
"time": "2021-03-07T09:25:29+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "35ea11d335fd638b5882ff1725228b3d35496ab1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/35ea11d335fd638b5882ff1725228b3d35496ab1",
"reference": "35ea11d335fd638b5882ff1725228b3d35496ab1",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0",
"ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"ext-zlib": "*",
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10"
},
"suggest": {
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"psr-7",
"request",
"response",
"stream",
"uri",
"url"
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/1.8.1"
},
"time": "2021-03-21T16:25:00+00:00"
},
{
"name": "imagine/imagine",
"version": "1.2.4",
@ -1304,6 +1537,50 @@
},
"time": "2017-10-23T01:57:42+00:00"
},
{
"name": "ralouphie/getallheaders",
"version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/getallheaders.git",
"reference": "120b605dfeb996808c31b6477290a714d356e822"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
"reference": "120b605dfeb996808c31b6477290a714d356e822",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^5 || ^6.5"
},
"type": "library",
"autoload": {
"files": [
"src/getallheaders.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "A polyfill for getallheaders.",
"support": {
"issues": "https://github.com/ralouphie/getallheaders/issues",
"source": "https://github.com/ralouphie/getallheaders/tree/develop"
},
"time": "2019-03-08T08:55:37+00:00"
},
{
"name": "swiftmailer/swiftmailer",
"version": "v6.2.7",
@ -3119,81 +3396,6 @@
},
"time": "2021-03-30T06:27:33+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "1.8.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "35ea11d335fd638b5882ff1725228b3d35496ab1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/35ea11d335fd638b5882ff1725228b3d35496ab1",
"reference": "35ea11d335fd638b5882ff1725228b3d35496ab1",
"shasum": ""
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0",
"ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"ext-zlib": "*",
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10"
},
"suggest": {
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.7-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"psr-7",
"request",
"response",
"stream",
"uri",
"url"
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/1.8.1"
},
"time": "2021-03-21T16:25:00+00:00"
},
{
"name": "myclabs/deep-copy",
"version": "1.10.2",
@ -4340,50 +4542,6 @@
},
"time": "2019-01-08T18:20:26+00:00"
},
{
"name": "ralouphie/getallheaders",
"version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/getallheaders.git",
"reference": "120b605dfeb996808c31b6477290a714d356e822"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
"reference": "120b605dfeb996808c31b6477290a714d356e822",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^5 || ^6.5"
},
"type": "library",
"autoload": {
"files": [
"src/getallheaders.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "A polyfill for getallheaders.",
"support": {
"issues": "https://github.com/ralouphie/getallheaders/issues",
"source": "https://github.com/ralouphie/getallheaders/tree/develop"
},
"time": "2019-03-08T08:55:37+00:00"
},
{
"name": "sebastian/cli-parser",
"version": "1.0.1",

View File

@ -77,7 +77,7 @@ $config = [
'controller' => 'main'
],
'product/<catn:[^/]+>' => 'product/index',
'product/<catn:[^/]+>/<action:(write|edit|delete)>/<target:(title|catn|dscr|image)>' => 'product/<action>-<target>',
'product/<catn:[^/]+>/<action:(write|edit|delete)>/<target:(title|catn|dscr|dmns|image|cover)>' => 'product/<action>-<target>',
'orders' => 'order/index'
],
],

View File

@ -106,8 +106,8 @@ class ProductController extends Controller
if ($model = Product::searchByCatn($catn)) {
// Товар найден
// Инициализация
$text = yii::$app->request->get('text') ?? yii::$app->request->post('text') ?? 'Без названия';
// Инициализация
$text = yii::$app->request->post('text') ?? yii::$app->request->get('text') ?? 'Без названия';
$model->catn = $text;
@ -138,7 +138,7 @@ class ProductController extends Controller
}
}
public function actionEditDesc(string $catn): array|string|null
public function actionEditDscr(string $catn): array|string|null
{
// Инициализация
$return = [
@ -159,7 +159,7 @@ class ProductController extends Controller
// Инициализация
$text = yii::$app->request->get('text') ?? yii::$app->request->post('text') ?? 'Без названия';
$product->desc = $text;
$product->dscr = $text;
if ($product->save()) {
// Товар обновлён
@ -188,6 +188,63 @@ class ProductController extends Controller
}
}
public function actionEditDmns(string $catn): array|string|null
{
// Инициализация
$return = [
'_csrf' => yii::$app->request->getCsrfToken()
];
if (is_null($catn)) {
// Не получен артикул
yii::$app->response->statusCode = 500;
goto end;
}
if ($product = Product::searchByCatn($catn)) {
// Товар найден
// Инициализация
$text = yii::$app->request->post('text') ?? yii::$app->request->get('text') ?? '0';
$text or $text = '0';
$dimension = yii::$app->request->post('dimension') ?? yii::$app->request->get('dimension') ?? 'x';
$product->dmns = array_merge(
$product->dmns ?? [],
[
$dimension => $text
]
);
if ($product->save()) {
// Товар обновлён
$return['dimension'] = $text;
}
}
/**
* Конец алгоритма
*/
end:
if (yii::$app->request->isPost) {
// POST-запрос
yii::$app->response->format = Response::FORMAT_JSON;
return $return;
}
if ($model = Product::searchByCatn($catn)) {
return $this->render('index', compact('model'));
} else {
return $this->redirect('/');
}
}
public function actionWriteImage(string $catn): array|string|null
{
// Инициализация
@ -203,17 +260,137 @@ class ProductController extends Controller
goto end;
}
if ($model = Product::searchByCatn($catn)) {
if ($product = Product::searchByCatn($catn)) {
// Товар найден
// Инициализация
$model->file_image = UploadedFile::getInstancesByName('images');
$model->scenario = $model::SCENARIO_IMPORT_IMAGE;
$product->file_image = UploadedFile::getInstancesByName('images');
$product->scenario = $product::SCENARIO_IMPORT_IMAGE;
if ($model->importImages() > 0) {
if ($product->importImages() > 0) {
// Товар обновлён
$return['main'] = $this->renderPartial('index', compact('model'));
$return['main'] = $this->renderPartial('index', ['model' => $product]);
}
}
/**
* Конец алгоритма
*/
end:
if (yii::$app->request->isPost) {
// POST-запрос
yii::$app->response->format = Response::FORMAT_JSON;
return $return;
}
if ($model = Product::searchByCatn($catn)) {
return $this->render('index', compact('model'));
} else {
return $this->redirect('/');
}
}
public function actionDeleteImage(string $catn): array|string|null
{
// Инициализация
$return = [
'_csrf' => yii::$app->request->getCsrfToken()
];
$index = yii::$app->request->post('index') ?? yii::$app->request->get('index');
if (is_null($catn) || is_null($index)) {
// Не получены обязательные параметры
yii::$app->response->statusCode = 500;
goto end;
}
if ($product = Product::searchByCatn($catn)) {
// Товар найден
// Инициализация (буфер нужен из-за кривых сеттеров)
$buffer = $product->imgs;
// Удаление
unset($buffer[$index]);
// Запись
$product->imgs = $buffer;
if ($product->save()) {
// Товар обновлён
$return['main'] = $this->renderPartial('index', ['model' => $product]);
}
}
/**
* Конец алгоритма
*/
end:
if (yii::$app->request->isPost) {
// POST-запрос
yii::$app->response->format = Response::FORMAT_JSON;
return $return;
}
if ($model = Product::searchByCatn($catn)) {
return $this->render('index', compact('model'));
} else {
return $this->redirect('/');
}
}
public function actionWriteCover(string $catn): array|string|null
{
// Инициализация
$return = [
'_csrf' => yii::$app->request->getCsrfToken()
];
$index = yii::$app->request->post('index') ?? yii::$app->request->get('index');
if (is_null($catn) || is_null($index)) {
// Не получены обязательные параметры
yii::$app->response->statusCode = 500;
goto end;
}
if ($product = Product::searchByCatn($catn)) {
// Товар найден
// Инициализация (буфер нужен из-за кривых сеттеров)
$buffer = $product->imgs;
foreach($buffer as $image_index => &$image) {
// Перебор изображений
if ($image_index === (int) $index) {
// Найдено запрашиваемое изображение
// Установка обложки
$image['covr'] = true;
} else {
$image['covr'] = false;
}
}
// Запись
$product->imgs = $buffer;
if ($product->save()) {
// Товар обновлён
$return['main'] = $this->renderPartial('index', ['model' => $product]);
}
}

View File

@ -17,6 +17,7 @@ use app\models\Search;
use app\models\Notification;
use app\models\Settings;
use app\models\SettingsEdgeSettings;
use app\models\connection\Dellin;
class ProfileController extends Controller
{
@ -90,6 +91,10 @@ class ProfileController extends Controller
*/
public function actionIndex(): string|array
{
$browser = new Dellin();
$browser->syncCities();
// Инициализация
$model = yii::$app->user->identity;
$panel = yii::$app->request->post('panel') ?? yii::$app->request->get('panel');
@ -117,7 +122,8 @@ class ProfileController extends Controller
}
// Инициализация
$list = $model->genListOem(Supply::searchByAccount(select: 'supply.onec["ЗначенияСвойств"]', limit: null));
$account_sections_city_list = null;
$import_sections_oem_list = $model->genListOem(Supply::searchByAccount(select: 'supply.onec["ЗначенияСвойств"]'));
if (yii::$app->request->isPost) {
// POST-запрос
@ -128,7 +134,8 @@ class ProfileController extends Controller
'main' => $this->renderPartial('index', compact(
'model',
'sidebar',
'list',
'account_sections_city_list',
'import_sections_oem_list',
'panel'
)),
'redirect' => '/profile',
@ -139,7 +146,8 @@ class ProfileController extends Controller
return $this->render('index', compact(
'model',
'sidebar',
'list',
'account_sections_city_list',
'import_sections_oem_list',
'panel'
));
}

View File

@ -0,0 +1,20 @@
<?php
use mirzaev\yii2\arangodb\Migration;
class m210412_171912_create_city_controller extends Migration
{
public function up()
{
/**
* @param string Название коллекции
* @param array Тип коллекции (2 - документ, 3 - ребро)
*/
$this->createCollection('city', ['type' => 2]);
}
public function down()
{
$this->dropCollection('city');
}
}

View File

@ -9,6 +9,8 @@ use yii\web\IdentityInterface;
use carono\exchange1c\interfaces\PartnerInterface;
use app\models\connection\Dellin;
/**
* Аккаунт
*
@ -245,6 +247,20 @@ class Account extends Document implements IdentityInterface, PartnerInterface
return $this->save();
}
/**
* Генерация списка городов
*
* Актуальное (выбранное, активное) значение записывается первым
*/
public function genListCity(): array
{
$browser = new Dellin();
$request = $browser->get('https://api.github.com/user', [
'auth' => ['user', 'pass']
]);
}
/**
* Генерация списка OEM-номеров
*

View File

@ -0,0 +1,65 @@
<?php
declare(strict_types=1);
namespace app\models;
class City extends Document
{
public static function collectionName(): string
{
return 'city';
}
public function attributes(): array
{
return array_merge(
parent::attributes(),
[
'name',
'code',
'term'
]
);
}
public function rules(): array
{
return array_merge(
parent::rules(),
[
[
[
'name',
'code'
],
'required',
'message' => 'Заполните поле: {attribute}'
],
[
[
'name',
'code'
],
'string'
],
[
'term',
'boolean'
]
]
);
}
public function attributeLabels(): array
{
return array_merge(
parent::attributeLabels(),
[
'name' => 'Название',
'code' => 'Код КЛАДР',
'term' => 'Указатель наличия терминала в городе'
]
);
}
}

View File

@ -0,0 +1,155 @@
<?php
declare(strict_types=1);
namespace app\models\connection;
use yii;
use yii\base\Model;
use app\models\City;
use GuzzleHttp\Client as Guzzle;
use Exception;
class Dellin extends Model
{
/**
* Инстанция браузера
*/
public Guzzle $browser;
/**
* Сессия аккаунта
*/
public string $session;
public function __construct($config = [])
{
parent::__construct($config);
$this->browser = new Guzzle([
'base_uri' => 'https://api.dellin.ru/'
]);
$this->authorization();
}
/**
* Поиск городов
*
* @return array|null Найденные города
*/
public function searchCities(): ?array
{
// $this->onReady(function () {
// // Запрос городов
// $request = $this->browser->post('/v2/public/kladr.json', [
// 'json' => [
// 'appkey' => yii::$app->params['dellin']['key'],
// ]
// ])
// });
}
/**
* Синхронизация городов
*
* @return array|null Найденные города
*
* @todo Написать проверку по хешу
*/
public function syncCities(): ?array
{
return $this->ifReady(function () {
// Запрос ссылки на файл с городам
// Получаем hash и url ()
$request = $this->browser->post('/v1/public/cities.json', [
'json' => [
'appkey' => yii::$app->params['dellin']['key'],
]
]);
if ($request->getStatusCode() === 200) {
// Запрос прошел успешно
// Инициализация
$response = json_decode((string) $request->getBody(), true);
if ($response['metadata']['status'] === 200) {
// Аутентификация и авторизация пройдены успешно
// Запись сессии
return $this;
}
throw new Exception('Не удалось синхронизировать данные городов с ДеловыеЛинии', $response['metadata']['status']);
}
throw new Exception('Не удалось синхронизировать данные городов с ДеловыеЛинии', $request->getStatusCode);
});
}
/**
* Аутентификация и авторизация
*/
protected function authorization(): ?self
{
return $this->ifReady(function () {
// Аутентификация и авторизация
$request = $this->browser->post('/v3/auth/login.json', [
'json' => [
'appkey' => yii::$app->params['dellin']['key'],
'login' => yii::$app->params['dellin']['nickname'],
'password' => yii::$app->params['dellin']['password']
]
]);
if ($request->getStatusCode() === 200) {
// Запрос прошел успешно
// Инициализация
$response = json_decode((string) $request->getBody(), true);
if ($response['metadata']['status'] === 200) {
// Аутентификация и авторизация пройдены успешно
// Запись сессии
$this->session = $response['data']['sessionID'];
return $this;
}
throw new Exception('Не удалось авторизироваться в ДеловыеЛинии', $response['metadata']['status']);
}
throw new Exception('Не удалось авторизироваться в ДеловыеЛинии', $request->getStatusCode);
});
}
/**
* Проверка на то, что браузер готов к работе
*
* @param callable $function Код к выполнению
* @param [type] ...$vars Параметры к нему
*
* @return mixed Возврат из функции
*/
protected function ifReady(callable $function, ...$vars): mixed
{
if (isset($this->browser)) {
// Браузер инициализирован
return $function(...$vars);
}
throw new Exception('Браузер не инициализирован', 500);
}
}

View File

@ -10,7 +10,7 @@ if (
!yii::$app->user->isGuest
&& yii::$app->user->identity->agnt
) {
$panel ?? $panel = 'profile_panel_settings_import';
$panel ?? $panel = 'profile_panel_settings_account';
} else {
$panel ?? $panel = 'profile_panel_settings_account';
}
@ -28,38 +28,19 @@ if (
<h4 class="ml-4 mb-4"><i class="fas fa-sliders-h my-auto mr-2"></i>Настройки</h4>
<div id="profile_panel_settings" class="profile_panel">
<div class="profile_panel_menu mb-3">
<label class="btn button_white mb-0 mr-2" for="profile_panel_settings_account">Аккаунт</label>
<?php
if (
!yii::$app->user->isGuest
&& yii::$app->user->identity->agnt
) {
echo <<<HTML
<?php if (!yii::$app->user->isGuest) : ?>
<label class="btn button_white mb-0 mr-2" for="profile_panel_settings_account">Аккаунт</label>
<?php if (yii::$app->user->identity->agnt) : ?>
<label class="btn button_white mb-0 mr-2" for="profile_panel_settings_company">Компания</label>
<label class="btn button_white mb-0" for="profile_panel_settings_import">Импорт</label>
HTML;
}
?>
<?php endif ?>
<?php endif ?>
</div>
<div class="profile_panel_content d-flex">
<input type="radio" id="profile_panel_settings_account" name="main_panel" <?= $panel === 'profile_panel_settings_account' ? 'checked' : null ?> />
<div class="col">
1
</div>
<?php if (
!yii::$app->user->isGuest
&& yii::$app->user->identity->agnt
) : ?>
<input type="radio" id="profile_panel_settings_company" name="main_panel" <?= $panel === 'profile_panel_settings_company' ? 'checked' : null ?> />
<?php if (!yii::$app->user->isGuest) : ?>
<input type="radio" id="profile_panel_settings_account" name="main_panel" <?= $panel === 'profile_panel_settings_account' ? 'checked' : null ?> />
<div class="col">
2
</div>
<input type="radio" id="profile_panel_settings_import" name="main_panel" <?= $panel === 'profile_panel_settings_import' ? 'checked' : null ?> />
<div class="col">
<h5>Параметры 1C</h5>
<div class="dropdown-divider mb-3"></div>
<h5>Основная информация</h5>
<?php $form = ActiveForm::begin([
'id' => 'form_profile_settings',
'action' => false,
@ -73,20 +54,57 @@ if (
// Инициализация
$model ?? $model = yii::$app->user->identity;
$list or $list = ['Нет данных'];
$account_sections_city_list or $account_sections_city_list = ['Нет данных'];
?>
<?= $form->field($model, 'opts[import_sections_oem]', ['options' => ['class' => "mb-1"]])
->dropDownList($list, [
'onChange' => 'page_profile_settings(this.parentElement.parentElement, \'profile_panel_settings_import\')',
'disabled' => count($list) <= 1
])->label('OEM-номера'); ?>
<?= $form->field($model, 'opts[account_sections_city]', ['options' => ['class' => "mb-1"]])
->dropDownList($account_sections_city_list, [
'onChange' => 'page_profile_settings(this.parentElement.parentElement, \'profile_panel_settings_account\')'
])->label('Город'); ?>
<small class="d-block mb-1">Выберите поле в котором хранятся <b>ОЕМ-номера</b> и повторите импорт</small>
<small class="d-block">Значения взяты из импортированных товаров</small>
<small class="d-block mb-1">Выберите город для <b>рассчёта доставки</b></small>
<?php ActiveForm::end(); ?>
</div>
<?php if (yii::$app->user->identity->agnt) : ?>
<input type="radio" id="profile_panel_settings_company" name="main_panel" <?= $panel === 'profile_panel_settings_company' ? 'checked' : null ?> />
<div class="col">
2
</div>
<input type="radio" id="profile_panel_settings_import" name="main_panel" <?= $panel === 'profile_panel_settings_import' ? 'checked' : null ?> />
<div class="col">
<h5>Параметры 1C</h5>
<div class="dropdown-divider mb-3"></div>
<?php $form = ActiveForm::begin([
'id' => 'form_profile_settings',
'action' => false,
'fieldConfig' => [
'template' => '{label}{input}',
],
'options' => [
'onsubmit' => 'return false;'
]
]);
// Инициализация
$model ?? $model = yii::$app->user->identity;
$import_sections_oem_list or $import_sections_oem_list = ['Нет данных'];
?>
<?= $form->field($model, 'opts[import_sections_oem]', ['options' => ['class' => "mb-1"]])
->dropDownList($import_sections_oem_list, [
'onChange' => 'page_profile_settings(this.parentElement.parentElement, \'profile_panel_settings_import\')',
'disabled' => count($import_sections_oem_list) <= 1
])->label('OEM-номера'); ?>
<small class="d-block mb-1">Выберите поле в котором хранятся <b>ОЕМ-номера</b> и повторите импорт</small>
<small class="d-block">Значения взяты из импортированных товаров</small>
<?php ActiveForm::end(); ?>
</div>
<?php endif ?>
<?php endif ?>
</div>
</div>

View File

@ -48,7 +48,7 @@ location ~* ^.+\.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?
location / {
# Force index.php routing (if not found)
try_files $uri $uri/ /index.php$is_args$args;
try_files $uri $uri/ /index_dev.php$is_args$args;
# Force index.php routing (all requests)
# rewrite ^/(.*)$ /index.php?/$1 last;

View File

@ -176,12 +176,21 @@ function page_profile_response(data, status) {
}
// Сокрытие первого элемента <option> в списке
function initDropdownOem() {
function initDropdownImportSectionsOem() {
let dropdown = document.getElementById('account-opts-import_sections_oem');
if (dropdown !== null && dropdown.length > 1) {
dropdown.children[0].hidden = true;
}
}
// Сокрытие первого элемента <option> в списке
function initDropdownAccountSectionsCity() {
let dropdown = document.getElementById('account-opts-account_sections_city');
initDropdownOem();
if (dropdown !== null && dropdown.length > 1) {
dropdown.children[0].hidden = true;
}
}
initDropdownImportSectionsOem();
initDropdownAccountSectionsCity();