<?php

// -----------------------------------------------------------------------
// This file is part of Igloo
//
// 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., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>

<form action="my_membership.php" method="post">
<?php
if (count($lang['arr_lang_name']) == 1) {
?>
<input type="hidden" name="language_ids" value="<?php echo $user['language_id'];?>" />
<?php }?>

<input type="hidden" name="language_id" value="<?php echo $user['language_id'];?>" />
<input type="hidden" name="user_firstname" value="<?php echo $user['user_firstname'];?>" />
<input type="hidden" name="user_surname" value="<?php echo $user['user_surname'];?>" />
<input type="hidden" name="user_gender" value="<?php echo $user['user_gender'];?>" />
<input type="hidden" name="user_hometown" value="<?php echo $user['user_hometown'];?>" />



<?php
if (isset($display) && $display == "edit_membership") {
?>
<div class="box">
	<div class="box_top">
		<?php echo $lang['hdr_membership_info'];?><br />
	</div>

	<div class="box_mid">
		<div class="content">
			<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_dob"><?php echo $lang['txt_dob'];?></label><br />
			   					</td>
			   					<td valign="top">
			   						<?php echo $datedropdown;?>
			   					</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="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="user_password2" size="8" value="" /><br />
								</td>
							</tr>
							<tr>
								<td valign="top" colspan="2">
									<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="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="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="template_id" id="id_templates">
									<?php
									foreach($templates as $key => $i):
										unset ($selected);
										if ($user['template_id'] == $i['template_id']) {
										    $selected = "selected";
										}

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

									endforeach;
									?>
									</select>
								</td>
							</tr>
							<?php
							}
							else {
							?>
							<input type="hidden" name="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="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="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="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>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
</div>
<?php
}
else if (isset($display) && $display == "view_membership") {
?>
<div class="col_left1">
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_membership'];?><br />
		</div>

		<div class="box_mid">
			<div class="content">
				<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_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 align="right" colspan="2">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="3" alt="" border="0" /><br />
						</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>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_statistics'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<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/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>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
</div>

<div class="col_right1">
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_sub_rss'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<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>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_sub_email'];?><br />
		</div>

		<div class="box_mid">
			<div class="content">
				<?php
				$email_message_checked = "";
				$digest_newsletter_checked = "";
				
				if (isset($user['preferences'])) {
					foreach ($user['preferences'] as $key => $i):
						if ($i['user_preference_id'] == $user_preference_ids['email_message']) {
							$email_message_checked = "checked=\"checked\"";
						}
						
						if ($i['user_preference_id'] == $user_preference_ids['digest_newsletter']) {
							$digest_newsletter_checked = "checked=\"checked\"";
						}
					endforeach;
				}
				?>
				
				<table border="0" cellspacing="4" cellpadding="0" width="100%">
					<tr>
						<td valign="top">
							<input id="id_user_email_message" type="checkbox" name="user_preferences[]" value="<?php echo $user_preference_ids['email_message'];?>" <?php echo $email_message_checked;?> /><br />
						</td>
						<td valign="top">
							<?php echo $lang['txt_email_message_help'];?><br />
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" border="0" /><br />
						</td>
					</tr>
					<?php
					if (isset($cron_enabled) && $cron_enabled==true) {
					?>
					<tr>
						<td valign="top">
							<input id="id_user_digest_newsletter" type="checkbox" name="user_preferences[]" value="<?php echo $user_preference_ids['digest_newsletter'];?>" <?php echo $digest_newsletter_checked;?> /><br />
						</td>
						<td valign="top">
							<?php echo $lang['txt_digest_newsletter_help'];?><br />
						</td>
					</tr>
					<?php }?>
					<tr>
						<td colspan="2" align="right">
							<input type="submit" name="update_user_preferences" value="<?php echo $lang['sub_update'];?>" class="button_urgent" /><br />
						</td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	<?php }?>
</div>
</form>
