<?php

// -----------------------------------------------------------------------
// This file is part of aroundme
// 
// Copyright (C) 2003, 2005 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., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
// -----------------------------------------------------------------------

?>


<form action="my_profile.php" method="post">

<table width="770" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="180" valign="top">
			<?php
			include $templatePath . "my_menu.inc.tpl.php";
			?>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />

			<table border="0" width="100%" cellspacing="4" cellpadding="0">
				<tr class="table_stnd">
					<td class="txt_title">
						<?php echo $lang['section_action'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php
						if (isset($display)) {
						?>
						<a href="my_profile.php" class="txt_sub_menu"><?php echo $lang['href_list'];?></a><br />
						<?php }?>
						
						<?php
						if (isset($display) && $display == "view_profile") {
						?>
						<a href="my_profile.php?edit_profile=1&amp;profile_id=<?php echo $profile['profile_id'];?>" class="txt_sub_menu"><?php echo $lang['href_edit_this'];?></a><br />
						<?php }?>
						
						<?php
						if (empty($display)) {
						?>
						<a href="my_profile.php?add_profile=1" class="txt_sub_menu"><?php echo $lang['href_add_profile'];?></a><br />
						<?php }?>
					</td>
				</tr>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="52" alt="" /><br />

			<?php
			include $templatePath . "logo.inc.tpl.php";
			?>
		</td>

		<td width="20">&nbsp;</td>

		<td width="570" valign="top">

			<?php
			if (isset($display) && $display == "edit_profile") {
			?>
			<input type="hidden" name="profile_id" class="formInput" value="<?php if (isset($profile['profile_id'])) { echo $profile['profile_id'];}?>" />
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php echo $lang['hdr_profile'];?><br />
						<hr />
					</td>
				</tr>
				
				<tr>
					<td colspan="4">
						<?php echo $lang['txt_profile_edit_intro'];?><br />
					</td>
				</tr>
				<tr>
					<td colspan="4">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php
						 echo $lang['txt_profile_name'];?><br />
					</td>
					<td valign="top">
						<input type="text" name="data[profile_name]" class="formInput" value="<?php if (isset($profile['profile_name'])) { echo $profile['profile_name'];}?>" /><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php
						 echo $lang['txt_profile_nic'];?><br />
					</td>
					<td valign="top">
						<input type="text" name="data[profile_nic]" maxlength="50" class="formInput" value="<?php if (isset($profile['profile_nic'])) { echo $profile['profile_nic'];}?>" /><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php echo $lang['txt_gender'];?><br />
					</td>
					<td>
						<input type="radio" name="data[profile_gender]" value="0" checked="checked">&nbsp;<?php echo $lang['txt_none'];?><br />
						<input type="radio" name="data[profile_gender]" value="1" <?php if (isset($profile['profile_gender']) && $profile['profile_gender'] == "1") { echo "checked=\"checked\"";}?>>&nbsp;<?php echo $lang['txt_male'];?><br />
						<input type="radio" name="data[profile_gender]" value="2" <?php if (isset($profile['profile_gender']) && $profile['profile_gender'] == "2") { echo "checked=\"checked\"";}?>>&nbsp;<?php echo $lang['txt_female'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php
						 echo $lang['txt_profile_hometown'];?><br />
					</td>
					<td valign="top">
						<input type="text" name="data[profile_hometown]" class="formInput" value="<?php if (isset($profile['profile_hometown'])) { echo $profile['profile_hometown'];}?>" /><br />
					</td>
				</tr>
				<?php
				if (!empty($lang['txt_profile_text1'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text1'];?><br />
					</td>
					<td>
						<input type="text" name="data[profile_text1]" class="formInput" value="<?php if (isset($profile['profile_text1'])) { echo $profile['profile_text1'];}?>" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text2'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text2'];?><br />
					</td>
					<td>
						<input type="text" name="data[profile_text2]" class="formInput" value="<?php if (isset($profile['profile_text2'])) { echo $profile['profile_text2'];}?>" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text3'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text3'];?><br />
					</td>
					<td>
						<input type="text" name="data[profile_text3]" class="formInput" value="<?php if (isset($profile['profile_text3'])) { echo $profile['profile_text3'];}?>" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text4'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text4'];?><br />
					</td>
					<td>
						<input type="text" name="data[profile_text4]" class="formInput" value="<?php if (isset($profile['profile_text4'])) { echo $profile['profile_text4'];}?>" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text5'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text5'];?><br />
					</td>
					<td>
						<input type="text" name="data[profile_text5]" class="formInput" value="<?php if (isset($profile['profile_text5'])) { echo $profile['profile_text5'];}?>" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text6'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text6'];?><br />
					</td>
					<td>
						<input type="text" name="data[profile_text6]" class="formInput" value="<?php if (isset($profile['profile_text6'])) { echo $profile['profile_text6'];}?>" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text7'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text7'];?><br />
					</td>
					<td>
						<input type="text" name="data[profile_text7]" class="formInput" value="<?php if (isset($profile['profile_text7'])) { echo $profile['profile_text7'];}?>" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text8'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text8'];?><br />
					</td>
					<td>
						<input type="text" name="data[profile_text8]" class="formInput" value="<?php if (isset($profile['profile_text8'])) { echo $profile['profile_text8'];}?>" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text9'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text9'];?><br />
					</td>
					<td>
						<input type="text" name="data[profile_text9]" class="formInput" value="<?php if (isset($profile['profile_text9'])) { echo $profile['profile_text9'];}?>" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text10'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text10'];?><br />
					</td>
					<td>
						<input type="text" name="data[profile_text10]" class="formInput" value="<?php if (isset($profile['profile_text10'])) { echo $profile['profile_text10'];}?>" /><br />
					</td>
				</tr>
				<?php }?>
				
				<tr>
					<td>
						<?php echo $lang['txt_allow_comments'];?><br />
					</td>
					<td>
						<input type="checkbox" name="data[profile_allow_comments]" value="1" <?php if (isset($profile['profile_allow_comments']) && $profile['profile_allow_comments'] == 1) echo "checked=\"checked\"";?> /><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_profile_allow_msg'];?><br />
					</td>
					<td>
						<input type="checkbox" name="data[profile_allow_msg]" value="1" <?php if (isset($profile['profile_allow_msg']) && $profile['profile_allow_msg'] == 1) echo "checked=\"checked\"";?> /><br />
					</td>
				</tr>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_summary'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<textarea name="data[profile_summary]" rows="10" cols="60"><?php if (isset($profile['profile_summary'])) { echo $profile['profile_summary'];}?></textarea><br />
						<br />
					</td>
				</tr>
			</table>
			
			<?php
			if (isset($images)) {
			?>
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="<?php echo $images_per_row;?>" class="txt_title" align="right">
						<?php echo $lang['hdr_images'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="<?php echo $images_per_row;?>">
						<span class="txt_footer"><?php echo $lang['txt_images_help'];?></span><br />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="<?php echo $images_per_row;?>">
						<input type="radio" value="0" name="data[file_id]" checked />&nbsp;no image<br />
					</td>
				</tr>
				<tr>
					<td>
						<table border="0" cellspacing="0" cellpadding="2" class="table_nested">
							<tr>
								<?php
								$images_per_row = 6;
								$r = 0;
								foreach($images as $key => $i):
			
			
								$selected = "";
									if (isset($profile['file_id']) && $profile['file_id'] == $i['file_id']) {
									    $selected = "checked";
									}
			
								?>
			
								<td valign="top">
									<img src="get_file.php?file=<?php echo $i['file']; ?>" border="0" class="picture" /><br />
									<input type="radio" value="<?php echo $i['file_id'];?>" name="data[file_id]" <?php echo $selected;?> /><br />
								</td>
			
								<?php
								$r++;
								if ($r == $images_per_row) {
								    echo "</tr><tr>";
									$r=0;
								}
			
								endforeach;
								if ($r != $images_per_row) {
									$r = $images_per_row-$r;
									print "<td colspan=" . $r . "><br /></td>";
								}
								?>
							</tr>
						</table>
					</td>
				</tr>
			</table>
			<?php }?>
			
			<?php
			}
			else if (isset($display) && $display == "view_profile") {
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="3" class="txt_title" align="right">
						<?php echo $lang['hdr_profile'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top" rowspan="12">
						<img src="get_file.php?file=<?php echo $profile['image']['file'];?>" align="left" border="0" class="picture" alt="<?php echo $profile['image']['file_title'];?>" /><br />
					</td>
					<td>
						<?php echo $lang['txt_profile_name'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_name'];?><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php echo $lang['txt_profile_nic'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_nic'];?><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php echo $lang['txt_profile_create_datetime'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_create_datetime'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_gender'];?><br />
					</td>
					<td>
						<?php 
						if (isset($profile['profile_gender'])) { 
							if ($profile['profile_gender'] == 1) {
								echo $lang['txt_male'];
							}
							elseif ($profile['profile_gender'] == 2) {
								echo $lang['txt_female'];
							}
						} else {
							echo $lang['txt_none'];
						}
						?><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php echo $lang['txt_profile_hometown'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_hometown'];?><br />
					</td>
				</tr>
				<?php
				if (!empty($lang['txt_profile_text1'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text1'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_text1'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text2'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text2'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_text2'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text3'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text3'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_text3'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text4'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text4'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_text4'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text5'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text5'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_text5'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text6'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text6'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_text6'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text7'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text7'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_text7'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text8'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text8'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_text8'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text9'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text9'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_text9'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($lang['txt_profile_text10'])) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_profile_text10'];?><br />
					</td>
					<td>
						<?php echo $profile['profile_text10'];?><br />
					</td>
				</tr>
				<?php }?>
				
				<tr>
					<td colspan="2">
						<?php
						if (isset($profile['profile_allow_comments']) && $profile['profile_allow_comments'] == 1) {
							echo $lang['txt_comment_allow'];
						}
						else {
							echo $lang['txt_comment_deny'];
						}
						?>
						<br />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<?php
						if (isset($profile['profile_allow_msg']) && $profile['profile_allow_msg'] == 1) {
							echo $lang['txt_msg_allow'];
						}
						else {
							echo $lang['txt_msg_deny'];
						}
						?>
						<br />
					</td>
				</tr>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="25" alt="" /><br />
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="2">
						<?php echo $lang['txt_summary'];?><br />
					</td>
				</tr>
				<tr>
					<td colspan="3" class="picture">
						<?php echo $profile['profile_summary_display'];?><br />
					</td>
				</tr>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="25" alt="" /><br />
			<?php
			}
			else {
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="4" class="txt_title" align="right">
						<?php echo $lang['hdr_profiles'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td colspan="4">
						<?php echo $lang['txt_profiles_intro'];?><br />
					</td>
				</tr>
				<tr>
					<td colspan="4">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
					</td>
				</tr>
				<?php
				if (isset($profiles)) {
				foreach($profiles as $key => $i):
				?>
				<tr>
					<td valign="top">
						<a href="my_profile.php?profile_id=<?php echo $i['profile_id'];?>"><img src="get_file.php?file=<?php echo $i['image']['file'];?>" align="left" border="0" class="picture" alt="<?php echo $i['image']['file_title'];?>" /></a><br />
					</td>
					<td valign="top">
						<a href="my_profile.php?profile_id=<?php echo $i['profile_id'];?>"><?php echo $i['profile_name'];?></a><br />
					</td>
					<td valign="top">
						<?php echo $i['profile_nic'];?><br />
					</td>
					<td valign = "top" align="right">
						<?php
						$selected = "";
						if ($i['profile_default'] == 1) {
						    $selected = "checked=\nchecked\n";
						}
						?>
						<input type="radio" name="data[default_profile_default]" value="<?php echo $i['profile_id'];?>" <?php echo $selected;?> /><br />
					</td>
				</tr>
				<?php
				endforeach;
				?>
				<tr>
					<td align="right" colspan="4">
						<input type="submit" name="set_default" value="<?php echo $lang['sub_update_default_profile'];?>" class="formInput" /><br />
					</td>
				</tr>
				<?php
				}
				else {
				?>
				<tr>
					<td colspan="4">
						<?php echo $lang['err_no_profiles'];?><br />
					</td>
				</tr>
				<?php
				}
				?>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<?php
			}
			?>
			
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="4" class="txt_title" align="right">
						<?php echo $lang['hdr_group_usage'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (isset($group_profiles)) {
				foreach($group_profiles as $key => $i):
				?>
				<tr>
					<td valign="top">
						<a href="g_group.php?group_id=<?php echo $i['group_id'];?>"><?php echo $i['group_title'];?></a><br />
					</td>
					<td valign="top">
						<a href="my_profile.php?profile_id=<?php echo $i['profile_id'];?>"><?php echo $i['profile_name'];?></a><br />
					</td>
					<td valign="top" align="right">
						<?php echo $i['profile_nic'];?><br />
					</td>
				</tr>
				<?php
				endforeach;
				}
				else {
				?>
				<tr>
					<td colspan="4">
						<?php echo $lang['err_no_profile_usage'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
			
			
			<?php
			if (!isset($profile) && (isset($display) &&$display != "edit_profile")) {
			?>
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="25" alt="" /><br />
			
			<table border="1" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php echo $lang['hdr_degree_usage'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				foreach($lang['sn']['degree'] as $key => $i):
				?>
				<tr>
					<td valign="top">
						<?php echo $i;?><br />
					</td>
					<td align="right">
						<select name="data[set_degree_profile_ids][<?php echo $key;?>]" class="formInput">
							<?php
							foreach($profiles as $key1 => $r):
								
								if (isset($degree_profiles)) {
									$selected1="";
								    foreach($degree_profiles as $keydp => $dp):
										if ($key == $dp['degree_id'] && $r['profile_id'] == $dp['profile_id']) {
											$selected1=" selected=\"selected\"";
											break;
										}
									endforeach;
								}
							
								print "<option value='" . $r['profile_id'] . "' " . $selected1  . ">" . $r['profile_name'] . "</option>";
							endforeach;
							?>
						</select>
						<br />
					</td>
				</tr>
				<?php
				endforeach;
				?><tr>
					<td align="right" colspan="4">
						<input type="submit" name="set_degree" value="<?php echo $lang['sub_update_degree_profile'];?>" class="formInput" /><br />
					</td>
				</tr>
			</table>
			<?php }?>
			
			<?php
			if (isset($display) && $display == "edit_profile") {
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td class="txt_title" align="right" colspan="2">
						<?php echo $lang['hdr_publishing'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php
						if (isset($profile['profile_id'])) {
						if (empty($group_profiles) && empty($profile['profile_default'])) {
						?>
						<input type="submit" name="delete_profile" class="formInput" value="<?php echo $lang['sub_delete'];?>" />&nbsp;&nbsp;
						<?php
						}
						else {
							echo $lang['txt_no_delete'] . "<br />";
						}}
						?>
					</td>
					<td valign="top" align="right">
						<?php
						if (isset($profile['profile_id'])) {
						?>
						<input type="submit" name="update_profile" class="formInput" value="<?php echo $lang['sub_update'];?>" /><br />
						<?php
						}
						else {
						?>
						<input type="submit" name="insert_profile" class="formInput" value="<?php echo $lang['sub_insert'];?>" /><br />
						<?php }?>
					</td>
				</tr>
			</table>
			<?php
			}
			?>
		</td>
	</tr>
</table>
</form>
