<?
/*
News Manager Plugin 1.0 (General Use)
Build Date 1.29.2003
*/
?>

					<table width="95%" cellpadding="0" cellspacing="0">
					
						<tr>
						
							<td width="50%" valign="top">
							
								<table width="95%">
									
									<script language="javascript">
						
										function vdelete() {
											var agree=confirm("Are you sure you want to delete the selected news item(s)?");
											if (agree) {
												document.news.action = "actions.php?a_mode=delete_news";
												document.news.submit();
											}
											else {
												false
											}
										}
														
									</script>
									
									<form name="news" method="post">
									<input type="hidden" name="return" value="<? echo "mgr.index.php?n=" . $n . "&p_mode=" . $p_mode; ?>">
									
									<tr bgcolor="#eeeeee">
									
										<td align="center" style="border-bottom: 1px solid #CCCBCB;border-right: 1px solid #CCCBCB"><font face="verdana" size="2" color="#8C8E91"><b>ID</b></td>
									
										<td align="left" style="border-bottom: 1px solid #CCCBCB;border-right: 1px solid #CCCBCB"><font face="verdana" size="2" color="#8C8E91"><b>Headline</b> <font face="verdana" size="1">(click to edit)</td>
										
										<td align="center" style="border-bottom: 1px solid #CCCBCB;border-right: 1px solid #CCCBCB"><font face="verdana" size="2" color="#8C8E91"><b>Date</b></td>
										
										<td align="center" style="border-bottom: 1px solid #CCCBCB;border-right: 1px solid #CCCBCB"><font face="verdana" size="2" color="#8C8E91"><b>Delete</b></td>
									
									</tr>
									
									<?									
									$news_result = mysql_query("SELECT * FROM news order by 'date' desc", $db);
									$rows = mysql_num_rows($news_result);
									while($news = mysql_fetch_object($news_result)){
										$posted = substr($news->date, 4, 2) . "/" . substr($news->date, 6, 2) . "/" . substr($news->date, 0, 4);
										if(strlen($news->title) > 30){
											$trim_title = substr($news->title, 0, 30) . "...";
										}
										else {
											$trim_title = $news->title;
										}
										
										$row_color++;	
										if ($row_color%2 == 0) {
											echo "<tr bgcolor=\"#ECF6F8\">";
										}
										else {
											echo "<tr>";
										}
									?>
									
										<td align="center"><font face="verdana" size="1" color="#A4A3A3"><? echo $news->news_id; ?></a></td>
									
										<td><font face="verdana" size="1">&nbsp; <a href="mgr.index.php?n=<? echo $n; ?>&p_mode=<? echo $p_mode; ?>&n_id=<? echo $news->news_id; ?>"><? echo $trim_title; ?></a></td>
										
										<td align="center"><font face="verdana" size="1"><? echo $posted; ?></td>
										
										<td align="center"><input type="checkbox" name="<? echo $news->news_id; ?>" value="1"></td>
										
									</tr>
									
									<?
									}
										if($rows == 0){
									?>
										<tr>
										
											<td colspan="3" align="center"><font face="verdana" size="2" color="#8C8E91">There are no News items at this time.</td>
											
										</tr>
									<?
										}
										else{
									?>
										<tr>
										
											<td></td>
										
											<td></td>
											
											<td></td>
											
											<td align="center"><? if($mgr_login_type == "demo"){ ?><img src="images/b.delete.gif" onclick="demo_mode()"><? } else { ?><a href="#" onclick="vdelete();"><img src="images/b.delete.gif" border="0"></a><? } ?></td>
											
										</tr>
									<?
										}
									?>
									
									<tr bgcolor="#eeeeee">
						
										<td align="left" colspan="4" style="border-bottom: 1px solid #CCCBCB;border-right: 1px solid #CCCBCB"><font face="verdana" size="1" color="#8C8E91"><b> &nbsp; </b></td>
										
									</tr>
									</form>
									
								</table>
							
							</td>
							
							<td width="50%" valign="top">
							
								<table width="95%">
					
									<?
									if($n_id != ""){
										
										$news_result = mysql_query("SELECT * FROM news where news_id = '$n_id'", $db);
										$news = mysql_fetch_object($news_result);
										
										$this_day = substr($news->date, 6, 2);
										$this_month = substr($news->date, 4, 2);
										$this_year = substr($news->date, 0, 4);
										echo "<form action=\"actions.php?a_mode=save_edit_news\" method=\"post\">";
										echo "<input type=\"hidden\" name=\"n_id\" value=\"" . $n_id . "\">";
										echo "<input type=\"hidden\" name=\"return\" value=\"mgr.index.php?n=" . $n . "&p_mode=" . $p_mode . "\">";
									}
									else {
										$this_day = date("d");
										$this_month = date("m");
										$this_year = date("Y");
										echo "<form action=\"actions.php?a_mode=save_new_news\" method=\"post\">";
										echo "<input type=\"hidden\" name=\"return\" value=\"mgr.index.php?n=" . $n . "&p_mode=" . $p_mode . "\">";
									}
									?>
								
									<tr bgcolor="#eeeeee">
									
										<td colspan="2" align="center" style="border-bottom: 1px solid #CCCBCB;border-right: 1px solid #CCCBCB"><font face="verdana" size="2" color="#8C8E91"><b><? if($n_id != ""){ echo "Edit"; } else { echo "Add"; } ?> News Item</b></td>
									
									</tr>
									
									<tr>
						
										<td align="right"><font face="verdana" size="2" color="#8C8E91"><b>Title</b></font></td>
										<td align="right"><input type="text" name="title" value="<? echo $news->title; ?>" style="font-size: 10; width: 300" maxlength="128"></td>
										
									</tr>
									
									<tr>
						
										<td align="right" valign="top"><font face="verdana" size="2" color="#8C8E91"><b>Article</b></font></td>
										<td align="right"><textarea name="article" style="width: 300;height:125;"><? echo $news->article; ?></textarea></td>
										
									</tr>
									
									<tr>
						
										<td align="right"><font face="verdana" size="2" color="#8C8E91"><b>Date</b></font></td>
										<td align="right">
										
										<select name="month" style="font-size: 10; width: 65">
											<?
											$month_x = 1;
											while($month_x <= 12){
												if(strlen($month_x) < 2){
													$month_x = "0" . $month_x;
												}
											?>
												<option value="<? echo $month_x; ?>" <? if($month_x == $this_month){ echo "selected"; } ?>><? echo $month_x; ?></option>
											<?
											$month_x++;
											}
											?>
										</select>
										
										<select name="day" style="font-size: 10; width: 65">
											<?
											$day_x = 1;
											while($day_x <= 31){
												if(strlen($day_x) < 2){
													$day_x = "0" . $day_x;
												}
											?>
												<option value="<? echo $day_x; ?>" <? if($day_x == $this_day){ echo "selected"; } ?>><? echo $day_x; ?></option>
											<?
											$day_x++;
											}
											?>
										</select>
										
										<select name="year" style="font-size: 10; width: 162">
											<?
											$year_x = 2003;
											while($year_x <= 2010){
											?>
												<option value="<? echo $year_x; ?>" <? if($year_x == $this_year){ echo "selected"; } ?>><? echo $year_x; ?></option>
											<?
											$year_x++;
											}
											?>
										</select>
									
										</td>
										
									</tr>
									
									<tr>
									
										<td colspan="2" align="right"><a href="mgr.index.php?n=<? echo $n; ?>&p_mode=<? echo $p_mode; ?>&n_id="><img src="images/b.cancel.gif" border="0"></a><? if($mgr_login_type == "demo"){ ?><img src="images/b.save.gif" onclick="demo_mode()"><? } else { ?><input type="image" src="images/b.save.gif"><? } ?></td>
										
									</tr>
									</form>
									
									<tr bgcolor="#eeeeee">
						
										<td align="right" colspan="2" style="border-bottom: 1px solid #CCCBCB;border-right: 1px solid #CCCBCB"><font face="verdana" size="1" color="#B3B3B3">News Plugin &nbsp; </td>
										
									</tr>				
									
								</table>							
							
							</td>
							
						</tr>
						
					</table>