<?php

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

?>

<script type="text/javascript" src="js/calendar.js"></script>
<script type="text/javascript" src="<?php echo $languagePath;?>calendar/calendar-lang.js"></script>
<script type="text/javascript" src="js/calendar-setup.js"></script>

<div class="col_main">
	<?php
	if (isset($schedule)) {
	?>
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_schedule_item'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<div class="metadata_top">
					<b><?php echo $lang['txt_item_options'];?></b> -&#62; 
					<?php
					if (isset($me['user_id']) && $me['user_id'] > 0) { // we need to be logged in
					?>
					
					<?php
					if ($me['user_id'] == $schedule['user_id']) {
					?>
					<a href="sch_edit.php?schedule_id=<?php echo $schedule['schedule_id'];?>"><?php echo $lang['href_edit'];?></a>
					,&nbsp;
					<?php }?>
					
					<?php
					if (isset($schedule['bookmark']['watch'])) {
					?>
					<a href="sch_view.php?schedule_id=<?php echo $schedule['schedule_id'];?>&amp;bookmark=del_mark"><?php echo $lang['href_unwatch_this'];?></a>
					<?php
					}
					else {
					?>
					<a href="sch_view.php?schedule_id=<?php echo $schedule['schedule_id'];?>&amp;bookmark=ins_mark"><?php echo $lang['href_watch_this'];?></a>
					<?php }?>
					,&nbsp;
					
					<?php
					if (isset($schedule['bookmark']['recommend'])) {
					?>
					<a href="sch_view.php?schedule_id=<?php echo $schedule['schedule_id'];?>&amp;bookmark=del_tip"><?php echo $lang['href_unrecommend_this'];?></a>
					<?php
					}
					else {
					?>
					<a href="sch_view.php?schedule_id=<?php echo $schedule['schedule_id'];?>&amp;bookmark=ins_tip"><?php echo $lang['href_recommend_this'];?></a>
					<?php }?>
					
					<?php
					if (!isset($schedule['bookmark']['watch']) && isset($batch_enabled) && $batch_enabled == true) {
					?>
					,&nbsp;
					<a href="sch_view.php?schedule_id=<?php echo $schedule['schedule_id'];?>&amp;bookmark=ins_mark&amp;notify=1"><?php echo $lang['href_watch_this_notify'];?></a>
					<?php }?>
					<?php }?>
					<br />
				</div>
				
				<p class="txt_item_title">
					<?php echo $schedule['schedule_title'];?><br />
				</p>
					
				<p>
					<?php echo $lang['txt_start'];?>:
					<?php 
					if (!empty($schedule['schedule_start_datetime'])) {
						echo $this->date->formatDate($schedule['schedule_start_datetime'], 1);
						
						if (!empty($schedule['schedule_all_day_item'])) {
							echo " (" .$lang['txt_all_day_item'] . ")";
						}
					}
					else {
						echo $lang['txt_no_start'];
					}
					?>&nbsp;
					
					<?php echo $lang['txt_end'];?>: 
					<?php 
					if (!empty($schedule['schedule_end_datetime'])) {
						echo $this->date->formatDate($schedule['schedule_end_datetime'], 1);
						
						if (!empty($schedule['schedule_all_day_item'])) {
							echo " (" .$lang['txt_all_day_item'] . ")";
						}
					}
					else {
						echo $lang['txt_no_end'];
					}
					?>
					<br />
					
					<?php echo $lang['txt_location'];?>: 
					<?php echo $schedule['schedule_location'];?>
					&nbsp;
					
					<?php echo $lang['txt_status'];?>: 
					<?php 
					if (isset($schedule['status_id'])) {
						echo $lang['schedule']['arr_event_status'][$schedule['status_id']];
					}?><br />
					
					
					<?php
					if (isset($schedule['schedule_type_id']) && $schedule['schedule_type_id'] == 2) { //task
					if (!empty($schedule['schedule_priority'])) {
					?>
						<?php echo $lang['txt_priority'];?>: 
						<?php echo $lang['schedule']['arr_priority'][$schedule['schedule_priority']];?>, 
					<?php }?>
						<?php echo $lang['txt_p_complete'];?>: 
					<?php 
						if (!empty($schedule['schedule_complete'])) { //task
							echo $lang['txt_complete'] . "<br />";
						}
						else {
							echo $schedule['schedule_p_complete'] . "<br />";
						}
					}
					?>
				</p>
				<hr />
				
				<p>
				<?php echo $schedule['schedule_body'];?><br />
				</p>
			
				<div class="metadata">
				<?php
				if (isset($author)) {
						if (isset($group)) {
							$profile_url = "grp_membership.php?group_id=" . $group['group_id'] . "&amp;user_id=" . $author['user_id'];
						}
						else {
							$profile_url = "sn_profile.php?user_id=" . $author['user_id'];
						}
				?>
					<p>
						<b><?php echo $lang['txt_author'];?></b> -&#62; 
						<?php echo $lang['txt_profile_nic'];?>: 
						<a href="<?php echo $profile_url;?>"><?php echo $author['profile_nic'];?></a>, 
						<?php echo $lang['txt_profile_session_status'];?>: 
						<?php
						if ($author['online_status'] == 1) {
							echo "<b>" . $lang['arr_user_online_status'][1] . "</b>";
						}
						else {
								echo $lang['arr_user_online_status'][$author['online_status']];
						}
						?>, 
						<?php echo $lang['txt_hometown'];?>: 
						<?php echo $author['profile_hometown'];?>, 
						<?php echo $lang['txt_joined'];?>: 
						<?php echo $this->date->formatDate($author['profile_create_datetime']);?>
						<?php
						if (isset($group)) {
						?>
						&nbsp;<?php echo $lang['txt_group_link'];?>: <a href="grp_view.php?group_id=<?php echo $group['group_id'];?>"><?php echo $group['group_title'];?></a>
						<?php }?>
						<br />
					</p>
					
					<p>
						<b><?php echo $lang['hdr_schedule_item'];?></b> -&#62; 
						<?php
						if (!empty($schedule['bookmark'])) {
							echo $lang['txt_bookmarks'] . ": ";
							
							if (!empty($schedule['bookmark']['watch'])) {
								echo $lang['txt_marked'];
							}
							
							if (!empty($schedule['bookmark']['watch']) && !empty($schedule['bookmark']['recommend'])) {
								echo "&nbsp;&amp;&nbsp;";
							}
						
							if (!empty($schedule['bookmark']['recommend'])) {
								echo $lang['txt_tipped'];
							}
							echo ", ";
						}
						?>
						<?php echo $lang['txt_published_to'];?>: 
						<?php
						if (isset($schedule['rsp'])) {
							foreach($schedule['rsp'] as $key => $i):
								if (!empty($i['degree_id']) && $i['level_id'] == $rspconfig['rsp_level']['node']) {
									echo $lang['rsp']['rsp_level_degree'][$i['degree_id']];
								}
								else {
									echo trim($lang['rsp']['rsp_level'][$i['level_id']]);
								}
								echo " (" .$lang['rsp']['status'][$i['status_id']];
								
								if (!empty($i['rsp_featured'])) {
									echo " &amp; " .  $lang['txt_featured'];
								}
								
								echo ")";
								if ($key+1 < count($schedule['rsp'])) {
									echo ", ";
								}
							endforeach;
						}
						?>
						<br />
					</p>
					<?php }?>
				</div>
			</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_comments'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php
					//comments
					if (!empty($schedule['schedule_allow_comments'])) {
						$unlocked = 1;
					}
						
					$hidden_form = array(
						"schedule_id" => $schedule['schedule_id']
					);
					
					if (isset($_REQUEST['user_id'])) {
						$hidden_form['user_id'] = $_REQUEST['user_id'];
					}
					
					if (isset($group['group_id'])) {
						$hidden_form['group_id'] = $group['group_id'];
					}
				
				if (isset($schedule['user_id'])) {
					$hidden_form['item_user_id'] = $schedule['user_id'];
				}
					
					include $templatePath . "comment.inc.tpl.php";
				?>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<?php 
	}
	elseif (isset($schedule_items)) { //list view
	?>
	
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_schedule_items'];?>
			<br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php
				if (isset($schedule_items)) {
				?>
					<p>
						<b><?php echo $lang['hdr_tasks'];?></b><br />
					</p>
					
					<table width="100%" cellpadding="4" cellspacing="0" border="0">
						<?php
						$display_items = trimArray($schedule_items);
						foreach($display_items as $key => $i):
						if (isset($i['schedule_type_id']) && $i['schedule_type_id'] == 2) { //task
						?>
						<tr>
							<td valign="top">
								<a href="sch_view.php?schedule_id=<?php echo $i['schedule_id']?>"><?php echo $i['schedule_title'];?></a><br />
								<?php echo $i['schedule_synopsis'];?><br />
							</td>
							<td align="right" valign="top" nowrap>
								<?php
								if (!empty($i['schedule_occurence'])) {
									if ($i['schedule_occurence'] == $schedule_config['occurrence']['daily']) {
										echo $lang['schedule']['occurrence'][1] . ": " . $this->date->formatDate($i['schedule_start_datetime'], 3);
									}
									elseif ($i['schedule_occurence'] == $schedule_config['occurrence']['weekly']) {
										echo $lang['schedule']['occurrence'][3] . ": " . $this->date->formatDate($i['schedule_start_datetime'], 4);
									}
									elseif ($i['schedule_occurence'] == $schedule_config['occurrence']['monthly']) {
										echo $lang['schedule']['occurrence'][9] . ": " . $this->date->formatDate($i['schedule_start_datetime'], 5);
									}
									elseif ($i['schedule_occurence'] == $schedule_config['occurrence']['yearly']) {
										echo $lang['schedule']['occurrence'][12] . ": " . $this->date->formatDate($i['schedule_start_datetime'], 5);
									}
								}
								else { //no repeat
									echo $i['display_schedule_start_datetime'];
								}
								?>
								<br />
								<?php
								if (isset($i['schedule_allocation'])) {
									echo $lang['txt_allocation'] . ": " . $i['schedule_allocation'] . "<br />";
								}
								?>
							</td>
						</tr>
						<?php
						}
						endforeach;
						?>
					</table>
					
					<p>
						<b><?php echo $lang['hdr_events'];?></b><br />
					</p>
					
					<table width="100%" cellpadding="4" cellspacing="0" border="0">
						<?php
						foreach($display_items as $key => $i):
						if (isset($i['schedule_type_id']) && $i['schedule_type_id'] == 1) { //event
						?>
						<tr>
							<td valign="top">
								<a href="sch_view.php?schedule_id=<?php echo $i['schedule_id']?>"><?php echo $i['schedule_title'];?></a><br />
								<?php echo $i['schedule_synopsis'];?><br />
							</td>
							<td align="right" valign="top" nowrap>
								<?php
								if (!empty($i['schedule_occurence'])) {
									if ($i['schedule_occurence'] == $schedule_config['occurrence']['daily']) {
										echo $lang['schedule']['occurrence'][1] . ": " . $this->date->formatDate($i['schedule_start_datetime'], 3);
									}
									elseif ($i['schedule_occurence'] == $schedule_config['occurrence']['weekly']) {
										echo $lang['schedule']['occurrence'][3] . ": " . $this->date->formatDate($i['schedule_start_datetime'], 4);
									}
									elseif ($i['schedule_occurence'] == $schedule_config['occurrence']['monthly']) {
										echo $lang['schedule']['occurrence'][9] . ": " . $this->date->formatDate($i['schedule_start_datetime'], 5);
									}
									elseif ($i['schedule_occurence'] == $schedule_config['occurrence']['yearly']) {
										echo $lang['schedule']['occurrence'][12] . ": " . $this->date->formatDate($i['schedule_start_datetime'], 5);
									}
								}
								else { //no repeat
									echo $i['display_schedule_start_datetime'];
								}
								?>
								<br />
								<?php
								if (isset($i['schedule_allocation'])) {
									echo $lang['txt_allocation'] . ": " . $i['schedule_allocation'] . "<br />";
								}
								?>
								<br />
								<?php
								if (isset($i['allocation_status_id'])) {
									echo $lang['schedule']['allocation_status'][$i['allocation_status_id']] . "<br />";
								}
								?>
							</td>
						</tr>
						<?php
						}
						endforeach;
						?>
					</table>
					<?php
					echo createArrayList($schedule_items);
					?>
				<?php 
				}
				if (!isset($schedule) && !isset($schedule_items	)) {
					echo $lang['err_no_schedule_items'] . "<br />";
				}
				?>
			</div>
		</div>
	</div>
	
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	<?php
	}
	elseif (isset($my_group_schedule_items)) { //list view sorted by group
	?>
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_my_group_schedule_items'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php echo $lang['txt_intro_group'];?><br />
				
				<?php
				if (!empty($my_group_schedule_items)) {
				?>
				
				<table border="0" cellspacing="0" cellpadding="4" width="100%">
					<?php
					foreach($my_group_schedule_items as $key => $g):
					if (!empty($g['schedule_items'])) {
					?>
					<tr>
						<td colspan="2">
							<b><?php echo $g['group_title'];?></b><br />
						</td>
						<td align="right" nowrap="nowrap">
							<a href="sch_view.php?group_id=<?php echo $g['group_id'];?>"><?php echo $lang['href_group_schedule_item'];?></a><br />
						</td>
					</tr>
					<?php
					foreach($g['schedule_items'] as $key => $i):
					?>
					<tr>
						<td width="1" rowspan="2">
							<a href="sch_view.php?schedule_id=<?php echo $i['schedule_id'];?>"><img src="get_file.php?file=<?php echo $i['image']['file'];?>" border="0" alt="<?php echo $i['image']['file_title'];?>" /></a><br />
						</td>
						<td valign="top">
							<a href="sch_view.php?schedule_id=<?php echo $i['schedule_id'];?>"><?php echo $this->date->formatDate($i['schedule_create_datetime'], 1);?></a><br />
							<?php echo $i['schedule_title'];?><br />
						</td>
						<td valign="top" align="right">
							<?php echo $lang['href_comments'];?>&nbsp;(<?php if (!empty($i['comment_total'])) { echo $i['comment_total'];} else { echo "0";}?>)
							<br />
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<?php echo $lang['txt_tag'];?>: 

							<?php
							$tags = "";
							if (isset($i['tags'])) {
								foreach ($i['tags'] as $keyt => $t):
									$tags .= $t['tag_body'];
									
									if (count($i['tags']) > $keyt+1) {
										$tags .= ", ";
									}
								endforeach;
								
								if (isset($tag)) {
									$tags = searchTextFormat($tag, $tags);
								}
								echo $tags;
							}
							?>
						</td>
					</tr>
					<?php
					endforeach;
					?>
					<tr>
						<td colspan="3">
							<hr />
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
						</td>
					</tr>
					<?php
					}
					else {
						$group_no_schedule_item_list[] = $g;
					}
					endforeach;
					?>
					
				</table>
				<?php }?>
				
				<?php
				if (!empty($group_no_schedule_item_list)) {
				?>
				
				<p>
					<?php echo $lang['txt_outro_group'];?><br />
				</p>
				
				<table border="0" cellspacing="0" cellpadding="4" width="100%">
					<?php
					foreach($group_no_schedule_item_list as $key => $g):
					?>
					<tr>
						<td>
							<b><?php echo $g['group_title'];?></b><br />
						</td>
						<td align="right">
							<a href="sch_view.php?group_id=<?php echo $g['group_id'];?>"><?php echo $lang['href_group_schedule_item'];?></a><br />
						</td>
					</tr>
				<?php
				endforeach;
				?>
				</table>
				<?php }?>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<?php
	}
	elseif (isset($my_network_schedule_items)) { //list view sorted by group
	?>
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_my_network_schedule_items'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<?php echo $lang['txt_intro_network'];?><br />
				</p>
				
				<?php
				if (!empty($my_network_schedule_items)) {
				?>
				
				<table border="0" cellspacing="0" cellpadding="4" width="100%">
					<?php
					foreach($my_network_schedule_items as $key => $g):
					if (!empty($g['schedule_items'])) {
					?>
					<tr>
						<td valign="top" width="32">
							<a href="sn_profile.php?user_id=<?php echo $g['user_id'];?>"><img src="get_file.php?file=<?php echo $g['image']['file'];?>" border="0" class="picture" alt="<?php echo $g['image']['file_title'];?>" /></a><br />
						</td>
						<td>
							<?php
							if (!empty($g['am_relation_to_them']['relation_show_true_self'])) {
							?>
								<b><a href="sn_profile.php?user_id=<?php echo $g['user_id'];?>"><?php echo $g['user_firstname']. " " . $g['user_surname'];?></a></b>,
								
								
								<?php echo $this->date->formatDate($g['user_create_datetime']);?>,
								<?php echo $g['user_hometown'];?>,
							<?php
							}
							else {
							?>
							
								<a href="sn_profile.php?user_id=<?php echo $g['user_id'];?>"><b><?php echo $g['profile_nic'];?></b></a>,
								
								
								<?php echo $this->date->formatDate($g['user_create_datetime']);?>,
								<?php echo $g['profile_hometown'];?>,
							<?php }?>
							
							<?php
							if ($g['online_status'] == 1) {
								echo "<b>" . $lang['arr_user_online_status'][1] . "</b><br />";
							}
							else {
									echo $lang['arr_user_online_status'][$g['online_status']] . "<br />";
							}
							?>
						</td>
						<td align="right">
							<a href="sch_view.php?user_id=<?php echo $g['user_id'];?>"><?php echo $lang['href_network_schedule_item'];?></a><br />
						</td>
					</tr>
					<?php
					foreach($g['schedule_items'] as $key => $i):
					?>
					<tr>
						<td width="32" rowspan="2">
							<a href="sch_view.php?schedule_id=<?php echo $i['schedule_id'];?>"><img src="get_file.php?file=<?php echo $i['image']['file'];?>" border="0" alt="<?php echo $i['image']['file_title'];?>" /></a><br />
						</td>
						<td valign="top" nowrap="nowrap">
							<a href="sch_view.php?schedule_id=<?php echo $i['schedule_id'];?>"><?php echo $this->date->formatDate($i['schedule_create_datetime'], 1);?></a><br />
							<?php echo $i['schedule_title'];?><br />
						</td>
						<td valign="top">
							<?php echo $lang['href_comments'];?>&nbsp;(<?php if (!empty($i['comment_total'])) { echo $i['comment_total'];} else { echo "0";}?>)
							<br />
						</td>
					</tr>
					<tr>
						<td>
							<?php echo $lang['txt_tag'];?>: 

							<?php
							$tags = "";
							if (isset($i['tags'])) {
								foreach ($i['tags'] as $keyt => $t):
									$tags .= $t['tag_body'];
									
									if (count($i['tags']) > $keyt+1) {
										$tags .= ", ";
									}
								endforeach;
								
								if (isset($tag)) {
									$tags = searchTextFormat($tag, $tags);
								}
								echo $tags;
							}
							?>
						</td>
						<td>
							<br />
						</td>
					</tr>
					<?php
					endforeach;
					?>
					<tr>
						<td colspan="4">
							<hr />
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
						</td>
					</tr>
					<?php
					}
					else {
						$network_no_schedule_item_list[] = $g;
					}
					endforeach;
					?>
				</table>
				<?php }?>
				
				<?php
				if (!empty($network_no_schedule_item_list)) {
				?>
				
				<p>
					<?php echo $lang['txt_outro_network'];?><br />
				</p>
				
				<table border="0" cellspacing="0" cellpadding="4" width="100%">
					<?php
					foreach($network_no_schedule_item_list as $key => $g):
					?>
					<tr>
						<td colspan="2">
							<?php
							if (!empty($g['am_relation_to_them']['relation_show_true_self'])) {
							?>
								<b><a href="sn_profile.php?user_id=<?php echo $g['user_id'];?>"><?php echo $g['user_firstname']. " " . $g['user_surname'];?></a></b>,
								
								
								<?php echo $g['user_create_datetime'];?>,
								<?php echo $g['user_hometown'];?>,
							<?php
							}
							else {
							?>
							
								<a href="sn_profile.php?user_id=<?php echo $g['user_id'];?>"><b><?php echo $g['profile_nic'];?></b></a>,
								
								
								<?php echo $g['user_create_datetime'];?>,
								<?php echo $g['profile_hometown'];?>,
							<?php }?>
							
							<?php
							if ($g['online_status'] == 1) {
								echo "<b>" . $lang['arr_user_online_status'][1] . "</b><br />";
							}
							else {
									echo $lang['arr_user_online_status'][$g['online_status']] . "<br />";
							}
							?>
						</td>
						<td align="right" colspan="2">
							<a href="sch_view.php?user_id=<?php echo $g['user_id'];?>"><?php echo $lang['href_network_schedule_item'];?></a><br />
						</td>
					</tr>
				<?php
				endforeach;
				?>
				</table>
				<?php }?>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	
	<?php
	}
	else  { //error - no schedule_items
	?>
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_schedule_items'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<?php echo $lang['err_no_schedule_items'];?><br />
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	<?php }?>
</div>

<div class="col_side">
	<?php
	if (isset($schedule_items) && isset ($profile)) {
	?>
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_schedule_item_author'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<b><?php echo $profile['profile_nic'];?></b><br />
				</p>
				
				<img src="get_file.php?file=<?php echo $profile['image']['file'];?>" border="0" alt="<?php echo $profile['image']['file_title'];?>" /><br />
				
				<table border="0" cellspacing="0" cellpadding="2" width="100%">
					<tr>
						<td>
							<?php echo $lang['txt_profile_session_status'];?><br />
						</td>
						<td>
							<?php
							if ($profile['online_status'] == 1) {
								echo "<b>" . $lang['arr_user_online_status'][1] . "</b><br />";
							}
							else {
									echo $lang['arr_user_online_status'][$profile['online_status']] . "<br />";
							}
							?>
						</td>
					</tr>
					<tr>
						<td>
							<?php echo $lang['txt_hometown'];?><br />
						</td>
						<td>
							<?php echo $profile['profile_hometown'];?><br />
						</td>
					</tr>
					<tr>
						<td valign="top">
							<?php echo $lang['txt_joined'];?><br />
						</td>
						<td>
							<?php echo $this->date->formatDate($profile['profile_create_datetime']);?><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 }?>
	
	<?php
	if (isset($schedule_items) && isset ($group)) {
	?>
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_schedule_item_group_author'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<b><?php echo $group['group_title'];?></b><br />
				</p>
				
				<?php
				if (isset($group['image']['file_id'])) {
				?>
				<img src="get_file.php?file=<?php echo $group['image']['file'];?>" border="0" alt="<?php echo $group['image']['file_title'];?>" /><br />
				<?php }?>
				
				<table border="0" cellspacing="0" cellpadding="2" width="100%">
					<tr>
						<td>
							<?php echo $lang['txt_membership_status'];?><br />
						</td>
						<td>
							<?php echo $group['member']['role_name'];?><br />
						</td>
					</tr>
					<tr>
						<td>
							<?php echo $lang['txt_group_language'];?><br />
						</td>
						<td>
							<?php
							if (isset($lang['arr_lang_name'][$group['language_id']])) {
								echo $lang['arr_lang_name'][$group['language_id']];
							}
							?><br />
						</td>
					</tr>
					<tr>
						<td>
							<?php echo $lang['txt_group_type'];?><br />
						</td>
						<td>
							<?php 
							if (isset($group['group_registration_type'])) {
								echo $lang['arr_registration_type'][$group['group_registration_type']];
							}
							else {
								echo $lang['txt_hidden'];
							}
							
							?><br />
						</td>
					</tr>
					<tr>
						<td>
							<?php echo $lang['txt_rec_age'];?><br />
						</td>
						<td>
							<?
							if ($group['group_from_age'] && $group['group_to_age']) {
								echo $group['group_from_age'] . "/" . $group['group_to_age'];
							}
							else if ($group['group_from_age'] && !$group['group_to_age']) {
								echo $lang['txt_age_from'] . " " . $group['group_from_age'];
							}
							else if (!$group['group_from_age'] && $group['group_to_age']) {
								echo $lang['txt_age_upto'] . " " . $group['group_to_age'];
							}
							else {
								echo $lang['txt_age_all'];
							}
							?>
							<br />
						</td>
					</tr>
				</table>
				
				<?php
				if (!empty($group['member']['role_visitor'])) {
				?>
				<p align="right">
					<b><a href="grp_membership.php?group_id=<?php echo $group['group_id'];?>"><?php echo $lang['href_join'];?></a></b><br />
				</p>
				<?php }?>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
	<?php }?>
	
	
	<form action="sch_view.php" method="post" name="frm" id="id_frm">
	<input type="hidden" name="schedule_id" value="<?php if(isset($schedule['schedule_id'])) { echo $schedule['schedule_id'];}?>" />
	<input type="hidden" name="schedule_type_id" value="<?php if(isset($schedule_type_id)) { echo $schedule_type_id;}?>" />
	<input type="hidden" name="group_id" value="<?php if(isset($group['group_id'])) { echo $group['group_id'];}?>" />
				
	<?php
	if (isset($schedule)) {
	?>
	<div class="box">
		<div class="box_top">
			<?php echo $lang['hdr_attendance'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<table border="0" cellspacing="0" cellpadding="2">
					<tr>
						<td>
							<?php echo $lang['txt_allocation'];?><br />
						</td>
						<td>
							<?php echo $schedule['schedule_allocation'];?><br />
						</td>
					</tr>
					<tr>
						<td>
							<?php echo $lang['txt_applications'];?><br />
						</td>
						<td>
							<?php echo $schedule['schedule_applicants'];?><br />
						</td>
					</tr>
					<tr>
						<td>
							<?php echo $lang['txt_confirmed'];?><br />
						</td>
						<td>
							<?php echo $schedule['schedule_confirmed'];?><br />
						</td>
					</tr>
				</table>
				
				<?php
				if (isset($me['user_id']) && $me['user_id']>0) {
				?>
				<table border="0" cellspacing="0" cellpadding="2" width="100%">
					<tr>
						<td valign="top">
							<?php
							$url = "sch_view.php?schedule_id=" . $schedule['schedule_id'];
							?>
							
							
							<?php
							if ($schedule['schedule_allocation'] > $schedule['schedule_confirmed']) { //spaces available
								echo $lang['txt_event_allocation_intro'];
								echo "<br /><br />";
							
								if (isset($schedule['allocation']['status_id'])) {
									if ($schedule['allocation']['status_id'] == $schedule_config['allocation_status']['rejected']) {
										echo "<p>" . $lang['txt_application_rejected'];
									}
									else {
										echo "<p align=\"right\"><b>" . $lang['txt_application'] . " " . $lang['schedule']['allocation_status'][$schedule['allocation']['status_id']] . "</b></p><p align=\"right\">";
									}
									
									
									
									//if task is confirmed allow use to remove it
									if ($schedule['allocation']['status_id'] == $schedule_config['allocation_status']['confirmed']) {
										$button = "<a href=\"" . $url . "&amp;withdraw_confirmation=1\" class=\"link_urgent\">" . $lang['href_event_withdraw_confirmation'] . "</a>";
									}
									elseif ($schedule['allocation']['status_id'] == $schedule_config['allocation_status']['withdrawn'] || $schedule['allocation']['status_id'] < 1) {
										$button = "<a href=\"" . $url . "&amp;schedule_apply_update=1\" class=\"link_urgent\">" . $lang['href_event_apply'] . "</a>";
									}
								}
								else {
									$button = "<a href=\"" . $url . "&amp;schedule_apply=1\" class=\"link_urgent\">" . $lang['href_event_apply'] . "</a>";
								}
							}
							?><br />
							</p>
						</td>
					</tr>
				</table>
				<?php
				}
				else {
				?>
				<p>
					<b><?php echo $lang['txt_log_in_attendance'];?></b><br />
				</p>
				<?php }?>
				
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td>
							<?php
							if (isset($button)) {
								echo "&nbsp;" . $button;
							}
							?>
						</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 class="box">
		<div class="box_top">
			<?php echo $lang['hdr_schedule_item'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<b><?php echo $lang['txt_statistics'];?></b><br />
				</p>
					
				<?php
				if (isset($lang['txt_task_summary'])) {
					echo $lang['txt_task_summary'];
				}
				?>
				&nbsp;
				<?php
				if (isset($lang['txt_event_summary'])) {
					echo $lang['txt_event_summary'];
				}
				?><br />
				</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_options'];?><br />
		</div>
		
		<div class="box_mid">
			<div class="content">
				<p>
					<b><?php echo $lang['txt_view'];?></b><br />
				</p>
				
				<?php
				if (isset($view) && $view == "node") {
				?>
				<?php echo $lang['href_view_node'];?><br />
				<?php
				}
				else {
				?>
				<a href="sch_view.php?view=node"><?php echo $lang['href_view_node'];?></a><br />
				<?php }?>
				
				<?php
				if (isset($me['user_id'])) {
				?>
				
				<?php
				if (isset($view) && $view == "my_network") {
				?>
				<?php echo $lang['href_view_network'];?><br />
				<?php
				}
				else {
				?>
				<a href="sch_view.php?view=my_network"><?php echo $lang['href_view_network'];?></a><br />
				<?php }?>
				
				<?php
				if (isset($view) && $view == "my_groups") {
				?>
				<?php echo $lang['href_view_my_groups'];?><br />
				<?php
				}
				else {
				?>
				<a href="sch_view.php?view=my_groups"><?php echo $lang['href_view_my_groups'];?></a><br />
				<?php }?>
				
				<?php
				if (isset($view) && $view == "allocation") {
				?>
				<?php echo $lang['href_allocation'];?><br />
				<?php
				}
				else {
				?>
				<a href="sch_view.php?view=allocation"><?php echo $lang['href_allocation'];?></a><br />
				<?php }?>
				
				<?php
				if (isset($view) && $view == "my_schedule_item") {
				?>
				<?php echo $lang['href_my_schedule'];?><br />
				<?php
				}
				else {
				?>
				<a href="sch_view.php?view=my_schedule_item"><?php echo $lang['href_my_schedule'];?></a><br />
				<?php }?>
				
				<?php
				if (isset($view) && $view == "marked_schedule_item_entries") {
				?>
				<?php echo $lang['href_marked'];?><br />
				<?php
				}
				else {
				?>
				<a href="sch_view.php?view=marked_schedule_item_entries"><?php echo $lang['href_marked'];?></a><br />
				<?php }?>
				
				
				<?php }?>
				<?php
				if (isset($schedule)) {
				if (isset($group)) {
				?>
				<a href="sch_view.php?group_id=<?php echo $group['group_id'];?>"><?php echo $lang['href_group_schedule'];?></a><br />
				<?php
				}
				else {
				?>
				<a href="sch_view.php?user_id=<?php echo $schedule['user_id'];?>"><?php echo $lang['href_network_schedule'];?></a><br />
				<?php }}?>
				
				<?php
				if (isset($group) || isset($view) && $view == "my_schedule_item") {
				?>
				<p>
					<b><?php echo $lang['txt_options'];?></b><br />
				</p>
				
					<?php
					if (isset($view) && $view == "my_schedule_item" && $this->user_acs->checkPermission($resource_ids['node']['schedule'], $privilege_ids['add_item'])) { //resourece_id, Priv_id
					?>
					<a href="sch_edit.php?schedule_type_id=<?php echo $schedule_config['type']['event'];?>"><?php echo $lang['href_add_event'];?></a><br />
					<a href="sch_edit.php?schedule_type_id=<?php echo $schedule_config['type']['task'];?>"><?php echo $lang['href_add_task'];?></a><br />
					<?php }?>
					
					<?php
					if (isset($group)) {
					if ($this->group_acs->checkPermission($resource_ids['group']['schedule'], $privilege_ids['add_item'])) { //resourece_id, Priv_id
					?>
					<a href="sch_edit.php?group_id=<?php echo $group['group_id'];?>&amp;schedule_type_id=<?php echo $schedule_config['type']['event'];?>"><?php echo $lang['href_group_add_event'];?></a><br />
					<a href="sch_edit.php?group_id=<?php echo $group['group_id'];?>&amp;schedule_type_id=<?php echo $schedule_config['type']['task'];?>"><?php echo $lang['href_group_add_task'];?></a><br />
					<?php }}?>
				<?php }?>
				
				<?php
				if (isset($schedule)) {
				?>
				<p>
					<b><?php echo $lang['hdr_tag'];?></b><br />
				</p>
					
				<p>
					<?php
					$tags = "";
					if (isset($item_tags)) {
						foreach ($item_tags as $key => $i):
							$tags .= "<a href='search.php?tag=" . $i['tag_body']. "'>" . $i['tag_body'] . "</a>";
							
							if (isset($me['user_id']) && $i['user_id'] == $me['user_id']) {
								$tags .= "*";
							}
							
							if (count($item_tags) > $key+1) {
								$tags .= ", ";
							}
						endforeach;
						echo $tags;
					}
					?>
				</p>
				
				<?php
				if ($this->user_acs->checkPermission($resource_ids['node']['schedule'], $privilege_ids['allow_tagging'])) { //resourece_id, Priv_id
				$tags = "";
				if (isset($my_tags)) {
					foreach ($my_tags as $key => $i):
						$tags .= $i['tag_body'];
						if (count($my_tags) > $key+1) {
							$tags .= ", ";
						}
					endforeach;
				}
				?>
				<p>
					<input width="30" class="input" name="tags" value="<?php echo $tags;?>" />
					<input type="image" src="<?php echo $templatePath;?>img/go.png" name="update_tag" value="1" class="go" /><br />
				</p>
				
				</form>
				<?php }?>
				<?php }?>
			
				<p>
					<b><?php echo $lang['hdr_search'];?></b><br />
				</p>
				
				<form action="search.php" method="post" name="search" id="id_search">
				<input type="hidden" name="search_type" value="schedule_item" />
				
				<p>
					<label for="id_start_date"><?php echo $lang['form_label_from_date'];?></label><br />
				</p>
				
				<p>
					<input type="text" name="start_date" id="id_start_date" class="slim_input" size="11" value="<?php if(isset($search['start_date'])) { echo $search['start_date'];}?>" />&nbsp;
					<img src="<?php echo $templatePath;?>img/cal_icon.png" id="id_cal_pop1" width="34" height="21" border="0" alt="" onmouseover="this.style.background='red';" onmouseout="this.style.background=''" /><br />
						
						<script type="text/javascript">
							function dateChanged1(calendar) {
								if (calendar.dateClicked) {
									var y = calendar.date.getFullYear();
									var m = calendar.date.getMonth()+1;     // integer, 0..11
									var d = calendar.date.getDate();      // integer, 1..31
							
									document.frm.id_start_date.value = y + '-' + m + '-' + d;
									calendar.callCloseHandler();
								}
							};
							
							Calendar.setup({           // our callback function
								ifFormat       :    "%m-%d-%Y",
								showsTime      :    true,
								button         :    "id_cal_pop1",
								singleClick    :    true,
								onSelect    : dateChanged1
							});
						</script>
				</p>
				
				
				<?php
				if (isset($display) && $display == "task") {
				?>
				<p>
					<label for="id_schedule_priority"><?php echo $lang['form_label_priority'];?></label><br />
				</p>
				<p>
						<select id="id_schedule_priority" name="schedule_priority">
						<option value="0"><?php echo $lang['form_option_all'];?></option>
						<?php
						foreach($lang['schedule']['arr_priority'] as $key => $i):
						$selected = "";

						if (isset($schedule_priority) && $schedule_priority == $key) {
							$selected = " selected=\"selected\"";
						}
						?>
						<option value="<?php echo $key;?>"<?php echo $selected;?>><?php echo $i;?></option>
						<?php endforeach; ?>
						</select>
				</p>>
				<?php
				}
				else {
				?>
				</p>
					<label for="id_schedule_show"><?php echo $lang['form_label_show'];?></label><br />
				</p>
				
				<p>
						<select id="id_schedule_show" name="schedule_show">
						<option value="0"><?php echo $lang['form_option_all'];?></option>
						<?php
						foreach($lang['schedule']['arr_show_days'] as $key => $i):
						$selected = "";

						if (isset($search['schedule_show']) && $search['schedule_show'] == $key) {
							$selected = " selected=\"selected\"";
						}
						?>
						<option value="<?php echo $key;?>"<?php echo $selected;?>><?php echo $i;?></option>
						<?php endforeach; ?>
						</select>
				</p>
				
				
				<?php
				$checked = "";
				if (!empty($search['schedule_status'])) {
					$checked = "checked=\"checked\"";
				}
				?>
				<p>
					<label for="id_schedule_status"><?php echo $lang['form_label_tentative'];?></label>
					<input type="checkbox" id="id_schedule_status" name="schedule_status" class="checkbox" <?php echo $checked;?> />
					<br />
				</p>
				<?php }?>
				
				<p>
					<input type="text" name="search_text" size="20" value="<?php if (isset($search_text)) { echo $search_text;};?>" />
					<input type="image" src="<?php echo $templatePath;?>img/go.png" value="search" class="go" /><br />
				</p>
				
				</form>
			</div>
		</div>
	</div>
		
	<div class="box_bottom">
		<span class="box_bottom_right"></span>
		<span class="box_bottom_left"></span>
	</div>
</div>
