<?php

// -----------------------------------------------------------------------
// This file is part of aroundme
// 
// Copyright (C) 2003 - 2007 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.
// -----------------------------------------------------------------------
?>

<style type="text/css">
<!--
@import url(<?php echo $template_path_core;?>css/aroundme_form.css);
-->
</style>

<form action="index.php?amn=core_invite" method="post" name="frm" id="id_frm">
<input type="hidden" name="item_id" value="<?php echo $item['item_id'];?>" />
<input type="hidden" name="module_id" value="<?php echo $module_id;?>" />



<div class="box">
	<div class="box_top">
		<div class="content">
			<h1><?php echo $lang['hdr_invite'];?></h1>
		</div>
	</div>
	
	<div class="box_mid">
		<div class="content">
			<table cellpadding="4" cellspacing="0" border="0" width="100%">
				<tr>
					<td width="40%" valign="top">
						<p>
							<b>Invite into <?php echo $item['item_title'];?></b><br />
							<?php echo $lang['txt_invite_intro'];?><br />
						</p>
						
						<img src="<?php echo $template_path_core;?>img/pixel.png" width="1" height="12" alt="" /><br />
						
						<p>
							<label for="id_message" style="width:200px;"><b><?php echo $lang['txt_message'];?></b></label><br />
							<textarea id="id_message" name="message_body" rows="6" cols="43"><?php echo $lang['txt_invite_message'];?></textarea>
						</p>
					</td>
					<td>
						<img src="<?php echo $template_path_core;?>img/pixel.png" width="20" height="1" alt="" /><br />
					</td>
					<td width="60%" valign="top">
						<?php
						if (isset($respected_network)) {
						?>
						<p>
							<b><?php echo $lang['txt_invite_network'];?>:</b><br />
						</p>

						<table cellspacing="0" cellpadding="2" border="0" width="100%">
							<tr>
								<td valign="top" align="right" colspan="2">
									<?php echo $lang['txt_mark_all'];?>
									&nbsp;
									<input type="checkbox" onClick="checkFormBoxes(this);" /><br />
									<br />
								</td>
							</tr>
							<?php 
							foreach($respected_network as $key => $i):
							?>
							<tr>
								<td valign="top">
									<?php echo $i['identity_nic'];?><br />
								</td>
								<td valign="top" align="right">
									<?php
									if (!empty($i['participation_create_datetime'])) {
									?>
									already joined (<?php echo $this->date->formatDate($i['participation_create_datetime']);?>)<br />
									<?php
									}
									else {
									?>
									<input type="checkbox" name="invited_identity_ids[]" value="<?php echo $i['identity_id_relation'];?>" /><br />
									<?php }?>
								</td>
							</tr>
							<?php
							endforeach;
							?>
						</table>
						
						<img src="<?php echo $template_path_core;?>img/pixel.png" width="1" height="12" alt="" /><br />
						<?php }?>

						<p>
							<label for="id_email" style="width:200px;"><b><?php echo $lang['txt_email_add'];?></b></label><br />
							<input type="text" name="to_emails[]" class="input1" style="width:260px; margin-bottom:2px;" /><br />
							<input type="text" name="to_emails[]" class="input1" style="width:260px; margin-bottom:2px;" /><br />
							<input type="text" name="to_emails[]" class="input1" style="width:260px; margin-bottom:2px;" /><br />
							<input type="text" name="to_emails[]" class="input1" style="width:260px; margin-bottom:2px;" /><br />
							<input type="text" name="to_emails[]" class="input1" style="width:260px;" /><br />
						</p>

						<p align="right">
							<input type="submit" name="send_invite" value="<?php echo $lang['sub_invite'];?>" class="input_submit" /><br />
						</p>
					</td>
				</tr>
			</table>

			<hr />

			<p>
				<b><?php echo $lang['txt_generate_invite'];?></b><br />
			</p>

			<?php
			if (isset($generated_invite)) {
			?>
				<textarea cols="70" rows="2" style="width:710px;"><?php echo $generated_invite;?></textarea><br />
			<?php }?>

			<p>
				<label for="id_email"><?php echo $lang['txt_email'];?></label>
				<input type="text" name="to_email" class="input1" style="width:260px; margin-bottom:2px;" /><br />
			</p>

			<p align="right">
				<input type="submit" name="generate_invite" value="<?php echo $lang['sub_generate_invite'];?>" class="input_submit" /><br />
			</p>
			
			<hr />

			<p>
				<b><?php echo $lang['txt_pending_relations'];?></b>
			</p>
			
			<?php
			if (isset($invite_identities) || isset($invite_emails)) {
			?>
			<table cellspacing="0" cellpadding="0" border="0" width="100%">
				<?php
				if (isset($invite_identities)) {
				foreach ($invite_identities as $key => $i):
				?>
				<tr>
					<td>
						<?php echo $i['identity_nic'];?><br />
					</td>
					<td valign="top">
						invited into: <a href="<?php echo $i['item']['item_url'];?>"><?php echo $i['item']['item_title'];?></a>
						<br />
					</td>
				<?php
				endforeach;
				}

				if (isset($invite_emails)) {
				foreach ($invite_emails as $key => $i):
				?>
				<tr>
					<td>
						<?php echo $i['invited_email'];?><br />
					</td>
					<td valign="top">
						invited into: <a href="<?php echo $i['item']['item_url'];?>"><?php echo $i['item']['item_title'];?></a>
						<br />
					</td>
				</tr>
				<?php
				endforeach;
				}
				?>
			</table>
			<?php }?>
		</div>
	</div>
</div>
</form>

<script language="javascript">
<!--

function checkFormBoxes(id) { //task is check or uncheck
	
	var form = document.frm.elements['invited_identity_ids[]'];
	var state = true;
	
	if (id.checked == false) {
		state = false;
	}

	if (form.length) {
		for (var i=0; i < form.length; i++) {
			form[i].checked = state;
		}
	}
	else {
		form.checked = state;
	}
	
	setToNames();
}
//-->
</script>