<?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 action="index.php?amn=core_profile" method="post" name="frm" id="id_frm">
<input type="hidden" name="identity_id" value="<?php echo $identity['identity_id'];?>" />
<input type="hidden" name="module_id" value="<?php if (!empty($_REQUEST['module_id'])) { echo $_REQUEST['module_id'];}?>" />
<input type="hidden" name="item_id" value="<?php if (!empty($_REQUEST['item_id'])) { echo $_REQUEST['item_id'];}?>" />

<div class="col_main">
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['hdr_identity'];?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php 
				if (isset($identity['testimonial_count'])) {
				?>
				<p style="float:right;white-space:nowrap;">
					<?php
					if (isset($matrix[0])) {
						echo drawMatrix($matrix[0]);
					}
					?>
					&nbsp;
					<?php
					if (isset($identity['testimonial_count'])) {
					?>
					<span class="icon_frame">
						<span class="icon_title">&nbsp;<?php echo $lang['txt_vouched'];?>&nbsp;</span>
						<span class="icon_value">&nbsp;<?php echo $identity['testimonial_count'];?>&nbsp;</span>
					</span>
					<?php }?>
				</p>
				<?php }?>
				
				<p>	
					<?php
					if (!empty($identity['blocking'])) {
					?>
					<a href="index.php?amn=core_blocked" title="<?php echo $lang['txt_block_warning'];?>"><img src="<?php echo $template_path_core;?>img/warning.png" alt="" border="0" /></a>
					<?php }?>
					
					<?php
					if (!empty($identity['identity_allow_msg'])) {
					?>
					<a href="index.php?amn=core_msg_edit&amp;to_identity_id=<?php echo $identity['identity_id'];?>" title="send message"><img src="<?php echo $template_path_core;?>img/unopenned_mail.png" alt="" border="0" /></a>
					<?php }?>
					
					<?php
					if (!empty($identity['identity_allow_export'])) {
					?>
					<a href="#" title="export as vcard"><img src="<?php echo $template_path_core;?>img/export.png" alt="" border="0" /></a>
					<?php }?>
					
					<a href="index.php?amn=core_profile&amp;identity_id=<?php echo $identity['identity_id'];?>"><b><?php echo $identity['identity_nic'];?></b></a><br />
				</p>
				
				
				<table cellspacing="2" cellpadding="2" border="0" width="100%">
					<tr>
						<?php
						if(isset($identity['image'])) {
						?>
						<td rowspan="2" valign="top" width="1">
							<a href="index.php?amn=core_profile&amp;identity_id=<?php echo $identity['identity_id'];?>"><img src="get_file.php?file=<?php echo $identity['image']['file_md5_name_view']; ?>" border="0" class="picture" alt="" /></a><br />
						</td>
						<td width="10">
							<br />
						</td>
						<?php }?>
						<td valign="top">
							<?php echo $identity['location_name'];?><br />
							<?php echo $this->date->formatDate($identity['user_create_datetime'],1);?><br />
							<?php echo $lang['user_online_status'][$identity['online_status']];?><br />
							<?php
							if (isset($identity['invitee'])) {
							?>
							<?php echo $lang['txt_invitee'];?>: 
							<a href="index.php?amn=core_profile&amp;identity_id=<?php echo $identity['invitee']['identity_id'];?>"><?php echo $identity['invitee']['identity_nic'];?></a><br />
							<?php }?>
							
							<?php
							if (!empty($identity['tags'])) {
							?>
								<p>
									<?php echo $lang['txt_tagged'];?>: 
									<?php
									$prnt = "";
									foreach($identity['tags'] as $key => $i):
										$prnt .= $i['tag_body'] . ", ";
									endforeach;
									$prnt = substr($prnt, 0, -2);
									echo $prnt;
									?>
									<br />
								</p>
							<?php }?>
							
							<?php
							if (!empty($identity['identity_signature'])) {
							?>
							<p>
								<i>"<?php echo $identity['identity_signature'];?>"</i><br />
							</p>
							<?php }?>
							
						</td>
					</tr>
				</table>
				
				<?php
				if (!empty($identity['custom_fields'])) {
				?>
				<p>
					<?php
					$prnt = "";
					foreach ($identity['custom_fields'] as $idckey => $idc):
					if (!empty($idc['custom_item_body'])) {
						$prnt .= $lang['identity']['custom'][$idc['custom_item_id']] . ":";
						$prnt .= $idc['custom_item_body'];
						$prnt .= ",&nbsp; ";
					}
					endforeach;
					$prnt = substr($prnt, 0, -8);
					echo $prnt;
					?>
					<br />
				</p>
				<?php }?>
			</div>
		</div>
	</div>
	
	<?php
	if (isset($network_me)) {
	?>
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['hdr_network'];?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<?php echo $lang['txt_respected_network_intro']; ?>
				</p>
				
				<table border="0" cellspacing="0" cellpadding="4">
					<?php foreach($network_me as $key => $i): ?>
					<tr>
						<td colspan="3">
							<a href="index.php?amn=core_profile&amp;module_id=<?php if (isset($_REQUEST['module_id'])) echo $_REQUEST['module_id']; ?>&amp;item_id=<?php if (isset($_REQUEST['item_id'])) echo $_REQUEST['item_id']; ?>&amp;identity_id=<?php echo $network[$key]['identity_id']; ?>"><b><?php echo $network[$key]['identity_nic']; ?></b></a><br />
						</td>
					</tr>
					<tr>
						<td rowspan="2" width="32">
							<a href="index.php?amn=core_profile&amp;module_id=<?php if (isset($_REQUEST['module_id'])) echo $_REQUEST['module_id']; ?>&amp;item_id=<?php if (isset($_REQUEST['item_id'])) echo $_REQUEST['item_id']; ?>&amp;identity_id=<?php echo $network[$key]['identity_id']; ?>"><img class="picture" src="get_file.php?file=<?php echo $network[$key]['image']['file_md5_name_view']; ?>" /></a><br />
						</td>
						<td>
							<?php echo $network['identity']['identity_nic']; ?><br />
						</td>
						<td align="right">
							<?php echo drawMatrix($network_you[$key][0]); ?>
						</td>
					</tr>
					<tr>
						<td>
							<?php echo $lang['txt_me']; ?><br />
						</td>
						<td align="right">
							<?php echo drawMatrix($i[0]); ?>
						</td>
					</tr>
					<?php endforeach; ?>
				</table>
			</div>
		</div>
	</div>
	<?php } ?>

	
	<?php
	if (!empty($core_config['user']['include_ledger'])) {
	?>
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['hdr_ledger'];?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<?php echo $lang['txt_ledger_list_intro'];?><br />
				</p>

				<?php
				if (isset($ledger)) {
				?>
				<table border="0" cellspacing="2" cellpadding="2" width="100%">
					<tr>
						<td valign="top">
							<b><?php echo $lang['txt_ledger_id'];?></b><br />
						</td>
						<td valign="top">
							<b><?php echo $lang['txt_ledger_item'];?></b><br />
						</td>
						<td valign="top">
							<b><?php echo $lang['txt_payment_date'];?></b><br />
						</td>
						<td valign="top" align="center">
							<b><?php echo $lang['txt_expiry_date'];?></b><br />
						</td>
						<td valign="top" align="right">
							(<?php echo $lang['curr_symbol'];?>) <b><?php echo $lang['txt_net'];?></b><br />
						</td>
					</tr>
					<?php
					$ledger_total = "0";
					
					foreach($ledger as $key => $i):
					$ledger_total = $ledger_total+$i['ledger_net'];
					?>
					<tr>
						<td valign="top">
							<?php echo $i['ledger_id'];?><br />
						</td>
						<td valign="top">
							<?php echo $lang['user_ledger_type'][$i['ledger_type']];?><br />
						</td>
						<td valign="top">
							<?php echo $this->date->formatDate($i['ledger_payment_date']);?><br />
						</td>
						<td valign="top" align="center">
							<?php
							if (!empty($i['ledger_expiry_date'])) {
								echo $this->date->formatDate($i['ledger_expiry_date']);
							}
							else {
								echo "-";
							}
							?><br />
						</td>
						<td valign="top" align="right">
							<?php echo $i['ledger_net'];?><br />
						</td>
					</tr>
					<?php
					endforeach;
					?>
					<tr>
						<td colspan="4">
							<br />
						</td>
						<td valign="top" align="right">
							<b><?php echo $ledger_total;?></b><br />
						</td>
					</tr>
				</table>
				<?php
				} else {
				?>
			
				<p>
					<?php echo $lang['template_error']['err_no_items'];?><br />
				</p>
			
				<?php }?>
			</div>
		</div>
	</div>
	<?php }?>
	
	
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['hdr_statistics'];?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php
				if (isset($statistics)) {
				?>
				<table border="0" cellspacing="0" cellpadding="4" width="100%">
					<?php
					foreach($statistics as $keystattype => $st):
					foreach($st as $key => $i):
					if (isset($lang['statistic'][$keystattype][$i['statistic_type_id']])) {
					?>
					<tr>
						<td>
							<?php echo $lang['statistic'][$keystattype][$i['statistic_type_id']];?><br />
						</td>
						<td align="right">
							<?php echo $i['total'];?><br />
						</td>
					</tr>
					<?php
					}
					endforeach;
					endforeach;
					?>
				</table>
				<?php
				} else {
				?>
			
				<p>
					<?php echo $lang['template_error']['err_no_items'];?><br />
				</p>
			
				<?php }?>
			</div>
		</div>
	</div>

	
	<?php
	if (is_file($template_path . "inc/profile.tpl.inc.php")) {
		include $template_path . "inc/profile.tpl.inc.php";
	}
	?>
</div>

<div class="col_side">
	<?php
	if (isset($_SESSION['user_id']) && $_SESSION['user_id'] != $identity['user_id']) {
	?>
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['hdr_options'];?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
				<?php 
				if (!isset($identity['blocking']) && $_SESSION['user_id'] != $identity['user_id']) {
				?>
					<a href="index.php?amn=core_blocked&amp;identity_id=<?php echo $identity['identity_id'];?>"><?php echo $lang['href_block_user']; ?></a><br />
				<?php }?>
				</p>
				
				<p>
					<?php if (!isset($matrix[0]['relation']['respected'])) { ?>
						<a href="index.php?amn=core_profile&amp;respect=1&amp;identity_id=<?php echo $identity['identity_id'];?>&amp;module_id=<?php if(isset($module_id)) { echo $module_id;}?>&amp;item_id=<?php if (isset($item['item_id'])) { echo $item['item_id'];}?>"><?php echo $lang['href_respect'];?></a><br />
					<?php } ?>
				</p>
				
				<hr />
				
				<p>
					<b><?php echo $lang['txt_tags'];?></b><br />
					<?php
					if (isset($tags)) {
					$prnt = "";
					foreach($tags as $key => $i):
						$prnt .= $i['tag_body'] . "<sup><a href='index.php?amn=core_profile&amp;edit_tag=" . $i['tag_id'] . "&amp;identity_id=" . $i['item_id'] . "' style='text-decoration:none;'>&#43;</a></sup> ";
					endforeach;
					echo $prnt;
					}
					?>
				</p>
				
				<table cellspacing="1" cellpadding="0" border="0" width="100%">
					<tr>
						<td>
							<input type="hidden" name="tag_id" value="<?php if (isset($tag)) { echo $tag['tag_id'];}?>" />
							<input type="text" class="input1" name="tag_body" size="10" value="<?php if (isset($tag)) { echo $tag['tag_body'];}?>" /><br />
						</td>	
						<td nowrap="nowrap" align="right">
							<input type="submit" name="insert_tag" class="input_submit" style="font-size:60%;" value="OK" /> 
							<input type="submit" name="delete_tag" class="input_submit" style="font-size:60%;" value="DEL" /><br />
						</td>					
					</tr>				
				</table>
				
				<?php
				if (isset($identity_metadata))  {
				?>
				
				<hr />
				
				<p>
					<b><?php echo $lang['txt_metadata'];?></b><br />
					<?php
					$prnt = "";
					foreach($identity_metadata as $key => $i):
						$i = trim($i);
						$prnt .= "<a href='index.php?amn=core_people&amp;meta=" . $i . "'>" . $i . "</a>, ";
					endforeach;
					$prnt = substr($prnt, 0 ,-2);
					echo $prnt;
					?>
					<br />
				</p>
				<?php }?>
			</div>
		</div>
	</div>
	<?php }?>
	
	<div class="box">
		<div class="box_top">
			<div class="content">
				<h1><?php echo $lang['hdr_testimonials'];?></h1>
			</div>
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php
				if (isset($invitee_identity)) {
				?>
				<b><?php echo $lang['txt_invited_by'];?></b><br />
				<?php
				$id_card = $invitee_identity;
				$id_card_layout = "portrait";
				include("inc/identity.inc.php");
				
				if (!empty($invitee_identity['testimonial']['testimonial_body'])) {
				?>
				<p>
					<i><?php echo $invitee_identity['testimonial']['testimonial_body'];?></i><br />
				</p>
				
				<hr />
				<?php }?>
				<?php }?>
				
				<?php if (isset($testimonials) && !empty($testimonials)) { ?>
				<?php foreach($testimonials as $t):?>
				<p>
					<a href="index.php?amn=core_profile&amp;identity_id=<?php echo $t['testifier_identity_id']; ?>"><b><?php echo $t['identity_nic']; ?></b></a><br />
					<p><i><?php echo $t['testimonial_body']; ?></i></p><hr /><br />
				</p>
				<?php endforeach; ?>
				<?php } else { ?>
				<p>
				<?php echo $lang['txt_no_testimonials']; ?>
				</p>
				<?php }?>
			
				<p align="right">
					<a href="index.php?amn=core_testimonial&amp;identity_id=<?php echo $_REQUEST['identity_id']; ?>"><?php echo $lang['txt_write_testimonial']; ?></a><br />
				</p>
				
			</div>
		</div>
	</div>
</div>
</form>
