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;
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
--- /dev/null
+<?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
</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"]);
$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>
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"]);
$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>
", \yii\web\View::POS_BEGIN, 'api2_menu_init_global_vars');
$this->registerJsFile('/js/site/get_menu.js', ['position' => \yii\web\View::POS_END]);
+
+
+
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>
</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'])): ?>
</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>
<?= 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 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) { ?>
</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>
.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 {
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
.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 {
}
.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 {
align-items: center;
padding: 7px 14px 7px 44px;
font-size: 13px;
- color: #6c756e;
+ color: black;
}
.slide-item .icon {
}
.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);