File: //home/awaldron/public_html/archive/demo/event_new.php
<?php
session_start();
include("_functions.php");
dbconnect();
//
if ($_GET["type"] == "su") $type = "Event Sign-Up Form";
else if ($_GET["type"] == "is") $type = "General Interest Form";
else if ($_GET["type"] == "rs") $type = "Event Reservation Form";
//
$bbjava = true;
if (isset($_GET["id"])) $page_title = "Editing ".$type;
else $page_title = "Create New ".$type;
$GLOBALS["ext_page"] = $page_title; // 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);
//
if (isset($_POST["insertevent"])) {
$insert = TRUE;
$errors = "<span class=\"error\">";
if (zero(trim($_POST["event_title"]))) { $insert = FALSE; $errors .= "<li> Please enter a valid Event Title.<br>"; }
if (zero(trim($_POST["message"]))) { $insert = FALSE; $errors .= "<li> Please enter a valid Event Description.<br>"; }
if (!preg_match("/[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]/si",$_POST["event_deadline"])) {
if (!isset($_POST["nodeadline"])) { $insert = FALSE; $errors .= "<li> Please enter a valid date for Event Deadline.<br>"; }
}
$errors .= "</span>\n";
if ($insert) {
$ins = "INSERT INTO tbl_event (event_title,event_desc,event_owner,event_word,event_active,event_parent,event_deadline,event_type,event_emponly) VALUES (";
$ins .= "'".$_POST["event_title"]."',";
$ins .= "'".$_POST["message"]."',";
$ins .= "'".$_POST["event_owner"]."',";
//$ins .= $_POST["event_notify"].",";
$ins .= $_POST["event_word"].",";
$ins .= $_POST["event_active"].",";
$ins .= $_POST["event_parent"].",";
if (!preg_match("/[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]/si",$_POST["event_deadline"])) $ins .= "'0',";
else if ($_POST["nodeadline"]) $ins .= "'0',";
else $ins .= date_tstounix(substr($_POST["event_deadline"],6,4).substr($_POST["event_deadline"],0,2).substr($_POST["event_deadline"],3,2)."235959").",";
$ins .= "'".$_POST["event_type"]."',";
$ins .= $_POST["event_emponly"]." ";
$ins .= ")";
//
// PRINT SQL **TEST**
//echo $ins;
$res = quickUPDATE($ins);
if ($res !== FALSE) {
// GO TO NEXT PAGE
$maxid = quickSQL("SELECT MAX(event_id) FROM tbl_event");
header("Location: /event_new_".$_POST["event_type"].".php?id=".$maxid);
//echo "<pre>"; print_r($_POST); echo "</pre>";
} else echo "<pre>"; print_r($_POST); echo "\n\n".$ins."\n\n".mysql_error()."</pre>";
}
}
//
if (isset($_POST["editevent"])) {
$update = TRUE;
$errors = "<span class=\"error\">";
if (zero(trim($_POST["event_title"]))) { $update = FALSE; $errors .= "<li> Please enter a valid Event Title.<br>"; }
if (zero(trim($_POST["message"]))) { $update = FALSE; $errors .= "<li> Please enter a valid Event Description.<br>"; }
if (!preg_match("/[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]/",$_POST["event_deadline"])) {
if (!isset($_POST["nodeadline"])) { $update = FALSE; $errors .= "<li> Please enter a valid date for Event Deadline.<br>"; }
}
$errors .= "</span>\n";
if ($update) {
$upd = "UPDATE tbl_event SET ";
$upd .= "event_title='".$_POST["event_title"]."',";
$upd .= "event_desc='".$_POST["message"]."',";
$upd .= "event_owner='".$_POST["event_owner"]."',";
//$upd .= "event_notify=".$_POST["event_notify"].",";
$upd .= "event_word=".$_POST["event_word"].",";
$upd .= "event_active=".$_POST["event_active"].",";
$upd .= "event_parent=".$_POST["event_parent"].",";
if (isset($_POST["nodeadline"])) $upd .= "event_deadline='0',";
else $upd .= date_tstounix(substr($_POST["event_deadline"],6,4).substr($_POST["event_deadline"],0,2).substr($_POST["event_deadline"],3,2)."235959").",";
$upd .= "event_type='".$_POST["event_type"]."',";
$upd .= "event_emponly=".$_POST["event_emponly"]." ";
$upd .= "WHERE event_id=".$_GET["id"];
//
// PRINT SQL **TEST**
//echo $ins;
$res = quickUPDATE($upd);
if ($res !== FALSE) {
// GO BACK TO SIGNUP PABE
//$maxid = quickSQL("SELECT MAX(event_id) FROM tbl_event");
header("Location: /eventreg_".$_POST["event_type"].".php?id=".$_GET["id"]);
//echo "<pre>"; print_r($_POST); echo "</pre>";
//echo "<br>".$upd;
}
}
}
//
include("_pagestart.php");
echo "<div class=\"headline\">".$page_title."</div>\n";
echo "<div class=\"pagebody\">\n";
//
if (isset($_GET["type"])) {
$edit = FALSE;
if (isset($_GET["id"])) {
$edit = TRUE;
$sql = "SELECT * FROM tbl_event WHERE event_id=".$_GET["id"];
$res = mysql_query($sql);
extract(mysql_fetch_array($res));
if (authorize($event_owner)) {
echo "<P>".$errors;
echo "<P><table border=0 cellspacing=1 cellpadding=4 bgcolor=\"#C0C0C0\">\n";
echo "<form action=\"".self()."\" method=\"post\" name=\"post\">\n";
echo "<input type=\"hidden\" name=\"event_owner\" value=\"".$event_owner."\">\n";
echo "<input type=\"hidden\" name=\"event_type\" value=\"".$_GET["type"]."\">\n";
echo "<tr><td id=\"dat-field\">Event Owner</td><td id=\"dat-input\">".get_user($event_owner,"fullname2")."</td></tr>\n";
echo "<tr><td id=\"dat-field\">Form Type</td><td id=\"dat-input\">".$type."</td></tr>\n";
echo "<tr><td id=\"dat-field\">Event Type</td><td id=\"dat-input\"><SELECT name=\"event_word\"><option value=\"1\"".($event_word==1?" SELECTED":"").">Educational Course</option><option value=\"2\"".($event_word==2?" SELECTED":"").">Employee Event</option></SELECT></td></tr>\n";
echo "<tr><td id=\"dat-field\">Event Title</td><td id=\"dat-input\"><input type=\"text\" name=\"event_title\" value=\"".stripslashes($event_title)."\" size=90></td></tr>\n";
echo "<tr><td id=\"dat-field\" valign=\"top\">Event Description</td><td id=\"dat-input\">".ins_textarea(stripslashes($event_desc),0,0,0,0,625,175)."</td></tr>\n";
echo "<tr><td id=\"dat-field\">Event Active?</td><td id=\"dat-input\"><SELECT name=\"event_active\"><option value=\"1\"".($event_active==1?" SELECTED":"").">Yes</option><option value=\"0\"".($event_active==0?" SELECTED":"").">No</option></SELECT></td></tr>\n";
echo "<tr><td id=\"dat-field\">Registration Deadline</td><td id=\"dat-input\"><input type=\"text\" name=\"event_deadline\" value=\"".(zero($event_deadline)?"mm/dd/yyyy":date("m/d/Y",$event_deadline))."\" size=15> <input type=\"checkbox\" name=\"nodeadline\" onClick=\"disableDeadline()\"".(zero($event_deadline)?" CHECKED":"")."> Check box if no deadline</td></tr>\n";
//echo "<tr><td id=\"dat-field\">Notify me on each registration</td><td id=\"dat-input\"><SELECT name=\"event_notify\"><option value=\"1\"".($event_emponly==1?" SELECTED":"").">Yes</option><option value=\"0\"".($event_notify==0?" SELECTED":"").">No</option></SELECT></td></tr>\n";
echo "<tr><td id=\"dat-field\">Who May Attend</td><td id=\"dat-input\"><SELECT name=\"event_emponly\"><option value=\"1\"".($event_emponly==1?" SELECTED":"").">Employees Only</option><option value=\"2\"".($event_emponly==2?" SELECTED":"").">Employees and Guests</option><option value=\"3\"".($event_emponly==3?" SELECTED":"").">Employees and Contractors</option><option value=\"4\"".($event_emponly==4?" SELECTED":"").">Employees, Contractors and All Guests</option></SELECT></td></tr>\n";
echo "<tr><td id=\"dat-field\">Link form from this page:</td><td id=\"dat-input\"><SELECT name=\"event_parent\">";
page_select(0,0,$event_parent,1);
echo "</SELECT></td></tr>\n";
echo "</table>\n";
echo "<P><input type=\"submit\" value=\"Edit Event Information\" name=\"editevent\" class=\"btn\"></form>\n";
} else {
echo "<br><br><br><center>".error("You do not have the proper permissions to edit this information.")."<br><br><br></center>\n";
}
} else {
echo "<P>".$errors;
echo "<P><table border=0 cellspacing=1 cellpadding=4 bgcolor=\"#C0C0C0\">\n";
echo "<form action=\"".self()."\" method=\"post\" name=\"post\">\n";
echo "<input type=\"hidden\" name=\"event_owner\" value=\"".$_SESSION["auth_user"]."\">\n";
echo "<input type=\"hidden\" name=\"event_type\" value=\"".$_GET["type"]."\">\n";
echo "<tr><td id=\"dat-field\">Event Owner</td><td id=\"dat-input\">".get_user($_SESSION["auth_user"],"fullname2")."</td></tr>\n";
echo "<tr><td id=\"dat-field\">Form Type</td><td id=\"dat-input\">".$type."</td></tr>\n";
echo "<tr><td id=\"dat-field\">Event Type</td><td id=\"dat-input\"><SELECT name=\"event_word\"><option value=\"1\"".(!isset($_POST["event_word"])||$_POST["event_word"]==1?" SELECTED":"").">Educational Course</option><option value=\"2\"".(isset($_POST["event_word"])&&$_POST["event_word"]==0?" SELECTED":"").">Employee Event</option></SELECT></td></tr>\n";
echo "<tr><td id=\"dat-field\">Event Title</td><td id=\"dat-input\"><input type=\"text\" name=\"event_title\" value=\"".stripslashes($_POST["event_title"])."\" size=90></td></tr>\n";
echo "<tr><td id=\"dat-field\" valign=\"top\">Event Description</td><td id=\"dat-input\">".ins_textarea(stripslashes($_POST["message"]),0,0,0,0,625,175)."</td></tr>\n";
echo "<tr><td id=\"dat-field\">Event Active?</td><td id=\"dat-input\"><SELECT name=\"event_active\"><option value=\"1\"".(!isset($_POST["event_active"])||$_POST["event_active"]==1?" SELECTED":"").">Yes</option><option value=\"0\"".(isset($_POST["event_active"])&&$_POST["event_active"]==0?" SELECTED":"").">No</option></SELECT></td></tr>\n";
echo "<tr><td id=\"dat-field\">Registration Deadline</td><td id=\"dat-input\"><input type=\"text\" name=\"event_deadline\" value=\"".(zero($_POST["event_deadline"])?"mm/dd/yyyy":$_POST["event_deadline"])."\" onFocus=\"this.value='';\" size=15> <input type=\"checkbox\" name=\"nodeadline\" onClick=\"disableDeadline()\"".(isset($_POST["nodeadline"])?" CHECKED":"")."> Check box if no deadline</td></tr>\n";
//echo "<tr><td id=\"dat-field\">Notify me on each registration</td><td id=\"dat-input\"><SELECT name=\"event_notify\"><option value=\"1\"".(isset($_POST["event_emponly"])&&$_POST["event_notify"]==1?" SELECTED":"").">Yes</option><option value=\"0\"".(!isset($_POST["event_notify"])||$_POST["event_notify"]==0?" SELECTED":"").">No</option></SELECT></td></tr>\n";
echo "<tr><td id=\"dat-field\">Who May Attend</td><td id=\"dat-input\"><SELECT name=\"event_emponly\"><option value=\"1\"".(!isset($_POST["event_active"])||$_POST["event_emponly"]==1?" SELECTED":"").">Employees Only</option><option value=\"2\"".(isset($_POST["event_emponly"])&&$_POST["event_emponly"]==2?" SELECTED":"").">Employees and Guests</option><option value=\"3\"".(isset($_POST["event_emponly"])&&$_POST["event_emponly"]==3?" SELECTED":"").">Employees and Contractors</option><option value=\"4\"".(isset($_POST["event_emponly"])&&$_POST["event_emponly"]==4?" SELECTED":"").">Employees, Contractors and All Guests</option></SELECT></td></tr>\n";
echo "<tr><td id=\"dat-field\">Link form from this page:</td><td id=\"dat-input\"><SELECT name=\"event_parent\">";
page_select(0,0,(isset($_POST["event_parent"])?$_POST["event_parent"]:1),1);
echo "</SELECT></td></tr>\n";
echo "</table>\n";
echo "<P><input type=\"submit\" value=\"Continue -->\" name=\"insertevent\" class=\"btn\"></form>\n";
}
} else {
echo "<P>Welcome to the <b>Create New Employee Sign-Up Form</b>, um... form.\n";
echo "<P>To begin, please select the type of sign up form you would like to create from the options below.\n";
echo "<br><br>";
echo $errors;
echo "<br><center>\n";
echo "<table border=0 width=90%>\n";
echo "<form action=\"".self()."\" method=\"get\">\n";
echo "<tr><td valign=\"top\"><input type=\"radio\" name=\"type\" value=\"su\" CHECKED></td>\n";
echo " <td><b>Event Sign-Up Form</b><br>Choose this type of form if you have a pre-defined list of event dates and times and want to allow employees to register for a single or multiple event times.</td></tr>\n";
echo "<tr><td colspan=2> </td></tr>\n";
echo "<tr><td valign=\"top\"><input type=\"radio\" name=\"type\" value=\"is\"></td>\n";
echo " <td><b>General Interest Form</b><br>Choose this type of form if you do not have a pre-defined list of event dates and times but simply want to generate a list of people who are interested in attending your event.</td></tr>\n";
echo "<tr><td colspan=2> </td></tr>\n";
echo "<tr><td valign=\"top\"><input type=\"radio\" name=\"type\" value=\"rs\" DISABLED></td>\n";
echo " <td><b>Event Reservation Form</b><br>Choose this type of form if you have one event date and time which is open to employees and their guests. Employees will be able to specify the number of tickets they need for each category you specify. This has been used previously for the Kennywood Picnic and Pirate Game Outing.</td></tr>\n";
echo "<tr><td colspan=2> </td></tr>\n";
echo "<tr><td> </td><td><input type=\"submit\" value=\"Continue -->\" class=\"btn\"></td></tr>\n";
echo "</form></table></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");
?>