<?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="770" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="180" valign="top">
			<?php
			include $templatePath . "g_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_search'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<select name="role_id" class="formInput">
							<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>
					</td>
			    </tr>
				<tr>
					<td align="right">
						<input type="submit" name="search" value="<?php echo $lang['sub_search'];?>" class="formInput" /><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%">
				<tr class="table_stnd">
					<td class="txt_title">
						<?php echo $lang['section_action'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php
						if ($this->group_acs->checkPermission($resource_ids['group_membership'], $privilege_ids['allow_invite'])) { //resourece_id, Priv_id
						?>
						<a href="g_membership.php?group_id=<?php echo $group['group_id'];?>&amp;invite_members=1" class="txt_sub_menu"><?php echo $lang['menu_invite_members'];?></a><br />
						<?php
						}
						?>
					</td>
				</tr>
			</table>

			<?php
			if (isset($members)) {
			?>
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />

			<table width="100%" cellpadding="4" cellspacing="0" border="0" class="table_stnd">
			    <tr>
					<td colspan="2" class="txt_title">
						<?php echo $lang['hdr_statistics'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['hdr_members'];?><br />
					</td>
					<td align="right">
						<?php
						echo count($members);
						?>
						<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>

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

		<td width="570" valign="top">
			<?php
			if (isset($non_member_friends)) {
			?>
			<table width="100%" cellpadding="4" cellspacing="0" border="0" class="table_stnd">
				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php echo $lang['hdr_invite_friends']?><br />
						<hr />
					</td>
				</tr>
				<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="formInput" /><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" class="table_stnd">
			    <tr>
					<td colspan="5" class="txt_title" align="right">
						<?php echo $lang['hdr_non_member_friends'];?><br />
						<hr />
					</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][]" 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>
		</td>
		<?php
		}
		else {
		?>
		<td width="570" valign="top">
			<table width="100%" cellpadding="4" cellspacing="0" border="0" class="table_stnd">
			    <tr>
					<td colspan="7" class="txt_title" align="right">
						<?php echo $lang['hdr_members'];?><br />
						<hr />
					</td>
				</tr>
				<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="6">
						<?php echo $lang['err_no_members'];?><br />
					</td>
				</tr>
				<?php }?>

			</table>
		</td>
		<?php } ?>
	</tr>
</table>
</form>
