From: Steve Sutton Date: Mon, 8 Feb 2010 21:58:36 +0000 (+0000) Subject: update contact form X-Git-Tag: v1.0.0~108 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=aabf5e5a658800dfc8cfce2632e55b53cb1438b8;p=web%2FTroutCreek.git update contact form --- diff --git a/Toolkit/Contacts/ContactUs.php b/Toolkit/Contacts/ContactUs.php index f852d02..571304e 100755 --- a/Toolkit/Contacts/ContactUs.php +++ b/Toolkit/Contacts/ContactUs.php @@ -162,8 +162,12 @@ class Toolkit_Contacts_ContactUs * @access protected */ protected $successMsg = ' +
- Thank you for your questions or comments! + Thank you for the reservation request!
'; /** @@ -289,7 +293,7 @@ class Toolkit_Contacts_ContactUs $this->siteName = SITENAME; } if (empty($this->subject)) { - $this->subject = 'Contact Request from website ' . SITENAME; + $this->subject = 'You have received a reservation request'; } /** @@ -387,10 +391,32 @@ class Toolkit_Contacts_ContactUs public function configureElements() { $e = array(); - //$this->setInterestFields(); + $this->setInterestFields(); // Grouped Elements are defined here. - //$this->interestsGroups =& $this->getInterestFields(); - + $this->interestsGroups =& $this->getInterestFields(); + + // unit sizes + $unit_size2[''] = "-- Select --"; + $unit_size2[6] = "5 bedroom & loft, 3.5 bathroom (sleeps 12)"; + $unit_size2[0] = "3 bedroom & loft, 2 bathroom (sleeps 8-10)"; + $unit_size2[1] = "2 bedroom & loft, 2 bathroom (sleeps 6-8)"; + $unit_size2[2] = "2 bedroom, 2 bathroom + (sleeps 4-6)"; + $unit_size2[3] = "2 bedroom, 2 bathroom (sleeps 4-6)"; + $unit_size2[4] = "2 bedroom, 1 bathroom (sleeps 4-6)"; + $unit_size2[5] = "1 bedroom, 1 bathroom (sleeps 2-4)"; + + // referred by + $referred_by2[''] = "-- Select --"; + $referred_by2[0] = "AAA"; + $referred_by2[1] = "Big Fore"; + $referred_by2[2] = "Chamber/Visitors Bureau"; + $referred_by2[3] = "Detroit Free Press"; + $referred_by2[4] = "Friends/Relatives"; + $referred_by2[5] = "Great Rentals Web Site"; + $referred_by2[6] = "Internet"; + $referred_by2[7] = "Nubs Nob"; + $referred_by2[8] = "Other"; + $referred_by2[9] = "Past Guest"; // All Elements are created here. This includes group element definitions. $e[] = array( 'type' => 'hidden', @@ -404,86 +430,80 @@ class Toolkit_Contacts_ContactUs ); $e[] = array( 'type' => 'text', - 'req' => false, + 'req' => true, 'name' => 'fname', - 'display' => 'First Name' + 'display' => 'First Name:' ); $e[] = array( 'type' => 'text', 'req' => false, 'name' => 'lname', - 'display' => 'Last Name' + 'display' => 'Last Name:' ); $e[] = array( 'type' => 'text', - 'req' => false, - 'name' => 'address', - 'display' => 'Address 1' + 'req' => true, + 'name' => 'email', + 'display' => 'Email:' + ); + $e[] = array( + 'type' => 'text', + 'req' => true, + 'name' => 'email_rmv', + 'display' => 'Verify Email:' ); $e[] = array( 'type' => 'text', 'req' => false, - 'name' => 'address2', - 'display' => 'Address 2' + 'name' => 'address', + 'display' => 'Address:' ); $e[] = array( 'type' => 'text', 'req' => false, 'name' => 'city', - 'display' => 'City' + 'display' => 'City:' ); $e[] = array( 'type' => 'select', 'req' => false, 'name' => 'state', - 'display' => 'State/Province', + 'display' => 'State/Province:', 'opts' => $GLOBALS['states'] ); $e[] = array( 'type' => 'text', 'req' => false, 'name' => 'zip', - 'display' => 'ZIP/Postal Code' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'email', - 'display' => 'Email' - ); - $e[] = array( - 'type' => 'text', - 'req' => true, - 'name' => 'email_rmv', - 'display' => 'Verify Email' + 'display' => 'ZIP/Postal Code:' ); $e[] = array( 'type' => 'text', 'req' => false, 'name' => 'phone', - 'display' => 'Phone' + 'display' => 'Phone:' ); + $e[] = array( - 'type' => 'text', + 'type' => 'select', 'req' => false, - 'name' => 'fax', - 'display' => 'Fax' + 'name' => 'unit_size', + 'display' => 'Unit Size:', + 'opts' => $unit_size2 ); $e[] = array( - 'type' => 'textarea', - 'req' => false, - 'name' => 'comments', - 'display' => 'Comments' + 'type' => 'select', + 'req' => true, + 'name' => 'referred_by', + 'display' => 'How did you hear about Trout Creek?', + 'opts' => $referred_by2 ); $e[] = array( - 'type' => 'advcheckbox', + 'type' => 'textarea', 'req' => false, - 'name' => 'mail_ok', - 'display' => 'Yes, I would like to receive Email Newsletters', - 'opts' => 'Yes', - 'val' => array(0, 1) + 'name' => 'other', + 'display' => 'If other, please specify:' ); - /* if (is_array($this->interestsGroups)) { foreach ($this->interestsGroups as $group => $gData) { $this->myGroups[] = $gData; @@ -498,19 +518,33 @@ class Toolkit_Contacts_ContactUs ); } } - */ + + $e[] = array( + 'type' => 'textarea', + 'req' => false, + 'name' => 'comments', + 'display' => 'Additional Questions:' + ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'mail_ok', + 'display' => 'Please notify me of specials and offers.', + 'opts' => 'Yes', + 'val' => array(0, 1) + ); $e[] = array( 'type' => 'CAPTCHA_Image', 'req' => false, 'name' => 'captcha_question', - 'display' => 'Verification code', + 'display' => 'Verification code:', 'opts' => $this->captchaOptions ); $e[] = array( 'type' => 'text', 'req' => true, 'name' => 'captcha_rmv', - 'display' => 'Enter verification code' + 'display' => 'Enter verification code:' ); $e[] = array( 'type' => 'submit', @@ -867,7 +901,7 @@ class Toolkit_Contacts_ContactUs protected function insertData($values) { unset($values['comments']); - $values['contact_type'] = ":{$this->contactType}:"; + //$values['contact_type'] = ":{$this->contactType}:"; if (is_array($values['interest']) && !empty($values['interest'])) { foreach ($values['interest'] as $iGroup => $interests) { $newInterest[] = implode(':', array_keys($interests)); @@ -935,6 +969,7 @@ class Toolkit_Contacts_ContactUs $streamSend = new Toolkit_Contacts_StreamSend(); $streamSend->addContact($values); } + $values['unit_size'] = (!$values['unit_size']) ? null: $values['unit_size']; // Check if we are updating an existing contact or not // question: is this the best approach? what if someone else @@ -966,6 +1001,10 @@ class Toolkit_Contacts_ContactUs SELECT contact_inq.*, inq_group.name FROM contact_inq LEFT OUTER JOIN inq_group ON (contact_inq.groupid = inq_group.id) ORDER BY groupid, pos"; + $sql = " + SELECT contact_inq.*,'Let us know what you are interested in' as name + FROM contact_inq + ORDER BY pos"; $i = array(); foreach ($this->dbh->query($sql) as $row) { @@ -1074,6 +1113,7 @@ class Toolkit_Contacts_ContactUs try { // Get all the existing contact type data + /* $sql = " SELECT contact_type FROM {$this->tableName} @@ -1089,6 +1129,7 @@ class Toolkit_Contacts_ContactUs if (!in_array($this->contactType, $existingTypes)) { $values['contact_type'] = "$cType{$this->contactType}:"; } + */ $sql = Toolkit_Common::createSQLUpdate( $this->tableName, @@ -1105,6 +1146,7 @@ class Toolkit_Contacts_ContactUs } catch (PDOException $e) { return Toolkit_Common::handleError($e); } + } // }}} diff --git a/setup.phtml b/setup.phtml index 8bbcd3b..3aed6a4 100644 --- a/setup.phtml +++ b/setup.phtml @@ -273,7 +273,7 @@ if (!isset($SITEINFO)) { /** * Constant of log store to use */ - define('ERROR_LOG_NAME', PEAR_LOG_TYPE_FILE); + define('ERROR_LOG_NAME', ''); /** * Identity reported to the log system */ @@ -337,7 +337,7 @@ if (!isset($SITEINFO)) { /** * Site owners email address */ - define('OWNER_EMAIL', 'jamie.kahgee@gmail.com'); + define('OWNER_EMAIL', 'steve@gaslightmedia.com'); /** * From header for admin/Contact mailout. */ diff --git a/static/32.phtml b/static/32.phtml index 11a881f..2f0f248 100755 --- a/static/32.phtml +++ b/static/32.phtml @@ -1,400 +1,11 @@ DB->db_auto_get_data($int_qs) ) -{ - foreach( $data as $row ) - { - $interest2[$row['id']] = $row['header']; - } -} -unset($unit_size); -unset($referred_by); -unset($fields); -$THANKYOU_TEXT = "


-

Thank you for the reservation request!

-"; -$GLOBALS["THANKYOU_TEXT"] = $THANKYOU_TEXT; -$fields['fname'] = "First Name"; -$fields['lname'] = "Last Name"; -$fields['email'] = "Email Address"; -$fields['address'] = "Address "; -$fields['city'] = "City "; -$fields['state'] = "State "; -$fields['zip'] = "Zip "; -$fields['arrive_date'] = "Arrival Date"; -$fields['depart_date'] = "Departure Date"; -$fields['unit_size'] = "Unit Size "; -$fields['referred_by'] = "Referred By"; -$fields['other'] = "Other "; -$fields['question'] = "Questions"; -$unit_size2[6] = "5 bedroom & loft, 3.5 bathroom (sleeps 12)"; -$unit_size2[0] = "3 bedroom & loft, 2 bathroom (sleeps 8-10)"; -$unit_size2[1] = "2 bedroom & loft, 2 bathroom (sleeps 6-8)"; -$unit_size2[2] = "2 bedroom, 2 bathroom + (sleeps 4-6)"; -$unit_size2[3] = "2 bedroom, 2 bathroom (sleeps 4-6)"; -$unit_size2[4] = "2 bedroom, 1 bathroom (sleeps 4-6)"; -$unit_size2[5] = "1 bedroom, 1 bathroom (sleeps 2-4)"; -$referred_by2[0] = "AAA"; -$referred_by2[1] = "Big Fore"; -$referred_by2[2] = "Chamber/Visitors Bureau"; -$referred_by2[3] = "Detroit Free Press"; -$referred_by2[4] = "Friends/Relatives"; -$referred_by2[5] = "Great Rentals Web Site"; -$referred_by2[6] = "Internet"; -$referred_by2[7] = "Nubs Nob"; -$referred_by2[8] = "Other"; -$referred_by2[9] = "Past Guest"; -/* -$interest2[0] = "Golf Trip"; -$interest2[1] = "Big 4 Golf Package"; -$interest2[2] = "Ski Trip"; -$interest2[3] = "Family vacation"; -$interest2[4] = "Family Reunion"; -$interest2[5] = "Romantic Getaway"; -$interest2[6] = "Honeymoon/Anniversary"; -$interest2[7] = "Soccer Weekend"; -$interest2[8] = "Wedding Group"; -$interest2[9] = "Biking"; -$interest2[10] = "Fishing"; -$interest2[11] = "Tennis"; -$interest2[12] = "Business"; -$interest2[13] = "Fall Color Tour"; -$interest2[14] = "Morel Mushrooms"; -$interest2[15] = "Spring/Fall Relaxing vacation"; -$interest2[16] = "Empty Nester Getaway"; -$interest2[17] = "Real Estate"; -$interest2[18] = "Senior Packages"; -$interest2[19] = "Scrapbooking"; -*/ -$GLOBALS['fields'] = $fields; -$GLOBALS['unit_size2'] = $unit_size2; -$GLOBALS['referred_by2'] = $referred_by2; -$GLOBALS['interest2'] = $interest2; -function build_select($array,$name,$multiple = 0) -{ - if(is_array($array)) - { - $select = ''; - } - return($select); -} -function build_checkbox($int_array) -{ - $total = count($int_array); - if($total == 0) - return(false); - $split = $total / 2; - $padding = $split * 2; - $int_array = array_pad($int_array,$padding," "); - $interest .= ""; - $count = 1; - foreach($int_array as $key=>$value) - { - $interest .= ""; - if($count%2==0 && $count != $padding) - { - $interest .= ""; - } - elseif($count == $padding) - { - $interest .= ""; - } - $count++; - } - $interest .= "
"; - $interest .= "$value
"; - $interest .= "
"; - return($interest); -} -function process_form( $_POST ) -{ - extract($_POST); - foreach($_POST as $key=>$value) - { - if($key == "email" && ( !GLM_TEMPLATE::valid_email($value) || $value == "" )) - { - $errors["email"] = "
your email is not valid or empty!
"; - } - if($key == "fname" && $value == "" ) - { - $errors["fname"] = "
your name is empty!
"; - } - if($key == "referred_by" && $value == "") - { - $errors["referred_by"] = "
Required Field!
"; - } - if($key == "other" && $value != "") - { - unset($errors["referred_by"]); - } - } - if(is_array($errors) && count($errors) > 0) - { - return($errors); - } - else - { - $DB =& new GLM_DB(); - $DB->db_connect(); - // database part - if(is_array($interest)) - { - foreach($interest as $ik=>$iv) - { - $int4[] = $GLOBALS['interest2'][$iv]; - } - $interest = ':'.implode(":",$int4).':'; - } - unset($_POST["interest"]); - // catid must be unset so it doesn't try to stick it in the db - unset($_POST['catid']); - $_POST["interest"] = $interest; - foreach($_POST as $key=>$value){ - if($key == "SUBMIT") - continue; - if($key == "arrive_date" && $value == "") - continue; - if($key == "depart_date" && $value == "") - continue; - if($key == "referred_by" && $value == "") - { - $tmp[] = $key; - $tmp_val[] = "NULL"; - continue; - } - if($key == "unit_size" && $value == "") - { - $tmp[] = $key; - $tmp_val[] = "NULL"; - continue; - } - $tmp[] = $key; - $tmp_val[] = "'$value'"; - } - $tmp = implode($tmp,","); - $tmp_val = implode($tmp_val,","); - $date = date("m/d/Y"); - $query = "INSERT INTO contact (create_date,$tmp) VALUES ('$date',$tmp_val)"; - $DB->db_exec($query); - $DB->db_close(); - //echo $query; - // mail part - foreach($_POST as $key=>$value) - { - if($key == "SUBMIT") - { - continue; - } - if($key == "interest") - { - $interest = $GLOBALS['interest2'][$value]; - $body .= $GLOBALS['fields'][$key]."\t$interest\n"; - } - if($key == "referred_by") - { - $referred = $GLOBALS['referred_by2'][$value]; - $body .= $GLOBALS['fields'][$key]."\t$referred\n"; - } - elseif($key == "unit_size") - { - $unit = $GLOBALS['unit_size2'][$value]; - $body .= $GLOBALS['fields'][$key]."\t$unit\n"; - } - elseif($key == "mail_ok") - { - if($value == 't') - $body .= "Yes I would like email\n"; - } - elseif($value != "") - { - $body .= $GLOBALS['fields'][$key]."\t$value\n"; - } - } - $subject = "You have received a reservation request!"; - $headers = "Reply-To: ".REPLY_TO."\n"; - mail(OWNER_EMAIL,$subject,$body,$headers); - echo $GLOBALS["THANKYOU_TEXT"]; - return(true); - } - -} -function show_form( $errors = NULL ) -{ - $unit = build_select($GLOBALS['unit_size2'],"unit_size"); - $referred = build_select($GLOBALS['referred_by2'],"referred_by"); - $intr = build_checkbox($GLOBALS['interest2']); - - echo ' - -

*=Required Form Fields

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* First - Name: - - - '.$errors["fname"].' -
Last - Name: - - '.$errors["lname"].' -
* Email - Address: - - '.$errors["email"].' -
Address: - - - '.$errors["address"].' -
City: - - - '.$errors["city"].' -
State: - - - '.$errors["state"].' -
Zip: - - - '.$errors["zip"].' -
Phone: - - - '.$errors["city"].' -
Date - Requested From: - - '.$errors["arrive_date"].' - (dd/mm/yy)
Date - Requested To: - - '.$errors["depart_date"].' - (dd/mm/yy)
Unit - Size: '.$unit.' - '.$errors["unit_size"].' -
- * How did you hear about
Trout Creek?
'.$referred.' - '.$errors["referred_by"].' -
- If other, please specify: - - '.$errors["other"].' -
- Let us know what you are interested in: '.$intr.' - '.$errors["interest"].' -
- Additional Questions: - - '.$errors["questions"].' -
- Please notify me of specials and offers. - - Yes - No -

-
- -
- Note: This is a reservation request only. It does not guarantee - a reservation.
-
- '; -} - -if(!$_POST){ - show_form(); -} -else{ - if(is_array($errors = process_form($_POST))){ - show_form($errors); - } -} - - +$cf = new Toolkit_Contacts_ContactUs( + Toolkit_Database::getInstance(), + 'contact_form', + 'post', + BASE_URL . 'index.php?catid=32' +); +$cf->configureForm(); +$cf->useCaptcha(true); +echo $cf->toHtml(); ?>