/booking/reservations/edit_event.php
PHP | 326 lines | 323 code | 3 blank | 0 comment | 4 complexity | 2d16a0da47e087bb9ee14565a6b09b2b MD5 | raw file
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=x-sjis">
- <title>Today's Schedule</title>
- </head>
- <body bgcolor="white" text="black">
- <?
- include ("../sqlfuncs.php");
- // open a connection to mysql
- $mysql_link = connect_to_db();
- $mysql_result = select_db($mysql_link);
- /*
- if ($EventId)
- {
- $query_update = "UPDATE
- EVENTS SET event_name = '$EventName',
- event_desc = '$EventDesc',
- event_date = '$EventDate',
- event_hour_from = '$From',
- event_hour_to = '$To' WHERE event_id = '$EventId'";
- $mysql_result_update = mysql_query($query_update, $mysql_link);
- }
- */
- $NewCategoryId = get_new_id_from_table("CATEGORIES","category_id", $mysql_link);
- if ($CategoryName)
- {
- $NewCategoryName = strtoupper($CategoryName);
- $query_check_cat = "SELECT category_id from CATEGORIES where category_name = '$NewCategoryName'";
- $mysql_result_cat_check = mysql_query($query_check_cat,$mysql_link);
- $numrows_check = mysql_num_rows($mysql_result_cat_check);
- if ($numrows_check == 0)
- {
- $query_cat_insert = "INSERT INTO CATEGORIES (category_id, category_name)
- VALUES ('$NewCategoryId','$NewCategoryName')";
- $mysql_result_cat_insert = mysql_query($query_cat_insert, $mysql_link);
- $CategoryId = $NewCategoryId;
- }
- else
- {
- $row_check = mysql_fetch_array($mysql_result_cat_check);
- $CategoryId = $row_check[0];
- }
- }
- $query_get_info = "SELECT event_name,event_desc,event_date,event_hour_to, event_hour_from, event_color, event_type,user_id,shared,category_id FROM EVENTS where event_id = '$EventId'";
- // print($query_get_info);
- $mysql_result_get_info = mysql_query($query_get_info, $mysql_link);
- $row = mysql_fetch_array($mysql_result_get_info);
- $EventName = $row[0];
- $EventDesc = $row[1];
- $EventDate = $row[2];
- $EventHourTo = $row[3];
- $EventHourFrom = $row[4];
- $EventColor = $row[5];
- $EventType = $row[6];
- $EventUserId = $row[7];
- $Shared = $row[8];
- $CategoryId = $row[9];
- $query_user = "SELECT user_name from USER where user_id = '$EventUserId'";
- $mysql_result_user = mysql_query($query_user, $mysql_link);
- $row_user = mysql_fetch_array($mysql_result_user);
- $ThisUserName = strtoupper($row_user[0]);
- print("<center>\n");
- $EditMode = "True";
- if (($UserId == $EventUserId) or (!$ThisUserName))
- {
- print("<font face='arial'>Edit Event</font><br></center>\n");
- $EditMode = "True";
- }
- else
- {
- print("<font face='arial'>View Event</font><br></center>\n");
- $EditMode = "False";
- }
- if ($EditMode == "True")
- {
- print("<form name='addevent' action='edit_event_db.php'><br>\n");
- }
- print("<TABLE\n");
- if ($ThisUserName)
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Created By:</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'>$ThisUserName</TD>");
- print("</TR>\n");
- }
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Event Date:</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'>$EventDate</TD>");
- print("</TR>\n");
- if ($EventType == "TOUR")
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Tour:</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'>$EventName</TD>");
- print("</TR>\n");
- print("<input type='hidden' name='EventName' value='$EventName'>\n");
- }
- else
- {
- if ($EditMode == "True")
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Event Name:</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'><input type='text' size='40' name='EventName' value='$EventName'></TD>");
- print("</TR>\n");
- }
- else
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Event Name:</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'>$EventName</TD>");
- print("</TR>\n");
- }
- }
- if ($EditMode == "True")
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>From</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'><input type='text' size='20' name='HourFrom' value='$EventHourFrom'></TD>");
- print("</TR>\n");
- }
- else
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>From</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'>$EventHourFrom</TD>");
- print("</TR>\n");
- }
- if ($EditMode == "True")
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>To</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'><input type='text' size='20' name='HourTo' value='$EventHourTo'></TD>");
- print("</TR>\n");
- }
- else
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>To</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'>$EventHourTo</TD>");
- print("</TR>\n");
- }
- if ($EditMode == "True")
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Create New Category</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'><input type='text' size='20' name='CategoryName'></TD>");
- print("</TR>\n");
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'>OR <b>Choose Category</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'><select name='CategoryId'>");
- $query_list_categories = "SELECT category_id,category_name FROM CATEGORIES where category_id = '$CategoryId' order by category_name ASC";
- $mysql_result_list = mysql_query($query_list_categories, $mysql_link);
- $iCount = 0;
- while ($row_list = mysql_fetch_array($mysql_result_list))
- {
- $TempCategoryId = $row_list[0];
- $TempCategoryName = strtoupper($row_list[1]);
- print("<option value='$TempCategoryId'>$TempCategoryName</option>\n");
- $iCount = $iCount + 1;
- }
- $query_list_categories = "SELECT category_id,category_name FROM CATEGORIES where category_id <> '$CategoryId' order by category_name ASC";
- $mysql_result_list = mysql_query($query_list_categories, $mysql_link);
- $iCount = 0;
- while ($row_list = mysql_fetch_array($mysql_result_list))
- {
- $TempCategoryId = $row_list[0];
- $TempCategoryName = strtoupper($row_list[1]);
- print("<option value='$TempCategoryId'>$TempCategoryName</option>\n");
- $iCount = $iCount + 1;
- }
- if ($iCount == 0)
- {
- print("<option value=''>NONE</option>\n");
- }
- print("</TD></TR>");
- }
- else
- {
- $query_list_categories = "SELECT category_id,category_name FROM CATEGORIES where category_id = '$CategoryId' order by category_name ASC";
- $mysql_result_list = mysql_query($query_list_categories, $mysql_link);
- $iCount = 0;
- $row_list = mysql_fetch_array($mysql_result_list);
- $ThisCategoryName = strtoupper($row_list[1]);
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Category</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'>$ThisCategoryName</TD>");
- print("</TR>\n");
- }
- if ($EditMode == "True")
- {
- if ($Shared == "N")
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Share?</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'><input type='checkbox' name='EventChecked'></TD>");
- print("</TR>\n");
- }
- else
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Share?</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'><input type='checkbox' name='EventChecked' checked></TD>");
- print("</TR>\n");
- }
- }
- if ($EditMode == "True")
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Link Color</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'><input type='text' size='20' name='EventColor' value='$EventColor'></TD>");
- print("</TR>\n");
- }
- else
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top'><Font color='blue'><b>Link Color</b></font></TD>\n");
- print("<TD ALIGN='LEFT' valign='top'>$EventColor</TD>");
- print("</TR>\n");
- }
- if ($EditMode == "True")
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top' colspan='2'><Font color='blue'><b>Event Description</b></font><br>\n");
- print("<TEXTAREA name='EventDesc' rows='20' cols='70'>$EventDesc");
- print("</TEXTAREA></TR>\n");
- }
- else
- {
- if ($EventDesc)
- {
- print("<TR>");
- print("<TD ALIGN='LEFT' valign='top' colspan='2'><Font color='blue'><b>Event Description</b></font><br>\n");
- print("$EventDesc");
- print("</TR>\n");
- }
- }
- if ($EditMode == "True")
- {
- print("<TR>");
- print("<TD ALIGN='center' valign='top' colspan='2'><input type='submit' name='EditEvent' value='Update'></TD>");
- print("</TR>\n");
- }
- print("</table>\n");
- if ($EditMode == "True")
- {
- print("<input type='hidden' name='UserLevel' value='$UserLevel'>\n");
- print("<input type='hidden' name='UserName' value='$UserName'>\n");
- print("<input type='hidden' name='mode' value='$mode'>\n");
- print("<input type='hidden' name='UserId' value='$EventUserId'>\n");
- print("<input type='hidden' name='EventId' value='$EventId'>\n");
- print("<input type='hidden' name='EventDate' value='$EventDate'>\n");
- print("<input type='hidden' name='EventType' value='$EventType'>\n");
- print("</form><br>\n");
- }
- print("<center><br><br>\n");
- print("<a href='get_events.php?date=$EventDate&mode=$mode&UserName=$UserName&UserLevel=$UserLevel'><font face='arial' size='-1'>List Today's Events</font></a> \n");
- if ($EventType != "TOUR")
- {
- if ($EditMode == "True")
- {
- print("<a href='delete_event.php?EventId=$EventId&EventDate=$EventDate&mode=$mode&UserName=$UserName&UserLevel=$UserLevel'><font face='arial' size='-1' color='red'><u>Delete Event</u></font></a> \n");
- }
- }
- print("<a href='javascript:close();'><font face='arial' size='-1'>Return to Calendar</font></a></center>\n");
- ?>
- </body>
- </html>