Skip to content

Instantly share code, notes, and snippets.

@naeluh
Created July 17, 2013 18:56
Show Gist options
  • Save naeluh/6023385 to your computer and use it in GitHub Desktop.
Save naeluh/6023385 to your computer and use it in GitHub Desktop.
<?
if ($mode == "") {
// NO MODE IS SET - CREATE NEW SPECIAL EVENT
$spevent = new event;
} else if ($mode == "edit") { // ***** EDIT MODE *****
mysql_select_db($database_NHMMYSQL, $NHMMYSQL);
// Are we editing a group of events, or an individual event?
if (isset($_GET["id"])) {
$eventId = $_GET["id"];
} else {
$eventId = '';
}
if (isset($_GET["groupid"])) {
$groupId = $_GET["groupid"];
} else {
$groupId = '';
}
if ($eventId != "") {
// SET QUERY TO SELECT BY EVENT ID
$query_Recordset1 = "SELECT * FROM tblspevents WHERE id='" . $eventId . "'";
} else if ($groupId != "") {
// SET QUERY TO SELECT BY GROUP ID
$query_Recordset1 = "SELECT * FROM tblspevents WHERE groupid='" . $groupId . "'";
}
$Recordset1 = mysql_query($query_Recordset1, $NHMMYSQL) or die(mysql_error());
// LOAD VARS FROM DB
while ($myrow = mysql_fetch_assoc($Recordset1)) {
$spevent = new event;
$spevent->id = $myrow['id'];
$spevent->groupid = $myrow['groupid'];
$spevent->event_name = $myrow['event_name'];
$spevent->b_day = $myrow['b_day'];
$spevent->b_month = $myrow['b_month'];
$spevent->b_year = $myrow['b_year'];
$spevent->b_time = $myrow['b_time'];
$spevent->b_time2 = $myrow['b_time2'];
$spevent->b_tindex = $myrow['b_tindex'];
$spevent->e_day = $myrow['e_day'];
$spevent->e_month = $myrow['e_month'];
$spevent->e_year = $myrow['e_year'];
$spevent->e_time = $myrow['e_time'];
$spevent->e_time2 = $myrow['e_time2'];
$spevent->e_tindex = $myrow['e_tindex'];
$spevent->locations = "";
foreach ($locations_order as $mylocation) {
$loc = "location" . $mylocation->location_id;
if (trim($myrow[$loc]) != "") {
$spevent->locations .= $loc . ",";
}
}
$spevent->vendors = $myrow['vendors'];
$spevent->setup_needs = $myrow['setup_needs'];
$spevent->request_name = $myrow['request_name'];
$spevent->request_email = $myrow['request_email'];
$spevent->approval = $myrow['approved'];
}
} // END IF MODE SET
// DISPLAY FORM HEADER
print <<<ENDADD
<form action="specialevents_confirm.php" method="post" name="addevent" id="addevent" onSubmit="javascript:validate()">
<table width="600" border="1" cellpadding="5" cellspacing="0" bordercolor="#ECF3E0">
<tr>
<td bgcolor="#507811"><strong><span style="color: #FFFFFF;">Special Events Request Form</span></strong><br><span style="color: #EEEEEE; font-size:11px;"><span class="required">*</span> = required field</span></td>
</tr>
ENDADD;
// ***** EDIT MODE *****
if (($mode == "edit") && ($groupId == "")) {
// DISPLAY SINGLE EVENT EDIT WARNING
echo '<tr><td colspan="2">ATTENTION: You are editing a single event, rather than a group events. Therefore the reccurence information is unavailable.</td></tr>' . "\r";
} else if (($mode == "edit") && ($eventId = "")) {
// DISPLAY GROUP EVENT EDIT WARNING
echo '<tr><td colspan="2">ATTENTION: You are editing a group of events, rather than an individual event. Your changes will affect all events from this group.</td></tr>' . "\r";
}
echo '<tr align="left" valign="top">' . "\r";
echo '<td><strong>Event Name: <span class="required">*</span></strong><br>' . "\r";
echo '<input name="event_name" type="text" id="event_name" size="50" value="' . $spevent->event_name . '">' . "\r";
echo '<input type="hidden" name="id" id="id" value="' . $spevent->id . '"></td></tr>' . "\r";
echo '<tr align="left" valign="top">' . "\r";
echo '<td><strong>Event Locations: <span class="required">*</span></strong><br><br>' . "\r";
// SET THE LOCATION INFO TO DISPLAY IN FORM
$colcount = 1;
$colmax = round(count($locations_order) / 2);
// PRINT HIDDEN locations INFO
print "<input type=\"hidden\" name=\"loc_count\" value=\"" . count($locations_order) . "\">\r";
echo '<table border="0" cellspacing="0" cellpadding="0"><tr>' . "\r";
echo '<td valign="top" align="left">' . "\r";
$label_displayed = '';
$column_switched = false;
foreach ($locations_order as $mylocation) {
if ($mylocation->hidden)
continue;
$loc = "location" . $mylocation->location_id;
$loc_selected = split(',', $spevent->locations);
$loc_selected = array_unique($loc_selected);
$loc_count = count($loc_selected) - 1;
unset($loc_selected[$loc_count]);
if ($mylocation->location_group != $label_displayed) {
$label_displayed = $mylocation->location_group;
if (($label_displayed > 2) && ($column_switched == false)) {
$column_switched = true;
print '</td>' . "\r";
print '<td valign="top" align="left" style="padding-left:40px;">' . "\r";
}
print '<p style="font-weight:bold;">' . $location_group_labels[$label_displayed] . "</p>\r";
}
// DISPLAY HTML FIELDS FOR LOCATIONS
if (in_array($loc, $loc_selected)) {
$str = '<input type="checkbox" name="location' . $mylocation->location_id . '" value="selected" checked>' . $mylocation->location_name . '<br>' . "\r";
} else {
$str = '<input type="checkbox" name="location' . $mylocation->location_id . '" value="selected">' . $mylocation->location_name . '<br>' . "\r";
}
print $str;
$colcount += 1;
//if ($colcount == $colmax)
/*
if (($label_displayed > 2) && ($column_switched == false))
{
$column_switched = true;
print '</td>' . "\r";
print '<td valign="top" align="left" style="padding-left:40px;">' . "\r";
}
*/
} // END foreach
echo '</td></tr></table></td></tr>' . "\r";
echo '<tr align="left" valign="top">' . "\r";
echo '<td width="308"><nobr><strong>Start Date and Time: <span class="required">*</span></strong><br>' . "\r\r";
$i = 1;
// POPULATE month FIELDS
echo '<select name="begin_month" size="1" id="begin_month" onChange="javascript:adjustbookdates(\'month\')">' . "\r";
foreach ($months as $mymonth) {
if ($i == $spevent->b_month) {
echo '<option value="' . $i . '" selected="selected">' . $mymonth . '</option>';
} else if (($i == $month) && ($spevent->b_month == "")) {
echo '<option value="' . $i . '" selected="selected">' . $mymonth . '</option>';
} else {
echo '<option value="' . $i . '">' . $mymonth . '</option>';
}
$i++;
} // END foreach
echo '</select>' . "\r\r"; // END SELECT MONTHS
// POPULATE DAY FIELDS
echo '<select name="begin_date" size="1" id="begin_date" onChange="javascript:adjustbookdates(\'date\')">' . "\r";
for ($i = 1; $i <= 31; $i++) {
if ($i == $spevent->b_day) {
echo '<option value="' . $i . '" selected="selected">' . $i . '</option>';
} else if (($i == $day) && ($spevent->b_day == "")) {
echo '<option value="' . $i . '" selected="selected">' . $i . '</option>';
} else {
echo '<option value="' . $i . '">' . $i . '</option>';
}
} // END for
echo '</select>' . "\r\r"; // END DAY SELECT
// POPULATE YEAR FIELDS
echo '<select name="begin_year" size="1" id="begin_year" onChange="javascript:adjustbookdates(\'year\')">' . "\r";
foreach ($years as $myyear) {
if ($myyear == $spevent->b_year) {
echo '<option value="' . $myyear . '" selected="selected">' . $myyear . '</option>';
} else if (($myyear == $year) && ($spevent->b_year == "")) {
echo '<option value="' . $myyear . '" selected="selected">' . $myyear . '</option>';
} else {
echo '<option value="' . $myyear . '">' . $myyear . '</option>';
}
} // END foreach
echo '</select>' . "\r\r"; // END YEAR SELECT
// POPULATE 1st start time FIELD
echo '<strong>from:</strong> <select name="begin_time" size="1">' . "\r";
foreach ($times as $mytime) {
if ($mytime == $spevent->b_time) {
echo '<option value="' . $mytime . '" selected="selected">' . $mytime . '</option>';
} else if (($mytime == "9:00") && ($spevent->b_time == "")) {
echo '<option value="' . $mytime . '" selected="selected">' . $mytime . '</option>';
} else {
echo '<option value="' . $mytime . '">' . $mytime . '</option>';
}
}
echo '</select>' . "\r\r"; // END 1ST TIME SELECT
// POPULATE 2nd start time FIELD
echo '<select name="begin_time2" size="1" id="begin_time2">' . "\r";
foreach ($times2 as $mytime2) {
if ($mytime2 == $spevent->b_time2) {
echo '<option value="' . $mytime2 . '" selected="selected">' . $mytime2 . '</option>';
} else {
echo '<option value="' . $mytime2 . '">' . $mytime2 . '</option>';
}
}
echo '</select>' . "\r\r"; // END 1st START TIME SELECT
// POPULATE 1st end time FIELD
echo '<strong>to:</strong> <select name="end_time" size="1" id="end_time">' . "\r";
foreach ($times as $mytime) {
if ($mytime == $spevent->e_time) {
echo '<option value="' . $mytime . '" selected="selected">' . $mytime . '</option>';
} else if (($mytime == "10:00") && ($spevent->e_time == "")) {
echo '<option value="' . $mytime . '" selected="selected">' . $mytime . '</option>';
} else {
echo '<option value="' . $mytime . '">' . $mytime . '</option>';
}
}
echo '</select>' . "\r\r"; // END 1ST TIME END SELECT
// POPULATE 2nd end time FIELD
echo '<select name="end_time2" size="1" id="end_time2">' . "\r";
foreach ($times2 as $mytime2) {
if ($mytime2 == $spevent->e_time2) {
echo '<option value="' . $mytime2 . '" selected="selected">' . $mytime2 . '</option>';
} else {
echo '<option value="' . $mytime2 . '">' . $mytime2 . '</option>';
}
}
// CLOSE TIME INFO
echo '</select>' . "\r\r";
echo '</nobr></td></tr>' . "\r";
// ***** NOT EDIT MODE or EDITING GROUP EVENT
if (($mode != "edit") || (($mode == "edit") && ($groupId != ""))) {
?>
<tr align="left" valign="top">
<td bgcolor="#CCCCFF"><strong>Group ID:</strong> <input type="text" id="groupid" name="groupid" size="20" maxlength="24" /><br />
<span class="smallblacktext">If this event is Recurring, please assign 3-5 character code, specific to this cluster of events. For example: AIN05. Please include letters and numbers only.</span>
</td>
</tr>
<tr align="left" valign="top">
<td><strong>Recurence Pattern</strong> <br />
<table width="600" border="0" cellspacing="3" cellpadding="6">
<tr bgcolor="#66CCCC">
<td width="94">
<p><label><input type="radio" name="frequency" value="daily" />Daily</label><br /></p>
</td>
<td width="392">
<p><label><input type="radio" name="dailydistribution" value="byday" onclick="javascript:selectdaily()" />Every</label>
<input name="distdays" type="text" id="distdays" value="1" size="3" maxlength="3" />Days<br />
<label><input type="radio" name="dailydistribution" value="weekday" onclick="javascript:selectdaily()" />Every Weekday</label><br />
</p>
</td>
</tr>
<tr bgcolor="#6699FF">
<td><label>
<input type="radio" name="frequency" value="weekly" onclick="javascript:selectweekly2()" />
Weekly</label></td>
<td><input name="weekdistribution" type="radio" value="weekly" onclick="javascript:selectweekly()" />
Every
<input name="distweeks" type="text" id="distweeks" value="1" size="3" maxlength="3" />
Weeks <br />
<input name="weeksunday" type="checkbox" id="weeksunday" value="yes" />
Sun
<input name="weekmonday" type="checkbox" id="weekmonday" value="yes" />
Mon
<input name="weektuesday" type="checkbox" id="weektuesday" value="yes" />
Tue
<input name="weekwednesday" type="checkbox" id="weekwednesday" value="yes" />
Wed
<input name="weekthursday" type="checkbox" id="weekthursday" value="yes" />
Thu
<input name="weekfriday" type="checkbox" id="weekfriday" value="yes" />
Fri
<input name="weeksaturday" type="checkbox" id="weeksaturday" value="yes" />
Sat
</td>
</tr>
<tr bgcolor="#6699CC">
<td><label>
<input type="radio" name="frequency" value="monthly" />
Monthly</label></td>
<td><p>
<label>
<input type="radio" name="monthlydist" value="byday" onclick="javascript:selectmonthly()" />
Day </label>
<input name="monthdistday" type="text" id="monthdistday" value="1" size="3" maxlength="3" />
of Every
<input name="monthdistmonth" type="text" id="monthdistmonth" value="1" size="3" maxlength="3" />
Months<br />
<label>
<input type="radio" name="monthlydist" value="byweekday" onclick="javascript:selectmonthly()" />
The</label>
<select name="monthdistweekdaynum" id="monthdistweekdaynum"><option value="0" selected="selected">First</option><option value="1">Second</option><option value="2">Third</option><option value="3">Forth</option></select>
<input name="monthdistweekday" type="text" id="monthdistweekday" value="Monday" size="10" maxlength="50" />
of Every Month<br />
</p></td>
</tr>
<tr bgcolor="#669966">
<td align="center" valign="middle">End Date </td>
<td><p>
<label>
<input type="radio" name="enddate" value="noend" />
No End Date</label>
<br />
<label>
<input type="radio" name="enddate" value="bynumber" />
End After</label>
<input name="endbynumber" type="text" id="endbynumber" value="1" size="3" maxlength="3" />
Occurences<br />
<label>
<input type="radio" name="enddate" value="bydate" checked="checked" />
End By</label>
<?php
// SET RECURRENCE end month
echo '<select name="end_month" size="1" id="end_month">';
$i = 1;
foreach ($months as $mymonth) {
if ($i == $month) {
echo '<option value="' . $i . '" selected="selected">' . $mymonth . '</option>';
} else {
echo '<option value="' . $i . '">' . $mymonth . '</option>';
}
$i++;
}
// SET RECURRENCE end day
echo '</select> <select name="end_date" size="1" id="end_date">';
for ($i = 1; $i <= 31; $i++) {
if ($i == $day) {
echo '<option value="' . $i . '" selected="selected">' . $i . '</option>';
} else {
echo '<option value="' . $i . '">' . $i . '</option>';
}
}
// SET RECURRENCE end year
echo '</select><select name="end_year" size="1" id="end_year">';
foreach ($years as $myyear) {
if ($myyear == $year) {
echo '<option value="' . $myyear . '" selected="selected">' . $myyear . '</option>';
} else {
echo '<option value="' . $myyear . '">' . $myyear . '</option>';
}
}
// END RECURRENCE TABLE
echo '</select></td></tr></table></td></tr>' . "\r";
} // END IF of recurrence fields
echo '<tr align="left" valign="top">' . "\r";
echo '<td><strong>Event Vendors:</strong><br><textarea name="vendors" cols="60" rows="4" id="vendors">' . $spevent->vendors . '</textarea></td>' . "\r";
echo '</tr><tr align="left" valign="top">' . "\r";
echo '<td><strong>Set Up Needs:</strong><br><textarea name="setup_needs" cols="60" rows="4" id="setup_needs">' . $spevent->setup_needs . '</textarea></td>' . "\r";
echo '</tr><tr align="left" valign="top">' . "\r";
echo '<td><strong>Requested By:<br>Name and Phone Number: <span class="required">*</span></strong><br><input name="request_name" type="text" id="request_name" size="30" value="' . $spevent->request_name . '"></td>' . "\r";
echo '</tr><tr align="left" valign="top">' . "\r";
echo '<td><strong>Email: <span class="required">*</span></strong><br><input name="request_email" type="text" id="request_email" size="30" value="' . $spevent->request_email . '">';
if ($mode == "edit") {
// SET HIDDEN STATUS VAR TO 'edit'
echo '<input type="hidden" name="status" id="status" value="edit">';
}
echo '</td></tr>' . "\r";
print <<<ENDADD3
<tr align="center" valign="top">
<td class="black14" bgcolor="#66CCFF" style="height:40px; vertical-align:middle;"><input type="hidden" name="approval" id="approval" value="pending"><a href="#" onClick="javascript:validate()"><b>Submit your Request</b></a></td>
</tr>
</table>
</form>
ENDADD3;
// Function DBSAFE
function DBsafe($param)
{
return $param;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment