<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="themes/jquery/css/themes/default/jquery.mobile-1.4.5.min.css">
	<link rel="stylesheet" href="themes/home/css/fonts/font-awesome.min.css">
    <link rel="stylesheet" href="themes/home/css/ui-box.css">
    <link rel="stylesheet" href="themes/home/css/ui-base.css">
    <link rel="stylesheet" href="themes/home/css/ui-color.css">
    <link rel="stylesheet" href="themes/home/css/icon.css">
    <link rel="stylesheet" href="themes/home/css/control.css">
    <link rel="stylesheet" href="themes/home/css/main.css">
	<script src="themes/jquery/js/jquery.js"></script>
	<script src="themes/jquery/js/jquery.mobile-1.4.5.min.js"></script>
</head>
<body class="um-vp c-wh " ontouchstart>
	<div data-role="page" data-quicklinks="true" class="ub ub-ver ">
      <div data-role="header" id="header" data-position="fixed" data-fullscreen="true" data-tap-toggle="false" >
	  <div class="uh bc-text-head ub bc-head">
                <div class="nav-btn" id="nav-left" onClick="javascript:window.location='index.php?ac=<?php echo $ac;?>&fileurl=plugin&type=<?php echo $type?>'">
                    <div class="fa fa-angle-left fa-2x"></div>
                </div>
                <h1 class="ut ub-f1 ulev-3 ut-s tx-c" tabindex="0"><?php echo $work['title'];?></h1>
				<?php
				$sql = "SELECT * FROM ".DB_TABLEPRE."workclass_personnel where name like '%".get_realname($_USER->id)."%' and (pertype=0 or pertype=4) and typeid='".$work['typeid']."' and workid='".$work['id']."'  order by perid desc";
				$per = $db->fetch_one_array($sql);
				if($per['perid']!=''){
				if($per['appkey']==1 && $per['appkey1']==1){
					$perlnum = $db->result("SELECT COUNT(*) AS perlnum FROM ".DB_TABLEPRE."workclass_personnel_log where perid='".$per['perid']."' and uid='".$_USER->id."' and pertype=0");
					if($perlnum>0){
				 ?>
					<div class="nav-btn nav-bt" id="nav-right" onClick="javascript:window.location='index.php?ac=workadd&fileurl=plugin&workid=<?php echo $work['id'];?>&typeid=<?php echo $work['typeid'];?>&tplid=<?php echo $work['tplid'];?>&perid=<?php echo $per['perid'];?>&flowid=<?php echo $per['flowid'];?>'">
						<div class="ub-img icon-edit umw2 umh4"></div>
					</div>
				<?php
					}
				}else{
				?>
					<div class="nav-btn nav-bt" id="nav-right" onClick="javascript:window.location='index.php?ac=workadd&fileurl=plugin&workid=<?php echo $work['id'];?>&typeid=<?php echo $work['typeid'];?>&tplid=<?php echo $work['tplid'];?>&perid=<?php echo $per['perid'];?>&flowid=<?php echo $per['flowid'];?>'">
						<div class="ub-img icon-edit umw2 umh4"></div>
					</div>
				<?php
				}
				}
			    ?>
                
				
       </div>
	  
	   <div class="ub ub-ver uinn-FS2">
                <div class="ub">
                    <div class="ub ub-ver ub-f1" onClick="active('info');">
                        <div class="ub-f1 ub ub-ac">
                            <div class="uwh-FS1 c-gra-FS1 uc-a-FS1 ub ub-ac ub-pc">
                                <div id="infos" class="uwh-FS2 sc-bg-alert uc-a-FS2 ub ub-ac ub-pc">
                                    <div class="ub-img uwh-FS3 formStep1"></div>
                                </div>
                            </div>
                            <div class="ub-f1 uh-FS1 c-gra-FS1"></div>
                        </div>
                        <div class="ulev-2 umar-tFS1">
                            基本信息
                        </div>
                    </div>
                    <div class="ub ub-ver ub-f1"  onClick="active('flow');">
                        <div class="ub-f1 ub ub-ac">
                            <div class="uwh-FS1 c-gra-FS1 uc-a-FS1 ub ub-ac ub-pc">
                                <div id="flows" class="uwh-FS2 c-gra-FS2 uc-a-FS2 ub ub-ac ub-pc">
                                    <div class="ub-img uwh-FS3 formStep2"></div>
                                </div>
                            </div>
                            <div class="ub-f1 uh-FS1 c-gra-FS1"></div>
                        </div>
                        <div class="ulev-2 umar-tFS1">
                            流程记录
                        </div>
                    </div>
                    
                    <div class="ub ub-ver"  onClick="active('file');">
                        <div class="ub">
                            <div class="uwh-FS1 c-gra-FS1 uc-a-FS1 ub ub-ac ub-pc">
                                <div id="files" class="uwh-FS2 c-gra-FS2 uc-a-FS2 ub ub-ac ub-pc">
                                    <div class="ub-img uwh-FS3 formStep4"></div>
                                </div>
                            </div>
                        </div>
                        <div class="ulev-2 umar-tFS1 tx-c">
                            附件
                        </div>
                    </div>
                </div>
            </div>
	  
</div>
		<!-- /header -->
  <div data-role="content" id="content">
	  <div class="ub ub-ver">
			
			<div class="uinn-a6 sc-text  ulev-app1" id="info">
						基本信息
					</div>
					<div class="ub ub-ver uinn-a1 ub-f1">
						<div class="uba bc-border c-wh">
							<ul class="ubb ub bc-border bc-text ub-ac uinn-a9">
								<li class="uw-infor ut-s sc-text  umar-r-infor ulev-app1">
									流水号
								</li>
								<li class="ub-f1 ulev-app1">
								<?php echo trim($work['number']);?>
								</li>
							</ul>
							<ul class="ubb ub bc-border bc-text ub-ac uinn-a9">
								<li class="uw-infor ut-s sc-text  umar-r-infor ulev-app1">
									流程类型
								</li>
								<li class="ub-f1 ulev-app1">
									<?php echo public_value('typename','workclass_type','tid='.$work["typeid"])?>
								</li>
							</ul>
							<ul class="ubb ub bc-border bc-text ub-ac uinn-a9">
								<li class="uw-infor ut-s sc-text  umar-r-infor ulev-app1">
									所属模型
								</li>
								<li class="ub-f1 ulev-app1">
									<?php echo public_value('title','workclass_template','tplid='.$work["tplid"])?>
								</li>
							</ul>
							<?php
							if($tpl['tplkey']!=4 && $tpl['tplkey']!=5){
							 global $db;
							$query = $db->query("SELECT inputname,fromname FROM ".DB_TABLEPRE."workclass_from where tplid='".$work['tplid']."' and typeid='".$work['typeid']."' and inputtype!='6' ORDER BY inputnumber Asc");
							$n=0;
							while ($rowdb = $db->fetch_array($query)) {
							 ?>
							<ul class="ubb ub bc-border bc-text ub-ac uinn-a9">
								<li class="uw-infor ut-s sc-text  umar-r-infor ulev-app1">
									<?php echo $rowdb["fromname"];?>
								</li>
								<li class="ub-f1 ulev-app1">
									<?php
								 echo public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']);
								 ?>
								</li>
							</ul>
							<?php }
							}else{
							$file = $db->fetch_one_array("SELECT fileid,filename FROM ".DB_TABLEPRE."fileoffice  WHERE number = 'WORK".$work['id']."' and officetype='3' and filetype='1'");
							?>
							<ul class="ubb ub bc-border bc-text ub-ac uinn-a9">
								<li class="uw-infor ut-s sc-text  umar-r-infor ulev-app1">
									流程正文
								</li>
								<li class="ub-f1 ulev-app1">
									<a href="../data/word/wordflow/<?php echo $file['filename'];?>" download="<?php echo $work['title'];?>" target="_blank">下载到手机</a>
								</li>
							</ul>
							<?php }?>
							<ul class="ubb ub bc-border bc-text ub-ac uinn-a9">
								<li class="uw-infor ut-s sc-text  umar-r-infor ulev-app1">
									发布人
								</li>
								<li class="ub-f1 ulev-app1">
									<?php echo get_realname($work['uid']);?>
								</li>
							</ul>
							
							<ul class=" ub bc-text ub-ac uinn-a9">
								<li class="uw-infor ut-s sc-text  umar-r-infor ulev-app1">
									发布时间
								</li>
								<li class="ub-f1 ulev-app1">
									<?php echo trim($work['date']);?>
								</li>
							</ul>
							
						</div>
					</div>
					<?php 
					$nums = $db->result("SELECT COUNT(*) AS nums FROM ".DB_TABLEPRE."workclass_from where tplid='".$work['tplid']."' and typeid='".$work['typeid']."' and inputtype='6' ORDER BY inputnumber Asc");
					$query = $db->query("SELECT fromid,fromname,inputname FROM ".DB_TABLEPRE."workclass_from where tplid='".$work['tplid']."' and typeid='".$work['typeid']."' and inputtype='6' ORDER BY inputnumber Asc");
					while ($from = $db->fetch_array($query)) {
					if($nums>0){
					$sqlv = "SELECT * FROM ".DB_TABLEPRE."workclass_from_view where tplid='".$work['tplid']."' and typeid='".$work['typeid']."' and fromid='".$from['fromid']."' ORDER BY inputnumber Asc";
					$results = $db->fetch_all($sqlv);
					$htmls='';
					foreach ($results as $row) {
						$htmls.=$row['inputname']."!='' or ";
					}
					if(trim($htmls)!=''){
						$html='and ('.substr($htmls, 0, -4).')';
					}
					
					$sqlwv = "SELECT * FROM ".DB_TABLEPRE."wd_".$work['tplid']."_".$from['fromid']." where workid='".$work['id']."' ".$html." ORDER BY vid asc";
					$resultws = $db->fetch_all($sqlwv);
					?>
					<div class="uinn-a6 t-gra3 ulev-app1">
						<?php echo $from['fromname'];?>
					</div>
					<div class="ub ub-ver uinn-a1">
						<div class="ub-img-rank rank-bg uinn-t-rank">
							<div class="ub c-blu-rank uinn-a1 t-blu-rank umar-fr1">
								<?php foreach ($results as $row) {?>
								<div class="uw-rank ulev-4">
									<?php echo $row["fromname"];?>
								</div>
								<?php }?>
							</div>
							<?php foreach ($resultws as $roww) {?>
							<div class="ub c-wh uinn-a1 ubb bc-border">
								<?php foreach ($results as $row) {?>
								<div class="uw-rank t-blu ulev-4 ufm1">
									<?php echo $roww[$row['inputname']];?>
								</div>
								<?php }?>
							</div>
							<?php }?>
						</div>
					</div> 
					
					<?php }
					}
					?>
					
					
					
					
					
					
					<!--流程信息 -->
					
					<div class="uinn-a6 sc-text  ulev-app1" id="flow">
						流程办理进度
					</div>
					<div class="ub ub-ver uinn-a1 ub-f1">
						<div class="uba bc-border c-wh">
							<?php
							$sql = "SELECT * FROM ".DB_TABLEPRE."workclass_personnel where workid='".$workid."'  order by perid asc";
							$result = $db->fetch_all($sql);
							$i=0;
							foreach ($result as $rows) {
							$sql = "SELECT * FROM ".DB_TABLEPRE."workclass_flow  WHERE fid = '".$rows['flowid']."'";
							$flow = $db->fetch_one_array($sql);
							$i++;
							?>
							<ul ontouchstart="appcan.touch('btn-act')" class="ubb ub bc-border lis">
								<li class="uh-app3 uw-app3 uc-a-app2 ub-img mar-ar1" style="background-image:url(themes/home/css/myImg/num<?php echo $i;?>.png);"></li>
								<li class="ub-f1 ub ub-ver">
									<div class="ub ub-f1 ub-ac">
										<div class="ut-s ulev-4 sc-text-active "><?php echo $flow['flowname']?> (办理人员：<?php echo $rows['name']?>)</div>
									</div>
									<div class="ub umar-t">	
										<div class="ub-f1 ub t-gra-comm ulev-2">
											<div class="umar-r-comm"><?php echo Sms_Date(strtotime($rows['designationdate']));?></div>
											<div><?php
											  if($rows['pertype']==0){
												  echo '<font color=red>[流程办理中]</font>';
											  }
											  ?></div>
										</div>
										
									</div>
									<?php if($flow['flownum']==1){?>
									<div class="t-bla ulev-4 ub-f1 umar-t"><?php echo $rows['name']?></div>
									<div class="uba bc-border sc-bg-active  uc-a1 umar-at1">
										<div class="uinn-comm ulev-4">
											<div class="sc-text-active line-hei-com"><?php echo $rows['approvaldate']?><div class="umar-r-comm"><?php echo work_pertype($rows['pertype'])?></div></div>
											<div class="t-gra2-comm line-hei-com"><?php echo $rows['lnstructions']?></div>
										</div>
									</div>
									<?php }else{?>
									<?php
									if($rows['pertype']!=0){
										if($rows['appkey']==2){?>
									<div class="t-bla ulev-4 ub-f1 umar-t"><?php echo $rows['name']?></div>
									<div class="uba bc-border sc-bg-active  uc-a1 umar-at1">
										<div class="uinn-comm ulev-4">
											<div class="sc-text-active line-hei-com"><?php echo $rows['approvaldate']?><div class="umar-r-comm"><?php echo work_pertype($rows['pertype'])?></div></div>
											<div class="t-gra2-comm line-hei-com"><?php echo $rows['lnstructions']?></div>
										</div>
									</div>
									<?php }else{
										$query = $db->query("SELECT * FROM ".DB_TABLEPRE."workclass_personnel_log where perid='".$rows['perid']."' ORDER BY lid Asc");
										while ($log = $db->fetch_array($query)) {
									?>
									<div class="t-bla ulev-4 ub-f1 umar-t"><?php echo $log['name']?></div>
									<div class="uba bc-border sc-bg-active  uc-a1 umar-at1">
										<div class="uinn-comm ulev-4">
											<div class="sc-text-active line-hei-com"><?php echo $log['approvaldate']?><div class="umar-r-comm"><?php echo work_pertype_log($log['pertype'])?></div></div>
											<div class="t-gra2-comm line-hei-com"><?php echo $log['lnstructions']?></div>
										</div>
									</div>
									<?php 
										}
									}
								}
							}?>
								</li>
							</ul>
						<?php }?>
							
						</div>
					</div>
					
					<!--附件 -->
					<div style="padding-left:5px; padding-right:5px;" id="file">
					<div class="uinn-a6 sc-text  ulev-app1">
						流程附件
					</div>
					<ul data-role="listview" data-inset="true">
					<?php
					$sql = "SELECT * FROM ".DB_TABLEPRE."fileoffice WHERE number='".$work['id']."' and officetype='3' and filetype='2' ORDER BY id desc";
					$result = $db->query($sql);
					while ($row = $db->fetch_array($result)) {
					$filetype=preg_replace('/.*\.(.*[^\.].*)*/iU','\\1',$row['filename']);
					if(file_exists('../template/default/content/ico/'.$filetype.'.gif')!=''){
						$ico=$filetype;
					}else{
						$ico='ini';
					}
						echo '<li onClick=javascript:window.location="../'.$row['fileaddr'].'"><img class="ui-li-icon ui-corner-none" src="../template/default/content/ico/'.$ico.'.gif">'.str_replace('.'.$filetype,'',$row['filename']).'<span class="ui-li-count">';
						if(filesize('../'.$row['fileaddr'])>=1000000000){
							echo sprintf("%.2f", (filesize('../'.$row['fileaddr'])*0.000000001)).'GB';
						}elseif(filesize('../'.$row['fileaddr'])>=1000000){
							echo sprintf("%.2f", (filesize('../'.$row['fileaddr'])*0.000001)).'MB';
						}else{
							echo sprintf("%.2f", (filesize('../'.$row['fileaddr'])*0.001)).'KB';
						}
						echo '</span></li>';
					}
					?>
				</ul>
				</div>	
			
			
	</div>
		
		
		
		
		
		
		
		
		
		
  </div>
	</div><!-- /page -->
 <script type="text/javascript"> 
    window.onload = function(){ 
        var heg=document.getElementById("header").offsetHeight;
		var content=document.getElementById("content"); 
		content.style.cssText="margin-top:"+heg+"px;";
    }
	function active(type){
		if(type!=''){
			document.getElementById('files').className = 'uwh-FS2 c-gra-FS2 uc-a-FS2 ub ub-ac ub-pc';
			document.getElementById('infos').className = 'uwh-FS2 c-gra-FS2 uc-a-FS2 ub ub-ac ub-pc';
			document.getElementById('flows').className = 'uwh-FS2 c-gra-FS2 uc-a-FS2 ub ub-ac ub-pc';
			document.getElementById('file').style.cssText="margin-top:0px;";
			document.getElementById('info').style.cssText="margin-top:0px;";
			document.getElementById('flow').style.cssText="margin-top:0px;";
			document.getElementById(type+'s').className = 'uwh-FS2 sc-bg-alert uc-a-FS2 ub ub-ac ub-pc'; 
			mScroll(type);
			if(type!='file'){
				var heg=document.getElementById("header").offsetHeight;
				document.getElementById(type).style.cssText="margin-top:"+heg+"px;";
			}

		}
	}
	function mScroll(id){
		$("body").stop(true);
		$("body").animate({scrollTop: $("#"+id).offset().top}); 
	} 
</script> 
</body>
</html>
