<script language="javascript">
var role = '{$role}';
if(role==-2){
	$.messager.alert('提示','您没有新增权限！','warning');
}

var act = '{$act}';
$(function(){
	var th = $(".top").height();
	th = 111-th;
	var wh = $(window).height()-th-200;
	$("#notes{$uniqid}").height(wh);
		
	$("#addFormReport{$uniqid}").form('load',{
		'name':'<?php echo $info["name"] ?>',
		'status':'<?php echo $info["status"] ?>',
		'view_state':'<?php echo $info["view_state"] ?>',
		'client_id':'<?php echo $info["client_id"] ?>',
		'app_handler':'<?php echo $info["pro_info"]["app_handler"] ?>',
		'itemtype':'<?php echo $info["itemtype"] ?>',
		'pro_creatdate':'<?php echo $info["pro_info"]["pro_creatdate"] ?>',
	});
	
	var pid = '{$pid}';
	$("#pid{$uniqid}").combobox({
		url:'__APP__?g=<?php echo GROUP_NAME; ?>&m=Project&a=getProject&act=json',
		editable:true,
		method:'get',
		valueField:'id',
		textField:'text',
		required:true,
		filter: function(q,r){
			var opts = $(this).combobox('options');
			var v = r[opts.textField];
			var vp = ','+String(getPinYin(v));
			var qp = ','+q.toUpperCase();
			if(vp.indexOf(qp)>=0 || v.indexOf(q) == 0){
				return r[opts.textField];
			}
		},
		onLoadSuccess:function(){
			if(act=='add'){
				$("#pid{$uniqid}").combobox('setValue',pid);
			}
		}
	});
	
	$("#priority{$uniqid}").combobox({
		url:'__ITEM__/__RUNTIME__/Data/Json/Linkage/youxianji_data.json',
		editable:false,
		method:'get',
		required:true,
		valueField:'id',
		textField:'text',
		onLoadSuccess:function(){
			if(act=='add'){
				$("#priority{$uniqid}").combobox('setValue',1);
			}
		}
	});
	
	$("#hertz{$uniqid}").combobox({
		url:'__ITEM__/__RUNTIME__/Data/Json/Linkage/chuxianpinlv_data.json',
		editable:false,
		method:'get',
		required:true,
		valueField:'id',
		textField:'text',
		onLoadSuccess:function(){
			if(act=='add'){
				$("#hertz{$uniqid}").combobox('setValue','未知');
			}
		}
	});
	
	$("#type{$uniqid}").combobox({
		url:'__ITEM__/__RUNTIME__/Data/Json/Linkage/chuxianweizhi_data.json',
		editable:false,
		method:'get',
		required:true,
		valueField:'id',
		textField:'text'
	});
	
	$("#level{$uniqid}").combobox({
		url:'__ITEM__/__RUNTIME__/Data/Json/Linkage/yanzhongxing_data.json',
		editable:false,
		method:'get',
		required:true,
		valueField:'id',
		textField:'text',
		onLoadSuccess:function(){
			if(act=='add'){
				$("#level{$uniqid}").combobox('setValue','小调整');
			}
		}
	});
	
	$("#user_id{$uniqid}").combobox({
		url:'__URL__/getUser/id/9999',
		editable:true,
		method:'get',
		valueField:'id',
		textField:'text',
		required:false,
		filter: function(q,r){
			var opts = $(this).combobox('options');
			var v = r[opts.textField];
			var vp = ','+String(getPinYin(v));
			var qp = ','+q.toUpperCase();
			if(vp.indexOf(qp)>=0 || v.indexOf(q) == 0){
				return r[opts.textField];
			}
		}
	});
	
	var mc = Number('<?php echo C("MORE_COMY") ?>');
	if(mc){
		$("#comy{$uniqid}").combotree({
			url:'__ITEM__/__RUNTIME__/Data/Json/Comy_Part_data.json',
			editable:false,
			method:'get',
			required:false,
			valueField:'id',
			textField:'text',
			onSelect:function(c){
				$("#user_id{$uniqid}").combobox('setValue',0);
				$("#user_id{$uniqid}").combobox('reload','__APP__?g=<?php echo GROUP_NAME; ?>&m=<?php echo MODULE_NAME; ?>&a=getUser&id='+c['id']);
			},
			onLoadSuccess:function(){
				if(act=='edit'){
					$("#user_id{$uniqid}").combobox('reload','__APP__?g=<?php echo GROUP_NAME; ?>&m=<?php echo MODULE_NAME; ?>&a=getUser&id=<?php echo $info["comy"] ?>');
				}
			}
		});
	}else{
		$("#comy{$uniqid}").combobox({
			url:'__ITEM__/__RUNTIME__/Data/Json/Part_2_data.json',
			editable:false,
			method:'get',
			required:false,
			valueField:'id',
			textField:'text',
			onSelect:function(c){
				$("#user_id{$uniqid}").combobox('setValue',0);
				$("#user_id{$uniqid}").combobox('reload','__APP__?g=<?php echo GROUP_NAME; ?>&m=<?php echo MODULE_NAME; ?>&a=getUser&id='+c['id']);
			},
			onLoadSuccess:function(){
				if(act=='edit'){
					$("#user_id{$uniqid}").combobox('reload','__APP__?g=<?php echo GROUP_NAME; ?>&m=<?php echo MODULE_NAME; ?>&a=getUser&id=<?php echo $info["comy"] ?>');
				}
			}
		});
	}
	
	$("#pro_creatdate{$uniqid}").datepicker('setValue','<?php echo date("Y-m-d",time()) ?>');
});

function onSubmitReport(idd){
	$.messager.progress();
	$("#toUser"+idd+" option").attr("selected",true);
	$("#addFormReport"+idd).form('submit',{
		url:'__APP__?g=<?php echo GROUP_NAME; ?>&m=<?php echo MODULE_NAME; ?>&a=add&act=add&go=1',
		onSubmit: function(){
			var isValid = $(this).form('validate');
			if (!isValid){
				$.messager.progress('close');
			}
			return isValid;
		},
		success:function(data){
			$.messager.progress('close');
			$("#toUser"+idd+" option").attr("selected",false);
			if(data==1){
				$.messager.alert('提示','新增数据成功！','info',function(){
					onResetReport(idd);
				});
			}else if(data==0){
				$.messager.alert('提示','新增数据失败！','warning');
			}else{
				//alert(data);
				$.messager.alert('提示','您没有新增权限！','warning');
			}
		}
	});
}

function onResetReport(idd){
	var tab = $("#rightTabs").tabs('getSelected');
	$("#rightTabs").tabs('update',{
		tab:tab,
		options:{
			title : '提交BUG',
			href : '__APP__?g=<?php echo GROUP_NAME; ?>&m=<?php echo MODULE_NAME; ?>&a=add&act=add',
			closable : true
		} 
	});
}
</script>
<div class="con">
<form method="post" enctype="multipart/form-data" id="addFormReport{$uniqid}">
    <table class="infobox table-border" width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse;">
      <tbody>
      <tr>
        <td width="11%" class="rebg"><label for="bugno">问题编号</label><input id="ids{$uniqid}" type="hidden" value="{$id}" /></td>
        <td width="23%">{$bugno}<input name="bugno" type="hidden" value="{$bugno}" /></td>
        <td width="11%" class="rebg"><label for="type">出现位置</label></td>
        <td width="22%"><input name="type" id="type{$uniqid}" class="relo" size="24" /></td>
        <td width="11%" class="rebg"><label for="pid">所属项目</label></td>
        <td width="22%"><input name="pid" id="pid{$uniqid}" class="relo" size="24" /></td>
      </tr>
      <tr>
        <td width="11%" class="rebg"><label for="level">严重性</label></td>
        <td width="23%"><input name="level" id="level{$uniqid}" class="relo" size="26" /></td>
        <td width="11%" class="rebg"><label for="hertz">频率</label></td>
        <td width="22%"><input name="hertz" id="hertz{$uniqid}" class="relo" size="24" /></td>
        <td width="11%" class="rebg"><label for="priority">优先级</label></td>
        <td width="22%"><input name="priority" id="priority{$uniqid}" class="relo" size="24" /></td>
      </tr>
      <tr>
        <td class="rebg"><label for="user_id">指派给</label></td>
        <td colspan="3"><input name="comy" id="comy{$uniqid}" class="relo" size="44" />&nbsp;-->&nbsp;<input name="user_id" id="user_id{$uniqid}" class="relo" size="24" /></td>
        <td class="rebg"><label for="os">平台</label></td>
        <td><input name="os" id="os{$uniqid}" size="24" class="easyui-validatebox" data-options="validType:'ptext'" /></td>
        </tr>
      <tr>
        <td class="rebg"><label for="title">摘要</label></td>
        <td colspan="3"><input name="title" type="text" id="title{$uniqid}" class="easyui-validatebox" data-options="validType:'ptext'" style="width:99%" /></td>
        <td class="rebg"><label for="creator">创建人</label></td>
        <td>{$username}</td>
        </tr>
      <tr>
        <td class="rebg"><label for="notes">详细现象</label></td>
        <td height="265" colspan="5" style="padding:3px"><textarea name="notes" id="notes{$uniqid}"  rows="18" data-options="uploadJson:'__APP__?g=Public&m=Upload&a=save&act=Report'" class="easyui-kindeditor" style="width:99%; height:260px;">{$info.baseinfo.notes}</textarea></td>
      </tr>
      <tr>
        <td class="rebg"><label for="comment">备注</label></td>
        <td colspan="5"><input name="comment" type="text" id="comment{$uniqid}" class="easyui-validatebox" data-options="validType:'ptext'" style="width:99%" /></td>
        </tr>
      <if condition="$act=='add'">
      <tr>
        <td class="rebg"><label for="path">附件</label></td>
        <td colspan="5">
         <input name="path" type="file" />&nbsp;<font class="up-font-over">(文件类型：rar、zip)</font>
        </td>
      </tr> 
     </if>
      </tbody>
      <tr>
        <td height="38" colspan="6" align="center"><if condition="$act=='add'">
        <a href="javascript:void(0);" onclick="javascript:onSubmitReport('{$uniqid}')" id="su" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a><else /><a href="javascript:void(0);" onclick="javascript:return onUploadReport('{$uniqid}')" id="sue" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a></if> 
        &nbsp; <a href="javascript:void(0);" onclick="javascript:onResetReport('{$uniqid}')" id="re" class="easyui-linkbutton" data-options="iconCls:'icon-reload'">刷新</a></td>
        </tr>
     </table> 
</form>
</div>
<div id="addApp"></div>