diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 4e22dbbd..7a9e9263 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -1165,21 +1165,24 @@ class ClientController extends AdminController $self = $policy_terms_data->family_floaters; } - $emp_count = $this->employeeModel->join('client_policy cp', "employees.client_id = cp.client_id") - ->join('employee_polices ep', "cp.id = ep.client_policy_id AND employees.id = ep.employee_id") - ->where("employees.client_id", $record['client_id']) - ->where("employees.emp_status", 'active') - ->where("ep.status", 'active') - ->where("employees.is_active", 1) - ->where("ep.is_active", 1) + // $emp_count = $this->employeeModel + // ->join('client_policy cp', "employees.client_id = cp.client_id") + // ->join('employee_polices ep', "cp.id = ep.client_policy_id AND employees.id = ep.employee_id") + // ->where("employees.client_id", $record['client_id']) + // ->where("employees.emp_status", 'active') + // ->where("ep.status", 'active') + // ->where("employees.is_active", 1) + // ->where("ep.is_active", 1) + // ->countAllResults(); + + + $emp_count = $this->employeePolicyModel + ->join('client_policy cp', "cp.id = employee_polices.client_policy_id") + ->where("employee_polices.client_policy_id", $client_policy_id) + ->where("employee_polices.status", 'active') + ->where("employee_polices.is_active", 1) ->countAllResults(); - - // $data = $this->employeePolicyModel->select('employee_polices.id') - // ->where('employee_polices.is_active', 1) - // ->where('employee_polices.client_policy_id', $client_policy_id) - // ->findAll(); - // $emp_count = count($data); // if($emp_count == 0){ @@ -1289,14 +1292,14 @@ class ClientController extends AdminController // print_r($premium1); // print_r($premium2); die; - return $this->respond(['status' => true, 'code' => 200, 'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200); + return $this->respond(['status' => true, 'code' => 200, 'data' => $resultss, 'premiumData' => json_encode($premiumDataa), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200); } else if ($search_term === 'GPA') { - return $this->respond(['status' => true, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200); + return $this->respond(['status' => true, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200); } else { - return $this->respond(['status' => false, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self], 200); + return $this->respond(['status' => false, 'code' => 200, 'data' => $results, 'premiumData' => json_encode($premiumData), 'count' => $emp_count, 'policy_name' => $policy_name, 'family_floater' => $family_floater, 'self' => $self, 'client_policy_id' => $client_policy_id], 200); } } diff --git a/app/Views/policy_grid.php b/app/Views/policy_grid.php index e3c8ff95..c96b1c69 100644 --- a/app/Views/policy_grid.php +++ b/app/Views/policy_grid.php @@ -1,3 +1,5 @@ + + - -
-
+
+ + Copy from excel
-
+
+
+ +
@@ -158,6 +173,26 @@ $('#btnGridSubmit').hide(); $('.close').click(function() { + $('#grid_content_input').show(); + $('#grid_content_from_excel').hide(); + + if ($('#copyfromexcel').text() == "Manual entry") { + $('#copyfromexcel').text("Copy from excel") + } else { + $('#copyfromexcel').text("Copy from excel"); + } + + + $('#additional_grid_content_input').show(); + $('#additional_grid_content_from_excel').hide(); + + if ($('#copyfromexcelforadditional').text() == "Manual entry") { + $('#copyfromexcelforadditional').text("Copy from excel") + } else { + $('#copyfromexcelforadditional').text("Copy from excel"); + } + + for (var i = 1; i <= 13; i++) { $('#grid_' + i).remove(); $('#add_grid_' + i).remove(); @@ -166,6 +201,7 @@ $('.close').click(function() { }); $('#copyfromexcel').click(function() { + // alert('called'); // $('#copyfromexcel').toggle(); // $("#copied_excel_data").val(result.exampleMessage); @@ -182,6 +218,22 @@ $('#copyfromexcel').click(function() { +}); + +$('#copyfromexcelforadditional').click(function() { + + if ($(this).text() == "Copy from excel") { + $(this).text("Manual entry") + + } else { + $(this).text("Copy from excel"); + } + + $('#additional_grid_content_input').toggle(); + $('#additional_grid_content_from_excel').toggle(); + + + }); function addGridHTML(event = false, data = false, ui_type = false, si_or_bp = false, rr_type = false) { @@ -807,8 +859,7 @@ $("#GridForm").submit(function(event) { $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); - var message = (policy_PrimaryKey === '') ? 'Policy Premium Added successfully' : - 'Policy Premium Added Successfully'; + var message = (policy_PrimaryKey === '') ? 'Policy Premium Added successfully' :'Policy Premium Added Successfully'; toastr.success(message, 'Success'); // $('.close').click(); @@ -829,7 +880,6 @@ $("#GridForm").submit(function(event) { $("#AdditionalGridForm").submit(function(event) { var check = checkDuplicate(1); - event.preventDefault(); if ($('#grid_emp_count').val() == 'false') { @@ -966,18 +1016,21 @@ $('body').on('click', '.btnPolicyModel', function() { res.premiumData = JSON.parse(res.premiumData); console.log('policy grid responce', res.premiumData); - console.log('policy grid responce', res.policy_name); + console.log('policy name', res.policy_name); - $('#nameOfThePolicy').html(' - ' + res.policy_name); + $('#nameOfThePolicy').text(' - ' + res.policy_name); $('#grid_emp_count').val(res.count); if (res.count > 0) { $("#hide_smbt_btn").hide(); + $("#secondary_rack_rate_btn_grp").hide(); } else { $("#hide_smbt_btn").show(); + $("#secondary_rack_rate_btn_grp").show(); } + if (res.status === false) { toastr.error(res.status); @@ -1037,8 +1090,6 @@ $('body').on('click', '.btnPolicyModel', function() { console.log('policy_grid_id_value', policy_grid_id_value); console.log('secondary_policy_grid_id_value', secondary_policy_grid_id_value); - - $('#grid_content_input').empty(); var policeGridOptionHTML = ''; policeGridOptionHTML += ` `; @@ -1050,7 +1101,7 @@ $('body').on('click', '.btnPolicyModel', function() { }); - + $('#additional_grid_content_input').empty(); var policeGridOptionHTMLforSecondary = ''; policeGridOptionHTMLforSecondary += ` `; @@ -1129,7 +1180,12 @@ $('body').on('click', '.btnPolicyModel', function() { $(this).trigger('keyup'); }); - var id_for_trigger = temp_for_premiumData[0].policy_grid_id; + var id_for_trigger = []; + if (temp_for_premiumData.length > 0 && temp_for_premiumData[0] !== undefined) { + id_for_trigger = temp_for_premiumData[0].policy_grid_id; + } + + $(`input[name="${id_for_trigger}_si[]"]`).each(function() { // console.log($(this)); $(this).trigger('keyup'); @@ -1167,6 +1223,8 @@ $('body').on('click', '.btnPolicyModel', function() { $('#grid').change(function() { + $('.excel_textarea').val(''); + var grid_id = $(this)[0].value; var client_policy_id = $('#client_policy_id')[0].value; @@ -1239,7 +1297,6 @@ $('#grid').change(function() { si_or_bp_value = res.premiumData[0].si_or_bp; $('#si_or_bp').val(si_or_bp_value); - } @@ -1277,6 +1334,8 @@ $('#grid').change(function() { $('#additional_grid').change(function() { + $('.excel_textarea').val(''); + var grid_id = $(this)[0].value; var client_policy_id = $('#client_policy_id')[0].value; @@ -1302,9 +1361,9 @@ $('#additional_grid').change(function() { if (res.count > 0) { // console.log(' hide submit btn count ', res.count); - $("#hide_smbt_btn").hide(); + $("#secondary_rack_rate_btn_grp").hide(); } else { - $("#hide_smbt_btn").show(); + $("#secondary_rack_rate_btn_grp").show(); // console.log('show submit btn count ', res.count); } @@ -1315,9 +1374,9 @@ $('#additional_grid').change(function() { if (res.count > 0) { // console.log(' hide submit btn count ', res.count); - $("#hide_smbt_btn").hide(); + $("#secondary_rack_rate_btn_grp").hide(); } else { - $("#hide_smbt_btn").show(); + $("#secondary_rack_rate_btn_grp").show(); // console.log('show submit btn count ', res.count); } @@ -1332,7 +1391,7 @@ $('#additional_grid').change(function() { policy_grid_id_value = res.premiumData[0].policy_grid_id; } - $('#grid_content_input').empty(); + $('#additional_grid_content_input').empty(); var policeGridOptionHTML = ''; policeGridOptionHTML += ` `; $.each(res.data, function(index, item) { @@ -1341,7 +1400,9 @@ $('#additional_grid').change(function() { 'selected="selected"' : '') + '>' + item.policy_grid_type + ''; }); + // $('#grid').html(policeGridOptionHTML); + var si_or_bp_value = ''; if (res.premiumData && res.premiumData.length > 0) { @@ -2530,12 +2591,16 @@ function getCurrentTime() { function createCheckboxes(obj, additional_relationship) { - console.log('createCheckboxes function called'); - console.log(additional_relationship) - additional_relationship = JSON.parse(additional_relationship); - console.log(additional_relationship) + console.log(additional_relationship); + try { + additional_relationship = JSON.parse(additional_relationship); + console.log(additional_relationship); + } catch (error) { + console.error("Error parsing additional_relationship:", error); + return; + } $('#relationship').empty(); const $relationshipElement = $('#relationship'); @@ -2545,24 +2610,24 @@ function createCheckboxes(obj, additional_relationship) { const multiplier = 7; // Adjust this value as needed $.each(obj, function(key, value) { - if (value > 0 && key != 'either-parents-pil') { - + const isChecked = additional_relationship && typeof additional_relationship === 'object' && additional_relationship[key] == 1 ? 'checked' : ''; key = formatString(key); - const isChecked = additional_relationship && additional_relationship[key] === 1 ? 'checked' : ''; + console.log('isChecked', isChecked); html += `
- +
`; + // console.log(html); } }); $relationshipElement.append(html); - } + function formatString(str) { return str.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1)).join(' '); } diff --git a/app/Views/policy_grid_excel.php b/app/Views/policy_grid_excel.php index 50487a0a..009c6bb6 100644 --- a/app/Views/policy_grid_excel.php +++ b/app/Views/policy_grid_excel.php @@ -1,241 +1,412 @@ +table { + border-collapse: collapse; + width: 100%; +} -
- - -

Paste excel data here: Copy Excel Headers

-
- - -
-
- -
-
- -

-

JSON output:

-
-
+td, +th { + padding: 0.2rem; +} - -
+ $(`input[name="${formatType}_premium[]"]`).each(function() { + // console.log($(this)); + $(this).trigger('keyup'); + }); + + + + } + + \ No newline at end of file