]> _ Git - ccv-wordpress.git/commitdiff
wip #5666 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 6 Feb 2023 17:05:51 +0000 (18:05 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 6 Feb 2023 17:05:51 +0000 (18:05 +0100)
wp-content/mu-plugins/cube/src/Forms/Consultation.php
wp-content/themes/CCV/resources/views/forms/consultation.blade.php

index 819c744d91b89186f623ee7071ddf61a7a928c19..4d7d17f22b6e9c04df70619672ce135e3160f6ba 100644 (file)
@@ -14,135 +14,139 @@ use Cube\Forms\Builder\Fields\Textarea;
 
 use function Roots\asset;
 
-class Consultation extends Base
-{
-    public function __construct() {
-        $this->set_form_title(__('E-diagnostic', 'ccv'));
-    }
-
-    public function register_scripts() {
-
-        parent::register_scripts();
-
-        wp_enqueue_script('ccv-consultation', asset('scripts/consultation.js'), ['jquery'], null, true);
-        wp_enqueue_script('lity', asset('scripts/lity.js'), ['jquery'], null, true);
-        wp_enqueue_style('lity-css', asset('styles/lity.css'));
-    }
-
-
-    function register_fields() {
-
-        $this->add_fields([
-
-            //=== PERSONAL INFORMATION
-            Text::field('last-name', _x('Nom', 'Nom de famille', 'ccv')),
-            Text::field('first-name', __('Prénom', 'ccv')),
-            Text::field('profession', __('Profession', 'ccv')),
-            Text::field('city', __('Ville (département)', 'ccv')),
-            Text::field('country', __('Pays', 'ccv')),
-            Text::field('phone', __('Tel', 'ccv')),
-            Email::field('email', __('Email', 'ccv')),
-            Radio::field('sex', __('Sexe', 'ccv'))
-                ->options([
-                    _x('M', 'Sexe (M)', 'ccv'),
-                    _x('F', 'Sexe (F)', 'ccv'),
-                ]),
-            Text::field('age', __('Âge :', 'ccv')),
-            Textarea::field('message', __('Avez vous un message (ou une demande) spécifique à nous formuler ?', 'ccv'))->required(false),
-
-            // Special field: if a surgeon is selected, their e-mail address will be override the default delivery address
-            Select::field('surgeon', __('Chirurgien spécifique', 'ccv'))
-                ->required(false)
-                ->options([
-                    'Dr Guilhaume GENESTE' => 'dr.geneste@ccv-montpellier.fr',
-                    'Dr Grégory EDGARD-ROSA' => 'dr.edgard-rosa@ccv-montpellier.fr',
-                    'Dr Martin GRAU ORTIZ' => 'dr.grauortiz@ccv-montpellier.fr',
-                    'Dr Caroline HIRSH' => 'dr.hirsch@ccv-montpellier.fr',
-                ]),
-
-            //=== IMAGERY
-            // This is a special case and will be output manually so only using this for the e-mail label
-            Radio::field('imagery-type', __('Imagerie', 'ccv'))->required(false),
-            Textarea::field('imagery-online', __('Images en ligne', 'ccv'))->required(false), // Again, a manually handled field
-            Checkbox::field('imagery-posted', __('Images envoyées par courrier', 'ccv'))->required(false),
-
-            // Unique session identifier for uploads that go directly to CCV's NAS (upload.ccv-montpellier.fr)
-            // Made up of timestamp YYMMDDHHMM + nonce
-            Hidden::field('imagery-phone-token', __('ID sur le NAS', 'ccv'))->value(date('ymdHi') . '_'. wp_create_nonce('NAS-upload')),
-
-            //== SYMPTOMS
-            Radio::field('main-problem', __('Problème principal', 'ccv'))
-                ->options([
-                    __('Cervicales', 'ccv'),
-                    __('Lombaires', 'ccv'),
-                    __('Scoliose', 'ccv'),
-                ]),
-
-            Date::field('date-first-symptoms', __('Date des premiers symptômes :', 'ccv')),
-
-            Date::field('date-pain-since', __('Douleurs permanentes depuis (le cas échéant) :', 'ccv'))->required(false),
-
-            Binary::field('pain-arms-legs', __('Avez-vous des douleurs dans les bras ou les jambes (sciatiques, cruralgies, névralgies) ?', 'ccv')),
-
-            Checkbox::field('pain-arms-legs-detail', __('Si oui, cochez les membres concernés :', 'ccv'))
-                ->required(false)
-                ->options([
-                    __('Haut du bras droit', 'ccv'),
-                    __('Haut du bras gauche', 'ccv'),
-                    __('Avant-bras droit', 'ccv'),
-                    __('Avant-bras gauche', 'ccv'),
-                    __('Haut de la jambe droite', 'ccv'),
-                    __('Haut de la jambe gauche', 'ccv'),
-                    __('Bas de la jambe droite', 'ccv'),
-                    __('Bas de la jambe gauche', 'ccv'),
-                ]),
-
-            Radio::field('main-pain', __('La douleur principale est-elle ?', 'ccv'))
-                ->options([
-                    __('Dans la colonne', 'ccv'),
-                    __('Dans les membres', 'ccv'),
-                    __('Les deux', 'ccv'),
-                ]),
-
-            Binary::field('tingling-numbness', __('Avez-vous des fourmillements ou une sensation d’engourdissement dans un des membres ? ', 'ccv')),
-            Date::field('tingling-numbness-date', __('Si oui depuis quand ?', 'ccv'))->required(false),
-
-            Binary::field('strength-loss', __('Avez-vous une perte de force importante dans un des membres ?', 'ccv')),
-            Date::field('strength-loss-date', __('Si oui depuis quand ?', 'ccv'))->required(false),
-
-            //=== TREATMENTS
-            Textarea::field('medication', __('Indiquez ici les médicaments que vous avez pris pour vos douleurs (le cas échéant)', 'ccv'))->required(false),
-            Binary::field('kine-osteo', __('Kinésithérapie ou ostéopathie', 'ccv')),
-            Binary::field('corset', __('Corset ou ceinture lombaire', 'ccv')),
-            Binary::field('hospitalisation', __('Séjour en hospitalisation', 'ccv')),
-            Binary::field('infiltration', __('Infiltration ou thermocoagulation', 'ccv')),
-            Textarea::field('surgeries', __('Indiquez ici vos précédentes chirurgies de la colonne et leurs dates (le cas échéant)', 'ccv'))->required(false),
-
-        ]);
-    }
-
-    public function pre_process() {
-
-        // Include patient name in subject line
-        $this->set_form_title(' - '. strtoupper($this->get_data('last-name')) .', '. $this->get_data('first-name') , true);
-
-        // Due to the complexity of the "Imagery" section of the form, there's no validation on these fields
-        // so it's possible to submit the form without ever selecting an imagery-type. In this case, we update
-        // the field value so it is clear to CCV that the client never filled out this section...
-        if (empty($this->get_data('imagery-type'))) {
-            $this->set_data('imagery-type', __('Aucune image envoyée', 'ccv'));
-        }
-
-        // If the user didn't select the NAS upload option, there's no point including the NAS ID in the form data
-        // NOTE: This relies on the value of the field so make sure it is always the same in both places (consultation.blade.php)
-        if ($this->get_data('imagery-type') !== __('Images téléversées depuis portable', 'ccv')) {
-            $this->remove_field('imagery-phone-token');
-        }
-
-        // If a surgeon is selected, send the form directly to them
-        $surgeons = $this->get_field('surgeon')->get_options();
-        if (!empty($this->get_data('surgeon')) && array_key_exists($this->get_data('surgeon'), $surgeons)) {
-            $this->set_destination($surgeons[$this->get_data('surgeon')]);
-        }
-    }
+class Consultation extends Base {
+       public function __construct() {
+               $this->set_form_title(__('E-diagnostic', 'ccv'));
+               if (defined('TEST_EMAIL')) {
+                       $this->destination = TEST_EMAIL;
+               }
+       }
+
+
+       public function register_scripts() {
+
+               parent::register_scripts();
+
+               wp_enqueue_script('ccv-consultation', asset('scripts/consultation.js'), ['jquery'], null, true);
+               wp_enqueue_script('lity', asset('scripts/lity.js'), ['jquery'], null, true);
+               wp_enqueue_style('lity-css', asset('styles/lity.css'));
+       }
+
+
+       function register_fields() {
+
+               $this->add_fields([
+
+                       //=== PERSONAL INFORMATION
+                       Text::field('last-name', __('Nom', 'Nom de famille', 'ccv')),
+                       Text::field('first-name', __('Prénom', 'ccv')),
+                       Text::field('profession', __('Profession', 'ccv')),
+                       Text::field('postcode', __('Code postal', 'ccv')),
+                       Text::field('city', __('Ville', 'ccv')),
+                       Text::field('country', __('Pays', 'ccv')),
+                       Text::field('phone', __('Tel', 'ccv')),
+                       Email::field('email', __('Email', 'ccv')),
+                       Radio::field('sex', __('Sexe', 'ccv'))
+                               ->options([
+                                       _x('M', 'Sexe (M)', 'ccv'),
+                                       _x('F', 'Sexe (F)', 'ccv'),
+                               ]),
+                       Text::field('age', __('Âge :', 'ccv')),
+                       Textarea::field('message', __('Avez vous un message (ou une demande) spécifique à nous formuler ?', 'ccv'))->required(false),
+
+                       // Special field: if a surgeon is selected, their e-mail address will be override the default delivery address
+                       Select::field('surgeon', __('Chirurgien spécifique', 'ccv'))
+                               ->required(false)
+                               ->options([
+                                       'Dr Guilhaume GENESTE' => 'dr.geneste@ccv-montpellier.fr',
+                                       'Dr Grégory EDGARD-ROSA' => 'dr.edgard-rosa@ccv-montpellier.fr',
+                                       'Dr Martin GRAU ORTIZ' => 'dr.grauortiz@ccv-montpellier.fr',
+                                       'Dr Caroline HIRSH' => 'dr.hirsch@ccv-montpellier.fr',
+                               ]),
+
+                       //=== IMAGERY
+                       // This is a special case and will be output manually so only using this for the e-mail label
+                       Radio::field('imagery-type', __('Imagerie', 'ccv'))->required(false),
+                       Textarea::field('imagery-online', __('Images en ligne', 'ccv'))->required(false), // Again, a manually handled field
+                       Checkbox::field('imagery-posted', __('Images envoyées par courrier', 'ccv'))->required(false),
+
+                       // Unique session identifier for uploads that go directly to CCV's NAS (upload.ccv-montpellier.fr)
+                       // Made up of timestamp YYMMDDHHMM + nonce
+                       Hidden::field('imagery-phone-token', __('ID sur le NAS', 'ccv'))->value(date('ymdHi') . '_' . wp_create_nonce('NAS-upload')),
+
+                       //== SYMPTOMS
+                       Radio::field('main-problem', __('Problème principal', 'ccv'))
+                               ->options([
+                                       __('Cervicales', 'ccv'),
+                                       __('Lombaires', 'ccv'),
+                                       __('Scoliose', 'ccv'),
+                               ]),
+
+                       Date::field('date-first-symptoms', __('Date des premiers symptômes :', 'ccv')),
+
+                       Date::field('date-pain-since', __('Douleurs permanentes depuis (le cas échéant) :', 'ccv'))->required(false),
+
+                       Binary::field('pain-arms-legs', __('Avez-vous des douleurs dans les bras ou les jambes (sciatiques, cruralgies, névralgies) ?', 'ccv')),
+
+                       Checkbox::field('pain-arms-legs-detail', __('Si oui, cochez les membres concernés :', 'ccv'))
+                               ->required(false)
+                               ->options([
+                                       __('Haut du bras droit', 'ccv'),
+                                       __('Haut du bras gauche', 'ccv'),
+                                       __('Avant-bras droit', 'ccv'),
+                                       __('Avant-bras gauche', 'ccv'),
+                                       __('Haut de la jambe droite', 'ccv'),
+                                       __('Haut de la jambe gauche', 'ccv'),
+                                       __('Bas de la jambe droite', 'ccv'),
+                                       __('Bas de la jambe gauche', 'ccv'),
+                               ]),
+
+                       Radio::field('main-pain', __('La douleur principale est-elle ?', 'ccv'))
+                               ->options([
+                                       __('Dans la colonne', 'ccv'),
+                                       __('Dans les membres', 'ccv'),
+                                       __('Les deux', 'ccv'),
+                               ]),
+
+                       Binary::field('tingling-numbness', __('Avez-vous des fourmillements ou une sensation d’engourdissement dans un des membres ? ', 'ccv')),
+                       Date::field('tingling-numbness-date', __('Si oui depuis quand ?', 'ccv'))->required(false),
+
+                       Binary::field('strength-loss', __('Avez-vous une perte de force importante dans un des membres ?', 'ccv')),
+                       Date::field('strength-loss-date', __('Si oui depuis quand ?', 'ccv'))->required(false),
+
+                       //=== TREATMENTS
+                       Textarea::field('medication', __('Indiquez ici les médicaments que vous avez pris pour vos douleurs (le cas échéant)', 'ccv'))->required(false),
+                       Binary::field('kine-osteo', __('Kinésithérapie ou ostéopathie', 'ccv')),
+                       Binary::field('corset', __('Corset ou ceinture lombaire', 'ccv')),
+                       Binary::field('hospitalisation', __('Séjour en hospitalisation', 'ccv')),
+                       Binary::field('infiltration', __('Infiltration ou thermocoagulation', 'ccv')),
+                       Textarea::field('surgeries', __('Indiquez ici vos précédentes chirurgies de la colonne et leurs dates (le cas échéant)', 'ccv'))->required(false),
+
+               ]);
+       }
+
+       public function pre_process() {
+
+               // Include patient name in subject line
+               $this->set_form_title(' - ' . strtoupper($this->get_data('last-name')) . ', ' . $this->get_data('first-name'), true);
+
+               // Due to the complexity of the "Imagery" section of the form, there's no validation on these fields
+               // so it's possible to submit the form without ever selecting an imagery-type. In this case, we update
+               // the field value so it is clear to CCV that the client never filled out this section...
+               if (empty($this->get_data('imagery-type'))) {
+                       $this->set_data('imagery-type', __('Aucune image envoyée', 'ccv'));
+               }
+
+               // If the user didn't select the NAS upload option, there's no point including the NAS ID in the form data
+               // NOTE: This relies on the value of the field so make sure it is always the same in both places (consultation.blade.php)
+               if ($this->get_data('imagery-type') !== __('Images téléversées depuis portable', 'ccv')) {
+                       $this->remove_field('imagery-phone-token');
+               }
+
+               // If a surgeon is selected, send the form directly to them
+               $surgeons = $this->get_field('surgeon')->get_options();
+               if (!empty($this->get_data('surgeon')) && array_key_exists($this->get_data('surgeon'), $surgeons)) {
+                       $this->set_destination($surgeons[$this->get_data('surgeon')]);
+               }
+       }
 }
index a7cc32b91c4a0bb663637f89fc2124797373b43f..f6364eaed93eb55d665bd75d26183edb9ca3ccca 100644 (file)
       {!! $form->field('last-name', ['show_title' => false]) !!}
       {!! $form->field('first-name', ['show_title' => false]) !!}
       {!! $form->field('profession', ['show_title' => false]) !!}
+      {!! $form->field('postcode', ['show_title' => false]) !!}
       {!! $form->field('city', ['show_title' => false]) !!}
       {!! $form->field('country', ['show_title' => false]) !!}
       {!! $form->field('phone', ['show_title' => false]) !!}
 @push('afterform')
   <form action="https://ccvmontpellier34.synology.me/upload.php" id="phone-file-upload-form" method="post"
         enctype="multipart/form-data" style="visibility:hidden;height:1px;position:absolute;top:0;">
-    <input type="file" multiple="multiple" name="files[]" id="phone-file-upload-field" accept="image/*" capture />
+    <input type="file" multiple="multiple" name="files[]" id="phone-file-upload-field" accept="image/*" capture/>
   </form>
   <script>
-    (function($) {
+    (function ($) {
       // Clicking browse triggers the file form. It opens the dialog to capture images or browse files
       $('#phone-image-browse').on('click touchend', function () {
         $('#phone-file-upload-field').click();