<?php include "../../includes/start_ajax.php";?>
<?php include "config_form.php"; ?>

<?php


//------------------data display----------------------
echo "<div class='data_display_content'>";	
	
	
$query_display="SELECT * FROM $form_table_name ";
$query_display=$query_display." WHERE $form_key_id = '".$_REQUEST[$form_key_id]."';";
$result_display=mysqli_query($dbconn,$query_display)or die("Get Data failed- Err msg  ". mysqli_error($dbconn));
			
if($line_display=mysqli_fetch_array($result_display,MYSQLI_ASSOC))
{
	  	
	for($i=1;$i<=count($form_field);$i++)
	{
		
	
	
		if($form_field_separator[$i]!="")
		{
			echo "<div class='data_display_separator' >";
			echo "<font size=3><b>".$form_field_separator[$i]."</b></font>";
			echo "</div>";
		}

		
		
		
		
		echo "<div class='data_display_row'>";
		
			
			echo "<div class='data_display_label'>";
				echo $form_field_label[$i];
			echo "</div>";
		
			echo "<div class='data_display_value'>";
		
				if($form_field_type[$i]=="TEXT")
				{
					echo $line_display[$form_field[$i]]."";
				}
			
				if($form_field_type[$i]=="QUANTITY")
				{
					echo $line_display[$form_field[$i]]."";
				}
			
				if($form_field_type[$i]=="PRICE")
				{
					echo $line_display[$form_field[$i]]."";
				}
				
				if($form_field_type[$i]=="TIME")
				{
					echo $line_display[$form_field[$i]]."";
				}
				
				if($form_field_type[$i]=="DATE")
				{
					echo $line_display[$form_field[$i]]."";
				}
				
				if($form_field_type[$i]=="DATE_START")
				{
					echo $line_display[$form_field[$i]]."";
				}
				
				if($form_field_type[$i]=="DATE_END")
				{
					echo $line_display[$form_field[$i]]."";
				}
				
				if($form_field_type[$i]=="PASSWORD")
				{
					echo "******";
				}
					
				if($form_field_type[$i]=="TEXTAREA")
				{
					echo str_replace(chr(10),"<br>",$line_display[$form_field[$i]])."";
				}
				
				if($form_field_type[$i]=="DROPDOWN")
				{
				
					if($form_field_dropdown_option[$i]=="KEYWORD")
					{
					 
						echo "".$mon_keyword_list[$form_field_dropdown_option_values[$i]][$line_display[$form_field[$i]]]."";
					 
					
						
					}
					if($form_field_dropdown_option[$i]=="SQL")
					{
					 
						$query_select=$form_field_dropdown_option_values[$i];
						$query_select=$query_select." where ".$form_field_dropdown_option_values_key[$i]."='".$line_display[$form_field[$i]]."';";
						$result_select=mysqli_query($dbconn,$query_select) or die("Retrieval failed- Err msg  ". mysqli_error($dbconn));
						if($line_select=mysqli_fetch_array($result_select,MYSQLI_ASSOC))
						{
							echo "".$line_select["text"].""; 
						}
														
					}
				
				
				
				
					}
					
					if($form_field_type[$i]=="FILE_PHOTO")
					{
						$query_file="select fil_id, fil_storage_method from t_".$key_table_prefix."_file 
							where fil_mod='".$form_key_id."' 
							and fil_mod_id='".$_REQUEST[$form_key_id]."'
							and fil_mod_field='".$form_field[$i]."'
							";
			
						$result_file=mysqli_query($dbconn,$query_file) or die("Retrieval failed- Err msg  ". mysqli_error($dbconn));
						if($line_file=mysqli_fetch_array($result_file,MYSQLI_ASSOC))
						{
							if($line_file["fil_storage_method"]=="OS")
							{
								echo "<img width=250 src='".$file_storage_folder.$line_file["fil_id"].".jpg' >";	
							}
							else
							{
								echo "<img width=250 src='mod/uploader/file.php?id=".$line_file["fil_id"]."' >";	
							}
							
						} 
					}
					
					if($form_field_type[$i]=="FILE")
					{
						$query_file="select fil_name, fil_id, fil_storage_method from t_".$key_table_prefix."_file 
										where fil_mod='".$form_key_id."' 
										and fil_mod_id='".$_REQUEST[$form_key_id]."'
										and fil_mod_field='".$form_field[$i]."'
										";
						
						$result_file=mysqli_query($dbconn,$query_file) or die("Retrieval failed- Err msg  ". mysqli_error($dbconn));
						if($line_file=mysqli_fetch_array($result_file,MYSQLI_ASSOC))
						{
							$fileName_array=explode(".",$line_file["fil_name"]);
							$ext=$fileName_array[count($fileName_array)-1];
							if($line_file["fil_storage_method"]=="OS")
							{
								echo "<a href='".$file_storage_folder.$line_file["fil_id"].".".$ext."' target=_blank >".$line_file["fil_name"]."</a>";	
							}
							else
							{
								echo "<a href='mod/fuploader/file.php?id=".$line_file["fil_id"]."' >".$line_file["fil_name"]."</a>";	
							}
						} 
					}
		
				echo "</div>"; // end value division
				
				
				
		echo "</div>"; //end row division
	 
	}
						
}	
		
	
echo "</div>";
			

?>




<?php include "../../includes/end_ajax.php";?>