Доработка корзины, фронтенд изменений

This commit is contained in:
Arsen Mirzaev Tatyano-Muradovich 2021-03-09 08:11:55 +10:00
parent 53d7e2a048
commit 081a34a8f4
24 changed files with 838 additions and 341 deletions

185
composer.lock generated
View File

@ -11,7 +11,7 @@
"version": "v3.4.1",
"source": {
"type": "git",
"url": "git@github.com:twbs/bootstrap.git",
"url": "https://github.com/twbs/bootstrap.git",
"reference": "68b0d231a13201eb14acd3dc84e51543d16e5f7e"
},
"dist": {
@ -32,7 +32,7 @@
"version": "3.3.11",
"source": {
"type": "git",
"url": "git@github.com:RobinHerbots/Inputmask.git",
"url": "https://github.com/RobinHerbots/Inputmask.git",
"reference": "5e670ad62f50c738388d4dcec78d2888505ad77b"
},
"dist": {
@ -53,7 +53,7 @@
"version": "3.5.1",
"source": {
"type": "git",
"url": "https://github.com/jquery/jquery-dist.git",
"url": "git@github.com:jquery/jquery-dist.git",
"reference": "4c0e4becb8263bb5b3e6dadc448d8e7305ef8215"
},
"dist": {
@ -876,10 +876,10 @@
},
{
"name": "npm-asset/jquery",
"version": "3.5.1",
"version": "3.6.0",
"dist": {
"type": "tar",
"url": "https://registry.npmjs.org/jquery/-/jquery-3.5.1.tgz"
"url": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz"
},
"type": "npm-asset",
"license": [
@ -888,16 +888,16 @@
},
{
"name": "phpoffice/phpspreadsheet",
"version": "1.16.0",
"version": "1.17.1",
"source": {
"type": "git",
"url": "https://github.com/PHPOffice/PhpSpreadsheet.git",
"reference": "76d4323b85129d0c368149c831a07a3e258b2b50"
"reference": "c55269cb06911575a126dc225a05c0e4626e5fb4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/76d4323b85129d0c368149c831a07a3e258b2b50",
"reference": "76d4323b85129d0c368149c831a07a3e258b2b50",
"url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/c55269cb06911575a126dc225a05c0e4626e5fb4",
"reference": "c55269cb06911575a126dc225a05c0e4626e5fb4",
"shasum": ""
},
"require": {
@ -925,7 +925,7 @@
},
"require-dev": {
"dompdf/dompdf": "^0.8.5",
"friendsofphp/php-cs-fixer": "^2.16",
"friendsofphp/php-cs-fixer": "^2.18",
"jpgraph/jpgraph": "^4.0",
"mpdf/mpdf": "^8.0",
"phpcompatibility/php-compatibility": "^9.3",
@ -983,9 +983,9 @@
],
"support": {
"issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues",
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.16.0"
"source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.17.1"
},
"time": "2020-12-31T18:03:49+00:00"
"time": "2021-03-02T17:54:11+00:00"
},
{
"name": "psr/http-client",
@ -1200,16 +1200,16 @@
},
{
"name": "swiftmailer/swiftmailer",
"version": "v6.2.5",
"version": "v6.2.6",
"source": {
"type": "git",
"url": "https://github.com/swiftmailer/swiftmailer.git",
"reference": "698a6a9f54d7eb321274de3ad19863802c879fb7"
"reference": "d2791ff0b73247cdc2096b14f5580aba40c12bff"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/698a6a9f54d7eb321274de3ad19863802c879fb7",
"reference": "698a6a9f54d7eb321274de3ad19863802c879fb7",
"url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/d2791ff0b73247cdc2096b14f5580aba40c12bff",
"reference": "d2791ff0b73247cdc2096b14f5580aba40c12bff",
"shasum": ""
},
"require": {
@ -1259,7 +1259,7 @@
],
"support": {
"issues": "https://github.com/swiftmailer/swiftmailer/issues",
"source": "https://github.com/swiftmailer/swiftmailer/tree/v6.2.5"
"source": "https://github.com/swiftmailer/swiftmailer/tree/v6.2.6"
},
"funding": [
{
@ -1271,7 +1271,7 @@
"type": "tidelift"
}
],
"time": "2021-01-12T09:35:59+00:00"
"time": "2021-03-05T12:08:49+00:00"
},
{
"name": "symfony/polyfill-iconv",
@ -1804,16 +1804,16 @@
},
{
"name": "yiisoft/yii2",
"version": "2.0.40",
"version": "2.0.41.1",
"source": {
"type": "git",
"url": "https://github.com/yiisoft/yii2-framework.git",
"reference": "debb520c1d72a2c97c09d70a2a2a4f600ef3958e"
"reference": "2ad0894a2ccbd3912b33de4419ad1ae3df0595c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/debb520c1d72a2c97c09d70a2a2a4f600ef3958e",
"reference": "debb520c1d72a2c97c09d70a2a2a4f600ef3958e",
"url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/2ad0894a2ccbd3912b33de4419ad1ae3df0595c4",
"reference": "2ad0894a2ccbd3912b33de4419ad1ae3df0595c4",
"shasum": ""
},
"require": {
@ -1921,7 +1921,7 @@
"type": "tidelift"
}
],
"time": "2020-12-23T15:44:43+00:00"
"time": "2021-03-04T15:45:04+00:00"
},
{
"name": "yiisoft/yii2-bootstrap",
@ -2343,16 +2343,16 @@
},
{
"name": "codeception/lib-innerbrowser",
"version": "1.4.0",
"version": "1.4.1",
"source": {
"type": "git",
"url": "https://github.com/Codeception/lib-innerbrowser.git",
"reference": "b7406c710684c255d9b067d7795269a5585a0406"
"reference": "693e116f81ef98eae98c43ef785a726faf87394e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/b7406c710684c255d9b067d7795269a5585a0406",
"reference": "b7406c710684c255d9b067d7795269a5585a0406",
"url": "https://api.github.com/repos/Codeception/lib-innerbrowser/zipball/693e116f81ef98eae98c43ef785a726faf87394e",
"reference": "693e116f81ef98eae98c43ef785a726faf87394e",
"shasum": ""
},
"require": {
@ -2397,9 +2397,9 @@
],
"support": {
"issues": "https://github.com/Codeception/lib-innerbrowser/issues",
"source": "https://github.com/Codeception/lib-innerbrowser/tree/1.4.0"
"source": "https://github.com/Codeception/lib-innerbrowser/tree/1.4.1"
},
"time": "2021-01-29T18:17:25+00:00"
"time": "2021-03-02T08:01:54+00:00"
},
{
"name": "codeception/module-asserts",
@ -3284,16 +3284,16 @@
},
{
"name": "php-webdriver/webdriver",
"version": "1.9.0",
"version": "1.10.0",
"source": {
"type": "git",
"url": "https://github.com/php-webdriver/php-webdriver.git",
"reference": "e3633154554605274cc9d59837f55a7427d72003"
"reference": "cd9290b95b7651d495bd69253d6e3ef469a7f211"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/e3633154554605274cc9d59837f55a7427d72003",
"reference": "e3633154554605274cc9d59837f55a7427d72003",
"url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/cd9290b95b7651d495bd69253d6e3ef469a7f211",
"reference": "cd9290b95b7651d495bd69253d6e3ef469a7f211",
"shasum": ""
},
"require": {
@ -3309,7 +3309,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
"ondram/ci-detector": "^2.1 || ^3.5",
"ondram/ci-detector": "^2.1 || ^3.5 || ^4.0",
"php-coveralls/php-coveralls": "^2.4",
"php-mock/php-mock-phpunit": "^1.1 || ^2.0",
"php-parallel-lint/php-parallel-lint": "^1.2",
@ -3349,9 +3349,9 @@
],
"support": {
"issues": "https://github.com/php-webdriver/php-webdriver/issues",
"source": "https://github.com/php-webdriver/php-webdriver/tree/1.9.0"
"source": "https://github.com/php-webdriver/php-webdriver/tree/1.10.0"
},
"time": "2020-11-19T15:21:05+00:00"
"time": "2021-02-25T13:38:09+00:00"
},
{
"name": "phpdocumentor/reflection-common",
@ -4042,27 +4042,22 @@
},
{
"name": "psr/container",
"version": "1.0.0",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/container.git",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f"
"reference": "8622567409010282b7aeebe4bb841fe98b58dcaf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f",
"url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf",
"reference": "8622567409010282b7aeebe4bb841fe98b58dcaf",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
"php": ">=7.2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Container\\": "src/"
@ -4075,7 +4070,7 @@
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common Container Interface (PHP FIG PSR-11)",
@ -4089,9 +4084,9 @@
],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/master"
"source": "https://github.com/php-fig/container/tree/1.1.1"
},
"time": "2017-02-14T16:28:37+00:00"
"time": "2021-03-05T17:36:06+00:00"
},
{
"name": "psr/event-dispatcher",
@ -5153,16 +5148,16 @@
},
{
"name": "symfony/browser-kit",
"version": "v5.2.3",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
"reference": "b03b2057ed53ee4eab2e8f372084d7722b7b8ffd"
"reference": "3ca3a57ce9860318b20a924fec5daf5c6db44d93"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/b03b2057ed53ee4eab2e8f372084d7722b7b8ffd",
"reference": "b03b2057ed53ee4eab2e8f372084d7722b7b8ffd",
"url": "https://api.github.com/repos/symfony/browser-kit/zipball/3ca3a57ce9860318b20a924fec5daf5c6db44d93",
"reference": "3ca3a57ce9860318b20a924fec5daf5c6db44d93",
"shasum": ""
},
"require": {
@ -5204,7 +5199,7 @@
"description": "Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/browser-kit/tree/v5.2.3"
"source": "https://github.com/symfony/browser-kit/tree/v5.2.4"
},
"funding": [
{
@ -5220,20 +5215,20 @@
"type": "tidelift"
}
],
"time": "2021-01-27T12:56:27+00:00"
"time": "2021-02-22T06:48:33+00:00"
},
{
"name": "symfony/console",
"version": "v5.2.3",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a"
"reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/89d4b176d12a2946a1ae4e34906a025b7b6b135a",
"reference": "89d4b176d12a2946a1ae4e34906a025b7b6b135a",
"url": "https://api.github.com/repos/symfony/console/zipball/d6d0cc30d8c0fda4e7b213c20509b0159a8f4556",
"reference": "d6d0cc30d8c0fda4e7b213c20509b0159a8f4556",
"shasum": ""
},
"require": {
@ -5301,7 +5296,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v5.2.3"
"source": "https://github.com/symfony/console/tree/v5.2.4"
},
"funding": [
{
@ -5317,11 +5312,11 @@
"type": "tidelift"
}
],
"time": "2021-01-28T22:06:19+00:00"
"time": "2021-02-23T10:08:49+00:00"
},
{
"name": "symfony/css-selector",
"version": "v5.2.3",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
@ -5366,7 +5361,7 @@
"description": "Converts CSS selectors to XPath expressions",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/css-selector/tree/v5.2.3"
"source": "https://github.com/symfony/css-selector/tree/v5.2.4"
},
"funding": [
{
@ -5453,16 +5448,16 @@
},
{
"name": "symfony/dom-crawler",
"version": "v5.2.3",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "5d89ceb53ec65e1973a555072fac8ed5ecad3384"
"reference": "400e265163f65aceee7e904ef532e15228de674b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/5d89ceb53ec65e1973a555072fac8ed5ecad3384",
"reference": "5d89ceb53ec65e1973a555072fac8ed5ecad3384",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/400e265163f65aceee7e904ef532e15228de674b",
"reference": "400e265163f65aceee7e904ef532e15228de674b",
"shasum": ""
},
"require": {
@ -5507,7 +5502,7 @@
"description": "Eases DOM navigation for HTML and XML documents",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/dom-crawler/tree/v5.2.3"
"source": "https://github.com/symfony/dom-crawler/tree/v5.2.4"
},
"funding": [
{
@ -5523,20 +5518,20 @@
"type": "tidelift"
}
],
"time": "2021-01-27T10:01:46+00:00"
"time": "2021-02-15T18:55:04+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v5.2.3",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "4f9760f8074978ad82e2ce854dff79a71fe45367"
"reference": "d08d6ec121a425897951900ab692b612a61d6240"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/4f9760f8074978ad82e2ce854dff79a71fe45367",
"reference": "4f9760f8074978ad82e2ce854dff79a71fe45367",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d08d6ec121a425897951900ab692b612a61d6240",
"reference": "d08d6ec121a425897951900ab692b612a61d6240",
"shasum": ""
},
"require": {
@ -5592,7 +5587,7 @@
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/event-dispatcher/tree/v5.2.3"
"source": "https://github.com/symfony/event-dispatcher/tree/v5.2.4"
},
"funding": [
{
@ -5608,7 +5603,7 @@
"type": "tidelift"
}
],
"time": "2021-01-27T10:36:42+00:00"
"time": "2021-02-18T17:12:37+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
@ -5691,16 +5686,16 @@
},
{
"name": "symfony/finder",
"version": "v5.2.3",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "4adc8d172d602008c204c2e16956f99257248e03"
"reference": "0d639a0943822626290d169965804f79400e6a04"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/4adc8d172d602008c204c2e16956f99257248e03",
"reference": "4adc8d172d602008c204c2e16956f99257248e03",
"url": "https://api.github.com/repos/symfony/finder/zipball/0d639a0943822626290d169965804f79400e6a04",
"reference": "0d639a0943822626290d169965804f79400e6a04",
"shasum": ""
},
"require": {
@ -5732,7 +5727,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v5.2.3"
"source": "https://github.com/symfony/finder/tree/v5.2.4"
},
"funding": [
{
@ -5748,7 +5743,7 @@
"type": "tidelift"
}
],
"time": "2021-01-28T22:06:19+00:00"
"time": "2021-02-15T18:55:04+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -6074,7 +6069,7 @@
},
{
"name": "symfony/process",
"version": "v5.2.3",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
@ -6116,7 +6111,7 @@
"description": "Executes commands in sub-processes",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/process/tree/v5.2.3"
"source": "https://github.com/symfony/process/tree/v5.2.4"
},
"funding": [
{
@ -6215,16 +6210,16 @@
},
{
"name": "symfony/string",
"version": "v5.2.3",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "c95468897f408dd0aca2ff582074423dd0455122"
"reference": "4e78d7d47061fa183639927ec40d607973699609"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/c95468897f408dd0aca2ff582074423dd0455122",
"reference": "c95468897f408dd0aca2ff582074423dd0455122",
"url": "https://api.github.com/repos/symfony/string/zipball/4e78d7d47061fa183639927ec40d607973699609",
"reference": "4e78d7d47061fa183639927ec40d607973699609",
"shasum": ""
},
"require": {
@ -6278,7 +6273,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v5.2.3"
"source": "https://github.com/symfony/string/tree/v5.2.4"
},
"funding": [
{
@ -6294,20 +6289,20 @@
"type": "tidelift"
}
],
"time": "2021-01-25T15:14:59+00:00"
"time": "2021-02-16T10:20:28+00:00"
},
{
"name": "symfony/yaml",
"version": "v5.2.3",
"version": "v5.2.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "338cddc6d74929f6adf19ca5682ac4b8e109cdb0"
"reference": "7d6ae0cce3c33965af681a4355f1c4de326ed277"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/338cddc6d74929f6adf19ca5682ac4b8e109cdb0",
"reference": "338cddc6d74929f6adf19ca5682ac4b8e109cdb0",
"url": "https://api.github.com/repos/symfony/yaml/zipball/7d6ae0cce3c33965af681a4355f1c4de326ed277",
"reference": "7d6ae0cce3c33965af681a4355f1c4de326ed277",
"shasum": ""
},
"require": {
@ -6353,7 +6348,7 @@
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/yaml/tree/v5.2.3"
"source": "https://github.com/symfony/yaml/tree/v5.2.4"
},
"funding": [
{
@ -6369,7 +6364,7 @@
"type": "tidelift"
}
],
"time": "2021-02-03T04:42:09+00:00"
"time": "2021-02-22T15:48:39+00:00"
},
{
"name": "theseer/tokenizer",

View File

@ -4,14 +4,12 @@ declare(strict_types=1);
namespace app\controllers;
use app\models\AccountEdgeNotification;
use yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\Response;
use app\models\Order;
use app\models\AccountEdgeOrder;
use Exception;
@ -40,72 +38,40 @@ class CartController extends Controller
*/
public function actionIndex(): string|array|null
{
// Инициализация настроек страницы
$page = yii::$app->request->get('page') ?? 1;
// Инициализация
$page = yii::$app->request->get('page') ?? yii::$app->request->post('page') ?? 1;
$account = yii::$app->user;
// Инициализация корзина
// Поиск корзины (текущего заказа)
$model = Order::search();
if (empty($model)) {
// Корзина не инициализирована
// Инициализация
$model = new Order();
$model->save() or throw new Exception('Не удалось инициализировать заказ');
// Подключение
$model->connect($account);
}
// Инициализация содержимого корзины
$supplies = $model->content(10, $page);
// Инициализация реестра дубликатов
$registry = [];
// Подсчёт и перестройка массива
foreach ($supplies as $key => &$supply) {
// Перебор поставок
if (in_array($supply->catn, $registry)) {
// Если данная поставка найдена в реестре
// Удаление
unset($supplies[$key]);
// Пропуск итерации
continue;
}
$amount = 0;
// Повторный перебор для поиска дубликатов
foreach ($supplies as &$supply4check) {
if ($supply == $supply4check) {
// Найден дубликат
// Постинкрементация счётчика
$amount++;
// Запись в реестр
$registry []= $supply4check->catn;
}
}
// Запись количества
$supply->amnt = $amount;
}
// Инициализация возврата по умолчанию
$return = [
'_csrf' => yii::$app->request->getCsrfToken()
];
if (yii::$app->request->isPost) {
// POST-запрос
yii::$app->response->format = Response::FORMAT_JSON;
$return = array_merge($return, [
return [
'main' => $this->renderPartial('index', compact('model', 'supplies')),
'title' => 'Корзина',
'redirect' => '/cart'
]);
} else {
// GET-запрос (подразумевается)
'redirect' => '/cart',
'_csrf' => yii::$app->request->getCsrfToken()
];
}
return $this->render('index', compact('model', 'supplies'));
}
return $return;
}
}

View File

@ -81,7 +81,7 @@ class NotificationController extends Controller
$type = 'checked';
}
// Генерация подзапроса по перебору ядра
// Генерация
$let = $let->createCommand();
/**
@ -134,7 +134,7 @@ class NotificationController extends Controller
if (empty($notifications)) {
// Уведомления не найдены
yii::$app->response->statusCode = 100;
yii::$app->response->statusCode = 404;
goto end;
}

View File

@ -10,9 +10,10 @@ use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\Response;
use app\models\Supply;
use app\models\Order;
use app\models\AccountEdgeOrder;
use app\models\OrderEdgeSupply;
use Exception;
class OrderController extends Controller
@ -35,10 +36,30 @@ class OrderController extends Controller
public function actionIndex()
{
// Инициализация
$orders = Order::search(type: 'all', limit: 10, page: 1, select: '{account_edge_order, order}');
if (yii::$app->request->isPost) {
// POST-запрос
yii::$app->response->format = Response::FORMAT_JSON;
return [
'main' => $this->renderPartial('/orders/index', compact('orders')),
'title' => 'Заказы',
'redirect' => '/orders',
'_csrf' => yii::$app->request->getCsrfToken()
];
}
public function actionWrite(): string|array|null {
return $this->render('/orders/index', compact('orders'));
}
/**
* Запись
*/
public function actionWrite(): string|array|null
{
if (yii::$app->request->isPost) {
// POST-запрос
@ -68,7 +89,7 @@ class OrderController extends Controller
$model = new Order();
$model->save() or throw new Exception('Не удалось инициализировать заказ');
// Запись в аккаунт
// Запись ребра: АККАУНТ -> ЗАКАЗ
AccountEdgeOrder::write($account->id, $model->readId(), 'current') or $model->addError('errors', 'Не удалось инициализировать ребро: АККАУНТ -> ЗАКАЗ');
}
@ -91,4 +112,96 @@ class OrderController extends Controller
return null;
}
/**
* Удаление
*/
public function actionDelete(): string|array|null
{
// Инициализация
$targets = yii::$app->request->post('targets') ?? yii::$app->request->get('targets');
$page = yii::$app->request->get('page') ?? yii::$app->request->post('page') ?? 1;
$account = yii::$app->user;
if ($targets) {
// Удаление выбранных целей (удаление из заказа)
foreach ($targets as $target) {
// Инициализация
$model = Order::search();
// Удаление
$model->deleteEdge($target);
}
} else {
// Целью подразумевается сам заказ (удаление заказа)
// Инициализация корзины (текущего заказа)
$model = Order::search();
// Поиск
$edge = AccountEdgeOrder::searchByVertex($account->id, $model->readId(), 'current');
// Запись
$edge->type = 'reserved';
// Отправка
$edge->update();
}
// Инициализация содержимого корзины
$supplies = $model->content(10, $page);
if (yii::$app->request->isPost) {
// POST-запрос
yii::$app->response->format = Response::FORMAT_JSON;
return [
'main' => $this->renderPartial('/cart/index', compact('model', 'supplies')),
'title' => 'Корзина',
'redirect' => '/cart',
'_csrf' => yii::$app->request->getCsrfToken()
];
}
return $this->render('/cart/index', compact('model', 'supplies'));
}
/**
* Оплата
*/
public function actionPay(): string|array|null
{
// Инициализация
$model = Order::search();
// Поиск ребра
$edge = AccountEdgeOrder::searchByVertex(yii::$app->user->id, $model->readId(), 'current');
// Запись
$edge->type = 'accepted';
// Отправка изменений
$edge->update();
// Инициализация
$orders = Order::search(type: 'all', limit: 10, page: 1, select: '{account_edge_order, order}');
if (yii::$app->request->isPost) {
// POST-запрос
yii::$app->response->format = Response::FORMAT_JSON;
return [
'main' => $this->renderPartial('/orders/index', compact('orders')),
'title' => 'Заказы',
'redirect' => '/orders',
'_csrf' => yii::$app->request->getCsrfToken()
];
}
return $this->render('/orders/index', compact('orders'));
}
}

View File

@ -265,7 +265,19 @@ class ProfileController extends Controller
// Генерация
$sidebar = $this->renderPartial('sidebar');
$search_history = Search::searchByAccount(yii::$app->user->id, $rows_amount, ((int) $page_search_history ?? 0) * $rows_amount);
$search_history = Search::SearchByEdge(
from: 'account',
to: 'search',
subquery_where: [
[
'account._id' => yii::$app->user->id
]
],
foreach: ['edge' => 'account_edge_search'],
where: 'edge._to == search._id',
limit: $rows_amount,
offset: ((int) $page_search_history ?? 0) * $rows_amount
);
if (yii::$app->request->isPost) {
// AJAX-POST-запрос

View File

@ -60,8 +60,8 @@ class SearchController extends Controller
$timer = 0;
// Период пропуска запросов (в секундах)
$period = 1;
$keep_connect = true;
$period = 5;
$keep_connect = false;
$sanction = false;
$sanction_condition = ($session['last_request'] + $period - time()) < $period;
$sanction_time = 2;

View File

@ -87,7 +87,7 @@ abstract class Edge extends Document
*/
public static function writeSafe(string $_from, string $_to, string $type = '', array $data = []): ?static
{
if ($edge = self::searchByVertex($_from, $_to, 1)) {
if ($edge = self::searchByVertex($_from, $_to, limit: 1)) {
// Найдено в базе данных
return $edge;
@ -128,11 +128,29 @@ abstract class Edge extends Document
/**
* Поиск ребра по его вершинам
*/
public static function searchByVertex(string $_from, string $_to, int $limit = 1): static|array|null
public static function searchByVertex(string $_from, string $_to, string $type = '', int $limit = 1): static|array|null
{
$query = self::find()->where(['_from' => $_from, '_to' => $_to]);
$query = self::find()->where(['_from' => $_from, '_to' => $_to, 'type' => $type]);
if ($limit <= 1) {
if ($limit < 2) {
return $query->one();
} else {
return $query->limit($limit)->all();
}
}
/**
* Поиск рёбер
*/
public static function search(string $target, string $direction = 'OUTBOUND', string $type = '', int $limit = 1): static|array|null
{
if ($direction === 'OUTBOUND') {
$query = self::find()->where(['_from' => $target, 'type' => $type]);
} else if ($direction === 'INBOUND') {
$query = self::find()->where(['_to' => $target, 'type' => $type]);
}
if ($limit < 2) {
return $query->one();
} else {
return $query->limit($limit)->all();

View File

@ -83,7 +83,7 @@ class Order extends Document
$trgt ?? $trgt = yii::$app->user ?? throw new Exception('Не удалось инициализировать заказчика');
if ($supply instanceof Supply) {
// Передана инстанция класса поставки
// Передана инстанция класса поставки или второй элемент массива не является числом
// Унификация входных данных
$supply = [$supply, 1];
@ -107,15 +107,15 @@ class Order extends Document
}
}
foreach ($supply as $supply_raw) {
foreach (is_array($supply[0]) ? $supply : [$supply] as $supply_raw) {
// Перебор поставок
for ($i = 0; $i < $supply_raw[1]; $i++) {
// Создание рёбер соразмерно запросу (добавление нескольких продуктов в корзину)
// Инициализация ребра: ЗАКАЗ -> ПОСТАВКА
if (!$supply = Supply::searchByCatn($supply_raw[0]) or !OrderEdgeSupply::write($this->readId(), $supply->readId(), 'add')) {
// Поставка не найдена или инициализация ребра не удалась
// Запись ребра: ЗАКАЗ -> ПОСТАВКА
if (!$supply = Supply::searchByCatn($supply_raw[0]) or !OrderEdgeSupply::write($this->readId(), $supply->readId(), 'write')) {
// Поставка не найдена или запись ребра не удалась
continue;
}
@ -126,13 +126,44 @@ class Order extends Document
return $this->save() ? $this : null;
}
/**
* Подключение к аккаунту
*/
public function connect(Account $account): ?AccountEdgeOrder {
// Запись ребра: АККАУНТ -> ЗАКАЗ
return AccountEdgeOrder::write($account->id, $this->readId(), 'current') ?? throw new Exception('Не удалось инициализировать ребро: АККАУНТ -> ЗАКАЗ');
}
/**
* Удаление
*/
public function deleteEdge(string|array $catn): ?OrderEdgeSupply
{
// Запись ребра: ЗАКАЗ -> ПОСТАВКА
return OrderEdgeSupply::write($this->readId(), Supply::searchByCatn($catn)->readId(), 'delete');
}
/**
* Поиск заказа
*/
public static function search(Account $account = null, string $type = 'current', int $limit = 1): self|array
public static function search(Account $account = null, string $type = 'current', int $limit = 1, int $page = 1, string $select = null): self|array|null
{
// Инициализация
$account or $account = yii::$app->user ?? throw new Exception('Не удалось инициализировать пользователя');
// Генерация сдвига по запрашиваемым данным (пагинация)
$offset = $limit * ($page - 1);
if (strcasecmp($type, 'all') !== 0) {
// Если не указан параметр поиска всех заказов
$where_type = [
'account_edge_order.type' => $type
];
} else {
$where_type = [];
}
$return = self::searchByEdge(
from: 'account',
to: 'order',
@ -140,16 +171,18 @@ class Order extends Document
[
'account._id' => $account->id
],
[
'account_edge_order.type' => $type
]
$where_type
],
foreach: ['edge' => 'account_edge_order'],
where: 'edge._to == order._id',
limit: $limit,
offset: $offset,
sort: ['DESC'],
select: $select,
direction: 'INBOUND'
);
return $limit === 1 ? $return[0] : $return;
return $limit === 1 ? $return[0] ?? null : $return;
}
/**
@ -157,13 +190,33 @@ class Order extends Document
*
* @todo В будущем возможно заказ не только поставок реализовать
*/
public function content(int $limit = 1, int $page = 1): Supply|array
public function content(int $limit = 1, int $page = 1): Supply|array|null
{
// Генерация сдвига по запрашиваемым данным (пагинация)
$offset = $limit * ($page - 1);
// Подзапрос для проверки статуса уведомления относительно пользователя
// Поиск рёбер: ПОЛЬЗОВАТЕЛЬ -> УВЕДОМЛЕНИЕ
$let = Supply::find()
->for(['order', 'order_edge_supply_deleted'])
->traversal('supply', 'INBOUND')
->in('order_edge_supply')
->where([
[
'order._id' => $this->readId()
],
[
'order_edge_supply_deleted.type' => 'delete'
]
])
->select('order_edge_supply_deleted');
// Генерация
$let = $let->createCommand();
// Поиск рёбер: ЗАКАЗ -> ПОСТАВКА
$return = Supply::searchByEdge(
$supplies = Supply::searchByEdge(
from: 'order',
to: 'supply',
edge: 'order_edge_supply',
@ -172,15 +225,80 @@ class Order extends Document
'order._id' => $this->readId()
],
[
'order_edge_supply.type' => 'add'
'order_edge_supply.type' => 'write'
]
],
params: $let->getBindVars(),
let: [
'order_edge_supply_deleted',
'(' . (string) $let . ')'
],
foreach: ['edge' => 'order_edge_supply'],
where: 'edge._to == supply._id',
where: 'edge._to == supply._id && edge._to != order_edge_supply_deleted[0]._to',
limit: $limit,
offset: $offset
offset: $offset,
direction: 'INBOUND'
);
return $limit === 1 ? $return[0] : $return;
// Инициализация реестра дубликатов
$registry = [];
// Подсчёт и перестройка массива для очистки от дубликатов
foreach ($supplies as $key => &$supply) {
// Перебор поставок
if (in_array($supply->catn, $registry)) {
// Если данная поставка найдена в реестре
// Удаление
unset($supplies[$key]);
// Пропуск итерации
continue;
}
$amount = 0;
// Повторный перебор для поиска дубликатов
foreach ($supplies as &$supply4check) {
if ($supply == $supply4check) {
// Найден дубликат
// Постинкрементация счётчика
$amount++;
// Запись в реестр
$registry[] = $supply4check->catn;
}
}
// Запись количества для заказа
$supply->amnt = $amount;
}
// Поиск стоимости для каждой поставки
foreach ($supplies as $key => &$supply) {
// Перебор поставок
// Чтение стоимости
$cost = $supply->readCost();
if ($cost < 1) {
// Если стоимость равна нулю (явная ошибка)
$this->deleteEdge($supply->readId());
// Удаление
unset($supplies[$key]);
// Пропуск итерации
continue;
}
// Запись цены
$supply->cost = $cost['ЦенаЗаЕдиницу'] . ' ' . $cost['Валюта'];
}
return $supplies;
}
}

View File

@ -432,4 +432,16 @@ class Supply extends Product implements ProductInterface
{
return [];
}
/**
* Прочитать стоимость
*/
public function readCost(Product $product = null): array
{
if (isset($product)) {
return SupplyEdgeProduct::searchByVertex($this->readId(), $product->readId(), type: 'connect', limit: 1)['onec']['Цены']['Цена'];
}
return SupplyEdgeProduct::search($this->readId(), type: 'connect', limit: 1)['onec']['Цены']['Цена'];
}
}

View File

@ -32,9 +32,10 @@ trait SearchByEdge
array $let = [],
string|array $select = null,
callable $handle = null,
array &$params = []
array $params = []
): ?array {
$subquery = static::find()
->params($params)
->for([$from, $edge ?? $from . '_edge_' . $to])
->traversal($to, $direction)
->in($edge ?? $from . '_edge_' . $to)
@ -44,7 +45,7 @@ trait SearchByEdge
->createCommand();
$query = static::find()
->params($params, $subquery->getBindVars())
->params($subquery->getBindVars())
->let($edge ?? $from . '_edge_' . $to, '(' . (string) $subquery . ')')
->limit($limit)
->offset($offset)

View File

@ -8,10 +8,10 @@ if (!yii::$app->user->isGuest) {
$popup = yii::$app->controller->renderPartial('/notification/panel');
echo <<<HTML
<a id="notification_button" class="text-dark d-flex h-100 mr-2" title="Уведомления" href="/notification" role="button" data-toggle="dropdown" data-offset="-100%p + 100%" onclick="return notification_stream();">
<a id="notification_button" class="text-dark d-flex h-100 mr-2" title="Уведомления" role="button" data-toggle="dropdown" data-offset="-100%p + 100%" onclick="return notification_stream();">
<i class="fas fa-bell my-auto mx-2"></i>
</a>
<div id="notification_button_panel" class="dropdown-menu py-1" aria-labelledby="notification_button">
<div id="notification_button_panel" class="dropdown-menu p-2" aria-labelledby="notification_button">
$popup
</div>
HTML;

View File

@ -1,56 +1,83 @@
<link href="/css/pages/cart.css" rel="stylesheet">
<div id="page_cart" class="container h-100">
<article class="my-3 p-3 h-100">
<h4 class="ml-4 mt-3 mb-4"><i class="fas fa-shopping-cart mr-2"></i>Корзина</h4>
<div class="col list">
<div id="page_cart" class="container py-3">
<article class="py-3 px-4 rounded">
<h4 class="ml-4 mt-2 mb-4"><i class="fas fa-shopping-cart mr-2"></i>Корзина</h4>
<div class="col mb-4 list rounded overflow-hidden">
<div class="row py-2">
<div class="col-1">
<input id="checkbox_cart_all" type="checkbox"/>
<div class="pl-3 mr-1">
<input id="checkbox_cart_all" type="checkbox" onchange="return cart_list_checkbox(this);"/>
</div>
<div class="col">
<div class="col-2">
<span>Артикул</span>
</div>
<div class="col">
<div class="col-3">
<span>Описание</span>
</div>
<div class="col">
<div class="col-2 ml-auto text-center">
<span>Количество</span>
</div>
<div class="col">
<div class="col-2 text-right">
<span>Доставка</span>
</div>
<div class="col">
<span>Стоимость </span>
<div class="col-2 mr-3 text-right">
<span>Стоимость</span>
</div>
</div>
<?php
if (isset($supplies) && !empty($supplies)) {
foreach ($supplies as $supply) {
echo <<<HTML
<div class="row py-2">
<div class="col-1">
<input id="checkbox_cart_$supply->catn" type="checkbox"/>
<div class="row py-2 cart_list_target">
<div class="pl-3 mr-1">
<input id="checkbox_cart_$supply->catn" type="checkbox" onchange="return cart_list_checkbox(this);"/>
</div>
<div class="col">
<div class="col-2">
$supply->catn
</div>
<div class="col">
<div class="col-3">
$supply->desc
</div>
<div class="col">
<div class="col-2 ml-auto text-center">
$supply->amnt
</div>
<div class="col">
<div class="col-2 text-right">
$supply->time
</div>
<div class="col">
<div class="col-2 mr-3 text-right">
$supply->cost
</div>
</div>
HTML;
}
} else {
echo <<<HTML
<div class="row py-2 cart_list_target">
<div class="mx-auto py-2">
Корзина пуста
</div>
</div>
HTML;
}
?>
</div>
<div class="row mb-2 mx-0">
<select id="cart_list_action" class="form-control mr-3 button_clean w-auto" name="CartListAction">
<option value="none" hidden>Действие с выбранными</option>
<option value="delete" onclick="return cart_list_delete();">Удалить</option>
</select>
<a class="mr-3 btn button_red button_clean" title="Очистить корзину" href="/cart" role="button" onclick="return cart_delete();">
Очистить
</a>
<p class="ml-auto mr-3 cart_field_cost">
<span id="cart_cost">0</span>
руб
</p>
<a class="btn button_clean button_blue" title="Оформить заказ" href="/pay" role="button" onclick="return cart_pay();">
Оформить заказ
</a>
</div>
</article>
</div>
<script src="/js/cart.js" defer></script>

View File

@ -1,7 +1,7 @@
<?php
if (empty($notifications)) {
echo <<<HTML
<p class="px-2 py-3 text-center">Уведомлений нет</p>
<p class="px-2 py-4 text-center">Уведомлений нет</p>
HTML;
return;

View File

@ -0,0 +1,63 @@
<link href="/css/pages/orders.css" rel="stylesheet">
<div id="page_orders" class="container py-3">
<article class="py-3 px-4 rounded">
<h4 class="ml-4 mt-2 mb-4"><i class="fas fa-list mr-2"></i>Заказы</h4>
<div class="col mb-4 list rounded overflow-hidden">
<div class="row py-2">
<div class="pl-3 mr-1">
<input id="checkbox_cart_all" type="checkbox" onchange="return cart_list_checkbox(this);" />
</div>
<div class="col-2 ml-auto">
<span>Статус</span>
</div>
<div class="col-2 mr-3 text-right">
<span>Время</span>
</div>
</div>
<?php
if (isset($orders) && !empty($orders)) {
foreach ($orders as $order) {
// Перебор заказов
// Инициализация
extract($order);
$date = date('d.m.Y', $order['date']);
echo <<<HTML
<div class="row py-2 cart_list_target">
<div class="pl-3 mr-1">
<input type="checkbox" onchange="return cart_list_checkbox(this);"/>
</div>
<div class="col-2 ml-auto">
{$account_edge_order[0]['type']}
</div>
<div class="col-2 mr-3 text-right">
$date
</div>
</div>
HTML;
}
} else {
echo <<<HTML
<div class="row py-2 cart_list_target">
<div class="mx-auto py-2">
Заказов нет
</div>
</div>
HTML;
}
?>
</div>
<div class="row mb-2 mx-0">
<select id="cart_list_action" class="form-control mr-3 button_clean w-auto" name="CartListAction">
<option value="none" hidden>Действие с выбранными</option>
<option value="delete" onclick="return cart_list_delete();">Удалить</option>
</select>
</div>
</article>
</div>
<script src="/js/orders.js" defer></script>

View File

@ -8,8 +8,7 @@ use app\models\Product;
?>
<link href="/css/pages/product.css" rel="stylesheet">
<div id="page_product" class="h-100">
<!-- <div class="container h-100"> -->
<div id="page_product" class="container h-100">
<div class="row h-100 py-3">
<article class="col-12">
<div class="h-100 p-3 d-flex flex-column rounded">
@ -126,5 +125,4 @@ use app\models\Product;
</div>
</article>
</div>
<!-- </div> -->
</div>

View File

@ -56,10 +56,11 @@ use app\models\Supply;
*/
// Инициализация
isset($model) or $model = yii::$app->user->identity;
isset($supplies) or $supplies = Supply::searchByAccount(select: 'supply.onec["ЗначенияСвойств"]');
$model ?? $model = yii::$app->user->identity;
$supplies ?? $supplies = Supply::searchByAccount(select: 'supply.onec["ЗначенияСвойств"]');
$list = [];
// Перебор свойств поставок
foreach ($supplies as $supply) {
// Инициализация
@ -72,7 +73,7 @@ use app\models\Supply;
}
// Генерация
$list[$id] = $supply['ЗначенияСвойства']['Наименование'];
!isset($supply['ЗначенияСвойства']['Наименование']) or $list[$id] = $supply['ЗначенияСвойства']['Наименование'];
}
// Инициализация текущего значения параметра в начале массива

View File

@ -39,17 +39,36 @@
// Инициализация артикула
$catn = $supply['catn'] ?? $supply['onec']['Артикул'];
// Инициализация количества
$amount = $supply['amnt'] ?? $supply['onec']['Количество'];
// Инициализация цены
$price_raw = $supply['prce'] ?? $supply['onec']['Цены']['Цена']['ЦенаЗаЕдиницу'];
$price = $price_raw . ' ' . $supply['onec']['Цены']['Цена']['Валюта'];
if (empty($amount) || $amount < 1) {
// Инициализация количества
$amount_raw = $amount = $supply['amnt'] ?? $supply['onec']['Количество'];
if (empty($amount_raw) || $amount_raw < 1) {
$amount = 'Под заказ';
} else {
$amount .= ' шт';
}
// Инициализация цена
$price = $supply['prce'] ?? $supply['onec']['Цены']['Цена']['ЦенаЗаЕдиницу'] . ' ' . $supply['onec']['Цены']['Цена']['Валюта'];
if ($amount_raw < 1 || $price_raw < 1) {
// Нет в наличии или цена 0 рублей
$button_cart = <<<HTML
<div class="col-1 h-100 text-dark d-flex" title="Товар недоступен">
</div>
HTML;
} else {
$button_cart = <<<HTML
<a class="col-1 h-100 text-dark d-flex" title="Добавить $catn в корзину" href="/cart" role="button" onclick="return cart_write('$catn');">
<i class="fas fa-cart-arrow-down my-auto"></i>
</a>
HTML;
}
$supplies_html .= <<<HTML
<div class="row my-auto m-0 h-100 text-right">
@ -62,9 +81,7 @@
<b class="col-2 my-auto">
$price
</b>
<a class="col-1 h-100 text-dark d-flex" title="Добавить $catn в корзину" href="/cart" role="button" onclick="return cart_write('$catn');">
<i class="fas fa-cart-arrow-down my-auto"></i>
</a>
$button_cart
</div>
HTML;
}

View File

@ -104,13 +104,13 @@ main {
.button_red {
color : #eee;
background-color: #ab1212;
background-color: #c40000;
transition : 0s;
}
.button_red:hover {
color : #fff;
background-color: #b52424;
background-color: #d81313;
transition : 0s;
}

View File

@ -15,5 +15,13 @@
#notification_button_panel {
z-index: 2500;
min-width: 250px;
min-width: 300px;
}
#notification_button_panel :first-child {
margin-top: 0 !important;
}
#notification_button_panel :last-child {
margin-bottom: 0 !important;
}

View File

@ -3,9 +3,14 @@
}
#page_cart article .list .row:nth-child(2n+1) {
background-color: #f5f2fa;
background-color: #f7f6f9;
}
#page_cart article .list .row:first-child {
background-color: #edeaf2;
background-color: #dbdde3;
}
#page_cart .cart_field_cost span {
font-weight: bold;
font-size: larger;
}

View File

@ -0,0 +1,16 @@
#page_orders article {
background-color: #fff;
}
#page_orders article .list .row:nth-child(2n+1) {
background-color: #f7f6f9;
}
#page_orders article .list .row:first-child {
background-color: #dbdde3;
}
#page_orders .cart_field_cost span {
font-weight: bold;
font-size: larger;
}

View File

@ -17,6 +17,111 @@ function cart_write(catn, amount = 1) {
return false;
}
function cart_delete() {
$.ajax({
url: '/order/delete',
type: 'post',
dataType: 'json',
data: {
'_csrf': yii.getCsrfToken()
},
success: cart_success,
error: cart_error
});
return false;
}
function cart_pay() {
$.ajax({
url: '/order/pay',
type: 'post',
dataType: 'json',
data: {
'_csrf': yii.getCsrfToken()
},
success: cart_success,
error: cart_error
});
return false;
}
function cart_list_checkbox(target) {
// Инициализация
let elements = document.getElementsByClassName('cart_list_target');
let reg = /^\w+_([^_]*)$/;
let catn = reg.exec(target.id)[1];
if (catn === 'all') {
if (target.checked === true) {
for ($i = 0; $i < elements.length; $i++) {
elements[$i].getElementsByTagName('input')[0].checked = true;
}
target.checked = true;
} else {
for ($i = 0; $i < elements.length; $i++) {
elements[$i].getElementsByTagName('input')[0].checked = false;
}
target.checked = false;
}
return false;
}
}
function cart_list_delete(dropdown) {
// Инициализация
let elements = document.getElementsByClassName('cart_list_target');
let reg = /^\w+_([^_]*)$/;
let targets = [];
for ($i = 0; $i < elements.length; $i++) {
let checkbox = elements[$i].getElementsByTagName('input')[0];
if (checkbox.checked === true) {
targets.push(reg.exec(checkbox.id)[1]);
}
}
$.ajax({
url: '/order/delete',
type: 'post',
dataType: 'json',
data: {
'_csrf': yii.getCsrfToken(),
'targets': targets
},
success: cart_success,
error: cart_error
});
document.getElementById('cart_list_action').value = 'none';
// Подсчитывание стоимости
cart_cost_calculate();
return false;
}
function cart_cost_calculate() {
let elements = document.getElementsByClassName('cart_list_target');
let reg = /^([0-9]*)\s*\w*/;
let costs = 0;
for ($i = 0; $i < elements.length; $i++) {
let cost = elements[$i].getElementsByTagName('div')[5];
costs += +reg.exec(cost.innerText)[1];
}
document.getElementById('cart_cost').innerHTML = costs;
}
cart_cost_calculate();
function cart_success(data, status) {
// Обработка ответов от удавшихся запросов

View File

@ -49,6 +49,23 @@ function page_cart() {
return false;
};
function page_orders() {
if (document.getElementById('page_orders') === null) {
url = '/orders'
$.ajax({
url: url,
type: 'post',
dataType: 'json',
data: { '_csrf': yii.getCsrfToken() },
success: menu_success,
error: menu_error
});
}
return false;
};
function notifications() {
return false;

View File

@ -3,17 +3,22 @@ function tickerInit(target) {
target = $('.ticker');
}
if (target.length > 0) {
target.bxSlider({
ticker: true,
speed: 80000
});
// Добавить ещё логотипов под широкие окна
if ($(window).width() > 1280 && target.getSlideCount() <= 15) {
tickerInit();
}
}
// if (target.length > 0) {
// target.bxSlider({
// ticker: true,
// speed: 80000
// });
// // Добавить ещё логотипов под широкие окна
// if ($(window).width() > 1280 && target.getSlideCount() <= 15) {
// tickerInit();
// }
// }
};
document.addEventListener('DOMContentLoaded', tickerInit(), true);