瀏覽代碼

PMHx section UI - Add custom-items support

Vijayakrishnan Krishnan 4 年之前
父節點
當前提交
a74922be34
共有 3 個文件被更改,包括 122 次插入0 次删除
  1. 60 0
      storage/sections/pmhx/form.blade.php
  2. 28 0
      storage/sections/pmhx/processor.php
  3. 34 0
      storage/sections/pmhx/summary.php

+ 60 - 0
storage/sections/pmhx/form.blade.php

@@ -26,6 +26,21 @@ $fields = [
     ]
 ];
 
+$customFields = [
+    [
+        ":::Anxiety disorder|BPH|carpal tunnel|CHF|Degernative Disc Disorder|Fibromyalgia",
+    ],
+    [
+        ":::Hard of Hearing|Hearing Impairment|Lupus|Multiple Falls|Multiple kidney stones|Multiple Rib Fractures",
+    ],
+    [
+        ":::Neuropathy|Obesity|Obstructive Sleep Apnea|Primary immunodeficiency diso|pulmonary hypertension|Restless Leg Syndrome",
+    ],
+    [
+        ":::Rhinitis|Russell Silver Syndrome|transverse myelitis|Vertigo",
+    ]
+];
+
 $contentData = false;
 if($section){
     $contentData = json_decode($section->content_data, true);
@@ -47,6 +62,20 @@ for ($i = 0; $i < count($fields); $i++) {
         }
     }
 }
+for ($i = 0; $i < count($customFields); $i++) {
+    for($j = 0; $j < count($customFields[$i]); $j++) {
+        $parts = explode(":::", $customFields[$i][$j]);
+        $head = 'custom';
+        if(!empty($parts[0])) $head = $parts[0];
+        $values = explode("|", $parts[1]);
+        for($k = 0; $k < count($values); $k++) {
+            $fName = $head . '_' . sanitize_field_name($values[$k]);
+            if(!isset($contentData[$fName])) {
+                $contentData[$fName] = '';
+            }
+        }
+    }
+}
 
 $formID = rand(0, 100000);
 ?>
@@ -108,6 +137,37 @@ $formID = rand(0, 100000);
         @endfor
     </div>
 
+    <div class="font-weight-bold mb-2">Custom Items</div>
+
+    <div class="row">
+        @for ($i = 0; $i < count($customFields); $i++)
+            <div class="col-md-3">
+                @for($j = 0; $j < count($customFields[$i]); $j++)
+                    <?php
+                    $parts = explode(":::", $customFields[$i][$j]);
+                    $head = 'custom';
+                    if(!empty($parts[0])) $head = $parts[0];
+                    $values = explode("|", $parts[1]);
+                    ?>
+                    <div class="mb-3">
+                        @if($head !== 'custom')
+                            <div class="font-weight-bold mb-2">{{ $head }}</div>
+                        @endif
+                        @for($k = 0; $k < count($values); $k++)
+                            <?php
+                            $fName = $head . '_' . sanitize_field_name($values[$k]);
+                            ?>
+                            <label class="d-flex align-items-center mb-1">
+                                <input type="checkbox" name="{{ $fName }}" {{ $contentData[$fName] ? 'checked' : '' }} class="m-0">
+                                <span class="ml-2">{{ $values[$k] }}</span>
+                            </label>
+                        @endfor
+                    </div>
+                @endfor
+            </div>
+        @endfor
+    </div>
+
     <div class="row mb-3">
         <div class="col-12">
             <textarea rte type="text" class="form-control form-control-sm p-2"

+ 28 - 0
storage/sections/pmhx/processor.php

@@ -26,6 +26,21 @@ $fields = [
     ]
 ];
 
+$customFields = [
+    [
+        ":::Anxiety disorder|BPH|carpal tunnel|CHF|Degernative Disc Disorder|Fibromyalgia",
+    ],
+    [
+        ":::Hard of Hearing|Hearing Impairment|Lupus|Multiple Falls|Multiple kidney stones|Multiple Rib Fractures",
+    ],
+    [
+        ":::Neuropathy|Obesity|Obstructive Sleep Apnea|Primary immunodeficiency diso|pulmonary hypertension|Restless Leg Syndrome",
+    ],
+    [
+        ":::Rhinitis|Russell Silver Syndrome|transverse myelitis|Vertigo",
+    ]
+];
+
 $newContentData = [];
 
 $newContentData['blood_type'] = $request->get('blood_type');
@@ -44,4 +59,17 @@ for ($i = 0; $i < count($fields); $i++) {
     }
 }
 
+for ($i = 0; $i < count($customFields); $i++) {
+    for($j = 0; $j < count($customFields[$i]); $j++) {
+        $parts = explode(":::", $customFields[$i][$j]);
+        $head = 'custom';
+        if(!empty($parts[0])) $head = $parts[0];
+        $values = explode("|", $parts[1]);
+        for($k = 0; $k < count($values); $k++) {
+            $fName = $head . '_' . sanitize_field_name($values[$k]);
+            $newContentData[$fName] = $request->get($fName);
+        }
+    }
+}
+
 $newContentData['comments'] = $request->get('comments');

+ 34 - 0
storage/sections/pmhx/summary.php

@@ -26,6 +26,21 @@ $fields = [
     ]
 ];
 
+$customFields = [
+    [
+        ":::Anxiety disorder|BPH|carpal tunnel|CHF|Degernative Disc Disorder|Fibromyalgia",
+    ],
+    [
+        ":::Hard of Hearing|Hearing Impairment|Lupus|Multiple Falls|Multiple kidney stones|Multiple Rib Fractures",
+    ],
+    [
+        ":::Neuropathy|Obesity|Obstructive Sleep Apnea|Primary immunodeficiency diso|pulmonary hypertension|Restless Leg Syndrome",
+    ],
+    [
+        ":::Rhinitis|Russell Silver Syndrome|transverse myelitis|Vertigo",
+    ]
+];
+
 $blood = [];
 if(isset($newContentData['blood_type'])) {
     $blood[] = $newContentData['blood_type'];
@@ -59,6 +74,25 @@ for ($i = 0; $i < count($fields); $i++) {
     }
 }
 
+for ($i = 0; $i < count($customFields); $i++) {
+    for($j = 0; $j < count($customFields[$i]); $j++) {
+        $parts = explode(":::", $customFields[$i][$j]);
+        $head = 'custom';
+        if(!empty($parts[0])) $head = $parts[0];
+        $values = explode("|", $parts[1]);
+        for($k = 0; $k < count($values); $k++) {
+            $fName = $head . '_' . sanitize_field_name($values[$k]);
+            if(isset($newContentData[$fName])) { ?>
+                <div>
+                    <?= ucwords($head) ?>
+                    <i class="fa fa-arrow-right text-sm text-secondary"></i>
+                    <span class="font-weight-bold"><?= $values[$k] ?></span>
+                </div>
+            <?php }
+        }
+    }
+}
+
 if(isset($newContentData['comments'])) { ?>
     <div class="mt-2 mb-1">
         <div class="font-weight-bold">Comments:</div>