From 2e6dc18b7a733f0693e07b46e28dbed4764332ff Mon Sep 17 00:00:00 2001 From: "venkatesh.r" Date: Thu, 1 Aug 2024 08:37:19 +0530 Subject: [PATCH] FEAT_INSURER_EXPORT_TEMPLATE_PAGE_AND_COPY_INSURER_TEMPLATE : RV --- app/Config/Routes.php | 2 + app/Controllers/MasterController.php | 47 +++++++- app/Views/insurer_basic_info.php | 46 ++++---- app/Views/insurer_export_templete.php | 152 ++++++++++++++++++++++++++ app/Views/insurer_onboarding.php | 46 +++----- 5 files changed, 235 insertions(+), 58 deletions(-) create mode 100644 app/Views/insurer_export_templete.php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 440895a8..3ca47517 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -275,6 +275,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("remove_rack_rate/(:any)", "ClientController::removeRackRate/$1"); $routes->get("get_client_policy_list_for_remainder/(:any)", "EmployeeController::get_client_policy_list_for_remainder/$1"); $routes->get("send_manual_remainder/(:any)", "DashboardController::sendManualRemainder/$1"); + $routes->get("get_insurer_by_export_templete", "MasterController::getInsurerByExportTemplete"); + $routes->get("copy_insurer_templete/(:any)", "MasterController::copyInsurerTemplete/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 603f9e51..969f01c6 100644 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -29,6 +29,7 @@ use App\Models\StateModel; use App\Models\PolicyTypeModel; use App\Models\CDMasterModel; use App\Models\ClientDepositModel; +use App\Models\InsurerExcelExportTemplateModel; class MasterController extends AdminController { @@ -52,6 +53,7 @@ class MasterController extends AdminController protected $CDMasterModel; protected $clientModel; protected $clientDepositModel; + protected $insurerTemplateModel; @@ -60,7 +62,7 @@ class MasterController extends AdminController set_session_context('Master'); $this->myLogger = \Config\Services::mylogger(); - $this->insurerModel = new ClientModel(); + // $this->insurerModel = new ClientModel(); $this->userModel = new UserModel(); // $this->insurerBranchModel = new ClientBranchModel(); $this->insurerKYCDocsModel = new ClientKYCDocsModel(); @@ -79,6 +81,7 @@ class MasterController extends AdminController $this->CDMasterModel = new CDMasterModel(); $this->clientModel = new ClientModel(); $this->clientDepositModel = new ClientDepositModel(); + $this->insurerTemplateModel = new InsurerExcelExportTemplateModel(); } @@ -150,6 +153,7 @@ class MasterController extends AdminController $editData['insurer'] = $this->insurerModel->where(['id' => $id, 'is_active' => 1])->first(); $editData['insuer_branch'] = $this->insurerBranchModel->where(['insurer_id' => $id, 'is_active' => 1])->findAll(); + $editData['insurer_templete_count'] = $this->insurerTemplateModel->where(['insurer_id' => $id, 'is_active' => 1])->countAllResults(); // echo "
";
@@ -209,7 +213,8 @@ class MasterController extends AdminController
         $insert = $this->insurerModel->insert($data);
         if($insert){
             $insurer_data = $this->insurerModel->where(['id' => $insert, 'is_active' => 1])->first();
-            echo json_encode(array("status" => true , 'data' => $insurer_data));
+            $insurer_templete_count = $this->insurerTemplateModel->where(['insurer_id' => $insert, 'is_active' => 1])->countAllResults();
+            echo json_encode(array("status" => true , 'data' => $insurer_data, 'templete_count' => $insurer_templete_count));
         }else{
             echo json_encode(array("status" => false));
         }
@@ -337,6 +342,44 @@ class MasterController extends AdminController
         }
     }
 
+    public function getInsurerByExportTemplete()
+    {
+        $insurer_data = $this->insurerModel
+            ->select('insurers.name as insurer_name, insurers.id, insurers.is_multi_event')
+            ->join('insurer_excel_export_template', 'insurer_excel_export_template.insurer_id = insurers.id')
+            ->groupBy('insurers.id')
+            ->findAll();
+
+        return $this->respond(['status' => true, 'code' => 200, 'data' => $insurer_data], 200);
+    }
+
+    public function copyInsurerTemplete($existing_insurer_id, $copy_insurer_id)
+    {
+        $insurer_templete_data = $this->insurerTemplateModel->where('insurer_id', $existing_insurer_id)->findAll();
+        $existing_insurer_templete_data =  $this->insurerTemplateModel->where('insurer_id', $copy_insurer_id)->delete();
+
+        $data_to_insert = [];
+        foreach ($insurer_templete_data as $value) {
+            $data_to_insert[] = [
+                "insurer_id" => $copy_insurer_id,
+                "policy_type_id" => $value['policy_type_id'],
+                "event_name" => $value['event_name'],
+                "type_name" => $value['type_name'],
+                "jsoncolumns" => $value['jsoncolumns'],
+                "created_by" => get_session_user(),
+                "is_active" => 1,
+            ];
+        }
+
+        $insert_result = $this->insurerTemplateModel->insertBatch($data_to_insert);
+        if($insert_result){
+            return $this->respond(['status' => true, 'message' => 'Template added successfully',  $insurer_templete_data]);
+        }else{
+            return $this->respond(['status' => true, 'message' => 'Failed to add template',  $insurer_templete_data]);
+        }
+
+
+    }
     // Insurer Ends
 
 
diff --git a/app/Views/insurer_basic_info.php b/app/Views/insurer_basic_info.php
index 8ba9dcc2..1ab97fc8 100644
--- a/app/Views/insurer_basic_info.php
+++ b/app/Views/insurer_basic_info.php
@@ -150,16 +150,12 @@ input:checked + .slider:before {
         $("#insurer_general_form").submit(function(events) {
 
             events.preventDefault();
-            // var isValid     = validateForm();
 
-            var isValid = true;
-            jQuery.each(events.target, function(index, event) {
-                if (event.validity.valid) {
-
-                } else {
-                    isValid = false;
-                }
-            });
+            var isValid = $('#insurer_General_PrimaryKey').parsley().validate();  
+            if (!isValid) { 
+                console.log('Form is Empty', 'Warning');
+                return ; 
+            }
 
             var PrimaryKey = $('#insurer_General_PrimaryKey').val();
             var form_action = '';
@@ -193,29 +189,25 @@ input:checked + .slider:before {
                         $('#insurer_id').val(res.data.id);
                         $('#insurer_General_PrimaryKey').val(res.data.id);
                         $('#insurer_id_branch').val(res.data.id);
-                        $('#insurer_branch_contacts_id').click();
+                        // $('#insurer_branch_contacts_id').click();
 
                         $('#btnBranchAdd').show();
                         var message = "Insurer General Info";
                         toastr.success(message, 'Success');
-
-                        // $.toast({
-                        //     text: 'Insurer General Info',
-                        //     heading: "Submitted Sucessfully", 
-                        //     position: 'top-right',
-                        //     icon: 'success', 
-                        //     bgColor: !1,
-                        // });
+                        
+                        if (PrimaryKey === '') {
+                            setTimeout(function(){
+                            window.location.href = '' + res.data.id
+                            }, 100)
+                        }
 
                     },
                     error: function(xhr, status, error) {
                         console.error(xhr.responseText);
                         console.error(status, error);
-
-                        setTimeout(function() {
-                            $('.loader').fadeOut();
-                            $('.loader-mask').delay(350).fadeOut('slow');
-                     console.log('Something Wrong!', 'warning');                        }, 1000);
+                        $('.loader').fadeOut();
+                        $('.loader-mask').delay(350).fadeOut('slow');
+                        console.log('Something Wrong!', 'warning');                        
                     }
                 });
             }
@@ -252,7 +244,8 @@ input:checked + .slider:before {
 
     });
 
-    function PreviewImage() {
+    function PreviewImage() 
+    {
         var oFReader = new FileReader();
         oFReader.readAsDataURL(document.getElementById("insurer_logo").files[0]);
 
@@ -260,4 +253,9 @@ input:checked + .slider:before {
             document.getElementById("uploadPreview").src = oFREvent.target.result;
         };
     };
+
+    //-----------------------------------------------------------------------------------------------------
+
+
+
 
\ No newline at end of file
diff --git a/app/Views/insurer_export_templete.php b/app/Views/insurer_export_templete.php
new file mode 100644
index 00000000..3b4c049b
--- /dev/null
+++ b/app/Views/insurer_export_templete.php
@@ -0,0 +1,152 @@
+
+ + +
+
+ + +
+ +
+ + Copy +
+
+ +
+ + + \ No newline at end of file diff --git a/app/Views/insurer_onboarding.php b/app/Views/insurer_onboarding.php index 359543d9..03e9598c 100644 --- a/app/Views/insurer_onboarding.php +++ b/app/Views/insurer_onboarding.php @@ -1,35 +1,3 @@ - -
@@ -59,10 +27,24 @@ body { Branch & Contacts + + + + + + + +
+