PageRenderTime 62ms CodeModel.GetById 37ms RepoModel.GetById 0ms app.codeStats 0ms

/middCalendar/events.php~

https://github.com/gkipkorir/public_html
Unknown | 292 lines | 232 code | 60 blank | 0 comment | 0 complexity | bcc9605e33d9b0e4bc6020ec65ed4589 MD5 | raw file
  1. <?php session_start(); ?>
  2. <!DOCTYPE HTML>
  3. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  4. <script>
  5. $(document).ready(function() {
  6. $(document).ready(function(){
  7. $(".genres").each(function(){
  8. //alert("hi");
  9. $(this).change(function() {
  10. a = $(this).attr('id');
  11. //alert(a);
  12. if (!$(this).is(':checked')) {
  13. // $('.OldCalendar').hide();
  14. $("."+a).hide();
  15. }else{
  16. $("."+a).show();
  17. //alert(".'"+a+"'");
  18. }
  19. });
  20. });
  21. });
  22. });
  23. </script>
  24. <title> Midd Events </title>
  25. <html>
  26. <body background=1003background1.png>
  27. <?php
  28. //start session
  29. //must happen before anything else on the page
  30. session_start();
  31. //set up the connection to the database
  32. define('DB_SERVER','panther.cs.middlebury.edu');
  33. define('DB_USERNAME','wschaaf');
  34. define('DB_PASSWORD','wschaaf');
  35. define('DB_DATABASE','wschaaf_Calendar');
  36. $con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die("Could not connect");
  37. //get todays date in form (y-m-d)
  38. $date = getdate();
  39. $today = $date['year']."-".$date['mon']."-".$date['mday'];
  40. $date1 = date_create("$today");
  41. //make array of week
  42. $t = date_create("$today");
  43. $byDate[date_format($t,"Y-m-d")][]=' ';
  44. for ($x=1; $x<=6; $x++) {
  45. date_add($t,date_interval_create_from_date_string("1 days"));
  46. $byDate[date_format($t,"Y-m-d")][]=' ';
  47. }
  48. //get date 6 days from today (to create a week, including today)
  49. $date=date_create("$today");
  50. date_add($date,date_interval_create_from_date_string("6 days"));
  51. //echo "Seven days from now is: ".date_format($date,"Y-m-d")."</br>";
  52. //sql query selects all events between today's date and 6 days from now
  53. $sql="SELECT * FROM Events WHERE date BETWEEN '".date_format($date1,"Y-m-d")."' AND '".date_format($date,"Y-m-d")."' AND approved=1 Order BY date, time";
  54. if (!mysqli_query($con,$sql))
  55. {
  56. die('Error: ' . mysqli_error());
  57. }
  58. else
  59. {
  60. //execute the SQL query
  61. $result = mysqli_query($con,$sql);
  62. }
  63. //$byDate needs to be initialized first so that days with no events still show up...
  64. echo "</br>Events in the Next 7 days: </br>";
  65. while ($row = mysqli_fetch_array($result)) {
  66. //for each event, display its name as a link to detailed event info, with eid in the url
  67. // echo "<a href='./eventInfo.php?eid=".$row['eid']."'>".$row['name']."</a><br>";
  68. $byDate[$row['date']][]=$row;
  69. }
  70. //print_r($byDate);
  71. echo "<div id='links'>";
  72. echo "</br>";
  73. //if session user is set (from logging in), show link to create event and log out
  74. if(isset($_SESSION['User'])){
  75. echo "Welcome ".$_SESSION['User']."</br>";
  76. echo "<a href='./MyEvents.php'>My Events</a></br>";
  77. echo "<a href='./CreateEvent.php'>Create Event</a></br>";
  78. echo "<a href='./CreateOrganization.php'>Create Organization</a></br>";
  79. echo "<a href='./addMembers.php'>Add Members to Org</a></br>";
  80. $sql2="SELECT supervisor FROM Users WHERE uid = '$_SESSION[uid]'";
  81. if (!mysqli_query($con,$sql2)) {
  82. die('Error: ' . mysqli_error());
  83. }
  84. else {
  85. //execute the SQL query
  86. $result2 = mysqli_query($con,$sql2);
  87. }
  88. $row = mysqli_fetch_array($result2);
  89. if($row['supervisor']==1) {
  90. echo "<a href='./approveEvents.php'>Approve Events</a></br>";
  91. }
  92. echo "<a href='./logout.php'>Don't forget to logout</a><br>";
  93. }
  94. else {
  95. //if session user is not set, show link to log in and to create user
  96. $_SESSION['User'] = null;
  97. echo "<a href='./login.php'>Log In</a></br>";
  98. echo "<a href='./CreateUser.php'>Create User</a></br>";
  99. }
  100. ?>
  101. <form method="POST" action="insert1.php">
  102. Search: <input type="text" name="Search" /> <br> <br>
  103. <input type="submit" value="Search"/> <br> <br>
  104. </form>
  105. <!--This creates the drop down list-->
  106. <form name="thisForm" method="POST" action="eventsByGenre.php">
  107. <p>Select Genre: <select size="1" name="genre">
  108. <option value="Dance"> Dance </option>
  109. <option value="Party"> Party </option>
  110. <option value="Clam Bake"> Clam Bake </option>
  111. <option value="Pineapple"> Pineapple </option>
  112. <!--<option value="drinking"> drinking </option>-->
  113. <option value="sports"> sports </option>
  114. <input type="submit" value="Go">
  115. </select></p>
  116. <p>
  117. </p>
  118. </form>
  119. </div>
  120. <div id='content'>
  121. <div id='genres'>
  122. Administrations's Calendar<input type="checkbox" id="OldCalendar" class="genres" checked/>
  123. Dance<input type="checkbox" id="Dance" class="genres" checked/>
  124. Clam Bake<input type="checkbox" id="Clam Bake" class="genres" checked/>
  125. Dance<input type="checkbox" id="dance" class="genres" checked/>
  126. Dance<input type="checkbox" id="check" class="genres" checked/>
  127. Dance<input type="checkbox" id="checkbox1" class="genres" checked/>
  128. Dance<input type="checkbox" id="checkbox1" class="genres" checked/>
  129. </div>
  130. <?php
  131. $days = array('Sunday', 'Monday', 'Tuesday', 'Wednesday','Thursday','Friday', 'Saturday');
  132. $months = array('01'=>'January', '02'=>'February', '03'=>'March', '04'=>'April','05'=>'May','06'=>'June', '07'=>'July', '08'=>'August', '09'=>'September', '10'=>'October', '11'=>'November', '12'=>'December');
  133. echo "</br>";
  134. echo "<div id='table1'>";
  135. echo "<table>";
  136. echo "<tr>";
  137. foreach($byDate as $key => $value) {
  138. echo "<td>";
  139. echo "<div class = 'date'>";
  140. echo "<a href='./date.php?date=".$key."' >";
  141. echo $days[date( "w", strtotime($key))]."</br>";
  142. echo $months[date( "m", strtotime($key))]." ".date( "d", strtotime($key))."</br></br>";
  143. echo "</a></div>";
  144. //array shift removes first value of array, which kept being current time for some reason.
  145. array_shift($value);
  146. //print out each event that occurs on day, as a link to more details
  147. foreach($value as $event){
  148. echo "<div class='".$event['genre']."'>";
  149. echo "<a href='./eventInfo.php?eid=".$event['eid']."'>".$event['name']."</a> </br>".date('g:i A',strtotime($event['time']))."<br>";
  150. //echo "<a href='./eventInfo.php?eid=".$event['eid']."'>".$event['name']."</a> ".date("l jS \of F Y h:i:s A",strtotime($event['time']))."<br>";
  151. echo "<div class = 'description'>".substr($event['description'],0,15)."...</div></br>";
  152. echo "</div>";
  153. }
  154. echo "</td>";
  155. }
  156. echo "</tr>";
  157. echo "</table>";
  158. echo "</div>";
  159. echo "</div>";
  160. //Display events
  161. //echo "</br>Events in the Next 7 days: </br>";
  162. //while ($row = mysqli_fetch_array($result)) {
  163. //for each event, display its name as a link to detailed event info, with eid in the url
  164. // echo "<a href='./eventInfo.php?eid=".$row['eid']."'>".$row['name']."</a><br>";
  165. //}
  166. //view session data:
  167. //print_r($_SESSION);
  168. //close connection
  169. mysql_close($con);
  170. ?>
  171. </div>
  172. </body>
  173. </html>
  174. <style>
  175. #genres{
  176. float:top;
  177. }
  178. a:visited, a:link {
  179. color:#0066CC;
  180. }
  181. a{
  182. font-size:20;
  183. }
  184. #links {
  185. border-radius: 25px;
  186. color: pink;
  187. position:fixed;
  188. background-color:black;
  189. opacity: .90;
  190. width:10%;
  191. padding-top: 20px;
  192. padding-bottom: 20px;
  193. padding-right: 10%;
  194. padding-left: 10%;
  195. border-width: 3px;
  196. border-color: black;
  197. margin-top: 10%;
  198. margin-right: 20%;
  199. margin-left: 65%;
  200. z-index: 1;
  201. //background-color: white;
  202. //opacity: .9;
  203. //float:left;
  204. //width: 200px ;
  205. }
  206. #content {
  207. float:left;
  208. }
  209. #table1 {
  210. border-radius: 25px;
  211. opacity: .9;
  212. color: pink;
  213. background-color: black;
  214. width: 1100px ;
  215. margin-left: auto ;
  216. margin-right: auto ;
  217. }
  218. div.date a:link,div.date a:visited {
  219. text-transform:uppercase;
  220. font-weight:bold;
  221. color: #0066CC;
  222. }
  223. table, th, td {
  224. border-radius: 25px;
  225. border: 1px solid white;
  226. text-align:center;
  227. }
  228. td {
  229. vertical-align:top;
  230. width:50;
  231. }
  232. </style>