From 5b08142d5be57b97c717a932f4d5002eba7d55f6 Mon Sep 17 00:00:00 2001 From: Fayyazi Date: Sat, 21 Dec 2019 10:38:17 +0330 Subject: [PATCH] add qrcode and arcode for test type --- app/Http/Controllers/BarCodeController.php | 6 +- app/Http/Controllers/TestResultController.php | 56 ++++- resources/js/show/config/urls.js | 4 +- resources/js/show/router/paths.js | 5 + .../show/views/TestResult/ShowTestResult.vue | 228 ++++++++++++++++++ .../vue/components/modal/barcode/Barcode.vue | 4 +- resources/js/vue/views/TestResult/List.vue | 6 +- resources/js/vue/views/TestType/List.vue | 16 ++ routes/web.php | 1 + 9 files changed, 319 insertions(+), 7 deletions(-) create mode 100644 resources/js/show/views/TestResult/ShowTestResult.vue diff --git a/app/Http/Controllers/BarCodeController.php b/app/Http/Controllers/BarCodeController.php index 6f591e81..f4aa4df0 100644 --- a/app/Http/Controllers/BarCodeController.php +++ b/app/Http/Controllers/BarCodeController.php @@ -18,8 +18,12 @@ class BarCodeController extends Controller $Barcode = DNS1D::getBarcodePNG($Number, "C128"); $QRCode = DNS2D::getBarcodePNG($URL, "QRCODE"); + $ShowLink = 'Show/'.$Type.'/'.$Number; + if ($Type == 'TestType') { + $QRCode = DNS2D::getBarcodePNG($Number, "QRCODE"); + } - return \MessageResponse::data(['Barcode' => 'data:image/png;base64,' .$Barcode, 'QRCode' => 'data:image/png;base64,' .$QRCode, 'ShowLink' => 'Show/'.$Type.'/'.$Number]); + return \MessageResponse::data(['Barcode' => 'data:image/png;base64,' .$Barcode, 'QRCode' => 'data:image/png;base64,' .$QRCode, 'ShowLink' => $ShowLink]); } } public function generateQRcode(TestResult $TestResult) diff --git a/app/Http/Controllers/TestResultController.php b/app/Http/Controllers/TestResultController.php index 316b2557..6fa47650 100644 --- a/app/Http/Controllers/TestResultController.php +++ b/app/Http/Controllers/TestResultController.php @@ -485,6 +485,60 @@ class TestResultController extends Controller //--------------------------------------------------------------------------Show public function showTestResult($id) { - return view('ShowTestResult', compact('id')); + $TestResult = TestResult::with('input_values', 'user.medical_center', 'test_type')->select('result', 'verified', 'device_id','user_id','id', 'test_type_id', 'created_at')->findOrFail($id); + $options = []; + foreach ($TestResult->input_values as $value) { + $input = $value->input; + + if ($input->parent_id != null && $input->parent['type'] == 'Form') { + //----------------------------------------------------------------------FormType + if ($input->type == 'Checkbox' || $input->type == 'Select' || $input['type'] == 'Radiobutton') { + $input_options = InputValue::with('option')->where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get(); + $options = []; + foreach ($input_options as $input_option) { + $options[] = $input_option->option->title; + $input_values[$input->name] = $options; + } + + $children[$input->parent->name] = $input_values; + $TestResult['children'] = $children; + } + else { + + $children[$input->parent->name][$input->name] = $value->value; + $TestResult['children'] = $children; + } + //-----------------------------------------------------------------------FormType + } + else { + //-----------------------------------------------------------------------Anothertype + if ($input->type == 'Checkbox' || $input->type == 'Select' || $input['type'] == 'Radiobutton') { + $input_options = InputValue::with('option')->where('test_result_id', $TestResult->id)->where('input_id', $input->id)->get(); + $options = []; + foreach ($input_options as $input_option) { + $options[] = $input_option->option->title; + } + + $values[$input->name] = $options; + $TestResult['options'] = $values; + } + else { + $inputs[$input->name] = $value->value; + $TestResult['inputs'] = $inputs; + } + //-----------------------------------------------------------------------Anothertype + } + } + + $ImagesPath = []; + if (count($TestResult->TitleImage)) { + foreach ($TestResult->TitleImage as $Key => $TitleImage) { + $ImagesPath[] = $TitleImage->path; + } + $TestResult['imagesPath'] = $ImagesPath; + } + // dd($TestResult->test_type()->device_label); + $TestResult['device_label'] = $TestResult->test_type->device_label; + return \MessageResponse::data($TestResult); } } diff --git a/resources/js/show/config/urls.js b/resources/js/show/config/urls.js index 05a55d93..824a3785 100644 --- a/resources/js/show/config/urls.js +++ b/resources/js/show/config/urls.js @@ -1,5 +1,7 @@ const urls = { - + showTestResult: function(id) { + return `/ShowTestResult/${id}`; + }, showItem: function(id) { return `/ShowItem/${id}`; }, diff --git a/resources/js/show/router/paths.js b/resources/js/show/router/paths.js index b75f375e..fa247d16 100644 --- a/resources/js/show/router/paths.js +++ b/resources/js/show/router/paths.js @@ -30,4 +30,9 @@ export default [ name: 'ShowCycle', view: 'Cycle/ShowCycle' }, + { + path: '/Show/TestResult/:id', + name: 'ShowTestResult', + view: 'TestResult/ShowTestResult' + }, ] diff --git a/resources/js/show/views/TestResult/ShowTestResult.vue b/resources/js/show/views/TestResult/ShowTestResult.vue new file mode 100644 index 00000000..31c6fa02 --- /dev/null +++ b/resources/js/show/views/TestResult/ShowTestResult.vue @@ -0,0 +1,228 @@ + + + + diff --git a/resources/js/vue/components/modal/barcode/Barcode.vue b/resources/js/vue/components/modal/barcode/Barcode.vue index 9ef340c5..c6c1e1fd 100644 --- a/resources/js/vue/components/modal/barcode/Barcode.vue +++ b/resources/js/vue/components/modal/barcode/Barcode.vue @@ -14,7 +14,8 @@ - + + @@ -45,6 +46,7 @@ export default { this.ShowLink = this.getModalProperties.result.data.data.ShowLink ? this.getModalProperties.result.data.data.ShowLink : '#'; this.Type = this.ShowLink.split('/')[1]; this.ID = this.ShowLink.split('/')[2]; + }, computed: { ...mapGetters("modal", ["getModalProperties", "getModalLink"]) diff --git a/resources/js/vue/views/TestResult/List.vue b/resources/js/vue/views/TestResult/List.vue index b2687116..cc733168 100644 --- a/resources/js/vue/views/TestResult/List.vue +++ b/resources/js/vue/views/TestResult/List.vue @@ -141,7 +141,7 @@ fas fa-eye Show - + fas fa-eye generate Barcode @@ -313,8 +313,8 @@ export default { this.testTypes = result.data.data.TestTypes; } }, - async generateBarcode(id) { - const result = await ApiService.post(urls.TestResultQRcode(id)); + async generateBarcode(id, type) { + const result = await ApiService.post(urls.Barcode(id, type)); if (result && result.status == 200) { this.changeCurrentModal({ modal: "modal-barcode-barcode", diff --git a/resources/js/vue/views/TestType/List.vue b/resources/js/vue/views/TestType/List.vue index 7a6b1f8a..027ebd00 100644 --- a/resources/js/vue/views/TestType/List.vue +++ b/resources/js/vue/views/TestType/List.vue @@ -116,6 +116,10 @@ fas fa-folder Archive + + fas fa-barcode + Generate Barcode + @@ -140,6 +144,8 @@