]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-199 Доработка меню (вёрстка+)
authormarina <m.zozirova@gmail.com>
Thu, 7 Nov 2024 06:14:07 +0000 (09:14 +0300)
committermarina <m.zozirova@gmail.com>
Thu, 7 Nov 2024 06:14:07 +0000 (09:14 +0300)
erp24/controllers/AuthController.php
erp24/records/AdminMenuPositions.php [new file with mode: 0644]
erp24/templates/top.php
erp24/views/layouts/api2_menu.php
erp24/views/layouts/main.php
erp24/views/layouts/menu.php
erp24/views/site/index.php
erp24/web/azea/assets/css-rtl/sidemenu-icon.css
erp24/web/azea/assets/css-rtl/sidemenu.scss
erp24/web/min/css_1646055591.css
erp24/web/min/css_1646055591.nogz.css

index bd5f70ca78efe8e52c774bb26b3524f30b3dac89..279ec5446280bb2232c18bfc14b48a34224ca580 100644 (file)
@@ -7,6 +7,7 @@ use yii\helpers\ArrayHelper;
 use yii_app\records\Admin;
 use yii_app\records\AdminGroup;
 use yii_app\records\AdminGroupRbacConfig;
+use yii_app\records\AdminMenuPositions;
 use yii_app\records\CrmMenu;
 use yii_app\records\CrmMenuPermission;
 use yii_app\records\UniversalCatalog;
@@ -252,4 +253,59 @@ class AuthController extends BaseController
         CrmMenu::deleteAll(['parent_id' => $id]);
         return $this->redirect('menu');
     }
+
+    public function actionMenuByRoles()
+    {
+        $roles = ArrayHelper::map(AdminGroup::find()->all(), 'id', 'name');
+        $menuItems = [];
+
+        if (Yii::$app->request->isPost) {
+            // Сохранение порядка
+            $data = Yii::$app->request->post('order');
+            foreach ($data as $position => $id) {
+                AdminMenuPositions::updateAll(['position' => $position], ['id' => $id]);
+            }
+            Yii::$app->session->setFlash('success', 'Порядок сохранён');
+            return $this->refresh();
+        }
+
+        $selectedRole = Yii::$app->request->get('role');
+        if ($selectedRole) {
+            // Attempt to get menu items for the selected role
+            $menuItems = AdminMenuPositions::find()->where(['role' => $selectedRole])->orderBy('position')->all();
+
+            // If no items found, fetch from CrmMenu
+            if (empty($menuItems)) {
+                $crmMenuItems = CrmMenu::find()->all(); // Fetch all items from CrmMenu
+                foreach ($crmMenuItems as $crmItem) {
+                    // Check if the item already exists in AdminMenuPositions
+                    if (!AdminMenuPositions::find()->where(['id' => $crmItem->id, 'role' => $selectedRole])->exists()) {
+                        // Create a new AdminMenuPosition record
+                        $adminMenuPosition = new AdminMenuPositions();
+                        $adminMenuPosition->id = $crmItem->id; // Assuming 'id' is the same
+                        $adminMenuPosition->title = $crmItem->title; // Assuming 'title' exists in CrmMenu
+                        $adminMenuPosition->role = $selectedRole; // Assign the selected role
+                        $adminMenuPosition->position = 0; // Set default position (you can modify this logic)
+                        $adminMenuPosition->save();
+                    }
+                }
+
+                // After saving, get the menu items again
+                $menuItems = AdminMenuPositions::find()->where(['role' => $selectedRole])->orderBy('position')->all();
+            }
+        }
+
+        if (Yii::$app->request->isAjax) {
+            if ($selectedRole) {
+                return $this->asJson($menuItems);
+            }
+        }
+
+        return $this->render('menu-by-roles', [
+            'roles' => $roles,
+            'menuItems' => $menuItems,
+            'selectedRole' => $selectedRole,
+        ]);
+    }
+
 }
\ No newline at end of file
diff --git a/erp24/records/AdminMenuPositions.php b/erp24/records/AdminMenuPositions.php
new file mode 100644 (file)
index 0000000..8ca1a18
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+use yii\helpers\ArrayHelper;
+
+/**
+ * This is the model class for table "admin_payroll_history".
+ *
+ * @property int $id
+ * @property int $admin_id
+ * @property int $store_id
+ * @property int $year
+ * @property int $month
+ * @property int $type_value
+ * @property float $value
+ * @property string $created_at
+ */
+class AdminMenuPositions extends \yii\db\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return 'admin_menu_positions';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['admin_group_id', 'crm_menu_id', 'is_parent', 'position'], 'required'],
+            [['admin_group_id', 'crm_menu_id', 'position'], 'integer'],
+            [['is_parent'], 'safe'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'admin_group_id' => 'Admin Group ID',
+            'crm_menu_id' => 'Crm Menu ID',
+            'is_parent' => 'Is Parent',
+            'position' => 'Position'
+        ];
+    }
+}
\ No newline at end of file
index 22dd4f1fd2c72282049c4994da3c5cde50617a93..8361ea093a19c15478a9603ab0fe13118b2bbd76 100644 (file)
@@ -95,11 +95,14 @@ elseif(!is_mobile()) echo" [MENU_COLLAPSE]";
                                                </a>
                                        </div>
                                        
-                                       
-                                       
+
 
 <ul class="side-menu app-sidebar3 noprint" id="main_menu_l">
-<?php
+    <h1>Поиск по меню</h1>
+    <input type="text" id="search" placeholder="Введите название блюда...">
+    <div id="results"></div>
+
+    <?php
 
 if(empty($_SESSION["lasttime"]) or ( $_SESSION["lasttime"] <(time()-20) ) ) {
 $db::sql("UPDATE admin set lasttime=NOW() WHERE id=?", $_SESSION["admin_id"]);
@@ -140,8 +143,8 @@ $menu_html .=$mass["icon_file"];
 $menu_html .='<span class="side-menu__label">'.$mass["name"].'</span>';
 
 //$menu_html .='<span class="badge bg-danger  side-badge">'.rand(0,12).'</span>';
-
-if(!empty($category_arr[$mass["id"]]))  $menu_html .='<i class="angle fe fe-chevron-right"></i>';
+var_dump(1);die();
+if(!empty($category_arr[$mass["id"]])) $menu_html .='<i class="fa fa-chevron-right"></i>';
 
 $menu_html .='</a>
 
@@ -151,9 +154,9 @@ $menu_html .='</a>
                                        
                                        
                                 if(empty($category_arr[$mass2["id"]]))  {
-                                
-                                
-                                
+
+                     var_dump($category_arr);die();
+
                                 $menu_html .='<li class="slide"><a href="'.$mass2["url"].'" class="slide-item">';
                                 $mass2["icon_file"]=str_replace('<svg ','<svg class="side-menu__icon" ',$mass2["icon_file"]);
 
@@ -167,7 +170,8 @@ $menu_html .='</a>
                                                      $menu_html .='<li class="sub-slide2">
                                                                                        <a class="sub-slide-item2" data-bs-toggle="sub-slide2" href="'.$category_arr[$mass2["id"]][0]["url"].'">
                                                                                        <span class="sub-side-menu__label2">'.$category_arr[$mass2["id"]][0]["name"].'</span>
-                                                                                       <i class="sub-angle2 fe fe-chevron-right"></i></a>
+//                                                     
+</a>
                                                                                        <ul class="sub-slide-menu2">';
                                                                                        //<span class="badge bg-success  side-badge">'.rand(0,12).'</span>
                                                                                        
index 18e16f09561b7d8246605639b5a39855dc0cc1cc..ebef3bce3bdcbf10bacd4473f4074b0cb57603ab 100644 (file)
@@ -5,3 +5,6 @@ $this->registerJS("
 ", \yii\web\View::POS_BEGIN, 'api2_menu_init_global_vars');
 
 $this->registerJsFile('/js/site/get_menu.js', ['position' => \yii\web\View::POS_END]);
+
+
+
index 9131424f0f39d442a4e8af727c218b69772b5413..b7e6e7a5adc348179fc98a41fb3575af23c95f2a 100755 (executable)
@@ -10,6 +10,9 @@ app\assets\CachemenutopAsset::register($this);
 app\assets\JQueryPluginsAsset::register($this); /** @TODO удалить после переписывания основного функционала */
 
 use yii\widgets\Breadcrumbs;
+use yii_app\records\Admin;
+use yii_app\records\AdminGroup;
+
 ?>
 <?php $this->beginPage() ?>
 <!DOCTYPE html>
@@ -47,7 +50,16 @@ use yii\widgets\Breadcrumbs;
                         </a>
                     </div>
                     <?php //if (isset(Yii::$app->params['API2_TOKEN'])): ?>
+                    <div class="menu-search">
+                        <div class="search-icon">
+                            <svg xmlns="http://www.w3.org/2000/svg" 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"></path>
+                            </svg>
+                        </div>
+                        <input type="text" id="search" placeholder="">
+                    </div>
                         <div id="main_menu_id"></div>
+
                         <?php $this->render('api2_menu.php') ?>
                     <?php /* else: ?>
                         <?php if ($this->beginCache('menu_' . $_SESSION['admin_id'])): ?>
@@ -83,6 +95,40 @@ use yii\widgets\Breadcrumbs;
                 </div>
             </div>
         </div>
+<script>
+    document.addEventListener('DOMContentLoaded', function() {
+        function replaceIcons() {
+            const selectors = [
+                'i.angle.fe.fe-chevron-right',
+                'i.sub-angle2.fe.fe-chevron-right',
+                'i.fa.fe-chevron-right'
+            ];
+
+            selectors.forEach(function(selector) {
+                document.querySelectorAll(selector).forEach(function(element) {
+                    element.classList.remove('angle', 'fe', 'fe-chevron-right');
+                    element.classList.add('fa fa-chevron-right');
+                });
+            });
+        }
+
+        replaceIcons();
+    });
+
+
+    document.getElementById('search').addEventListener('input', function() {
+        const filter = document.getElementById('search').value.toLowerCase();
+        const menuItems = document.querySelectorAll('.slide');
+        menuItems.forEach(item => {
+            const text = item.textContent.toLowerCase();
+            if (text.includes(filter)) {
+                item.style.display = '';
+            } else {
+                item.style.display = 'none';
+            }
+        });
+    });
+</script>
 
     <?php $this->endBody(); ?>
     </body>
index 122108a276c74957d938d51c9527e3c547778320..02ad8af59e5d72c227dcc3096358bff4d6341075 100755 (executable)
                         <?= 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>
@@ -31,7 +31,6 @@
                                             <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) { ?>
index ddb851909a51158d96ea5cd9418c66ccdf00c902..30b5aa6017c6e2fb24e57f81dcc65d78c6ea4e43 100644 (file)
@@ -63,6 +63,7 @@ $this->title = 'Добро пожаловать в систему!';
                         </div>
                         <div class="offer-content">
                             <a href="<?= $row["url"] ?>"><h5>
+<!--                                    --><?php //var_dump($icon); die()?>
                                     <?= str_replace('<svg ', '<svg class="side-menu__icon" ', ($icon[$row["url"]]) ?? ' ') . ' ' . $row["name"] ?>
                                 </h5>
                             </a>
index 5c944994522a7bcb79aaa9668f7cf7344ba089c7..24865ce48e2b34a86a89bef3bc2d2bdd0241196e 100644 (file)
 .side-menu {
   margin-bottom: 0;
   padding-bottom: 40px;
+  margin-top: 0px;
+}
+
+.menu-search {
   margin-top: 90px;
+  margin-left: 15px;
+}
+
+.menu-search #search {
+  padding-left: 29px;
+  border: 1px solid #fffff;
+  border-radius: 2.5px;
+  font-size: 16px;
+  transition: border-color 0.3s;
+  width: 90%;
+}
+
+.menu-search #search::placeholder { color: #5A5A5A; font-size:12px;}
+
+.menu-search .search-icon {
+  position: absolute;
+  left: 20px;
+  top: 20.5%;
+  transform: translateY(-50%);
+  width: 24px;
+  height: 24px;
+  color: #6a5acd !important;
+  pointer-events: none;
+}
+
+.menu-search #search:focus {
+  border-color: #664dc9!important;
+  outline: none;
 }
 
 .side-menu__item {
index 7642af36f4fa406307a11a3c7906d8076f7c6748..b001dcebf8380e6a84bc7709e2815d33207be63a 100644 (file)
   align-items: center;\r
   padding: 7px 44px 7px 14px;\r
   font-size: 13px;\r
-  color: #6c756e;\r
+  color: black;\r
 \r
   .icon {\r
     margin-right: 5px;\r
     }\r
 \r
     .slide-item {\r
+      color: black;\r
       display: -webkit-box;\r
       display: -ms-flexbox;\r
       display: flex;\r
index bf70b224f6e4233eb45cc00bd54b48dc3ff5e75c..3c975a2118833697108a74037e504224a70aad87 100644 (file)
@@ -56546,7 +56546,39 @@ a.bg-blue-dark:focus {
 .side-menu {
     margin-bottom: 0;
     padding-bottom: 40px;
+    margin-top: 0px;
+}
+
+.menu-search {
     margin-top: 90px;
+    margin-left: 15px;
+}
+
+.menu-search #search {
+    padding-left: 29px;
+    border: 1px solid #fffff;
+    border-radius: 2.5px;
+    font-size: 16px;
+    transition: border-color 0.3s;
+    width: 90%;
+}
+
+.menu-search #search::placeholder { color: #5A5A5A; font-size:12px;}
+
+.menu-search .search-icon {
+    position: absolute;
+    left: 20px;
+    top: 12.6%;
+    transform: translateY(-50%);
+    width: 24px;
+    height: 24px;
+    color: #6a5acd !important;
+    pointer-events: none;
+}
+
+.menu-search #search:focus {
+    border-color: #664dc9!important;
+    outline: none;
 }
 
 .side-menu__item {
@@ -56653,16 +56685,21 @@ a.bg-blue-dark:focus {
 }
 
 .side-menu__label {
-    white-space: nowrap;
+    color: black;
+    font-weight: normal;
+    /* font-weight: 700; */
+    font-size: 14px;
+    /*font-weight: 700;*/
+    /*white-space: nowrap;*/
     -webkit-box-flex: 1;
     -ms-flex: 1 1 auto;
     flex: 1 1 auto;
-    font-size: 14px;
-    font-weight: 600;
+    /*font-weight: 300;*/
     letter-spacing: .6px;
     opacity: 1;
     height: auto;
     transition: width 0.3s cubic-bezier(0, 0, 0.2, 1);
+    /*font-family: 'Arial', sans-serif;*/
 }
 
 .slide.is-expanded .slide-menu {
@@ -56690,7 +56727,7 @@ a.bg-blue-dark:focus {
     align-items: center;
     padding: 7px 14px 7px 44px;
     font-size: 13px;
-    color: #6c756e;
+    color: black;
 }
 
 .slide-item .icon {
index bf70b224f6e4233eb45cc00bd54b48dc3ff5e75c..fb8ec0b6e33e6a8f61bff42792a686baeab2836f 100644 (file)
@@ -56653,13 +56653,13 @@ a.bg-blue-dark:focus {
 }
 
 .side-menu__label {
-    white-space: nowrap;
+    /*white-space: nowrap;*/
     -webkit-box-flex: 1;
     -ms-flex: 1 1 auto;
     flex: 1 1 auto;
-    font-size: 14px;
-    font-weight: 600;
-    letter-spacing: .6px;
+    font-size: 12px;
+    font-weight: 300;
+    /*letter-spacing: .6px;*/
     opacity: 1;
     height: auto;
     transition: width 0.3s cubic-bezier(0, 0, 0.2, 1);