<?php
$menu_modules = unserialize($this->request->session()->read('modules'));
$current_action = $this->request->params['action'];
$current_sub_module = $this->request->params['controller'];
//dd($permissions,$nav_arr);
?>

<?php
//$this->log($current_sub_module);
switch ($current_sub_module) {
    case "Cmsusers":
        $icon = '<span class="glyphicon glyphicon-user"></span>';
        break;
    case "Roles":
        $icon = '<span class="glyphicon glyphicon-file"></span>';
        break;
    case "Usergroups":
        $icon = '<span class="glyphicon glyphicon-file"></span>';
        break;
    case "UserGroupRoleAssociation":
        $icon = '<span class="glyphicon glyphicon-file"></span>';
        break;
    case "RolePagesAssociation":
        $icon = '<span class="glyphicon glyphicon-file"></span>';
        break;
    case "default":
        $icon = '<span class="glyphicon glyphicon-file"></span>';
        break;
}
?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.min.js"></script>
<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <div class="box-body">
                <div class="row">
                    <div class="col-md-4">
                        <h3 class="box-title no-margin"><?php echo $icon ?><?= $title ?></h3>
                    </div>

                    <div class="col-md-8">
                        <div class="row">
                            <div class="col-md-12 text-right">
                                <?php
                                foreach ($permissions as $permission) {
                                    foreach($nav_arr as $nav){
                                        if ($permission['page_id'] == $nav['page_id']){?>

                                            <a href="<?php echo $this->Url->build(["action" => $nav['action']]); ?>" class="btn btn-success btn-flat btn-grid">
                                                <?php echo $nav['icon']; ?>
                                                <?php echo __($nav['label']) ?>
                                            </a>

                                <?php  } } } ?>

                            </div>


                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</div>