<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
// 
// Copyright (C) 2003 - 2007 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>

<style type="text/css">
<!--
@import url(<?php echo $template_path_core;?>css/aroundme_form.css);
-->
</style>

<form method="post" action="index.php?amn=core_fil_view" enctype="multipart/form-data" name="frm" id="id_frm">	
<input type="hidden" name="update" value="<?php if (isset($_REQUEST['update']) && !empty($_REQUEST['update']) && $_REQUEST['update'] != '') { echo $_REQUEST['update']; }?>" />
<input type="hidden" name="image" value="<?php if (isset($_REQUEST['image'])) { echo $_REQUEST['image'];}?>" />
<input type="hidden" name="item_id" value="<?php if (isset($_REQUEST['item_id'])) { echo $_REQUEST['item_id']; } ?>" />
<input type="hidden" name="module_id" value="<?php if (isset($_REQUEST['module_id'])) { echo $_REQUEST['module_id']; } ?>" />

<div class="col_left1">
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['txt_images']; ?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php if (isset($file_statistics)) { ?>
				<?php $percentage_used = $file_statistics['allocation'] == 0 ? 0 : (int) $file_statistics['allocation_used']/$file_statistics['allocation']*100;?>
				<table cellspacing="1" cellpadding="1" border="0" width="100%">
				<tr>
					<td width="<?php echo $percentage_used;?>%" class="bg1">
						<img src="<?php echo $template_path_core;?>img/pixel.png" width="1" height="6" alt="" /><br />
					</td>
					<td width="<?php echo 100 - $percentage_used;?>%" class="bg2">
						<img src="<?php echo $template_path_core;?>img/pixel.png" width="1" height="6" alt="" /><br />
					</td>
				</tr>
				</table>
				<?php } ?>
				<p>
					<?php if (empty($images)) { echo $lang['txt_no_images']; } else { ?>
					<?php foreach($images as $i): ?>
					<?php if (isset($_REQUEST['module_id'], $_REQUEST['item_id'])) { ?>
						<a style="float: left; margin-left: 18px; margin-top: 5px; min-width: 92px;" href="index.php?amn=core_fil_view&amp;file=<?php echo $i['file_md5_name']; ?>&amp;image=true&amp;item_id=<?php if (isset($_REQUEST['item_id'])) echo $_REQUEST['item_id']; ?>&amp;module_id=<?php if (isset($_REQUEST['module_id'])) echo $_REQUEST['module_id']; ?>"><img class="picture" src="get_file.php?file=<?php echo $i['file_md5_name_view']; ?>" alt="<?php echo $i['file_save_name']; ?>" /></a>
					<?php } else { ?>
						<a style="float: left; margin-left: 18px; margin-top: 5px; min-width: 92px;" href="index.php?amn=core_fil_view&amp;file=<?php echo $i['file_md5_name']; ?>&amp;image=true"><img class="picture" src="get_file.php?file=<?php echo $i['file_md5_name_view']; ?>" alt="<?php echo $i['file_save_name']; ?>"/></a>
					<?php } ?>
					<?php
					endforeach;
					}
					?>
				</p>
			</div>
		</div>
	</div>
	
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['txt_files']; ?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p> 
					<table border="0" width="100%" cellpadding="0" cellspacing="4">
					<?php if (empty($files)) { echo $lang['txt_no_files']; } else {
						foreach($files as $f):
						?>
						<tr>
						<td><a href="get_file.php?file=<?php echo $f['file_md5_name_view']; ?>">
						<?php echo $f['file_save_name'] ?></a> 
						(<?php echo $f['file_size']/1000; ?> kb)</td>
						<td align="right">
						<?php if (isset($_REQUEST['module_id'], $_REQUEST['item_id'])) { ?>
							<a href="index.php?amn=core_fil_view&amp;update=<?php echo $f['file_md5_name']; ?>&amp;image=false&amp;item_id=<?php if (isset($_REQUEST['item_id'])) echo $_REQUEST['item_id']; ?>&amp;module_id=<?php if (isset($_REQUEST['module_id'])) echo $_REQUEST['module_id']; ?>"><?php echo $lang['txt_update_file']; ?></a> /
							<a href="index.php?amn=core_fil_view&amp;delete=<?php echo $f['file_md5_name']; ?>&amp;image=false&amp;item_id=<?php if (isset($_REQUEST['item_id'])) echo $_REQUEST['item_id']; ?>&amp;module_id=<?php if (isset($_REQUEST['module_id'])) echo $_REQUEST['module_id']; ?>">
							<?php echo $lang['txt_delete_file']; ?></a></td>
						<?php } else { ?>
							<a href="index.php?amn=core_fil_view&amp;update=<?php echo $f['file_md5_name']; ?>&amp;image=false"><?php echo $lang['txt_update_file']; ?></a> /
							<a href="index.php?amn=core_fil_view&amp;delete=<?php echo $f['file_md5_name']; ?>&amp;image=false">
							<?php echo $lang['txt_delete_file']; ?></a></td>
						<?php } ?>
						</tr>
						<?php
						endforeach;
					} ?>
					</table>
				</p>
			</div>
		</div>
	</div>
</div>


<div class="col_right1">
	<?php if (isset($_REQUEST['file'], $selected_file[0]) || isset($_REQUEST['update'], $selected_file[0])) { ?>
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['txt_selected_file']; ?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p> 
					<table border="0" width="100%" cellpadding="0" cellspacing="4">
						<tr>
							<td></td>
							<td align="right" valign="top">
							<?php if (isset($_REQUEST['image'], $selected_file[0]) && $_REQUEST['image'] == "true") { ?>
								<a href="index.php?amn=core_fil_view&amp;update=<?php echo $selected_file[0]['file_md5_name']; ?>&amp;image=true&amp;item_id=<?php if (isset($_REQUEST['item_id'])) echo $_REQUEST['item_id']; ?>&amp;module_id=<?php if (isset($_REQUEST['module_id'])) echo $_REQUEST['module_id']; ?>"><?php echo $lang['txt_update_file']; ?></a> / <a href="index.php?amn=core_fil_view&amp;delete=<?php echo $selected_file[0]['file_md5_name']; ?>&amp;image=true&amp;item_id=<?php if (isset($_REQUEST['item_id'])) echo $_REQUEST['item_id']; ?>&amp;module_id=<?php if (isset($_REQUEST['module_id'])) echo $_REQUEST['module_id']; ?>"><?php echo $lang['txt_delete_file']; ?></a>
							<?php } ?>
							</td>
						</tr>
						<tr>
							<td align="left" valign="top" colspan="2">
							<?php if (isset($_REQUEST['image'], $selected_file[0]) && $_REQUEST['image'] == "true") { ?>
								<img class="picture" src="get_file.php?file=<?php echo $selected_file[0]['file_md5_name_view']; ?>" alt="<?php echo $selected_file[0]['file_save_name']; ?>"/>
							<?php } ?>
							</td>
						</tr>
						<tr>
							<td><?php echo $lang['txt_file_name']; ?></td>
							<td><?php echo $selected_file[0]['file_save_name']; ?></td>
						</tr>
						<tr>
							<td><?php echo $lang['txt_uploaded']; ?></td>
							<td><?php echo $selected_file[0]['file_create_datetime']; ?></td>
						</tr>
						<tr>
							<td><?php echo $lang['txt_type']; ?></td>
							<td><?php echo $selected_file[0]['file_type']; ?></td>
						</tr>
						<tr>
							<td><?php echo $lang['txt_size']; ?></td>
							<td><?php echo $selected_file[0]['file_size']; ?>b</td>
						</tr>
					</table>
				</p>
			</div>
		</div>
	</div>
	<?php } ?>
	
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['txt_upload_file']; ?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<?php if (!isset($_REQUEST['update']) || empty($_REQUEST['update']) || $_REQUEST['update'] == "") { ?>
					<label for="frm_file"><?php echo $lang['txt_file_to_upload']; ?></label>
					<input type="file" name="frm_file" id="frm_file" class="input1" /><br />
					<?php } ?>
				</p>
				
				<p>
					<label for="frm_file_name"><?php echo $lang['txt_file_to_upload_name']; ?></label>
					<input type="text" name="frm_file_name" class="input1" id="frm_file_name" value="<?php echo isset($_REQUEST['update'], $selected_file[0]['file_save_name']) ? $selected_file[0]['file_save_name'] : ''; ?>"/>
					<input type="submit" name="frm_<?php echo (isset($_REQUEST['update']) && !empty($_REQUEST['update']) && $_REQUEST['update'] != "") ? 'update' : 'submit'; ?>" id="frm_<?php echo isset($_REQUEST['update']) ? 'update' : 'submit'; ?>" value="<?php echo (isset($_REQUEST['update']) && !empty($_REQUEST['update']) && $_REQUEST['update'] != '') ? $lang['txt_file_update_button'] : $lang['txt_file_upload_button']; ?>" class="input_submit" /><br />
				</p>
			</div>
		</div>
	</div>
	
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['txt_about']; ?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php echo $lang['txt_about_content']; ?><br />
			</div>
		</div>
	</div>
</div>
</form>