<?php if (!defined('ROOT')){ echo 'Deny ...'; exit; } extract($data); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>MAIN</title>
        <link href="<?php echo $base_url; ?>static/css/style.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="<?php echo $base_url; ?>static/js/jquery.js"></script>
        <script type="text/javascript" src="<?php echo $base_url; ?>static/js/common.js"></script>
    </head>
    <body>
        <div class="place">
            <span>位置：</span>
            <ul class="placeul">
                <li><a href="<?php echo $base->get_url(array('c' => 'frame', 'm' => 'main')); ?>">首页</a></li>
                <li>管理员</li>
            </ul>
        </div>
        <div class="formbody">
            <div class="usual"> 
                <div class="tabson">
                    <div class="tools">
                        <ul class="toolbar">
                            <li class="click" onclick="location.href = '<?php echo $base->get_url(array('c' => 'manager', 'm' => 'create')); ?>';"><span><img src="<?php echo $base_url; ?>static/images/t01.png"></span>新增管理员</li>
                        </ul>
                    </div>
                    <table class="tablelist">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>管理员名称</th>
                                <th>模块</th>
                                <th>用户组</th>
                                <th>更新时间</th>
                                <th>更新IP</th>
                                <th>是否激活</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $channels = service::channels();
                            if ($result['lists']) {
                                foreach ($result['lists'] as $item) {
                                    $modelID = $groups[$item['level']]['model_id'];
                                    ?>
                                    <tr>
                                        <td><?php echo $item['id']; ?></td>
                                        <td><?php echo $item['username']; ?></td>
                                        <td><?php echo $channels[$modelID]['name'].'('.$channels[$modelID]['path'].')';?></td>
                                        <td><?php echo $groups[$item['level']]['name']; ?></td>
                                        <td><?php echo date('Y-m-d H:i', $item['lasttime']); ?></td>
                                        <td><?php echo $item['lastip']; ?></td>
                                        <td><?php echo $item['checked'] ? '<font color="green">已激活</font>' : '<del>已禁用</del>'; ?></td>
                                        <td>
                                            <a href="<?php echo $base->get_url(array('c' => 'manager', 'm' => 'edit', 'id' => $item['id']));?>" class="tablelink">[编辑]</a>
                                            <a href="javascript:;" class="tablelink" onclick="_delete(<?php echo $item['id'];?>, '<?php echo $item['username'];?>');">[删除]</a>
                                        </td>
                                    </tr>
                                    <?php
                                }
                            }
                            ?>                             
                        </tbody>
                    </table>
                    <div style="margin-top: 12px;"><?php echo $result['pager']; ?><br style="clear: both;"/></div>
                </div>  
            </div> 
        </div>
        
        <?php echo form::alert('deleteAdmin', $base_url);?>  
        <?php echo form::alert_confirm('deleteAdmin', $base->get_url(array('c' => 'manager', 'm' => 'delete')), form::create_nonce($admin['id'], 'deleteAdmin'));?>
        
        <script>
            function _delete(id, name){
                $('.deleteAdmin .tipright p').html('确认要删除 <font color="red">' + name + '</font> 吗?');
                $(".deleteAdmin").fadeIn(200);
                $('#_id').val(id);                
            }            
            $(function(){
                $('.tablelist tbody tr:odd').addClass('odd');
            });
        </script>
    </body>
</html>
