]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Форма загрузки
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 23 Apr 2025 16:05:55 +0000 (19:05 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 23 Apr 2025 16:05:55 +0000 (19:05 +0300)
12 files changed:
erp24/composer.json
erp24/media/config/media.config.php
erp24/media/controllers/MarketplaceController.php
erp24/media/index.php
erp24/media/views/layouts/_____main.php [new file with mode: 0644]
erp24/media/views/layouts/api2_menu.php [new file with mode: 0644]
erp24/media/views/layouts/footer.php [new file with mode: 0755]
erp24/media/views/layouts/header.php [new file with mode: 0755]
erp24/media/views/layouts/main.php [new file with mode: 0755]
erp24/media/views/layouts/menu.php [new file with mode: 0755]
erp24/media/views/marketplace/upload.php [new file with mode: 0644]
erp24/views/marketplace-orders/view.php

index 3ebdc3168878dc4c014c23b9ab8b6557e7c46a15..a5ef737e0ccc3f99cd6fda7c0f2a04530c5baff2 100644 (file)
         "squizlabs/php_codesniffer": "@stable"
     },
     "autoload": {
-        "psr-4": { "yii_app\\": "", "OpenAPI\\Client\\" : "lib/yandex_market_api/" }
+        "psr-4": {
+            "app\\": "",
+            "yii_app\\": "",
+            "OpenAPI\\Client\\" : "lib/yandex_market_api/"
+        }
     },
     "config": {
         "allow-plugins": {
index cdc2700ffff627a5f555898c585f7f96b388bfae..74448dac62fe74554317a2cf7a45e1c064dbab6d 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use app\models\User;
 use yii\queue\amqp_interop\Queue;
 
 return [
@@ -10,8 +11,8 @@ return [
     'components' => [
         'assetManager' => [
             'appendTimestamp' => true,
-            'basePath' => '@webroot/cache/assets',
-            'baseUrl' => '@web/cache/assets',
+            'basePath' => '@webroot/assets',
+            'baseUrl' => '@web/assets',
         ],
         'formatter' => [    // fallback if no ext-intl php extension
             'timeZone' => 'Europe/Moscow',
@@ -30,6 +31,8 @@ return [
                 'GET media/view-image/<id:\d+>' => 'media/view-image',
                 'flowwow/feed/<id:\d+>' => 'flowwow/feed',
                 'marketplace/upload-photo/<id:\d+>' => 'marketplace/upload-photo',
+                'marketplace/upload' => 'marketplace/upload',
+
             ],
         ],
         'request' => [
@@ -61,7 +64,8 @@ return [
             'exchangeName' => 'telegram-exchange',
         ],
         'user' => [
-            'identityClass' => \yii\web\IdentityInterface::class,
+            'identityClass' => \yii_app\records\Admin::class,
+            'enableAutoLogin' => false,
         ],
         'db' => require __DIR__ . '/../../config/db.php',
         'log' => [
@@ -76,7 +80,12 @@ return [
                         'yii\web\HttpException:403',
                         'yii\web\HttpException:401',
                     ],
-                ]
+                ],
+                [
+                    'class' => 'app\log\TelegramTarget',
+                    'levels' => ['error', 'warning'],
+                    // 'categories' => ['api.error', 'js.error', 'command.error'],
+                ],
             ],
         ],
         'cache' => [
@@ -87,7 +96,9 @@ return [
         '@bower' => '@vendor/bower-asset',
         '@npm' => '@vendor/npm-asset',
         '@dist' => '@app/dist',
-        '@uploads' => "@app/uploads",
+        '@uploads' => "@yii_app/uploads",
+
+
     ],
     'params' => require dirname(__DIR__, 2) . '/config/params.php',
     'timeZone' => 'Europe/Moscow',
index a8469c9789841786c894524b3d8afeb34960bf36..388ea99bd621152d0175140f440c3657555cd303 100644 (file)
@@ -31,6 +31,7 @@ class MarketplaceController extends Controller
                 $targetFile = $uploads . $target_dir. "/" . $file->baseName . '.' . $file->extension;
                 Yii::warning('Saved file: ' . json_encode($targetFile, JSON_UNESCAPED_UNICODE));
                 $file->saveAs($targetFile);
+                Files::deleteAll(['file_type' => $type, 'entity_id' => $order->id, 'entity' => $entity]);
                 $fileRecord = new Files;
                 $fileRecord->created_at = date("Y-m-d H:i:s", time() + 1);
                 $fileRecord->entity_id = $order->id;
@@ -56,4 +57,63 @@ class MarketplaceController extends Controller
         }
 
     }
+
+    public function actionUpload()
+    {
+        Yii::$app->response->format = Response::FORMAT_HTML;
+        $guid = Yii::$app->request->get('guid') ?? Yii::$app->request->post('guid');
+        //var_dump($guid); die();
+        if (!$guid) {
+            return $this->redirect(['/']);
+        }
+        $entity = MarketplaceOrders::PHOTO_ORDER;
+        $type = MarketplaceOrders::PHOTO_TYPE;
+        $order = MarketplaceOrders::find()->where(['guid' => $guid])->one();
+       // var_dump($order); die();
+        if (!$order) {
+            throw new \yii\web\NotFoundHttpException("Заказ не найден.");
+        }
+        if (Yii::$app->request->isPost) {
+            Yii::error('Ошибка' );
+            $files = UploadedFile::getInstancesByName('files');
+            Files::deleteAll(['entity_id' => $order->id, 'entity' => $entity]);
+            $uploads = Yii::getAlias("@uploads");
+            $target_dir = '/' . $order->id . '/' . date("Y") . "/" . date("m") . "/" . date("d") . "/";
+
+            foreach ($files as $file) {
+                $filePath = $uploads . $target_dir;
+                if (!is_dir($filePath)) {
+                    mkdir($filePath, 0777, true);
+                }
+                $targetFile = $filePath . $file->baseName . '.' . $file->extension;
+                $file->saveAs($targetFile);
+
+                $fileRecord = new Files();
+                $fileRecord->created_at = date("Y-m-d H:i:s");
+                $fileRecord->entity_id = $order->id;
+                $fileRecord->entity = $entity;
+                $fileRecord->file_type = $file->type;
+                $fileRecord->url = '/uploads' . $target_dir . $file->baseName . '.' . $file->extension;
+                if (!$fileRecord->save()) {
+                    Yii::error('Ошибка сохранения файла: ' . json_encode($fileRecord->getErrors(), JSON_UNESCAPED_UNICODE));
+                }
+            }
+            $photos = $order->getFiles();
+            if (count($photos) > 0 && isset($photos[0]->url)) {
+                $order->order_photo = $photos[0]->url;
+                if (!$order->save()) {
+                    Yii::error('Ошибка сохранения заказа' . json_encode($order->getErrors(), JSON_UNESCAPED_UNICODE));
+                    return ['error' => 'Ошибка сохранения заказа'];
+                }
+            }
+            Yii::$app->session->setFlash('success', 'Файлы успешно загружены.');
+            return $this->render('upload', [
+                'guid' => $guid,
+            ]);
+        }
+
+        return $this->render('upload', [
+            'guid' => $guid,
+        ]);
+    }
 }
\ No newline at end of file
index dc83619b16d7ff31663240d77b3f179dcb8966aa..abd42f99417f3ca3e26fd93098fd40539e9407f0 100644 (file)
@@ -9,7 +9,11 @@ require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
 $config = require __DIR__.'/config/media.config.php';
 
 Yii::setAlias('@yii_app', dirname(__DIR__));
-
+Yii::setAlias('@webroot', dirname(__DIR__, 3) . '/web');
+Yii::setAlias('@web', '/');
+Yii::setAlias('@uploads', dirname(__DIR__, 3) . '/uploads');
+// echo Yii::getAlias('@webroot'); // Должно вывести путь до web/
+// exit;
 $application = new yii\web\Application($config);
 $exitCode = $application->run();
 exit($exitCode);
diff --git a/erp24/media/views/layouts/_____main.php b/erp24/media/views/layouts/_____main.php
new file mode 100644 (file)
index 0000000..047fa9a
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+/** @var yii\web\View $this */
+/** @var string $content */
+
+use app\assets\AppAsset;
+use app\widgets\Alert;
+//use yii\bootstrap\Breadcrumbs;
+use yii\bootstrap\Html;
+use yii\bootstrap\Nav;
+use yii\bootstrap\NavBar;
+
+AppAsset::register($this);
+
+$this->registerCsrfMetaTags();
+$this->registerMetaTag(['charset' => Yii::$app->charset], 'charset');
+$this->registerMetaTag(['name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, shrink-to-fit=no']);
+$this->registerMetaTag(['name' => 'description', 'content' => $this->params['meta_description'] ?? '']);
+$this->registerMetaTag(['name' => 'keywords', 'content' => $this->params['meta_keywords'] ?? '']);
+$this->registerLinkTag(['rel' => 'icon', 'type' => 'image/x-icon', 'href' => Yii::getAlias('@web/favicon.ico')]);
+?>
+<?php $this->beginPage() ?>
+<!DOCTYPE html>
+<html lang="<?= Yii::$app->language ?>" class="h-100">
+<head>
+    <title><?= Html::encode($this->title) ?></title>
+    <?php $this->head() ?>
+</head>
+<body class="d-flex flex-column h-100">
+<?php $this->beginBody() ?>
+
+<header id="header">
+    <?php
+    NavBar::begin([
+        'brandLabel' => Yii::$app->name,
+        'brandUrl' => Yii::$app->homeUrl,
+        'options' => ['class' => 'navbar-expand-md navbar-dark bg-dark fixed-top']
+    ]);
+    echo Nav::widget([
+        'options' => ['class' => 'navbar-nav'],
+        'items' => [
+            ['label' => 'Home', 'url' => ['/site/index']],
+            ['label' => 'About', 'url' => ['/site/about']],
+            ['label' => 'Contact', 'url' => ['/site/contact']],
+            Yii::$app->user->isGuest
+                ? ['label' => 'Login', 'url' => ['/site/login']]
+                : '<li class="nav-item">'
+                    . Html::beginForm(['/site/logout'])
+                    . Html::submitButton(
+                        'Logout (' . Yii::$app->user->identity->name . ')',
+                        ['class' => 'nav-link btn btn-link logout']
+                    )
+                    . Html::endForm()
+                    . '</li>'
+        ]
+    ]);
+    NavBar::end();
+    ?>
+</header>
+
+<main id="main" class="flex-shrink-0" role="main">
+    <div class="container">
+        <?php if (!empty($this->params['breadcrumbs'])): ?>
+<!--            --><?php //= Breadcrumbs::widget(['links' => $this->params['breadcrumbs']]) ?>
+        <?php endif ?>
+        <?= Alert::widget() ?>
+        <?= $content ?>
+    </div>
+</main>
+
+<footer id="footer" class="mt-auto py-3 bg-light">
+    <div class="container">
+        <div class="row text-muted">
+            <div class="col-md-6 text-center text-md-start">&copy; My Company <?= date('Y') ?></div>
+            <div class="col-md-6 text-center text-md-end"><?= Yii::powered() ?></div>
+        </div>
+    </div>
+</footer>
+
+<?php $this->endBody() ?>
+</body>
+</html>
+<?php $this->endPage() ?>
diff --git a/erp24/media/views/layouts/api2_menu.php b/erp24/media/views/layouts/api2_menu.php
new file mode 100644 (file)
index 0000000..18e16f0
--- /dev/null
@@ -0,0 +1,7 @@
+<?php
+
+$this->registerJS("
+    var ADMIN_ID = " . (Yii::$app->user->id ?? 0) . ";
+", \yii\web\View::POS_BEGIN, 'api2_menu_init_global_vars');
+
+$this->registerJsFile('/js/site/get_menu.js', ['position' => \yii\web\View::POS_END]);
diff --git a/erp24/media/views/layouts/footer.php b/erp24/media/views/layouts/footer.php
new file mode 100755 (executable)
index 0000000..b9cbac8
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+list($queryCount, $queryTime) = Yii::getLogger()->getDbProfiling();
+global $modul, $act, $tstart;
+
+$totalTime=round((microtime(1)-$tstart),4);
+?>
+<footer class="footer d-print-none">
+    <div class="container">
+        <div class="row align-items-center flex-row-reverse">
+            <div class="col-md-12 col-sm-12 text-center fs-6">
+                <span class="fa fa-heart text-danger">База Цветов 24.ру</span>
+                <?php ?>
+                <a href="/video/show/?menu=/<?= $modul.'/'.$act ?>/">Смотреть уроки</a>
+            </div>
+        </div>
+        <div class="row align-items-center flex-row-reverse">
+            <div class="col-md-12 col-sm-12 text-center fs-6">
+                <span><i>время: <?php echo $totalTime ?? ''?> сек. </i> sql запросов: <?php echo $queryCount ?? ''?></span>
+            </div>
+        </div>
+    </div>
+</footer>
diff --git a/erp24/media/views/layouts/header.php b/erp24/media/views/layouts/header.php
new file mode 100755 (executable)
index 0000000..a367389
--- /dev/null
@@ -0,0 +1,274 @@
+<?php
+
+use app\controllers\MainController;
+use yii_app\records\Admin;
+use yii_app\records\AdminGroup;
+
+$this->registerCssFile('/css/timetable/style.css');
+?>
+<div class="side-app">
+
+    <!--app header-->
+    <div class="app-header header main-header1 noprint">
+        <div class="container-fluid">
+            <div class="d-flex">
+                <div class="app-sidebar__toggle d-flex" data-bs-toggle="sidebar">
+                    <a class="open-toggle" href="javascript:void(0);">
+                        <svg xmlns="http://www.w3.org/2000/svg" class="feather feather-align-left header-icon" width="24" height="24" viewBox="0 0 24 24"><path d="M4 6h16v2H4zm0 5h16v2H4zm0 5h16v2H4z"/></svg>
+                    </a>
+                </div>
+                <div class="mt-1 d-md-block d-none">
+                    <form class="form-inline">
+                        <div class="search-element">
+                            <input type="search" class="form-control header-search mobile-view-search poiskinpiut" autocomplete="off" name="seach" id="search" placeholder="Поиск…" aria-label="Search" tabindex="1">
+                                <button class="btn btn-primary-color" type="submit">
+                                    <svg xmlns="http://www.w3.org/2000/svg" class="header-icon search-icon" width="24" height="24" viewBox="0 0 24 24"><path d="M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"/></svg>
+                                </button>
+
+                        </div>
+                    </form>
+                </div><!-- SEARCH -->
+
+                <?php if (\yii_app\helpers\HtmlHelper::isMobile()) { ?>
+                    <div class="d-flex order-lg-2 ms-auto">    <span class="mt-4 header-avatar1">
+                            <img src="/<?= $_SESSION["avatarka"] ?>" height=40 alt="img" class="avatar">
+                        </span></div>
+
+
+                    <div class="d-flex order-lg-2 ms-auto text-left">
+                        <a href="/profile/" class="ml-2 mt-3">
+
+                            <small><?= $_SESSION["admin_group_name"] ?>:<br>
+                                    <b><?= $_SESSION["name_admin"] ?></b>
+                            </small>
+                        </a>
+                    </div>
+                <?php } ?>
+
+                <div class="d-flex order-lg-2 ms-auto main-header-end">
+                    <button  class="navbar-toggler navresponsive-toggler d-md-none ms-auto" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent-4" aria-controls="navbarSupportedContent-4" aria-expanded="true" aria-label="Toggle navigation">
+                        <i class="fe fe-more-vertical header-icons navbar-toggler-icon"></i>
+                    </button>
+                    <div class="navbar navbar-expand-lg navbar-collapse responsive-navbar p-0">
+                        <div class="collapse navbar-collapse" id="navbarSupportedContent-4">
+                            <div class="d-flex order-lg-2">
+                                <div class="dropdown d-lg-none d-flex responsive-search">
+                                    <a href="javascript:void(0);" class="nav-link icon" data-bs-toggle="dropdown">
+                                        <svg xmlns="http://www.w3.org/2000/svg" class="header-icon search-icon" width="24" height="24" viewBox="0 0 24 24"><path d="M10 18a7.952 7.952 0 0 0 4.897-1.688l4.396 4.396 1.414-1.414-4.396-4.396A7.952 7.952 0 0 0 18 10c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8zm0-14c3.309 0 6 2.691 6 6s-2.691 6-6 6-6-2.691-6-6 2.691-6 6-6z"/></svg>
+                                    </a>
+                                    <div class="dropdown-menu header-search dropdown-menu-start">
+                                        <div class="input-group w-100 p-2">
+                                            <input type="text" class="form-control poiskinpiut" id="search_m" autocomplete="off" name="search_m"  placeholder="Поиск....">
+                                                <button class="btn btn-primary-color" type="submit">
+                                                    <svg class="header-icon search-icon p-1 mt-1" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>
+                                                </button>
+                                        </div>
+                                    </div>
+                                </div><!-- SEARCH -->
+
+                                <div class="dropdown d-flex">
+                                    <a href="javascript:;" id="reload-js" class="nav-link icon theme-layout nav-link-bg" onclick="window.location.reload(true);" title="Сбросить кэш">
+                                        <span class="t">
+                                            <svg xmlns="http://www.w3.org/2000/svg" height="24px" fill="#000000" class="header-icon" viewBox="0 0 24 24" width="24px">
+                                                <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z"/>
+                                            </svg>
+                                        </span>
+                                    </a>
+                                </div>
+
+                                <div class="dropdown d-flex">
+                                    <a href="javascript:window.print();" class="nav-link icon theme-layout nav-link-bg">
+                                        <span class="t">
+                                            <svg xmlns="http://www.w3.org/2000/svg" height="24px" fill="#000000" class="header-icon" viewBox="0 0 24 24" width="24px" ><path d="M0 0h24v24H0V0z" fill="none"/><path d="M19 8h-1V3H6v5H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zM8 5h8v3H8V5zm8 12v2H8v-4h8v2zm2-2v-2H6v2H4v-4c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v4h-2z"/><circle cx="18" cy="11.5" r="1"/></svg>
+                                        </span>
+                                    </a>
+                                </div>
+
+                                <div class="dropdown d-flex">
+                                    <a href="/design/?teme_color=<?= ($_SESSION['teme_color'] ?? '') === 'dark' ? 'light': 'dark' ?>" class="nav-link icon theme-layout nav-link-bg layout-setting">
+                                        <span class="light-layout"><svg xmlns="http://www.w3.org/2000/svg" class="header-icon" width="24" height="24" viewBox="0 0 24 24"><path d="M20.742 13.045a8.088 8.088 0 0 1-2.077.271c-2.135 0-4.14-.83-5.646-2.336a8.025 8.025 0 0 1-2.064-7.723A1 1 0 0 0 9.73 2.034a10.014 10.014 0 0 0-4.489 2.582c-3.898 3.898-3.898 10.243 0 14.143a9.937 9.937 0 0 0 7.072 2.93 9.93 9.93 0 0 0 7.07-2.929 10.007 10.007 0 0 0 2.583-4.491 1.001 1.001 0 0 0-1.224-1.224zm-2.772 4.301a7.947 7.947 0 0 1-5.656 2.343 7.953 7.953 0 0 1-5.658-2.344c-3.118-3.119-3.118-8.195 0-11.314a7.923 7.923 0 0 1 2.06-1.483 10.027 10.027 0 0 0 2.89 7.848 9.972 9.972 0 0 0 7.848 2.891 8.036 8.036 0 0 1-1.484 2.059z"/></svg></span>
+                                        <span class="dark-layout"><svg xmlns="http://www.w3.org/2000/svg" class="header-icon" width="24" height="24" viewBox="0 0 24 24"><path d="M6.993 12c0 2.761 2.246 5.007 5.007 5.007s5.007-2.246 5.007-5.007S14.761 6.993 12 6.993 6.993 9.239 6.993 12zM12 8.993c1.658 0 3.007 1.349 3.007 3.007S13.658 15.007 12 15.007 8.993 13.658 8.993 12 10.342 8.993 12 8.993zM10.998 19h2v3h-2zm0-17h2v3h-2zm-9 9h3v2h-3zm17 0h3v2h-3zM4.219 18.363l2.12-2.122 1.415 1.414-2.12 2.122zM16.24 6.344l2.122-2.122 1.414 1.414-2.122 2.122zM6.342 7.759 4.22 5.637l1.415-1.414 2.12 2.122zm13.434 10.605-1.414 1.414-2.122-2.122 1.414-1.414z"/></svg></span>
+                                    </a>
+                                </div>
+                                <div class="d-flex">
+                                    <?php
+                                    $styleBackground = 'contractor';
+
+                                    if ($_SESSION['group_id'] == Admin::ADMINISTRATOR_GROUP_ID) {
+                                        $styleBackground = 'admin';
+                                    } else if (in_array($_SESSION['group_id'],Admin::ADMIN_WRITE_OFFS_SINGLE_STORE_GROUP_IDS)) {
+                                        $styleBackground = 'florist';
+                                    }
+
+                                    ?>
+                                    <!-- стили для должности сотр.  в зависимости кто зашел: admin, contractor, florist, -->
+                                    <div
+                                            class="d-flex justify-content-between align-items-center gap-2"
+                                    >
+                                        <div class="<?= $styleBackground?> m-2 p-1 ps-2 pe-2 rounded-2"><?= $_SESSION['name_group_admin']?? '-'?></div>
+                                        <div class="<?= $styleBackground?> m-2 p-1 ps-2 pe-2 rounded-2"><?= $_SESSION['name_admin']?? '-'?></div>
+                                    </div>
+                                </div>
+                                <div class="dropdown header-notify d-flex">
+                                    <div id="kolokolchik-counter" style="margin-top: 25px;"></div>
+                                    <a class="nav-link icon kolokolchik" data-bs-toggle="dropdown">
+                                        <svg xmlns="http://www.w3.org/2000/svg" class="header-icon" width="24" height="24" viewBox="0 0 24 24"><path d="M19 13.586V10c0-3.217-2.185-5.927-5.145-6.742C13.562 2.52 12.846 2 12 2s-1.562.52-1.855 1.258C7.185 4.074 5 6.783 5 10v3.586l-1.707 1.707A.996.996 0 0 0 3 16v2a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1v-2a.996.996 0 0 0-.293-.707L19 13.586zM19 17H5v-.586l1.707-1.707A.996.996 0 0 0 7 14v-4c0-2.757 2.243-5 5-5s5 2.243 5 5v4c0 .266.105.52.293.707L19 16.414V17zm-7 5a2.98 2.98 0 0 0 2.818-2H9.182A2.98 2.98 0 0 0 12 22z"/></svg>
+                                        <span class="pulse hidden"></span>
+                                    </a>
+                                    <div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow  animated">
+                                        <div class="dropdown-header">
+                                            <h6 class="mb-0">Уведомления</h6>
+                                            <span class="badge fs-10 bg-secondary br-7 ms-auto">новые</span>
+                                        </div>
+                                        <div class="notify-menu">
+                                            <a href="email-inbox.html" class="dropdown-item border-bottom d-flex ps-4">
+                                                <div class="notifyimg  text-primary bg-primary-transparent border-primary"> <i class="fa fa-envelope"></i> </div>
+                                                <div>
+                                                    <span class="fs-13">Всем сотрудникам привет!</span>
+                                                    <div class="small text-muted">3 часа назад</div>
+                                                </div>
+                                            </a>
+                                        </div>
+                                        <div class="notify-show-all text-center p-2">
+                                            <a href="#" target="_blank" class="btn btn-primary btn-md fs-13 btn-block">Показать все</a>
+                                        </div>
+                                    </div>
+                                </div>
+                                <div class="dropdown profile-dropdown d-flex">
+                                    <?php
+                                    $arr = explode(' ',$_SESSION["name_admin"]);
+                                    foreach ($arr as $key=>$value) {
+                                        mb_internal_encoding("UTF-8");
+                                        $arr["$key"] = mb_strtoupper(mb_substr(trim($value),0,1));
+                                    }
+                                    ?>
+                                    <a href="javascript:void(0);" class="nav-link pe-0 leading-none" data-bs-toggle="dropdown" aria-expanded="false">
+                                        <span class="header-avatar1">
+                                            <?php
+                                            if (!empty($_SESSION["avatarka"]) || empty($arr)) {
+                                                ?>
+                                                <img src="/<?= $_SESSION["avatarka"] ?>" alt="img" class="avatar avatar-md brround">
+                                                <?php
+                                            } else {
+                                            ?>
+                                                <div class="initials-employee d-flex justify-content-center align-items-center p-2 text-white rounded-5 background-main-color"
+                                                    ><?php
+                                                        echo trim(implode('',$arr));
+                                                    ?></div>
+                                            <?php
+                                            }
+                                            ?>
+                                        </span>
+                                    </a>
+                                    <div class="dropdown-menu dropdown-menu-end dropdown-menu-arrow animated">
+                                        <div class="text-center">
+                                            <div class="text-center user pb-0 font-weight-bold"><?= $_SESSION["name_admin"] ?? '-' ?></div>
+                                            <span class="text-center user-semi-title"><?= $_SESSION["admin_group_name"] ?? '-'?></span>
+                                            <div class="text-center user-semi-title"><?= '#' . $_SESSION["admin_id"] ?? '-'?></div>
+                                            <div class="dropdown-divider"></div>
+                                        </div>
+                                        <a class="dropdown-item d-flex" href="/profile/">
+                                            <svg class="header-icon me-2" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM7.07 18.28c.43-.9 3.05-1.78 4.93-1.78s4.51.88 4.93 1.78C15.57 19.36 13.86 20 12 20s-3.57-.64-4.93-1.72zm11.29-1.45c-1.43-1.74-4.9-2.33-6.36-2.33s-4.93.59-6.36 2.33C4.62 15.49 4 13.82 4 12c0-4.41 3.59-8 8-8s8 3.59 8 8c0 1.82-.62 3.49-1.64 4.83zM12 6c-1.94 0-3.5 1.56-3.5 3.5S10.06 13 12 13s3.5-1.56 3.5-3.5S13.94 6 12 6zm0 5c-.83 0-1.5-.67-1.5-1.5S11.17 8 12 8s1.5.67 1.5 1.5S12.83 11 12 11z"></path></svg>
+                                            <div class="fs-13">Профиль</div>
+                                        </a>
+                                        <a class="dropdown-item d-flex" href="/search/">
+                                            <svg class="header-icon me-2" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M19.43 12.98c.04-.32.07-.64.07-.98 0-.34-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.09-.16-.26-.25-.44-.25-.06 0-.12.01-.17.03l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.06-.02-.12-.03-.18-.03-.17 0-.34.09-.43.25l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98 0 .33.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.09.16.26.25.44.25.06 0 .12-.01.17-.03l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.06.02.12.03.18.03.17 0 .34-.09.43-.25l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zm-1.98-1.71c.04.31.05.52.05.73 0 .21-.02.43-.05.73l-.14 1.13.89.7 1.08.84-.7 1.21-1.27-.51-1.04-.42-.9.68c-.43.32-.84.56-1.25.73l-1.06.43-.16 1.13-.2 1.35h-1.4l-.19-1.35-.16-1.13-1.06-.43c-.43-.18-.83-.41-1.23-.71l-.91-.7-1.06.43-1.27.51-.7-1.21 1.08-.84.89-.7-.14-1.13c-.03-.31-.05-.54-.05-.74s.02-.43.05-.73l.14-1.13-.89-.7-1.08-.84.7-1.21 1.27.51 1.04.42.9-.68c.43-.32.84-.56 1.25-.73l1.06-.43.16-1.13.2-1.35h1.39l.19 1.35.16 1.13 1.06.43c.43.18.83.41 1.23.71l.91.7 1.06-.43 1.27-.51.7 1.21-1.07.85-.89.7.14 1.13zM12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"></path></svg>
+                                            <div class="fs-13">Настройки</div>
+                                        </a>
+                                        <a class="dropdown-item d-flex" href="/chat/">
+                                            <svg class="header-icon me-2" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M4 4h16v12H5.17L4 17.17V4m0-2c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2H4zm2 10h12v2H6v-2zm0-3h12v2H6V9zm0-3h12v2H6V6z"></path></svg>
+                                            <div class="fs-13">Сообщения</div>
+                                        </a>
+                                        <a class="dropdown-item d-flex" href="/config/admin_desktop/">
+                                            <svg class="header-icon me-2" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M19.43 12.98c.04-.32.07-.64.07-.98 0-.34-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.09-.16-.26-.25-.44-.25-.06 0-.12.01-.17.03l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.06-.02-.12-.03-.18-.03-.17 0-.34.09-.43.25l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98 0 .33.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.09.16.26.25.44.25.06 0 .12-.01.17-.03l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.06.02.12.03.18.03.17 0 .34-.09.43-.25l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zm-1.98-1.71c.04.31.05.52.05.73 0 .21-.02.43-.05.73l-.14 1.13.89.7 1.08.84-.7 1.21-1.27-.51-1.04-.42-.9.68c-.43.32-.84.56-1.25.73l-1.06.43-.16 1.13-.2 1.35h-1.4l-.19-1.35-.16-1.13-1.06-.43c-.43-.18-.83-.41-1.23-.71l-.91-.7-1.06.43-1.27.51-.7-1.21 1.08-.84.89-.7-.14-1.13c-.03-.31-.05-.54-.05-.74s.02-.43.05-.73l.14-1.13-.89-.7-1.08-.84.7-1.21 1.27.51 1.04.42.9-.68c.43-.32.84-.56 1.25-.73l1.06-.43.16-1.13.2-1.35h1.39l.19 1.35.16 1.13 1.06.43c.43.18.83.41 1.23.71l.91.7 1.06-.43 1.27-.51.7 1.21-1.07.85-.89.7.14 1.13zM12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"></path></svg>
+                                            <div class="fs-13">Привязать устройство</div>
+                                        </a>
+                                        <?php if (Yii::$app->request->cookies->has(MainController::SWITCH_USER_COOKIE) ||
+                                            (Admin::findOne(Yii::$app->user->id)->group_id ?? -1) == AdminGroup::GROUP_IT): ?>
+                                        <a class="dropdown-item d-flex" href="javascript:void(0)" onclick="switchUser();">
+                                            <svg class="header-icon me-2" xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0V0z" fill="none"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zM7.07 18.28c.43-.9 3.05-1.78 4.93-1.78s4.51.88 4.93 1.78C15.57 19.36 13.86 20 12 20s-3.57-.64-4.93-1.72zm11.29-1.45c-1.43-1.74-4.9-2.33-6.36-2.33s-4.93.59-6.36 2.33C4.62 15.49 4 13.82 4 12c0-4.41 3.59-8 8-8s8 3.59 8 8c0 1.82-.62 3.49-1.64 4.83zM12 6c-1.94 0-3.5 1.56-3.5 3.5S10.06 13 12 13s3.5-1.56 3.5-3.5S13.94 6 12 6zm0 5c-.83 0-1.5-.67-1.5-1.5S11.17 8 12 8s1.5.67 1.5 1.5S12.83 11 12 11z"></path></svg>
+                                            <div class="fs-13">Переключить пользователя</div>
+                                        </a>
+                                        <?php endif; ?>
+                                        <a class="dropdown-item d-flex" href="/site/logout">
+                                            <svg class="header-icon me-2" xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24"><g><rect fill="none" height="24" width="24"></rect></g><g><path d="M11,7L9.6,8.4l2.6,2.6H2v2h10.2l-2.6,2.6L11,17l5-5L11,7z M20,19h-8v2h8c1.1,0,2-0.9,2-2V5c0-1.1-0.9-2-2-2h-8v2h8V19z"></path></g></svg>
+                                            <div class="fs-13">Выйти</div>
+                                        </a>
+                                    </div>
+                                </div>
+
+
+
+                            </div>
+                        </div>
+                    </div>
+
+                </div>
+            </div>
+        </div>
+    </div>
+</div>
+
+<script>
+
+function switchUser() {
+    const paramXX = $('meta[name=csrf-param]').attr('content');
+    const tokenXX = $('meta[name=csrf-token]').attr('content');
+
+    $.ajax({
+        url: '/main/ajax-get-users',
+        method: 'post',
+        dataType: 'json',
+        data: {[paramXX]: tokenXX},
+        success: function(data){
+            const $mainModal = $('#mainModal');
+            const $modalBody = $mainModal.find('.modal-body');
+            const $modalFooter = $mainModal.find('.modal-footer');
+            $mainModal.find('.close').on('click', () => { $mainModal.modal('hide'); });
+            $mainModal.find('.modal-title').html('Переключить пользователя');
+            $modalFooter.html('<button class="btn btn-success">Переключить</button>');
+            $modalFooter.find('button').on('click', () => {
+                const adminId = $select.val();
+                $.ajax({
+                    url: '/main/ajax-switch-user',
+                    method: 'post',
+                    dataType: 'json',
+                    data: {adminId, [paramXX]: tokenXX},
+                    success: function(data) {
+                        if (data?.response) {
+                            window.location = window.location
+                        }
+                    },
+                    error: function(XMLHttpRequest, textStatus, errorThrown) {
+                        alert("Время для переключиения истекло");
+                    }
+                });
+            })
+            $modalBody.html('<select class="js-example-basic-single" name="state"></select>');
+            const $select = $('.js-example-basic-single');
+
+            $.each(data, (opt) => {
+                const optGroup = document.createElement("optgroup")
+                optGroup.label = opt;
+                $.each(data[opt], (key, value) => {
+                    const option = document.createElement("option")
+                    option.value = key;
+                    option.text = value;
+                    optGroup.append(option);
+                })
+                $select.append(optGroup);
+            });
+
+            $select.select2({
+                dropdownParent: $mainModal,
+            });
+
+            $mainModal.modal('show');
+        },
+        error: function(XMLHttpRequest, textStatus, errorThrown) {
+            alert("Время для переключиения истекло");
+        }
+    })
+}
+
+</script>
diff --git a/erp24/media/views/layouts/main.php b/erp24/media/views/layouts/main.php
new file mode 100755 (executable)
index 0000000..edcf0f5
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+    /**
+     * @var string $content rendered content
+     * @var \yii\web\View $this
+     */
+    global $_CONFIG;
+
+ app\assets\CommonAsset::register($this);
+app\assets\CachemenutopAsset::register($this);
+ app\assets\JQueryPluginsAsset::register($this); /** @TODO удалить после переписывания основного функционала */
+
+use yii\widgets\Breadcrumbs;
+?>
+<?php $this->beginPage() ?>
+<!DOCTYPE html>
+<html lang="ru" dir="ltr">
+    <head>
+        <meta charset="UTF-8">
+        <meta name='viewport' content='width=device-width, initial-scale=1.0, user-scalable=0'>
+        <?php $this->registerCsrfMetaTags() ?>
+        <title><?= $this->title ? $this->title : \yii_app\records\CrmMenu::getTitle(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)) ?></title>
+        <?php $this->head(); ?>
+    </head>
+    <?php
+    $attributes = 'app sidebar-mini';
+    if (($_SESSION["teme_color"] ?? '') === 'dark') {
+        $attributes .= ' dark-mode';
+    }
+    if (
+        !yii_app\helpers\HtmlHelper::isMobile() &&
+        \yii_app\records\CrmMenu::isLeftMenuCollapsed(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))
+    ) {
+        $attributes .= ' sidenav-toggled';
+    }
+    ?>
+    <body class="<?= $attributes ?> sidenav-toggled">
+    <?php $this->beginBody(); ?>
+        <div class="page">
+            <div class="page-main">
+                <aside class="app-sidebar noprint">
+                    <div class="app-sidebar__logo">
+                        <a class="header-brand" href="/">
+                            <img src="https://erp.erp-flowers.ru/i/dostavka-cvetov.svg" class="header-brand-img desktop-lgo" alt=" logo">
+                            <img src="https://erp.erp-flowers.ru/i/dostavka-cvetov.svg" class="header-brand-img dark-logo" alt=" logo">
+                            <img src="https://erp.erp-flowers.ru/i/dostavka-cvetov.svg" class="header-brand-img mobile-logo" alt=" logo">
+                            <img src="https://erp.erp-flowers.ru/i/dostavka-cvetov.svg" class="header-brand-img darkmobile-logo" alt=" logo">
+                        </a>
+                    </div>
+                    <?php //if (isset(Yii::$app->params['API2_TOKEN'])): ?>
+                        <div id="main_menu_id"></div>
+                        <?php $this->render('api2_menu.php') ?>
+                    <?php /* else: ?>
+                        <?php if ($this->beginCache('menu_' . $_SESSION['admin_id'])): ?>
+                            <?php $this->render('menu.php'); ?>
+                            <?php $this->endCache(); ?>
+                        <?php endif; ?>
+                    <?php endif; */ ?>
+                </aside>
+                <div class="app-content main-content">
+                    <?= $this->render('header.php'); ?>
+
+                    <? // TODO: Включить хлебные крошки?
+                    /*= Breadcrumbs::widget([
+                        'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
+                    ]) */?>
+                    <?= $content ?>
+                </div>
+            </div>
+            <?= $this->render('footer.php'); ?>
+        </div>
+
+        <div id="mainModal" class="modal" tabindex="-1" role="dialog">
+            <div class="modal-dialog modal-lg" role="document">
+                <div class="modal-content">
+                    <div class="modal-header">
+                        <h5 class="modal-title">DIALOG TITLE</h5>
+                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                            <span aria-hidden="true">&times;</span>
+                        </button>
+                    </div>
+                    <div class="modal-body"></div>
+                    <div class="modal-footer"></div>
+                </div>
+            </div>
+        </div>
+
+    <?php $this->endBody(); ?>
+    </body>
+</html>
+<?php $this->endPage() ?>
diff --git a/erp24/media/views/layouts/menu.php b/erp24/media/views/layouts/menu.php
new file mode 100755 (executable)
index 0000000..122108a
--- /dev/null
@@ -0,0 +1,53 @@
+<ul class="side-menu app-sidebar3 noprint" id="main_menu_l">
+    <?php
+        $categories = \yii_app\records\CrmMenu::getTree();
+        $menu_html = '';
+        foreach ($categories[0] as $pid => $mass) { ?>
+            <?php if (isset($_SESSION['modul_arr_dostup'][$mass['id']])) {
+                if (!empty($categories[$mass["id"]])) {
+                    $attributes = 'data-bs-toggle="slide" href="javascript:void(0);"';
+                } else {
+                    $attributes = 'href="' . $mass["url"] . '"';
+                }
+                ?>
+                <li class="slide">
+                    <a class="side-menu__item" <?= $attributes ?>>
+                        <?= str_replace('<svg ', '<svg class="side-menu__icon" ', $mass["icon_file"]); ?>
+                        <span class="side-menu__label"><?= $mass["name"] ?></span>
+                        <?php if (!empty($categories[$mass["id"]])) { ?>
+                            <i class="angle fe fe-chevron-right"></i>
+                            <ul class="slide-menu">
+                                <?php foreach ($categories[$mass["id"]] as $pid2 => $mass2) { ?>
+                                    <?php if (isset($_SESSION['modul_arr_dostup'][$mass2['id']])) { ?>
+                                        <?php if (empty($categories[$mass2["id"]])) { ?>
+                                            <li class="slide">
+                                                <a href="<?= $mass2["url"] ?>" class="slide-item">
+                                                    <?= str_replace('<svg ', '<svg class="side-menu__icon" ', $mass2["icon_file"]); ?>
+                                                    <?= $mass2["name"] ?>
+                                                </a>
+                                            </li>
+                                        <?php } ?>
+                                        <?php if (!empty($categories[$mass2["id"]])) { ?>
+                                            <li class="sub-slide2">
+                                                <a class="sub-slide-item2" data-bs-toggle="sub-slide2" href="<?= $categories[$mass2["id"]][0]["url"]; ?>">
+                                                    <span class="sub-side-menu__label2"><?= $categories[$mass2["id"]][0]["name"] ?></span>
+                                                    <i class="sub-angle2 fe fe-chevron-right"></i>
+                                                </a>
+                                                <ul class="sub-slide-menu2">
+                                                    <?php foreach ($categories[$mass2["id"]] as $pid3 => $mass4) { ?>
+                                                        <li>
+                                                            <a href="<?= $mass4["url"] ?>" class="sub-slide-item2"><?= $mass4["name"] ?></a>
+                                                        </li>
+                                                    <?php } ?>
+                                                </ul>
+                                            </li>
+                                        <?php } ?>
+                                    <?php } ?>
+                                <?php } ?>
+                            </ul>
+                        <?php } ?>
+                    </a>
+                </li>
+        <?php } ?>
+    <?php } ?>
+</ul>
\ No newline at end of file
diff --git a/erp24/media/views/marketplace/upload.php b/erp24/media/views/marketplace/upload.php
new file mode 100644 (file)
index 0000000..fe4596b
--- /dev/null
@@ -0,0 +1,23 @@
+<?php
+use yii\widgets\ActiveForm;
+use yii\helpers\Html;
+
+/** @var $this yii\web\View */
+/** @var string $guid */
+
+$this->title = 'Загрузка фотографий заказа (GUID: ' . $guid . ')';
+?>
+
+    <h1><?= Html::encode($this->title) ?></h1>
+
+<?php if (Yii::$app->session->hasFlash('success')): ?>
+    <div class="alert alert-success">
+        <?= Yii::$app->session->getFlash('success') ?>
+    </div>
+<?php endif; ?>
+
+<form action="/marketplace/upload" method="post" enctype="multipart/form-data">
+    <input type="hidden" name="guid" value="<?= $guid ?>">
+    <input type="file" name="files[]" multiple>
+    <button type="submit">Загрузить</button>
+</form>
\ No newline at end of file
index e7437724874e01b1b8915bd0641791b2299cda6f..43b3599219d654455a01877e8f018e887eeea8a2 100644 (file)
@@ -84,6 +84,14 @@ $this->params['breadcrumbs'][] = $this->title;
                     return $model->status1c->status ?? null;
                 }
             ],
+            [
+                'label'  => 'Фото заказа',
+                'format' => 'raw',
+                'value'  => function ($model) {
+
+                    return Html::img($model->order_photo, ['width' => '100px']);
+                }
+            ],
             [
                 'label'  => 'Товары',
                 'format' => 'raw',