<?php $this->widget('admin.widgets.TableCover');?>
<script type="text/javascript">
<!--
function addMember(self) {
	var html = '<tr><td></td><td><?php echo CHtml::textField('add[title][]','',array('size'=>10));?></td><td><?php echo CHtml::textField('add[title1][]','',array('size'=>10));?></td><td><?php echo CHtml::textField('add[title2][]','',array('size'=>10));?></td><td></td><td><?php echo CHtml::textField('add[creditshigher][]');?></td><td></td><td><?php echo CHtml::link('删除','javascript:void(0);',array('onclick'=>'delMember(this)'));?></td></tr>';
	$(self).parent().parent().parent().append(html);
}

function delMember(self) {
	$(self).parent().parent().remove();
}

function addGroup(self) {
	var html = '<tr><td></td><td><?php echo CHtml::textField('add[title][]','');?></td><td><?php echo CHtml::textField('add[title1][]','');?></td><td><?php echo CHtml::textField('add[title2][]','');?></td><td></td><td><?php echo CHtml::link('删除','javascript:void(0);',array('onclick'=>'delGroup(this)'));?></td></tr>';
	$(self).parent().parent().parent().append(html);
}

function delGroup(self) {
	$(self).parent().parent().remove();
}
//-->
</script>

<h2>用户组设置</h2>
<div class="form">
<fieldset>
    <legend>会员组编辑</legend>
<?php echo CHtml::beginForm(array('/admin/usergroups/member'));?>
    <table class="widefat post">
    <thead>
		<tr>
			<th>组ID</th>
			<th>头衔</th>
			<th>男</th>
			<th>女</th>
			<th>等级图片</th>
			<th>积分大于</th>
			<th>积分小于</th>
			<th>操作</th>
		</tr>
	</thead>
    <tbody>
    	<?php foreach ($level['member'] as $member):?>
    	<tr>
    		<td><?php echo $member->groupid;?></td>
    		<td><?php echo CHtml::textField('group['.$member->groupid.'][title]',$member->grouptitle,array('size'=>10));?></td>
    		<td><?php echo CHtml::textField('group['.$member->groupid.'][title1]',$member->grouptitle1,array('size'=>10));?></td>
    		<td><?php echo CHtml::textField('group['.$member->groupid.'][title2]',$member->grouptitle2,array('size'=>10));?></td>
    		<td><?php echo CHtml::image($member->getImageUrl(), $member->grouptitle);?></td>
    		<td><?php echo CHtml::textField('group['.$member->groupid.'][creditshigher]',$member->creditshigher);?></td>
    		<td><?php echo $member->creditslower;?></td>
    		<td>[<?php echo CHtml::link('权限',array('/admin/usergroups/permission','gid'=>$member->groupid));?>] [<?php echo CHtml::link('删除',array('/admin/usergroups/delete','gid'=>$member->groupid),array('confirm'=>'确定删除？'));?>]</td>
    	</tr>
    	<?php endforeach;?>
    	
    	<tr>
    		<td>新增:[<?php echo CHtml::link('+','javascript:void(0);',array('onclick'=>'addMember(this);'));?>]</td>
    		<td><?php echo CHtml::textField('add[title][]','',array('size'=>10));?></td>
    		<td><?php echo CHtml::textField('add[title1][]','',array('size'=>10));?></td>
    		<td><?php echo CHtml::textField('add[title2][]','',array('size'=>10));?></td>
    		<td></td>
    		<td><?php echo CHtml::textField('add[creditshigher][]');?></td>
    		<td></td>
    		<td></td>
    	</tr>
    </tbody>
    </table>
    <?php echo CHtml::submitButton('提交');?>
<?php echo CHtml::endForm();?>
</fieldset>

<fieldset>
    <legend>系统组编辑</legend>
    <?php echo CHtml::beginForm(array('/admin/usergroups/create','type'=>'system'));?>
    <table class="widefat post">
    <thead>
		<tr>
			<th>组ID</th>
			<th>头衔</th>
			<th>男</th>
			<th>女</th>
			<th>等级图片</th>
			<th>操作</th>
		</tr>
	</thead>
    <tbody>
    	<?php foreach ($level['system'] as $member):?>
    	<tr>
    		<td><?php echo $member->groupid;?></td>
    		<td><?php echo CHtml::textField('group['.$member->groupid.'][title]', $member->grouptitle);?></td>
    		<td><?php echo CHtml::textField('group['.$member->groupid.'][title1]', $member->grouptitle1);?></td>
    		<td><?php echo CHtml::textField('group['.$member->groupid.'][title2]', $member->grouptitle2);?></td>
    		<td><?php echo CHtml::image($member->getImageUrl(), $member->grouptitle);?></td>
    		<td>[<?php echo CHtml::link('权限',array('/admin/usergroups/permission','gid'=>$member->groupid));?>]</td>
    	</tr>
    	<?php endforeach;?>
    	<tr>
    		<td>新增:[<?php echo CHtml::link('+','javascript:void(0);',array('onclick'=>'addGroup(this);'));?>]</td>
    		<td><?php echo CHtml::textField('add[title][]', '');?></td>
    		<td><?php echo CHtml::textField('add[title1][]', '');?></td>
    		<td><?php echo CHtml::textField('add[title2][]', '');?></td>
    		<td></td>
    		<td>[删除]</td>
    	</tr>
    </tbody>
    </table>
    <?php echo CHtml::submitButton('提交');?>
    <?php echo CHtml::endForm();?>
</fieldset>

<fieldset>
    <legend>特殊组编辑</legend>
    <?php echo CHtml::beginForm(array('/admin/usergroups/create','type'=>'special'));?>
    <table class="widefat post">
    <thead>
		<tr>
			<th>组ID</th>
			<th>头衔</th>
			<th>男</th>
			<th>女</th>
			<th>等级图片</th>
			<th>操作</th>
		</tr>
	</thead>
    <tbody>
        <?php if ($level['special']):?>
    	<?php foreach ($level['special'] as $member):?>
    	<tr>
    		<td><?php echo $member->groupid;?></td>
    		<td><?php echo CHtml::textField('group['.$member->groupid.'][title]',$member->grouptitle);?></td>
    		<td><?php echo CHtml::textField('group['.$member->groupid.'][title1]',$member->grouptitle1);?></td>
    		<td><?php echo CHtml::textField('group['.$member->groupid.'][title2]',$member->grouptitle2);?></td>
    		<td><?php echo CHtml::image($member->getImageUrl(), $member->grouptitle);?></td>
    		<td>[<?php echo CHtml::link('权限',array('/admin/usergroups/permission','gid'=>$member->groupid));?>] [<?php echo CHtml::link('删除',array('/admin/usergroups/delete','gid'=>$member->groupid),array('confirm'=>'确定删除？'));?>]</td>
    	</tr>
    	<?php endforeach;?>
        <?php endif;?>
    	<tr>
    		<td>新增:[<?php echo CHtml::link('+','javascript:void(0);',array('onclick'=>'addGroup(this);'));?>]</td>
    		<td><?php echo CHtml::textField('add[title][]','');?></td>
    		<td><?php echo CHtml::textField('add[title1][]','');?></td>
    		<td><?php echo CHtml::textField('add[title2][]','');?></td>
    		<td></td>
    		<td>[删除]</td>
    	</tr>
    </tbody>
    </table>
    <?php echo CHtml::submitButton('提交');?>
    <?php echo CHtml::endForm();?>
</fieldset>

</div>