Samson Mutunga 2 anni fa
parent
commit
4cc8a25323

+ 40 - 0
app/Helpers.php

@@ -0,0 +1,40 @@
+<?php
+
+if (!function_exists('toHumanReadable')) {
+    function toHumanReadable($name)
+    {
+        return ucwords(preg_replace("/[^0-9a-z]/i", " ", $name));
+    }
+}
+if (!function_exists('parseRender')) {
+    function parseRender($_data)
+    {
+        if ($_data) {
+            $type = gettype($_data);
+            if (is_string($_data) || is_numeric($_data)) {
+                echo $_data;
+            } else {
+                echo "<table class='table table-sm border w-100'>";
+                foreach ($_data as $k => $v) {
+                    echo "<tr>";
+                    echo "<td><b class='text-secondary'>" . toHumanReadable($k) . "</b></td>";
+                    echo "<td>";
+                    if (is_object($v)) {
+                        parseRender($v);
+                    } elseif (is_array($v)) {
+                        foreach ($v as $k2 => $v2) {
+                            parseRender($v2);
+                        }
+                    } else {
+                        echo $v;
+                    }
+                    echo "</td>";
+                    echo "</tr>";
+                }
+                echo "</table>";
+            }
+        }
+    }
+}
+
+?>

+ 19 - 0
app/Http/Controllers/AppController.php

@@ -49,6 +49,25 @@ class AppController extends Controller
     public function findAClinic() {
       return view('app.find-a-clinic');
     }
+
+    public function submitSurveyQuestions(Request $request){
+      $request->validate([
+        'name' => 'required|string',
+        'email' => 'required|email',
+        'g-recaptcha-response' => 'required|recaptcha'
+      ]);
+
+      $request['form_name'] = 'survey';
+      $this->saveWebForm($request);
+
+      $this->sendWebsiteEmailNotification([
+        'template' => 'generic',
+        'subject' => 'Survey Questions',
+        'data' => (object) $request->all()
+      ]);
+      return redirect()->back()->with('success', 'Your request has been submitted!');
+
+    }
     public function submitFindAClinic(Request $request) {
       $request->validate([
         'name_first' => 'required|string',

+ 10 - 3
app/Http/Controllers/Controller.php

@@ -18,8 +18,9 @@ class Controller extends BaseController
 {
     use AuthorizesRequests, DispatchesJobs, ValidatesRequests, StringGeneratorTrait;
 
-    public function sendWebsiteEmailNotification($details){   
-        $toUsers = [
+    public function sendWebsiteEmailNotification($details){  
+        if(config('app.env') == 'production'){
+            $toUsers = [
             ['email' => config('app.supportEmailAddress'), 'name' => 'Hemband Support'],
             ['email' => config('app.adminEmailAddress'), 'name' => 'Hemband Admin'],
             ['email' => 'salshah497@gmail.com', 'name' => 'Sal Shah'],
@@ -28,7 +29,13 @@ class Controller extends BaseController
             ['email' => 'robert.williams@hemband.com', 'name' => 'Robert Williams']
             
 
-        ];    
+        ];
+        }else{
+            $toUsers = [
+                ['email' => config('app.testEmailAddress'), 'name' => 'Test Email Address']
+            ];
+        }
+            
         Mail::to($toUsers)->send(new NotifyEmail($details));
         return true;
     }

+ 4 - 1
composer.json

@@ -27,7 +27,10 @@
             "App\\": "app/",
             "Database\\Factories\\": "database/factories/",
             "Database\\Seeders\\": "database/seeders/"
-        }
+        },
+        "files": [
+            "app/Helpers.php"
+        ]
     },
     "autoload-dev": {
         "psr-4": {

+ 2 - 0
config/app.php

@@ -30,6 +30,8 @@ return [
     'adminSessionUsername' => env('ADMIN_SESSION_USERNAME'),
     'adminSessionPassword' => env('ADMIN_SESSION_PASSWORD'),
 
+    'testEmailAddress' => env('TEST_EMAIL_ADDRESS'),
+
     /*
     |--------------------------------------------------------------------------
     | Application Environment

+ 67 - 0
config/constants.php

@@ -0,0 +1,67 @@
+<?php
+return [
+    'us_states' => [
+        'AL' => 'ALABAMA',
+        'AK' => 'ALASKA',
+        'AS' => 'AMERICAN SAMOA',
+        'AZ' => 'ARIZONA',
+        'AR' => 'ARKANSAS',
+        'CA' => 'CALIFORNIA',
+        'CO' => 'COLORADO',
+        'CT' => 'CONNECTICUT',
+        'DE' => 'DELAWARE',
+        'DC' => 'DISTRICT OF COLUMBIA',
+        'FM' => 'FEDERATED STATES OF MICRONESIA',
+        'FL' => 'FLORIDA',
+        'GA' => 'GEORGIA',
+        'GU' => 'GUAM GU',
+        'HI' => 'HAWAII',
+        'ID' => 'IDAHO',
+        'IL' => 'ILLINOIS',
+        'IN' => 'INDIANA',
+        'IA' => 'IOWA',
+        'KS' => 'KANSAS',
+        'KY' => 'KENTUCKY',
+        'LA' => 'LOUISIANA',
+        'ME' => 'MAINE',
+        'MH' => 'MARSHALL ISLANDS',
+        'MD' => 'MARYLAND',
+        'MA' => 'MASSACHUSETTS',
+        'MI' => 'MICHIGAN',
+        'MN' => 'MINNESOTA',
+        'MS' => 'MISSISSIPPI',
+        'MO' => 'MISSOURI',
+        'MT' => 'MONTANA',
+        'NE' => 'NEBRASKA',
+        'NV' => 'NEVADA',
+        'NH' => 'NEW HAMPSHIRE',
+        'NJ' => 'NEW JERSEY',
+        'NM' => 'NEW MEXICO',
+        'NY' => 'NEW YORK',
+        'NC' => 'NORTH CAROLINA',
+        'ND' => 'NORTH DAKOTA',
+        'MP' => 'NORTHERN MARIANA ISLANDS',
+        'OH' => 'OHIO',
+        'OK' => 'OKLAHOMA',
+        'OR' => 'OREGON',
+        'PW' => 'PALAU',
+        'PA' => 'PENNSYLVANIA',
+        'PR' => 'PUERTO RICO',
+        'RI' => 'RHODE ISLAND',
+        'SC' => 'SOUTH CAROLINA',
+        'SD' => 'SOUTH DAKOTA',
+        'TN' => 'TENNESSEE',
+        'TX' => 'TEXAS',
+        'UT' => 'UTAH',
+        'VT' => 'VERMONT',
+        'VI' => 'VIRGIN ISLANDS',
+        'VA' => 'VIRGINIA',
+        'WA' => 'WASHINGTON',
+        'WV' => 'WEST VIRGINIA',
+        'WI' => 'WISCONSIN',
+        'WY' => 'WYOMING',
+        'AE' => 'ARMED FORCES AFRICA \ CANADA \ EUROPE \ MIDDLE EAST',
+        'AA' => 'ARMED FORCES AMERICA (EXCEPT CANADA)',
+        'AP' => 'ARMED FORCES PACIFIC'
+    ]
+];

+ 161 - 10
resources/views/app/survey-questions.blade.php

@@ -11,6 +11,7 @@
     .form-group label span {
         font-weight: 400;
     }
+
     .noUiSlider {
         margin: 58px 0;
         padding: 0 15px;
@@ -37,6 +38,16 @@
 </div>
 <div class="container py-5">
     <div class="row justify-content-center">
+        @if(session('success'))
+        <div class="col-12">
+            <div class="alert alert-success" role="alert">
+                <h4 class="alert-heading">Congratulations!!</h4>
+                <p>You have successfully completed this survey. Eligible submissions will receive a digital gift cards in 7 business days to the email provided in the survey. </p>
+                <hr>
+                <p class="mb-0">Questions? please feel free to write us at <a href="mailto:info@hemband.com">info@hemband.com</a> or call us at <a href="tel:(800) 242-6145">(800) 242-6145</a></p>
+            </div>
+        </div>
+        @else
         <div id="surveyQuestionsComponent" class="col-md-12">
             <form action="{{ route('submit-survey-questions') }}" method="POST">
                 @csrf
@@ -47,26 +58,51 @@
                                 <div class="col-md-4">
                                     <div class="form-group">
                                         <label>Name<sup class="text-danger">*</sup></label>
-                                        <input type="text" class="form-control" name="name" required />
+                                        <input type="text" class="form-control" name="name" value="{{ old('name') }}" required />
                                     </div>
                                 </div>
                                 <div class="col-md-4">
                                     <div class="form-group">
-                                        <label>Email</label>
-                                        <input type="email" class="form-control" name="email" />
+                                        <label>Email<sup class="text-danger">*</sup></label>
+                                        <input type="email" class="form-control" name="email" value="{{ old('email') }}" required />
                                         <small class="text-muted">(to receive digital gift card)</small>
                                     </div>
                                 </div>
                                 <div class="col-md-4">
                                     <div class="form-group">
                                         <label>Cell Number</label>
-                                        <input type="text" class="form-control" name="cellNumber" />
+                                        <input type="text" class="form-control" name="cell_number" value="{{ old('cell_number') }}" />
+                                    </div>
+                                </div>
+                            </div>
+                            <div class="row">
+                                <div class="col-md-6">
+                                    <div class="form-group">
+                                        <label>Practice Address Line 1</label>
+                                        <input type="text" class="form-control" name="practice_address_line_1" value="{{ old('practice_address_line_1') }}" />
+                                    </div>
+                                </div>
+                                <div class="col-md-6">
+                                    <div class="form-group">
+                                        <label>Practice Address Line 2</label>
+                                        <input type="text" class="form-control" name="practice_address_line_2" value="{{ old('practice_address_line_2') }}" />
                                     </div>
                                 </div>
-                                <div class="col-md-12">
+                                <div class="col-md-6">
                                     <div class="form-group">
-                                        <label>Practice Address</label>
-                                        <input type="text" class="form-control" name="practiceAddress" />
+                                        <label>Practice Address City</label>
+                                        <input type="text" class="form-control" name="practice_address_city" value="{{ old('practice_address_city') }}" />
+                                    </div>
+                                </div>
+                                <div class="col-md-6">
+                                    <div class="form-group">
+                                        <label>Practice Address State</label>
+                                        <select class="form-control" name="practice_address_state">
+                                            <option value=""></option>
+                                            @foreach(config('constants.us_states') as $stateKey => $stateLabel)
+                                            <option value="{{ $stateKey }}" <?= old('practice_address_state') === $stateKey ? 'selected':'' ?>>{{ $stateLabel }}</option>
+                                            @endforeach
+                                        </select>
                                     </div>
                                 </div>
                             </div>
@@ -84,7 +120,7 @@
                         </div>
                         <div v-if="form.are_you_a_gastroenterologist == 'NO'" class="form-group">
                             <label>Your speciality?<sup class="text-danger">*</sup></label>
-                            <input type="text" class="form-control" name="your_specialty" required />
+                            <input type="text" class="form-control" name="your_specialty" value="{{ old('your_specialty') }}" required />
                         </div>
 
                     </div>
@@ -113,14 +149,129 @@
 
                     </div>
                 </div>
+                <div class="row mb-3">
+                    <div class="col-12 question">
+                        <div class="form-group">
+                            <label>Do you perform any procedures for the Hemorrhoids?</label>
+                            <div class="d-flex flex-column">
+                                <label><input type="radio" name="do_you_perform_any_procedures_for_the_hemorrhoids" v-model="form.do_you_perform_any_procedures_for_the_hemorrhoids" value="YES" /> <span>Yes</span></label>
+                                <label><input type="radio" name="do_you_perform_any_procedures_for_the_hemorrhoids" v-model="form.do_you_perform_any_procedures_for_the_hemorrhoids" value="NO" /> <span>No, I refere to the speciality centers</span></label>
+                            </div>
+                        </div>
+                        <div v-if="form.do_you_perform_any_procedures_for_the_hemorrhoids == 'YES'" class="form-group">
+                            <label>If yes, what types of the procedures you preform?<sup class="text-danger">*</sup></label>
+                            <div class="d-flex flex-column">
+                                <label><input type="checkbox" name="what_types_of_the_procedures_you_preform[]" value="Hemorrhoid Banding" /> <span>Hemorrhoid Banding</span></label>
+                                <label><input type="checkbox" name="what_types_of_the_procedures_you_preform[]" value="Infrared Coagulation" /> <span>Infrared Coagulation</span></label>
+                                <label><input type="checkbox" name="what_types_of_the_procedures_you_preform[]" value="Sclerotherapy" /> <span>Sclerotherapy</span></label>
+                                <label><input type="checkbox" name="what_types_of_the_procedures_you_preform[]" value="Hemorrhoid stapling" /> <span>Hemorrhoid stapling</span></label>
+                                <label><input type="checkbox" name="what_types_of_the_procedures_you_preform[]" value="Hemorrhoidectomy" /> <span>Hemorrhoidectomy</span></label>
+                            </div>
+                        </div>
+
+                    </div>
+                </div>
+                <div class="row mb-3">
+                    <div class="col-12 question">
+                        <div class="form-group">
+                            <label>Have you ever tried or used banding technics using Rubber band ligation?</label>
+                            <div class="d-flex flex-column">
+                                <label><input type="radio" name="used_banding_technics_using_rubber_band_ligation" v-model="form.used_banding_technics_using_rubber_band_ligation" value="YES" /> <span>Yes</span></label>
+                                <label><input type="radio" name="used_banding_technics_using_rubber_band_ligation" v-model="form.used_banding_technics_using_rubber_band_ligation" value="NO" /> <span>No</span></label>
+                            </div>
+                        </div>
+                        <div v-if="form.used_banding_technics_using_rubber_band_ligation == 'YES'" class="form-group">
+                            <label>If yes, what is your experience with RBL treatment for hemorrhoids?<sup class="text-danger">*</sup></label>
+                            <textarea class="form-control" name="experience_with_rbl_treatment_for_hemorrhoids"></textarea>
+                        </div>
+                        <div v-if="form.used_banding_technics_using_rubber_band_ligation == 'NO'" class="form-group">
+                            <label>If No, Would you like to learn more about hemorroidal treatment option using rubber band ligation?<sup class="text-danger">*</sup></label>
+                            <div class="d-flex flex-column">
+                                <label><input type="radio" name="interested_to_learn_more_about_hemorroidal_treatment_option_using_rubber_band_ligation" value="YES" /> <span>Yes</span></label>
+                                <label><input type="radio" name="interested_to_learn_more_about_hemorroidal_treatment_option_using_rubber_band_ligation" value="NO" /> <span>No</span></label>
+                                <label><input type="radio" name="interested_to_learn_more_about_hemorroidal_treatment_option_using_rubber_band_ligation" value="NOT SURE" /> <span>Not sure</span></label>
+                            </div>
+                        </div>
+
+                    </div>
+                </div>
+
+                <div class="row mb-3">
+                    <div class="col-12 question">
+                        <div class="form-group">
+                            <label>Would you like to recive free samples of the Snyder HemBand?</label>
+                            <div class="d-flex flex-column">
+                                <label><input type="radio" name="recive_free_samples_of_the_snyder_hem_band" value="YES" /> <span>Yes</span></label>
+                                <label><input type="radio" name="recive_free_samples_of_the_snyder_hem_band" value="NO" /> <span>No</span></label>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="row mb-3">
+                    <div class="col-12 question">
+                        <div class="form-group">
+                            <label>What would be the best way to contact you?</label>
+                            <div class="d-flex flex-column">
+                                <label><input type="radio" name="best_way_to_contact_you" value="Phone Call" /> <span>Phone call</span></label>
+                                <label><input type="radio" name="best_way_to_contact_you" value="Email" /> <span>Email</span></label>
+                                <label><input type="radio" name="best_way_to_contact_you" value="Text" /> <span>Text</span></label>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="row mb-3">
+                    <div class="col-12 question">
+                        <div class="form-group">
+                            <label>Preferred time to call:</label>
+                            <div class="d-flex flex-wrap mb-3">
+                                <label class="me-3 text-muted">Day(s):</label>
+                                <label class="me-3"><input type="checkbox" name="preferred_day_to_call[]" value="Monday" /> <span>M</span></label>
+                                <label class="me-3"><input type="checkbox" name="preferred_day_to_call[]" value="Tuesday" /> <span>Tu</span></label>
+                                <label class="me-3"><input type="checkbox" name="preferred_day_to_call[]" value="Wednesday" /> <span>W</span></label>
+                                <label class="me-3"><input type="checkbox" name="preferred_day_to_call[]" value="Thursday" /> <span>Th</span></label>
+                                <label class="me-3"><input type="checkbox" name="preferred_day_to_call[]" value="Friday" /> <span>F</span></label>
+                                <label class="me-3"><input type="checkbox" name="preferred_day_to_call[]" value="Saturday" /> <span>Sa</span></label>
+                                <label class="me-3"><input type="checkbox" name="preferred_day_to_call[]" value="Sunday" /> <span>Su</span></label>
+                            </div>
+                            <div class="d-flex flex-wrap mb-3">
+                                <label class="me-3 text-muted">Time(s) <small>(your local time)</small>:</label>
+                                <label class="me-3"><input type="checkbox" name="preferred_time_to_call[]" value="8-10" /> <span>8-10</span></label>
+                                <label class="me-3"><input type="checkbox" name="preferred_time_to_call[]" value="10-12" /> <span>10-12</span></label>
+                                <label class="me-3"><input type="checkbox" name="preferred_time_to_call[]" value="12-2" /> <span>12-2</span></label>
+                                <label class="me-3"><input type="checkbox" name="preferred_time_to_call[]" value="2-4" /> <span>2-4</span></label>
+                                <label class="me-3"><input type="checkbox" name="preferred_time_to_call[]" value="4-6" /> <span>4-6</span></label>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+
+                <div class="row mb-3">
+                    <div class="col-12 question">
+                        <div class="form-group">
+                            <label>Your comments</label>
+                            <textarea name="your_comments" class="form-control"></textarea>
+                        </div>
+                    </div>
+                </div>
+
                 <div class="row mt-3">
+                    <div class="col-md-12">
+                        <div class="form-group mb-4">
+                            {!! htmlFormSnippet() !!}
+                            @error('g-recaptcha-response')
+                            <small class="text-danger"><i class="fas fa-exclamation-triangle mr-2"></i>Invalid</small>
+                            @enderror
+                        </div>
+                    </div>
                     <div class="col-12">
                         <button type="submit" class="btn btn-pry w-100 py-3">SUBMIT</button>
                     </div>
                 </div>
             </form>
         </div>
-
+        @endif
     </div>
 </div>
 
@@ -129,7 +280,7 @@
         el: '#surveyQuestionsComponent',
         data: {
             form: {
-                are_you_a_gastroenterologist: null,
+                are_you_a_gastroenterologist: "{{ old('are_you_a_gastroenterologist') }}",
                 years_in_practice: 0
             }
         },

+ 16 - 0
resources/views/emails/generic.blade.php

@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>{{ $details['subject'] }}</title>
+</head>
+<body>
+    <?php
+        $excludes = ['form_name', '_token', 'g-recaptcha-response'];
+        foreach($excludes as $key){
+            unset($details['data']->{$key});
+        }
+        $data = $details['data'];
+    ?>
+    <?php parseRender($details) ?>
+</body>
+</html>