<?php if (!defined('ROOT')){ echo 'Deny ...'; exit; } extract($data); ?>
<?php echo $search;?>
<table class="tablelist">
    <thead>
        <tr>
            <th width="100">ID</th>
            <?php foreach ($shows as $show){?>
            <th><?php echo $show['tag'];?></th>
            <?php }?>
            <th>更新时间</th>
            <th>操作</th>
            <?php echo service::do_action('table_option_plus_th', array($base, $base->tid));?>
        </tr>
    </thead>
    <tbody>
        <?php
        if ($result['lists']) {
            foreach ($result['lists'] as $item) {
        ?>
        <tr>
            <td><?php echo $item['id'];?></td>
            <?php foreach ($shows as $show){?>
            <td>
                <?php
                $value = '';
                switch ($show['_form']){
                    case 'select':
                    case 'radio':
                    case 'radio_int':
                    case 'select_int':
                        if ($fields[$show['name']]['content']){
                            $value = $fields[$show['name']]['content'][$item[$show['name']]]['name'];
                        }else{
                            if ($fields[$show['name']]['connect_id']){
                                $value = $item[$show['name'].'_value'];
                            }else{
                                $value = $item[$show['name']];
                            }
                        }
                        break;
                    case 'checkbox':
                        if ($item[$show['name']]){
                            $exItem = explode(',', $item[$show['name']]);
                            $exValue = array();
                            foreach ($exItem as $id){
                                $exValue[] = $fields[$show['name']]['content'][$id]['name'];
                            }
                            $value = implode(', ', $exValue);
                        }
                        break;
                    case 'singleImage':
                        $value = '<img src="'.$item[$show['name']].'?imageView/1/w/24/h/24" width="24" height="24"/>';
                        break;
                    case 'timepicker':
                        $value = $item[$show['name']] ? date('Y-m-d H:i', $item[$show['name']]) : '--';
                        break;
                    default:
                        if ($fields[$show['name']]['connect_id']){
                            $value = $item[$show['name'].'_value'];
                        }else{
                            $value = $item[$show['name']];
                        }
                        break;
                }
                echo $value ? $value : '--';
                ?>
            </td>
            <?php }?>
            <?php
            if ($_fid_input){
                $edit = array('c' => $controller, 'm' => 'edit', 'id' => $item['id'], '_fid' => $_fid_input['id'], '_from' => $from);
            }else{
                $edit = array('c' => $controller, 'm' => 'edit', 'id' => $item['id'], '_from' => $from);
            }
            ?>
            <td><?php echo date('Y-m-d H:i', $item['dateline']);?></td>
            <td width="200">
                <a href="<?php echo $base->get_model_url($edit);?>" class="tablelink">[编辑]</a>
                <a href="javascript:;" class="tablelink" onclick="_delete(<?php echo $item['id'];?>);">[删除]</a>
                <?php if ($next){?>
                <select style="opacity: 1;border: 1px solid #ddd; margin-left: 6px;" onchange="_jump(this.value);">
                    <option value="">-- 选择 --</option>
                    <?php foreach ($next as $ext){?>
                    <option value="<?php echo $base->get_model_url(array('c' => $ext['name'], '_fid' => $item['id']));?>">[<?php echo $ext['tag'];?>管理]</option>
                    <?php }?>
                </select>
                <?php }?>
            </td>
            <?php echo service::do_action('table_option_plus_td', array($base, $base->tid, $item));?>
        </tr>
        <?php
            }
        }
        ?>
    </tbody>
</table>
<div style="margin-top: 12px;"><?php echo $result['pager']; ?><br style="clear: both;"/></div>

<?php echo form::alert('delete'.$controller, $base_url);?>
<?php echo form::alert_confirm('delete'.$controller, $base->get_model_url(array('c' => $controller, 'm' => 'delete')), form::create_nonce($admin['id'], 'delete'.$controller));?>
<script>
    function _delete(id){
        $('.delete<?php echo $controller;?> .tipright p').html('确认要删除ID: <font color="red">' + id + '</font> 的数据吗?');
        $(".delete<?php echo $controller;?>").fadeIn(200);
        $('.delete<?php echo $controller;?> #_id').val(id);                
    }
    function _jump(url){
        if (url){
            location.href = url;
        }
    }
</script>