* @access protected
*/
protected $successMsg = '
+ <style type="text/css">
+ #category {display:none;}
+ .listings {display:none;}
+ </style>
<div id="form-success-top">
- Thank you for your questions or comments!
+ Thank you for the reservation request!
</div>';
/**
$this->siteName = SITENAME;
}
if (empty($this->subject)) {
- $this->subject = 'Contact Request from website ' . SITENAME;
+ $this->subject = 'You have received a reservation request';
}
/**
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',
);
$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;
);
}
}
- */
+
+ $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',
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));
$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
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) {
try {
// Get all the existing contact type data
+ /*
$sql = "
SELECT contact_type
FROM {$this->tableName}
if (!in_array($this->contactType, $existingTypes)) {
$values['contact_type'] = "$cType{$this->contactType}:";
}
+ */
$sql = Toolkit_Common::createSQLUpdate(
$this->tableName,
} catch (PDOException $e) {
return Toolkit_Common::handleError($e);
}
+
}
// }}}
<?php
-//include_once("classes/class_db.inc");
-$int_qs = "select * from contact_inq order by pos;";
-
-if( $data = $this->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 = "<br><br><br>
- <h2>Thank you for the reservation request!</h2>
-";
-$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 = '<select name="'.$name.'"';
- if($multiple == 1)
- {
- $select .= ' multiple size="10"';
- }
- $select .= '>';
- $select .= '<option value="">Please select</option>';
- foreach($array as $key=>$value)
- {
- $select .= '<option value="'.$key.'">'.$value.'</option>';
- }
- $select .= '</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 .= "<table border=0><tr>";
- $count = 1;
- foreach($int_array as $key=>$value)
- {
- $interest .= "<td>";
- $interest .= "<input type=\"checkbox\" name=\"interest[$count]\" value=\"$key\"";
- $interest .= "><font size=\"2\" face=\"arial, helvetica\">$value</font><br>";
- $interest .= "</td>";
- if($count%2==0 && $count != $padding)
- {
- $interest .= "</tr><tr>";
- }
- elseif($count == $padding)
- {
- $interest .= "</tr>";
- }
- $count++;
- }
- $interest .= "</tr></TABLE>";
- return($interest);
-}
-function process_form( $_POST )
-{
- extract($_POST);
- foreach($_POST as $key=>$value)
- {
- if($key == "email" && ( !GLM_TEMPLATE::valid_email($value) || $value == "" ))
- {
- $errors["email"] = "<div style=\"color:red;\">your email is not valid or empty!</div>";
- }
- if($key == "fname" && $value == "" )
- {
- $errors["fname"] = "<div style=\"color:red;\">your name is empty!</div>";
- }
- if($key == "referred_by" && $value == "")
- {
- $errors["referred_by"] = "<div style=\"color:red;\">Required Field!</div>";
- }
- 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 '
- <!-- form table begin -->
- <p>*=Required Form Fields</p>
- <FORM METHOD="POST" ACTION="'.$_SERVER["PHP_SELF"].'?catid='.$_GET['catid'].'">
- <table cellpadding=3 cellspacing="3" border="0" width="100%" align="left">
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">* First
- Name:</font></td>
- <td>
- <input type="hidden" name="catid" value="'.$_GET['catid'].'">
- <input type="TEXT" name="fname" size=25>
- '.$errors["fname"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">Last
- Name: </font></td>
- <td>
- <input type="TEXT" name="lname" size=25>
- '.$errors["lname"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">* Email
- Address: </font></td>
- <td>
- <input type="TEXT" name="email" size=25>
- '.$errors["email"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">Address:
- </font></td>
- <td>
- <input type="TEXT" name="address" size=25>
- '.$errors["address"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">City:
- </font></td>
- <td>
- <input type="TEXT" name="city" size=25>
- '.$errors["city"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">State:
- </font></td>
- <td>
- <input type="TEXT" name="state" size=25>
- '.$errors["state"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">Zip:
- </font></td>
- <td>
- <input type="TEXT" name="zip" size=25>
- '.$errors["zip"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2"
- face="arial, helvetica">Phone:
- </font></td>
- <td>
- <input type="TEXT" name="phone" size=25>
- '.$errors["city"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">Date
- Requested From: </font></td>
- <td>
- <input type="TEXT" name="arrive_date" size=15>
- '.$errors["arrive_date"].'
- <font face="Arial, Helvetica, sans-serif" size="1">(dd/mm/yy)</font></td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">Date
- Requested To: </font></td>
- <td>
- <input type="TEXT" name="depart_date" size=15>
- '.$errors["depart_date"].'
- <font face="Arial, Helvetica, sans-serif" size="1">(dd/mm/yy)</font></td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">Unit
- Size: </font></td>
- <td>'.$unit.'
- '.$errors["unit_size"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">
- * How did you hear about<br> Trout Creek?</font> </td>
- <td>'.$referred.'
- '.$errors["referred_by"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font face="Arial, Helvetica, sans-serif" size="2">
- <B>If other, please specify:</B></font></td>
- <td>
- <textarea name="other" cols="25"></textarea>
- '.$errors["other"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">
- Let us know what you are interested in: </font> </td>
- <td>'.$intr.'
- '.$errors["interest"].'
- </td>
- </tr>
- <tr>
- <td align=right width="175"><font size="2" face="arial, helvetica">
- Additional Questions: </font></td>
- <td>
- <textarea name="questions" rows="3" cols="25"></textarea>
- '.$errors["questions"].'
- </td>
- </tr>
- <tr>
- <td colspan="2" align="left" width="175"><font size="2" face="arial, helvetica">
- Please notify me of specials and offers.
- </font>
- <input type="radio" name="mail_ok" value="t" checked><font size="2" face="arial, helvetica">Yes</font>
- <input type="radio" name="mail_ok" value="f"><font size="2" face="arial, helvetica">No</font>
- </td>
- </tr>
- <tr>
- <td><br>
- </td>
- <td align=left>
- <input type="SUBMIT" value="Place Request" name="SUBMIT">
- </td>
- </tr>
- <tr>
- <td colspan=2 align=left><font size="2" face="arial, helvetica">
- Note: This is a reservation request only. It does not guarantee
- a reservation. </font></td>
- </tr>
- </table>
- </form>
- <!-- form table end -->';
-}
-
-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();
?>