<?php if (defined('AAM_KEY')) { ?>
    <div class="aam-feature" id="admin_menu-content">
        <div class="row">
            <div class="col-xs-12">
                <p class="aam-info">
                    <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('Protect your backend area. The list of menus and submenus is based on capabilities [%s] has. For more information please check %sHow to manage WordPress backend menu%s.', 'b', 'b'), AAM_Backend_Subject::getInstance()->getName(), '<a href="https://aamplugin.com/help/how-to-manage-wordpress-backend-menu" target="_blank">', '</a>'); ?>
                </p>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12">
                <div class="aam-overwrite" id="aam-menu-overwrite" style="display: <?php echo ($this->isOverwritten() ? 'block' : 'none'); ?>">
                    <span><i class="icon-check"></i> <?php echo __('Settings are customized', AAM_KEY); ?></span>
                    <span><a href="#" id="menu-reset" class="btn btn-xs btn-primary"><?php echo __('Reset To Default', AAM_KEY); ?></a>
                </div>
            </div>
        </div>

        <div class="panel-group" id="admin-menu" role="tablist" aria-multiselectable="true">
            <?php
            $first  = false;
            $object = AAM_Backend_Subject::getInstance()->getObject('menu');
            foreach ($this->getMenu() as $i => $menu) {
                ?>
                <div class="panel panel-default">
                    <div class="panel-heading" role="tab" id="menu-<?php echo $i; ?>-heading">
                        <h4 class="panel-title">
                            <a role="button" data-toggle="collapse" data-parent="#admin-menu" href="#menu-<?php echo $i; ?>" aria-controls="menu-<?php echo $i; ?>" <?php if (!$first) { echo 'aria-expanded="true"'; } ?>>
                                <?php echo $menu['name']; ?> <small class="aam-menu-capability"><?php echo $menu['capability']; ?></small>
                            </a>
                            <?php if ($object->has($menu['id'])) { ?>
                                <i class="aam-panel-title-icon icon-eye-off text-danger"></i>
                            <?php } elseif ($this->hasSubmenuChecked($object, $menu['submenu'])) { ?>
                                <i class="aam-panel-title-icon icon-attention-circled text-warning"></i>
                            <?php } ?>
                        </h4>
                    </div>

                    <div id="menu-<?php echo $i; ?>" class="panel-collapse collapse<?php if (!$first) { echo ' in'; $first = true; } ?>" role="tabpanel" aria-labelledby="menu-<?php echo $i; ?>-heading">
                        <div class="panel-body">
                            <?php if (!empty($menu['submenu'])) { ?>
                                <div class="row">
                                    <?php echo ($object->has($menu['id']) ? '<div class="aam-lock"></div>' : ''); ?>
                                    <?php foreach ($menu['submenu'] as $j => $submenu) { ?>
                                        <?php if ($submenu['id'] == 'index.php') { ?>
                                            <div class="col-xs-12 col-md-6 aam-submenu-item">
                                                <label for="menu-item-<?php echo $i . $j; ?>"><?php echo $submenu['name']; ?> <small class="aam-menu-capability"><?php echo $submenu['capability']; ?></small></label>
                                                <a href="#dashboard-lockout-modal" data-toggle="modal"><i class="icon-help-circled"></i></a>
                                            </div>
                                        <?php } else { ?>
                                            <div class="col-xs-12 col-md-6 aam-submenu-item">
                                                <label for="menu-item-<?php echo $i . $j; ?>"><?php echo $submenu['name']; ?> <small class="aam-menu-capability"><?php echo $submenu['capability']; ?></small></label>
                                                <input type="checkbox" class="aam-checkbox-danger" id="menu-item-<?php echo $i . $j; ?>" data-menu-id="<?php echo $submenu['id']; ?>"<?php echo ($object->has($submenu['id']) ? ' checked="checked"' : ''); ?> />
                                                <label for="menu-item-<?php echo $i . $j; ?>" data-toggle="tooltip" title="<?php echo ($object->has($submenu['id']) ?  __('Uncheck to allow', AAM_KEY) : __('Check to restrict', AAM_KEY)); ?>"></label>
                                            </div>
                                        <?php } ?>
                                    <?php } ?>
                                </div>
                            
                                <hr class="aam-divider" />
                            <?php } ?>

                            <div class="row<?php echo (!empty($menu['submenu']) ? ' aam-margin-top-xs' : ''); ?>">
                                <div class="col-xs-10 col-md-6 col-xs-offset-1 col-md-offset-3">
                                    <?php if ($object->has($menu['id'])) { ?>
                                        <a href="#" class="btn btn-primary btn-sm btn-block aam-restrict-menu" data-menu-id="<?php echo $menu['id']; ?>" data-target="#menu-<?php echo $i; ?>">
                                            <i class="icon-eye"></i> <?php echo __('Show Menu', AAM_KEY); ?>
                                        </a>
                                    <?php } else { ?>
                                        <a href="#" class="btn btn-danger btn-sm btn-block aam-restrict-menu" data-menu-id="<?php echo $menu['id']; ?>" data-target="#menu-<?php echo $i; ?>">
                                            <i class="icon-eye-off"></i> <?php echo __('Restrict Menu', AAM_KEY); ?>
                                        </a>
                                    <?php } ?>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            <?php } ?>
        </div>
        
        <div class="modal fade" id="dashboard-lockout-modal" tabindex="-1" role="dialog">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="<?php echo __('Close', AAM_KEY); ?>"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title"><?php echo __('Dashboard Lockdown', AAM_KEY); ?></h4>
                    </div>
                    <div class="modal-body">
                        <p class="text-center alert alert-warning text-larger">
                            <strong><?php echo __('You cannot restrict access to Dashboard home page.', AAM_KEY); ?></strong><br/>
                            <?php echo sprintf(AAM_Backend_View_Helper::preparePhrase('The [Home] is the default page every user is redirected after login. To restrict access to the entire backend, please check %sHow to lockdown WordPress backend%s article.', 'b'), '<a href="https://aamplugin.com/help/how-to-lockdown-wordpress-backend" target="_blank">', '</a>'); ?>
                        </p>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal"><?php echo __('OK', AAM_KEY); ?></button>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php }