File: /home/awaldron/www/archive/demo/event_new_su.php
<?php
session_start();
include("_functions.php");
dbconnect();
if (isset($_GET["del"])) {
quickUPDATE("DELETE FROM tbl_event_su WHERE esu_id=".$_GET["del"]);
}
if (isset($_POST["adddate"])) {
extract($_POST);
if (($startampm == "pm") && ($starthr < 12)) $starthr += 12;
if (($endampm == "pm") && ($endhr < 12)) $endhr += 12;
if (($startampm == "am") && ($starthr == 12)) $starthr = 0;
$start = $newyear.($newmon<10?"0".$newmon:$newmon).($newday<10?"0".$newday:$newday).($starthr<10?"0".$starthr:$starthr).($startmin<10?"0".$startmin:$startmin)."00";
$end = $newyear.($newmon<10?"0".$newmon:$newmon).($newday<10?"0".$newday:$newday).($endhr<10?"0".$endhr:$endhr).($endmin<10?"0".$endmin:$endmin)."00";
$ins = "INSERT INTO tbl_event_su (event_id,esu_title,esu_desc,esu_location,esu_size,esu_start,esu_end) VALUES (";
$ins .= $event_id.",";
$ins .= "'".$esu_title."',";
$ins .= "'".$message."',";
$ins .= "'".$esu_location."',";
$ins .= $esu_size.",";
$ins .= "'".$start."',";
$ins .= "'".$end."')";
$res = quickUPDATE($ins);
if ($res === FALSE) $error = error("There was an error while attempting to insert this event time.");
}
if (isset($_POST["editdate"])) {
extract($_POST);
if (($startampm == "pm") && ($starthr < 12)) $starthr += 12;
if (($endampm == "pm") && ($endhr < 12)) $endhr += 12;
if (($startampm == "am") && ($starthr == 12)) $starthr = 0;
$start = $newyear.($newmon<10?"0".$newmon:$newmon).($newday<10?"0".$newday:$newday).($starthr<10?"0".$starthr:$starthr).($startmin<10?"0".$startmin:$startmin)."00";
$end = $newyear.($newmon<10?"0".$newmon:$newmon).($newday<10?"0".$newday:$newday).($endhr<10?"0".$endhr:$endhr).($endmin<10?"0".$endmin:$endmin)."00";
$upd = "UPDATE tbl_event_su SET ";
$upd .= "esu_title='".$esu_title."',";
$upd .= "esu_desc='".$message."',";
$upd .= "esu_location='".$esu_location."',";
$upd .= "esu_size=".$esu_size.",";
$upd .= "esu_start='".$start."',";
$upd .= "esu_end='".$end."' ";
$upd .= "WHERE esu_id=".$esu_id;
$res = quickUPDATE($upd);
if ($res === FALSE) $error = error("There was an error while attempting to edit this event time.");
}
$sql = "SELECT * FROM tbl_event WHERE event_id=".$_GET["id"];
$res = mysql_query($sql);
extract(mysql_fetch_array($res));
$bbjava = true;
$page_title = "Add Dates to \"".$event_title."\"";;
$GLOBALS["ext_page"] = "New Event: Add Dates / Times"; // SET FAUX PAGE NAME
$_GET["p"] = 1; // SET FAUX PARENT ID
$lnav_mods = get_layout($_GET["p"],1);
$rnav_mods = get_layout($_GET["p"],3);
include("_pagestart.php");
echo "<div class=\"headline\">".$page_title."</div>\n";
echo "<div class=\"pagebody\">\n";
if (authorize($event_owner)) {
if ($event_word == 1) {
$word = "class";
$maxnum = "Seats Available";
} else if ($event_word == 2) {
$word = "event";
$maxnum = "Max # Participants";
}
$sql = "SELECT * FROM tbl_event_su WHERE event_id=".$_GET["id"]." ORDER BY esu_start ASC";
$res = mysql_query($sql);
$times = "<br><br><table border=0 cellspacing=1 cellpadding=4 bgcolor=\"#C0C0C0\">\n";
$times .= "<tr id=\"head-row\"><td>Day, Date</td><td>Time</td><td>".ucfirst($word)."</td><td>Description</td><td>Location</td><td>".$maxnum."</td><td>Actions</td></tr>\n";
if (mysql_num_rows($res) < 1) {
$times .= "<tr id=\"dat-input\"><td colspan=6>No times have been scheduled for this ".$word."</td></tr>\n";
} else for ($i=0; $row = mysql_fetch_array($res); $i++) {
$times .= "<tr id=\"".($i%2==0?"dat-input":"dat-field")."\"".($_GET["edit"]==$row["esu_id"]?" style=\"background:#D5EFFF\"":"").">\n";
$times .= "<td>".date("D, n/j",$row["esu_start"])."</td>\n";
$times .= "<td>".date("h:m a",$row["esu_start"])." - ".date("h:m a",$row["esu_end"])."</td>\n";
$times .= "<td>".$row["esu_title"]."</td>\n";
$times .= "<td>".(zero($row["esu_desc"])?"None":"Click Edit to View")."</td>\n";
$times .= "<td>".$row["esu_location"]."</td>\n";
$times .= "<td>".$row["esu_size"]."</td>\n";
$times .= "<td><a href=\"".(isset($_GET["edit"])?substr(self(),0,strrpos(self(),"&")):self())."&edit=".$row["esu_id"]."\">Edit</a> | <a href=\"javascript:deleteEvent(".$row["event_id"].",".$row["esu_id"].",'su');\">Delete</a></td>\n";
$times .= "</tr>\n";
if (isset($_GET["edit"])) {
if ($_GET["edit"] == $row["esu_id"]) {
$maxtime = $row["esu_start"];
$maxtime2 = $row["esu_end"];
$maxtitle = $row["esu_title"];
$maxdesc = $row["esu_desc"];
$maxloc = $row["esu_location"];
$maxsize = $row["esu_size"];
}
} else {
$maxtime = $row["esu_start"];
$maxtime2 = $row["esu_end"];
$maxtitle = ""; //$row["esu_title"];
$maxdesc = ""; //$row["esu_desc"];
$maxloc = ""; //$row["esu_location"];
$maxsize = ""; //$row["esu_size"];
}
}
$times .= "</table>\n";
// FORM TO ADD ANOTHER EVENT TIME
$month = array("","January","February","March","April","May","June","July","August","September","October","November","December");
$n = getdate($maxtime?$maxtime:time());
$o = getdate($maxtime2?$maxtime2:time());
echo "<P>".$error;
echo "<form action=\"".(isset($_GET["edit"])?substr(self(),0,strrpos(self(),"&")):self())."\" method=\"post\" name=\"newtime\">\n";
echo "<input type=\"hidden\" name=\"event_id\" value=\"".$_GET["id"]."\">\n";
if (isset($_GET["edit"])) echo "<input type=\"hidden\" name=\"esu_id\" value=\"".$_GET["edit"]."\">\n";
echo "<P><table border=0 cellspacing=1 cellpadding=4 bgcolor=\"#C0C0C0\">\n";
if (isset($_GET["edit"])) echo "<tr><td id=\"head-row\" style=\"background:#D5EFFF\" colspan=2><b>Editing ".$word." \"".$maxtitle."\"</b></td></tr>\n";
else echo "<tr><td id=\"head-row\" style=\"background:#B9EBB3\" colspan=2><b>Add a new time for this ".$word.":</b></td></tr>\n";
echo "<tr><td id=\"dat-field\">".ucfirst($word)." Title</td><td id=\"dat-input\"><input type=\"text\" name=\"esu_title\" value=\"".$maxtitle."\" size=60></td></tr>\n";
echo "<tr><td id=\"dat-field\" valign=\"top\">".ucfirst($word)." Description</td><td id=\"dat-input\">".ins_textarea(stripslashes($maxdesc),0,0,0,0,625,175)."</td></tr>\n";
echo "<tr><td id=\"dat-field\">".ucfirst($word)." Date</td><td id=\"dat-input\">";
echo "<SELECT name=\"newmon\">\n";
echo "<option></option>\n";
for ($i=1; $i <= 12; $i++) {
$val = ($i<10?"0".$i:$i);
echo "<option value=\"".$i."\"".($i==$n["mon"]?" SELECTED":"").">".$month[$i]."</option>\n";
}
echo "</select>\n";
echo "<SELECT name=\"newday\">\n";
echo "<option></option>\n";
for ($j=1; $j <= 31; $j++) echo "<option value=\"".$j."\"".($j==$n["mday"]?" SELECTED":"").">".$j."</option>\n";
echo "</select>\n";
echo "<SELECT name=\"newyear\">\n";
echo "<option></option>\n";
for ($k=(date("Y")-5); $k <= (date("Y")+5); $k++) echo "<option value=\"".$k."\"".($k==$n["year"]?" SELECTED":"").">".$k."</option>\n";
echo "</select>\n";
echo "</td></tr>\n";
echo "<tr><td id=\"dat-field\">Start Time</td><td id=\"dat-input\">";
echo "<SELECT name=\"starthr\">\n";
echo "<option></option>\n";
for ($l=1; $l <= 12; $l++) echo "<option value=\"".$l."\"".($l==($n["hours"]%12)||($n["hours"]==12)?" SELECTED":"").">".$l."</option>\n";
echo "</select>:";
echo "<SELECT name=\"startmin\">\n";
echo "<option></option>\n";
for ($m=0; $m < 60; $m+=15) echo "<option value=\"".$m."\"".($n["minutes"]>=$m&&$n["minutes"]<($m+15)?" SELECTED":"").">".($m==0?"00":$m)."</option>\n";
echo "</select>\n";
echo "<SELECT name=\"startampm\">\n";
echo "<option></option>\n";
echo "<option value=\"am\"".($n["hours"]<12?" SELECTED":"").">am</option>\n";
echo "<option value=\"pm\"".($n["hours"]>=12?" SELECTED":"").">pm</option>\n";
echo "</td></tr>\n";
echo "<tr><td id=\"dat-field\">End Time</td><td id=\"dat-input\">";
echo "<SELECT name=\"endhr\">\n";
echo "<option></option>\n";
for ($l=1; $l <= 12; $l++) echo "<option value=\"".$l."\"".($l==($o["hours"]%12)||($o["hours"]==12)?" SELECTED":"").">".$l."</option>\n";
echo "</select>:";
echo "<SELECT name=\"endmin\">\n";
echo "<option></option>\n";
for ($m=0; $m < 60; $m+=15) echo "<option value=\"".$m."\"".($o["minutes"]>=$m&&$o["minutes"]<($m+15)?" SELECTED":"").">".($m==0?"00":$m)."</option>\n";
echo "</select>\n";
echo "<SELECT name=\"endampm\">\n";
echo "<option></option>\n";
echo "<option value=\"am\"".($o["hours"]<12?" SELECTED":"").">am</option>\n";
echo "<option value=\"pm\"".($o["hours"]>=12?" SELECTED":"").">pm</option>\n";
echo "</td></tr>\n";
echo "<tr><td id=\"dat-field\">".$maxnum."</td><td id=\"dat-input\"><input type=\"text\" name=\"esu_size\" value=\"".$maxsize."\" size=5></td></tr>\n";
echo "<tr><td id=\"dat-field\">".ucfirst($word)." Location</td><td id=\"dat-input\"><input type=\"text\" name=\"esu_location\" value=\"".$maxloc."\" size=15></td></tr>\n";
if (isset($_GET["edit"])) echo "<tr><td bgcolor=\"#F0F0F0\" colspan=2><input type=\"submit\" name=\"editdate\" value=\"Edit This ".ucfirst($word)." Time\" class=\"btn\"> <input type=\"button\" onClick=\"location.href='/event_new_su.php?id=".$_GET["id"]."'\" value=\"Cancel Edit\" class=\"btn\"></td></tr>\n";
else echo "<tr><td bgcolor=\"#F0F0F0\" colspan=2><input type=\"submit\" name=\"adddate\" value=\"Add New ".ucfirst($word)." Time\" class=\"btn\"></td></tr>\n";
echo "</table>\n";
echo "</form>\n";
echo $times;
echo "<P><a href=\"event_new_su.php?id=".$_GET["id"]."\">Refresh This Page</a> | <a href=\"/eventreg_su.php?id=".$_GET["id"]."\">Go To Sign-Up Page</a></center>\n";
} else {
echo "<br><br><br><center>".error("You do not have the proper permissions to edit this information.")."<br><br><br></center>\n";
}
echo "</div>\n";
echo "<br><br><br><br><div class=\"pagefoot\" style=\"border-width:1px 0px 0px 0px;\"><div style=\"float:right\">Last Updated: ".date("F j, Y")." by <a href=\"/profile.php?u=awaldron\">awaldron</a></div></div>\n";
include("_pageend.php");
?>