<!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>
	<script type="text/javascript">
	function openBrowse(){ 
		var ie=navigator.appName=="Microsoft Internet Explorer" ? true : false; 
		if(ie){ 
			document.getElementById("fileupload").click(); 
			document.getElementById("filename").value=document.getElementById("fileupload").value;
		}else{
			var a=document.createEvent("MouseEvents");//FF的处理 
			a.initEvent("click", true, true);  
			document.getElementById("fileupload").dispatchEvent(a); 
		} 
	}
	</script>
</head>
<body class="um-vp c-wh " ontouchstart>
<form name="save" id="save" method="post" action="index.php?ac=workadd&do=add&fileurl=plugin&typeid=<?php echo $typeid?>&tplid=<?php echo $tplid?>&modid=<?php echo $modid?>">
<input type="hidden" name="workid" value="<?php echo $workid;?>" />
<input type="hidden" name="perid" value="<?php echo $flow['perid'];?>" />
<input type="hidden" name="flowid" value="<?php echo $flow['flowid'];?>" />
<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=workclass&fileurl=plugin'">
						<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>
					
					<div class="nav-btn nav-bt" id="nav-right">
					<a href="#popupMenu" data-rel="popup" data-transition="slideup"><div class="ub-img icon-edit umw2 umh4"></div></a>
						
					</div>
								
		   </div>
		  <div id="error" style="display:none; margin-top:65px;">流程信息保存成功！</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('mana');">
							<div class="ub-f1 ub ub-ac">
								<div class="uwh-FS1 c-gra-FS1 uc-a-FS1 ub ub-ac ub-pc">
									<div id="manas" 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 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 formStep3"></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 id="info">
				<div class="uinn-a6 sc-text  ulev-app1">
					流水号
					<input id="number" name="number" value="<?php echo $work['number'];?>" type="text">
				</div>
				<div class="uinn-a6 sc-text  ulev-app1">
					流程名称
					<input id="title" name="title" value="<?php echo $work['title'];?>" type="text">
				</div>
				<?php
				global $db;
				$query = $db->query("SELECT * FROM ".DB_TABLEPRE."workclass_from where tplid='".$work['tplid']."' and typeid='".$work['typeid']."' and inputtype!='6' and inputtype!='8' ORDER BY inputnumber Asc");
				while ($rowdb = $db->fetch_array($query)) {
					$formkey=public_value('formkey','workclass_flow','fid='.$flow['flowid']);
					//if(sizeof(explode('toa',$formkey))>1){
					if(sizeof(explode('"'.$rowdb['inputname'].'"',$formkey))>1){
						echo '<div class="uinn-a6 sc-text  ulev-app1">';
						echo $rowdb['fromname'];
						if($rowdb['inputtype']==0){
							if($rowdb['inputtype1']==2){
								echo '<textarea id="'.$rowdb['inputname'].'" cols="40" rows="8" style="height:20em;" name="'.$rowdb['inputname'].'">'.public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']).'</textarea>';
							}elseif($rowdb['inputtype1']==3){
								echo mob_radio('选择'.$rowdb['fromname'],$rowdb['inputname'],public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']),$rowdb['inputvaluenum']);
							}elseif($rowdb['inputtype1']==4){
								echo mob_select('选择'.$rowdb['fromname'],$rowdb['inputname'],public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']),$rowdb['inputvaluenum']);
							}elseif($rowdb['inputtype1']==5){
								echo mob_radio('选择'.$rowdb['fromname'],$rowdb['inputname'],public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']),$rowdb['inputvaluenum']);
							}else{
								echo '<input id="'.$rowdb['inputname'].'" name="'.$rowdb['inputname'].'" value="'.public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']).'" type="text">';
							}
						}elseif($rowdb['inputtype']==1){
							echo mob_radio_pic('选择图片',$rowdb['inputname'],public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']));
						}elseif($rowdb['inputtype']==2){
							echo mob_radio_pic('选择附件',$rowdb['inputname'],public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']));
						}elseif($rowdb['inputtype']==3){
							if(public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id'])!=''){
								$date=explode('-',public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id'])); 
								echo mob_date('选择日期',$rowdb['inputname'],$date[0],$date[1],$date[2],0);
							}else{
								$y=get_date('Y',PHP_TIME);
								$m=get_date('m',PHP_TIME);
								$d=get_date('d',PHP_TIME);
								echo mob_date('选择日期',$rowdb['inputname'],$y,$m,$d,0);
							}
						}elseif($rowdb['inputtype']==4){
							if(public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id'])!=''){
								echo '<input id="'.$rowdb['inputname'].'" name="'.$rowdb['inputname'].'" value="'.public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']).'" type="text">';
							}else{
								echo '<input id="'.$rowdb['inputname'].'" name="'.$rowdb['inputname'].'" value="'.get_depauseridname($USER->id,2).'" type="text">';
							}
						}elseif($rowdb['inputtype']==5){
							if(public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id'])!=''){
							
								echo mob_radio_user('选择成员',$rowdb['inputname'],public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']));
							}else{
								echo mob_radio_user('选择成员',$rowdb['inputname'],trim($USER->id));
							}
						}elseif($rowdb['inputtype']==7){
							echo mob_magnificent('选择内容',$rowdb['inputname'],public_value($rowdb['inputname'],'wd_'.$work['tplid'],'workid='.$work['id']),$rowdb['magnificent']);
						}
						echo '</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).')';
					}
					$numsv = $db->result("SELECT COUNT(*) AS numsv FROM ".DB_TABLEPRE."wd_".$work['tplid']."_".$from['fromid']." where workid='".$work['id']."' ".$html." ORDER BY vid asc");
					$sqlwv = "SELECT * FROM ".DB_TABLEPRE."wd_".$work['tplid']."_".$from['fromid']." where workid='".$work['id']."' ".$html." ORDER BY vid asc";
					$resultws = $db->fetch_all($sqlwv);
					$numtr=10-$numsv;
					?>
					<div class="uinn-a6 t-gra3 ulev-app1">
						<?php echo $from['fromname'];?><input type="hidden" name="inputname6[]" value="<?php echo $from['inputname'];?>,<?php echo $from['fromid'];?>" />
					</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) {?>
							<input type="hidden" name="t6<?php echo $from['fromid'];?>[]" value="1" />
							<div class="ub c-wh uinn-a1 ubb bc-border">
								<?php foreach ($results as $row) {?>
								<div class="uw-rank t-blu ulev-4 ufm1">
									<input type="text" data-role="none" name="<?php echo $row['inputname'];?>[]" style="height:2em; width:5em;" value="<?php echo $roww[$row['inputname']];?>" placeholder="<?php echo $row["fromname"];?>" />
								</div>
								<?php }?>
							</div>
							<?php }?>
							<?php for($i=1;$i<=$numtr;$i++){?>
							<input type="hidden" name="t6<?php echo $from['fromid'];?>[]" value="1" />
							<div class="ub c-wh uinn-a1 ubb bc-border">
								<?php foreach ($results as $row) {?>
								<div class="uw-rank t-blu ulev-4 ufm1">
									<input type="text" data-role="none" name="<?php echo $row['inputname'];?>[]" style="height:2em; width:5em;" value="" placeholder="<?php echo $row["fromname"];?>" />
								</div>
								<?php }?>
							</div>
							<?php }?>
						</div>
					</div> 
					
					<?php }
					}
					?>
			
			<!--附件 -->
			<div class="uinn-a6 sc-text  ulev-app1" id="file">
				流程附件
			</div>
			<style>
					.progressbar {
						width: 0px;
						height: 25px;
						margin - bottom: 20px;
						background:#006633;
						color:#FFFFFF;
						font-size:14px;
						font-weight:bold;
					}
				  </style>
			<div class="ub ub-ver uinn-a1 ub-f1">
				<div class="uba bc-border c-wh">
				<input data-role="none" id="fileupload" type="file" name="files[]" multiple style="display:none">
				<input type="hidden" id="filename"/>
				<div class="progressbar" id="progressbar">
					<div id="progress-bar"></div>
				</div>
				<ul>
				<?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']);
				?>
				<li class="ubb ub bc-border t-bla ub-ac lis" data-index="0" onClick='javascript:window.location="../<?php echo $row['fileaddr']?>"'>
					<ul class="ub-f1 ub ub-pj ub-ac">
						<ul class="ub-f1 ub ub-ver marg-l">
							<li class="bc-text ub ub-ver ut-m line1"><?php echo $row['filename']?></li>
						</ul>
						<li class="fa fa-angle-right ulev2"></li>
					</ul>
				</li>
				<?php } ?>
				<div id="filess"></div>
				</ul>
				
					
				</div>
				
				<div class="uinn" onClick="javascript:openBrowse();">
					<div class="btn ub ub-ac bc-text-head ub-pc bc-btn uc-a1">
						流程附件上传
					</div>
                </div>
			</div>	
			
			
			<!--审批 -->
			<div class="uinn-a6 sc-text  ulev-app1" id="mana">
				签批内容
			</div>
			<div class="ub ub-ver uinn-a1 ub-f1">
				<div class="uba bc-border c-wh">
				<textarea data-role="none" id="contents" cols="40" rows="8" style="height:5em; width:18em; border: #F8F8F8 solid 0px;" name="content" placeholder="输入内容"></textarea>
				</div>
			</div>	
			<!--流程办理进度 -->
			<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']."'";
						$flows = $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 $flows['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($flows['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{?>
							<?php 
							$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 }?>
							<?php }?>
							<?php }?>
							
							<?php }?>
						</li>
					</ul>
					<?php }?>
							
				</div>
			</div>		
		</div>
		
	</div>
	<div data-role="popup" id="popupMenu"  style="min-width:240px;top:90px;right:30px;">
            <div class="c-wh uinn ub-ver">
				<div class=" uinn"  onClick="sendForm();">
                    <div class="btn ub ub-ac bc-text-head ub-pc  uc-a1 uba b-gra t-gra">
                        保存数据
                    </div>
                </div>
				<div class="uinn" onClick="flowForm();">
                    <div class="btn ub ub-ac bc-text-head ub-pc bc-btn uc-a1">
                        转交下一步
                    </div>
                </div>
				<?php
				$flowkey=public_value('flowkey','workclass_flow','fid='.$flow['flowid']);
				if($flowkey==3){
				?>
                <div class="uinn"  onClick="flowFormup();">
                    <div class="btn ub ub-ac bc-text-head ub-pc sc-btn uc-a1">
                        流程退回
                    </div>
                </div>
				<?php }?>
                

            </div>
	</div>
	
</div><!-- /page -->
</form>
 <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;";
		<?php if($_GET['error']!=''){?>
		$("#error").fadeIn("slow");
		window.setTimeout('$("#error").hide();',2000);
		<?php }?>
    }
	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('manas').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('mana').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);
			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}); 
	}
	function CheckForm()
	{
	   if(document.save.number.value=="")
	   { alert("流水号不能为空！");
		 document.save.number.focus();
		 return (false);
	   }
	   if(document.save.title.value=="")
	   { alert("流程名称不能为空！");
		 document.save.title.focus();
		 return (false);
	   }
	<?
	global $db;
	$query = $db->query("SELECT * FROM ".DB_TABLEPRE."workclass_from where typeid='".$typeid."' and tplid='".$tplid."' and inputtype!='6' and inputtype!='3' and inputtype1!='3' and inputtype1!='4' ORDER BY inputnumber Asc");
	$formkey=public_value('formkey','workclass_flow','fid='.$flow['flowid']);
		while ($row = $db->fetch_array($query)) {
		if(sizeof(explode('"'.$row['inputname'].'"',$formkey))>1){
			if($row["confirmation"]=='1'){
	?>
	
	if(document.save.<?php echo $row["inputname"]?>.value=="")
	   { alert("<?php echo $row["fromname"]?>不能为空！");
		 document.save.<?php echo $row["inputname"]?>.focus();
		 return (false);
	   }
	   
	<?php
		}
	  }
	}
	?>
	   return true;
	}
	function ckeditor(){
	   if(document.save.content.value==""){
	     alert("流程签批不能为空！");
		 document.save.content.focus();
		 return (false);
	   }
	   return true;
	}
	function sendForm()
	{
	   if(CheckForm()){
		  document.save.submit();
	   }
	}
	function flowForm()
	{
	   if(CheckForm() && ckeditor()){
		  //ckeditor();
		  document.getElementById("save").action = 'index.php?ac=workflow&fileurl=plugin&typeid=<?php echo $typeid?>&tplid=<?php echo $tplid?>&modid=<?php echo $modid?>';
		  document.getElementById("save").submit();
	   }
	}
	function flowFormup()
	{
		document.getElementById("save").action = 'index.php?ac=workflow&fileurl=plugin&typeid=<?php echo $typeid?>&tplid=<?php echo $tplid?>&do=up&modid=<?php echo $modid?>';
		document.getElementById("save").submit();
	}
</script>
<!-- The jQuery UI widget factory, can be omitted if jQuery UI is already included -->
<script src="../template/default/upload/js/vendor/jquery.ui.widget.js"></script>
<!-- The Iframe Transport is required for browsers without support for XHR file uploads -->
<script src="../template/default/upload/js/jquery.iframe-transport.js"></script>
<!-- The basic File Upload plugin -->
<script src="../template/default/upload/js/jquery.fileupload.js"></script>
<!-- Bootstrap JS is not required, but included for the responsive demo navigation -->
<script src="../template/default/upload/js/bootstrap.min.js"></script>
<script>
/*jslint unparam: true */
/*global window, $ */
$(function () {
    'use strict';
    // Change this to the location of your server-side upload handler:
    var url = window.location.hostname === 'blueimp.github.io' ?
                '' : '../upload/index.php?userid=<?php echo $_USER->id;?>';
    $('#fileupload').fileupload({
        url: url,
        dataType: 'json',
        done: function (e, data) {
            $.each(data.result.files, function (index, file) {
				var html='';
				html+='<li class="ubb ub bc-border t-bla ub-ac lis" data-index="0" ';
				html+=' onClick=javascript:window.location="'+file.url+'">';
				html+='<ul class="ub-f1 ub ub-pj ub-ac">';
				html+='<ul class="ub-f1 ub ub-ver marg-l">';
				html+='<li class="bc-text ub ub-ver ut-m line1">'+file.name+'</li>';
				html+='</ul>';
				html+='<li class="fa fa-angle-right ulev2"></li>';
				html+='</ul>';
				html+='</li>';
				public_fileadd(file.name,file.url);
				//html+='<li>'+file.name+'<span class="ui-li-count">'+(file.size/1000)+'KB</span></li>';
				$('<p>').html(html).appendTo('#filess');
            });
        },
        progressall: function (e, data) {
            var progress = parseInt(data.loaded / data.total * 100, 0);
			$('#progressbar').css(
				'width',
				progress + '%'
			);
			$("#h4txt").hide();
			$("#progress-bar").text(progress + '%');
        }
    }).prop('disabled', !$.support.fileInput)
        .parent().addClass($.support.fileInput ? undefined : 'disabled');
});
	function public_fileadd(title,annex){
			if(annex!=''){
				jQuery.ajax({
				  type: 'GET',
				  url: 'index.php?ac=workadd&fileurl=plugin&workid=<?php echo $workid;?>&do=fileadd&title='+escape(title)+'&annex='+annex+'&newdate='+new Date(),
				  success: function(data){
					  if(data=='false'){
						  return (false);
					  }else if(data=='true'){
						  return (true);
					  }
				  }
			   });
		   }
		}
</script>

</body>
</html>
