|
}
$stateArray = getState();
$contactInfo = array();
$serviceId = 0;
switch ($in->postArgs["action"]) {
case "formSubmit":
// if register
if ($in->postArgs["submit"]=="Register") {
$contactInfo = array(
"id" => "0",
"firstName" => $in->postArgs["firstName"],
"lastName" => $in->postArgs["lastName"],
"email" => $in->postArgs["email"],
"address" => $in->postArgs["address"],
"city" => $in->postArgs["city"],
"state" => $in->postArgs["state"],
"zip" => $in->postArgs["zip"],
"phoneArea" => $in->postArgs["phoneArea"],
"phone1" => $in->postArgs["phone1"],
"phone2" => $in->postArgs["phone2"],
"speed" => $in->postArgs["speed"],
"newsletter" => "NO"
);
if ($in->postArgs["newsletter"]=="YES") {
$contactInfo["newsletter"] = "YES";
}
if (!checkRegInfo()) {
showPage($stateArray, showErrors());
break;
}
// reg form filled ok
// check if he's already registered
$userRegInfo = getUserByEmail(strtolower(trim($contactInfo["email"])));
// an error occured
if ($userRegInfo==-1) {
showPage($stateArray, showErrors());
break;
}
// user is not registered - register him
if ($userRegInfo==0) {
if (!$userRegInfo = registerUser($contactInfo)) {
showPage($stateArray, showErrors());
break;
}
// user sucessfuly registered
$contactInfo["id"] = $userRegInfo["id"];
$contactInfo["clientCode"] = $userRegInfo["clientCode"];
} else {
// user was registered
$contactInfo["id"] = $userRegInfo["id"];
$contactInfo["clientCode"] = $userRegInfo["clientCode"];
// update his contact info
if (!updateContactInfo($contactInfo)) {
showPage($stateArray, showErrors());
break;
}
// contact info updated
}
// check if he already got CTS for this year
$alreadyGotIt = checkIfAlreadyGot($contactInfo["id"], "CTS");
// an error occured
if ($alreayGotIt==-1) {
showPage($stateArray, showErrors());
break;
}
// doesn't have it
if ($alreadyGotIt==0) {
// save service
if (!$serviceId = saveService("CTS", $contactInfo["id"], "0", "")) {
showPage($stateArray, showErrors());
break;
}
}
// user info inserted
// send him e-mail if he got cts for the first time this year and redirect the user to the next page
if ($alreadyGotIt==0) {
mailCTSConf(stripslashes(strtolower($contactInfo["email"])), $contactInfo["clientCode"], $serviceId);
mail("customerservice@e-file-online.com", "E-File-Online.Com CTS registration", "Name: ".$contactInfo["firstName"]."\nLast Name: ".$contactInfo["lastName"]."\nE-mail: ".$contactInfo["email"]."\nAddress: ".$contactInfo["address"]." ".$contactInfo["city"]." ".$contactInfo["state"]." ".$contactInfo["zip"]."\n","From: customerservice@E-file-Online.Com\nReply-to: customerservice@E-file-Online.Com");
redirectWithOverture("https://www.taxnotebook.com/tnstart.asp?welcome=WL7959093");
exit;
break;
}
redirect("https://www.taxnotebook.com/tnstart.asp?welcome=WL7959093");
exit;
break;
// if login
} elseif ($in->postArgs["submit"]=="Log-in") {
if (!checkLoginInfo()) {
showPage($stateArray, showErrors());
break;
}
// login form filled ok
// check if he's already registered
$userRegInfo = getUserByEmail(strtolower(trim($in->postArgs["regEmail"])));
// an error occured
if ($userRegInfo==-1) {
showPage($stateArray, showErrors());
break;
}
// user not registered
if ($userRegInfo==0) {
$errors[] = "Please register first.";
showPage($stateArray, showErrors());
break;
}
// user was registered ($userRegInfo is an array containing id and clientCode)
// check if the user alredy got CTS for the current fiscal year
$alreadyGotIt = checkIfAlreadyGot($userRegInfo["id"], "CTS");
// an error occured
if ($alreayGotIt==-1) {
showPage($stateArray, showErrors());
break;
}
// doesn't have it - he needs to enter his detailed contact data
if ($alreadyGotIt==0) {
$errors[] = "Please register first.";
showPage($stateArray, showErrors());
break;
}
// redirect
redirect("https://www.taxnotebook.com/tnstart.asp?welcome=WL7959093");
exit;
break;
} else {
$errors[] = "Undefined action";
showPage($stateArray, showErrors());
break;
}
default:
if (!$stateArray = getState()) {
$errors[] = "An error occured while processing your request. Please try again later.";
showPage($stateArray, showErrors());
break;
}
showPage($stateArray);
break;
}
?>
|