<?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_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($activity['activity_id'])) { echo $activity['activity_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="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_activity_schedule") {
			?>
			
			<input type="hidden" name="data[activity_title]" value="<?php if(isset($activity['activity_title'])) { echo $activity['activity_title'];}?>" />
			<input type="hidden" name="data[activity_synopsis]" value="<?php if(isset($activity['activity_synopsis'])) { echo $activity['activity_synopsis'];}?>" />
			<input type="hidden" name="data[activity_body]" value="<?php if(isset($activity['activity_body'])) { echo $activity['activity_body'];}?>" />
			<input type="hidden" name="data[activity_location]" value="<?php if(isset($activity['activity_location'])) { echo $activity['activity_location'];}?>" />
			<input type="hidden" name="data[activity_frequency]" value="<?php if(isset($activity['activity_frequency'])) { echo $activity['activity_frequency'];}?>" />
			<input type="hidden" name="data[activity_type_id]" value="<?php if(isset($activity['activity_type_id'])) { echo $activity['activity_type_id'];}?>" />
			<input type="hidden" name="data[file_id]" value="<?php if(isset($activity['file_id'])) { echo $activity['file_id'];}?>" />
			<input type="hidden" name="data[cms_node]" value="<?php if(isset($activity['cms_node'])) { echo $activity['cms_node'];}?>" />
			<input type="hidden" name="data[cms_group]" value="<?php if(isset($activity['cms_group'])) { echo $activity['cms_group'];}?>" />
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_activity'];?><br />
						<hr />
					</td>
				</tr>
				<?php
				if (isset($activity['activity_frequency']) && $activity['activity_frequency'] == $frequency_ids['yearly']) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_start_yr'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $start_datedropdown;?>
						&nbsp;&nbsp;&nbsp;<?php echo $lang['txt_no_start_date'];?>: <input type="checkbox" name="no_start_datetime" <?php if (empty($activity['activity_start_datetime'])) {echo "checked selected";};?> /><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_end_yr'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $end_datedropdown;?>
						&nbsp;&nbsp;&nbsp;<?php echo $lang['txt_no_end_date'];?>: <input type="checkbox" name="no_end_datetime" <?php if (empty($activity['activity_end_datetime'])) {echo "checked selected";};?>><br />
						<input type="hidden" name="activity_frequency" value="<?php echo $activity['activity_frequency'];?>" />
					</td>
				</tr>
				<?php
				}
				elseif (isset($activity['activity_frequency']) && $activity['activity_frequency'] == $frequency_ids['monthly']) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_start_mth'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $start_datedropdown;?>
						&nbsp;&nbsp;&nbsp;<?php echo $lang['txt_no_start_date'];?>: <input type="checkbox" name="no_start_datetime" <?php if (empty($activity['activity_start_datetime'])) {echo "checked selected";};?> /><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_end_mth'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $end_datedropdown;?>
						&nbsp;&nbsp;&nbsp;<?php echo $lang['txt_no_end_date'];?>: <input type="checkbox" name="no_end_datetime" <?php if (empty($activity['activity_end_datetime'])) {echo "checked selected";};?>><br />
						<input type="hidden" name="activity_frequency" value="<?php echo $activity['activity_frequency'];?>" />
					</td>
				</tr>
				<?php
				}
				elseif (isset($activity['activity_frequency']) && $activity['activity_frequency'] == $frequency_ids['weekly']) {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_from'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $start_datedropdown;?>
						&nbsp;&nbsp;&nbsp;<?php echo $lang['txt_no_start_date'];?>: <input type="checkbox" name="no_start_datetime" <?php if (empty($activity['activity_start_datetime'])) {echo "checked selected";};?> /><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<b><?php echo $lang['txt_start_wk'];?>:</b><br />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="1">
						<select name="data[activity_start_weekday]" class='formInput'>
						<?php
						foreach($lang['activity']['arr_day_name'] as $key => $i):
						?>
						<option value="<?php echo $key;?>"><?php echo $i;?></option>
						<?php endforeach; ?>
						</select>
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_to'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $end_datedropdown;?>
						&nbsp;&nbsp;&nbsp;<?php echo $lang['txt_no_end_date'];?>: <input type="checkbox" name="no_end_datetime" <?php if (empty($activity['activity_end_datetime'])) {echo "checked selected";};?>><br />
						<input type="hidden" name="activity_frequency" value="<?php echo $activity['activity_frequency'];?>" />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_end_wk'];?></b>
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="1">
						<select name="data[activity_end_weekday]" class='formInput'>
						<?php
						foreach($lang['activity']['arr_day_name'] as $key => $i):
						?>
						<option value="<?php echo $key;?>"><?php echo $i;?></option>
						<?php endforeach; ?>
						</select>
					</td>
				</tr>
				<?php
				}
				else {
				?>
				<tr>
					<td>
						<?php echo $lang['txt_from'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $start_datedropdown;?>
						&nbsp;&nbsp;&nbsp;<?php echo $lang['txt_no_start_date'];?>: <input type="checkbox" name="no_start_datetime" <?php if (empty($activity['activity_start_datetime'])) {echo "checked selected";};?> /><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_to'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $end_datedropdown;?>
						&nbsp;&nbsp;&nbsp;<?php echo $lang['txt_no_end_date'];?>: <input type="checkbox" name="no_end_datetime" <?php if (empty($activity['activity_end_datetime'])) {echo "checked selected";};?>><br />
						<input type="hidden" name="activity_frequency" value="<?php echo $activity['activity_frequency'];?>" />
					</td>
				</tr>
				<?php }?>
			</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">
						<?php echo $lang['section_schedule'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="2">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="25" alt="" /><br />
					</td>
				</tr>
				<tr>
					<td valign="top" align="right">
						<input type="submit" name="insert_activity" class="formInput" value="<?php echo $lang['sub_add'];?>" /><br />
					</td>
				</tr>
			</table>
			<?php
			}
			elseif (isset($display) && $display == "no_edit_allowed") {
			?>
			
			<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_activity'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_title'];?><br />
					</td>
					<td>
						<?php echo $activity['activity_title'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_synopsis'];?><br />
					</td>
					<td>
						<?php echo $activity['activity_synopsis'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_from'];?><br />
					</td>
					<td>
						<?php echo $activity['activity_start_datetime'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_to'];?><br />
					</td>
					<td>
						<?php echo $activity['activity_end_datetime'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_location'];?><br />
					</td>
					<td>
						<?php echo $activity['activity_location'];?><br />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="20" alt="" /><br />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<?php echo $lang['txt_no_activity_delete_allowed'];?><br />
					</td>
				</tr>
			</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_activity'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<b><?php echo $lang['txt_title'];?></b><br />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<input type="text" name="data[activity_title]" size="65" value="<?php if (isset($activity['activity_title'])) { echo $activity['activity_title'];}?>" /><br />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<b><?php echo $lang['txt_synopsis'];?></b><br />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<textarea name="data[activity_synopsis]" cols="50" rows="2"><?php if (isset($activity['activity_synopsis'])) { echo $activity['activity_synopsis'];}?></textarea><br />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<b><?php echo $lang['txt_body'];?></b><br />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<textarea name="data[activity_body]" cols="50" rows="5"><?php if (isset($activity['activity_body'])) { echo $activity['activity_body'];}?></textarea><br />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<b><?php echo $lang['txt_location'];?></b><br />
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<input type="text" name="data[activity_location]" size="35" value="<?php if (isset($activity['activity_location'])) { echo $activity['activity_location'];}?>"><br />
					</td>
				</tr>
				<tr>
					<td>
						<b><?php echo $lang['txt_frequency'];?></b><br />
					</td>
					<td>
						<b><?php echo $lang['txt_type'];?></b><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<select name="data[activity_frequency]" class='formInput'>
						<?php
						foreach($lang['activity']['arr_frequency'] as $key => $i):
						$selected = "";
		
						if (isset($activity['activity_frequency']) && $activity['activity_frequency'] == $i['activity_frequency']) {
						    $selected = " selected=\"selected\"";
						}
						?>
						<option value="<?php echo $key;?>"<?php echo $selected;?>><?php echo $i;?></option>
						<?php endforeach; ?>
						</select>
					</td>
					<td valign="top">
						<select name="data[activity_type_id]" class="formInput">
						<?php
						foreach($lang['group']['arr_activity_type'] as $key => $i):
						$selected = "";
		
						if (isset($activity['activity_type_id']) && $activity['activity_type_id'] == $i['activity_type_id']) {
						    $selected = " selected=\"selected\"";
						}
						?>
						<option value="<?php echo $key;?>"<?php echo $selected;?>><?php echo $i;?></option>
						<?php endforeach; ?>
						</select>
					</td>
				</tr>
				<?php
				if (isset($activity['activity_id'])) {
				?>
				<tr>
					<td valign="top" align="right" colspan="2">
						<input type="submit" name="delete_activity" class="formInput" value="<?php echo $lang['sub_delete'];?>" /><br />
					</td>
				</tr>
				<?php }?>
			</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($activity['cms_node']) && $activity['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($activity['cms_group']) && $activity['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 />
			
			<?php
			if (isset($images)) {
			?>
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td colspan="<?php echo $images_per_row;?>" class="txt_title" align="right">
						<?php echo $lang['hdr_images'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="<?php echo $images_per_row;?>">
						<span class="txt_footer"><?php echo $lang['txt_images_help'];?></span><br />
					</td>
				</tr>
				<tr>
					<td valign="top" colspan="<?php echo $images_per_row;?>">
						<input type="radio" value="0" name="data[file_id]" checked="checked" />&nbsp;no image<br />
					</td>
				</tr>
				<tr>
					<td>
						<table border="0" cellspacing="0" cellpadding="2" class="table_nested">
							<tr>
								<?php
								$images_per_row = 6;
								$r = 0;
								foreach($images as $key => $i):
			
			
								$selected = "";
									if (isset($activity['file_id']) && $activity['file_id'] == $i['file_id']) {
									    $selected = "checked=\"checked\"";
										
									}
			
								?>
			
								<td valign="top">
									<img src="get_file.php?file=<?php echo $i['file']; ?>" border="0" class="picture" /><br />
									<input type="radio" value="<?php echo $i['file_id'];?>" name="data[file_id]" <?php echo $selected;?> /><br />
								</td>
			
								<?php
								$r++;
								if ($r == $images_per_row) {
								    echo "</tr><tr>";
									$r=0;
								}
			
								endforeach;
								if ($r != $images_per_row) {
									$r = $images_per_row-$r;
									print "<td colspan=" . $r . "><br /></td>";
								}
								?>
							</tr>
						</table>
					</td>
				</tr>
			</table>

			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<?php
			}
			?>
			
			<table border="0" cellspacing="0" cellpadding="4" width="100%" class="table_stnd">
				<tr>
					<td class="txt_title" align="right">
						<?php echo $lang['section_schedule'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php echo $lang['txt_activity_schedule'];?><br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="25" alt="" /><br />
					</td>
				</tr>
				<tr>
					<td valign="top" align="right">
						<input type="submit" name="edit_activity_schedule" class="formInput" value="<?php echo $lang['sub_schedule'];?>" /><br />
					</td>
				</tr>
			</table>
			<?php }?>
		</td>
	</tr>
</table>
</form>
