<?php
$btianarr=array();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?=$da['title']?>-<?=TITLE?></title>
<link rel="stylesheet" href="css/css.css" />
<link rel="stylesheet" href="webrock/css/rockcss.css" />
<link rel="shortcut icon" href="favicon.ico" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/js.js"></script>
<script type="text/javascript" src="js/base64-min.js"></script>
<script type="text/javascript">
js.path	= '<?=PATH?>';
PROJECT = '<?=P?>';
var btianarr = {},courseid='<?=$da['arr']['coursers']['id']?>',coursenum='<?=$da['arr']['coursers']['num']?>',userid='<?=$da['uid']?>';
var flownum= '<?=$da['arr']['flownum']?>',flowid='<?=$da['arr']['mid']?>';
function othercheck(){}
function initbody(){
	$('body').keydown(function(e){
		var code	= e.keyCode;
		if(code==27){
			connectclose();
			return false;
		}
	});
}
function check(o1){
	var da = {'sm':form('check_explain').value,'courseid':courseid,'id':flowid,'flownum':flownum,'zt':_getaolvw('check_status'),'cid':_getaolvw('check_name'),'nextcheckid':js.getchecked('check_nextchangeid')};
	if(da.zt==''){js.setmsg('请选择处理动作');return;}if(da.zt=='2'&&isempt(da.sm)){js.setmsg('此动作必须填写说明');return;}
	if(da.zt=='1'){for(var csa in btianarr){if(form(csa).value==''&&btianarr[csa]!=''){js.setmsg('【'+btianarr[csa]+'】不能为空');return;}}}
	if(form('zhuangyi_name')){
		da.zyname 	= form('zhuangyi_name').value;
		da.zynameid = form('zhuangyi_name_id').value;
	}
	var ostr=othercheck();
	if(typeof(ostr)=='string'&&ostr!=''){js.setmsg(ostr);return;}
	if(typeof(ostr)=='object')for(var csa in ostr)da[csa]=ostr[csa];
	js.setmsg('处理中...');
	o1.disabled = true;
	for(var csa in btianarr)da[csa]=jm.base64encode(form(csa).value);
	da.fileid = form('fileid').value;
	var url = js.getajaxurl('check','flow','taskrun');
	$.ajax({type:'post',url:url,data:da,success:function(das){backreturn();if(das.indexOf('成功')>-1){js.setmsg(das,'green');if(get('autocheckbox').checked)connectclose();}else{js.setmsg(das);o1.disabled = false;}},error:function(){js.setmsg('处理失败请重试');o1.disabled = false;}});
}
function _getaolvw(na){
	var v = '',i,o=$("input[name='"+na+"']");
	for(i=0;i<o.length;i++)if(o[i].checked)v=o[i].value;
	return v;
}
var backnana;
function getuserla(na){
	backnana=na;
	//js.open(js.getajaxurl('$change','dept','system',{changetype:'changeuser',callback:'backusercane'}),500,400);
	//return false;
	
	var h = winHb()-70;
	if(h>400)h=400;
	js.tanbody('changeaction','请选择...',500,h,{
		html:'<div style="height:'+h+'px"><iframe src="" name="winiframe" width="100%" height="100%" frameborder="0"></iframe></div>',
		bbar:'none'
	});
	var url = js.getajaxurl('$change','dept','system',{changetype:'changeuser',callback:'backusercane'});
	winiframe.location.href=url;
	return false;
	
}
function clearxuan(na){
	form(na).value='';
	form(na+'_id').value='';
	form(backnana).focus();
}
function backusercane(na,naid){
	form(backnana).value=na;
	form(backnana+'_id').value=naid;
	form(backnana).focus();
}
function connectclose(){
	try{
		window.external.formclose();
	}catch(e){
		window.close();
	}	
}
function backreturn(){
	try{
	var sid = js.request('gridid'),nonum='';try{nonum=opener.nowtab.num}catch(e){};
	if(sid){var o1 = opener.getcmp(sid);if(o1){o1.setReload(true);if(nonum==o1.itemId){o1.storereload();}}};
	}catch(e){}
}
function closechangeuser(){
	js.tanclose('changeaction');
}
function openupload(){
	js.upload('',{showid:'fileidview'});
	return false;
}
function openprint(){
	var as = '<?=$da['printurl']?>',bs,url='';
	if(as){
		url = ''+js.path+'.php?rocktoken='+as+'';
	}else{
		url = location.href;
		url = url.replace('a=view','a=print');
	}	
	location.href = url;
}
function submitother(nae,zt,las, smlx){
	if(userid==''||userid=='0'||!nae||!las){js.msg('sorry;不允许操作','','msgview_spage');return;}
	var sm = '';if(!smlx)sm=$('#'+las+'').val();
	if(!zt)zt=nae;
	if(!sm){js.setmsg('没有输入任何信息','','msgview_spage');return;}
	var da = {'name':nae,'id':flowid,'flownum':flownum,'zt':zt,'cid':userid,'sm':sm};
	var url = js.getajaxurl('addlog','flow','taskrun');
	js.setmsg('处理中...','','msgview_spage');
	js.ajax(url,da,function(s){
		if(s=='success'){
			js.setmsg('处理成功','green', 'msgview_spage');
			$('#spage_btn').hide();
		}else{
			js.setmsg(s,'','msgview_spage');
		}
	},'post');
	return false;
}
</script>
<style>
.table{font-size:14px;}
.tdcont{padding:0px 0px}
.tdcont p{padding:3px 5px}
.tdcont a{color:blue;TEXT-DECORATION:underline;}
.table .tdys1{padding:5px 5px;border:1px #888888 solid;text-align:right;width:100px}
.table .tdys2{padding:5px 5px;border:1px #888888 solid;text-align:left}
.tabled2 td{padding:8px;border:1px #dddddd solid;text-align:center}
.tabled2 tr:hover,.tdcont tr:hover{background:#f1f1f1}
.tabled2 td.pandys{padding:5px;text-align:center}
.createtable{width:100%}
.ys2{padding:0px 5px; border:1px #000000 solid}
.ys1{padding:0px 5px; border:1px #000000 solid}
.ys0{border:1px #000000 solid}
.ydullist{display:inline-block;width:100%}
.ydullist li{float:left;width:20%;text-align:left;padding:5px 0px;font-size:12px}
.ydullist li img{height:24px;width:24px;margin-right:3px;}
.ydullist li span{font-size:10px;color:#888888}
.yyjnr{font-size:12px;background-color:#f1f1f1;padding:5px;margin:5px 0px}
.status{position: absolute;right:5px;top:-10px;display:}
</style>
</head>
<body style="padding:15px">
<div align="center">

<div id="printdiv" style="position:fixed;left:2px;top:2px;z-index:4" align="left">
	<button class="webbtn" type="button" onclick="openprint()"><img src="images/print.png"> 打印</button>&nbsp; 
	<button class="webbtn" type="button" onclick="connectclose()">关闭</button>
</div>

<div style="width:700px;position:relative">
	
	<?php 
	if($da['arr']['isflow']==1){
		$_tzt = $da['arr']['status'];
		if($da['arr']['data']['isturn']==0)$_tzt=3;
		echo '<div class="status"><img src="images/status'.$_tzt.'.png"></div>';
	}
	if($da['notitle']!='true'){
		echo '<div style="padding-bottom:15px;font-size:30px">'.$da['title'].'</div>'; 
	}
	?>
	<div class="tdcont" align="left">
		<?=$da['content']?>
	</div>
	<?php
	if($da['spagepath']!=''){
		echo '<div align="left" style="padding-top:20px;padding-bottom:5px">';
		include_once($da['spagepath']);
		echo '</div>';
	}
	$logcount = count($da['arr']['logarr']);
	if($logcount>0){
	?>
	<div align="left" style="padding-top:20px;padding-bottom:5px"><b>操作记录(<?=$logcount?>)</b></div>
	<div>
		<table border="0"  class="tabled2" style="border-collapse:collapse;" width="100%" cellspacing="0" cellpadding="0">
		<tr bgcolor="#D2E9FF">
			<td align="center" width="50">序号</td>
			<td align="center">名称</td>
			<td align="center">处理人</td>
			<td align="center">状态</td>
			
			<td align="center">说明</td>
			<td align="center">时间</td>
		</tr>
		<?php 
		foreach($da['arr']['logarr'] as $k=>$rs){
			$ss = '';
			if($rs['filearr'])$ss='rowspan="2"';
		?>
		<tr >
			<td class="pandys" <?=$ss?>><?=$k+1?></td>
			<td class="pandys"><?=$rs['name']?></td>
			<td class="pandys"><?=$rs['checkname']?></td>
			<td class="pandys"><?php
				echo '<font color="'.$rs['statuscolor'].'">'.$rs['statusname'].'</font>';
			?></td>
			<td class="pandys"><?=$rs['explain']?></td>
			<td class="pandys"><?=$rs['optdt']?></td>
		</tr>
		<?php 
		if($rs['filearr']){
			$s = '<tr>';
			$s .= '<td colspan="5"><div align="left" style="line-height:25px">';
			$s .= '【相关文件】';
			foreach($rs['filearr'] as $k1=>$rs1){
				$s.='<br>'.($k1+1).'、<a href="javascript:" onclick="return js.downshow(\''.$rs1['id'].'\')" class="blue">'.$rs1['filename'].'</a> ('.$rs1['filesizecn'].')';
			}
			$s .= '</div></td>';
			$s .= '</tr>';
			echo $s;
		}
		?>
		
		<?php }?>
		</table>
	</div>
	<?php
	}
	if($da['arr']['isflow']==1){
	?>
	<div align="center" style="padding-top:20px;padding-bottom:5px"><b>审核处理</b></div>
	<div align="center">
		<form name="myform">
		<table border="0" width="700" class="tabled2" style="border-collapse:collapse;" cellspacing="0" cellpadding="0">
		<tr bgcolor="#D2E9FF">
			<td width="130"><div align="right" style="color:#555555">状态:</div></td>
			<td><div align="left"><?=$da['arr']['data']['checkstatustext']?></div></td>
		</tr>
		<tr>
			<td><div align="right" style="color:#555555">处理流程:</div></td>
			<td><div align="left"><?=$da['arr']['logstr']?></div></td>
		</tr>
		<?php if($da['arr']['ischeck']==1){?>
		<tr>
			<td><div align="right" style="color:#555555"><font color=red>*</font>处理人:</div></td>
			<td><div align="left">
			<?php 
			foreach($da['urs'] as $k=>$us){
				$chek = '';
				if($k==0)$chek='checked';
				echo '<label><input name="check_name" '.$chek.' type="radio" value="'.$us['id'].'">'.$us['name'].'</label>&nbsp; ';
			}
			?>
			</div></td>
		</tr>
		<tr>
			<td ><div align="right" style="color:#555555"><font color=red>*</font>处理动作:</div></td>
			<td><div align="left">
			<?php 
			foreach($da['arr']['actarr'] as $k=>$act){
				echo '<label><input name="check_status"  type="radio" value="'.$act[0].'">'.$act[1].'</label>&nbsp; ';
			}
			?>
			</div></td>
		</tr>
		<?php 
		if($da['arr']['coursers']['type']==1){
		?>
		<tr>
			<td ><div align="right" style="color:#555555">转给其他人:</div></td>
			<td>
				<div  style="float:left" align="left"><input class="input" placeholder="--请选择人员--" style="width:370px;" readonly type="text" name="zhuangyi_name"><input name="zhuangyi_name_id" type="hidden"></div>
				<div style="float:left;padding:8px 0px"><a href="javascript:" style="padding:8px" onclick="return clearxuan('zhuangyi_name')"  class="webbtn">×</a><a href="javascript:" style="padding:8px" onclick="return getuserla('zhuangyi_name')"  class="webbtn">请选择...</a></div>
			</td>
		</tr>
		
		<?php
		}
		if(count($da['arr']['nextcheck'])>1){?>
		<tr>
			<td ><div  align="right" style="color:#555555"><a href="http://www.rockoa.com/view_nextchange.html" target="_blank">?</a>指定下步审核人:</div></td>
			<td><div align="left">
			<?php
			foreach($da['arr']['nextcheck'] as $u=>$us){
				echo '<label><input type="checkbox" name="check_nextchangeid" value="'.$us['nameid'].'"> '.$us['name'].'</label>&nbsp; &nbsp; ';
			}
			?>
			</div></td>
		<?php }?>
		
		<?php
		
		foreach($da['inputrs'] as $k=>$inp){?>
		<tr>
			<td ><div  align="right" style="color:#555555"><font color=red>*</font><?=$inp['label']?>:</div></td>
			<td><div align="left">
			<?php
			$type = $inp['type'];
			$innae= 'checkinput_'.$inp['name'].'';
			$ss1  = '<input class="input"  style="width:95%;" type="text" name="'.$innae.'">';
			$sss  = $ss1;
			if($type=='changeuser'){
				$sss = '<div style="float:left"><input class="input" placeholder="--请选择人员--" style="width:370px;" readonly type="text" name="'.$innae.'"><input name="'.$innae.'_id" type="hidden"></div>';
				$sss .= '<div style="float:left;padding:10px"><a href="javascript:" onclick="return getuserla(\''.$innae.'\')" class="webbtn">请选择...</a></div>';

			}
			$btianarr[$innae]=$inp['label'];
			$btianarr[$innae.'_id']='';
			echo $sss;
			?>
			
			</div></td>
		</tr>
		<?php }?>
		<tr>
			<td ><div  align="right" style="color:#555555">说明:</div></td>
			<td><div align="left"><textarea class="textarea" name="check_explain" style="width:95%;height:80px"></textarea></div></td>
		</tr>
		<tr>
			<td ><div  align="right" style="color:#555555">相关附件:</div><input name="fileid" type="hidden" id="fileidview-inputEl"></td>
			<td><div align="left"><div id="view_fileidview" style="width:97%;height:60px;border:1px #cccccc solid; background:white;overflow:auto"></div><div><a href="javascript:" class="blue" onclick="return openupload()"><u>＋添加附件</u></a></div></div></td>
		</tr>
		<tr>
			<td></td>
			<td><div align="left"><input onclick="check(this)" style="height:35px;cursor:pointer;padding:0px 10px" value="提交处理" type="button">&nbsp;<span id="msgview"></span>&nbsp; &nbsp; <label style="color:#888888"><input id="autocheckbox" checked type="checkbox">处理完自动关闭</label></div></td>
		</tr>
		<?php }?>
		</table>
		</form>
	</div>
	<?php }?>
	
	
	
	<div align="left" style="padding-top:20px;padding-bottom:5px"><b>查阅记录(<?=count($da['arr']['readarr'])?>)</b></div>
	<div><ul class="ydullist"><?php
		foreach($da['arr']['readarr'] as $k=>$rs){
			echo '<li title="总查阅'.$rs['stotal'].'次"><img src="'.$rs['face'].'" align="absmiddle">'.$rs['name'].'<span>('.substr($rs['optdt'],5,11).')</span></li>';
		}
	?></ul></div>
	<div class="blank10"></div>
</div>	
</div>
<script>
var btianarr=<?=json_encode($btianarr)?>;
</script>
</body>
</html>