Добавлены сессии, разделение по правам доступа, редактирование товаров
This commit is contained in:
parent
722bf6c378
commit
3fea918255
|
@ -1,2 +1,3 @@
|
||||||
/vendor
|
/vendor
|
||||||
/cache
|
/cache
|
||||||
|
/.vscode
|
|
@ -24,8 +24,7 @@
|
||||||
"triagens/arangodb": "^3.6",
|
"triagens/arangodb": "^3.6",
|
||||||
"moonlandsoft/yii2-phpexcel": ">=2.0",
|
"moonlandsoft/yii2-phpexcel": ">=2.0",
|
||||||
"carono/yii2-1c-exchange": "^0.3.1",
|
"carono/yii2-1c-exchange": "^0.3.1",
|
||||||
"mirzaev/yii2-arangodb": "~2.1.x-dev",
|
"yiisoft/yii2-imagine": "*"
|
||||||
"mirzaev/yii2-arangodb-sessions": "~1.0.0"
|
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"codeception/codeception": ">=4.1",
|
"codeception/codeception": ">=4.1",
|
||||||
|
@ -42,7 +41,9 @@
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"mirzaev\\skillparts\\": "mirzaev/skillparts/system"
|
"mirzaev\\skillparts\\": "mirzaev/skillparts/system",
|
||||||
|
"mirzaev\\yii2\\arangodb\\": "../yii2-arangodb/mirzaev/yii2/arangodb",
|
||||||
|
"mirzaev\\yii2\\arangodb\\sessions\\": "../yii2-arangodb-sessions/mirzaev/yii2/arangodb/sessions"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "116946ecdb84687a081d5633fd8505f6",
|
"content-hash": "77be6b3a5d18070b9d685430060a770e",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "bower-asset/bootstrap",
|
"name": "bower-asset/bootstrap",
|
||||||
|
@ -471,6 +471,68 @@
|
||||||
},
|
},
|
||||||
"time": "2020-06-29T00:56:53+00:00"
|
"time": "2020-06-29T00:56:53+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "imagine/imagine",
|
||||||
|
"version": "1.2.4",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/avalanche123/Imagine.git",
|
||||||
|
"reference": "d2e18be6e930ca169e4f921ef73ebfc061bf55d8"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/avalanche123/Imagine/zipball/d2e18be6e930ca169e4f921ef73ebfc061bf55d8",
|
||||||
|
"reference": "d2e18be6e930ca169e4f921ef73ebfc061bf55d8",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"friendsofphp/php-cs-fixer": "^2.2",
|
||||||
|
"phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"ext-gd": "to use the GD implementation",
|
||||||
|
"ext-gmagick": "to use the Gmagick implementation",
|
||||||
|
"ext-imagick": "to use the Imagick implementation"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-develop": "0.7-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Imagine\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Bulat Shakirzyanov",
|
||||||
|
"email": "mallluhuct@gmail.com",
|
||||||
|
"homepage": "http://avalanche123.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Image processing for PHP 5.3",
|
||||||
|
"homepage": "http://imagine.readthedocs.org/",
|
||||||
|
"keywords": [
|
||||||
|
"drawing",
|
||||||
|
"graphics",
|
||||||
|
"image manipulation",
|
||||||
|
"image processing"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/avalanche123/Imagine/issues",
|
||||||
|
"source": "https://github.com/avalanche123/Imagine/tree/1.2.4"
|
||||||
|
},
|
||||||
|
"time": "2020-11-03T22:35:03+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "maennchen/zipstream-php",
|
"name": "maennchen/zipstream-php",
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
|
@ -2019,6 +2081,89 @@
|
||||||
],
|
],
|
||||||
"time": "2020-06-24T00:04:01+00:00"
|
"time": "2020-06-24T00:04:01+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "yiisoft/yii2-imagine",
|
||||||
|
"version": "2.3.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/yiisoft/yii2-imagine.git",
|
||||||
|
"reference": "b103b1b1deb786d4d5fe955898ec866dbee5c1b4"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/yiisoft/yii2-imagine/zipball/b103b1b1deb786d4d5fe955898ec866dbee5c1b4",
|
||||||
|
"reference": "b103b1b1deb786d4d5fe955898ec866dbee5c1b4",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"imagine/imagine": "^1.0",
|
||||||
|
"yiisoft/yii2": "~2.0.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"cweagans/composer-patches": "^1.7",
|
||||||
|
"phpunit/phpunit": "4.8.34"
|
||||||
|
},
|
||||||
|
"type": "yii2-extension",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.0.x-dev"
|
||||||
|
},
|
||||||
|
"composer-exit-on-patch-failure": true,
|
||||||
|
"patches": {
|
||||||
|
"phpunit/phpunit-mock-objects": {
|
||||||
|
"Fix PHP 7 and 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_mock_objects.patch"
|
||||||
|
},
|
||||||
|
"phpunit/phpunit": {
|
||||||
|
"Fix PHP 7 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php7.patch",
|
||||||
|
"Fix PHP 8 compatibility": "https://yiisoft.github.io/phpunit-patches/phpunit_php8.patch"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"yii\\imagine\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Antonio Ramirez",
|
||||||
|
"email": "amigo.cobos@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "The Imagine integration for the Yii framework",
|
||||||
|
"keywords": [
|
||||||
|
"helper",
|
||||||
|
"image",
|
||||||
|
"imagine",
|
||||||
|
"yii2"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"forum": "http://www.yiiframework.com/forum/",
|
||||||
|
"irc": "irc://irc.freenode.net/yii",
|
||||||
|
"issues": "https://github.com/yiisoft/yii2-imagine/issues",
|
||||||
|
"source": "https://github.com/yiisoft/yii2-imagine",
|
||||||
|
"wiki": "http://www.yiiframework.com/wiki/"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://github.com/yiisoft",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://opencollective.com/yiisoft",
|
||||||
|
"type": "open_collective"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/yiisoft/yii2-imagine",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2020-12-23T17:16:36+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "yiisoft/yii2-swiftmailer",
|
"name": "yiisoft/yii2-swiftmailer",
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
|
|
|
@ -19,16 +19,27 @@ $config = [
|
||||||
'class' => 'yii\caching\FileCache',
|
'class' => 'yii\caching\FileCache',
|
||||||
],
|
],
|
||||||
'user' => [
|
'user' => [
|
||||||
'identityClass' => 'app\models\Account',
|
'identityClass' => 'app\models\Account',
|
||||||
'loginUrl' => ['/authentication'],
|
'loginUrl' => ['/authentication'],
|
||||||
'enableAutoLogin' => true
|
'enableAutoLogin' => true,
|
||||||
|
'enableSession' => true
|
||||||
|
],
|
||||||
|
'session' => [
|
||||||
|
'class' => 'mirzaev\yii2\arangodb\sessions\ArangoDbSession',
|
||||||
|
'document' => 'session',
|
||||||
|
'cookieParams' => [
|
||||||
|
// 'lifetime' => 3600 * 24 * 30 * 12
|
||||||
|
'lifetime' => 3600 * 24 * 3
|
||||||
|
],
|
||||||
|
'writeCallback' => function($session) {
|
||||||
|
return [
|
||||||
|
'account' => Yii::$app->user->id,
|
||||||
|
'ip' => yii::$app->request->userIP
|
||||||
|
];
|
||||||
|
},
|
||||||
|
'timeout' => 3600 * 24 * 3,
|
||||||
|
'useCookies' => true,
|
||||||
],
|
],
|
||||||
// 'session' => [
|
|
||||||
// 'class' => 'yii\web\Session',
|
|
||||||
// 'cookieParams' => ['lifetime' => 3600 * 24 * 30 * 12],
|
|
||||||
// 'timeout' => 3600 * 24 * 30 * 12,
|
|
||||||
// 'useCookies' => true,
|
|
||||||
// ],
|
|
||||||
'errorHandler' => [
|
'errorHandler' => [
|
||||||
'errorAction' => 'error',
|
'errorAction' => 'error',
|
||||||
],
|
],
|
||||||
|
|
|
@ -48,7 +48,7 @@ class AuthenticationController extends Controller
|
||||||
// Аккаунт аутентифицирован
|
// Аккаунт аутентифицирован
|
||||||
|
|
||||||
// Создание сессии
|
// Создание сессии
|
||||||
yii::$app->session->open();
|
// yii::$app->session->open();
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
$notifications_button = $this->renderPartial('/notification/button');
|
$notifications_button = $this->renderPartial('/notification/button');
|
||||||
|
|
|
@ -37,11 +37,13 @@ class DeauthenticationController extends Controller
|
||||||
// Инициализация
|
// Инициализация
|
||||||
yii::$app->response->format = Response::FORMAT_JSON;
|
yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
|
// Удаление сессии
|
||||||
|
yii::$app->session['status'] = 'inactive';
|
||||||
|
// yii::$app->session->close();
|
||||||
|
|
||||||
// Выход из аккаунта
|
// Выход из аккаунта
|
||||||
yii::$app->user->logout();
|
yii::$app->user->logout();
|
||||||
|
|
||||||
// Удаление сессии
|
|
||||||
yii::$app->session->destroy();
|
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
$model = new AccountForm(yii::$app->request->post('AccountForm') ?? yii::$app->request->get('AccountForm') ?? null);
|
$model = new AccountForm(yii::$app->request->post('AccountForm') ?? yii::$app->request->get('AccountForm') ?? null);
|
||||||
|
|
|
@ -19,11 +19,11 @@ class NotificationController extends Controller
|
||||||
return [
|
return [
|
||||||
'access' => [
|
'access' => [
|
||||||
'class' => AccessControl::class,
|
'class' => AccessControl::class,
|
||||||
'only' => ['index'],
|
|
||||||
'rules' => [
|
'rules' => [
|
||||||
[
|
[
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'roles' => ['@']
|
'roles' => ['@'],
|
||||||
|
'actions' => ['index']
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -35,8 +35,6 @@ class NotificationController extends Controller
|
||||||
*/
|
*/
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
var_dump(yii::$app->session->id);
|
|
||||||
|
|
||||||
if (yii::$app->request->isPost) {
|
if (yii::$app->request->isPost) {
|
||||||
// POST-запрос
|
// POST-запрос
|
||||||
|
|
||||||
|
|
|
@ -20,17 +20,52 @@ class OrderController extends Controller
|
||||||
return [
|
return [
|
||||||
'access' => [
|
'access' => [
|
||||||
'class' => AccessControl::class,
|
'class' => AccessControl::class,
|
||||||
'only' => ['index'],
|
|
||||||
'rules' => [
|
'rules' => [
|
||||||
[
|
[
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'roles' => ['@']
|
'roles' => ['@'],
|
||||||
|
'actions' => ['index', 'write', 'delete', 'amount-update', 'pay']
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'allow' => false,
|
||||||
|
'roles' => ['?'],
|
||||||
|
'denyCallback' => [$this, 'accessDenied']
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function accessDenied()
|
||||||
|
{
|
||||||
|
// Инициализация
|
||||||
|
$cookies = yii::$app->response->cookies;
|
||||||
|
|
||||||
|
// Запись cookie с редиректом, который выполнится после авторизации
|
||||||
|
$cookies->add(new Cookie([
|
||||||
|
'name' => 'redirect',
|
||||||
|
'value' => yii::$app->request->pathInfo
|
||||||
|
]));
|
||||||
|
|
||||||
|
if (Yii::$app->request->isPost) {
|
||||||
|
// POST-запрос
|
||||||
|
|
||||||
|
// Настройка
|
||||||
|
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
|
// Генерация ответа
|
||||||
|
Yii::$app->response->content = json_encode([
|
||||||
|
'main' => $this->renderPartial('/orders/index'),
|
||||||
|
'redirect' => '/authentication',
|
||||||
|
'_csrf' => Yii::$app->request->getCsrfToken()
|
||||||
|
]);
|
||||||
|
} else if (Yii::$app->request->isGet) {
|
||||||
|
// GET-запрос
|
||||||
|
|
||||||
|
$this->redirect('/authentication');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function actionIndex()
|
public function actionIndex()
|
||||||
{
|
{
|
||||||
// Инициализация
|
// Инициализация
|
||||||
|
|
|
@ -4,56 +4,31 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\controllers;
|
namespace app\controllers;
|
||||||
|
|
||||||
use Yii;
|
use yii;
|
||||||
use yii\filters\AccessControl;
|
use yii\filters\AccessControl;
|
||||||
use yii\web\Controller;
|
use yii\web\Controller;
|
||||||
use yii\web\Response;
|
use yii\web\Response;
|
||||||
use yii\web\HttpException;
|
use yii\web\HttpException;
|
||||||
|
use yii\web\UploadedFile;
|
||||||
|
|
||||||
use app\models\Product;
|
use app\models\Product;
|
||||||
|
|
||||||
class ProductController extends Controller
|
class ProductController extends Controller
|
||||||
{
|
{
|
||||||
// /**
|
public function actionIndex(string $catn): array|string|null
|
||||||
// * {@inheritdoc}
|
|
||||||
// */
|
|
||||||
// public function behaviors()
|
|
||||||
// {
|
|
||||||
// return [
|
|
||||||
// 'access' => [
|
|
||||||
// 'class' => AccessControl::class,
|
|
||||||
// 'rules' => [
|
|
||||||
// [
|
|
||||||
// 'allow' => true,
|
|
||||||
// 'actions' => ['index'],
|
|
||||||
// 'roles' => ['@']
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// 'allow' => false,
|
|
||||||
// 'roles' => ['?']
|
|
||||||
// ],
|
|
||||||
// ]
|
|
||||||
// ]
|
|
||||||
// ];
|
|
||||||
// }
|
|
||||||
|
|
||||||
public function actionIndex(string $catn)
|
|
||||||
{
|
{
|
||||||
if ($model = Product::searchByCatn($catn)) {
|
if ($model = Product::searchByCatn($catn)) {
|
||||||
// Товар найден
|
// Товар найден
|
||||||
|
|
||||||
// Инициализация
|
if (yii::$app->request->isAjax) {
|
||||||
$model = $model->getAttributes();
|
|
||||||
|
|
||||||
if (Yii::$app->request->isAjax) {
|
|
||||||
// AJAX-POST-запрос
|
// AJAX-POST-запрос
|
||||||
|
|
||||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'main' => $this->renderPartial('index', compact('model')),
|
'main' => $this->renderPartial('index', compact('model')),
|
||||||
'redirect' => '/product/' . $catn,
|
'redirect' => '/product/' . $catn,
|
||||||
'_csrf' => Yii::$app->request->getCsrfToken()
|
'_csrf' => yii::$app->request->getCsrfToken()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,4 +37,203 @@ class ProductController extends Controller
|
||||||
throw new HttpException(404);
|
throw new HttpException(404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function actionEditTitle(string $catn): array|string|null
|
||||||
|
{
|
||||||
|
// Инициализация
|
||||||
|
$return = [
|
||||||
|
'_csrf' => yii::$app->request->getCsrfToken()
|
||||||
|
];
|
||||||
|
|
||||||
|
if (is_null($catn)) {
|
||||||
|
// Не получен артикул
|
||||||
|
|
||||||
|
yii::$app->response->statusCode = 500;
|
||||||
|
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model = Product::searchByCatn($catn)) {
|
||||||
|
// Товар найден
|
||||||
|
|
||||||
|
// Инициализация
|
||||||
|
$text = yii::$app->request->get('text') ?? yii::$app->request->post('text') ?? 'Без названия';
|
||||||
|
|
||||||
|
$model->name = $text;
|
||||||
|
|
||||||
|
if ($model->save()) {
|
||||||
|
// Товар обновлён
|
||||||
|
|
||||||
|
$return['name'] = $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 actionEditCatn(string $catn): array|string|null
|
||||||
|
{
|
||||||
|
// Инициализация
|
||||||
|
$return = [
|
||||||
|
'_csrf' => yii::$app->request->getCsrfToken()
|
||||||
|
];
|
||||||
|
|
||||||
|
if (is_null($catn)) {
|
||||||
|
// Не получен артикул
|
||||||
|
|
||||||
|
yii::$app->response->statusCode = 500;
|
||||||
|
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model = Product::searchByCatn($catn)) {
|
||||||
|
// Товар найден
|
||||||
|
|
||||||
|
// Инициализация
|
||||||
|
$text = yii::$app->request->get('text') ?? yii::$app->request->post('text') ?? 'Без названия';
|
||||||
|
|
||||||
|
$model->catn = $text;
|
||||||
|
|
||||||
|
if ($model->save()) {
|
||||||
|
// Товар обновлён
|
||||||
|
|
||||||
|
$return['main'] = $this->renderPartial('index', compact('model'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Конец алгоритма
|
||||||
|
*/
|
||||||
|
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 actionEditDesc(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->get('text') ?? yii::$app->request->post('text') ?? 'Без названия';
|
||||||
|
|
||||||
|
$product->desc = $text;
|
||||||
|
|
||||||
|
if ($product->save()) {
|
||||||
|
// Товар обновлён
|
||||||
|
|
||||||
|
$return['description'] = $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
|
||||||
|
{
|
||||||
|
// Инициализация
|
||||||
|
$return = [
|
||||||
|
'_csrf' => yii::$app->request->getCsrfToken()
|
||||||
|
];
|
||||||
|
|
||||||
|
if (is_null($catn)) {
|
||||||
|
// Не получен артикул
|
||||||
|
|
||||||
|
yii::$app->response->statusCode = 500;
|
||||||
|
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($model = Product::searchByCatn($catn)) {
|
||||||
|
// Товар найден
|
||||||
|
|
||||||
|
// Инициализация
|
||||||
|
$model->file_image = UploadedFile::getInstancesByName('images');
|
||||||
|
$model->scenario = $model::SCENARIO_IMPORT_IMAGE;
|
||||||
|
|
||||||
|
if ($model->importImages() > 0) {
|
||||||
|
// Товар обновлён
|
||||||
|
|
||||||
|
$return['main'] = $this->renderPartial('index', compact('model'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Конец алгоритма
|
||||||
|
*/
|
||||||
|
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('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ProfileController extends Controller
|
||||||
[
|
[
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'roles' => ['@'],
|
'roles' => ['@'],
|
||||||
'actions' => ['index', 'supplies', 'import', 'monitoring', 'readGroups'],
|
'actions' => ['index', 'supplies', 'import', 'monitoring', 'readGroups']
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'allow' => false,
|
'allow' => false,
|
||||||
|
@ -38,9 +38,16 @@ class ProfileController extends Controller
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'allow' => true,
|
'allow' => true,
|
||||||
'actions' => ['trusted', 'trusted-notification-write'],
|
'actions' => ['panel', 'panel-notification-write'],
|
||||||
'matchCallback' => function ($rule, $action) {
|
'matchCallback' => function ($rule, $action): bool {
|
||||||
return yii::$app->user->identity->trst;
|
if (
|
||||||
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -140,7 +147,7 @@ class ProfileController extends Controller
|
||||||
/**
|
/**
|
||||||
* Страница панели управления для доверенных пользователей
|
* Страница панели управления для доверенных пользователей
|
||||||
*/
|
*/
|
||||||
public function actionTrusted(): string|array
|
public function actionPanel(): string|array
|
||||||
{
|
{
|
||||||
// Инициализация
|
// Инициализация
|
||||||
$model_notifications = null;
|
$model_notifications = null;
|
||||||
|
@ -196,18 +203,18 @@ class ProfileController extends Controller
|
||||||
yii::$app->response->format = Response::FORMAT_JSON;
|
yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'main' => $this->renderPartial('trusted', compact(
|
'main' => $this->renderPartial('panel', compact(
|
||||||
'model_notifications',
|
'model_notifications',
|
||||||
'model_settings',
|
'model_settings',
|
||||||
'sidebar',
|
'sidebar',
|
||||||
'panel'
|
'panel'
|
||||||
)),
|
)),
|
||||||
'redirect' => '/profile/trusted',
|
'redirect' => '/profile/panel',
|
||||||
'_csrf' => yii::$app->request->getCsrfToken()
|
'_csrf' => yii::$app->request->getCsrfToken()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render('trusted', compact(
|
return $this->render('panel', compact(
|
||||||
'model_notifications',
|
'model_notifications',
|
||||||
'model_settings',
|
'model_settings',
|
||||||
'sidebar',
|
'sidebar',
|
||||||
|
@ -348,9 +355,10 @@ class ProfileController extends Controller
|
||||||
*/
|
*/
|
||||||
public function actionImport()
|
public function actionImport()
|
||||||
{
|
{
|
||||||
|
var_dump($_FILES);
|
||||||
// Инициализация
|
// Инициализация
|
||||||
$model = new Supply(yii::$app->request->post('Supply') ?? yii::$app->request->get('Supply'));
|
$model = new Supply(yii::$app->request->post('Supply') ?? yii::$app->request->get('Supply'));
|
||||||
$model->scenario = $model::SCENARIO_IMPORT;
|
$model->scenario = $model::SCENARIO_IMPORT_EXCEL;
|
||||||
$panel = yii::$app->request->post('panel') ?? yii::$app->request->get('panel');
|
$panel = yii::$app->request->post('panel') ?? yii::$app->request->get('panel');
|
||||||
$sidebar = $this->renderPartial('sidebar');
|
$sidebar = $this->renderPartial('sidebar');
|
||||||
$groups = self::readGroups();
|
$groups = self::readGroups();
|
||||||
|
@ -360,9 +368,9 @@ class ProfileController extends Controller
|
||||||
|
|
||||||
yii::$app->response->format = Response::FORMAT_JSON;
|
yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
$model->file = UploadedFile::getInstances($model, 'file');
|
$model->file_excel = UploadedFile::getInstances($model, 'file_excel');
|
||||||
|
|
||||||
if ($model->import()) {
|
if ($model->importExcel()) {
|
||||||
return [
|
return [
|
||||||
'main' => $this->renderPartial('supplies', compact(
|
'main' => $this->renderPartial('supplies', compact(
|
||||||
'model',
|
'model',
|
||||||
|
|
|
@ -51,7 +51,6 @@ class SearchController extends Controller
|
||||||
|
|
||||||
// Инициализация сессии
|
// Инициализация сессии
|
||||||
$session = yii::$app->session;
|
$session = yii::$app->session;
|
||||||
$session->open();
|
|
||||||
|
|
||||||
// Инициализация ответа
|
// Инициализация ответа
|
||||||
$response = null;
|
$response = null;
|
||||||
|
@ -129,7 +128,7 @@ class SearchController extends Controller
|
||||||
|
|
||||||
$limit = yii::$app->request->isPost ? 10 : 20;
|
$limit = yii::$app->request->isPost ? 10 : 20;
|
||||||
|
|
||||||
if ($response = Product::searchByCatn($query, $limit, ['catn' => 'catn', '_key' => '_key'])) {
|
if ($response = Product::searchByPartialCatn($query, $limit, ['catn' => 'catn', '_key' => '_key'])) {
|
||||||
// Данные найдены по поиску в полях Каталожного номера
|
// Данные найдены по поиску в полях Каталожного номера
|
||||||
|
|
||||||
foreach ($response as &$row) {
|
foreach ($response as &$row) {
|
||||||
|
|
|
@ -42,7 +42,8 @@ class Account extends Document implements IdentityInterface, PartnerInterface
|
||||||
'taxn',
|
'taxn',
|
||||||
'onec',
|
'onec',
|
||||||
'opts',
|
'opts',
|
||||||
'trst'
|
'agnt',
|
||||||
|
'type'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +66,8 @@ class Account extends Document implements IdentityInterface, PartnerInterface
|
||||||
'taxn' => 'ИНН',
|
'taxn' => 'ИНН',
|
||||||
'onec' => 'Данные 1C',
|
'onec' => 'Данные 1C',
|
||||||
'opts' => 'Параметры',
|
'opts' => 'Параметры',
|
||||||
'trst' => 'Доверенный пользователь'
|
'agnt' => 'Агент (поставщик)',
|
||||||
|
'type' => 'Тип аккаунта'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class AccountForm extends Model
|
||||||
|
|
||||||
public $mail;
|
public $mail;
|
||||||
public $pswd;
|
public $pswd;
|
||||||
public $auto = true;
|
public $auto = false;
|
||||||
|
|
||||||
private $account = false;
|
private $account = false;
|
||||||
|
|
||||||
|
|
|
@ -67,11 +67,14 @@ abstract class Document extends ActiveRecord
|
||||||
if (parent::beforeSave($data)) {
|
if (parent::beforeSave($data)) {
|
||||||
if ($this->isNewRecord) {
|
if ($this->isNewRecord) {
|
||||||
// Запись в журнал
|
// Запись в журнал
|
||||||
$this->jrnl = [[
|
$this->jrnl = array_merge(
|
||||||
'date' => time(),
|
[[
|
||||||
'account' => yii::$app->user->id,
|
'date' => time(),
|
||||||
'action' => 'create'
|
'account' => yii::$app->user->id,
|
||||||
]];
|
'action' => 'create'
|
||||||
|
]],
|
||||||
|
$this->jrnl ?? []
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -92,7 +95,10 @@ abstract class Document extends ActiveRecord
|
||||||
public function journal(string $action = 'update', array ...$data): int|bool
|
public function journal(string $action = 'update', array ...$data): int|bool
|
||||||
{
|
{
|
||||||
// Инициализация
|
// Инициализация
|
||||||
is_array($this->jrnl) or $this->jrnl = [];
|
if (isset($this->jrnl) && is_array($this->jrnl)) {
|
||||||
|
} else {
|
||||||
|
$this->jrnl = [];
|
||||||
|
}
|
||||||
|
|
||||||
// Генерация
|
// Генерация
|
||||||
$this->jrnl = array_merge(
|
$this->jrnl = array_merge(
|
||||||
|
@ -108,7 +114,7 @@ abstract class Document extends ActiveRecord
|
||||||
);
|
);
|
||||||
|
|
||||||
// Запись и возврат
|
// Запись и возврат
|
||||||
return $this->save() ? $time : false;
|
return $this->update() ? $time : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -118,16 +118,7 @@ abstract class Edge extends Document
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($edge->save()) {
|
return $edge->save() ? $edge : null;
|
||||||
// Записано в базу данных
|
|
||||||
|
|
||||||
// Запись в журнал
|
|
||||||
$edge->journal('create');
|
|
||||||
|
|
||||||
return $edge;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -45,7 +45,7 @@ class Notification extends Document
|
||||||
*
|
*
|
||||||
* @see SCENARIO_TRUSTED_CREATE
|
* @see SCENARIO_TRUSTED_CREATE
|
||||||
*/
|
*/
|
||||||
public string $account;
|
public string|null $account;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Текст уведомления
|
* Текст уведомления
|
||||||
|
|
|
@ -146,8 +146,6 @@ class Order extends Document
|
||||||
if (!$supply_model = Supply::searchByCatn($supply_raw) or !OrderEdgeSupply::write($this->readId(), $supply_model->readId(), 'write')) {
|
if (!$supply_model = Supply::searchByCatn($supply_raw) or !OrderEdgeSupply::write($this->readId(), $supply_model->readId(), 'write')) {
|
||||||
// Поставка не найдена или запись ребра не удалась
|
// Поставка не найдена или запись ребра не удалась
|
||||||
|
|
||||||
var_dump('ПИЗДА');
|
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// Ребро создано (товар подключен к заказу)
|
// Ребро создано (товар подключен к заказу)
|
||||||
|
|
|
@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||||
namespace app\models;
|
namespace app\models;
|
||||||
|
|
||||||
use yii;
|
use yii;
|
||||||
|
use yii\web\UploadedFile;
|
||||||
|
use yii\imagine\Image;
|
||||||
|
|
||||||
use app\models\traits\SearchByEdge;
|
use app\models\traits\SearchByEdge;
|
||||||
|
|
||||||
|
@ -22,11 +24,18 @@ class Product extends Document
|
||||||
use SearchByEdge;
|
use SearchByEdge;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Сценарий импорта из .excel документа
|
* Сценарий импорта .excel документа
|
||||||
*
|
*
|
||||||
* Использовать для обхода правил при загрузке файла
|
* Использовать для обхода правил при загрузке файла
|
||||||
*/
|
*/
|
||||||
const SCENARIO_IMPORT = 'import';
|
const SCENARIO_IMPORT_EXCEL = 'import_excel';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Сценарий импорта изображений
|
||||||
|
*
|
||||||
|
* Использовать для обхода правил при загрузке файла
|
||||||
|
*/
|
||||||
|
const SCENARIO_IMPORT_IMAGE = 'import_image';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Сценарий записи товара
|
* Сценарий записи товара
|
||||||
|
@ -36,7 +45,12 @@ class Product extends Document
|
||||||
/**
|
/**
|
||||||
* Файл .excel для импорта товаров
|
* Файл .excel для импорта товаров
|
||||||
*/
|
*/
|
||||||
public Excel|string|array|null $file = null;
|
public Excel|string|array|null $file_excel = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Изображение для импорта
|
||||||
|
*/
|
||||||
|
public UploadedFile|string|array|null $file_image = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Группа в которой состоит товар
|
* Группа в которой состоит товар
|
||||||
|
@ -59,9 +73,10 @@ class Product extends Document
|
||||||
return array_merge(
|
return array_merge(
|
||||||
parent::attributes(),
|
parent::attributes(),
|
||||||
[
|
[
|
||||||
|
'catn',
|
||||||
|
'name',
|
||||||
'desc',
|
'desc',
|
||||||
'ocid',
|
'ocid',
|
||||||
'catn',
|
|
||||||
'imgs',
|
'imgs',
|
||||||
'time',
|
'time',
|
||||||
'oemn',
|
'oemn',
|
||||||
|
@ -79,13 +94,15 @@ class Product extends Document
|
||||||
parent::attributeLabels(),
|
parent::attributeLabels(),
|
||||||
[
|
[
|
||||||
'catn' => 'Каталожный номер (catn)',
|
'catn' => 'Каталожный номер (catn)',
|
||||||
|
'name' => 'Название (name)',
|
||||||
'desc' => 'Описание (desc)',
|
'desc' => 'Описание (desc)',
|
||||||
'ocid' => 'Идентификатор 1C (ocid)',
|
'ocid' => 'Идентификатор 1C (ocid)',
|
||||||
'imgs' => 'Изображения (imgs)',
|
'imgs' => 'Изображения (imgs)',
|
||||||
'time' => 'Срок доставки (time)',
|
'time' => 'Срок доставки (time)',
|
||||||
'oemn' => 'OEM номера (oemn)',
|
'oemn' => 'OEM номера (oemn)',
|
||||||
'cost' => 'Стоимость (cost)',
|
'cost' => 'Стоимость (cost)',
|
||||||
'file' => 'Документ (file)',
|
'file_excel' => 'Документ (file_excel)',
|
||||||
|
'file_image' => 'Изображение (file_image)',
|
||||||
'group' => 'Группа (group)'
|
'group' => 'Группа (group)'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -104,7 +121,7 @@ class Product extends Document
|
||||||
'required',
|
'required',
|
||||||
'message' => 'Заполните поля: {attribute}',
|
'message' => 'Заполните поля: {attribute}',
|
||||||
'on' => self::SCENARIO_WRITE,
|
'on' => self::SCENARIO_WRITE,
|
||||||
'except' => self::SCENARIO_IMPORT
|
'except' => [self::SCENARIO_IMPORT_EXCEL, self::SCENARIO_IMPORT_IMAGE]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'catn',
|
'catn',
|
||||||
|
@ -120,13 +137,13 @@ class Product extends Document
|
||||||
'message' => '{attribute} должен быть массивом.'
|
'message' => '{attribute} должен быть массивом.'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'file',
|
'file_excel',
|
||||||
'required',
|
'required',
|
||||||
'message' => 'Заполните поля: {attribute}',
|
'message' => 'Заполните поля: {attribute}',
|
||||||
'on' => self::SCENARIO_IMPORT
|
'on' => self::SCENARIO_IMPORT_EXCEL
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'file',
|
'file_excel',
|
||||||
'file',
|
'file',
|
||||||
'skipOnEmpty' => false,
|
'skipOnEmpty' => false,
|
||||||
'extensions' => 'xlsx',
|
'extensions' => 'xlsx',
|
||||||
|
@ -135,7 +152,25 @@ class Product extends Document
|
||||||
'maxSize' => 1024 * 1024 * 30,
|
'maxSize' => 1024 * 1024 * 30,
|
||||||
'wrongExtension' => 'Разрешены только документы в формате: ".xlsx"',
|
'wrongExtension' => 'Разрешены только документы в формате: ".xlsx"',
|
||||||
'message' => 'Проблема при чтении документа',
|
'message' => 'Проблема при чтении документа',
|
||||||
'on' => self::SCENARIO_IMPORT
|
'on' => self::SCENARIO_IMPORT_EXCEL
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'file_image',
|
||||||
|
'required',
|
||||||
|
'message' => 'Загрузите изображение',
|
||||||
|
'on' => self::SCENARIO_IMPORT_IMAGE
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'file_image',
|
||||||
|
'file',
|
||||||
|
'skipOnEmpty' => false,
|
||||||
|
'extensions' => ['jpg', 'jpeg', 'png', 'gif', 'webp'],
|
||||||
|
'checkExtensionByMimeType' => true,
|
||||||
|
'maxFiles' => 10,
|
||||||
|
'maxSize' => 1024 * 1024 * 30,
|
||||||
|
'wrongExtension' => 'Разрешены только изображения в формате: ".jpg", ".jpeg", ".png", ".gif", ".webp"',
|
||||||
|
'message' => 'Проблема при загрузке изображения',
|
||||||
|
'on' => self::SCENARIO_IMPORT_IMAGE
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
@ -223,20 +258,93 @@ class Product extends Document
|
||||||
return $catn[0];
|
return $catn[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Импорт изображений
|
||||||
|
*
|
||||||
|
* @return int Количество сохранённых изображений
|
||||||
|
*/
|
||||||
|
public function importImages(): int
|
||||||
|
{
|
||||||
|
if ($this->validate()) {
|
||||||
|
// Проверка пройдена
|
||||||
|
|
||||||
|
// Инициализация
|
||||||
|
$amount = 0;
|
||||||
|
|
||||||
|
foreach ($this->file_image as $file) {
|
||||||
|
// Перебор обрабатываемых изображений
|
||||||
|
|
||||||
|
if (!file_exists(YII_PATH_PUBLIC . $catalog = '/img/products/' . $this->_key)) {
|
||||||
|
// Директория для изображений продукта не найдена
|
||||||
|
|
||||||
|
if (!mkdir(YII_PATH_PUBLIC . $catalog, 0775, true)) {
|
||||||
|
// Не удалось записать директорию
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!file_exists(YII_PATH_PUBLIC . $catalog_h150 = '/img/products/' . $this->_key . '/h150')) {
|
||||||
|
// Директория для обложек изображений продукта не найдена
|
||||||
|
|
||||||
|
if (!mkdir(YII_PATH_PUBLIC . $catalog_h150, 0775, true)) {
|
||||||
|
// Не удалось записать директорию
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Запись на сервер
|
||||||
|
$file->saveAs(YII_PATH_PUBLIC . $catalog . '/' . $file->baseName . '.' . $file->extension . '.original');
|
||||||
|
|
||||||
|
// Конвертация изображения для сохранения полного изображения
|
||||||
|
Image::resize(YII_PATH_PUBLIC . $catalog . '/' . $file->baseName . '.' . $file->extension . '.original', 800, 800)
|
||||||
|
->save(YII_PATH_PUBLIC . $catalog . '/' . $file->baseName . '.' . $file->extension, ['quality' => 80]);
|
||||||
|
|
||||||
|
// Конвертация изображения для сохранения обложки (150px)
|
||||||
|
Image::resize(YII_PATH_PUBLIC . $catalog . '/' . $file->baseName . '.' . $file->extension, 150, 150)
|
||||||
|
->save(YII_PATH_PUBLIC . $catalog_h150 . '/' . $file->baseName . '.' . $file->extension, ['quality' => 80]);
|
||||||
|
|
||||||
|
// Запись в базу данных
|
||||||
|
$this->imgs = array_merge(
|
||||||
|
$this->imgs ?? [],
|
||||||
|
[[
|
||||||
|
'orig' => $catalog . '/' . $file->baseName . '.' . $file->extension,
|
||||||
|
'h150' => $catalog_h150 . '/' . $file->baseName . '.' . $file->extension
|
||||||
|
]]
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$this->scenario = self::SCENARIO_WRITE;
|
||||||
|
|
||||||
|
if ($this->save()) {
|
||||||
|
// Изменения сохранены в базе данных
|
||||||
|
|
||||||
|
// Постинкрементация счётчика
|
||||||
|
$amount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $amount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Импорт товаров
|
* Импорт товаров
|
||||||
*
|
*
|
||||||
* На данный момент обрабатывает только импорт из
|
* На данный момент обрабатывает только импорт из
|
||||||
* файлов с расширением .excel
|
* файлов с расширением .excel
|
||||||
*/
|
*/
|
||||||
public function import(): bool
|
public function importExcel(): bool
|
||||||
{
|
{
|
||||||
// Инициализация
|
// Инициализация
|
||||||
$data = [];
|
$data = [];
|
||||||
$amount = 0;
|
$amount = 0;
|
||||||
|
|
||||||
if ($this->validate()) {
|
if ($this->validate()) {
|
||||||
foreach ($this->file as $file) {
|
foreach ($this->file_excel as $file) {
|
||||||
// Перебор файлов
|
// Перебор файлов
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
|
@ -296,7 +404,7 @@ class Product extends Document
|
||||||
}
|
}
|
||||||
|
|
||||||
// Деинициализация
|
// Деинициализация
|
||||||
$this->file = '';
|
$this->file_excel = '';
|
||||||
|
|
||||||
static::afterImportExcel($amount);
|
static::afterImportExcel($amount);
|
||||||
|
|
||||||
|
@ -325,7 +433,34 @@ class Product extends Document
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = self::find()
|
$query = self::find()
|
||||||
->collection('product_search')
|
->where(['catn' => $catn])
|
||||||
|
->limit($limit)
|
||||||
|
->select($select)
|
||||||
|
->createCommand()
|
||||||
|
->execute()
|
||||||
|
->getAll();
|
||||||
|
|
||||||
|
foreach ($query as &$attribute) {
|
||||||
|
// Приведение всех свойств в массив и очистка от лишних данных
|
||||||
|
|
||||||
|
$attribute = $attribute->getAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Поиск по каталожному номеру (через представления)
|
||||||
|
*
|
||||||
|
* Ищет продукт и возвращает его,
|
||||||
|
* либо выполняет поиск через представление
|
||||||
|
*
|
||||||
|
* @todo Переделать нормально
|
||||||
|
*/
|
||||||
|
public static function searchByPartialCatn(string $catn, int $limit = 1, array $select = []): static|array|null
|
||||||
|
{
|
||||||
|
$query = self::find()
|
||||||
|
->in('product_search')
|
||||||
->search(['catn' => $catn])
|
->search(['catn' => $catn])
|
||||||
->limit($limit)
|
->limit($limit)
|
||||||
->select($select)
|
->select($select)
|
||||||
|
|
|
@ -7,6 +7,9 @@ use yii\bootstrap\ActiveForm;
|
||||||
|
|
||||||
use app\models\AccountForm;
|
use app\models\AccountForm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo Восстановить сохранение сессии
|
||||||
|
*/
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
|
@ -6,6 +6,7 @@ use yii\helpers\Html;
|
||||||
use app\models\Product;
|
use app\models\Product;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<link href="/css/pages/product.css" rel="stylesheet">
|
<link href="/css/pages/product.css" rel="stylesheet">
|
||||||
|
|
||||||
<div id="page_product" class="container mb-auto">
|
<div id="page_product" class="container mb-auto">
|
||||||
|
@ -19,17 +20,26 @@ use app\models\Product;
|
||||||
// Перебор изображений
|
// Перебор изображений
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
$name = $image['name'] ?? 'Без названия';
|
|
||||||
$h150 = $image['h150'] ?? '/img/covers/h150/product.png';
|
$h150 = $image['h150'] ?? '/img/covers/h150/product.png';
|
||||||
|
|
||||||
// Генерация предпросмотра изображения
|
// Генерация предпросмотра изображения
|
||||||
echo <<<HTML
|
echo <<<HTML
|
||||||
<label class="p-0 mb-2" for="product_slider_image_$key">
|
<label class="p-0 mb-2" for="product_slider_image_$key">
|
||||||
<img class="img-fluid rounded" src="$h150"/>
|
<img class="img-fluid rounded" src="$h150"/>
|
||||||
</label>
|
</label>
|
||||||
HTML;
|
HTML;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<?php if (
|
||||||
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) : ?>
|
||||||
|
<input id="product_slider_image_new" type="file" class="d-none" onchange="return product_panel_images_write('<?= $model['catn'] ?>', this);" multiple />
|
||||||
|
<label class="p-0 mb-2" for="product_slider_image_new" role="button">
|
||||||
|
<img class="img-fluid rounded" src="/img/covers/h150/product_new.png" />
|
||||||
|
</label>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="product_slider_image">
|
<div class="product_slider_image">
|
||||||
<?php
|
<?php
|
||||||
|
@ -37,7 +47,7 @@ use app\models\Product;
|
||||||
$imgs = $model['imgs'] ?? [null];
|
$imgs = $model['imgs'] ?? [null];
|
||||||
$checked = '';
|
$checked = '';
|
||||||
|
|
||||||
foreach ($imgs as $key => $image) {
|
foreach ($model['imgs'] ?? [null] as $key => $image) {
|
||||||
// Перебор изображений
|
// Перебор изображений
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
|
@ -54,11 +64,11 @@ use app\models\Product;
|
||||||
|
|
||||||
// Генерация изображения
|
// Генерация изображения
|
||||||
echo <<<HTML
|
echo <<<HTML
|
||||||
<input type="radio" id="product_slider_image_$key" name="slider" $checked/>
|
<input type="radio" id="product_slider_image_$key" name="slider" $checked/>
|
||||||
<div class="col p-0">
|
<div class="col p-0">
|
||||||
<img class="img-fluid rounded" src="$orig"/>
|
<img class="img-fluid rounded" src="$orig"/>
|
||||||
</div>
|
</div>
|
||||||
HTML;
|
HTML;
|
||||||
|
|
||||||
// Деинициализация
|
// Деинициализация
|
||||||
$checked = '';
|
$checked = '';
|
||||||
|
@ -67,13 +77,47 @@ use app\models\Product;
|
||||||
</div>
|
</div>
|
||||||
<div class="col ml-4 d-flex flex-column">
|
<div class="col ml-4 d-flex flex-column">
|
||||||
<div class="row mb-1">
|
<div class="row mb-1">
|
||||||
<h3 class="my-auto">Название товара</h3>
|
<?php if (
|
||||||
<h5 class="ml-auto my-auto"><?= $model['catn'] ?></h5>
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) : ?>
|
||||||
|
<h3 id="title_<?= $model['catn'] ?>" class="my-auto pointer-event" role="button" onclick="return product_panel_title_edit('<?= $model['catn'] ?>', this);"><?= $model['name'] ?? 'Без названия' ?></h3>
|
||||||
|
<?php else : ?>
|
||||||
|
<h3 id="title_<?= $model['catn'] ?>" class="my-auto"><?= $model['name'] ?? 'Без названия' ?></h3>
|
||||||
|
<?php endif ?>
|
||||||
|
|
||||||
|
<?php if (
|
||||||
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) : ?>
|
||||||
|
<h5 id="catn_<?= $model['catn'] ?>" class="ml-auto my-auto d-flex pointer-event" role="button" onclick="return product_panel_catn_edit('<?= $model['catn'] ?>', this, true);">
|
||||||
|
<?= $model['catn'] ?>
|
||||||
|
<!-- <small class="d-flex">
|
||||||
|
<a class="text-dark my-auto ml-3" title="Редактировать" role="button" onclick="return product_panel_edit('<?= $model['catn'] ?>');">
|
||||||
|
<i class="fas fa-edit"></i>
|
||||||
|
</a>
|
||||||
|
<a class="text-dark my-auto ml-2" title="Удалить" role="button" onclick="return product_panel_delete('<?= $model['catn'] ?>');">
|
||||||
|
<i class="fas fa-trash-alt"></i>
|
||||||
|
</a>
|
||||||
|
</small> -->
|
||||||
|
</h5>
|
||||||
|
<?php else : ?>
|
||||||
|
<h5 id="catn_<?= $model['catn'] ?>" class="ml-auto my-auto d-flex">
|
||||||
|
<?= $model['catn'] ?>
|
||||||
|
</h5>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown-divider px-0 mb-3"></div>
|
<div class="dropdown-divider px-0 mb-3"></div>
|
||||||
<div class="row mb-3 h-100 product_panel d-flex flex-column">
|
<div class="row mb-3 h-100 product_panel d-flex flex-column">
|
||||||
|
<?php if (
|
||||||
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) : ?>
|
||||||
|
<p id="description_<?= $model['catn'] ?>" class="mt-0 ml-0 text-break pointer-event product_description" role="button" onclick="return product_panel_description_edit('<?= $model['catn'] ?>', this);"><?= $model['desc'] ?? 'Без описания' ?></p>
|
||||||
|
<?php else : ?>
|
||||||
|
<p id="description_<?= $model['catn'] ?>" class="mt-0 ml-0 text-break product_description"><?= $model['name'] ?? 'Без описания' ?></p>
|
||||||
|
<?php endif ?>
|
||||||
<p class="mt-0">
|
<p class="mt-0">
|
||||||
ОЕМ-номера можно сюда добавить с возможностью перехода
|
|
||||||
<?php
|
<?php
|
||||||
// foreach ($model['catn'] ?? [] as $catn) {
|
// foreach ($model['catn'] ?? [] as $catn) {
|
||||||
// echo <<<HTML
|
// echo <<<HTML
|
||||||
|
@ -118,11 +162,20 @@ use app\models\Product;
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row mt-auto mx-0">
|
|
||||||
|
<!-- <div class="row mt-3 mx-0">
|
||||||
<p class="ml-0">Время для повышения релевантности в поисковиках</p>
|
<p class="ml-0">Время для повышения релевантности в поисковиках</p>
|
||||||
<time class="ml-auto"></time>
|
<time class="ml-auto"></time>
|
||||||
</div>
|
</div> -->
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<script src="/js/product.js" defer></script>
|
||||||
|
<?php if (
|
||||||
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) : ?>
|
||||||
|
<script src="/js/product_panel.js" defer></script>
|
||||||
|
<?php endif ?>
|
|
@ -6,7 +6,11 @@ use yii;
|
||||||
use yii\bootstrap\ActiveForm;
|
use yii\bootstrap\ActiveForm;
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
$panel ?? $panel = 'profile_panel_settings_import';
|
if (yii::$app->user->identity->agnt) {
|
||||||
|
$panel ?? $panel = 'profile_panel_settings_import';
|
||||||
|
} else {
|
||||||
|
$panel ?? $panel = 'profile_panel_settings_account';
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<link href="/css/pages/profile.css" rel="stylesheet">
|
<link href="/css/pages/profile.css" rel="stylesheet">
|
||||||
|
@ -22,51 +26,59 @@ $panel ?? $panel = 'profile_panel_settings_import';
|
||||||
<div id="profile_panel_settings" class="profile_panel">
|
<div id="profile_panel_settings" class="profile_panel">
|
||||||
<div class="profile_panel_menu mb-3">
|
<div class="profile_panel_menu mb-3">
|
||||||
<label class="btn button_white mb-0 mr-2" for="profile_panel_settings_account">Аккаунт</label>
|
<label class="btn button_white mb-0 mr-2" for="profile_panel_settings_account">Аккаунт</label>
|
||||||
<label class="btn button_white mb-0 mr-2" for="profile_panel_settings_company">Компания</label>
|
<?php
|
||||||
<label class="btn button_white mb-0" for="profile_panel_settings_import">Импорт</label>
|
if (yii::$app->user->identity->agnt) {
|
||||||
|
echo <<<HTML
|
||||||
|
<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;
|
||||||
|
}
|
||||||
|
?>
|
||||||
</div>
|
</div>
|
||||||
<div class="profile_panel_content d-flex">
|
<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 ?>/>
|
<input type="radio" id="profile_panel_settings_account" name="main_panel" <?= $panel === 'profile_panel_settings_account' ? 'checked' : null ?> />
|
||||||
<div class="col">
|
<div class="col">
|
||||||
1
|
1
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="radio" id="profile_panel_settings_company" name="main_panel" <?= $panel === 'profile_panel_settings_company' ? 'checked' : null ?>/>
|
<?php if (yii::$app->user->identity->agnt) : ?>
|
||||||
<div class="col">
|
<input type="radio" id="profile_panel_settings_company" name="main_panel" <?= $panel === 'profile_panel_settings_company' ? 'checked' : null ?> />
|
||||||
2
|
<div class="col">
|
||||||
</div>
|
2
|
||||||
|
</div>
|
||||||
|
|
||||||
<input type="radio" id="profile_panel_settings_import" name="main_panel" <?= $panel === 'profile_panel_settings_import' ? 'checked' : null ?>/>
|
<input type="radio" id="profile_panel_settings_import" name="main_panel" <?= $panel === 'profile_panel_settings_import' ? 'checked' : null ?> />
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h5>Параметры 1C</h5>
|
<h5>Параметры 1C</h5>
|
||||||
<div class="dropdown-divider mb-3"></div>
|
<div class="dropdown-divider mb-3"></div>
|
||||||
<?php
|
<?php $form = ActiveForm::begin([
|
||||||
$form = ActiveForm::begin([
|
'id' => 'form_profile_settings',
|
||||||
'id' => 'form_profile_settings',
|
'action' => false,
|
||||||
'action' => false,
|
'fieldConfig' => [
|
||||||
'fieldConfig' => [
|
'template' => '{label}{input}',
|
||||||
'template' => '{label}{input}',
|
],
|
||||||
],
|
'options' => [
|
||||||
'options' => [
|
'onsubmit' => 'return false;'
|
||||||
'onsubmit' => 'return false;'
|
]
|
||||||
]
|
]);
|
||||||
]);
|
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
$model ?? $model = yii::$app->user->identity;
|
$model ?? $model = yii::$app->user->identity;
|
||||||
$list or $list = ['Нет данных'];
|
$list or $list = ['Нет данных'];
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?= $form->field($model, 'opts[import_sections_oem]', ['options' => ['class' => "mb-1"]])
|
<?= $form->field($model, 'opts[import_sections_oem]', ['options' => ['class' => "mb-1"]])
|
||||||
->dropDownList($list, [
|
->dropDownList($list, [
|
||||||
'onChange' => 'page_profile_settings(this.parentElement.parentElement, \'profile_panel_settings_import\')',
|
'onChange' => 'page_profile_settings(this.parentElement.parentElement, \'profile_panel_settings_import\')',
|
||||||
'disabled' => count($list) <= 1
|
'disabled' => count($list) <= 1
|
||||||
])->label('OEM-номера'); ?>
|
])->label('OEM-номера'); ?>
|
||||||
<small class="d-block mb-1">Выберите поле в котором хранятся <b>ОЕМ-номера</b> и повторите импорт</small>
|
|
||||||
<small class="d-block">Значения взяты из импортированных товаров</small>
|
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
<small class="d-block mb-1">Выберите поле в котором хранятся <b>ОЕМ-номера</b> и повторите импорт</small>
|
||||||
</div>
|
<small class="d-block">Значения взяты из импортированных товаров</small>
|
||||||
|
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -74,4 +86,10 @@ $panel ?? $panel = 'profile_panel_settings_import';
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/js/profile.js" defer></script>
|
<script src="/js/profile.js" defer></script>
|
||||||
|
<?php if (
|
||||||
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) : ?>
|
||||||
|
<script src="/js/profile_panel.js" defer></script>
|
||||||
|
<?php endif ?>
|
|
@ -29,7 +29,7 @@ $panel ?? $panel = 'profile_panel_monitoring_input_search_history';
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="radio" id="profile_panel_monitoring_input_search_history" name="main_panel" <?= $panel === 'profile_panel_monitoring_input_search_history' ? 'checked' : null ?>/>
|
<input type="radio" id="profile_panel_monitoring_input_search_history" name="main_panel" <?= $panel === 'profile_panel_monitoring_input_search_history' ? 'checked' : null ?>/>
|
||||||
<div class="col">
|
<div class="col rounded overflow-hidden">
|
||||||
<div class="row header_blue py-2">
|
<div class="row header_blue py-2">
|
||||||
<div class="col-sm-4 col-md-3">IPv4</div>
|
<div class="col-sm-4 col-md-3">IPv4</div>
|
||||||
<div class="col-7 col-sm-3 col-md-4 col-lg-6 pr-0 px-sm-0 px-lg-3">Поисковый запрос</div>
|
<div class="col-7 col-sm-3 col-md-4 col-lg-6 pr-0 px-sm-0 px-lg-3">Поисковый запрос</div>
|
||||||
|
@ -77,4 +77,10 @@ $panel ?? $panel = 'profile_panel_monitoring_input_search_history';
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/js/profile.js" defer></script>
|
<script src="/js/profile.js" defer></script>
|
||||||
|
<?php if (
|
||||||
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) : ?>
|
||||||
|
<script src="/js/profile_panel.js" defer></script>
|
||||||
|
<?php endif ?>
|
|
@ -9,7 +9,7 @@ use yii\helpers\Html;
|
||||||
use app\models\Notification;
|
use app\models\Notification;
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
$panel ?? $panel = 'profile_panel_trusted_input_notifications';
|
$panel ?? $panel = 'profile_panel_panel_input_notifications';
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -23,19 +23,19 @@ $panel ?? $panel = 'profile_panel_trusted_input_notifications';
|
||||||
<article class="col-9">
|
<article class="col-9">
|
||||||
<div class="p-4 rounded">
|
<div class="p-4 rounded">
|
||||||
<h4 class="ml-4 mb-4"><i class="fas fa-user-shield my-auto mr-2"></i>Панель управления</h4>
|
<h4 class="ml-4 mb-4"><i class="fas fa-user-shield my-auto mr-2"></i>Панель управления</h4>
|
||||||
<div id="profile_panel_trusted" class="profile_panel">
|
<div id="profile_panel_panel" class="profile_panel">
|
||||||
<div class="profile_panel_menu mb-3">
|
<div class="profile_panel_menu mb-3">
|
||||||
<label class="btn button_white mb-0 mr-2" for="profile_panel_trusted_input_notifications">Уведомления</label>
|
<label class="btn button_white mb-0 mr-2" for="profile_panel_panel_input_notifications">Уведомления</label>
|
||||||
<label class="btn button_white mb-0 mr-2" for="profile_panel_trusted_input_settings">Настройки</label>
|
<label class="btn button_white mb-0 mr-2" for="profile_panel_panel_input_settings">Настройки</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="profile_panel_content">
|
<div class="profile_panel_content">
|
||||||
<input type="radio" id="profile_panel_trusted_input_notifications" name="main_panel" <?= $panel === 'profile_panel_trusted_input_notifications' ? 'checked' : null ?>/>
|
<input type="radio" id="profile_panel_panel_input_notifications" name="main_panel" <?= $panel === 'profile_panel_panel_input_notifications' ? 'checked' : null ?>/>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<h5>Отправка уведомления</h5>
|
<h5>Отправка уведомления</h5>
|
||||||
<div class="dropdown-divider mb-3"></div>
|
<div class="dropdown-divider mb-3"></div>
|
||||||
<?php
|
<?php
|
||||||
$form = ActiveForm::begin([
|
$form = ActiveForm::begin([
|
||||||
'id' => 'form_profile_trusted_notifications',
|
'id' => 'form_profile_panel_notifications',
|
||||||
'action' => false,
|
'action' => false,
|
||||||
'fieldConfig' => [
|
'fieldConfig' => [
|
||||||
'template' => '{label}{input}'
|
'template' => '{label}{input}'
|
||||||
|
@ -62,17 +62,17 @@ $panel ?? $panel = 'profile_panel_trusted_input_notifications';
|
||||||
|
|
||||||
<?= $form->field($model_notifications, 'text', ['options' => ['class' => "mb-3"]])->textarea(); ?>
|
<?= $form->field($model_notifications, 'text', ['options' => ['class' => "mb-3"]])->textarea(); ?>
|
||||||
|
|
||||||
<?= Html::submitButton('Отправить', ['name' => 'submitNotification', 'onclick' => 'page_profile_trusted_notification_create(this.parentElement);', 'class' => 'flex-grow-1 mr-2 btn button_white button_clean']) ?>
|
<?= Html::submitButton('Отправить', ['name' => 'submitNotification', 'onclick' => 'page_profile_panel_notification_create(this.parentElement);', 'class' => 'flex-grow-1 mr-2 btn button_white button_clean']) ?>
|
||||||
<?= Html::submitButton('Отправить как HTML', ['name' => 'submitNotification', 'onclick' => 'page_profile_trusted_notification_create(this.parentElement, 1);', 'class' => 'flex-grow-1 mr-2 btn button_white button_clean']) ?>
|
<?= Html::submitButton('Отправить как HTML', ['name' => 'submitNotification', 'onclick' => 'page_profile_panel_notification_create(this.parentElement, 1);', 'class' => 'flex-grow-1 mr-2 btn button_white button_clean']) ?>
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<input type="radio" id="profile_panel_trusted_input_settings" name="main_panel" <?= $panel === 'profile_panel_trusted_input_settings' ? 'checked' : null ?>/>
|
<input type="radio" id="profile_panel_panel_input_settings" name="main_panel" <?= $panel === 'profile_panel_panel_input_settings' ? 'checked' : null ?>/>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<?php
|
<?php
|
||||||
$form = ActiveForm::begin([
|
$form = ActiveForm::begin([
|
||||||
'id' => 'form_profile_trusted_settings_search_period',
|
'id' => 'form_profile_panel_settings_search_period',
|
||||||
'action' => false,
|
'action' => false,
|
||||||
'fieldConfig' => [
|
'fieldConfig' => [
|
||||||
'template' => '{label}{input}',
|
'template' => '{label}{input}',
|
||||||
|
@ -86,14 +86,14 @@ $panel ?? $panel = 'profile_panel_trusted_input_notifications';
|
||||||
|
|
||||||
<?= $form->errorSummary($model_settings, ['header' => 'Получены ошибки:']) ?>
|
<?= $form->errorSummary($model_settings, ['header' => 'Получены ошибки:']) ?>
|
||||||
|
|
||||||
<?= $form->field($model_settings, 'search_period', ['options' => ['class' => "mb-1"]])->textInput(['value' => $model_settings['search_period'], 'onChange' => 'page_profile_trusted_settings(this.parentElement.parentElement, \'profile_panel_trusted_input_settings\')']); ?>
|
<?= $form->field($model_settings, 'search_period', ['options' => ['class' => "mb-1"]])->textInput(['value' => $model_settings['search_period'], 'onChange' => 'page_profile_panel_settings(this.parentElement.parentElement, \'profile_panel_panel_input_settings\')']); ?>
|
||||||
<small class="d-block mb-1">Время которое надо ждать для повторного поиска в секундах</small>
|
<small class="d-block mb-1">Время которое надо ждать для повторного поиска в секундах</small>
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
<?php ActiveForm::end(); ?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$form = ActiveForm::begin([
|
$form = ActiveForm::begin([
|
||||||
'id' => 'form_profile_trusted_settings_search_connect_keep',
|
'id' => 'form_profile_panel_settings_search_connect_keep',
|
||||||
'action' => false,
|
'action' => false,
|
||||||
'fieldConfig' => [
|
'fieldConfig' => [
|
||||||
'template' => '{label}{input}',
|
'template' => '{label}{input}',
|
||||||
|
@ -128,7 +128,7 @@ $panel ?? $panel = 'profile_panel_trusted_input_notifications';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?= $form->field($model_settings, 'search_connect_keep', ['options' => ['class' => "mb-1"]])->dropDownList($list, ['onChange' => 'page_profile_trusted_settings(this.parentElement.parentElement, \'profile_panel_trusted_input_settings\')']); ?>
|
<?= $form->field($model_settings, 'search_connect_keep', ['options' => ['class' => "mb-1"]])->dropDownList($list, ['onChange' => 'page_profile_panel_settings(this.parentElement.parentElement, \'profile_panel_panel_input_settings\')']); ?>
|
||||||
<small class="d-block mb-1">Удерживать открытое соединение до истечения срока блокировки поиска?</small>
|
<small class="d-block mb-1">Удерживать открытое соединение до истечения срока блокировки поиска?</small>
|
||||||
<small class="d-block mb-1">При малой задержке позволяет снизить время загрузки страницы, но при большой будет казаться, что сайт завис</small>
|
<small class="d-block mb-1">При малой задержке позволяет снизить время загрузки страницы, но при большой будет казаться, что сайт завис</small>
|
||||||
|
|
||||||
|
@ -142,4 +142,4 @@ $panel ?? $panel = 'profile_panel_trusted_input_notifications';
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/js/profile.js" defer></script>
|
<script src="/js/profile.js" defer></script>
|
||||||
<script src="/js/profile_trusted.js" defer></script>
|
<script src="/js/profile_panel.js" defer></script>
|
|
@ -18,11 +18,14 @@ use app\models\SupplyEdgeProduct;
|
||||||
<div class="dropdown-divider my-3"></div>
|
<div class="dropdown-divider my-3"></div>
|
||||||
<dl class="m-0">
|
<dl class="m-0">
|
||||||
<?php
|
<?php
|
||||||
if (yii::$app->user->identity->trst) {
|
if (
|
||||||
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) {
|
||||||
// Пользователь является доверенным
|
// Пользователь является доверенным
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
$targetUrl = '/profile/trusted';
|
$targetUrl = '/profile/panel';
|
||||||
|
|
||||||
if ('/' . yii::$app->request->pathInfo === $targetUrl) {
|
if ('/' . yii::$app->request->pathInfo === $targetUrl) {
|
||||||
// Запрошена та же страница от которой послан запрос (текущая)
|
// Запрошена та же страница от которой послан запрос (текущая)
|
||||||
|
@ -35,7 +38,7 @@ use app\models\SupplyEdgeProduct;
|
||||||
} else {
|
} else {
|
||||||
echo <<<HTML
|
echo <<<HTML
|
||||||
<dt>
|
<dt>
|
||||||
<a class="row text-dark button_white px-3 py-3 py-lg-2 font-weight-normal" title="Панель управления сайтом" href="$targetUrl" role="button" onclick="return page_profile_trusted_settings();"><i class="fas fa-user-shield my-auto mx-auto mx-lg-0 col-1 pl-0 mr-lg-2"></i><span>Панель управления</span></a>
|
<a class="row text-dark button_white px-3 py-3 py-lg-2 font-weight-normal" title="Панель управления сайтом" href="$targetUrl" role="button" onclick="return page_profile_panel_settings();"><i class="fas fa-user-shield my-auto mx-auto mx-lg-0 col-1 pl-0 mr-lg-2"></i><span>Панель управления</span></a>
|
||||||
</dt>
|
</dt>
|
||||||
HTML;
|
HTML;
|
||||||
}
|
}
|
||||||
|
@ -43,19 +46,21 @@ use app\models\SupplyEdgeProduct;
|
||||||
?>
|
?>
|
||||||
<dt>
|
<dt>
|
||||||
<?php
|
<?php
|
||||||
if (
|
if (yii::$app->user->identity->agnt) {
|
||||||
'/' . yii::$app->request->pathInfo === $targetUrl = '/profile/supplies'
|
if (
|
||||||
|| '/' . yii::$app->request->pathInfo === $targetUrl = '/profile/import'
|
'/' . yii::$app->request->pathInfo === $targetUrl = '/profile/supplies'
|
||||||
) {
|
|| '/' . yii::$app->request->pathInfo === $targetUrl = '/profile/import'
|
||||||
// Запрошена та же страница от которой послан запрос (текущая)
|
) {
|
||||||
|
// Запрошена та же страница от которой послан запрос (текущая)
|
||||||
|
|
||||||
echo <<<HTML
|
echo <<<HTML
|
||||||
<a class="row text-dark button_white button_white_hover px-3 py-3 py-lg-2 font-weight-normal" title="Управление поставками" href="$targetUrl" role="button" onclick="return false;"><i class="fas fa-truck my-auto mx-auto mx-lg-0 col-1 pl-0 mr-lg-2"></i><span>Поставки</span></a>
|
<a class="row text-dark button_white button_white_hover px-3 py-3 py-lg-2 font-weight-normal" title="Управление поставками" href="$targetUrl" role="button" onclick="return false;"><i class="fas fa-truck my-auto mx-auto mx-lg-0 col-1 pl-0 mr-lg-2"></i><span>Поставки</span></a>
|
||||||
HTML;
|
HTML;
|
||||||
} else {
|
} else {
|
||||||
echo <<<HTML
|
echo <<<HTML
|
||||||
<a class="row text-dark button_white px-3 py-3 py-lg-2 font-weight-normal" title="Управление поставками" href="$targetUrl" role="button" onclick="return page_profile_supplies();"><i class="fas fa-truck my-auto mx-auto mx-lg-0 col-1 pl-0 mr-lg-2"></i><span>Поставки</span></a>
|
<a class="row text-dark button_white px-3 py-3 py-lg-2 font-weight-normal" title="Управление поставками" href="$targetUrl" role="button" onclick="return page_profile_supplies();"><i class="fas fa-truck my-auto mx-auto mx-lg-0 col-1 pl-0 mr-lg-2"></i><span>Поставки</span></a>
|
||||||
HTML;
|
HTML;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</dt>
|
</dt>
|
||||||
|
@ -96,21 +101,24 @@ use app\models\SupplyEdgeProduct;
|
||||||
?>
|
?>
|
||||||
</dt>
|
</dt>
|
||||||
</dl>
|
</dl>
|
||||||
<div class="dropdown-divider my-3"></div>
|
<?php if (yii::$app->user->identity->agnt) : ?>
|
||||||
<div class="row px-3">
|
<div class="dropdown-divider my-3"></div>
|
||||||
<p class="ml-0">Загрузок с аккаунта:</p>
|
<div class="row px-3">
|
||||||
<p class="mr-0"><?= AccountEdgeSupply::readAmount() ?></p>
|
<p class="ml-0">Загрузок с аккаунта:</p>
|
||||||
</div>
|
<p class="mr-0"><?= AccountEdgeSupply::readAmount() ?>
|
||||||
<div class="row px-3">
|
</p>
|
||||||
<p class="ml-0">Товары:</p>
|
</div>
|
||||||
<p class="mr-0"><?= Product::readAmount() ?></p>
|
<div class="row px-3">
|
||||||
</div>
|
<p class="ml-0">Товары:</p>
|
||||||
<div class="row px-3">
|
<p class="mr-0"><?= Product::readAmount() ?></p>
|
||||||
<p class="ml-0">Поставки:</p>
|
</div>
|
||||||
<p class="mr-0"><?= Supply::readAmount() ?></p>
|
<div class="row px-3">
|
||||||
</div>
|
<p class="ml-0">Поставки:</p>
|
||||||
<div class="row px-3">
|
<p class="mr-0"><?= Supply::readAmount() ?></p>
|
||||||
<p class="ml-0">Связано поставок:</p>
|
</div>
|
||||||
<p class="mr-0"><?= SupplyEdgeProduct::readAmount() ?></p>
|
<div class="row px-3">
|
||||||
</div>
|
<p class="ml-0">Связано поставок:</p>
|
||||||
|
<p class="mr-0"><?= SupplyEdgeProduct::readAmount() ?></p>
|
||||||
|
</div>
|
||||||
|
<?php endif ?>
|
||||||
</div>
|
</div>
|
|
@ -51,7 +51,7 @@ $panel ?? $panel = 'profile_panel_supplies_input_import';
|
||||||
]);
|
]);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?= $form->field($model, 'file', ['enableLabel' => false])->fileInput(['multiple' => true, 'class' => 'mb-2', 'onChange' => 'page_profile_supplies_import_excel(this.parentElement.parentElement, \'profile_panel_supplies_input_import\')']) ?>
|
<?= $form->field($model, 'file_excel', ['enableLabel' => false])->fileInput(['multiple' => true, 'class' => 'mb-2', 'onChange' => 'page_profile_supplies_import_excel(this.parentElement.parentElement, \'profile_panel_supplies_input_import\')']) ?>
|
||||||
|
|
||||||
<?= $form->errorSummary($model, ['header' => 'В документе были допущены ошибки:' /*, 'footer' => 'Исправьте их и попробуйте снова'*/]); ?>
|
<?= $form->errorSummary($model, ['header' => 'В документе были допущены ошибки:' /*, 'footer' => 'Исправьте их и попробуйте снова'*/]); ?>
|
||||||
|
|
||||||
|
@ -63,4 +63,10 @@ $panel ?? $panel = 'profile_panel_supplies_input_import';
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/js/profile.js" defer></script>
|
<script src="/js/profile.js" defer></script>
|
||||||
|
<?php if (
|
||||||
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) : ?>
|
||||||
|
<script src="/js/profile_panel.js" defer></script>
|
||||||
|
<?php endif ?>
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="d-flex flex-column mx-auto">
|
<div class="d-flex flex-column mx-auto">
|
||||||
<p class="px-2 mb-1 text-center d-flex justify-content-center">Слишком частые запросы, повторите попытку через: $timer секунд</p>
|
<p class="px-2 mb-1 text-center d-flex justify-content-center">Слишком частые запросы, повторите попытку через: $timer секунд</p>
|
||||||
<small class="mb-3 text-center d-flex justify-content-center">Подождите или нажмите на кнопку вручную</small>
|
<small class="mb-3 text-center d-flex justify-content-center">Подождите или нажмите на кнопку вручную</small>
|
||||||
<a class="btn text-white button_clean button_blue mx-auto" onclick="window.location.reload();">Повторить</a>
|
<a class="btn text-white button_clean button_blue mx-auto" title="Перезагрузить страницу" role="button" onclick="window.location.reload();">Повторить</a>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
setTimeout('window.location.reload()', $timer + '000');
|
setTimeout('window.location.reload()', $timer + '000');
|
||||||
|
@ -147,4 +147,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/js/cart.js" defer></script>
|
<script src="/js/cart.js" defer></script>
|
||||||
|
<script src="/js/product.js" defer></script>
|
||||||
|
<?php if (
|
||||||
|
yii::$app->user->identity->type === 'administrator'
|
||||||
|
|| yii::$app->user->identity->type === 'moderator'
|
||||||
|
) : ?>
|
||||||
|
<script src="/js/product_panel.js" defer></script>
|
||||||
|
<?php endif ?>
|
|
@ -30,4 +30,8 @@
|
||||||
#page_product #product_slider>.product_slider_preview>label:focus>img {
|
#page_product #product_slider>.product_slider_preview>label:focus>img {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
filter: brightness(0.8) contrast(1.3);
|
filter: brightness(0.8) contrast(1.3);
|
||||||
|
}
|
||||||
|
|
||||||
|
#page_product article .product_description {
|
||||||
|
display: contents;
|
||||||
}
|
}
|
|
@ -1 +1,2 @@
|
||||||
/supplies
|
/supplies
|
||||||
|
/products
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
|
@ -61,7 +61,6 @@ function cart_pay() {
|
||||||
* Управление чекбоксами
|
* Управление чекбоксами
|
||||||
*/
|
*/
|
||||||
function cart_list_checkbox(target) {
|
function cart_list_checkbox(target) {
|
||||||
|
|
||||||
// Инициализация
|
// Инициализация
|
||||||
let elements = document.getElementsByClassName('cart_list_target');
|
let elements = document.getElementsByClassName('cart_list_target');
|
||||||
let reg = /^\w+_([^_]*)$/;
|
let reg = /^\w+_([^_]*)$/;
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
function product_response_success(data, status) {
|
||||||
|
product_response(data, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
function product_response_error(data, status) {
|
||||||
|
// Инициализация
|
||||||
|
data = data.responseJSON;
|
||||||
|
|
||||||
|
product_response(data, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
function product_response(data, status) {
|
||||||
|
// Основной блок
|
||||||
|
if (data.main !== undefined) {
|
||||||
|
// Инициализация
|
||||||
|
main = document.getElementsByTagName('main')[0];
|
||||||
|
|
||||||
|
// Обновление документа
|
||||||
|
main.innerHTML = data.main;
|
||||||
|
|
||||||
|
// Реинициализация
|
||||||
|
reinitialization(main);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Перенаправление
|
||||||
|
if (data.redirect !== undefined) {
|
||||||
|
// Перенаправление
|
||||||
|
history.pushState({}, document.title, data.redirect);
|
||||||
|
};
|
||||||
|
|
||||||
|
// CSRF-токен
|
||||||
|
if (data._csrf !== undefined) {
|
||||||
|
// Обновление документа
|
||||||
|
$('meta[name=csrf-token]').prop("content", data._csrf);
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,181 @@
|
||||||
|
function product_panel_title_edit(catn, element) {
|
||||||
|
if (catn !== null && catn !== undefined && element !== null && element !== undefined) {
|
||||||
|
element.innerHTML = '<input class="form-control text-center" type="text" value="' + element.innerText + '" onchange="return product_panel_title_save(\'' + catn + '\', this.parentElement)" aria-invalid="false">';
|
||||||
|
|
||||||
|
element.removeAttribute('onclick');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function product_panel_title_save(catn, element) {
|
||||||
|
if (catn !== null && catn !== undefined && element !== null && element !== undefined) {
|
||||||
|
// Инициализация
|
||||||
|
let text = element.children[0].value;
|
||||||
|
|
||||||
|
// Обновление заголовка (предзагрузка)
|
||||||
|
element.innerHTML = text;
|
||||||
|
|
||||||
|
// Запись аттрибута (предзагрузка)
|
||||||
|
element.setAttribute('onclick', 'return product_panel_title_edit(\'' + catn + '\', this);');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/product/' + catn + '/edit/title',
|
||||||
|
type: 'post',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
'_csrf': yii.getCsrfToken(),
|
||||||
|
'text': text
|
||||||
|
},
|
||||||
|
success: function (data, status) {
|
||||||
|
// Заголовок
|
||||||
|
if (data.name !== undefined && element !== null && element !== undefined) {
|
||||||
|
// Обновление заголовка
|
||||||
|
element.innerHTML = data.name;
|
||||||
|
|
||||||
|
// Запись аттрибута
|
||||||
|
element.setAttribute('onclick', 'return product_panel_title_edit(\'' + catn + '\', this);');
|
||||||
|
};
|
||||||
|
|
||||||
|
product_response_success(data, status);
|
||||||
|
},
|
||||||
|
error: product_response_error
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function product_panel_catn_edit(catn, element, redirect = false) {
|
||||||
|
if (catn !== null && catn !== undefined && element !== null && element !== undefined) {
|
||||||
|
element.innerHTML = '<input class="form-control text-center" type="text" value="' + element.innerText + '" onchange="return product_panel_catn_save(\'' + catn + '\', this.parentElement, ' + redirect + ')" aria-invalid="false">';
|
||||||
|
|
||||||
|
element.removeAttribute('onclick');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function product_panel_catn_save(catn, element, redirect = false) {
|
||||||
|
if (catn !== null && catn !== undefined && element !== null && element !== undefined) {
|
||||||
|
// Инициализация
|
||||||
|
let text = element.children[0].value;
|
||||||
|
|
||||||
|
// Обновление заголовка (предзагрузка)
|
||||||
|
element.innerHTML = text;
|
||||||
|
|
||||||
|
// Запись аттрибута (предзагрузка)
|
||||||
|
element.setAttribute('onclick', 'return product_panel_catn_edit(\'' + catn + '\', this);');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/product/' + catn + '/edit/catn',
|
||||||
|
type: 'post',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
'_csrf': yii.getCsrfToken(),
|
||||||
|
'text': text
|
||||||
|
},
|
||||||
|
success: function (data, status) {
|
||||||
|
// Заголовок
|
||||||
|
if (data.catn !== undefined && element !== null && element !== undefined) {
|
||||||
|
if (redirect) {
|
||||||
|
// Перенаправление
|
||||||
|
history.pushState({}, '/product/' + catn, '/product/' + data.catn);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
product_response_success(data, status);
|
||||||
|
},
|
||||||
|
error: product_response_error
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function product_panel_description_edit(catn, element) {
|
||||||
|
if (catn !== null && catn !== undefined && element !== null && element !== undefined) {
|
||||||
|
element.innerHTML = '<textarea class="form-control" cols="50" rows="5" onchange = "return product_panel_description_save(\'' + catn + '\', this.parentElement)">' + element.innerText + '</textarea>';
|
||||||
|
|
||||||
|
element.removeAttribute('onclick');
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function product_panel_description_save(catn, element) {
|
||||||
|
if (catn !== null && catn !== undefined && element !== null && element !== undefined) {
|
||||||
|
// Инициализация
|
||||||
|
let text = element.children[0].value;
|
||||||
|
|
||||||
|
// Обновление заголовка (предзагрузка)
|
||||||
|
element.innerHTML = text;
|
||||||
|
|
||||||
|
// Запись аттрибута (предзагрузка)
|
||||||
|
element.setAttribute('onclick', 'return product_panel_description_edit(\'' + catn + '\', this);');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/product/' + catn + '/edit/desc',
|
||||||
|
type: 'post',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {
|
||||||
|
'_csrf': yii.getCsrfToken(),
|
||||||
|
'text': text
|
||||||
|
},
|
||||||
|
success: function (data, status) {
|
||||||
|
// Заголовок
|
||||||
|
if (data.description !== undefined && element !== null && element !== undefined) {
|
||||||
|
// Обновление заголовка
|
||||||
|
element.innerHTML = data.description;
|
||||||
|
|
||||||
|
// Запись аттрибута
|
||||||
|
element.setAttribute('onclick', 'return product_panel_description_edit(\'' + catn + '\', this);');
|
||||||
|
};
|
||||||
|
|
||||||
|
product_response_success(data, status);
|
||||||
|
},
|
||||||
|
error: product_response_error
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function product_panel_images_write(catn, element) {
|
||||||
|
if (catn !== null && catn !== undefined && element !== null && element !== undefined) {
|
||||||
|
// Инициализация
|
||||||
|
let data = new FormData();
|
||||||
|
|
||||||
|
data.append('_csrf', yii.getCsrfToken());
|
||||||
|
for (i = 0; i < element.files.length; i++) {
|
||||||
|
data.append('images[' + i + ']', element.files[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/product/' + catn + '/write/image',
|
||||||
|
type: 'post',
|
||||||
|
dataType: 'json',
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
data: data,
|
||||||
|
success: product_response_success,
|
||||||
|
error: product_response_error
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -48,9 +48,9 @@ function page_profile_supplies_import_excel(form, panel) {
|
||||||
url: '/profile/import',
|
url: '/profile/import',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: form,
|
|
||||||
processData: false,
|
processData: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
|
data: form,
|
||||||
success: page_profile_response_success,
|
success: page_profile_response_success,
|
||||||
error: page_profile_response_error
|
error: page_profile_response_error
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
function page_profile_trusted_notification_create(form, html = 0) {
|
function page_profile_panel_notification_create(form, html = 0) {
|
||||||
if (form == undefined) {
|
if (form == undefined) {
|
||||||
form = {
|
form = {
|
||||||
'_csrf': yii.getCsrfToken()
|
'_csrf': yii.getCsrfToken()
|
||||||
|
@ -13,10 +13,10 @@ function page_profile_trusted_notification_create(form, html = 0) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_profile_trusted_write(form);
|
return page_profile_panel_write(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
function page_profile_trusted_settings(form, panel) {
|
function page_profile_panel_settings(form, panel) {
|
||||||
if (form == undefined) {
|
if (form == undefined) {
|
||||||
form = {
|
form = {
|
||||||
'_csrf': yii.getCsrfToken()
|
'_csrf': yii.getCsrfToken()
|
||||||
|
@ -34,12 +34,12 @@ function page_profile_trusted_settings(form, panel) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return page_profile_trusted_write(form);
|
return page_profile_panel_write(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
function page_profile_trusted_write (form) {
|
function page_profile_panel_write (form) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/profile/trusted',
|
url: '/profile/panel',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
data: form,
|
data: form,
|
Reference in New Issue