<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	// Edit Existing Calendar Event
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_calendar.gif" width="28" height="18"> '.$MsgText[1][82];
	$BrowserTitle = $MsgText[1][82];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > <a href="'.$MainURL.'/admin/calendar.html">'.$MsgText[1][2].'</a> > '.$MsgText[1][82];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[100] == 'y') {
		
			$query55 = "select * from `".$Settings['DBPrefix']."core-Settings` where Name='TimezoneOffset' limit 1";
			$result55 = mysql_query($query55) or die (mysql_error());
			$row55 = mysql_fetch_array($result55);
			if ($row55['Value'] != '') {		
				$TZO = (($row55['Value']+5)*3600);
			}
		
	
												
			$query55 = "select * from `".$Settings['DBPrefix']."cl-Events` where RecordNumber='".$Arguments3."' and MinLevel<='".$UserLevel."' and MinEditLevel<='".$UserLevel."' limit 1";
			$result55 = mysql_query($query55) or die (mysql_error());
			
			if (mysql_num_rows($result55) > 0) {
				
				$row55 = mysql_fetch_array($result55);
				
				$MinLevelSelected[$row55['MinLevel']] = ' selected';
				
				$query = "select Level,Description from `".$Settings['DBPrefix']."core-Permissions` where Level<=".$UserLevel;
		   		$result = mysql_query($query) or die (mysql_error());
				while ($row = mysql_fetch_array($result)) {
					$LevelDescriptions[$row['Level']] = $row['Description'];
				}
		
				$PermissionsDropdown = '<option value="0" selected> 0 - '.$MsgText[0][162].'</option>';
				for ($i = 1; $i <= $UserLevel; $i++) {
					if ($LevelDescriptions[$i] != '') {
						$PermissionsDropdown .= '<option value="'.$i.'"'.$MinLevelSelected[$i].'> '.$i.' - '.$LevelDescriptions[$i].'</option>';
					}
					else {
						$PermissionsDropdown .= '<option value="'.$i.'"'.$MinLevelSelected[$i].'> '.$i.'</option>';
					}
				}
				
				$MinEditLevelSelected[$row55['MinEditLevel']] = ' selected';
				
				$PermissionsDropdown2 = '<option value="0"'.$MinEditLevelSelected[0].'> 0 - '.$MsgText[0][162].'</option>';
				for ($i = 1; $i <= $UserLevel; $i++) {
					if ($LevelDescriptions[$i] != '') {
						$PermissionsDropdown2 .= '<option value="'.$i.'"'.$MinEditLevelSelected[$i].'> '.$i.' - '.$LevelDescriptions[$i].'</option>';
					}
					else {
						$PermissionsDropdown2 .= '<option value="'.$i.'"'.$MinEditLevelSelected[$i].'> '.$i.'</option>';
					}
				}
				
				
				$query2 = "select * from `".$Settings['DBPrefix']."cl-EventDates` where EventID='".$row55['RecordNumber']."' order by DateCode asc";
				$result2 = mysql_query($query2) or die (mysql_error());
				while ($row2 = mysql_fetch_array($result2)) {
				
					if ($DatesString != '') {
						$DatesString .= ', ';
					}
					$DatePieces = getdate($row2['DateCode']-$TZO);
					$DatesString .=  $DatePieces['mon'] . '/' . $DatePieces['mday'] . '/' . $DatePieces['year'];
				
				}
				
				
				
				$TimePrint = '';
				
				
				if ($row55['StartTime'] >= 0) {
					$UseStartTimeChecked = ' checked';
					
				
					$Hours = 0;
					$Minutes = 0;
					
					$Seconds = $row55['StartTime'];
					while ($Seconds >= 3600) {
						$Seconds = $Seconds - 3600;
						$Hours++;					
					}
					while ($Seconds >= 60) {
						$Seconds = $Seconds - 60;
						$Minutes++;					
					}
					
					
					if ($Hours >= 12) {
						$Hours -= 12;
						$StartTimeAmPmSelected['pm'] = ' selected';
					}

					$StartTimeHourSelected[$Hours] = ' selected';
					$StartTimeMinuteSelected[$Minutes] = ' selected';
					

					//if ($row55['EndTime'] >= 0 && $row55['EndTime'] > $row55['StartTime']) {
					if ($row55['EndTime'] >= 0) {
						
						$UseEndTimeChecked = ' checked';
						
						$Hours = 0;
						$Minutes = 0;
					
						$Seconds = $row55['EndTime'];
						while ($Seconds >= 3600) {
							$Seconds = $Seconds - 3600;
							$Hours++;					
						}
						while ($Seconds >= 60) {
							$Seconds = $Seconds - 60;
							$Minutes++;					
						}
						
						
						if ($Hours >= 12) {
							$Hours -= 12;
							$EndTimeAmPmSelected['pm'] = ' selected';
						}

						$EndTimeHourSelected[$Hours] = ' selected';
						$EndTimeMinuteSelected[$Minutes] = ' selected';
							
					}
								
				}
				else {
					$TimePrint = '';
				}
				
				
				
				if ($row55['Username'] == '') {
					$HidePosterChecked = ' checked';
				}
				
				$EventTypeSelected[$row55['EventType']] = ' selected';
				
				
				$DateBoxesYearSelected[date('Y',GetTimestamp())] = ' selected';
				
				$PageContents .= '<table border="0" cellpadding="3" cellspacing="0"><form action="'.$MainURL.'/admin/calendar-save" method="post" name="EditEvent"><input type="hidden" name="RecordNumber" value="'.$row55['RecordNumber'].'">
       
	<tr>
      <td width="120"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[1][8].':</b> </td>
      <td><input type="text" name="Title" size="35" maxlength="255" value="'.str_replace('"','&#34;',$row55['Title']).'"></td>
    </tr>
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[1][12].':</b> </td>
      <td><textarea name="Text" cols="40" rows="6" wrap="virtual">'.str_replace('<','&lt;',$row55['Text']).'</textarea></td>
    </tr>
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="8" alt=""></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="8" alt=""></td>
    </tr>
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[1][13].':</b> </td>
      <td><input type="checkbox" name="UseStartTime" value="y"'.$UseStartTimeChecked.'>&nbsp; <select name="StartTimeHour">
	  		<option value="00"'.$StartTimeHourSelected[0].'> 12</option>
			<option value="01"'.$StartTimeHourSelected[1].'> 01</option>
			<option value="02"'.$StartTimeHourSelected[2].'> 02</option>
			<option value="03"'.$StartTimeHourSelected[3].'> 03</option>
			<option value="04"'.$StartTimeHourSelected[4].'> 04</option>
			<option value="05"'.$StartTimeHourSelected[5].'> 05</option>
			<option value="06"'.$StartTimeHourSelected[6].'> 06</option>
			<option value="07"'.$StartTimeHourSelected[7].'> 07</option>
			<option value="08"'.$StartTimeHourSelected[8].'> 08</option>
			<option value="09"'.$StartTimeHourSelected[9].'> 09</option>
			<option value="10"'.$StartTimeHourSelected[10].'> 10</option>
			<option value="11"'.$StartTimeHourSelected[11].'> 11</option>
		</select> <select name="StartTimeMinute">
			<option value="00"'.$StartTimeMinuteSelected[0].'> 00</option>
			<option value="05"'.$StartTimeMinuteSelected[5].'> 05</option>
			<option value="10"'.$StartTimeMinuteSelected[10].'> 10</option>
			<option value="15"'.$StartTimeMinuteSelected[15].'> 15</option>
			<option value="20"'.$StartTimeMinuteSelected[20].'> 20</option>
			<option value="25"'.$StartTimeMinuteSelected[25].'> 25</option>
			<option value="30"'.$StartTimeMinuteSelected[30].'> 30</option>
			<option value="35"'.$StartTimeMinuteSelected[35].'> 35</option>
			<option value="40"'.$StartTimeMinuteSelected[40].'> 40</option>
			<option value="45"'.$StartTimeMinuteSelected[45].'> 45</option>
			<option value="50"'.$StartTimeMinuteSelected[50].'> 50</option>
			<option value="55"'.$StartTimeMinuteSelected[55].'> 55</option>
		</select> <select name="StartTimeAmPm">
			<option value="am"'.$StartTimeAmPmSelected['am'].'> AM</option>
			<option value="pm"'.$StartTimeAmPmSelected['pm'].'> PM</option>
		</select></td>
    </tr>
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[1][14].':</b> </td>
      <td><input type="checkbox" name="UseEndTime" value="y"'.$UseEndTimeChecked.'>&nbsp; <select name="EndTimeHour">
	  		<option value="00"'.$EndTimeHourSelected[0].'> 12</option>
			<option value="01"'.$EndTimeHourSelected[1].'> 01</option>
			<option value="02"'.$EndTimeHourSelected[2].'> 02</option>
			<option value="03"'.$EndTimeHourSelected[3].'> 03</option>
			<option value="04"'.$EndTimeHourSelected[4].'> 04</option>
			<option value="05"'.$EndTimeHourSelected[5].'> 05</option>
			<option value="06"'.$EndTimeHourSelected[6].'> 06</option>
			<option value="07"'.$EndTimeHourSelected[7].'> 07</option>
			<option value="08"'.$EndTimeHourSelected[8].'> 08</option>
			<option value="09"'.$EndTimeHourSelected[9].'> 09</option>
			<option value="10"'.$EndTimeHourSelected[10].'> 10</option>
			<option value="11"'.$EndTimeHourSelected[11].'> 11</option>
		</select> <select name="EndTimeMinute">
			<option value="00"'.$EndTimeMinuteSelected[0].'> 00</option>
			<option value="05"'.$EndTimeMinuteSelected[5].'> 05</option>
			<option value="10"'.$EndTimeMinuteSelected[10].'> 10</option>
			<option value="15"'.$EndTimeMinuteSelected[15].'> 15</option>
			<option value="20"'.$EndTimeMinuteSelected[20].'> 20</option>
			<option value="25"'.$EndTimeMinuteSelected[25].'> 25</option>
			<option value="30"'.$EndTimeMinuteSelected[30].'> 30</option>
			<option value="35"'.$EndTimeMinuteSelected[35].'> 35</option>
			<option value="40"'.$EndTimeMinuteSelected[40].'> 40</option>
			<option value="45"'.$EndTimeMinuteSelected[45].'> 45</option>
			<option value="50"'.$EndTimeMinuteSelected[50].'> 50</option>
			<option value="55"'.$EndTimeMinuteSelected[55].'> 55</option>
		</select> <select name="EndTimeAmPm">
			<option value="am"'.$EndTimeAmPmSelected['am'].'> AM</option>
			<option value="pm"'.$EndTimeAmPmSelected['pm'].'> PM</option>
		</select></td>
    </tr>
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="8" alt=""></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="8" alt=""></td>
    </tr>
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[1][15].':</b> </td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'">	<input type="checkbox" name="HidePoster" value="yes"'.$HidePosterChecked.'> '.$MsgText[0][118] .'</td>
    </tr>
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="12" alt=""></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="12" alt=""></td>
    </tr>
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[1][16].':</b> </td>
      <td><select name="Month">
			<option value="01"> 01 - '.$MsgText[0][34].'</option>
			<option value="02"> 02 - '.$MsgText[0][35].'</option>
			<option value="03"> 03 - '.$MsgText[0][36].'</option>
			<option value="04"> 04 - '.$MsgText[0][37].'</option>
			<option value="05"> 05 - '.$MsgText[0][38].'</option>
			<option value="06"> 06 - '.$MsgText[0][39].'</option>
			<option value="07"> 07 - '.$MsgText[0][40].'</option>
			<option value="08"> 08 - '.$MsgText[0][41].'</option>
			<option value="09"> 09 - '.$MsgText[0][42].'</option>
			<option value="10"> 10 - '.$MsgText[0][43].'</option>
			<option value="11"> 11 - '.$MsgText[0][44].'</option>
			<option value="12"> 12 - '.$MsgText[0][45].'</option>
		</select> <select name="Day">
			<option value="01"> 01</option>
			<option value="02"> 02</option>
			<option value="03"> 03</option>
			<option value="04"> 04</option>
			<option value="05"> 05</option>
			<option value="06"> 06</option>
			<option value="07"> 07</option>
			<option value="08"> 08</option>
			<option value="09"> 09</option>
			<option value="10"> 10</option>
			<option value="11"> 11</option>
			<option value="12"> 12</option>
			<option value="13"> 13</option>
			<option value="14"> 14</option>
			<option value="15"> 15</option>
			<option value="16"> 16</option>
			<option value="17"> 17</option>
			<option value="18"> 18</option>
			<option value="19"> 19</option>
			<option value="20"> 20</option>
			<option value="21"> 21</option>
			<option value="22"> 22</option>
			<option value="23"> 23</option>
			<option value="24"> 24</option>
			<option value="25"> 25</option>
			<option value="26"> 26</option>
			<option value="27"> 27</option>
			<option value="28"> 28</option>
			<option value="29"> 29</option>
			<option value="30"> 30</option>
			<option value="31"> 31</option>
		</select> <select name="Year">
			<option value="2004"'.$DateBoxesYearSelected[2004].'> 2004</option>
			<option value="2005"'.$DateBoxesYearSelected[2005].'> 2005</option>
			<option value="2006"'.$DateBoxesYearSelected[2006].'> 2006</option>
			<option value="2007"'.$DateBoxesYearSelected[2007].'> 2007</option>
			<option value="2008"'.$DateBoxesYearSelected[2008].'> 2008</option>
			<option value="2009"'.$DateBoxesYearSelected[2009].'> 2009</option>
			<option value="2010"'.$DateBoxesYearSelected[2010].'> 2010</option>
			<option value="2011"'.$DateBoxesYearSelected[2011].'> 2011</option>
			<option value="2012"'.$DateBoxesYearSelected[2012].'> 2012</option>
			<option value="2013"'.$DateBoxesYearSelected[2013].'> 2013</option>
			<option value="2014"'.$DateBoxesYearSelected[2014].'> 2014</option>
			<option value="2015"'.$DateBoxesYearSelected[2015].'> 2015</option>
			<option value="2016"'.$DateBoxesYearSelected[2016].'> 2016</option>
			<option value="2017"'.$DateBoxesYearSelected[2017].'> 2017</option>
			<option value="2018"'.$DateBoxesYearSelected[2018].'> 2018</option>
			<option value="2019"'.$DateBoxesYearSelected[2019].'> 2019</option>
			<option value="2020"'.$DateBoxesYearSelected[2020].'> 2020</option>
		</select>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="'.$MsgText[1][16].'" onClick="if ( document.forms[\'EditEvent\'].elements[\'Dates\'].value == \'\') { document.forms[\'EditEvent\'].elements[\'Dates\'].value = document.forms[\'EditEvent\'].elements[\'Month\'].value + \'/\' + document.forms[\'EditEvent\'].elements[\'Day\'].value + \'/\' + document.forms[\'EditEvent\'].elements[\'Year\'].value; } else { document.forms[\'EditEvent\'].elements[\'Dates\'].value = document.forms[\'EditEvent\'].elements[\'Dates\'].value + \', \' + document.forms[\'EditEvent\'].elements[\'Month\'].value + \'/\' + document.forms[\'EditEvent\'].elements[\'Day\'].value + \'/\' + document.forms[\'EditEvent\'].elements[\'Year\'].value; }"></td>
    </tr>
	<tr>
      <td valign="top"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[1][17].':</b> </td>
      <td><input type="text" name="Dates" size="45" value="'.$DatesString.'"><br><font face="'.$FontFace.'" size="1">'.$MsgText[1][18].'<br></font></td>
    </tr>
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="8" alt=""></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="8" alt=""></td>
    </tr>
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[1][19].':</b> </td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><select name="EventType">
	<option value="1"'.$EventTypeSelected[1].'> '.$MsgText[1][20].'</option>
	<option value="2"'.$EventTypeSelected[2].'> '.$MsgText[1][21].'</option>
</select>
</td>
    </tr>
	<tr>
      <td valign="top"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[1][22].':</b></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><input type="text" name="Priority" size="3" value="'.$row55['Priority'].'"><br><font face="'.$FontFace.'" size="1">'.$MsgText[1][23].'</font></td>
    </tr>
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="8" alt=""></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="8" alt=""></td>
    </tr>
	<tr>
      <td valign="top"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[2][16].':</b></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><select name="MinLevel">'.$PermissionsDropdown.'</select></td>
    </tr>
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="8" alt=""></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="8" alt=""></td>
    </tr>
	<tr>
      <td valign="top"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][542].':</b></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><select name="MinEditLevel">'.$PermissionsDropdown2.'</select></td>
    </tr>
	
	
	<tr>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="22" alt=""></td>
      <td><font face="'.$FontFace.'" size="'.$FontSize.'"><img src="'.$ImagesURL.'/admin/spacer.gif" border="0" width="1" height="22" alt=""></td>
    </tr>

	<input type="hidden" name="Link" value="'.$row55['Link'].'">

	
	<tr>
	<td colspan="2"><div align="center"><input type="submit" value="'.$MsgText[0][123].'"></div></td>
	</tr>
			</table></form>';
				
		
			}
			else {
				$PageContents .= '<br>['.$MsgText[1][81].']<br>';
			}
	
				
	
	
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}
	

	// ========================================================================================




?>
