Exemplo n.º 1
0
    public function Role2Menu()
    {
        $t = time();
        //create matrix to adjust menu
        $arrMenu = Registor::getAllAdminMenuFromSession();
        ?>
<div class="table-responsive">
    <table class="table table-bordered table-striped table-hover">
        <thead>
            <tr>
                <td><?php 
        echo Lang::t('Menu');
        ?>
</td>
                <td><?php 
        echo Lang::t('Min-Role');
        ?>
</td>
            </tr>
        </thead>
        <tbody>
            <?php 
        $r = new Role();
        $existingRoles = $r->getWhere("role_active = 1 ORDER BY role_id ASC");
        foreach ($arrMenu as $menu) {
            $role = Role2Menu::getRoleForMenu($menu);
            ?>
            <tr>
                <td><?php 
            echo $menu;
            ?>
</td>
                <td>
                    <select id="role_select_<?php 
            echo $menu;
            ?>
_<?php 
            echo $t;
            ?>
">
                <?php 
            foreach ($existingRoles as $ro) {
                ?>
                
                        <option value="<?php 
                echo $ro->role_id;
                ?>
" <?php 
                if ($ro->role_id == $role) {
                    echo "selected";
                }
                ?>
><?php 
                echo $ro->role_id;
                ?>
</option>
                <?php 
            }
            ?>
                    </select>
                    <script>
                    $("#role_select_<?php 
            echo $menu;
            ?>
_<?php 
            echo $t;
            ?>
").change(function(){
                        var slc = $("#role_select_<?php 
            echo $menu;
            ?>
_<?php 
            echo $t;
            ?>
").val();
                       $.get("<?php 
            echo _SPPATH;
            ?>
RoleWeb/ins?menu=<?php 
            echo base64_encode($menu);
            ?>
&role_id="+slc); 
                    });    
                    </script>
                </td>
            </tr>
            <?php 
        }
        ?>
        </tbody>
       
    </table>
</div>    
        <?php 
    }