<?php

use yiister\gentelella\widgets\Menu;
use app\models\Messages;
use app\models\Bidding;

$bids_count = Bidding::find()->where([(Yii::$app->user->can('member') ? 'user_id' : 'org_id') => Yii::$app->user->id, 'readed' => 0])->count();

if (Yii::$app->user->can('admin')) {
    ?>
    <?= Menu::widget(
        [
            "items" => [
                [
                    "label" => Yii::t('app', 'Статистика'),
                    "url" => ['/statistics'],
                    "icon" => "bar-chart",
                ],
                [
                    "label" => Yii::t('app', 'Publishing ID'),
                    "url" => ['/publishing'],
                    "icon" => "folder-open",
                ],
                [
                    "label" => Yii::t('app', 'News'),
                    "url" => ['/blog-posts'],
                    "icon" => "folder-open",
                ],
                [
                    "label" => Yii::t('app', 'Bidding ID'),
                    "url" => ['/bidding'],
                    "icon" => "envelope",
                    "badge" => $bids_count,
                    "badgeOptions" => ["class" => $bids_count ? "label-danger" : 'hidden'],
                ],
                [
                    "label" => Yii::t('app', 'Аукціони'),
                    "url" => '#',
                    "icon" => "money",
                    "items" => [
                        [
                            "label" => Yii::t('app', 'AukName ID'),
                            "url" => ["/auctions"],
                        ],
                        // [
                        //     "label" => Yii::t('app', 'Template ID'),
                        //     "url" => ["/auclots"],
                        // ],
                        [
                            "label" => Yii::t('app', 'Lots ID'),
                            "url" => ["/lots"],
                        ],
                    ],
                ],
                [
                    "label" => Yii::t('app', 'Subscriptions'),
                    "url" => ['/subscriptions'],
                    "icon" => "plane",
                ],
                [
                    "label" => Yii::t('app', 'Файли'),
                    "url" => ['/files'],
                    "icon" => "database",
                ],
                [
                    "label" => Yii::t('app', 'Bills'),
                    "url" => ['/bills'],
                    "icon" => "credit-card",
                ],
                [
                    "label" => Yii::t('app', 'Settings ID'),
                    "url" => '#',
                    "icon" => "cog",
                    "items" => [
                        [
                            "label" => Yii::t('app', 'Profile'),
                            "url" => ["/settings/profile"],
                        ],
                        [
                            "label" => Yii::t('app', 'Manage users'),
                            "url" => ["/user/admin"],
                        ],
                        [
                            "label" => Yii::t('app', 'Одиниці виміру'),
                            "url" => ["/units"],
                        ],
                        [
                            "label" => Yii::t('app', 'Categories ID'),
                            "url" => ["/category"],
                        ],
                        [
                            "label" => Yii::t('app', 'Requisites'),
                            "url" => ["/requisites"],
                        ],
                        [
                            "label" => Yii::t('app', 'Bills'),
                            "url" => ["/settings/bills-template"],
                        ],
                        [
                            "label" => Yii::t('app', 'DocumentsToTheUser ID'),
                            "url" => ["/documents-to-the-user"],
                        ],
                    ],
                ],
                [
                    "label" => Yii::t('app', 'EventLog ID'),
                    "url" => ["/eventlog"],
                    "icon" => "list",
                ],
                [
                    "label" => Yii::t('app', 'Довідка'),
                    "url" => ['#'],
                    "icon" => "comment",
                    "items" => [
                        [
                            "label" => Yii::t('app', 'Керівництва'),
                            "url" => ["#"],
                        ],
                        [
                            "label" => Yii::t('app', 'Правила проведення торгів'),
                            "url" => ["#"],
                        ],
                        [
                            "label" => Yii::t('app', 'Зразки заяв'),
                            "url" => ["#"],
                        ],
                        [
                            "label" => Yii::t('app', 'Регламент'),
                            "url" => ["#"],
                        ],
                    ],
                ],
            ],
        ]
    );
}
?>
<?php
if (Yii::$app->user->can('member')) {
    ?>
    <?= Menu::widget(
        [
            "items" => [
                [
                    "label" => Yii::t('app', 'Статистика'),
                    "url" => '/statistics/user',
                    "icon" => "bar-chart",
                ],
                [
                    "label" => Yii::t('app', 'Publishing ID'),
                    "url" => ['/publishing'],
                    "icon" => "folder-open",
                ],
                [
                    "label" => Yii::t('app', 'Bidding ID'),
                    "url" => ['/bidding/view'],
                    "icon" => "envelope",
                    "badge" => $bids_count,
                    "badgeOptions" => ["class" => $bids_count ? "label-danger" : 'hidden'],
                ],
                [
                    "label" => Yii::t('app', 'Прийняти участь'),
                    "url" => ['/auctions'],
                    "icon" => "money",
                ],
                [
                    "label" => Yii::t('app', 'Bills'),
                    "url" => ['/bills'],
                    "icon" => "credit-card",

                ],
                [
                    "label" => Yii::t('app', 'Subscriptions'),
                    "url" => ['/subscriptions'],
                    "icon" => "plane",
                ],
                [
                    "label" => Yii::t('app', 'Settings ID'),
                    "url" => '#',
                    "icon" => "cog",
                    "items" => [
                        [
                            "label" => Yii::t('app', 'Profile'),
                            "url" => ["/settings/profile"],
                        ],
                        [
                            "label" => Yii::t('app', 'Requisites'),
                            "url" => ["/requisites/index?id=" . Yii::$app->user->identity->id,]
                        ],
                    ],
                ],
                [
                    "label" => Yii::t('app', 'Довідка'),
                    "url" => ['#'],
                    "icon" => "comment",
                    "items" => [
                        [
                            "label" => Yii::t('app', 'Керівництва'),
                            "url" => ["#"],
                        ],
                        [
                            "label" => Yii::t('app', 'Правила проведення торгів'),
                            "url" => ["#"],
                        ],
                        [
                            "label" => Yii::t('app', 'Зразки заяв'),
                            "url" => ["#"],
                        ],
                        [
                            "label" => Yii::t('app', 'Регламент'),
                            "url" => ["#"],
                        ],
                    ],
                ],
            ]
        ]
    );
}
?>
<?php
if (Yii::$app->user->can('org')) {
    ?>
    <?= Menu::widget(
        [
            "items" => [
                [
                    "label" => Yii::t('app', 'Статистика'),
                    "url" => '/statistics/user',
                    "icon" => "bar-chart",
                ],
                [
                    "label" => Yii::t('app', 'Publishing ID'),
                    "url" => ['/publishing'],
                    "icon" => "folder-open",
                ],
                [
                    "label" => Yii::t('app', 'Bidding ID'),
                    "url" => ['/bidding/view'],
                    "icon" => "envelope",
                    "badge" => $bids_count,
                    "badgeOptions" => ["class" => $bids_count ? "label-danger" : 'hidden'],
                ],
                [
                    "label" => Yii::t('app', 'Прийняти участь'),
                    "url" => ['/auctions'],
                    "icon" => "money",
                ],
                [
                    "label" => Yii::t('app', 'Аукціони'),
                    "url" => '#',
                    "icon" => "money",
                    "items" => [
                        [
                            "label" => Yii::t('app', 'AukName ID'),
                            "url" => ["/auctions"],
                        ],
                        // [
                        //     "label" => Yii::t('app', 'Template ID'),
                        //     "url" => ["/auclots"],
                        // ],
                        [
                            "label" => Yii::t('app', 'Lots ID'),
                            "url" => ["/lots"],
                        ],
                    ],
                ],
                [
                    "label" => Yii::t('app', 'Bills'),
                    "url" => ['/bills'],
                    "icon" => "credit-card",

                ],
                [
                    "label" => Yii::t('app', 'Subscriptions'),
                    "url" => ['/subscriptions'],
                    "icon" => "plane",
                ],
                [
                    "label" => Yii::t('app', 'Settings ID'),
                    "url" => '#',
                    "icon" => "cog",
                    "items" => [
                        [
                            "label" => Yii::t('app', 'Profile'),
                            "url" => ["/settings/profile"],
                        ],
                        [
                            "label" => Yii::t('app', 'Requisites'),
                            "url" => ["/requisites/index?id=" . Yii::$app->user->identity->id,]
                        ],
                    ],
                ],
                [
                    "label" => Yii::t('app', 'Довідка'),
                    "url" => ['#'],
                    "icon" => "comment",
                    "items" => [
                        [
                            "label" => Yii::t('app', 'Керівництва'),
                            "url" => ["#"],
                        ],
                        [
                            "label" => Yii::t('app', 'Правила проведення торгів'),
                            "url" => ["#"],
                        ],
                        [
                            "label" => Yii::t('app', 'Зразки заяв'),
                            "url" => ["#"],
                        ],
                        [
                            "label" => Yii::t('app', 'Регламент'),
                            "url" => ["#"],
                        ],
                    ],
                ],
            ]
        ]
    );
}
?>
