Location: PHPKode > projects > Gsys > calendar/calendar_functions.php
<?PHP
//Filename : calendar_functions.php
//Description : Functions for working on/with the calendar table
//Author :  darc
//Last modified :  2006.12.20

    include '../includes/auth.php';
    include '../includes/db.php';


switch($_GET["cat"])
{
case "add_event":
{
         $date_time = $_POST['year'] ."-". $_POST['month'] ."-". $_POST['day'];
         $posted_by = $_POST['posted_by'];
         $title = $_POST['title'];
         $description = $_POST['description'];
         if($_POST['mandatory'] == TRUE)
                  $mandatory = 1;
         else
                  $mandatory = 0;



         $sql = "INSERT INTO `calendar` (`event_id`, `date_time`, `date_posted`, `posted_by`, `title`, `description`, `mandatory`) VALUES (NULL, '$date_time', NOW(), '$posted_by', '$title', '$description', '$mandatory')";
         $result = mysql_query($sql,$connection) or die(mysql_error());
          
		 $sql2 ="SELECT pin_num FROM $table_name WHERE l_name != \"\" && status != \"alumnus\"";
		 $result2 = mysql_query($sql2,$connection) or die(mysql_error());
		 while ($row2 = mysql_fetch_array($result2))
   		 {
          $to_pin = $row2['pin_num'];
		  $body = "$posted_by added an event to the calendar.";
		  $sender_pin = "0";
		  $title = "New Calendar Event";
		  $sql3 = "INSERT INTO `messages` (`msg_id` , `to_pin` , `from_pin` , `date_sent` , `title` , `body` , `read`) VALUES ('', '$to_pin', '$sender_pin', NOW(), '$title', '$body', '0')";
		  mysql_query($sql3,$connection) or die(mysql_error());		
		 }
		  echo "<html>
		<head><title>Event Added Successfully</title>
		<link href=\"../includes/index.css\" rel=\"stylesheet\" type=\"text/css\"></head>
		<body class=\"body\">
<br />
<table width=\"810\" height=\"626\" border=\"0\" align=\"center\" cellpadding=\"15\">
  <tr> 
    <td height=\"128\" colspan=\"2\"><img src=\"../images/eg_banner.gif\" width=\"810\" height=\"172\"></td>
  </tr>
  <tr> 
    <td width=\"27%\" height=\"488\" valign=\"top\">"; include '../includes/nav.inc'; echo "</td>
    <td width=\"53%\" align=\"center\">Successfully added event to the calendar for "; echo $date_time;".<br>   </td>
  </tr>
</table></body></html>";
          break;
}
case "del_event":
{
        $event_id= $_POST['event_id'];
        $sql = "DELETE FROM calendar WHERE event_id = '$event_id'";
        $result = mysql_query($sql,$connection) or die(mysql_error());
		
          echo "<html>
		<head><title>Event Deleted Successfully</title>
		<link href=\"../includes/index.css\" rel=\"stylesheet\" type=\"text/css\"></head>
		<body class=\"body\">
<br />
<table width=\"810\" height=\"626\" border=\"0\" align=\"center\" cellpadding=\"15\">
  <tr> 
    <td height=\"128\" colspan=\"2\"><img src=\"../images/eg_banner.gif\" width=\"810\" height=\"172\"></td>
  </tr>
  <tr> 
    <td width=\"27%\" height=\"488\" valign=\"top\">"; include '../includes/nav.inc'; echo "</td>
    <td width=\"53%\" align=\"center\">Successfully deleted event.<br></td>
  </tr>
</table></body></html>";
          break;
}
case "edit_event" :
    {
      $event_id = $_POST['event_id'];
      $date_time = $_POST['date_time'];
      $title = $_POST['title'];
      $description = $_POST['description'];
	  $mandatory = $_POST['mandatory'];
      
      $sql = "UPDATE calendar SET date_time = '$date_time', title = '$title', description = '$description', mandatory = '$mandatory'  WHERE event_id = '$event_id' LIMIT 1";
      $result = mysql_query($sql,$connection) or die(mysql_error());

    }
}
Return current item: Gsys