{include "header.inc.html"}
{$userLang = $lang.admin.user.form}
<div class="content_box">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>人才列表</strong><br />
		<span class="english">Diplomas</span> </span> </div>
	</div>
	<div class="tool">
	<div class="left">
		<form action="{$adminUrl}diplomas" method="get" class="form">
		<label class="label">证书编号/姓名：</label><input type="text" name="key" value="{$key}" /><input type="submit" class="btn_sub" value="{$lang.form.search}"></button>
		</form>
	</div>
	<div class="right">
		<a class="ui-btn">添加</a>
	</div>
		<div class="clear"></div>
	</div>
<div class="userForm">
{if $smarty.get.act=="edit" || $smarty.get.act=="add"}
 {else}
<div class="digDialog none">
<form class="form" action="{$adminUrl}diplomas" method="post" id="dipForm">
<input type="hidden" name="act" value="add" />
{if $smarty.get.act=="edit"}
<input type="hidden" name="id" value="{$smarty.get.id}" />
{/if}
<input type="hidden" name="inajax" value="1" />
<div class="form-line"><label class="label">证书编号：</label><div class="element"><input type="text" class="text w100" name="certificateNo" value="{$userInfo.certificateNo}" /></div></div>
<div class="form-line"><label class="label">姓名：</label><div class="element"><input type="text" class="text w70" name="name" value="{$userInfo.name}" /></div></div>
<div class="form-line"><label class="label">性别：</label><div class="element"><input type="radio" name="sex" value="男"{if $userInfo.sex=='男'} checked{/if} id="male" validate="required:true"><label for="male">男</label> <input type="radio" name="sex" value="女"{if $userInfo.sex=='女'} checked{/if} id="female"><label for="female">女</label> <label class="error" for="sex" generated="true"></label></div></div>
<div class="form-line"><label class="label">年龄：</label><div class="element"><input type="text" class="text w30" name="age" value="{$userInfo.age}" maxlength="3" /></div></div>
<div class="form-line"><label class="label">身份证号码：</label><div class="element"><input type="text" class="text w150" name="certNo" value="{$userInfo.certNo}"/></div></div>
<div class="form-line"><label class="label">培训项目：</label><div class="element"><input type="text" class="text w200" name="project" value="{$userInfo.project}"/></div></div>
<div class="form-line"><label class="label">培训开始日期：</label><div class="element"><input type="text" class="text w70 ipt-date" autocomplete="off" name="starttime" value="{$userInfo.starttime}" /></div></div>
<div class="form-line"><label class="label">培训毕业日期：</label><div class="element"><input type="text" class="text w70 ipt-date" autocomplete="off" name="endtime" value="{$userInfo.endtime}" /></div></div>
<div class="form-line">
<label class="label"></label><div class="element"><input type="submit" class="btn_sub" value="{$lang.form.submit}" /></div>
</div>
</form>
</div>
</div>

<script type="text/javascript">
$(".ipt-date").datepicker({ dateFormat:'yy-mm-dd' });
$("#dipForm").validate({
	rules:{
		certificateNo:{ required:true },
		name:{ required:true },
		sex:{ required:true },
		age:{ required:true,number:true },
		certNo:{ required:true },
		project:{ required:true },
		starttime:{ required:true,date:true },
		endtime:{ required:true,date:true }
	},
	messages:{
		certificateNo:{ required:'证书编号不可为空' },
		name:{ required:'姓名不可为空' },
		sex:{ required:'请选择性别' },
		age:{ required:'请填写年龄',number:'年龄为数字' },
		certNo:{ required:'身份证号码必填' },
		project:{ required:'请填写接受培训的项目' },
		starttime:{ required:'开始培训日期',date:'日期格式不正确(格式应如：2013-05-15)' },
		endtime:{ required:'毕业日期',date:'日期格式不正确(格式应如：2013-05-15)' }
	},
	submitHandler:function(){
		$("#dipForm").attr("disabled",true);
			$("#dipForm").ajaxSubmit({ cache:false,dataType:'json',success:showResponse,error:function(){ alert('处理失败'); $("#dipForm").attr("disabled",false); } });
		return false;
	}
});
function showResponse(rt,st,xhr,form){
	$("#dipForm").attr("disabled",false);
	if(rt.success){
		var id = rt.data.id;
		var html = '<tr><td>'+id+'</td><td>'+$("input[name='certificateNo']").val()+'</td><td>'+$("input[name='name']").val()+'</td><td>'+$("input[name='sex']:checked").val()+'</td><td>'+$("input[name='age']").val()+'</td><td>'+$("input[name='certNo']").val()+'</td><td>'+$("input[name='project']").val()+'</td><td>'+$("input[name='starttime']").val()+'</td><td>'+$("input[name='endtime']").val()+'</td><td>'+rt.data.posttime+'</td><td></td></tr>';
		$("#tInfo").find("tr").eq(0).after(html);
		digDia.dialog("destroy");
	}else{
		alert(rt.message);
	}
}
</script>

 <table class="table-ca table_1" id="tInfo">
 <tr>
<th class="w60">{$lang.form.id}</th><th class="w80">证书编号</th><th class="w60">姓名</th><th class="w40">性别</th><th class="w40">年龄</th><th class="w140">身份证号</th><th class="">培训项目</th><th class="w70">开始日期</th><th class="w70">毕业日期</th><th class="w130">录入时间</th><th class="w50">操作</th>
 </tr>
{diplomas limit=15 key="$key"}
<tr>
<td>{$item.id}</td>
<td><span sid="{$item.id}" name="certificateNo" class="smodedit" width="70">{$item.certificateNo}</span></td>
<td><span sid="{$item.id}" name="name" class="smodedit" width="50">{$item.name}</span></td>
<td><span sid="{$item.id}" name="sex" class="smodedit" width="30">{$item.sex}</span></td>
<td><span sid="{$item.id}" name="age" class="smodedit" width="30" type="number">{$item.age}</span></td>
<td><span sid="{$item.id}" name="certNo" class="smodedit" width="130">{$item.certNo}</span></td>
<td><span sid="{$item.id}" name="project" class="smodedit" width="430">{$item.project}</span></td>
<td><span sid="{$item.id}" name="starttime" class="smodedit" width="65" type="date">{$item.starttime|date_format:"Y-m-d"}</span></td>
<td><span sid="{$item.id}" name="endtime" class="smodedit" width="65" type="date">{$item.endtime|date_format:"Y-m-d"}</span></td>
<td>{$item.posttime|date_format:"Y-m-d H:i:s"}</td>
<td><a href="javascript:void(0)" sid="{$item.id}" class="delBtn" title="{$lang.del}">{$lang.del}</a></td>
</tr>
{/diplomas}
</table>
<div class="page">
{$key=$key|escape:"url"}
{if $key}
{$key = "/key/$key"}
{/if}
	<div class="pagin fr">{pager allCount=$allCount url="/qkadmin/user$key/page/" number="false"}</div>
</div>
{/if}
</div><!--.content_box-->
<script type="text/javascript">
{if $smarty.get.act=="add" || $smarty.get.act=="edit"}
$(function(){
	{if $smarty.get.act=="add"}
	$("#userForm").validate({
		rules:{
			loginName:{ required:true },
			email:{ required:true,email:true },
			name:{ required:true },
			certNo:{ required:true,minlength:15,maxlength:18 },
			mobile:{ required:true,minlength:11,maxlength:11 },
			loginPwd:{ required:true }
		},
		submitHandler:function(){
			$("#userForm").ajaxSubmit({ dataType:"json",success:showResponse });//
		}
	});
	{else}
		$("#userForm").ajaxForm({ dataType:"json",success:showResponse });//
	{/if}
});

var timer;
function showResponse(rt,xt,xhr,form){
	qlib.tips(rt.message);
}

{else}
$(function(){
	$(".delBtn").click(function(){
		if(!confirm(lang[4])){ return false; }
		var id = $(this).attr("sid");
		var tr = $(this).parent("td").parent("tr");
		if(!id || !parseInt(id)){ return false; }
		$.ajax({
			type:"POST",
			url:"{$adminUrl}diplomas",
			data:"inajax=1&act=del&id="+id,
			dataType:"json",
			success:function(json){
				Msg(json.message);
				if(json.success){
					tr.remove();
				}
			}
		})
	
	});

	$(".ui-btn").click(function(){
		var digDia = $(".digDialog").dialog({ width:600,height:340,title:'添加回复',resizable:false,dialogClass:'layer_global_main' });
	});
})

{/if}
</script>
{include "footer.inc.html"}