diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 85fe7c76..4d6c729d 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -49,7 +49,8 @@ $routes->group("/client", ["filter" => "authMVC"], function($routes){ $routes->group("relation", ["filter" => "authMVC"], function($routes){ $routes->post("create", "ClientController::createClientRelation"); $routes->post("edit", "ClientController::editClientRelation"); - }); + }); + $routes->group("policy", ["filter" => "authMVC"], function($routes){ $routes->post("create", "ClientController::createClientPolicy"); $routes->post("edit", "ClientController::editClientPolicy"); @@ -57,16 +58,24 @@ $routes->group("/client", ["filter" => "authMVC"], function($routes){ $routes->post("jsonPost", "ClientController::jsonPost"); $routes->get("getjson", "ClientController::getjson"); }); + $routes->group("kyc", ["filter" => "authMVC"], function($routes){ $routes->post("create", "ClientController::createClientKYCInfo"); $routes->post("edit", "ClientController::editClientKYCInfo"); $routes->get("list/(:any)", "ClientController::getKycDocsById/$1"); $routes->get("delete/(:any)", "ClientController::deleteClientKycDocs/$1"); }); + $routes->group("premimum", ["filter" => "authMVC"], function($routes){ $routes->post("create", "ClientController::createClientPolicyPremium"); $routes->post("edit", "ClientController::editClientPolicyPremium"); }); + + $routes->group("terms", ["filter" => "authMVC"], function($routes){ + $routes->post("gpa_create", "ClientController::policyGPATerms"); + $routes->post("edit", "ClientController::editClientPolicyPremium"); + }); + }); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 743623ff..0d0b3097 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -499,7 +499,6 @@ class ClientController extends AdminController } } - public function createClientPolicyPremium() { $policy_type = $this->request->getPost('policy_type'); @@ -642,9 +641,6 @@ class ClientController extends AdminController $policy_id = $this->request->getGet('policy_id'); $client_id = $this->request->getGet('client_id'); - echo $policy_id; - echo $client_id; - $data = $this->policesModel->getPolicyPremium($policy_id); $pattern = '/gmc/i'; $subject = $data[0]->policy_type; @@ -656,17 +652,11 @@ class ClientController extends AdminController $results = $this->policyGridModel->like('policy_type', $search_term)->findAll(); if($search_term === 'GPA'){ - $premiumData = $this->policyPremium1Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); }else{ $premiumData = $this->policyPremium2Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); - } - - - // echo '
';
- // print_r($results);
- // print_r($data[0]->policy_type); die;
+
echo json_encode(array("status" => true , 'data' => $results, 'premiumData' => $premiumData));
}
@@ -734,10 +724,6 @@ class ClientController extends AdminController
$data['specialConditionLabel'] = $this->request->getPost("specialConditionLabel") ?? [];
$data['specialConditionInput'] = $this->request->getPost("specialConditionInput") ?? [];
- // print_r($data);
-
- // print_r($this->request->getPost());
- // die();
$jsonData = json_encode($data);
$dataa = array(
@@ -745,7 +731,9 @@ class ClientController extends AdminController
'client_id' => $client_id,
'policy_id' => $policy_id
);
+
$record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first();
+
if ($record) {
$update = $this->clientPolicyModel->update($record['id'], $dataa);
if ($update) {
@@ -762,6 +750,118 @@ class ClientController extends AdminController
}
}
} catch (\Exception $e) {
+
+ echo "Failed to insert data: " . $e->getMessage();
+ // Log the error
+ log_message('error', 'Failed to insert data: ' . $e->getMessage());
+ }
+
+ }
+
+ public function getjson()
+ {
+ $client_id = $this->request->getVar('client_id');
+ $policy_id = $this->request->getVar('policy_id');
+ $record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first();
+
+ if ($record) {
+ echo $record['policy_terms'];
+
+ } else {
+ echo "Record not found.";
+ }
+
+ }
+
+ public function policyGPATerms()
+ {
+
+ try {
+ $this->myLogger->logme('error','Policy GPA Terms CREATE function called');
+
+ // print_r($this->request->getPost());
+ $client_id = $this->request->getPost("client_id");
+ $policy_id = $this->request->getPost("policy_id");
+
+ $data['sumInsured2'] =$this->request->getPost("sumInsured2");
+ $data['totalSumInsured'] =$this->request->getPost("totalSumInsured");
+ $data['accidentalDeathBenefit'] =$this->request->getPost("accidentalDeathBenefit");
+ $data['permanentTotalDisablement'] =$this->request->getPost("permanentTotalDisablement");
+ $data['permanentPartialDisablement'] =$this->request->getPost("permanentPartialDisablement");
+ $data['temporaryTotalDisablementBenefit'] =$this->request->getPost("temporaryTotalDisablementBenefit");
+ $data['accidentalHospitalizationExpenses'] =$this->request->getPost("accidentalHospitalizationExpenses");
+ $data['childrenEducationWelfareFund'] =$this->request->getPost("childrenEducationWelfareFund");
+
+ $data['compassionateVisitExpenses'] =$this->request->getPost("compassionateVisitExpenses");
+ if ($data['compassionateVisitExpenses'] == 1) {
+ $data['compassionateVisitExpensesData'] =$this->request->getPost("compassionateVisitExpensesData");
+ }else{
+ $data['compassionateVisitExpensesData'] ="";
+ }
+
+ $data['brokenBoneExpenses'] = $this->request->getPost("brokenBoneExpenses");
+ if ($data['brokenBoneExpenses'] == 1) {
+ $data['brokenBoneExpensesData'] = $this->request->getPost("brokenBoneExpensesData");
+ }else{
+ $data['brokenBoneExpensesData'] ="";
+ }
+
+ $data['ambulanceCharges'] =$this->request->getPost("ambulanceCharges");
+ if ($data['ambulanceCharges'] == 1) {
+ $data['ambulanceChargesData'] =$this->request->getPost("ambulanceChargesData");
+ }else{
+ $data['ambulanceChargesData'] ="";
+ }
+
+ $data['burnExpenses'] = $this->request->getPost("burnExpenses");
+ if ($data['burnExpenses'] == 1) {
+ $data['burnExpensesData'] = $this->request->getPost("burnExpensesData");
+ }else{
+ $data['burnExpensesData'] = "";
+ }
+
+ $data['carriageOfDeadBody'] = $this->request->getPost("carriageOfDeadBody");
+ if ($data['carriageOfDeadBody'] == 1) {
+ $data['carriageOfDeadBodyData'] = $this->request->getPost("carriageOfDeadBodyData");
+ }else{
+ $data['carriageOfDeadBodyData'] = "";
+ }
+
+ $data['animalSnakeInsectBite'] = $this->request->getPost("animalSnakeInsectBite");
+ $data['terrorism'] = $this->request->getPost("terrorism");
+ $data['worldwideCover'] = $this->request->getPost("worldwideCover");
+
+
+ print_r($data);
+
+ // print_r($this->request->getPost());
+ // die();
+
+ $jsonData = json_encode($data);
+ $dataa = array(
+ 'policy_terms' => $jsonData,
+ 'client_id' => $client_id,
+ 'policy_id' => $policy_id
+ );
+ $record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first();
+ if ($record) {
+ $update = $this->clientPolicyModel->update($record['id'], $dataa);
+ if ($update) {
+ $response = array('message' => 'Data updated successfully');
+ header('Content-Type: application/json');
+ echo json_encode($response);
+ } else {
+ echo json_encode(array('message' => 'Failed to update data'));
+ }
+ }else{
+ $insert = $this->clientPolicyModel->insert($dataa);
+ if ($insert) {
+ echo json_encode(array('message' => 'Data stored successfully'));
+ } else {
+ echo json_encode(array('message' => 'Failed to store data'));
+ }
+ }
+ } catch (\Exception $e) {
// Handle the exception
echo "Failed to insert data: " . $e->getMessage();
// Log the error
@@ -770,16 +870,14 @@ class ClientController extends AdminController
}
+ public function getPolicyGPATerms(){
-
- public function getjson()
- {
$client_id = $this->request->getVar('client_id');
$policy_id = $this->request->getVar('policy_id');
$record = $this->clientPolicyModel->where(['client_id' => $client_id, 'policy_id' => $policy_id])->first();
if ($record) {
- echo $record['json'];
+ echo $record['policy_terms'];
} else {
echo "Record not found.";
diff --git a/app/Models/ClientPolicyModel.php b/app/Models/ClientPolicyModel.php
index 9a9cf2f3..ef70ef5b 100644
--- a/app/Models/ClientPolicyModel.php
+++ b/app/Models/ClientPolicyModel.php
@@ -35,7 +35,7 @@ class ClientPolicyModel extends Model
"earned_premium_amount",
"claims_incurred_amount",
- "json",
+ "policy_terms",
"created_by",
"updated_by",
"Is_active",
diff --git a/app/Views/client_basic_info.php b/app/Views/client_basic_info.php
index 9df58db2..dd4b3621 100644
--- a/app/Views/client_basic_info.php
+++ b/app/Views/client_basic_info.php
@@ -139,6 +139,9 @@ $(document).ready(function () {
form_action = '= base_url("client/general/edit"); ?>';
}
+ $('.loader').fadeIn();
+ $('.loader-mask').fadeIn();
+
var formData = new FormData($('#general_form')[0]);
var OptionsHTML1 = ''
@@ -150,8 +153,19 @@ $(document).ready(function () {
processData: false,
contentType: false,
success: function(res) {
+
+ if(res){
+ setTimeout(function() {
+
+ $('.loader').fadeOut();
+ $('.loader-mask').delay(350).fadeOut('slow');
+ $('#kyc_tab').click();
+ var message = (PrimaryKey === '') ? 'Client General Info Created successfully' : 'Client General Info Updated successfully';
+ toastr.success(message, 'Success');
+
+ }, 1000);
+ }
- console.log(res);
$('#client_id').val(res.data.id);
$('#client_id_relation').val(res.data.id);
$('#client_id_branch').val(res.data.id);
@@ -160,10 +174,6 @@ $(document).ready(function () {
$('#policy_PrimaryKey').val(res.data.id);
$('#client_id_kyc').val(res.data.id);
$('#entity_type').val(res.data.entity_type_id);
- $('#kyc_tab').click();
-
- var message = (PrimaryKey === '') ? 'Client General Info Created successfully' : 'Client General Info Updated successfully';
- toastr.success(message, 'Success');
$.ajax({
url: '= base_url("client/kyc/list/"); ?>' + res.data.entity_type_id,
diff --git a/app/Views/client_branch.php b/app/Views/client_branch.php
index 23dc8c51..dee42779 100644
--- a/app/Views/client_branch.php
+++ b/app/Views/client_branch.php
@@ -237,6 +237,9 @@ $(document).ready(function () {
if (isValid) {
+ $('.loader').fadeIn();
+ $('.loader-mask').fadeIn();
+
var formData = new FormData($('#branch_form')[0]);
$.ajax({
@@ -247,9 +250,21 @@ $(document).ready(function () {
processData: false,
contentType: false,
success: function(res) {
- console.log(res);
- var message = (branch_PrimaryKey === '') ? 'Client General Info Created successfully' : 'Client General Info Updated successfully';
- toastr.success(message, 'Success');
+
+ if(res){
+ setTimeout(function() {
+
+ $('.loader').fadeOut();
+ $('.loader-mask').delay(350).fadeOut('slow');
+ $('#add_branch').hide();
+ $('#branch_table').show();
+ $('.btnBack').hide();
+ $('#btnBranchAdd').show();
+ var message = (branch_PrimaryKey === '') ? 'Client Branch Created successfully' : 'Client Branch Updated successfully';
+ toastr.success(message, 'Success');
+ }, 1000);
+ }
+
$('#branch_list tr').remove();
var branchTableInsert = ''
$.each(res.data, function(index, item) {
@@ -262,10 +277,7 @@ $(document).ready(function () {
`;
});
$('#branch_list').append(branchTableInsert);
- $('#add_branch').hide();
- $('#branch_table').show();
- $('.btnBack').hide();
- $('#btnBranchAdd').show();
+
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
diff --git a/app/Views/client_kyc.php b/app/Views/client_kyc.php
index 154e5d06..68aa6ef8 100644
--- a/app/Views/client_kyc.php
+++ b/app/Views/client_kyc.php
@@ -168,8 +168,6 @@
});
});
- ;
-
if(kycPrimaryKey !== ''){
$.ajax({
@@ -203,8 +201,10 @@
}
});
+
var table = '';
var data = = isset($client_kyc) ? json_encode($client_kyc) : '[]' ?>;
+
console.log(data)
$('#other_docs tr').remove();
$.each(data, function(index, item) {
@@ -221,14 +221,15 @@
});
$('#other_docs').append(table);
+
$.each(data, function(index, item) {
// console.log(item.kyc_doc_type_id);
// console.log('name_' + item.kyc_doc_type_id);
// console.log(document.getElementById('name_' + item.kyc_doc_type_id));
setTimeout(function() {
- $('#name_'+item.kyc_doc_type_id).show();
- $('#name_'+item.kyc_doc_type_id).html(item.file_name);
- $('#form_'+item.kyc_doc_type_id).hide();
+ $('#name_'+item.id).show();
+ $('#name_'+item.id).html(item.file_name);
+ $('#form_'+item.id).hide();
}, 1000);
});
diff --git a/app/Views/client_onboarding.php b/app/Views/client_onboarding.php
index 92d70c6a..bd5248f2 100644
--- a/app/Views/client_onboarding.php
+++ b/app/Views/client_onboarding.php
@@ -36,12 +36,15 @@ body {
- Client Onboarding
+ Client Onboarding
+
+
+