<?php
/* @var $this ExammanageController */
/* @var $model Exammanage */
/* @var $form CActiveForm */
?>
<script type="text/javascript">
	$(function(){
	//单选
		$('#tt').tree({
			url:'<?php echo $this->createUrl('category/mytree')?>',
			animate:true,
			lines:true,
			cascadeCheck:false,
			onClick: function(node){
				$(this).tree('check',node.target);
				if(node.checked)
				{$(this).tree('uncheck',node.target);}
				
			},
			onCheck:function(){
				var nodes = $('#tt').tree('getChecked');
				var s = '';  
					for(var i=0; i<nodes.length; i++){  
						if (s != '') s += ',';  
						s += nodes[i].id;  
					}  
					//alert(s);
				if(s.length!=0 || 1){
					var queryParams = $('#single_table').datagrid('options').queryParams; 
					queryParams.charpter_id = s;  
					$('#single_table').datagrid('options').queryParams=queryParams;        
					$("#single_table").datagrid('reload'); 	
				}
				
			}
		});

	//判断	
//单选题选择表-----》开始
		$('#single_table').datagrid({  
			title:'单选题列表',
			striped:true,
			pagination:true,
			//queryParams:{pageSize:'10',page:'10'},
			remoteSort:true,
			sortName: 'id',
			sortOrder: 'asc',
			url:"<?php echo $this->createUrl('qq'); ?>",  
			//idField:"id",
			//checkbox:false,
			fitColumns:true,
			toolbar:[{
					id:'btnRemove',
					iconCls: 'icon-add',
					text:'选择',
					disabled:true,
					handler: function(){
						var rows = $('#single_table').datagrid('getSelections');
						var uprow = [];
							for(var i=0;i<rows.length;i++){
								uprow.push(rows[i]['id']);
							}
						//alert(JSON.stringify(uprow));
						
								$.messager.confirm('确认','确定要选择吗？',function(r){
								if (r){


										$.ajax({
											  type: 'POST',
											  url: '<?php echo $this->createUrl('selectall')?>',
											  data: {action:'selectsingle',qq:JSON.stringify(uprow)},
											  success: function(data){//alert(data);
												   //if(data=="yes"){
													$.messager.alert('系统提示',data,'info');
													$('#single_table').datagrid('reload');
													$('#btnRemove').linkbutton('disable');
													//$('#btnSave').linkbutton('disable');
												   //}else $.messager.alert('系统提示','更新失败!','info');
											   
											   },
											  dataType: "text"
										});	

								
								}
							});
	
					}},'-',{
                    id:'btnAllon',
					iconCls: 'icon-remove',
					text:'重新选择',
					handler: function(){
					
						var rows = $('#single_table').datagrid('getSelections');
						var uprow = [];
							for(var i=0;i<rows.length;i++){
								uprow.push(rows[i]);
							}
						//alert(JSON.stringify(uprow));
						
								$.messager.confirm('确认','确定要重新选择吗？',function(r){
								if (r){


										$.ajax({
											  type: 'POST',
											  url: '<?php echo $this->createUrl('resetall')?>',
											  data: {action:'resetsingle'},
											  success: function(data){//alert(data);
												   //if(data=="yes"){
													$.messager.alert('系统提示',data,'info');
													$('#single_table').datagrid('reload');
													$('#btnRemove').linkbutton('disable');
													//$('#btnSave').linkbutton('disable');
												   //}else $.messager.alert('系统提示','更新失败!','info');
											   
											   },
											  dataType: "text"
										});	

								
								}
							});
					
						}
					},					
					],
			
			columns:[[  
				{field:'ck',checkbox:'true'}, 
				{field:'id',title:'ID',width:50,align:'center',sortable:true},  
				{field:'title',title:'标题',width:200,align:'center',sortable:true,editor:{type:'validatebox',options:{required:true}}}, 
				{field:'charpter_id',title:'所属章节',width:200,align:'center',sortable:true,editor:{type:'validatebox',options:{required:true}}},
				{field:'difficulty',title:'难度',width:50,align:'center',sortable:true,editor:{type:'validatebox',options:{required:true}}}, 
				{field:'frequency',title:'频率',width:50,align:'center',sortable:true,editor:{type:'validatebox',options:{required:true}}}, 
				{field:'forbidden',title:'禁用',width:50,align:'center',sortable:true,editor:{type:'checkbox',options:{"0":'P',"1":'Q'}}}, //这里的editor没用。可以取消
				{field:'created',title:'创建日期',width:150,align:'center',sortable:true,editor:{type:'validatebox',options:{required:true}}}, 
				{field:'modified',title:'修改日期',width:150,align:'center',sortable:true,editor:{type:'validatebox',options:{required:true}}}, 

			]],
            onSelect:function(index,row){
                $('#btnRemove').linkbutton('enable');
                },
			onUnselect:function(rowIndex, rowData){
				var rows = $('#single_table').datagrid('getSelections');
				if(rows.length==0) {
					$('#btnRemove').linkbutton('disable');
				}
				},
            onSelectAll:function(index,row){
                $('#btnRemove').linkbutton('enable');
                },
            onUnselectAll:function(index,row){
                $('#btnRemove').linkbutton('disable');
                } 			
		}); 
//单选题选择表-----》结束
	});
</script>
	<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css/tablesorter/themes/blue/style.css" type="text/css" media="print, projection, screen" />
	<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css/tablesorter/jquery.tablesorter.pager.css" type="text/css" media="print, projection, screen" />
	<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/css/tablesorter/jquery.tablesorter.min.js"></script>
	<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/css/tablesorter/jquery.tablesorter.pager.js"></script>
	<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/css/tablesorter/check.js"></script>
	<script type="text/javascript">
	$(function() {
		$("#single")
			//.tablesorter({headers: { 0: { sorter: false} ,1: { sorter: false}},widthFixed: true, widgets: ['zebra'],sortList:[[4,1],[5,1]]})//这个是完整的
			.tablesorter({headers: {0:{ sorter: false}},widthFixed: true, widgets: ['zebra'],sortList:[[4,1],[5,1]]})
			.tablesorterPager({container: $("#pager")});
		$("#thead_top").click(function(){
			$("input['chk_list']").attr("checked",$(this).attr("checked"));
		})

	});
	</script>
    <style type="text/css">
/*
	th,tr>td:first-child{text-align: center; vertical-align: middle;}
	*/

</style>







<div>

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'exammanage-form',
	'enableAjaxValidation'=>false,
)); ?>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>256)); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>
	<!--单选-->
	<div class="row">
			<?php echo $form->labelEx($model,'singlechoicelist'); ?>
	</div>
	<div><input onclick="single_cascade()" id="single_cascade_" type="button" value="启用级联选择" /><input id="single_leaf_" onclick="single_leaf()" type="button" value="启用仅选择叶子" /></div>
	
	<div class="easyui-layout" style="width:100%;height:367px;">
		<div data-options="region:'west',split:true" title="章节目录" style="width:250px;"><ul id="tt" checkbox="true"></ul></div>
		<div data-options="region:'center'" style="background:#fafafa;">
			<table id="single_table">  
			</table>
		</div>
	</div>
	
	<!--多选-->
	<div class="row">
		<?php echo $form->labelEx($model,'multichoicelist'); ?>
	</div>
	<div><input onclick="multi_cascade()" id="multi_cascade_" type="button" value="启用级联选择" /><input id="multi_leaf_" onclick="multi_leaf()" type="button" value="启用仅选择叶子" /></div>
	
	<div class="easyui-layout" style="width:100%;height:367px;">
		<div data-options="region:'west',split:true" title="章节目录" style="width:250px;"><ul id="tt2" checkbox="true"></ul></div>
		<div data-options="region:'center'" style="background:#fafafa;">
			<table id="multi_table">  
			</table>
		</div>
	</div>
	<!--判断-->
	<div class="row">
		<?php echo $form->labelEx($model,'judgelist'); ?>
	</div>
	<div><input onclick="judge_cascade()" id="judge_cascade_" type="button" value="启用级联选择" /><input id="judge_leaf_" onclick="judge_leaf()" type="button" value="启用仅选择叶子" /></div>
	
	<div class="easyui-layout" style="width:100%;height:367px;">
		<div data-options="region:'west',split:true" title="章节目录" style="width:250px;"><ul id="tt3" checkbox="true"></ul></div>
		<div data-options="region:'center'" style="background:#fafafa;">
			<table id="judge_table">  
			</table>
		</div>
	</div>
	<!--操作-->
	<div class="row">
		<?php echo $form->labelEx($model,'operatelist'); ?>
	</div>
	<div><input onclick="operate_cascade()" id="operate_cascade_" type="button" value="启用级联选择" /><input id="operate_leaf_" onclick="operate_leaf()" type="button" value="启用仅选择叶子" /></div>
	
	<div class="easyui-layout" style="width:100%;height:367px;">
		<div data-options="region:'west',split:true" title="章节目录" style="width:250px;"><ul id="tt4" checkbox="true"></ul></div>
		<div data-options="region:'center'" style="background:#fafafa;">
			<table id="operate_table">  
			</table>
		</div>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'testScore'); ?>
		<?php echo $form->textField($model,'testScore',array('size'=>32,'maxlength'=>32)); ?><label>注：各题型分值,包括单选、多选、判断、操作。格式：2,3,1,10</label>
		<?php echo $form->error($model,'testScore'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'testCount'); ?>
		<?php echo $form->textField($model,'testCount',array('size'=>32,'maxlength'=>32)); ?><label>注：是否限制各题型数量,包括单选、多选、判断、操作。格式同上，1表示不限制，限制数量格式为：20,10,5,3</label>
		<?php echo $form->error($model,'testCount'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'testRand'); ?>
		<?php echo $form->textField($model,'testRand',array('size'=>32,'maxlength'=>32)); ?><label>注：是否限制各题型顺序随机,包括单选、多选、判断、操作。格式同上，0表示不随机，1表示随机</label>
		<?php echo $form->error($model,'testRand'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'summary'); ?>
		<?php echo $form->textArea($model,'summary',array('rows'=>6, 'cols'=>50)); ?>
		<?php echo $form->error($model,'summary'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'examState'); ?>
		<?php echo $form->checkBox($model,'examState'); ?>
		<?php echo $form->error($model,'examState'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'examMode'); ?>
		<?php echo $form->checkBox($model,'examMode'); ?>
		<?php echo $form->error($model,'examMode'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'examTime'); ?>
		<?php echo $form->textField($model,'examTime'); ?>
		<?php echo $form->error($model,'examTime'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'beforeSubmit'); ?>
		<?php echo $form->textField($model,'beforeSubmit'); ?>
		<?php echo $form->error($model,'beforeSubmit'); ?>
	</div>


	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? '创建' : '保存'); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->