<?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_activity_task_edit.php" method="post">
<input type="hidden" name="group_id" value="<?php if(isset($group['group_id'])) { echo $group['group_id'];}?>" />
<input type="hidden" name="activity_id" value="<?php if(isset($task['activity_id'])) { echo $task['activity_id'];}?>" />
<input type="hidden" name="task_id" value="<?php if(isset($task['task_id'])) { echo $task['task_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" cellspacing="0" cellpadding="4" width="100%">
				<tr>
					<td class="txt_title">
						<?php echo $lang['section_action'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php
						if (isset($allow_task_edit) && $allow_task_edit == true) {
						?>
						<a href="g_activity_task_edit.php?group_id=<?php echo $group['group_id'];?>&amp;activity_id=<?php echo $task['activity_id'];?>&amp;task_id=<?php echo $task['task_id'];?>&amp;edit_task=1" class="txt_sub_menu"><?php echo $lang['href_edit_this'];?></a><br />
						<?php }?>
					</td>
				</tr>
			</table>
			
			<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>

		<td width="570" valign="top">
			<?php
			if (isset($display) && $display == "edit_task") {
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_task'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_title'];?></b><br />
					</td>
				</tr>
				<tr>
					<td>
						<input type="text" name="data[task_title]" size="65" value="<?php if (isset($task['task_title'])) { echo $task['task_title'];}?>" /><br />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_synopsis'];?></b><br />
					</td>
				</tr>
				<tr>
					<td>
						<textarea name="data[task_synopsis]" cols="50" rows="2"><?php if (isset($task['task_synopsis'])) { echo $task['task_synopsis'];}?></textarea><br />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_task_user_requirement'];?></b><br />
						<span class="txt_footer">
						<?php echo $lang['txt_task_user_requirement_help'];?><br />
						</span>
					</td>
				</tr>
				<tr>
					<td>
						<input type="text" name="data[task_user_requirement]" size="4" value="<?php if (isset($task['task_user_requirement'])) { echo $task['task_user_requirement'];}?>" /><br />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_type'];?></b><br />
					</td>
				</tr>
				<tr>
					<td>
						<select name="data[task_type_id]" class="formInput">
						<?php
						foreach($lang['group']['arr_task_type'] as $key => $i):
						$selected = "";
		
						if (isset($task['task_type_id']) && $task['task_type_id'] == $key) {
						    $selected = " selected=\"selected\"";
						}
						?>
						<option value="<?php echo $key;?>"<?php echo $selected;?>><?php echo $i;?></option>
						<?php endforeach; ?>
						</select>
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_start_datetime'];?></b><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $start_datedropdown;?><br />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_end_datetime'];?></b><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $end_datedropdown;?><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%" class="table_stnd">
				<tr>
					<td colspan="2" class="txt_title" align="right">
						<?php echo $lang['section_cms'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php
						if ($this->group_acs->checkPermission($resource_ids['group_cms'], $privilege_ids['allow_cms_public'])) { //resource_id, Priv_id
							if ($cms_node_auto_publish == 1) {
							    $txt_cms_node = $lang['txt_cms_node_auto'];
							}
							else {
								$txt_cms_node = $lang['txt_cms_node'];
							}
							
						?>
						<input type="checkbox" name="data[cms_node]" value="1" <?php if (isset($task['cms_node']) && $task['cms_node'] == 1) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $txt_cms_node;?><br />
						<?php
						}
						
						if ($this->group_acs->checkPermission($resource_ids['group_cms'], $privilege_ids['allow_cms_group_home'])) { //resource_id, Priv_id
							if ($group['group_cms_auto_publish'] == 1) {
							    $txt_cms_group = $lang['txt_cms_group_auto'];
							}
							else {
								$txt_cms_group = $lang['txt_cms_group'];
							}
						?>
						<input type="checkbox" name="data[cms_group]" value="1" <?php if (isset($task['cms_group']) && $task['cms_group'] == 1) { echo "checked=\"checked\"";}?> />&nbsp;<?php echo $txt_cms_group;?><br />
						<?php } ?>
					</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%" class="table_stnd">
			
				<?php
				if (isset($task['task_id'])) {
				?>
				<tr>
					<td valign="top">
						<input type="submit" name="delete_task" class="formInput" value="<?php echo $lang['sub_delete'];?>" /><br />
					</td>
					<td valign="top" align="right">
						<input type="submit" name="update_task" class="formInput" value="<?php echo $lang['sub_update'];?>" /><br />
					</td>
				</tr>
				<?php 
				}
				else {
				?>
				<tr>
					<td valign="top" align="right" colspan="2">
						<input type="submit" name="insert_task" class="formInput" value="<?php echo $lang['sub_add'];?>" /><br />
					</td>
				</tr>
				<?php }?>
			</table>
			<?php
			}
			else {
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td class="txt_title" align="right" colspan="2">
						<?php echo $lang['hdr_task'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_title'];?></b><br />
					</td>
					<td>
						<?php echo $task['task_title'];?><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<b><?php echo $lang['txt_synopsis'];?></b><br />
					</td>
					<td valign="top">
						<?php echo $task['task_synopsis'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_type'];?></b><br />
					</td>
					<td>
						<?php 
						if (isset($task['task_type_id'])) {
						    echo $lang['group']['arr_task_type'][$task['task_type_id']];
						}
						?><br />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_start_datetime'];?></b><br />
					</td>
					<td>
						<?php echo $task['task_start_datetime'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_end_datetime'];?></b><br />
					</td>
					<td>
						<?php echo $task['task_end_datetime'];?><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%" class="table_stnd">
				<tr>
					<td class="txt_title" align="right" colspan="6">
						<?php echo $lang['hdr_applicants'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td colspan="6">
						<?php echo $lang['txt_applicants'];?><br />
					</td>
				</tr>
				<?php
				if (isset($task_applicants)) {
				foreach($task_applicants as $key => $i):
				?>
				<tr>
					<td valign="top">
						<?php echo $i['profile_nic'];?><br />
					</td>
					<td valign="top">
						<?php echo $i['profile_create_datetime'];?><br />
					</td>
					<td valign="top">
						<?php echo $i['profile_hometown'];?><br />
					</td>
					<td valign="top">
						<a href="msg_compose.php?to_user_id=<?php echo $i['user_id'];?>"><img src="<?php echo $templatePath;?>img/unopenned_mail.png" title="<?php echo $lang['href_send_message'];?>" border="0" alt="" /></a>&nbsp;
					</td>
					<td valign="top">
						<?php echo $i['task_user_create_datetime'];?><br />
					</td>
					<td align="right">
						<?php
						if (isset($i['status_id']) && $i['status_id'] == $task_user_status_ids['confirmed']) {
						    echo $lang['arr_activity_user_status'][$task_user_status_ids['confirmed']];
						}
						else {
						$show_submit_button = 1;
						?>
						<input type="hidden" name="data[user_id][]" value="<?php echo $i['user_id'];?>" />
						<select name="data[status_id][]" class="formInput">
						<option value="0" selected><?php echo $lang['txt_none'];?></option>
						<?php
						foreach($lang['arr_activity_user_status'] as $key => $r):
							$selected="";
							if ($key == $i['status_id']) {
							    $selected = "selected";
							}
							echo "<option value='" . $key . "' " . $selected . ">" . $r . "</option>";
						endforeach;
						}
						?>
						<br />
					</td>
			    </tr>
				<?php
				endforeach;
				}
				if (isset($show_submit_button) && $show_submit_button > 0) {
				?>
				<tr>
					<td align="right" colspan="6">
						<input type="submit" name="update_user_tasks" value="<?php echo $lang['sub_update'];?>" class="formInput" />&nbsp;&nbsp;
						<br />
					</td>
				</tr>
				<?php
				}
				?>
			</table>
			
			<?php
			}
			?>
		</td>
	</tr>
</table>
</form>
