<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);
	}
	{/literal}
//-->
</script>

	<!-- TITLE TABLE -->
	<table border="0" width="100%">
		<tr>
			<td>
				<h3> <!-- PAGE TITLE -->
					{$TITLE.file_insert_into_project} <I>{$mpfile->project_data.project_name}</I>
				</h3>				
			</td>			
		</tr> 
		{if $error}
		<tr>
			<td colspan="2" class="error">
				{$error}
			</td>
		</tr>
		{/if}
	</table>
	<br> <!-- ALL PUBLIC FIELDS -->
<form action="bug.php" method="post" enctype="multipart/form-data">
	<input type="hidden" name="project_id" value="{$mpfile->project_data.project_id}">
	<input type="hidden" name="op" value="do">
	
	<table border="0" cellspacing="0" cellpadding="4">
		{assign var=Shift value='null'}
		{foreach key=k item=v name=std_fields from=$filtered_conf}
			{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}
				<TD align="left">
					<B>
						<!-- 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>
						{$v.title} :
					</B>
				</TD>
				<TD > <!-- 'k' is also the field_name  -->
					{* These condition are disabled because in bug.php show_insert_form(), these fields are filtered out *}
					{* if $k == 'assigned_to' *} 
						{* build_dynamic_input 
							field_conf=$v 
							file_id=$file.bug_id.value
							name=$k
							value=$default_assignation
							mpfile=$mpfile
							allow_void=0
						*}
					{* elseif $k == 'project_id' *}
						{* build_dynamic_input 
							field_conf=$v 
							file_id=$file.bug_id.value
							name='_no_name'
							value=$default_project_id
							mpfile=$mpfile
							read_only=1
						*}
					{* elseif in_array($k, array('title', 'description')) *}
					{if $k == 'title'}
						{build_dynamic_input 
							field_conf=$v 
							name=$k
							value=$v.default_value
							mpfile=$mpfile
							read_only=0							
						}
					{else}
						{if !empty($mpfile->sp_cache.$k->label)&&!empty($mpfile->sp_cache.$k->label)&&($mpfile->sp_cache.$k->label)}
							{assign var=RO value=$mpfile->sp_cache.$k->read_only}
						{else}
							{assign var=RO value=0}
						{/if}
						{build_dynamic_input 
							field_conf=$v 
							file_id=$file.bug_id.value
							name=$k
							value=$v.default_value
							mpfile=$mpfile
							read_only=$RO							
						}
					{/if}
				</TD>
				<TD>
				&nbsp;&nbsp;&nbsp;
				</TD>
			{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>
						<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}
	</table>
	<br>
	<!-- ATTACHMENT -->
	<table border="0" width="50%">
		<tr>
			<td>
				<table style="border: solid 2px" border="0" align="center">
		<tr>
			<td align="center" >			
				<b>
					{$STRING.BUGDISPLAY.attachment} :
				</b>
				</td>
		</tr>
					<tr>
						<td colspan="2" align="center">
							{$STRING.BUGDISPLAY.add_attachment_instruction}
							<br>
							{$STRING.BUGDISPLAY.attachment_max_size} : {$max_size} {$STRING.bytes}
							<br>
							<br>
						</td><td></td>
					</tr>
					<tr>
						<td>
							{$STRING.BUGDISPLAY.attachment_file} :
						</td>
						<td>
								<input type="file" name="attachment">
						</td>
					</tr>
					<tr>
						<td>
							{$STRING.BUGDISPLAY.attachment_description} :
						</td>
						<td>
							<input type="text" name="attachment[description]" maxlength="255" value="">
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>	
	<br>
	<input type="submit" name="submit" value="{$STRING.BUGFORM.Submit}">
</form>
<!------------------------------------------------------------------------------------------------------------>
