<?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="g_membership.php" method="post">
<input type="hidden" name="group_id" value="<?php echo $group['group_id'];?>" />

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

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

		<?php
		if (isset($display) && $display == "invite_members") {
		?>

		<td width="560" valign="top">
			<div class="box_top">
				<?php echo $lang['hdr_invite_friends'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<?php
			if (isset($non_member_friends)) {
			?>
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td>
						<?php echo $lang['txt_invite_friends'];?><br />
					</td>
			    </tr>
			    <tr>
					<td align="right">
						<input type="submit" name="invite_friends" value="<?php echo $lang['sub_invite'];?>" class="button" /><br />
					</td>
				</tr>
			</table>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<?php
			}
			?>
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
			    <tr>
					<td colspan="5">
						<b><?php echo $lang['hdr_non_member_friends'];?></b><br />
					</td>
				</tr>
				<?php
				if (isset($non_member_friends)) {
				?>
				<tr height="25" valign="middle">
					<td>
						<br />
					</td>
					<td>
						<?php echo $lang['txt_user_name'];?><br />
					</td>
					<td>
						<?php echo $lang['txt_user_hometown'];?><br />
					</td>
					<td>
						<?php echo $lang['txt_join_date'];?><br />
					</td>
					<td align="right">
						<?php echo $lang['txt_apply'];?><br />
					</td>
				</tr>
				<?php
				foreach($non_member_friends as $key => $i):
				?>
				<tr>
					<td width="3" valign="top">
						<img src="<?php echo $templatePath;?>img/green_dot.png" width="3" height="9" alt="" /><br />
					</td>
					<td valign="top">
						<?php echo $i['profile_nic'];?><br />
					</td>
					<td valign="top">
						<?php echo $i['profile_hometown'];?><br />
					</td>
					<td valign="top">
						<?php echo $i['profile_create_datetime'];?><br />
					</td>
					<td valign="top" align="right">
						<input type="hidden" name="data[group_invite_profile][<?php echo $i['user_id'];?>]" value="<?php echo $i['profile_id'];?>" /><br />
						<input type="checkbox" name="data[group_invite][]" value="<?php echo $i['user_id'];?>" /><br />
					</td>
				</tr>
				<tr>
					<td colspan="5">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
					</td>
				</tr>
				<?php
				endforeach;
				}
				else {
				?>
				<tr>
					<td colspan="5">
						<?php echo $lang['err_no_friends'];?><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>
		<?php
		}
		else {
		?>
		<td width="560" valign="top">
			<div class="box_top">
				<?php echo $lang['hdr_members'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<table width="100%" cellpadding="2" cellspacing="0" border="0">
				<tr>
					<td>
						<br />
					</td>
					<td>
						<?php echo $lang['txt_user_nic'];?><br />
					</td>
					<td>
						<?php echo $lang['txt_user_join_date'];?><br />
					</td>
					<td>
						<?php echo $lang['txt_group_join_date'];?><br />
					</td>
					<td>
						<?php echo $lang['txt_role'];?><br />
					</td>
					<td>
						<?php echo $lang['txt_member_status'];?><br />
					</td>
					<td>
						<br />
					</td>
				</tr>
				<tr>
					<td colspan="7">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
					</td>
				</tr>
				<?php
				if (isset($members)) {
				foreach($members as $key => $i): ?>

				<tr>
					<td width="3" valign="top">
						<img src="<?php echo $templatePath;?>img/green_dot.png" width="3" height="9" alt="" /><br />
					</td>
					<td valign="top">
						<a href="g_member_profile.php?group_id=<?php echo $group['group_id'];?>&amp;user_id=<?php echo $i['user_id'];?>"><?php echo $i['profile_nic'];?></a><br />
					</td>
					<td valign="top">
						<?php echo $i['membership_create_datetime'];?><br />
					</td>
					<td valign="top">
						<?php echo $i['user_create_datetime'];?><br />
					</td>
					<td valign="top">
						<?php
						foreach($group_roles as $key => $r):
							if ($r['role_id'] == $i['role_id']) {
							    echo $r['role_name'];
								break;
							}
						endforeach;
						?><br />
					</td>
					<td valign="top">
						<?php echo $lang['arr_group_member_status'][$i['status_id']];?><br />
					</td>
					<td valign="top" align="right">
						<a href="msg_compose.php?to_user_id=<?php echo $i['user_id'];?>"><img src="<?php echo $templatePath;?>img/unopenned_mail.png" alt="<?php echo $lang['ttl_send_message'];?>" border="0" /></a><br />
					</td>
				</tr>
				<tr>
					<td>
						<br />
					</td>
					<td valign="top" colspan="6" class="txt_footer">
						<?php echo $i['user_hometown'];?>, 
						<?php
						if ($i['online_status'] == 1) {
						    echo "<span class='txt_red'><b>" . $lang['arr_user_online_status'][1] . "</b></span><br />";
						}
						else {
							    echo $lang['arr_user_online_status'][$i['online_status']] . "<br />";
						}
						?>
				</tr>
				<tr>
					<td colspan="7">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
					</td>
				</tr>
				
				<?php
				endforeach;
				}
				else {
				?>
				<tr>
					<td colspan="7">
						<?php echo $lang['err_no_members'];?><br />
					</td>
				</tr>
				<?php }?>
				<tr>
					<td colspan="7">
						<div class="box_edit">
								<table border="0" width="100%" cellspacing="2" cellpadding="0">
									<tr>
										<td valign="top">
											<?php echo $lang['hdr_members'];?> : <?php echo count($members);?><br />
										</td>
										<td align="right">
											<select name="role_id">
												<option value="0"><?php echo $lang['txt_all_roles'];?></option>
												<?php
												foreach($group_roles as $key => $i):
													$selected = "";
													if(isset($search_role_id) && $search_role_id == $i['role_id']) {
														$selected = " selected";
													}
													print "<option value='" . $i['role_id'] . "'" . $selected . ">" . $i['role_name'] . "</option>";
												endforeach;
												?>
											</select>
											&nbsp;&nbsp;
											<input type="submit" name="search" value="<?php echo $lang['sub_search'];?>" class="button" /><br />
										</td>
									</tr>
								</table>
						</div>
					</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>
