include "../admin/connect.php3";
$now = Date("Y-m-d h:m:s");
$how_many_adds = 5;
if (!$sid || !$seminarID) {
$errors = "Sorry - required parameters not passed.";
}
else {
$sql = "select * from Sid where sid='$sid'";
$result = mysql($database, $sql);
$num = mysql_numrows($result);
if ($num == 0) {
$errors = "Sorry - invalid sid.";
}
else {
$companyID = mysql_result($result,0,"companyID");
$sql = "select * from Company where companyID=$companyID";
$result = mysql($database, $sql);
$num = mysql_numrows($result);
if ($num == 0) {
$errors = "Sorry - invalid companyID.";
}
else {
if (mysql_result($result,0,"numSeminars") == 0) {
$errors = "Sorry - You need to purchase more basic seminar listings
in order to post any more seminars.";
}
else {
$sql = "select * from Seminar where seminarID=$seminarID and companyID=$companyID";
$result = mysql($database, $sql);
$num = mysql_numrows($result);
if ($num == 0) {
$errors = "Sorry - seminar and company do not match.";
}
}
}
}
}
if (($edit || $add) && !$errors) {
if ($edit) {
$e=0;
while ($e<$how_many_edits) {
$sql="";
$seminarDatesIDname = "id$e";
$delete_name = "delete_edit$e";
if ($$delete_name) {
$sql = "delete from SeminarDates where seminarDatesID=${$seminarDatesIDname}";
} /* if */
else {
$cityname = "otherCity_edit$e";
$stateIDname = "otherStateID_edit$e";
$countryIDname = "otherCountryID_edit$e";
$leadername = "leader_edit$e";
$metroIDname = "metroID_edit$e";
if (!$$metroIDname) { $$metroIDname = 0; }
$fyname = "fromYear_edit$e";
$fmname = "fromMonth_edit$e";
$fdname = "fromDay_edit$e";
$tyname = "toYear_edit$e";
$tmname = "toMonth_edit$e";
$tdname = "toDay_edit$e";
$exactLocation = "exactLocation_edit$e";
$regCode = "regCode_edit$e";
$listingType = "listingType_edit$e";
if (!$$cityname) {
$errors = "Some dates not updated! (missing city)";
} /* if */
elseif ((!$$stateIDname && !$$countryIDname) || ($$stateIDname && $$countryIDname)) {
$errors = "Some dates not updated! (missing state or country, or both selected)";
} /* elseif */
else {
/* if country code chosen, we know it's not USA or Canada, otherwise they would've chosen a state/province-country. */
/* so, we'll need to create a State record with a blank description and this country code (unless it already exists) */
if ($$countryIDname) {
$sql = "select stateID from State where state='' and countryID=${$countryIDname}";
$result = mysql($database, $sql);
$num = mysql_numrows($result);
if ($num) {
$$stateIDname = mysql_result($result,$i,"stateID");
} /* if */
else {
$sql = "insert into State values ('', '', '', ${$countryIDname}, '$now', '')";
$result = mysql($database, $sql);
$$stateIDname = mysql_insert_id();
} /* else */
} /* if */
/* here we check to see if the record was actually changed. if not, don't do the update */
$old_cityname = "old_$cityname";
$old_stateIDname = "old_$stateIDname";
$old_countryIDname = "old_$countryIDname";
$old_leadername = "old_$leadername";
$old_metroIDname = "old_$metroIDname";
$old_fyname = "old_$fyname";
$old_fmname = "old_$fmname";
$old_fdname = "old_$fdname";
$old_tyname = "old_$tyname";
$old_tmname = "old_$tmname";
$old_tdname = "old_$tdname";
$old_exactLocation = "old_$exactLocation";
$old_regCode = "old_$regCode";
$old_listingType = "old_$listingType";
if ($$cityname != $$old_cityname || $$stateIDname != $$old_stateIDname || $$countryIDname != $$old_countryIDname || $$leadername != $$old_leadername || $$metroIDname != $$old_metroIDname || $$fyname != $$old_fyname || $$fmname != $$old_fmname || $$fdname != $$old_fdname || $$tyname != $$old_tyname || $$tmname != $$old_tmname || $$tdname != $$old_tdname || $$exactLocation != $$old_exactLocation || $$regCode != $$old_regCode || $$listingType != $$old_listingType) {
/* convert otherCity, otherStateID to cityID */
/* MAB 9/26/99 - removed this next section for consistency with inserts */
/* $sql = "SELECT * from City where city='$$cityname' and stateID=$$stateIDname"; */
/* $result = mysql($database, $sql); */
/* if (mysql_numrows($result)) { */
/* $cityID = mysql_result($result,0,"cityID"); */
/* } */
/* */
/* if we get this far, add otherCity to the City table, and return the new cityID */
/* else { */
/* $sql = "INSERT INTO City (cityID, city, stateID, dateEntered, dateModified) values ('', '$$cityname', $$otherStateID, '$now', '')"; */
/* $result = mysql($database, $sql); */
/* $cityID = mysql_insert_id(); */
/* } */
/* END REMOVE */
$fm = sprintf ("%02d", $$fmname);
$fd = sprintf ("%02d", $$fdname);
$fromDate = "" . $$fyname . "-$fm-$fd";
$tm = sprintf ("%02d", $$tmname);
$td = sprintf ("%02d", $$tdname);
$toDate = "" . $$tyname . "-$tm-$td";
$sql = "update SeminarDates set leader='${$leadername}', fromDate='$fromDate', toDate='$toDate', otherCity='${$cityname}', otherStateID=${$stateIDname}, datemodified='$now', cityID=0, metroRegionID=${$metroIDname}, exactLocation ='${$exactLocation}', regCode='${$regCode}', listingType='${$listingType}', processed=0 where seminarDatesID=${$seminarDatesIDname}";
# echo "$sql
\n";
$result = mysql($database, $sql);
} /* if changed */
} /* else */
} /* else */
$e++;
} /* while */
} /* if ($edit) */
if ($add) {
$a=0;
while ($a<=$how_many_adds) {
$cityname = "otherCity_add$a";
# we assume that if they entered a city, they want to add the date.
# we won't deduce (or create) a cityID now. the admin script that approves the date will do that.
if ($$cityname) {
$stateIDname = "otherStateID_add$a";
$countryIDname = "otherCountryID_add$a";
if ((!$$stateIDname && !$$countryIDname) || ($$stateIDname && $$countryIDname)) {
$errors = "Some dates not added! (missing state or country, or both selected)";
}
else {
/* if country code chosen, we know it's not USA or Canada, otherwise they would've chosen a state/province-country. */
/* so, we'll need to create a State record with a blank description and this country code (unless it already exists) */
if ($$countryIDname) {
$sql = "select stateID from State where state='' and countryID=${$countryIDname}";
$result = mysql($database, $sql);
$num = mysql_numrows($result);
if ($num) {
$$stateIDname = mysql_result($result,$i,"stateID");
} /* if */
else {
$sql = "insert into State values ('', '', '', ${$countryIDname}, '$now', '')";
$result = mysql($database, $sql);
$$stateIDname = mysql_insert_id();
} /* else */
} /* if */
$now = Date("Y-m-d h:m:s");
$leadername = "leader_add$a";
$metroIDname = "metroID_add$a";
$exactLocation = "exactLocation_add$a";
$regCode = "regCode_add$a";
$listingType = "listingType_add$a";
if (!$$metroIDname) { $$metroIDname = 0; }
$fyname = "fromYear_add$a";
$fmname = "fromMonth_add$a";
$fm = sprintf ("%02d", $$fmname);
$fdname = "fromDay_add$a";
$fd = sprintf ("%02d", $$fdname);
$fromDate = "" . $$fyname . "-$fm-$fd";
$tyname = "toYear_add$a";
$tmname = "toMonth_add$a";
$tm = sprintf ("%02d", $$tmname);
$tdname = "toDay_add$a";
$td = sprintf ("%02d", $$tdname);
$toDate = "" . $$tyname . "-$tm-$td";
$eyname = "exactYear_add$a";
$emname = "exactMonth_add$a";
$em = sprintf ("%02d", $$emname);
$edname = "exactDay_add$a";
$ed = sprintf ("%02d", $$edname);
$exactDate = "" . $$eyname . "-$em-$ed";
$sql = "insert into SeminarDates values ('', $seminarID, '${$leadername}', '$fromDate', '$toDate', '${$cityname}', ${$stateIDname}, '', '', 0, '$now', '', 0, 0, ${$metroIDname},'${$exactLocation}', '${$regCode}', '${$listingType}')";
# echo "$sql
\n";
$result = mysql($database, $sql);
$$cityname = "";
$$stateIDname = "";
$$countryIDname = "";
$$leadername = "";
$$metroIDname = "";
$$fyname = "";
$$fmname = "";
$$fdname = "";
$$tyname = "";
$$tmname = "";
$$tdname = "";
} /* else */
} /* if ($$cityname) */
$a++;
} /* while */
} /* if ($add) */
} /* if (($edit || $add) && !$errors) */
if ($errors) { $errors = "
\n"; echo "Add dates for this seminar
\n";
echo "Modify Existing Public Dates:
| City: | \n"; $name = "otherCity_edit$d"; echo "\n"; echo " | \n"; echo "||
| State/Province OR Country: | \n";
$name = "otherStateID_edit$d";
echo "\n"; echo ""; echo " OR \n"; $name = "otherCountryID_edit$d"; echo " | \n";
echo "||
| Metro Region: | \n"; $name = "metroID_edit$d"; echo ""; echo ""; echo " | \n"; echo "||
| Course Leader: | \n"; $name = "leader_edit$d"; echo ""; echo " | \n"; echo "||
| Exact Location: | \n"; $name = "exactLocation_edit$d"; echo ""; echo " | \n"; echo "||
| Reg Code: | \n"; $name = "regCode_edit$d"; echo ""; echo " | \n"; echo "||
| Listing Type: | \n"; $name = "listingType_edit$d"; echo ""; echo " | \n"; echo "||
| From Date: | \n"; $name = "fromMonth_edit$d"; $$name = 0 + substr($fromDate,5,2); echo "\n"; $name = "fromDay_edit$d"; $$name = 0 + substr($fromDate,8,2); echo " \n"; $name = "fromYear_edit$d"; $$name = substr($fromDate,0,4); echo " | \n"; echo "||
| To Date: | \n"; $name = "toMonth_edit$d"; $$name = 0 + substr($toDate,5,2); echo "\n"; $name = "toDay_edit$d"; $$name = 0 + substr($toDate,8,2); echo " \n"; $name = "toYear_edit$d"; $$name = substr($toDate,0,4); echo " | \n"; echo "||
| Delete: | \n"; echo "\n"; echo " | ||
\n
| City: | \n"; $name = "otherCity_add$a"; echo "\n"; echo " | ||
| States/Province OR Country: | \n";
$name = "otherStateID_add$a";
echo "\n"; echo " OR \n"; $name = "otherCountryID_add$a"; echo " | \n";
echo "||
| Metro Region: | \n"; $name = "metroID_add$a"; echo "\n"; echo " | ||
| Course Leader: | \n"; $name = "leader_add$a"; echo "\n"; echo " | ||
| Exact Location: | \n"; $name = "exactLocation_add$a"; echo "\n"; echo " | ||
| Reg Code: | \n"; $name = "regCode_add$a"; echo "\n"; echo " | ||
| Listing Type: | \n"; $name = "listingType_add$a"; echo "\n"; echo " | ||
| From Date: | \n"; $name = "fromMonth_add$a"; echo "\n"; $name = "fromDay_add$a"; echo " \n"; $name = "fromYear_add$a"; echo " | \n"; echo "||
| To Date: | \n"; $name = "toMonth_add$a"; echo "\n"; $name = "toDay_add$a"; echo " \n"; $name = "toYear_add$a"; echo " | \n"; echo "||
| Exact Date: | \n"; $name = "exactMonth_add$a"; echo "\n"; $name = "exactDay_add$a"; echo " \n"; $name = "exactYear_add$a"; echo " | \n"; echo "||