/* Author: Zack Huston Base Form for pensacolahomevalue.com Date: 3/14/05 Modifications: 3/14/05 Modified emails so that emails to agent and client come from the agents email address instead of the neighborhood */ require_once('include.php'); $emailFields = array('FirstName'=>'First Name', 'LastName'=>'Last Name', 'HomeAddress'=>'Home Address', 'HomeCity'=>'Home City', 'HomeState'=>'Home State', 'HomeZip'=>'Home Zip', 'EvalAddress'=>'To be Evaluated Address', 'EvalCity'=>'To be Evaluated City', 'EvalState'=>'To be Evaluated State', 'EvalZip'=>'To be Evaluated Zip', 'HomePhone'=>'Home Phone', 'WorkPhone'=>'Work Phone', 'Email'=>'Email', 'PurchasePrice'=>'Purchase Price', 'YearPurchased'=>'Year Purchased', 'PropertyOwner'=>'Property Owner', 'PropertyType'=>'Property Type', 'YearBuilt'=>'Year Built', 'Neighborhood'=>'Neighborhood', 'Bedrooms'=>'Bedrooms', 'FullBaths'=>'Full Baths', 'Halfbaths'=>'Half Baths', 'SquareFeet'=>'Square Feet', 'LotSize'=>'Lot Size', 'Waterfront'=>'Waterfront', 'CoolingType'=>'Cooling Type', 'Pool'=>'Pool', 'Screened'=>'Screened', 'Parking'=>'Parking', 'Spaces'=>'Spaces', 'Condition'=>'Condition', 'Comments'=>'Comments', 'PlansforHome'=>'Plans for Home', 'LeavingTheArea'=>'Leaving The Area', 'HomeListedWith'=>'Home Listed With', 'HeardAbout'=>'Heard About From'); $DB = new databaseObj(TPL_DB); //Select the record for the domain $host = $_SERVER['HTTP_HOST']; if ( substr($host, 0, 4) == 'www.' ) $host = substr($host, 4); //check for submission if ( $_POST ) { $insert = $_POST; $insert['siteAgentUID'] = (int)$insert['siteAgentUID']; $insertedSiteAgentUID = $insert['siteAgentUID']; $displayedSiteAgent = $DB->selectAndNext('sa.siteUID, sa.agentUID, sa.redirectUrl,a.email, a.name agentName,s.domainName,s.title siteTitle,s.fromEmail','siteAgents sa, sites s, agents a ','sa.siteUID=s.UID && sa.agentUID=a.UID && sa.UID='.$insert['siteAgentUID']); unset ($insert['siteAgentUID']); $insert['timeAdd'] = time(); // check for a duplicate email in the same site. If so send to the agent who received the first and do not update counter. $duplicateRequest = $DB->selectAndNext('*','requests','Email="'.$insert['Email'].'" AND siteUID='.$displayedSiteAgent['siteUID']); if ( $duplicateRequest['agentUID'] ) { $displayedSiteAgent = $DB->selectAndNext('sa.siteUID, sa.agentUID, sa.redirectUrl,a.email, a.name agentName,s.domainName,s.title siteTitle,s.Mortage_Banner,s.Mortage_URL,s.fromEmail','siteAgents sa, sites s, agents a ','sa.siteUID=s.UID && sa.agentUID=a.UID && sa.agentUID='.$duplicateRequest['agentUID'].' && sa.siteUID='.$duplicateRequest['siteUID']); } $insert['siteUID'] = $displayedSiteAgent['siteUID']; $insert['agentUID'] = $displayedSiteAgent['agentUID']; $insert['redirectUrl'] = $displayedSiteAgent['redirectUrl']; if($insert['Waterfront']) $insert['Waterfront'] = implode(',',$insert['Waterfront']); $requestUID = $DB->insert($insert,'requests'); // only update the counter if it was not a duplicate if ( !$duplicateRequest['agentUID'] ) $DB->query('UPDATE siteAgents SET submitCounter = submitCounter +1 WHERE UID = '.$insertedSiteAgentUID); //send html as a table email $emailData = $insert; if($emailData['Waterfront']) $emailData['Waterfront'] = str_replace(',',', ',$emailData['Waterfront']); $body = '