From: Steve Sutton Date: Thu, 5 Mar 2015 17:14:59 +0000 (-0500) Subject: forms X-Git-Tag: v1.0.0^2~17 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=e03c3ef8544334dbaba52d511b962fd07349f263;p=web%2FGaylordGolfMecca.git forms Working on passport form --- diff --git a/Toolkit/Contacts/Admin/EditContact.php b/Toolkit/Contacts/Admin/EditContact.php index 92f5b8c..9ac7a12 100644 --- a/Toolkit/Contacts/Admin/EditContact.php +++ b/Toolkit/Contacts/Admin/EditContact.php @@ -544,6 +544,14 @@ class Toolkit_Contacts_Admin_EditContact 'opts' => 'Yes', 'val' => array(0, 1) ); + $e[] = array( + 'type' => 'advcheckbox', + 'req' => false, + 'name' => 'golfvacation', + 'display' => '', + 'opts' => 'Golf Vacation Planner', + 'val' => array(0, 1) + ); if (is_array($this->interestsGroups)) { foreach ($this->interestsGroups as $group => $gData) { $this->myGroups[] = $gData; diff --git a/Toolkit/Contacts/ContactUs.php b/Toolkit/Contacts/ContactUs.php index 09857ab..caf773b 100755 --- a/Toolkit/Contacts/ContactUs.php +++ b/Toolkit/Contacts/ContactUs.php @@ -1181,7 +1181,7 @@ class Toolkit_Contacts_ContactUs } return $output; } - + /** * Return the existing contact/customer contact_type * diff --git a/Toolkit/Contacts/Database/tables/contact.sql b/Toolkit/Contacts/Database/tables/contact.sql index fd43ab4..cf60465 100644 --- a/Toolkit/Contacts/Database/tables/contact.sql +++ b/Toolkit/Contacts/Database/tables/contact.sql @@ -32,6 +32,10 @@ CREATE TABLE contacts.contact verify_password text, gift_cert BOOLEAN DEFAULT FALSE, members BOOLEAN DEFAULT FALSE, + big_giveaway BOOLEAN DEFAULT FALSE, + giveaway BOOLEAN DEFAULT FALSE, + eclub BOOLEAN DEFAULT FALSE, + golfvacation BOOLEAN DEFAULT FALSE, PRIMARY KEY (id)); CREATE INDEX contact_create_date_indx ON contacts.contact USING btree(create_date); diff --git a/Toolkit/Contacts/ENewsSignup.php b/Toolkit/Contacts/ENewsSignup.php index c85873f..28dbba0 100755 --- a/Toolkit/Contacts/ENewsSignup.php +++ b/Toolkit/Contacts/ENewsSignup.php @@ -118,7 +118,7 @@ class Toolkit_Contacts_ENewsSignup $attributes, $trackSubmit ); - $this->email = false;//ENEWS_EMAIL; + $this->email = ENEWS_EMAIL; } /** @@ -132,9 +132,9 @@ class Toolkit_Contacts_ENewsSignup public function configureConstants() { $constants = array( - 'user_agent' => $_SERVER['HTTP_USER_AGENT'], + 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'remote_addr' => $_SERVER['REMOTE_ADDR'], - 'mail_ok' => 1 + 'mail_ok' => 1 ); $this->setupConstants($constants); } diff --git a/Toolkit/Contacts/PassPort.php b/Toolkit/Contacts/PassPort.php index 493e441..3fe3884 100755 --- a/Toolkit/Contacts/PassPort.php +++ b/Toolkit/Contacts/PassPort.php @@ -153,6 +153,11 @@ class Toolkit_Contacts_PassPort 'req' => false, 'name' => 'remote_addr' ); + $e[] = array( + 'type' => 'hidden', + 'req' => false, + 'name' => 'mail_ok', + ); $e[] = array( 'type' => 'header', 'name' => 'firstHdr_rmv', @@ -256,20 +261,16 @@ class Toolkit_Contacts_PassPort 'req' => true, 'name' => 'qty', 'display' => 'Passports', - 'opts' => array(''=>'') + $qty + 'opts' => array(''=>'') + $qty, + 'att' => array('style' => 'width: 70px;margin-left: 50px;') ); $e[] = array( 'type' => 'static', 'req' => false, - 'name' => 'postage', - 'display' => 'Postage and Handling $3.00' - ); - $e[] = array( - 'type' => 'text', - 'req' => false, - 'name' => 'total_price', - 'display' => 'Total Price', - 'opts' => array('id' => 'passport_total') + 'display' => '' + . '' + . '' + . '
Postage and Handling
Total Price
' ); if ($this->hasAuthNetAcc) { @@ -383,17 +384,6 @@ class Toolkit_Contacts_PassPort 'reset' => true, 'force' => false ); - /* - $r[] = array( - 'element' => 'state', - 'message' => 'ERROR: Invalid State!', - 'type' => 'numeric', - 'format' => null, - 'validation' => $this->validationType, - 'reset' => true, - 'force' => false - ); - */ $r[] = array( 'element' => 'phone', 'message' => 'ERROR: Invalid number (xxx) xxx-xxxx!', @@ -412,17 +402,6 @@ class Toolkit_Contacts_PassPort 'reset' => true, 'force' => false ); - /* - $r[] = array( - 'element' => 'zip', - 'message' => 'ERROR: Invalid Zip!', - 'type' => 'zip', - 'format' => array('requireDBCheck' => false), - 'validation' => $this->validationType, - 'reset' => true, - 'force' => false - ); - */ $r[] = array( 'element' => 'mail_ok', 'message' => 'ERROR: Invalid Value!', @@ -460,6 +439,15 @@ class Toolkit_Contacts_PassPort 'reset' => false, 'force' => false ); + $r[] = array( + 'element' => 'cc_exp', + 'message' => 'ERROR: Card has expired!', + 'type' => 'callback', + 'format' => array(&$this, 'checkExpireDate'), + 'validation' => $this->validationType, + 'reset' => false, + 'force' => false + ); } $this->setupRules($r); @@ -546,6 +534,18 @@ class Toolkit_Contacts_PassPort } // }}} + public function checkExpireDate($value) + { + $month = filter_var($value['m'], FILTER_VALIDATE_INT); + $year = filter_var($value['Y'], FILTER_VALIDATE_INT); + if (!($month && $year)) { + return false; + } + $firstDay = mktime(0, 0, 0, $month, 1, $year); + $lastDay = mktime(0, 0, 0, $month, date('t', $firstDay), $year); + $today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); + return ($today < $lastDay); + } // {{{ checkNumber() /** @@ -571,4 +571,173 @@ class Toolkit_Contacts_PassPort } // }}} + // {{{ processAuthNet() + + /** + * Send payment to auth.net + * + * Test Cards + * Card Number Card Type + * =============== =============== + * 370000000000002 American Express + * 6011000000000012 Discover Card + * 5424000000000015 MasterCard + * 4000000000000000 Visa + * + * @param array $values Submitted values from the form + * + * @return array Auth.net response + * @access protected + */ + protected function processAuthNet($values) + { + $authNetLoginId = AUTH_LOGIN; + $authNetTranKey = AUTH_TRAN_KEY; + $authNetUrl = "https://secure.authorize.net/gateway/transact.dll"; + + $authNetValues = array( + 'x_login' => $authNetLoginId, + 'x_version' => '3.1', + 'x_delim_char' => '|', + 'x_delim_data' => 'TRUE', + 'x_type' => 'AUTH_CAPTURE', + 'x_method' => 'CC', + "x_test_request" => DEVELOPMENT ? "TRUE" : "FALSE", + 'x_tran_key' => $authNetTranKey, + 'x_relay_response' => 'FALSE', + 'x_card_num' => $values['cc_num'], + 'x_exp_date' => implode('/', $values['cc_exp']), + 'x_amount' => $values['total_price'], + 'x_first_name' => $values['fname'], + 'x_last_name' => $values['lname'], + ); + + $fields = ''; + foreach ($authNetValues as $i => $j) { + $fields .= "$i=" . urlencode($j) . '&'; + } + + $ch = curl_init($authNetUrl); + // set to 0 to elimindate header info from response + curl_setopt($ch, CURLOPT_HEADER, 0); + // Returns response data instead of TRUE(1) + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + // Use HTTP POST to send form data + curl_setopt($ch, CURLOPT_POSTFIELDS, rtrim($fields, "& ")); + // Uncomment this line if you get no gateway response. ### + // curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); + // Execute post and get results + $resp = curl_exec($ch); + curl_close($ch); + + $res = explode('|', $resp); + return $res; + } + + // }}} + public function processData($values) + { + $res = parent::processData($values); + if ($res) { + $res2 = $this->processAuthNet($values); +// echo '
'.print_r($res2, true).'
';exit; + if (is_array($res2) && !empty($res2)) { + if ($res2[0] == 1) { + // CC was Accepted. + return true; + } elseif ($res2[0] == 2) { + // CC was Declined. + return 2; + } else { + // There was a CC processing error. + return $res2[0]; + } + } else { + // There was a CC processing error. + return false; + } + } + echo '
'.print_r($res, true).'
'; + echo '
'.print_r($values, true).'
'; + exit; + + } + + /** + * Handles how to display the current step the user is at in the form + * + * destroying and resetting the captcha value dis-allows someone from + * re-sending a form on a previous captcha. + * + * @return string form HTML state + * @access public + */ + public function toHtml() + { + if ($this->validate()) { + $res = $this->process( + array(&$this, 'processData'), + $this->mergeFiles + ); + if ($res === true) { + $this->cleanForm(); + $this->freeze(); + $this->emailOwner(); + if (method_exists($this, 'confirmation')) { + $this->confirmation(); + } + $output = $this->successMsg; + $rem = array( + 'cc_cvv', + 'cc_type', + 'captcha_question', + ); + foreach ($rem as $i) { + if ($this->elementExists($i)) { + $this->removeElement($i); + } + } + + if ($this->elementExists('cc_num')) { + // Obscure th CC Num so its not displayed. + $e = $this->getElement('cc_num'); + $ccNum = $e->getValue(); + $newCCNum = preg_replace( + '/\d/', + '*', + $ccNum, + strlen($ccNum) - 4 + ); + $e->setValue($newCCNum); + } + } elseif ($res == 2) { + $this->_errors['cc_num'] = 'ERROR: Your credit card has been declined!'; + $this->captchaQuestion->destroy(); + $this->captchaAnswer->setValue(''); + $this->setupRenderers(); + $output = $this->errorMsg; + $output .= $this->template->bufferedOutputObject($this->view); + } else { + $this->_errors['cc_num'] = 'ERROR: There was an error processing your credit card!'; + $this->captchaQuestion->destroy(); + $this->captchaAnswer->setValue(''); + $this->setupRenderers(); + $output = $this->errorMsg; + $output .= $this->template->bufferedOutputObject($this->view); + } + $this->sent = true; + } elseif ($this->isSubmitted()) { + $this->captchaQuestion->destroy(); + $this->captchaAnswer->setValue(''); + $this->setupRenderers(); + $output = $this->errorMsg; + $output .= $this->template->bufferedOutputObject($this->view); + } else { + $this->captchaQuestion->destroy(); + $this->captchaAnswer->setValue(''); + $this->setupRenderers(); + $output .= $this->template->bufferedOutputObject($this->view); + } + return $output; + } } diff --git a/Toolkit/Contacts/VacationPlanner.php b/Toolkit/Contacts/VacationPlanner.php index b55572d..3cd416d 100644 --- a/Toolkit/Contacts/VacationPlanner.php +++ b/Toolkit/Contacts/VacationPlanner.php @@ -132,8 +132,9 @@ class Toolkit_Contacts_VacationPlanner public function configureConstants() { $constants = array( - 'user_agent' => $_SERVER['HTTP_USER_AGENT'], - 'remote_addr' => $_SERVER['REMOTE_ADDR'] + 'user_agent' => $_SERVER['HTTP_USER_AGENT'], + 'remote_addr' => $_SERVER['REMOTE_ADDR'], + 'mail_ok' => 1 ); $this->setupConstants($constants); } diff --git a/Toolkit/Contacts/templates/contactForm.html b/Toolkit/Contacts/templates/contactForm.html index da3e1bb..60f03df 100644 --- a/Toolkit/Contacts/templates/contactForm.html +++ b/Toolkit/Contacts/templates/contactForm.html @@ -30,7 +30,6 @@ {elem.html:h} {if:elem.error}{elem.error}{end:} - {else:} {if:elem.isType(#CAPTCHA_Image#)} {if:elem.required}