<?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="a_calendar.php" method="post">

<table width="770" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="180" valign="top">
			<?php
			include $templatePath . "a_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_action'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<a href="<?php echo $_SERVER["PHP_SELF"]?>?time=<?php echo $links["last"]?>" class="txt_sub_menu"><?php echo $lang['menu_calendar_last'];?></a><br />
						<a href="a_activities.php" class="txt_sub_menu"><?php echo $lang['menu_calendar_today'];?></a><br />
						<a href="<?php echo $_SERVER["PHP_SELF"]?>?time=<?php echo $links["next"]?>" class="txt_sub_menu"><?php echo $lang['menu_calendar_next'];?></a><br />
					
					
					</td>
				</tr>
			</table>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />

			<table border="0" width="100%" cellspacing="4" cellpadding="0" class="table_stnd">
				<tr>
					<td class="txt_title">
						<?php echo $lang['section_search'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<input type="text" name="search_text" size="18" class="formInput" value="<?php if(isset($search)) { echo $search;}?>" /><br />
					</td>
			    </tr>
				<tr>
					<td>
						<select name="search_activity_type_id" class="formInput">
							<option value="0"><?php echo $lang['txt_all_activity_types'];?></option>
							<?php
							foreach($lang['arr_activity_type'] as $key => $i):
								$selected = "";
								if(isset($search_activity_type_id) && $search_activity_type_id == $key) {
									$selected = " selected";
								}

								print "<option value='" . $key . "' " . $selected . ">" . $i . "</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="52" alt="" /><br />

			<?php
			include $templatePath . "logo.inc.tpl.php";
			?>
		</td>

		<td width="20">&nbsp;</td>
		
		<?php
		if (isset($display) && $display == "search") {
		?>
		<td width="570" valign="top">
			<table width="100%" cellpadding="4" cellspacing="0" border="0" class="table_stnd">
				<tr>
					<td colspan="4" class="txt_title" align="right">
						<?php echo $lang['hdr_activity_search_results'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (isset($activity_search_results)) {
				foreach($activity_search_results as $key => $i):
				?>
			     <tr>
					<td valign="top" colspan="2">
						<?php
						if (isset($i['image']['image_id'])) {
						?>
							<img align="left" src="get_file.php?file=<?php echo $i['image']['image'];?>" border="0" class="picture" alt="<?php echo $i['image']['image_title'];?>" />
						<?
						}
						?>
						<a href="e_activity.php?activity_id=<?php echo $i['activity_id'];?><?php if(isset($i['group_id'])) {echo "&amp;group_id=" . $i['group_id'];}?>"><?php echo $i['activity_title'];?></a><br />
						<span class="txt_footer"><?php echo $i['activity_synopsis'];?></span><br />
					</td>
					<td align="right" valign="top" nowrap>
						<?php echo $i['activity_start_datetime'];?><br />
					</td>
			    </tr>
				<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="3">
						<?php echo $lang['err_no_search_results'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>

			<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="4" class="txt_title" align="right">
						<?php echo $lang['hdr_task_search_results'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (isset($task_search_results)) {
				foreach($task_search_results as $key => $i):
				?>
			     <tr>
					<td valign="top">
						<a href="u_task.php?task_id=<?php echo $i['task_id'];?>"><?php echo $i['task_title'];?></a><br />
						<span class="txt_footer"><?php echo $i['task_synopsis'];?></span><br />
					</td>
					<td valign="top">
						<?php echo $i['task_user_requirement'];?><br />
					</td>
					<td align="right" valign="top" nowrap>
						<?php echo $i['task_start_datetime'];?><br />
					</td>
			    </tr>
				<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="4">
						<?php echo $lang['err_no_search_results'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
		</td>
		<?php
		} else {
		?>
		<td width="275" valign="top">
			<table width="100%" cellpadding="2" cellspacing="2" border="0" class="table_stnd">
				<tr>
					<td class="txt_title" align="right" colspan="3">
						<?php echo $lang['hdr_featured_activities'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (isset($activities)) {
				foreach($activities as $key => $i):
				?>
			     <tr>
					<td valign="top" width="28">
						<img src="get_file.php?file=<?php echo $i['image']['file'];?>" border="0" class="picture_left" title="<?php echo $i['image']['file_title'];?>">
					</td>
					<td>
						<a href="a_activity.php?activity_id=<?php echo $i['activity_id'];?>"><?php echo $i['activity_title'];?></a><br />
						<span class="txt_footer"><?php echo $i['activity_synopsis'];?></span><br />
					</td>
					<td align="right" valign="top">
						<?php echo $i['display_activity_start_datetime'];?><br />
					</td>
			    </tr>
				<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="3">
						<?php echo $lang['err_no_activity_tasks'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
		</td>
		
		<td width="20">&nbsp;</td>
		
		<td width="275" valign="top">
			<table width="100%" cellpadding="0" cellspacing="4" border="0" class="table_stnd">
				<tr>
					<td class="txt_title" align="right">
						<?echo $thismonth;?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<table width="100%" cellpadding="2" cellspacing="2" border="0" class="picture">
							<?php
							if (isset($calendar)) {

							$day = 0;
							?>
							<tr>
								<td class="bg2" align="center"><?php echo $lang['txt_sun'];?></td>
								<td class="bg2" align="center"><?php echo $lang['txt_mon'];?></td>
								<td class="bg2" align="center"><?php echo $lang['txt_tue'];?></td>
								<td class="bg2" align="center"><?php echo $lang['txt_wed'];?></td>
								<td class="bg2" align="center"><?php echo $lang['txt_thu'];?></td>
								<td class="bg2" align="center"><?php echo $lang['txt_fri'];?></td>
								<td class="bg2" align="center"><?php echo $lang['txt_sat'];?></td>
							</tr>

							<?php
							foreach($calendar as $key => $r):

							if ($day == 0) {
							    echo "<tr>";
							}
							?>

								<?php
								if (isset($r['today'])) {
								?>

								<?php
								if ($todaynumber == $r['daynumber']) {
								?>
								<td width="14%" valign="top" class="bg1" align="center">
								<?php
								}
								else {
								?>
								<td width="14%" valign="top" class="bg3" align="center">
								<?php
								}
								?>
									<table width="100%" cellpadding="2" cellspacing="0" border="0" class="table_nested">
										<tr>
											<td align="center">
												<?php
												if(!isset($r['content']))
													echo $r['daynumber'];
												else {
												?>
													<a href="a_schedule.php?time=<?php echo strtotime($r["today"]);?>"><?php echo $r['daynumber'];?></a>
												<?php
												}
												?><br />
											</td>
										</tr>
										<tr>
											<td align="center">
												<?php
												if (isset($r['content'])) {
													$count = count($r['content']);
													if ($count <= 0) {
													    $count = "";
													}
												
													echo $count;
												}
												?>
												<br />
											</td>
										</tr>
									</table>
								</td>

								<?php
								}
								else {
								?>
								<td class="bg4">&nbsp;<br /></td>
								<?php
								}
								?>

							<?php
							$day++;

							if ($day == 7) {
							    echo "</tr>";
								$day = 0;
							}

							endforeach;
							}
							?>
						</table>
					</td>
				</tr>
			</table>
			
			<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="4" class="txt_title" align="right">
						<?php echo $lang['hdr_featured_tasks'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (isset($tasks)) {
				foreach($tasks as $key => $i):
				?>
			     <tr>
					<td valign="top">
						<a href="a_activity.php?activity_id=<?php echo $i['activity_id'];?>"><?php echo $i['task_title'];?></a><br />
						<span class="txt_footer"><?php echo $i['task_synopsis'];?></span><br />
					</td>
					<td valign="top">
						<?php echo $i['task_user_requirement'];?><br />
					</td>
					<td align="right" valign="top" nowrap>
						<?php echo $i['task_start_datetime'];?><br />
					</td>
			    </tr>
				<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="4">
						<?php echo $lang['err_no_activity_tasks'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
		</td>
		<?php } ?>
	</tr>
</table>
</form>
