<?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
}
?>


<?php
if (isset($display) && $display == "edit_membership") {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="370" valign="top">
			<div class="box_top">
				<?php echo $lang['hdr_membership_info'];?><br />
			</div>

			<div class="box_mid" style="padding: 9px;">
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
				<tr>
					<td valign="top" width="50%">
						<table border="0" cellspacing="0" cellpadding="4">

							<tr>
			   					<td valign="top">
			   						<label for="id_firstname"><?php echo $lang['txt_firstname'];?></label><br />
			   					</td>
			   					<td>
			   						<input id="id_firstname" type="text" name="data[user_firstname]" size="16" value="<?php echo $user['user_firstname'];?>" /><br />
			   					</td>
			   				</tr>
			   				<tr>
			   					<td valign="top">
			   						<label for="id_surname"><?php echo $lang['txt_surname'];?></label><br />
			   					</td>
			   					<td valign="top">
			   						<input id="id_surname" type="text" name="data[user_surname]" size="16" value="<?php echo $user['user_surname'];?>" /><br />
			   					</td>
			   				</tr>
			   				<tr>
			   					<td valign="top">
			   						<label for="id_dob"><?php echo $lang['txt_dob'];?></label><br />
			   					</td>
			   					<td valign="top">
			   						<?php
			   							echo $datedropdown;
			   						?>
			   					</td>
			   				</tr>
			   				<tr>
			   					<td valign="top">
			   						<label for="id_gender"><?php echo $lang['txt_gender'];?></label><br />
			   					</td>
								<td valign="top">
									<input id="id_gender" type="radio" name="data[user_gender]" value="0" checked="checked">&nbsp;<?php echo $lang['txt_gender_none'];?><br />
									<input id="id_gender" type="radio" name="data[user_gender]" value="1" <?php if (isset($user['user_gender']) && $user['user_gender'] == "1") { echo "checked";}?>>&nbsp;<?php echo $lang['txt_gender_male'];?><br />
									<input id="id_gender" type="radio" name="data[user_gender]" value="2" <?php if (isset($user['user_gender']) && $user['user_gender'] == "2") { echo "checked";}?>>&nbsp;<?php echo $lang['txt_gender_female'];?><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<label for="id_hometown"><?php echo $lang['txt_hometown'];?></label><br />
								</td>
								<td valign="top">
									<input id="id_hometown" type="text" name="data[user_hometown]" size="22" value="<?php echo $user['user_hometown'];?>" /><br />
								</td>
							</tr>
							<tr>
								<td valign="top">
									<label for="id_password1"><?php echo $lang['txt_password'];?></label><br />
								</td>
								<td valign="top">
									<input id="id_password1" type="password" name="data[user_password1]" size="8" value="" /><br />
								</td>
							</tr>
							<tr>
								<td>
									<label for="id_password2"><?php echo $lang['txt_confirm_password'];?></label><br />
								</td>
								<td valign="top">
									<input id="id_password2" type="password" name="data[user_password2]" size="8" value="" /><br />
								</td>
							</tr>
							<tr>
								<td valign="top" colspan="2">
									<p>
									<?php echo $lang['txt_hometown_help'];?><br />
									</p>
									<p>
									<?php echo $lang['txt_password_help'];?><br />
									</p>
								</td>
							</tr>
						</table>
					</td>

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

					<td valign="top" width="50%">
						<table border="0" cellspacing="0" cellpadding="4">
							<?php
							if (count($lang['arr_lang_name']) > 1) {
							?>
							<tr>
								<td valign="top">
									<label for="id_pref_lang"><?php echo $lang['txt_pref_lang'];?></label><br />
								</td>
								<td>
									<select name="data[language_id]" id="id_pref_lang">
										<?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">
									<label for="id_lang"><?php echo $lang['txt_lang_selection'];?></label><br />
								</td>
								<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 id="id_lang" 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">
									<label for="id_templates"><?php echo $lang['txt_template'];?></label><br />
								</td>
								<td valign="top">
									<select name="data[template_id]" id="id_templates">
									<?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">
									<label for="id_homepage"><?php echo $lang['txt_homepage'];?></label><br />
								</td>
								<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 id="id_homepage" 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>
							<tr>
								<td colspan="2">
									<?php
									if (count($lang['arr_lang_name']) > 1) {
									?>
									<p>
									<?php echo $lang['txt_lang_help'];?><br />
									</p>
									<?php }?>
									<p>
									<?php echo $lang['txt_template_help'];?><br />
									</p>
								</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td align="right" colspan="3">
						<input type="submit" name="update_membership" value="<?php echo $lang['sub_update'];?>" class="button_urgent" /><br />
						<br />
					</td>
				</tr>
			</table>

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

			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td colspan="5">
						<b><?php echo $lang['hdr_email_info'];?></b><br />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="5">
						<?php echo $lang['txt_email_set_help'];?><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<label for="id_email1"><?php echo $lang['txt_email'];?></label><br />
					</td>
					<td valign="top">
						<input id="id_email1" type="text" name="data[user_email1]" size="25" value="<?php echo $user['user_email'];?>" /><br />
					</td>
					<td valign="top">
						<label for="id_email2"><?php echo $lang['txt_confirm_email'];?></label><br />
					</td>
					<td valign="top">
						<input id="id_email2" type="text" name="data[user_email2]" size="25" value="<?php echo $user['user_email'];?>" /><br />
					</td>
					<td align="right">
						<input type="submit" name="update_email" value="<?php echo $lang['sub_update'];?>" class="button_urgent" /><br />
						<br />
					</td>
				</tr>
			</table>
			</div>

			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>
		</td>
	</tr>
</table>
<?php
}
else if (isset($display) && $display == "view_membership") {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="370" valign="top">
			<div class="box_top">
				<?php echo $lang['hdr_membership'];?><br />
			</div>

			<div class="box_mid" style="padding: 9px;">
			<table border="0" cellspacing="0" cellpadding="4" width="100%">
				<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>
				<tr>
					<td align="right" colspan="2">
						<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="1" height="3" alt="" border="0" /><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td align="right" colspan="2">
						<a href="my_membership.php?edit_membership=1" class="link_urgent"><?php echo $lang['href_edit_membership'];?></a><br />
					</td>
				</tr>
			</table>
			</div>

			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>

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

			<div class="box_top">
				<?php echo $lang['hdr_statistics'];?><br />
			</div>

			<div class="box_mid" style="padding: 9px;">
			<table border="0" width="100%" cellspacing="0" cellpadding="4">
				<?php
				if (isset($user_statistic)) {
				foreach($user_statistic as $key => $i):
				if (isset($lang['arr_user_statistic_type_id'][$i['statistic_type_id']])) {
				?>
				<tr>
					<td width="3" valign="top">
						<img src="<?php echo $templatePath;?>img/green_dot.png" width="3" height="9" alt="" /><br />
					</td>
					<td>
						<?php echo $lang['arr_user_statistic_type_id'][$i['statistic_type_id']];?><br />
					</td>
					<td align="right">
						<?php echo $i['total'];?><br />
					</td>
				</tr>
				<?php
				}
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="3">
						<?php echo $lang['err_no_statistics'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
			</div>

			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>
		</td>

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

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

 			<div class="box_top">
				<?php echo $lang['hdr_sub_rss'];?><br />
			</div>

			<div class="box_mid" style="padding: 9px;">
			<table border="0" cellspacing="4" cellpadding="0" width="100%">
				<tr>
					<td>
						<?php echo $lang['txt_rss_help'];?><br />
					</td>
					<td align="right" valign="top">
						<a href="<?php echo $rss_url;?>"><img src="<?php echo $templatePath;?>img/rss.png" width="36" height="14" border="0" alt="" /></a><br />
					</td>
				</tr>
 			</table>
			</div>

			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>

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

 			<div class="box_top">
				<?php echo $lang['hdr_sub_email'];?><br />
			</div>

			<div class="box_mid" style="padding: 9px;">
			<table border="0" cellspacing="4" cellpadding="0" width="100%">
				<tr>
					<td>
						<?php echo $lang['txt_email_help'];?><br />
					</td>
				</tr>
 			</table>
			</div>

			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>
		</td>
		<?php }?>
	</tr>
</table>
</form>
