Добавлены сессии, разделение по правам доступа, редактирование товаров
This commit is contained in:
parent
722bf6c378
commit
3fea918255
|
@ -1,2 +1,3 @@
|
|||
/vendor
|
||||
/cache
|
||||
/.vscode
|
|
@ -24,8 +24,7 @@
|
|||
"triagens/arangodb": "^3.6",
|
||||
"moonlandsoft/yii2-phpexcel": ">=2.0",
|
||||
"carono/yii2-1c-exchange": "^0.3.1",
|
||||
"mirzaev/yii2-arangodb": "~2.1.x-dev",
|
||||
"mirzaev/yii2-arangodb-sessions": "~1.0.0"
|
||||
"yiisoft/yii2-imagine": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeception/codeception": ">=4.1",
|
||||
|
@ -42,7 +41,9 @@
|
|||
},
|
||||
"autoload": {
|
||||
"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": {
|
||||
|
|
|
@ -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": "116946ecdb84687a081d5633fd8505f6",
|
||||
"content-hash": "77be6b3a5d18070b9d685430060a770e",
|
||||
"packages": [
|
||||
{
|
||||
"name": "bower-asset/bootstrap",
|
||||
|
@ -471,6 +471,68 @@
|
|||
},
|
||||
"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",
|
||||
"version": "2.1.0",
|
||||
|
@ -2019,6 +2081,89 @@
|
|||
],
|
||||
"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",
|
||||
"version": "2.1.2",
|
||||
|
|
|
@ -19,16 +19,27 @@ $config = [
|
|||
'class' => 'yii\caching\FileCache',
|
||||
],
|
||||
'user' => [
|
||||
'identityClass' => 'app\models\Account',
|
||||
'identityClass' => 'app\models\Account',
|
||||
'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' => [
|
||||
'errorAction' => 'error',
|
||||
],
|
||||
|
|
|
@ -48,7 +48,7 @@ class AuthenticationController extends Controller
|
|||
// Аккаунт аутентифицирован
|
||||
|
||||
// Создание сессии
|
||||
yii::$app->session->open();
|
||||
// yii::$app->session->open();
|
||||
|
||||
// Инициализация
|
||||
$notifications_button = $this->renderPartial('/notification/button');
|
||||
|
|
|
@ -37,11 +37,13 @@ class DeauthenticationController extends Controller
|
|||
// Инициализация
|
||||
yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
// Удаление сессии
|
||||
yii::$app->session['status'] = 'inactive';
|
||||
// yii::$app->session->close();
|
||||
|
||||
// Выход из аккаунта
|
||||
yii::$app->user->logout();
|
||||
|
||||
// Удаление сессии
|
||||
yii::$app->session->destroy();
|
||||
|
||||
// Инициализация
|
||||
$model = new AccountForm(yii::$app->request->post('AccountForm') ?? yii::$app->request->get('AccountForm') ?? null);
|
||||
|
|
|
@ -19,11 +19,11 @@ class NotificationController extends Controller
|
|||
return [
|
||||
'access' => [
|
||||
'class' => AccessControl::class,
|
||||
'only' => ['index'],
|
||||
'rules' => [
|
||||
[
|
||||
'allow' => true,
|
||||
'roles' => ['@']
|
||||
'roles' => ['@'],
|
||||
'actions' => ['index']
|
||||
]
|
||||
]
|
||||
]
|
||||
|
@ -35,8 +35,6 @@ class NotificationController extends Controller
|
|||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
var_dump(yii::$app->session->id);
|
||||
|
||||
if (yii::$app->request->isPost) {
|
||||
// POST-запрос
|
||||
|
||||
|
|
|
@ -20,17 +20,52 @@ class OrderController extends Controller
|
|||
return [
|
||||
'access' => [
|
||||
'class' => AccessControl::class,
|
||||
'only' => ['index'],
|
||||
'rules' => [
|
||||
[
|
||||
'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()
|
||||
{
|
||||
// Инициализация
|
||||
|
|
|
@ -4,56 +4,31 @@ declare(strict_types=1);
|
|||
|
||||
namespace app\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\web\Controller;
|
||||
use yii\web\Response;
|
||||
use yii\web\HttpException;
|
||||
use yii\web\UploadedFile;
|
||||
|
||||
use app\models\Product;
|
||||
|
||||
class ProductController extends Controller
|
||||
{
|
||||
// /**
|
||||
// * {@inheritdoc}
|
||||
// */
|
||||
// public function behaviors()
|
||||
// {
|
||||
// return [
|
||||
// 'access' => [
|
||||
// 'class' => AccessControl::class,
|
||||
// 'rules' => [
|
||||
// [
|
||||
// 'allow' => true,
|
||||
// 'actions' => ['index'],
|
||||
// 'roles' => ['@']
|
||||
// ],
|
||||
// [
|
||||
// 'allow' => false,
|
||||
// 'roles' => ['?']
|
||||
// ],
|
||||
// ]
|
||||
// ]
|
||||
// ];
|
||||
// }
|
||||
|
||||
public function actionIndex(string $catn)
|
||||
public function actionIndex(string $catn): array|string|null
|
||||
{
|
||||
if ($model = Product::searchByCatn($catn)) {
|
||||
// Товар найден
|
||||
|
||||
// Инициализация
|
||||
$model = $model->getAttributes();
|
||||
|
||||
if (Yii::$app->request->isAjax) {
|
||||
if (yii::$app->request->isAjax) {
|
||||
// AJAX-POST-запрос
|
||||
|
||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||
yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
return [
|
||||
'main' => $this->renderPartial('index', compact('model')),
|
||||
'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);
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
'roles' => ['@'],
|
||||
'actions' => ['index', 'supplies', 'import', 'monitoring', 'readGroups'],
|
||||
'actions' => ['index', 'supplies', 'import', 'monitoring', 'readGroups']
|
||||
],
|
||||
[
|
||||
'allow' => false,
|
||||
|
@ -38,9 +38,16 @@ class ProfileController extends Controller
|
|||
],
|
||||
[
|
||||
'allow' => true,
|
||||
'actions' => ['trusted', 'trusted-notification-write'],
|
||||
'matchCallback' => function ($rule, $action) {
|
||||
return yii::$app->user->identity->trst;
|
||||
'actions' => ['panel', 'panel-notification-write'],
|
||||
'matchCallback' => function ($rule, $action): bool {
|
||||
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;
|
||||
|
@ -196,18 +203,18 @@ class ProfileController extends Controller
|
|||
yii::$app->response->format = Response::FORMAT_JSON;
|
||||
|
||||
return [
|
||||
'main' => $this->renderPartial('trusted', compact(
|
||||
'main' => $this->renderPartial('panel', compact(
|
||||
'model_notifications',
|
||||
'model_settings',
|
||||
'sidebar',
|
||||
'panel'
|
||||
)),
|
||||
'redirect' => '/profile/trusted',
|
||||
'redirect' => '/profile/panel',
|
||||
'_csrf' => yii::$app->request->getCsrfToken()
|
||||
];
|
||||
}
|
||||
|
||||
return $this->render('trusted', compact(
|
||||
return $this->render('panel', compact(
|
||||
'model_notifications',
|
||||
'model_settings',
|
||||
'sidebar',
|
||||
|
@ -348,9 +355,10 @@ class ProfileController extends Controller
|
|||
*/
|
||||
public function actionImport()
|
||||
{
|
||||
var_dump($_FILES);
|
||||
// Инициализация
|
||||
$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');
|
||||
$sidebar = $this->renderPartial('sidebar');
|
||||
$groups = self::readGroups();
|
||||
|
@ -360,9 +368,9 @@ class ProfileController extends Controller
|
|||
|
||||
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 [
|
||||
'main' => $this->renderPartial('supplies', compact(
|
||||
'model',
|
||||
|
|
|
@ -51,7 +51,6 @@ class SearchController extends Controller
|
|||
|
||||
// Инициализация сессии
|
||||
$session = yii::$app->session;
|
||||
$session->open();
|
||||
|
||||
// Инициализация ответа
|
||||
$response = null;
|
||||
|
@ -129,7 +128,7 @@ class SearchController extends Controller
|
|||
|
||||
$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) {
|
||||
|
|
|
@ -42,7 +42,8 @@ class Account extends Document implements IdentityInterface, PartnerInterface
|
|||
'taxn',
|
||||
'onec',
|
||||
'opts',
|
||||
'trst'
|
||||
'agnt',
|
||||
'type'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -65,7 +66,8 @@ class Account extends Document implements IdentityInterface, PartnerInterface
|
|||
'taxn' => 'ИНН',
|
||||
'onec' => 'Данные 1C',
|
||||
'opts' => 'Параметры',
|
||||
'trst' => 'Доверенный пользователь'
|
||||
'agnt' => 'Агент (поставщик)',
|
||||
'type' => 'Тип аккаунта'
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class AccountForm extends Model
|
|||
|
||||
public $mail;
|
||||
public $pswd;
|
||||
public $auto = true;
|
||||
public $auto = false;
|
||||
|
||||
private $account = false;
|
||||
|
||||
|
|
|
@ -67,11 +67,14 @@ abstract class Document extends ActiveRecord
|
|||
if (parent::beforeSave($data)) {
|
||||
if ($this->isNewRecord) {
|
||||
// Запись в журнал
|
||||
$this->jrnl = [[
|
||||
'date' => time(),
|
||||
'account' => yii::$app->user->id,
|
||||
'action' => 'create'
|
||||
]];
|
||||
$this->jrnl = array_merge(
|
||||
[[
|
||||
'date' => time(),
|
||||
'account' => yii::$app->user->id,
|
||||
'action' => 'create'
|
||||
]],
|
||||
$this->jrnl ?? []
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -92,7 +95,10 @@ abstract class Document extends ActiveRecord
|
|||
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(
|
||||
|
@ -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()) {
|
||||
// Записано в базу данных
|
||||
|
||||
// Запись в журнал
|
||||
$edge->journal('create');
|
||||
|
||||
return $edge;
|
||||
}
|
||||
|
||||
return null;
|
||||
return $edge->save() ? $edge : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,7 +45,7 @@ class Notification extends Document
|
|||
*
|
||||
* @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')) {
|
||||
// Поставка не найдена или запись ребра не удалась
|
||||
|
||||
var_dump('ПИЗДА');
|
||||
|
||||
continue;
|
||||
} else {
|
||||
// Ребро создано (товар подключен к заказу)
|
||||
|
|
|
@ -5,6 +5,8 @@ declare(strict_types=1);
|
|||
namespace app\models;
|
||||
|
||||
use yii;
|
||||
use yii\web\UploadedFile;
|
||||
use yii\imagine\Image;
|
||||
|
||||
use app\models\traits\SearchByEdge;
|
||||
|
||||
|
@ -22,11 +24,18 @@ class Product extends Document
|
|||
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 для импорта товаров
|
||||
*/
|
||||
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(
|
||||
parent::attributes(),
|
||||
[
|
||||
'catn',
|
||||
'name',
|
||||
'desc',
|
||||
'ocid',
|
||||
'catn',
|
||||
'imgs',
|
||||
'time',
|
||||
'oemn',
|
||||
|
@ -79,13 +94,15 @@ class Product extends Document
|
|||
parent::attributeLabels(),
|
||||
[
|
||||
'catn' => 'Каталожный номер (catn)',
|
||||
'name' => 'Название (name)',
|
||||
'desc' => 'Описание (desc)',
|
||||
'ocid' => 'Идентификатор 1C (ocid)',
|
||||
'imgs' => 'Изображения (imgs)',
|
||||
'time' => 'Срок доставки (time)',
|
||||
'oemn' => 'OEM номера (oemn)',
|
||||
'cost' => 'Стоимость (cost)',
|
||||
'file' => 'Документ (file)',
|
||||
'file_excel' => 'Документ (file_excel)',
|
||||
'file_image' => 'Изображение (file_image)',
|
||||
'group' => 'Группа (group)'
|
||||
]
|
||||
);
|
||||
|
@ -104,7 +121,7 @@ class Product extends Document
|
|||
'required',
|
||||
'message' => 'Заполните поля: {attribute}',
|
||||
'on' => self::SCENARIO_WRITE,
|
||||
'except' => self::SCENARIO_IMPORT
|
||||
'except' => [self::SCENARIO_IMPORT_EXCEL, self::SCENARIO_IMPORT_IMAGE]
|
||||
],
|
||||
[
|
||||
'catn',
|
||||
|
@ -120,13 +137,13 @@ class Product extends Document
|
|||
'message' => '{attribute} должен быть массивом.'
|
||||
],
|
||||
[
|
||||
'file',
|
||||
'file_excel',
|
||||
'required',
|
||||
'message' => 'Заполните поля: {attribute}',
|
||||
'on' => self::SCENARIO_IMPORT
|
||||
'on' => self::SCENARIO_IMPORT_EXCEL
|
||||
],
|
||||
[
|
||||
'file',
|
||||
'file_excel',
|
||||
'file',
|
||||
'skipOnEmpty' => false,
|
||||
'extensions' => 'xlsx',
|
||||
|
@ -135,7 +152,25 @@ class Product extends Document
|
|||
'maxSize' => 1024 * 1024 * 30,
|
||||
'wrongExtension' => 'Разрешены только документы в формате: ".xlsx"',
|
||||
'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 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
|
||||
*/
|
||||
public function import(): bool
|
||||
public function importExcel(): bool
|
||||
{
|
||||
// Инициализация
|
||||
$data = [];
|
||||
$amount = 0;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -325,7 +433,34 @@ class Product extends Document
|
|||
}
|
||||
|
||||
$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])
|
||||
->limit($limit)
|
||||
->select($select)
|
||||
|
|
|
@ -7,6 +7,9 @@ use yii\bootstrap\ActiveForm;
|
|||
|
||||
use app\models\AccountForm;
|
||||
|
||||
/**
|
||||
* @todo Восстановить сохранение сессии
|
||||
*/
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
|
|
|
@ -6,6 +6,7 @@ use yii\helpers\Html;
|
|||
use app\models\Product;
|
||||
|
||||
?>
|
||||
|
||||
<link href="/css/pages/product.css" rel="stylesheet">
|
||||
|
||||
<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';
|
||||
|
||||
// Генерация предпросмотра изображения
|
||||
echo <<<HTML
|
||||
<label class="p-0 mb-2" for="product_slider_image_$key">
|
||||
<img class="img-fluid rounded" src="$h150"/>
|
||||
</label>
|
||||
HTML;
|
||||
<label class="p-0 mb-2" for="product_slider_image_$key">
|
||||
<img class="img-fluid rounded" src="$h150"/>
|
||||
</label>
|
||||
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 class="product_slider_image">
|
||||
<?php
|
||||
|
@ -37,7 +47,7 @@ use app\models\Product;
|
|||
$imgs = $model['imgs'] ?? [null];
|
||||
$checked = '';
|
||||
|
||||
foreach ($imgs as $key => $image) {
|
||||
foreach ($model['imgs'] ?? [null] as $key => $image) {
|
||||
// Перебор изображений
|
||||
|
||||
// Инициализация
|
||||
|
@ -54,11 +64,11 @@ use app\models\Product;
|
|||
|
||||
// Генерация изображения
|
||||
echo <<<HTML
|
||||
<input type="radio" id="product_slider_image_$key" name="slider" $checked/>
|
||||
<div class="col p-0">
|
||||
<img class="img-fluid rounded" src="$orig"/>
|
||||
</div>
|
||||
HTML;
|
||||
<input type="radio" id="product_slider_image_$key" name="slider" $checked/>
|
||||
<div class="col p-0">
|
||||
<img class="img-fluid rounded" src="$orig"/>
|
||||
</div>
|
||||
HTML;
|
||||
|
||||
// Деинициализация
|
||||
$checked = '';
|
||||
|
@ -67,13 +77,47 @@ use app\models\Product;
|
|||
</div>
|
||||
<div class="col ml-4 d-flex flex-column">
|
||||
<div class="row mb-1">
|
||||
<h3 class="my-auto">Название товара</h3>
|
||||
<h5 class="ml-auto my-auto"><?= $model['catn'] ?></h5>
|
||||
<?php if (
|
||||
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 class="dropdown-divider px-0 mb-3"></div>
|
||||
<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">
|
||||
ОЕМ-номера можно сюда добавить с возможностью перехода
|
||||
<?php
|
||||
// foreach ($model['catn'] ?? [] as $catn) {
|
||||
// echo <<<HTML
|
||||
|
@ -118,11 +162,20 @@ use app\models\Product;
|
|||
<?php ActiveForm::end(); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-auto mx-0">
|
||||
|
||||
<!-- <div class="row mt-3 mx-0">
|
||||
<p class="ml-0">Время для повышения релевантности в поисковиках</p>
|
||||
<time class="ml-auto"></time>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</article>
|
||||
</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;
|
||||
|
||||
// Инициализация
|
||||
$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">
|
||||
|
@ -22,51 +26,59 @@ $panel ?? $panel = 'profile_panel_settings_import';
|
|||
<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>
|
||||
<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>
|
||||
<?php
|
||||
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 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">
|
||||
1
|
||||
</div>
|
||||
|
||||
<input type="radio" id="profile_panel_settings_company" name="main_panel" <?= $panel === 'profile_panel_settings_company' ? 'checked' : null ?>/>
|
||||
<div class="col">
|
||||
2
|
||||
</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;'
|
||||
]
|
||||
]);
|
||||
<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;
|
||||
$list or $list = ['Нет данных'];
|
||||
?>
|
||||
// Инициализация
|
||||
$model ?? $model = yii::$app->user->identity;
|
||||
$list or $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-номера'); ?>
|
||||
<small class="d-block mb-1">Выберите поле в котором хранятся <b>ОЕМ-номера</b> и повторите импорт</small>
|
||||
<small class="d-block">Значения взяты из импортированных товаров</small>
|
||||
<?= $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-номера'); ?>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
</div>
|
||||
<small class="d-block mb-1">Выберите поле в котором хранятся <b>ОЕМ-номера</b> и повторите импорт</small>
|
||||
<small class="d-block">Значения взяты из импортированных товаров</small>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -75,3 +87,9 @@ $panel ?? $panel = 'profile_panel_settings_import';
|
|||
</div>
|
||||
|
||||
<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>
|
||||
|
||||
<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="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>
|
||||
|
@ -78,3 +78,9 @@ $panel ?? $panel = 'profile_panel_monitoring_input_search_history';
|
|||
</div>
|
||||
|
||||
<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;
|
||||
|
||||
// Инициализация
|
||||
$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">
|
||||
<div class="p-4 rounded">
|
||||
<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">
|
||||
<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_trusted_input_settings">Настройки</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_panel_input_settings">Настройки</label>
|
||||
</div>
|
||||
<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">
|
||||
<h5>Отправка уведомления</h5>
|
||||
<div class="dropdown-divider mb-3"></div>
|
||||
<?php
|
||||
$form = ActiveForm::begin([
|
||||
'id' => 'form_profile_trusted_notifications',
|
||||
'id' => 'form_profile_panel_notifications',
|
||||
'action' => false,
|
||||
'fieldConfig' => [
|
||||
'template' => '{label}{input}'
|
||||
|
@ -62,17 +62,17 @@ $panel ?? $panel = 'profile_panel_trusted_input_notifications';
|
|||
|
||||
<?= $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('Отправить как 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('Отправить', ['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_panel_notification_create(this.parentElement, 1);', 'class' => 'flex-grow-1 mr-2 btn button_white button_clean']) ?>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
</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">
|
||||
<?php
|
||||
$form = ActiveForm::begin([
|
||||
'id' => 'form_profile_trusted_settings_search_period',
|
||||
'id' => 'form_profile_panel_settings_search_period',
|
||||
'action' => false,
|
||||
'fieldConfig' => [
|
||||
'template' => '{label}{input}',
|
||||
|
@ -86,14 +86,14 @@ $panel ?? $panel = 'profile_panel_trusted_input_notifications';
|
|||
|
||||
<?= $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>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
<?php
|
||||
$form = ActiveForm::begin([
|
||||
'id' => 'form_profile_trusted_settings_search_connect_keep',
|
||||
'id' => 'form_profile_panel_settings_search_connect_keep',
|
||||
'action' => false,
|
||||
'fieldConfig' => [
|
||||
'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>
|
||||
|
||||
|
@ -142,4 +142,4 @@ $panel ?? $panel = 'profile_panel_trusted_input_notifications';
|
|||
</div>
|
||||
|
||||
<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>
|
||||
<dl class="m-0">
|
||||
<?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) {
|
||||
// Запрошена та же страница от которой послан запрос (текущая)
|
||||
|
@ -35,7 +38,7 @@ use app\models\SupplyEdgeProduct;
|
|||
} else {
|
||||
echo <<<HTML
|
||||
<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>
|
||||
HTML;
|
||||
}
|
||||
|
@ -43,19 +46,21 @@ use app\models\SupplyEdgeProduct;
|
|||
?>
|
||||
<dt>
|
||||
<?php
|
||||
if (
|
||||
'/' . yii::$app->request->pathInfo === $targetUrl = '/profile/supplies'
|
||||
|| '/' . yii::$app->request->pathInfo === $targetUrl = '/profile/import'
|
||||
) {
|
||||
// Запрошена та же страница от которой послан запрос (текущая)
|
||||
if (yii::$app->user->identity->agnt) {
|
||||
if (
|
||||
'/' . 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>
|
||||
HTML;
|
||||
} else {
|
||||
echo <<<HTML
|
||||
} else {
|
||||
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>
|
||||
HTML;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</dt>
|
||||
|
@ -96,21 +101,24 @@ use app\models\SupplyEdgeProduct;
|
|||
?>
|
||||
</dt>
|
||||
</dl>
|
||||
<div class="dropdown-divider my-3"></div>
|
||||
<div class="row px-3">
|
||||
<p class="ml-0">Загрузок с аккаунта:</p>
|
||||
<p class="mr-0"><?= AccountEdgeSupply::readAmount() ?></p>
|
||||
</div>
|
||||
<div class="row px-3">
|
||||
<p class="ml-0">Товары:</p>
|
||||
<p class="mr-0"><?= Product::readAmount() ?></p>
|
||||
</div>
|
||||
<div class="row px-3">
|
||||
<p class="ml-0">Поставки:</p>
|
||||
<p class="mr-0"><?= Supply::readAmount() ?></p>
|
||||
</div>
|
||||
<div class="row px-3">
|
||||
<p class="ml-0">Связано поставок:</p>
|
||||
<p class="mr-0"><?= SupplyEdgeProduct::readAmount() ?></p>
|
||||
</div>
|
||||
<?php if (yii::$app->user->identity->agnt) : ?>
|
||||
<div class="dropdown-divider my-3"></div>
|
||||
<div class="row px-3">
|
||||
<p class="ml-0">Загрузок с аккаунта:</p>
|
||||
<p class="mr-0"><?= AccountEdgeSupply::readAmount() ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="row px-3">
|
||||
<p class="ml-0">Товары:</p>
|
||||
<p class="mr-0"><?= Product::readAmount() ?></p>
|
||||
</div>
|
||||
<div class="row px-3">
|
||||
<p class="ml-0">Поставки:</p>
|
||||
<p class="mr-0"><?= Supply::readAmount() ?></p>
|
||||
</div>
|
||||
<div class="row px-3">
|
||||
<p class="ml-0">Связано поставок:</p>
|
||||
<p class="mr-0"><?= SupplyEdgeProduct::readAmount() ?></p>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</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' => 'Исправьте их и попробуйте снова'*/]); ?>
|
||||
|
||||
|
@ -64,3 +64,9 @@ $panel ?? $panel = 'profile_panel_supplies_input_import';
|
|||
</div>
|
||||
|
||||
<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">
|
||||
<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>
|
||||
<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>
|
||||
<script type="text/javascript">
|
||||
setTimeout('window.location.reload()', $timer + '000');
|
||||
|
@ -148,3 +148,10 @@
|
|||
</div>
|
||||
|
||||
<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 ?>
|
|
@ -31,3 +31,7 @@
|
|||
cursor: pointer;
|
||||
filter: brightness(0.8) contrast(1.3);
|
||||
}
|
||||
|
||||
#page_product article .product_description {
|
||||
display: contents;
|
||||
}
|
|
@ -1 +1,2 @@
|
|||
/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) {
|
||||
|
||||
// Инициализация
|
||||
let elements = document.getElementsByClassName('cart_list_target');
|
||||
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',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: form,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
data: form,
|
||||
success: page_profile_response_success,
|
||||
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) {
|
||||
form = {
|
||||
'_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) {
|
||||
form = {
|
||||
'_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({
|
||||
url: '/profile/trusted',
|
||||
url: '/profile/panel',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: form,
|
Reference in New Issue