update forms
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 9 Feb 2010 15:09:40 +0000 (15:09 +0000)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 9 Feb 2010 15:09:40 +0000 (15:09 +0000)
Toolkit/Contacts/ContactUs.php
Toolkit/Contacts/ENews.php [new file with mode: 0755]

index 571304e..3d63c98 100755 (executable)
@@ -484,6 +484,33 @@ class Toolkit_Contacts_ContactUs
                        'display' => 'Phone:'
                );
 
+               $e[] = array(
+                       'type'    => 'date',
+                       'req'     => false,
+                       'name'    => 'arrive_date',
+            'display' => 'Date Requested From:',
+            'opts'    => array(
+                    'language'       => 'en',
+                    'format'         => 'mdY',
+                    'minYear'        => date('Y'),
+                    'maxYear'        => date('Y') + 3,
+                    'addEmptyOption' => true
+                )
+               );
+               $e[] = array(
+                       'type'    => 'date',
+                       'req'     => false,
+                       'name'    => 'depart_date',
+                       'display' => 'Date Requested To:',
+            'opts'    => array(
+                    'language'       => 'en',
+                    'format'         => 'mdY',
+                    'minYear'        => date('Y'),
+                    'maxYear'        => date('Y') + 3,
+                    'addEmptyOption' => true
+                )
+               );
+
                $e[] = array(
                        'type'    => 'select',
                        'req'     => false,
@@ -522,7 +549,7 @@ class Toolkit_Contacts_ContactUs
                $e[] = array(
                        'type'    => 'textarea',
                        'req'     => false,
-                       'name'    => 'comments',
+                       'name'    => 'questions',
                        'display' => 'Additional Questions:'
                );
                $e[] = array(
@@ -901,7 +928,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));
@@ -970,6 +997,35 @@ class Toolkit_Contacts_ContactUs
             $streamSend->addContact($values);
         }
         $values['unit_size'] = (!$values['unit_size']) ? null: $values['unit_size'];
+        // prep the dates
+        if ($values['arrive_date']) {
+            if (
+                $values['arrive_date']['m'] &&
+                $values['arrive_date']['d'] &&
+                $values['arrive_date']['Y'] 
+            ) {
+                $values['arrive_date'] = 
+                    $values['arrive_date']['m'] . '/'
+                    . $values['arrive_date']['d'] . '/'
+                    . $values['arrive_date']['Y'];
+            } else {
+                $values['arrive_date'] = null;
+            }
+        }
+        if ($values['depart_date']) {
+            if (
+                $values['depart_date']['m'] &&
+                $values['depart_date']['d'] &&
+                $values['depart_date']['Y'] 
+            ) {
+                $values['depart_date'] = 
+                    $values['depart_date']['m'] . '/'
+                    . $values['depart_date']['d'] . '/'
+                    . $values['depart_date']['Y'];
+            } else {
+                $values['depart_date'] = null;
+            }
+        }
 
         //  Check if we are updating an existing contact or not
         //  question: is this the best approach?  what if someone else
@@ -1113,7 +1169,6 @@ class Toolkit_Contacts_ContactUs
 
                try {
                        //      Get all the existing contact type data
-        /*
                        $sql = "
                                SELECT contact_type
                                  FROM {$this->tableName}
@@ -1129,7 +1184,6 @@ class Toolkit_Contacts_ContactUs
                        if (!in_array($this->contactType, $existingTypes)) {
                                $values['contact_type'] = "$cType{$this->contactType}:";
                        }
-        */
 
             $sql = Toolkit_Common::createSQLUpdate(
                 $this->tableName,
diff --git a/Toolkit/Contacts/ENews.php b/Toolkit/Contacts/ENews.php
new file mode 100755 (executable)
index 0000000..8d72416
--- /dev/null
@@ -0,0 +1,216 @@
+<?php
+//     vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
+
+/**
+ * File Doc Comment
+ *
+ * PHP version 5
+ *
+ * @category Contacts
+ * @package  Toolkit_Contacts
+ * @author   Jamie Kahgee <jamie.kahgee@gmail.com>
+ * @license     http://www.gaslightmedia.com Gaslightmedia
+ * @version  CVS: $Id: ENews.php,v 1.1 2010/01/17 15:29:11 jamie Exp $
+ * @link        http://demo.gaslightmedia.com
+ */
+
+/**
+ * GLM Contact Us form
+ *
+ * This form handles rendering and processing the contact us form.
+ * Controls the email functionality of the form, whether the client
+ * has a contact DB to store contact records and how to insert/update
+ * submitted form values.
+ *
+ * @category  Contacts
+ * @package   Toolkit_Contacts
+ * @author    Jamie Kahgee <jamie.kahgee@gmail.com>
+ * @copyright 2009 Jamie Kahgee
+ * @license   http://www.gaslightmedia.com Gaslightmedia
+ * @link      http://demo.gaslightmedia.com
+ * @see       Toolkit_FormBuilder
+ */
+class Toolkit_Contacts_ENews
+    extends Toolkit_Contacts_ContactUs
+{
+       //      {{{     properties
+
+       /**
+        * Contact type to be inserted into the DB as when the form is submitted
+        *
+        * This property is only valid when the [hasContactDB] property is set
+        * to true.
+        *
+        * N.B.
+        * If you subclass this class out to other forms that are
+        * inserted into the contact db, be sure to make each one of their
+        * contactType properties unique.  We don't check for duplicates.
+        *
+        * @var string
+        * @access protected
+        */
+       protected $contactType = '2';
+
+    /**
+        * Email subject and <h1> header in email
+        *
+        * It gets set in the constructor if you leave empty here, but you
+        * can set it to something different here to override that if you desire.
+        *
+     * @var    string
+     * @access protected
+     */
+       public $subject = 'ENews Signup for Trout Creek';
+
+    /**
+     * Message to display if the form is successfully submitted
+        *
+     * @var    string
+     * @access protected
+     */
+       protected $successMsg = '
+        <style type="text/css">
+        #category {display:none;}
+        .listings {display:none;}
+        </style>
+               <div id="form-success-top">
+            Thank you for signing up for our ENews!
+               </div>';
+
+       //      }}}
+    
+       //      {{{     configureElements()
+
+    /**
+     * Form element definitions
+     *
+     * @return void
+     * @access public
+     */
+       public function configureElements()
+       {
+               $e = array();
+               $this->setInterestFields();
+               //      Grouped Elements are defined here.
+               $this->interestsGroups =& $this->getInterestFields();
+
+               //      All Elements are created here.  This includes group element definitions.
+               $e[] = array(
+                       'type' => 'hidden',
+                       'req'  => false,
+                       'name' => 'user_agent'
+               );
+               $e[] = array(
+                       'type' => 'hidden',
+                       'req'  => false,
+                       'name' => 'remote_addr'
+               );
+               $e[] = array(
+                       'type'    => 'text',
+                       'req'     => false,
+                       'name'    => 'fname',
+                       'display' => 'First Name:'
+               );
+               $e[] = array(
+                       'type'    => 'text',
+                       'req'     => false,
+                       'name'    => 'lname',
+                       'display' => 'Last Name:'
+               );
+               $e[] = array(
+                       'type'    => 'text',
+                       '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'    => 'address',
+                       'display' => 'Address:'
+               );
+               $e[] = array(
+                       'type'    => 'text',
+                       'req'     => false,
+                       'name'    => 'city',
+                       'display' => 'City:'
+               );
+        $e[] = array(
+                       'type'    => 'select',
+                       'req'     => false,
+                       'name'    => 'state',
+                       'display' => 'State/Province:',
+                       'opts'    => $GLOBALS['states']
+               );
+        $e[] = array(
+                       'type'    => 'text',
+                       'req'     => false,
+                       'name'    => 'zip',
+                       'display' => 'ZIP/Postal Code:'
+               );
+               $e[] = array(
+                       'type'    => 'text',
+                       'req'     => false,
+                       'name'    => 'phone',
+                       'display' => 'Phone:'
+               );
+
+        if (is_array($this->interestsGroups)) {
+            foreach ($this->interestsGroups as $group => $gData) {
+                $this->myGroups[] = $gData;
+                $e[] = array(
+                    'type'       => 'group',
+                    'req'        => false,
+                    'name'       => 'interest['.$group.']',
+                    'group'         => $gData,
+                    'label'      => $group,
+                    'seperator'  => ' ',
+                    'appendName' => true
+                );
+            }
+        }
+
+               $e[] = array(
+                       'type'    => 'textarea',
+                       'req'     => false,
+                       'name'    => 'questions',
+                       'display' => 'Additional Questions:'
+               );
+               $e[] = array(
+                       'type'    => 'hidden',
+                       'req'     => false,
+                       'name'    => 'mail_ok',
+                       'val'     =>  1
+               );
+               $e[] = array(
+                       'type'    => 'CAPTCHA_Image',
+                       'req'     => false,
+                       'name'    => 'captcha_question',
+                       'display' => 'Verification code:',
+                       'opts'    => $this->captchaOptions
+               );
+               $e[] = array(
+                       'type'    => 'text',
+                       'req'     => true,
+                       'name'    => 'captcha_rmv',
+                       'display' => 'Enter verification code:'
+               );
+               $e[] = array(
+                       'type'    => 'submit',
+                       'req'     => false,
+                       'name'    => 'submit_rmv',
+                       'display' => 'Submit Form'
+               );
+
+               $this->setupElements($e);
+       }
+
+       //      }}}
+}
+?>