<script type="text/JavaScript">
<!--
	// FOR MEMENTO PLUS	
	{literal}
	// check that a date is written correctly
	checkDate_regexp = {/literal}{$internal_date_format_js}{literal}
	function checkDate(input) {
		result_array = checkDate_regexp.exec(input.value);
		if ((result_array != null) && (result_array[0] == input.value)) {
			return true;
		} else {
			alert('{/literal}{$ERROR.invalid_date|addslashes}{literal}');
			return false;
		}
	} // end of checkDate(input)
	
	// open a popup at the center of the screen
	function centeredPopup(url, width, height, options) {
		var top=(screen.height - height) / 2;
		var left=(screen.width - width) / 2;
		window.open(url,"","top="+top+",left="+left+",width="+width+",height="+height+","+options);
	}

//config for server
var server = "PointToYourPHPScriptWhichUsesPearXML_RPC_andhas some methods defined "
var target_object;
function sendXMLRPC(url, method, value) {
     //branch for native object
     type = method;
     if (window.XMLHttpRequest) {
         req = new XMLHttpRequest();
         req.onreadystatechange = processReqChange;

         req.open("POST", url, true);
         req.setRequestHeader("Content-Type", "text/xml");
         req.send('<?xml version="1.0"?>\n'+
'<methodCall>\n'+
'<methodName>'+ method + '</methodName>\n'+
'<params>\n'+
'<param>\n'+
'<value>\n'+
'<string>' + value + '</string>\n'+
'</value>\n'+
'</param>\n'+
'</params>\n'+
'</methodCall>\n');
     }
}

function processReqChange() {
     // only if req shows "loaded"
     if (req.readyState == 4) {
         // only if "OK"
         if (req.status == 200) {
         //hand off to delegate function
	 	update(type);
          } else {
             alert("There was a problem retrieving the XML data:\n" +
                 req.statusText);
          }
     }
}



	
	{/literal}
//-->
</script>
    <!-- File title : project title : next/previous links and back to list link -->
	<table border="0" width="100%">
		<tr>
			<td>
				<h3> <!-- PAGE TITLE -->
					{$TITLE.file_edition} #{$file.bug_id.value}
				</h3>
				<h4> <!-- file title -->
					&nbsp;&nbsp;&nbsp;<i>{$file.title.value}</i>
				</h4> <!-- link to file list -->
			</td> 
		</tr>
		<tr>
			<td colspan="5">
				<div align="left" class="bugdisplaylinks">
				</h4> <!-- link to file list -->
				{if isset($smarty.session.queryinfo) && count($smarty.session.queryinfo)}
					<b>
						<a href="query.php?op=redoquery">
							{$STRING.BUGDISPLAY.returnto} {$STRING.BUGDISPLAY.buglist}
						</a>
					</b> 
					&nbsp;&nbsp;|&nbsp;&nbsp;
				{/if}
					<b>
						<a href="{$smarty.server.PHP_SELF}?op=history&file_id={$file.bug_id.value}">
							{$STRING.BUGDISPLAY.viewbugactivity}
						</a>
					</b> 
					&nbsp;&nbsp;|&nbsp;&nbsp;
					<b>
						<a href="{$smarty.server.PHP_SELF}?op=print&file_id={$file.bug_id.value}">
							{$STRING.BUGDISPLAY.printableview}
						</a>
					</b>
				</div>
			</td>
			
		</tr>

	</table>
	<br>
<form action="bug.php" method="post" onSubmit="return checkForm(this)">
    <input type="hidden" name="op" value="update">
    <input type="hidden" name="file_id" value="{$file.bug_id.value}">
    <input type="hidden" name="last_modified_date" value="{$file.last_modified_date.value}">
    <input type="hidden" name="pos" value="{$smarty.request.pos}">
{if $mpfile->sp_cache.description->hidden != true}
<div class="mainFrame">
<div class="section">
	{$STRING.description_of_file} {$file.bug_id.value}:&nbsp;&nbsp;&nbsp;<i>{$file.title.value}</i> 				
</div>
	<div class="alt">	{$STRING.BUGDISPLAY.postedby} : {build_dynamic_input 
						field_conf=$file.created_by.field_conf
						file_id=$file.bug_id.value
						name='_no_name'
						value=$file.created_by.value
						mpfile=$mpfile
						read_only=1
						no_html=1
					} 
	<br>
	{$STRING.BUGDISPLAY.date} : {$file.created_date.value|date:TIME_FORMAT} {$STRING.BUGDISPLAY.dateon} {$file.created_date.value|date:DATE_FORMAT}
	<br>
	</div>
	<div class="contentFrame">
		<br>
		{$file.description.value|htmltruespace|nl2br|format_comments}
		<br>
		<br>
	</div>
</div>
{/if}
<!--<table class="section" width="100%"> <tr align="center"><td align="center"> -->
<div class="mainFrame" align="center">
<div class="section">
	{$STRING.field_edition}  				
{if $mpfile->sp_cache.description->hidden == true}
	&nbsp;&nbsp;&nbsp; {$STRING.file} {$file.bug_id.value} :&nbsp;&nbsp;<i>{$file.title.value}</i>
{/if}
</div>
	<table border="0" cellspacing="0" cellpadding="0" width="91%">
		{if $error.status}
		<tr>
			<td class="error" colspan=4>
				{$error.status}
			</td>
		</tr>
		{/if}
		{assign var=Shift value='null'}
		{foreach key=k item=v name=std_fields from=$fc_filtered}
			{* Try to reload previous data if there's been an error *}
			{ if $error.status && isset($primary_input_array.$k)}
				{assign var=treated_value value=$primary_input_array.$k}
			{else} {* if it's the normal case *}
				{assign var=treated_value value=$file.$k.value}
			{/if}
			{* if true, create a new table row *}
			{if $smarty.foreach.std_fields.iteration is odd && $Shift=='null'}
		<TR valign="top">
			{else}
				{if $smarty.foreach.std_fields.iteration is even && $Shift=='offset'}
		<TR valign="top">
				{else}
					{if $mpfile->sp_cache.$k->label}
		<TR valign="top">
					{/if}
				{/if}
			{/if}
			{if $mpfile->sp_cache.$k->label}
			<TD colspan="4"> 
				<DIV class="label">
					{$v.title}
				</DIV>
				<DIV class="endlabel">
					&nbsp;
				</DIV>
			</TD>
			{else}
			<TD align="left">
				<DIV class="cell" >
					<!-- POPUP of field properties-->
					<font size="1">
						<a 
							onClick="javascript:centeredPopup('{$smarty.server.PHP_SELF|dirname}/popup_field_properties.php?op=show&fid={$v.field_conf_id}', {$popup_field_properties_width}, {$popup_field_properties_height}, 'resizable=yes')"
						>
							<img name="title" src="{$template_path}/images/doc.png" alt="?" >
						</a>
					</font>
					<B>
					{if $mpfile->sp_cache.$k->highlight_url}
						<!-- convert the title into a link -->
					<A href="{$file.$k.value|url_with_header_encode}" target="new">
					{/if}						
					{$v.title} :
					{if $mpfile->sp_cache.$k->highlight_url}
					</A>
					{/if}
					</B>
	
					{if $v.field_type_title == $string && $mpfile->sp_cache.$k->maxlen == '0' }
					<br>
					{else}
					{/if}
				 <!-- 'k' is also the field_name  -->
					{if $k == 'assigned_to'}
						{build_dynamic_input 
							field_conf=$v 
							file_id=$file.bug_id.value
							name='_no_name'							
							mpfile=$mpfile
							read_only=1				
						}
					<!-- the project id is handled like a normal field
					{literal}					
					{elseif ($k == 'project_id')}
						{build_dynamic_input 
							field_conf=$v 
							file_id=$file.bug_id.value
							name='_no_name'
							value=$project_id
							mpfile=$mpfile
							read_only=1
						}
					{/literal}
					-->
					{else}
						{if $smarty.session.uid} {* if logged *}
							{if !empty($mpfile->sp_cache.$k->read_only)}
								{assign var=RO value=$mpfile->sp_cache.$k->read_only}
							{else}
								{if !empty($mpfile->sp_cache.$k->label)}
									{assign var=RO value=$mpfile->sp_cache.$k->label}
								{else}
									{assign var=RO value=0}
								{/if}
							{/if}
						{else}
							{assign var=RO value=1}
						{/if}
						{build_dynamic_input 
							field_conf=$v 
							file_id=$file.bug_id.value
							name=$v.field_name
							value=$treated_value
							mpfile=$mpfile
							read_only=$RO
						}
					{/if}
					</DIV>
				</TD>
				<TD>
				&nbsp;&nbsp;&nbsp;
				</TD>
			{/if}
			{if $mpfile->sp_cache.$k->dashAfter || $mpfile->sp_cache.$k->label}
				{if $mpfile->sp_cache.$k->dashAfter}
					</TR>
  					<tr>
					<td class="underlined"><img src="{$template_path}/images/spacer.gif"  width="32" height="1"></td>
					<td class="underlined"><img src="{$template_path}/images/spacer.gif"  width="32" height="1"></td>
					<td class="underlined"><img src="{$template_path}/images/spacer.gif"  width="32" height="1"></td>
					<td class="underlined"><img src="{$template_path}/images/spacer.gif"  width="32" height="1"></td>
					</TR>
				{/if}
				{if $smarty.foreach.std_fields.iteration is odd}
					{if $Shift=='null'}
						{assign var=Shift value='offset'}
					{else}
						{assign var=Shift value='offset'}
					{/if}
				{else}
					{if $Shift=='offset'}
						{assign var=Shift value='null'}
					{else}
						{assign var=Shift value='null'}
					{/if}
				{/if}
			{else}
				{if $smarty.foreach.std_fields.iteration is even && $Shift=='null'}
					</TR>		
				{/if}
				{if $smarty.foreach.std_fields.iteration is odd && $Shift=='offset'}
					</TR>		
				{/if}
			{/if}
		{/foreach}
		<TR>
			<TD colspan="4"> 
				<DIV class="label">
					{$STRING.BUGDISPLAY.Rest}
				</DIV>
				<DIV class="endlabel">
					&nbsp;
				</DIV>
			</TD>
		</TR>
		<tr valign="center">
		{if $smarty.session.uid}  {* if logged *}
		<td valign="center" rowspan="5">
			<table>
				<tr>
					<td>
				{$STRING.BUGDISPLAY.change_assignation} : 
				
				{* if there's been an error *}
				{ if $error.status  && isset($primary_input_array.assigned_to)}
					{assign var=treated_value value=$primary_input_array.assigned_to}					
				{else} {* if it's the normal case *}
					{assign var=treated_value value=null}
				{/if}
					</td>	
					<td>	
				{build_dynamic_input 
					field_conf=$field_conf.assigned_to
					name=assigned_to
					file_id=$file.bug_id.value
					mpfile=$mpfile
					allow_void=1
					value=$treated_value
					}
					</td>
				</tr>
			</table>
			</td>
			<TD rowspan="5">
				&nbsp;&nbsp;&nbsp;
			</TD>
		{/if}
			<td>
				{$STRING.BUGDISPLAY.addcc} :	
				<input type="text" name="add_cc" {if isset($add_cc)}value={$add_cc|stripslashes}{/if}>
			</td>
		</tr>
		<tr >
		{if count($contact_list)}
			<td valign="top">
				{$STRING.BUGDISPLAY.removeselectedcc} :
				<SELECT name="remove_cc[]" multiple>
				{foreach key=k item=v name=cclist from=$contact_list}
					<option value="{$v.user_id}" 
					{if is_array($remove_cc) && in_array($v.user_id, $remove_cc)}
						SELECTED
					{/if}>
						{$v.first_name} {$v.last_name}
					</option>
				{/foreach}
				</SELECT>
			</td>
		{/if}
		</tr>
		<tr>
			<td valign="top">
			{if !empty($error.add_dep)}
				<div class="error">
					{$error.add_dep}
				</div>
			{/if}
				{$STRING.BUGDISPLAY.bugdependency} :
				{$bug_dependencies} 
			</td>
		</tr>
		<tr>
			<td>
				{$STRING.BUGDISPLAY.adddependency} : 
				<input type="text" name="add_dependency" size="5" {if isset($add_dependency)} value="{$add_dependency}" {/if}> 
			</td>
		</tr>
		<tr>
			<td>
				{$STRING.BUGDISPLAY.removedependency} :
				<input type="text" name="del_dependency" size="5" {if isset($del_dependency)} value="{$del_dependency}" {/if}> 
			</td>			
		</tr>
		<tr>
			<td colspan="4">
				<table border="0" cellpadding="0" width="100%">
					<tr>
						<!-----------------------------ATTACHMENTS-------------------------------->
						<td colspan="2">
							{$STRING.BUGDISPLAY.attachments} :
						</td>
						<td colspan="3" align="right">
							{if $smarty.session.uid}  {* if logged *}
								<!-- TODO -->
								<a href="javascript:centeredPopup('{$smarty.server.PHP_SELF|dirname}/attachment.php?use_js=1&file_id={$file.bug_id.value|intval}' , 380, 150, 'resizable=yes');"
								>
									{$STRING.BUGDISPLAY.createattachment}
								</a>
							{/if}
						</td>
					</tr>
					<tr>
					<td colspan="5" height="2" bgcolor="#ffffff">
						<spacer type="block" height="2" width="2">
					</td>
				</tr>
				<tr>
					<td bgcolor="#cccccc" align="center"><b>{$STRING.BUGDISPLAY.name}</b></td>
					<td width="60" bgcolor="#cccccc" align="center"><b>{$STRING.BUGDISPLAY.size}</b></a></td>
					<td width="150" bgcolor="#cccccc" align="center"><b>{$STRING.BUGDISPLAY.type}</b></a></td>
					<td width="80" bgcolor="#cccccc" align="center"><b>{$STRING.BUGDISPLAY.created}</b></a></td>
					<td width="80" bgcolor="#cccccc" align="center">&nbsp;</a></td>
				</tr>
				<tr>
					<td bgcolor="#000000" height="1"><spacer type="block" height="1" width="1"></td>
					<td bgcolor="#000000" height="1"><spacer type="block" height="1" width="1"></td>
					<td bgcolor="#000000" height="1"><spacer type="block" height="1" width="1"></td>
					<td bgcolor="#000000" height="1"><spacer type="block" height="1" width="1"></td>
					<td bgcolor="#000000" height="1"><spacer type="block" height="1" width="1"></td>
				</tr>
					{section name=attachment loop=$attachments}
						<tr 
							title="{$attachments[attachment].description|stripslashes}"
							{if $smarty.section.attachment.iteration is even} 
								class="alt" bgcolor="#dddddd"
							{/if}>
							<td>
								{$attachments[attachment].file_name|stripslashes}
							</td>
						<td align="right">
							{if $attachments[attachment].file_size > 1024}
								{math equation="(round(x) / 1024 * 100) / 100" x=$attachments[attachment].file_size assign=file_size}
								{$file_size|number_format}k
							{else}
								{$attachments[attachment].file_size|number_format}b
							{/if}
						</td>
						<td align="center">{$attachments[attachment].mime_type}</td>
						<td align="center">{$attachments[attachment].created_date|date:DATE_FORMAT}</td>
						<td align="center">
							<a href='attachment.php?attachid={$attachments[attachment].attachment_id}'>
								View
							</a>
							{if isset($perm) and $perm->have_perm('Administrator')}
								| 
								<a 
									href='attachment.php?del={$attachments[attachment].attachment_id}' 
									onClick="return confirm('{$STRING.BUGDISPLAY.suredeleteattachment}');">
									{$STRING.delete}
								</a>
							{/if}
						</td>
					</tr>
				{sectionelse}
					<tr>
						<td colspan="5" align="center">{$STRING.BUGDISPLAY.noattachments}</td>
					</tr>
				{/section}
					<tr>
						<td bgcolor="#000000" height="1"><spacer type="block" height="1" width="1"></td>
						<td bgcolor="#000000" height="1"><spacer type="block" height="1" width="1"></td>
						<td bgcolor="#000000" height="1"><spacer type="block" height="1" width="1"></td>
						<td bgcolor="#000000" height="1"><spacer type="block" height="1" width="1"></td>
						<td bgcolor="#000000" height="1"><spacer type="block" height="1" width="1"></td>
					</tr>
					<tr>
						<td colspan="5" height="2" bgcolor="#ffffff">
							<spacer type="block" height="2" width="2">
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</div>	<!-- </td></tr></table> -->

<br>
<br>
<div class="mainFrame">
<div class="section">
{$STRING.BUGDISPLAY.comments} :
</div>
<table border="0" cellpadding="2" cellspacing="0" width="91%" >
	{section name=comment loop=$comments}
	<tr class="alt">
		<td>
			{$STRING.BUGDISPLAY.postedby} : {$comments[comment].login|maskemail} <br>
			{$STRING.BUGDISPLAY.date} : {$comments[comment].created_date|date:TIME_FORMAT} {$STRING.BUGDISPLAY.on} {$comments[comment].created_date|date:DATE_FORMAT}
		</td>
	</tr>
	<tr>
		<td> 
			<div >
			{* $comments[comment].comment_text|stripslashes|htmltruespace|nl2br|format_comments *}
			{* I consider that the comment has been stripslashed before being inserted in DB *}
			{$comments[comment].comment_text|htmltruespace|nl2br|format_comments}
			<br><br>
			</div>
		</td>
	</tr>
{/section}
</table>
<table border="0" cellpadding="2" cellspacing="0" >
	<tr>
		<td valign="top">
			{if $smarty.session.uid}  {* if logged *}
				{$STRING.BUGDISPLAY.additionalcomments} :
				<br><br>
				<textarea name="comments" rows="16" cols="100" wrap="virtual">{if isset($previous_comment)}{$previous_comment|stripslashes}{/if}</textarea>
				<br><br>
			{else}
				<b>{$STRING.logintomodify}</b>
			{/if}
		</td>
	</tr>
</table>
</div>
<div class="mainFrame">
<div class="section">
	{$STRING.BUGDISPLAY.Submition}
</div>
{if $smarty.session.uid}  {* if logged *}
	<div class="submit">
	
		<input type="checkbox" name="suppress_email" value="1" {if isset($suppress_email) && !empty($suppress_email)} checked {/if}>
		{$STRING.BUGDISPLAY.suppressemail}
		<br>
		<br>
		<input type="submit" value={$STRING.BUGFORM.Submit}>
					
	</div>
{else}
	<b>{$STRING.logintomodify}</b>
{/if}
</div>
</form>
