<?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_membership.php" method="post">
<?php
if (count($lang['arr_lang_name']) == 1) {
?>
<input type="hidden" name="data[language_id]" value="<?php echo $user['language_id'];?>" />
<input type="hidden" name="data[language_ids][]" value="<?php echo $user['language_id'];?>" />
<?php
}
?>



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

			<?php
			if (isset($display) && $display == "view_membership") {
			?>
			
			<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>
						<a href="my_membership.php?edit_membership=1" class="txt_sub_menu"><?php echo $lang['href_edit_membership'];?></a><br />
					</td>
				</tr>
			</table>
			<?php
			}
			?>
			
			<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_membership") {
			?>
			<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_membership_info'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top" width="50%">
						<table border="0" cellspacing="0" cellpadding="4" class="table_nested">
							
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_firstname'];?></b><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<input type="text" name="data[user_firstname]" class="formInput" size="16" value="<?php echo $user['user_firstname'];?>" /><br />
								</td>
							</tr>

							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_surname'];?></b><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<input type="text" name="data[user_surname]" class="formInput" size="16" value="<?php echo $user['user_surname'];?>" /><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_dob'];?></b><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<?php
										echo $datedropdown;
									?>
								</td>
							</tr>

							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_gender'];?></b><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<input type="radio" name="data[user_gender]" value="1" <? if($user['user_gender'] == '1') echo "checked";?> /><?php echo $lang['txt_gender_male'];?>
									<input type="radio" name="data[user_gender]" value="2" <? if($user['user_gender'] == '2')  echo "checked";?> /><?php echo $lang['txt_gender_female'];?><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_hometown'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_hometown_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<input type="text" name="data[user_hometown]" class="formInput" size="22" value="<?php echo $user['user_hometown'];?>" /><br />

								</td>
							</tr>
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_password'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_password_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<input type="password" name="data[user_password1]" class="formInput" size="8" value="" /><br />
								</td>
							</tr>

							<tr>
								<td>
									<span class="txt_footer"><?php echo $lang['txt_confirm_password'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<input type="password" name="data[user_password2]" class="formInput" size="8" value="" /><br />
								</td>
							</tr>
						</table>
					</td>

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

					<td valign="top" width="50%">
						<table border="0" cellspacing="0" cellpadding="4" class="table_nested">
							<?php
							if (count($lang['arr_lang_name']) > 1) {
							?>
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_pref_lang'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_pref_lang_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td>
									<select name="data[language_id]" class="formInput">
										<?php foreach($lang['arr_lang_name'] as $key => $i): ?>
										<option value="<?php echo $key;?>" <? if($user['language_id'] == $key) echo "selected";?>><?php echo $i;?></option>
										<?php endforeach; ?>
									</select>*<br />
								</td>
							</tr>

							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_lang_selection'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_lang_selection_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<?php
									foreach($lang['arr_lang_name'] as $key1 => $i):
									
									//find out if the language is selected
									unset($selected);
									foreach($user['language_ids'] as $key2 => $r):
										if ($key1 == $r) {
										   $selected = "checked";
										}
									endforeach;
									?>
									<input type="checkbox" name="data[language_ids][]" value="<?php echo $key1;?>" <?php if (isset($selected)) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $i;?><br />
									<?php
									endforeach;
									?>
									<br />
								</td>
							</tr>
							<?php
							}
							?>
							
							<?php
							if (count($templates)>1) {
							?>
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_template'];?></b><br />
									<span class="txt_footer"><?php echo $lang['txt_template_help'];?></span><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<select name="data[template_id]" class="formInput">
									<?php
									foreach($templates as $key => $i):
										unset ($selected);
										if ($user['template_id'] == $i['template_id']) {
										    $selected = "selected";
										}

										print "<option value=\"" . $i['template_id'] . "\"" . $selected . ">" . $i['template_title'] . "</option>";

									endforeach;
									?>
									</select>
								</td>
							</tr>
							<?php
							}
							else {
							?>
							<input type="hidden" name="data[template_id]" value="<?php echo $templates[0]['template_id'];?>" />
							<?php }?>
							<tr>
								<td valign="top">
									<b><?php echo $lang['txt_homepage'];?></b><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<?php
									foreach($lang['homepage']['page'] as $key => $i):
									$selected="";
									if (isset($user['user_homepage']) && $user['user_homepage'] == $i) {
									    $selected = "checked=\"checked\"";
									}
									?>
									<input type="radio" name="data[user_homepage]" value="<?php echo $i;?>" <?php echo $selected;?> />&nbsp;<?php echo $lang['homepage']['page_desc'][$key];?><br />
									<?php
									endforeach;
									?>
									</select>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td align="right" colspan="3">
						<input type="submit" name="update_membership" value="<?php echo $lang['sub_update'];?>" class="formInput" /><br />
						<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 colspan="2" class="txt_title" align="right">
						<?php echo $lang['hdr_email_info'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="2">
						<?php echo $lang['txt_email_help'];?><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<b><?php echo $lang['txt_email'];?></b><br />
					</td>
					<td valign="top">
						<b><?php echo $lang['txt_confirm_email'];?></b><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<input type="text" name="data[user_email1]" class="formInput" size="25" value="<?php echo $user['user_email'];?>" /><br />
					</td>
					<td valign="top">
						<input type="text" name="data[user_email2]" class="formInput" size="25" value="<?php echo $user['user_email'];?>" /><br />
					</td>
				</tr>
				<tr>
					<td align="right" colspan="2">
						<input type="submit" name="update_email" value="<?php echo $lang['sub_update'];?>" class="formInput" /><br />
						<br />
					</td>
				</tr>
			</table>
			<?php
			}
			else if (isset($display) && $display == "view_membership") {
			?>
			<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_membership'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_pref_lang'];?><br />
					</td>
					<td>
						<?php echo $lang['arr_lang_name'][$user['language_id']];?><br />
					</td>
				</tr>
				
				<tr>
					<td valign="top">
						<?php echo $lang['txt_lang_selection'];?><br />
					</td>
					<td>
						<?php
						foreach($user['language_ids'] as $key1 => $i):
							echo $lang['arr_lang_name'][$i] . "<br />";
						endforeach;
						?>
					</td>
				</tr>
				
				<tr>
					<td>
						<?php echo $lang['txt_template'];?><br />
					</td>
					<td>
						<?php echo $user['template']['template_title'];?><br />
					</td>
				</tr>
				
				<tr>
					<td>
						<?php echo $lang['txt_membership_number'];?><br />
					</td>
					<td>
						<?php echo $user['user_number'];?><br />
					</td>
				</tr>
				
				<tr>
					<td>
						<?php echo $lang['txt_hometown'];?><br />
					</td>
					<td>
						<?php echo $user['user_hometown'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_firstname'];?><br />
					</td>
					<td>
						<?php echo $user['user_firstname'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_surname'];?><br />
					</td>
					<td>
						<?php echo $user['user_surname'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_email'];?><br />
					</td>
					<td>
						<?php echo $user['user_email'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_dob'];?><br />
					</td>
					<td>
						<?php echo $user['user_dob'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_gender'];?><br />
					</td>
					<td>
						<?if ($user['user_gender'] == "1") echo $lang['txt_gender_male']; else echo $lang['txt_gender_female'];?><br />
					</td>
				</tr>
			</table>
			<?php
			}
			?>
		</td>
	</tr>
</table>
</form>
