Form work for site
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 5 May 2014 19:37:14 +0000 (19:37 +0000)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 5 May 2014 19:37:14 +0000 (19:37 +0000)
Two Forms created
Temp storage form
Service form

Toolkit/Contacts/ContactUs.php
Toolkit/Contacts/ServiceRequest.php
Toolkit/Contacts/TempStorageQuickLaunch.php
Toolkit/Contacts/templates/contactForm.html
css/contactform.css
static/19.phtml [new file with mode: 0644]

index 835feab..4905702 100755 (executable)
@@ -779,6 +779,32 @@ class Toolkit_Contacts_ContactUs
         $page->lname       = $this->getSubmitValue('lname');
         $page->formData    = $this->formData;
 
+        //var_dump($page->formData);exit;
+        if (   isset($this->newWorkRequest)
+            && is_array($this->newWorkRequest)
+            && !empty($this->newWorkRequest)
+        ) {
+            //var_dump($page->formData['work_requested']);
+            //    Clean up the interests so they will look nice in the email
+            $page->formData['work_requested']['nowrap']  = 'nowrap';
+            $page->formData['work_requested']['element'] = null;
+            //var_dump($page->formData['work_requested']);
+
+            //var_dump($this->workTypes);
+            foreach ($this->newWorkRequest as $group => $elements) {
+                //var_dump($elements);
+                $page->formData['work_requested['.$group.']']['label'] = $group;
+                foreach ($elements as $e => $vale) {
+                    $workRequest[] = $e;
+                }
+                $page->formData['work_requested['.$group.']']['element']
+                    = implode("<br>", $workRequest);
+                unset($workRequest);
+            }
+            //var_dump($page->formData);
+            //exit;
+        }
+
         if (   isset($this->newInterest)
             && is_array($this->newInterest)
             && !empty($this->newInterest)
@@ -798,6 +824,18 @@ class Toolkit_Contacts_ContactUs
             }
         }
 
+        if ($this->elementExists('service_request_yes')
+            && $page->formData['service_request_yes']['element']
+        ) {
+            $page->formData['service_request_yes']['label'] = 'Are you also requesting launch Service';
+            $page->formData['service_request_yes']['element'] = 'Yes';
+        }
+        if ($this->elementExists('service_request_no')
+            && $page->formData['service_request_no']['element']
+        ) {
+            $page->formData['service_request_no']['label'] = 'Are you also requesting launch Service';
+            $page->formData['service_request_no']['element'] = 'No';
+        }
         if ($this->elementExists('mail_ok')) {
             //    Clean up the mail_ok flag so its human readable
             $page->formData['mail_ok']['label'] = 'Emails';
@@ -956,7 +994,8 @@ class Toolkit_Contacts_ContactUs
         $existingContact = $this->contactExists($values['email']);
         // setup newInterest aray with the interest values
         // because their grouped can't be found with getElement('interest')
-        $this->newInterest = $values['interest'];
+        $this->newInterest    = $values['interest'];
+        $this->newWorkRequest = $values['work_requested'];
         // update create_date for this contact
         $values['create_date'] = date('m/d/Y');
 
@@ -1082,7 +1121,7 @@ class Toolkit_Contacts_ContactUs
     public function toHtml()
     {
         if ($this->validate()) {
-            $this->captchaQuestion->destroy();
+            //$this->captchaQuestion->destroy();
             $this->cleanForm();
             $this->setupRenderers();
             if ($this->process(array(&$this, 'processData'), $this->mergeFiles)) {
@@ -1092,14 +1131,14 @@ class Toolkit_Contacts_ContactUs
             }
             $this->sent = true;
         } elseif ($this->isSubmitted()) {
-            $this->captchaQuestion->destroy();
-            $this->captchaAnswer->setValue('');
+            //$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->captchaQuestion->destroy();
+            //$this->captchaAnswer->setValue('');
             $this->setupRenderers();
             $output .= $this->template->bufferedOutputObject($this->view);
         }
index 175d1b7..7233a3e 100755 (executable)
@@ -254,14 +254,14 @@ class Toolkit_Contacts_ServiceRequest
             'display' => 'Name of Vessel'
         );
         $engTypes = array(
-            ''                 => 'Select Engine Type',
-            'group1'           => '<span>Outboard</span>',
-            'Mercury'          => 'Mercury',
+            ''                   => 'Select Engine Type',
+            'group1'             => '<span>Outboard</span>',
+            'Mercury'            => 'Mercury',
             'Evinrude / Johnson' => 'Evinrude / Johnson',
-            'group2'           => '<span>Stern Drive</span>',
-            'Mercruiser'       => 'Mercruiser',
-            'group3'           => '<span>Sail Boats</span>',
-            'N/A'              => 'Not Applicable'
+            'group2'             => '<span>Stern Drive</span>',
+            'Mercruiser'         => 'Mercruiser',
+            'group3'             => '<span>Sail Boats</span>',
+            'N/A'                => 'Not Applicable'
         );
         $e[] = array(
             'type'    => 'select3',
@@ -270,61 +270,180 @@ class Toolkit_Contacts_ServiceRequest
             'display' => 'Engine Type',
             'opts'    => $engTypes
         );
-        $serTypes = array(
-            ''       => '',
-            'group1' => '<span>Yes</span>',
-            'Yes - Anticipated Arrival Date' => 'Anticipated Arrival Date',
-            'group2' => '<span>No</span>',
-            'No - Date vessel will be delivered to CM facility'
-                => 'Date vessel will be delivered to CM facility',
-            'No - Desired Completion Date'  => 'Desired Completion Date',
+        $e[] = array(
+            'type'    => 'header',
+            'name'    => 'serviceHdr_rmv',
+            'display' => 'Are you also requesting launch service?'
         );
         $e[] = array(
-            'type'    => 'select3',
-            'req'     => true,
-            'name'    => 'service_request',
-            'display' => 'Are you also requesting launch service?',
-            'opts'    => $serTypes
+            'type'    => 'advcheckbox',
+            'req'     => false,
+            'name'    => 'service_request_yes',
+            'display' => '',
+            'opts'    => 'Yes',
+            'val'     => array(0, 1)
         );
-        $workTypes = array(
-            ''       => '',
-            'group1' => '<span>Cleaning and Upkeep</span>',
-                'Cleaning and Upkeep - Wash & Vacuum' => 'Wash & Vacuum',
-                'Cleaning and Upkeep - Deck & Hull Wax Only' => 'Deck & Hull Wax Only',
-                'Cleaning and Upkeep - Paint Bottom (with anti-fouling paint)'
-                    => 'Paint Bottom (with anti-fouling paint)',
-                'Cleaning and Upkeep - Clear & Oil Teak' => 'Clear & Oil Teak',
-                'Cleaning and Upkeep - Repair Navigation Lights, Blower, bilge pump, etc. (please specify below)'
-                    => 'Repair Navigation Lights, Blower, bilge pump, etc. (please specify below)',
-                'Cleaning and Upkeep - Check Fire Extinguisher & Replace if Necessary'
-                    => 'Check Fire Extinguisher & Replace if Necessary',
-                'Cleaning and Upkeep - Detail Cabin (Larger Vessels)' => 'Detail Cabin (Larger Vessels)',
-            'group2' => '<span>Engine</span>',
-                'Engine - Basic Check (Hoses, Steering, Battery, Fuel Tanks, etc.)'
-                    => 'Basic Check (Hoses, Steering, Battery, Fuel Tanks, etc.)',
-                'Engine - Complete Ignition Tune-Up (Cap, Rotor, Plugs & Wires - if necessary)'
-                    => 'Complete Ignition Tune-Up (Cap, Rotor, Plugs & Wires - if necessary)',
-                'Engine - Change Engine Oil & Filter (and water separator if necessary)'
-                    => 'Change Engine Oil & Filter (and water separator if necessary)',
-                'Engine - Extensive Test run (15 to 20 minutes)'
-                    => 'Extensive Test run (15 to 20 minutes)',
-            'group2' => '<span>Outdrive & Gearcase</span>',
-                'Outdrive & Gearcase - Lube U-Joints'  => 'Lube U-Joints',
-                'Outdrive & Gearcase - Change Water impellor'  => 'Change Water impellor',
-                'Outdrive & Gearcase - Check Trim & Tilt'  => 'Check Trim & Tilt',
-                'Outdrive & Gearcase - Check Boots'  => 'Check Boots',
-                'Outdrive & Gearcase - Weld Skeg'  => 'Weld Skeg',
-                'Outdrive & Gearcase - Replace Anodes'  => 'Replace Anodes',
-                'Outdrive & Gearcase - Replace Upper Seals'  => 'Replace Upper Seals',
-                'Outdrive & Gearcase - Replace Lower Seals'  => 'Replace Lower Seals',
+        $e[] = array(
+            'type'    => 'text',
+            'req'     => false,
+            'name'    => 'arrival_date',
+            'display' => 'Anticipated Arrival Date'
         );
         $e[] = array(
-            'type'    => 'select3',
-            'req'     => true,
-            'name'    => 'work_requested',
-            'display' => 'Work Requested',
-            'opts'    => $workTypes
+            'type'    => 'advcheckbox',
+            'req'     => false,
+            'name'    => 'service_request_no',
+            'display' => '',
+            'opts'    => 'No',
+            'val'     => array(0, 1)
         );
+        $e[] = array(
+            'type'    => 'text',
+            'req'     => false,
+            'name'    => 'delivery_date',
+            'display' => 'Date vessel will be delivered to CM facility'
+        );
+        $e[] = array(
+            'type'    => 'text',
+            'req'     => false,
+            'name'    => 'completion_date',
+            'display' => 'Desired Completion Date'
+        );
+        $workTypes = array(
+            'Cleaning & Upkeep' => array(
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Wash & Vacuum',
+                    'opts' => 'Wash & Vacuum'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Deck & Hull Wax Only',
+                    'opts' => 'Deck & Hull Wax Only'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Paint Bottom (with anti-fouling paint)',
+                    'opts' => 'Paint Bottom (with anti-fouling paint)'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Clear & Oil Teak',
+                    'opts' => 'Clear & Oil Teak'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Repair Navigation Lights, Blower, bilge pump, etc. (please specify below)',
+                    'opts' => 'Repair Navigation Lights, Blower, bilge pump, etc. (please specify below)'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Check Fire Extinguisher & Replace if Necessary',
+                    'opts' => 'Check Fire Extinguisher & Replace if Necessary'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Detail Cabin (Larger Vessels)',
+                    'opts' => 'Detail Cabin (Larger Vessels)'
+                )
+            ),
+            'Engine' => array(
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Basic Check (Hoses, Steering, Battery, Fuel Tanks, etc.)',
+                    'opts' => 'Basic Check (Hoses, Steering, Battery, Fuel Tanks, etc.)'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Complete Ignition Tune-Up (Cap, Rotor, Plugs & Wires - if necessary)',
+                    'opts' => 'Complete Ignition Tune-Up (Cap, Rotor, Plugs & Wires - if necessary)'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Change Engine Oil & Filter (and water separator if necessary)',
+                    'opts' => 'Change Engine Oil & Filter (and water separator if necessary)'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Extensive Test run (15 to 20 minutes)',
+                    'opts' => 'Extensive Test run (15 to 20 minutes)'
+                ),
+            ),
+            'Outdrive & Gearcase' => array(
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Lube U-Joints',
+                    'opts' => 'Lube U-Joints'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Change Water impellor',
+                    'opts' => 'Change Water impellor'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Check Trim & Tilt',
+                    'opts' => 'Check Trim & Tilt'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Check Boots',
+                    'opts' => 'Check Boots'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Weld Skeg',
+                    'opts' => 'Weld Skeg'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Replace Anodes',
+                    'opts' => 'Replace Anodes'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Replace Upper Seals',
+                    'opts' => 'Replace Upper Seals'
+                ),
+                array(
+                    'type' => 'checkbox',
+                    'req'  => false,
+                    'name' => 'Replace Lower Seals',
+                    'opts' => 'Replace Lower Seals'
+                )
+            )
+        );
+        $this->workTypes = $workTypes;
+        //var_dump($workTypes);exit;
+        foreach ($workTypes as $groupName => $group) {
+            $e[] = array(
+                'type'       => 'group',
+                'req'        => false,
+                'name'       => 'work_requested['.$groupName.']',
+                'group'      => $group,
+                'label'      => '<b>'.$groupName.'</b>',
+                'seperator'  => '',
+                'appendName' => true
+            );
+        }
         $e[] = array(
             'type'    => 'textarea',
             'req'     => false,
@@ -352,6 +471,8 @@ class Toolkit_Contacts_ServiceRequest
         );
 
         $this->setupElements($e);
+        //echo '<pre>'.print_r($this, true).'</pre>';
+        //exit;
     }
 
     //    }}}
index 387eeb1..ea5c5d6 100755 (executable)
@@ -259,23 +259,51 @@ class Toolkit_Contacts_TempStorageQuickLaunch
             'name'    => 'make_and_model_of_vessel',
             'display' => 'Make and Model of Vessel'
         );
-        //$servTypes = array(
-            //''                 => 'Select Engine Type',
-            //'group1'           => '<span>Outboard</span>',
-            //'Mercury'          => 'Mercury',
-            //'Evinrude / Johnson' => 'Evinrude / Johnson',
-            //'group2'           => '<span>Stern Drive</span>',
-            //'Mercruiser'       => 'Mercruiser',
-            //'group3'           => '<span>Sail Boats</span>',
-            //'N/A'              => 'Not Applicable'
-        //);
-        //$e[] = array(
-            //'type'    => 'select3',
-            //'req'     => true,
-            //'name'    => 'service_required',
-            //'display' => 'Service Required',
-            //'opts'    => $servTypes
-        //);
+        $e[] = array(
+            'type'    => 'header',
+            'name'    => 'serviceHdr_rmv',
+            'display' => 'Service Required'
+        );
+        $e[] = array(
+            'type'    => 'text',
+            'req'     => false,
+            'name'    => 'arrival_date',
+            'display' => 'Vessel will be delivered to CM by'
+        );
+        $ownTrailer = array(
+            array(
+                'type' => 'radio',
+                'name' => 'have_own_trailer',
+                'opts' => 'Yes',
+                'att'  => 'Yes'
+            ),
+            array(
+                'type' => 'radio',
+                'name' => 'have_own_trailer',
+                'opts' => 'No',
+                'att'  => 'No'
+            )
+        );
+        $e[] = array(
+            'type'       => 'group',
+            'req'        => false,
+            'name'       => 'have_own_trailer',
+            'label'      => 'I have my own trailer (if no $30 fee will apply)',
+            'group'      => $ownTrailer,
+            'seperator'  => '',
+            'appendName' => false
+        );
+        $e[] = array(
+            'type'    => 'header',
+            'name'    => 'launchHdr_rmv',
+            'display' => 'Quick Launch'
+        );
+        $e[] = array(
+            'type'    => 'text',
+            'req'     => false,
+            'name'    => 'launch_date',
+            'display' => 'Anticipated Arrival Date'
+        );
         $e[] = array(
             'type'    => 'textarea',
             'req'     => false,
index 2f2f84a..bd06c3b 100644 (file)
                             <td class="fieldcell">
                         {else:}
                             {if:elem.isType(#group#)}
-                                <td colspan="2">
+                                <td colspan="2" class="checkbox">
                                     {if:elem.required}<span class="req">*</span>{end:}
                                     {if:elem.error}<div class="req">{end:}
                                     {elem.label:h}<br>
                                     {if:elem.error}</div>{end:}
                             {else:}
-                                <td class="labelcell">
-                                    {if:elem.required}<span class="req">*</span>{end:}
-                                    {if:elem.error}<div class="req">{end:}
-                                    {elem.label:h}
-                                    {if:elem.error}</div>{end:}
-                                </td>
-                                {if:elem.isName(#interest#)}
-                                    <td class="fieldcell checkbox">
+                                {if:elem.isName(#service_request#)}
+                                    <td colspan="2" class="checkbox">
+                                        {if:elem.required}<span class="req">*</span>{end:}
+                                        {if:elem.error}<div class="req">{end:}
+                                        {elem.label:h}
+                                        {if:elem.error}</div>{end:}
                                 {else:}
-                                    <td class="fieldcell">
+                                    <td class="labelcell">
+                                        {if:elem.required}<span class="req">*</span>{end:}
+                                        {if:elem.error}<div class="req">{end:}
+                                        {elem.label:h}
+                                        {if:elem.error}</div>{end:}
+                                    </td>
+                                    {if:elem.isName(#interest#)}
+                                        <td class="fieldcell checkbox">
+                                    {else:}
+                                        <td class="fieldcell">
+                                    {end:}
                                 {end:}
                             {end:}
                         {end:}
@@ -84,9 +92,9 @@
         {end:}  <!-- end for foreach:sec.element,elem -->
     {end:} <!-- end for foreach:form.section,sec -->
 
-               </table>
-       </form>
-       {if:form.requirednote}
+        </table>
+    </form>
+    {if:form.requirednote}
     <div>{form.requirednote:h}</div>
     {end:}
 </div>
index 9dedb38..669f2de 100644 (file)
 /* Main table */
 #contact table,
 .webform table {
-       background-color: #fff;
-       border: 1px solid #eee;
-       border-collapse: collapse;
-       }
+    background-color: #fff;
+    border: 1px solid #eee;
+    border-collapse: collapse;
+    }
 /* Any Table inside the form */
 #contact table table,
 .webform table table {
-       width: 100%;
-       margin-left: 0;
-       border: 0px solid #ddd;
-       }
-#contact table table td        {       border: 0px solid #ddd;}
+    width: 100%;
+    margin-left: 0;
+    border: 0px solid #ddd;
+    }
+#contact table table td {   border: 0px solid #ddd;}
 
 /* TD's */
 #contact td,
 .webform td {
-       padding: 3px;
-       font-family: arial, helvetica, sans-serif;
-       color: #000;
-       border: 1px solid #eee;
-       border-collapse: collapse;
-       }
+    padding: 3px;
+    font-family: arial, helvetica, sans-serif;
+    color: #000;
+    border: 1px solid #eee;
+    border-collapse: collapse;
+    }
 /* Left Cells */
 .labelcell {
-       background-color: transparent;
-       text-align: right;
-       padding-right: 10px;
-       padding-top: 3px;
-       white-space:nowrap;
-       width: 140px;
-       }
+    background-color: transparent;
+    text-align: right;
+    padding-right: 10px;
+    padding-top: 3px;
+    white-space:nowrap;
+    width: 140px;
+    }
 /*Right Cells */
 .fieldcell {
-       padding-left: 4px;
-       width: 250px;
-       }
+    padding-left: 4px;
+    width: 250px;
+    }
 
 /* Misc */
 textarea {width: 95%; height: 100px; display:block;}
 
 /* WARNINGS */
 #form-warning-top {
-       margin-top: 1em;
-       margin-bottom: 0.5em;
-       color: #f00;
-       font-size: 14px;
-       font-weight: bold;
-       }
+    margin-top: 1em;
+    margin-bottom: 0.5em;
+    color: #f00;
+    font-size: 14px;
+    font-weight: bold;
+    }
 /* SHow hide instruction div */
 #contact table tr td .form-warning-inside,
 .webform table tr td .form-warning-inside {
-       display: none;
-       }
+    display: none;
+    }
 #contact table tr.req td .form-warning-inside,
 .webform table tr.req td .form-warning-inside {
-       display: block;
-       background-image: url('../../../../images/error.gif');
-       background-repeat:no-repeat;
-       background-position: top left;
-       padding: 2px 2px 2px 22px;
+    display: block;
+    background-image: url('../../../../images/error.gif');
+    background-repeat:no-repeat;
+    background-position: top left;
+    padding: 2px 2px 2px 22px;
 }
 
 /* Showing/hiding rows */
 /*invisible*/
 #contact table tr td.instructioncell,
 .webform table tr td.instructioncell {
-       width: 200px;
-       white-space: nowrap;
-       color: #fff;
-       }
+    width: 200px;
+    white-space: nowrap;
+    color: #fff;
+    }
 
 /*visible*/
 table tr.req {
-       border: 2px solid #f00;
-       background-color:#FCD6D4;
-       border-collapse: separate;
-       border-collapse: collapse;
+    border: 2px solid #f00;
+    background-color:#FCD6D4;
+    border-collapse: separate;
+    border-collapse: collapse;
 }
 /*color*/
-table tr.req td                        { background-color: #fcd6d4;}
-table tr.req td.labelcell      { background-color: #FCD6D4; }
-table tr.req td.fieldcell      { background-color: #FCD6D4; }
-table tr.req td.instructioncell        { background-color: #FCD6D4; }
+table tr.req td         { background-color: #fcd6d4;}
+table tr.req td.labelcell   { background-color: #FCD6D4; }
+table tr.req td.fieldcell   { background-color: #FCD6D4; }
+table tr.req td.instructioncell { background-color: #FCD6D4; }
 table tr.req td.instructioncell {
-       padding: 4px;
-       padding-left: 20px;
-       background-image: url('../../../../images/error.gif');
-       background-repeat:no-repeat;
-       background-position: center left;
-       border-width: 0;
-       color: #000;
-       }
+    padding: 4px;
+    padding-left: 20px;
+    background-image: url('../../../../images/error.gif');
+    background-repeat:no-repeat;
+    background-position: center left;
+    border-width: 0;
+    color: #000;
+    }
 .glmCheckBox {
-       width: 200px;
-       float: left;
+    width: 100%;
+    float: left;
 }
 .single-checkbox label.glmCheckBox {
     width: auto;
diff --git a/static/19.phtml b/static/19.phtml
new file mode 100644 (file)
index 0000000..b502992
--- /dev/null
@@ -0,0 +1,12 @@
+<?php
+if ($catid = filter_input(INPUT_GET, 'catid', FILTER_VALIDATE_INT)) {
+    $cf = new Toolkit_Contacts_TempStorageQuickLaunch(
+        Toolkit_Database::getInstance(),
+        'contact_form',
+        'post',
+        BASE_URL . "index.php?catid=$catid"
+    );
+    $cf->configureForm();
+    $cf->useCaptcha(true);
+    echo $cf->toHtml();
+}