<?php
require_once("module/module.issue.php");
$issue = new CModuleIssue();
$issue->Init($_REQUEST["issue_id"]);
$issue->InitLog();
$issue->InitComment();

$query_id = 0;
$page = 0;
$view_job = 'issue_list';
if(array_key_exists("query_id", $_REQUEST))
{
	$query_id = $_REQUEST['query_id'];
	$page = $_REQUEST['page'];
	$view_job=$_REQUEST['view_job'];
}
?>
<input type="hidden" id="hidden_query_id" value=<?php echo $query_id?>>
<input type="hidden" id="hidden_page" value=<?php echo $page?>>
<input type="hidden" id="hidden_view_job" value="<?php echo $view_job?>">

<table width=99% bgcolor=#cccccc border=0 cellspacing=0 cellpadding="0" align=center>
	<tr height=26>
		<?php for($i=0;$i<sizeof($issue->modules[0]->actions);$i++){?>
			<td align=center width=80 bgcolor=#D0D0F0 id="title1" class="link" onclick="ClickIssueAction(<?php echo $issue->modules[0]->issue_id?>,<?php echo $issue->modules[0]->actions[$i]->action_id?>)">
					<img src="imgs/problem_process.gif" class="icon" border=0><?php echo $issue->modules[0]->actions[$i]->action_name?>
			</td>
			<td bgcolor=#ffffff  width=1></td>
		<?php }?>
		<td bgcolor=#ffffff>&nbsp;</td>
	</tr>
</table>

<table width=99% border=0 cellspacing="1" cellpadding="0" align=center bgcolor=#cccccc>
<tr>
<td>
		<table width=100% bgcolor=#ffffff border=0 cellspacing="1" cellpadding="0" align=center>
			<tr>
				<td colspan=2 style="padding-left:20;line-height:200%">
						项目: <?php echo $issue->modules[0]->project_name?>
						<br>
						模块: <?php echo $issue->modules[0]->module_name?>
						<br>
						<?php if($issue->modules[0]->parent_issue){?>
							父事务: <a href="javascript:go2issue(<?php echo $issue->modules[0]->parent_issue->issue_id?>)"><?php echo $issue->modules[0]->parent_issue->issue_title?></a> 
							<?php echo $issue->modules[0]->parent_issue->status_name?>
							<br>					
						<?php }?>	
						<span class='big' style="padding-left:40"><?php echo $issue->modules[0]->issue_title ?></span>
						&nbsp;&nbsp;&nbsp;&nbsp;
						<?php if($issue->modules[0]->ContainActionUser($UserInfo['UID'])){?>						
							<span class="link" style="background-color:#99bb00; color:#D0DCE9;" style="padding-left:5;padding-right:5" onclick="go2web('index.php?job=issue_create&project_id=<?php echo $issue->modules[0]->project_id?>&parent_id=<?php echo $issue->modules[0]->issue_id?>')"> 
								+ 子事务
							</span>						
						<?php }?>
						<br>
						<?php for($i=0;$i<sizeof($issue->modules[0]->child_issues); $i++){?>
							<span style="padding-left:60">
								<a href="javascript:go2issue(<?php echo $issue->modules[0]->child_issues[$i]->issue_id?>)"><?php echo $issue->modules[0]->child_issues[$i]->issue_title?></a>
								<?php echo $issue->modules[0]->child_issues[$i]->status_name?>
							</span>
							<br>
						<?php }?>		
				</td>
			</tr>
			<tr height=1>
				<td width="70%"><hr size=1 color=#D0DCE0></td>
				<td width="30%" style="padding-left:40;"><hr size=1 color=#D0DCE0></td>
			</tr>
			<tr>
				<td style="padding-left:20; padding-top:10"  valign=top>
						
						<table bgcolor=#ffffff border=0 cellspacing="1" cellpadding="0" >
							<tr height=30>
								<td align="right" width=80>当前状态:</td>
								<td width=160 style="padding-left:10;"><u><?php echo $issue->modules[0]->status_name?> &nbsp;&nbsp; </td>
								<td align="right">事务类型:</td>
								<td style="padding-left:10;"><u><?php echo $issue->modules[0]->issue_type_name?> &nbsp;&nbsp; </td>
							</tr>
							<tr height=30>
								<td align="right" width=80>严重性:</td>
								<td width=160 style="padding-left:10;"><u><?php echo $Config["serverity"][$issue->modules[0]->serverity_id]?> &nbsp;&nbsp;  </td>
								<td align="right" width=100>处理优先级:</td>
								<td width=160 style="padding-left:10;"><u><?php echo $Config["priority"][$issue->modules[0]->pripority_id]?> &nbsp;&nbsp;  </td>
							</tr>
						
							<tr>
								<td align="right" valign=top>创建者:</td>
								<td valign=top style="padding-left:10;"><u><?php echo $issue->modules[0]->create_user_name?> &nbsp;&nbsp;  </td>
								<td align="right" valign=top>当前处理者:</td>
								<td style="padding-left:10;">									
									<?php for($i=0;$i<sizeof($issue->modules[0]->action_users);$i++){?>
										<u>
											<?php echo $issue->modules[0]->action_users[$i]->action_user_name?> &nbsp;&nbsp; 
											<?php echo $issue->modules[0]->action_users[$i]->action_name?> &nbsp;&nbsp; 
											<?php if($issue->modules[0]->action_users[$i]->action_name!="") {echo $issue->modules[0]->action_users[$i]->action_time;}?>
										</u>
										<br>
									<?php }?>	
									
								</td>
							</tr>							
						</table>
						
						<br>
						<fieldset style='padding-left:20;'>
							<legend>详细描述</legend>
								<br>
								<?php echo $issue->modules[0]->issue_content;?>
							<br>
							
							<!--事务编辑功能------------------------------------------------------------------------------------------------------------------------------>
								<table border=0 cellspacing="1" cellpadding="0" bgcolor="#cccccc" align="right"><tr bgcolor="#FFFFCC"><td>
									<?php if($issue->modules[0]->edit_grade & $Config["issue_config_comment"]){?><img class="link" src="imgs/addcomment.gif"  alt='评论' onclick="ClickIssueComment(<?php echo $issue->modules[0]->issue_id?>)"><?php }?>
									<?php if($issue->modules[0]->edit_grade & $Config["issue_config_attach"]){?><img class="link" src="imgs/common.gif " alt='添加附件' onclick="ClickIssueAttach(<?php echo $issue->modules[0]->issue_id?>)"><?php }?>																
									<?php if($issue->modules[0]->edit_grade & $Config["issue_config_edit"]){?><img class="link" src="imgs/problem_edit.gif " alt='编辑' onclick="ClickIssueEdit(<?php echo $issue->modules[0]->issue_id?>)"><?php }?>
									<?php if($issue->modules[0]->edit_grade & $Config["issue_config_open"] && $issue->modules[0]->is_close){?><img class="link" src="imgs/s_reload.png " alt='重打开'><?php }?> 
									<?php if($issue->modules[0]->edit_grade & $Config["issue_config_tran"]){?><img class="link" src="imgs/s_process.png " alt='转移' onclick="ClickIssueTran(<?php echo $issue->modules[0]->issue_id?>)"><?php }?>
									<?php if($issue->modules[0]->edit_grade & $Config["issue_config_del"]){?><img class="link" src="imgs/b_empty.png" alt='删除' onclick="ClickDelIssue(<?php echo $issue->modules[0]->issue_id?>)"><?php }?>									
								</td></tr></table>			
							<!--事务编辑功能------------------------------------------------------------------------------------------------------------------------------>
							
							<br>
						</fieldset>						
							<br>
							<span class=small>
								<ul id="controls">		
										<li class="active"><span class="" id='li_log' onclick="SwitchPage(1)">处理日志(<?php echo sizeof($issue->modules[0]->logs)?>)</span></li>								
										<li class=""><span class="link" id='li_comment' onclick="SwitchPage(2)">评论信息(<?php echo sizeof($issue->modules[0]->comments)?>)</span></li>				
								</ul>
							</span>
							<br>
							<div id="div_issue_log">
								<?php for($i=0; $i<sizeof($issue->modules[0]->logs); $i++ ){ ?>
									<fieldset style='padding-left:20;'>
										<legend>
												<?php echo $issue->modules[0]->logs[$i]->work_time;?> &nbsp;&nbsp;
												<?php echo $issue->modules[0]->logs[$i]->real_name;?> &nbsp;&nbsp;
									 			<?php echo $issue->modules[0]->logs[$i]->action_name;?>
										</legend>									
										<?php echo $issue->modules[0]->logs[$i]->work_log;?>
										
										
										<?php if($issue->modules[0]->logs[$i]->attach){?>
													&nbsp;&nbsp;&nbsp;&nbsp;
									 				<span class="link" onclick="document.location.href='<?php echo $issue->modules[0]->logs[$i]->attach->file_name?>'">
													<img src="imgs/files/<?php echo $issue->modules[0]->logs[$i]->attach->attach_type?>.gif" class="icon">
													<?php echo $issue->modules[0]->logs[$i]->attach->attach_name?>
													</span>
													
													<?php 
														$file_size = $issue->modules[0]->logs[$i]->attach->file_size;
														if($file_size < 1024)
															echo $file_size . " byte";
														else if($file_size < 1024*1024)
															echo round($file_size/1024,2) . " kb";
														else
															echo round($file_size/(1024*1024),2) . " mb";
													?>
									 			<br>
									 			<?php }?>
										
									</fieldset>
									<br>
								<?php }?>
							</div>
							
							<div id="div_issue_comment" style="display:none">
								<?php for($i=0; $i<sizeof($issue->modules[0]->comments); $i++ ){ ?>
									<fieldset style='padding-left:20;'>
										<legend>
												<?php echo $issue->modules[0]->comments[$i]->comment_time;?> &nbsp;&nbsp;
												<?php echo $issue->modules[0]->comments[$i]->real_name;?> &nbsp;&nbsp;
										</legend>									
										<?php echo $issue->modules[0]->comments[$i]->issue_comment;?>
										<br>
									</fieldset>
									<br>
								<?php }?>
							</div>
				</td>
				<td style="padding-left:40;line-height:200%" valign=top>
					创建时间:<?php echo $issue->modules[0]->create_time?><br>
					到期时间:<?php echo $issue->modules[0]->exp_time?><br>
					关闭时间:<?php echo $issue->modules[0]->close_time?><br>
					附 件:<br>
						<?php for($i=0;$i<sizeof($issue->modules[0]->attachs);$i++){?>
							<span class="link" onclick="document.location.href='<?php echo $issue->modules[0]->attachs[$i]->file_name?>'">
							<img src="imgs/files/<?php echo $issue->modules[0]->attachs[$i]->attach_type?>.gif" class="icon">
							<?php echo $issue->modules[0]->attachs[$i]->attach_name?>
							</span>
							
							<?php 
								$file_size = $issue->modules[0]->attachs[$i]->file_size;
								if($file_size < 1024)
									echo $file_size . " byte";
								else if($file_size < 1024*1024)
									echo round($file_size/1024,2) . " kb";
								else
									echo round($file_size/(1024*1024),2) . " mb";
							?>
							
							<br>
						<?php }?>
				</td>
			</tr>
		</table>
	</td>
</tr>
</table>

<script>
		div = "<div >";
		div += "<table width=100%>";
		div += "<tr height=30>";
		div += "<td align=center class='link' onclick=\"go2web('index.php?job=<?php echo $view_job?>&query_id=<?php echo $query_id?>&page=<?php echo $page?>')\">";
		div += "<b><img border=0 src=imgs/undo_16.gif class=icon>返回";
		div += "</td></tr>";
		div += "</table>";
		div += "</div>";
		DispLayer(div, 160, 50, 0, 80, "#FFFFCC");	
</script>