<?
// called from: multidate.php
// description: creates multiple entries in the APPOINTMENT and xref tables
//
include("connect.inc");
include("reqlogin.inc");
if (!(checkdate($SelMon, $SelDay, $SelYear))) {
$Message = "Invalid Date";
include("multidate.php");
exit;
}
//get today's date for _added fields
include("getcurrdate.inc");
$LoopNum = 1;
while ($LoopNum < 11) {
if ($ForUser[$LoopNum] != 0) {
// correct problem input
$SelInfo[$LoopNum] = addslashes($SelInfo[$LoopNum]);
$SelTime = "$SelHour[$LoopNum]" . ":" . "$SelMinute[$LoopNum]" . ":00";
// insert new appointment
$InsAppointmentSQL = "INSERT INTO appointment (appt_id, owner, month, day, year, time, information, month_added, day_added, year_added, added_user) VALUES (NULL, '$ForUser[$LoopNum]', '$SelMon[$LoopNum]', '$SelDay[$LoopNum]', '$SelYear[$LoopNum]', '$SelTime', '$SelInfo[$LoopNum]', '$Month-num', '$Day-num', '$Year-num', '$UserID')";
$InsAppointment = mysql_query($InsAppointmentSQL,$db);
$NewApptID = mysql_insert_id($db);
$errno = mysql_errno($db);
$error = mysql_error($db);
if ($errno == 0) {
$Message = "Appointment Added Successfully";
}
else {
$Message = "Error $errno: $error";
}
// create entry in user-appt cross-reference table
$InsUserXSQL = "INSERT INTO userxappt (userxappt_id, xuser_id, xappt_id) VALUES (NULL, '$ForUser[$LoopNum]', '$NewApptID')";
$InsUserX = mysql_query($InsUserXSQL);
$errno = mysql_errno($db);
$error = mysql_error($db);
if ($errno == 0) {
$Message = "Appointment Added Successfully";
}
else {
$Message = "Error $errno: $error";
require("calendar.php");
exit;
}
// create entry in appointment-project cross-reference table
$InsProjXSQL = "INSERT INTO apptxproj (apptxproj_id, xappt_id, xproj_id) VALUES (NULL, '$NewApptID', '$id')";
$InsProjX = mysql_query($InsProjXSQL);
$errno = mysql_errno($db);
$error = mysql_error($db);
if ($errno == 0) {
$Message = "Appointment Added Successfully";
}
else {
$Message = "Error $errno: $error";
require("calendar.php");
exit;
}
//if $ForContact, then create entry in contact-appointment cross-reference table
if ($SelContact[$LoopNum] != 0) {
$InsContXSQL = "INSERT INTO contxappt (contxappt_id, xcont_id, xappt_id) VALUES (NULL, '$SelContact[$LoopNum]', '$NewApptID')";
$InsContX = mysql_query($InsContXSQL);
$errno = mysql_errno($db);
$error = mysql_error($db);
if ($errno == 0) {
$Message = "Appointment Added Successfully";
}
else {
$Message = "Error $errno: $error";
require("calendar.php");
exit;
}
}
}
$LoopNum++;
}
include("projectlist.php");
exit;
?>