CHANGE_BDS_CHANGE_2

This commit is contained in:
VENKATESHWARAN 2025-12-18 18:03:43 +05:30
parent 991147773c
commit b0441597b1
9 changed files with 622 additions and 323 deletions

View File

@ -2398,13 +2398,27 @@ class ClientController extends AdminController
public function uploadVehicleFile()
public function uploadVehicleFile($params = null)
{
$this->myLogger->logme('error', 'uploadVehicleFile function called');
$data = $this->request->getPost();
$files = $this->request->getFiles();
// $data['client_id'] = 12;
// $data['vehicle_id'] = 1;
$client_id = null;
$vehicle_id = null;
$files = null;
$docs_name = null;
if(empty($params) && $this->request){
$data = $this->request->getPost();
$files = $this->request->getFiles();
$client_id = $data['client_id'] ?? null;
$vehicle_id = $data['vehicle_id'] ?? null;
$docs_name = $data['other_docs_name'] ?? null;
}else {
$client_id = $params['client_id'] ?? null;
$vehicle_id = $params['vehicle_id'] ?? null;
$docs_name = $params['other_docs_name'] ?? null;
$files = $params['file_data'] ?? null;
}
// upload path
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
@ -2412,20 +2426,21 @@ class ClientController extends AdminController
$insertedDocs = [];
// Check document names and files
if (isset($data['other_docs_name']) && isset($files['file_name'])) {
foreach ($data['other_docs_name'] as $key => $docName) {
if (!empty($docs_name) && !empty($files) && !empty($client_id) && !empty($vehicle_id)) {
foreach ($docs_name as $key => $docName) {
// Get the corresponding file for this document name
$file = $files['file_name'][$key];
if (!empty($docName) && $file->isValid() && !$file->hasMoved()) {
// Upload the file
$uploadedFileName = file_Upload($file, $uploadFilePath);
$uploadedFileName = file_Upload_for_lead($file, $uploadFilePath);
if ($uploadedFileName) {
// Prepare data for each document upload
$docData = [
'client_id' => $data['client_id'],
'vehicle_id' => $data['vehicle_id'],
'client_id' => $client_id,
'vehicle_id' => $vehicle_id,
'other_docs_name' => $docName,
'file_name' => $uploadedFileName,
'created_by' => get_session_userid(),
@ -2441,16 +2456,21 @@ class ClientController extends AdminController
}
}
if(!empty($params) && !$this->request){
return true;
}
if (!empty($insertedDocs)) {
// Fetch all documents for the client
$vehicleDocs = $this->clientKYCDocsModel
->where('client_id', $data['client_id'])
->where('vehicle_id', $data['vehicle_id'])
->findAll();
return $this->respond(['status' => true, 'code' => 200, 'vehicle_docs' => $vehicleDocs, 'inserted_docs' => $insertedDocs], 200);
return $this->respond(['status' => true, 'code' => 200, 'vehicle_docs' => $vehicleDocs, 'inserted_docs' => $insertedDocs, 'message' => 'File uploaded successfully'], 200);
} else {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No documents uploaded or inserted'], 200);
}
} else {
return $this->respond(['status' => false, 'code' => 400, 'message' => 'Invalid data submission'], 200);
}

View File

@ -934,6 +934,12 @@
{
$data = $this->request->getPost();
$file_data = $this->request->getFiles() ?? null;
$data['file_data'] = $file_data ?? null;
$vehicle_file_data = $this->request->getFiles() ?? null;
$data['vehicle_file_data'] = $vehicle_file_data ?? null;
// print_r($data); die;
if (empty($data['policy_issue_date'])) {
@ -1043,6 +1049,28 @@
}
}
// policy file upload
if(isset($data['doc_name']) && isset($data['file_data']) && !empty($data['doc_name']) && !empty($data['file_data'])){
$this->uploadFile($data['doc_name'], $data['file_data'], $insert);
}
// policy file upload
if(
isset($data['other_docs_name']) && isset($data['vehicle_file_data']) && isset($data['client_id']) && isset($data['vehicle_id']) &&
!empty($data['other_docs_name']) && !empty($data['vehicle_file_data']) && !empty($data['client_id']) && !empty($data['vehicle_id'])
)
{
$vdd = [
'other_docs_name' => $data['other_docs_name'],
'file_data' => $data['vehicle_file_data'],
'client_id' => $data['client_id'],
'vehicle_id' => $data['vehicle_id'],
];
$clientController = new ClientController();
$clientController->uploadVehicleFile($vdd);
}
$client_data = $this->clientModel->where('id', $data['client_id'])->first();
$data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll();
@ -2871,20 +2899,23 @@
//------------------------------------------------------------------------------------------------
//file upload function
public function uploadFile()
public function uploadFile($docs_name = null, $files = null, $pt_id = null)
{
$GoogleDriveController = new GoogleDriveController();
$files = $this->request->getFiles();
$doc_name = $this->request->getPost('doc_name[]');
$pt_id = $this->request->getPost('pt_id');
$client_policy_id = $this->request->getPost('client_policy_id');
$data = $this->request->getPost();
if(empty($docs_name) && empty($files) && empty($pt_id) && $this->request){
$files = $this->request->getFiles();
$docs_name = $this->request->getPost('doc_name');
$pt_id = $this->request->getPost('pt_id');
$client_policy_id = $this->request->getPost('client_policy_id');
}
$uploadFilePath = WRITEPATH . 'uploads/client_kyc_documents';
$uploadData = [];
foreach ($data['doc_name'] as $key => $docName) {
foreach ($docs_name as $key => $docName) {
// Get the corresponding file for this document name
$file = $files['file'][$key];
@ -2892,7 +2923,7 @@
if (!empty($docName) && $file->isValid() && !$file->hasMoved()) {
// Upload the file
$uploadedFileName = file_Upload($file, $uploadFilePath);
$uploadedFileName = file_Upload_for_lead($file, $uploadFilePath);
if ($uploadedFileName) {
// Prepare data for each document upload
@ -2917,6 +2948,10 @@
}
}
if(!empty($docs_name) && !empty($files) && !empty($pt_id) && !$this->request){
return true;
}
// print_r($uploadData); die;
// $uploadData = uploadFilesToGoogleDrive($files['file'], $doc_name, $pt_id);

View File

@ -99,12 +99,14 @@ $("#drive_file_upload_form").submit(function(event) {
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == true){
toastr.success(res.message, 'Success');
toastr.success(res.message, 'SUCCESS');
appendFileTableBody(res.data.pt_files);
}else{
toastr.error(res.message, 'Error');
toastr.warning(res.message, 'WARNING');
}
$('#drive_file_upload_form')[0].reset();
},
error: function (xhr, status, error) {
console.error(xhr.responseText);

View File

@ -2446,26 +2446,71 @@
// }
// }
// if(allocg == "EB"){
// $('.hideter').hide();
// $('.hidetp').hide();
// $('.hidecoter').hide()
// $('.hidecotp').hide()
// }else{
// $('.hidetp').show();
// if(is_co_pay_yes == 1){
// $('.hidecotp').show();
// $('#table_tr_7').show();
// $('#table_tr_35').show();
// $('#table_tr_3').show();
// }else{
// $('.hidecotp').hide();
// $('#table_tr_7').hide();
// $('#table_tr_35').hide();
// $('#table_tr_3').hide();
// }
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
// $('.hideter').show();
// if(is_co_pay_yes == 1){
// $('.hidecoter').show();
// }else{
// $('.hidecoter').hide();
// }
// }else{
// $('.hideter').hide();
// }
// }
if(allocg == "EB"){
$('.hideter').hide();
$('.hidetp').hide();
$('.hidecoter').hide()
$('.hidecotp').hide()
}else{
} else if(allocg == "Non-EB"){
$('.hidetp').hide();
$('.hidecotp').hide();
$('.hideter').show();
if(is_co_pay_yes == 1){
$('.hidecoter').show();
}else{
$('.hidecoter').hide();
}
} else if(allocg == "Motor"){
$('.hideter').hide();
$('.hidecoter').hide();
$('.hidetp').show();
if(is_co_pay_yes == 1){
$('.hidecotp').show();
$('#table_tr_7').show();
$('#table_tr_35').show();
$('#table_tr_3').show();
}else{
$('.hidecotp').hide();
$('#table_tr_7').hide();
$('#table_tr_35').hide();
$('#table_tr_3').hide();
}
} else{
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
$('.hideter').show();
if(is_co_pay_yes == 1){

View File

@ -349,7 +349,7 @@
</label>
<div class="card mb-1">
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_0">
<div class="card-body">
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
<div class="row">
<div class="form-group col-md-3">
<label for="email"> Policy Type <span class="text-danger">*</span></label>
@ -457,15 +457,15 @@
<div class="col-md-12">
<div id="accordion_1" class="mb-0">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<span class="font-color-black">Pre Sales</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
</a>
<span class="font-color-black">Pre Sales</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwo"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</label>
<div class="card mb-1">
<div id="collapseTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_1">
<div class="card-body">
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
<div class="row" id="policyholdernamediv" style="display: none;">
<div class="form-group col-md-3">
<label for="bp_igst">Policyholder Name</label>
@ -490,7 +490,6 @@
</div>
</div>
</div>
<hr>
<div class="row">
<div class="form-group col-md-3">
@ -659,6 +658,48 @@
</div>
</div>
</div>
<!-- Policy Docs Row -->
<div class="row" id="policy_docs" style="display: none;">
<div class="col-md-12">
<div id="accordion_23" class="mb-0">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<span class="font-color-black">Policy Docs</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwentyTwo"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</label>
<div class="card mb-1">
<div id="collapseTwentyTwo" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_23">
<div class="card-body" id="policy_docs_div" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Vehicle Docs Row -->
<div class="row" id="vehicle_docs" style="display: none;">
<div class="col-md-12">
<div id="accordion_22" class="mb-0">
<label id="policyAccordion" class="m-1 d-flex justify-content-between align-items-center">
<span class="font-color-black">Vehicle Docs</span>
<a id="toggleIcon" class="text-dark float-right" data-toggle="collapse" href="#collapseTwentyThree"
aria-expanded="true">
<i id="icon" class="mdi mdi-chevron-up mr-1 text-primary" style="font-size: 28px;"></i>
</a>
</label>
<div class="card mb-1">
<div id="collapseTwentyThree" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_22">
<div class="card-body" id="vehicle_docs_div" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
</div>
</div>
</div>
</div>
</div>
</div>
<!-- sales Row -->
<div class="row" id="sales_row" style="display: none;">
@ -673,7 +714,7 @@
</label>
<div class="card mb-1">
<div id="collapseThree" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_2">
<div class="card-body">
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
<div class="row">
<div class="form-group col-md-3" id="base_policy_id" style="display: none;">
@ -890,7 +931,7 @@
</label>
<div class="card mb-0">
<div id="collapseFour" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion_3">
<div class="card-body">
<div class="card-body" style="background-color: #F5FFFF !important; border-radius: 10px; box-shadow: 4px 4px 4px 4px #00000040;">
<div class="row d-none" id="add_more_row">
<div class="col-md-2">
<!-- <label for="setInsurerCount">Insurer Count : </label> -->
@ -941,7 +982,7 @@
<tr id="table_tr_4">
<td>Base Premium</td>
</tr>
<tr class="hidetp" id="table_tr_5">
<tr class="hidetp" id="table_tr_5" style="display: none;">
<td id="tp_premium_td">TP Premium</td>
</tr>
<tr class="hideter" id="table_tr_6" style="display: none;">
@ -1809,11 +1850,28 @@
var is_co_pay_yes = $('#cop_yes').prop('checked') ? 1 : 0;
if(allocg == "EB"){
$('.hideter').hide();
$('.hidetp').hide();
$('.hidecoter').hide()
$('.hidecotp').hide()
}else{
} else if(allocg == "Non-EB"){
$('.hidetp').hide();
$('.hidecotp').hide();
$('.hideter').show();
if(is_co_pay_yes == 1){
$('.hidecoter').show();
}else{
$('.hidecoter').hide();
}
} else if(value == 8){
$('.hideter').hide();
$('.hidecoter').hide();
$('.hidetp').show();
if(is_co_pay_yes == 1){
@ -1822,6 +1880,8 @@
$('.hidecotp').hide();
}
} else{
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
$('.hideter').show();
if(is_co_pay_yes == 1){
@ -1834,6 +1894,7 @@
}
}
// do not remove this commented item
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
// $('.hideter').show();
@ -1891,7 +1952,7 @@
$('#vhnodiv').show();
$('#client_type_div').hide();
$('#policyholdernamediv').hide();
$('#hide_vehicle_tab').show();
// $('#hide_vehicle_tab').show();
$('#client_type').addClass('readonly-select ');
$('#client_id').addClass('readonly-select ').select2('destroy');
$('#client_branch_id').addClass('readonly-select ').select2('destroy');
@ -1899,7 +1960,7 @@
$('#vehicle_no').val("").select2();
$('#vhnodiv').hide();
$('#client_type_div').show();
$('#hide_vehicle_tab').hide();
// $('#hide_vehicle_tab').hide();
$('#client_type').removeClass('readonly-select ');
$('#client_id').removeClass('readonly-select ').select2();
$('#client_branch_id').removeClass('readonly-select ').select2();
@ -1960,6 +2021,14 @@
$("select[name='cd_ac_no_for_child[]']").attr('required', 'required');
}
if(value == 8){
addHTMLInputForVehicleFileUpload(null, 'vehicle_docs_div')
$('#vehicle_docs').show();
}else{
$('#vehicle_docs').hide();
$('#vehicle_docs_div').empty();
}
});
})
@ -1999,7 +2068,7 @@
$('[name="calc_policy_issue_date[]"]').each(function () {
$(this).val('').removeClass('readonly-select');
});
let policy_issue_date = $('#policy_issue_date').val();
if ($('#cop_yes').is(':checked') && $(this).is(':checked')) {
$('#follower_policy_no_' + uniqueid).prop('readonly', true);
@ -2009,6 +2078,20 @@
$('#calc_policy_issue_date_1').val(policy_issue_date).addClass('readonly-select');
}
if ($(this).is(':checked')) {
// Hide all
$('[name="cd_ac_no_for_child[]"]').hide();
$('[id^="cd_current_balance_"]').hide();
// Show only current one
$('#cd_ac_no_' + uniqueid).show();
$('#cd_current_balance_' + uniqueid).show();
} else {
// Show all back
$('[name="cd_ac_no_for_child[]"]').show();
$('[id^="cd_current_balance_"]').show();
}
});
$(document).on('change', 'select[name="relationship[]"]', function() {
@ -2397,6 +2480,10 @@
$('#is_cd_reduce_from_bds').prop('checked', false);
}
$('#vehicle_docs').hide();
$('#vehicle_docs_div').empty();
} else {
console.log('No data found');
}
@ -2532,7 +2619,7 @@
$('#sgst_' + input).val(isFinite($('#sgst_' + input).val()) ? $('#sgst_' + input).val() : 0);
}
function amountCalculation(input) {
function amountCalculation(input, name = null) {
console.log('############################## AMOUNT CALCULATION ############################################')
console.log('amountCalculation : ' + input);
@ -2717,7 +2804,7 @@
// $('#variance_' + input).val(!isNaN(variance) && isFinite(variance) ? variance.toFixed(2) : '0.00');
let policy_type_id = $('#policy_type_id').val();
if(policy_type_id > 7){
if(policy_type_id > 7 && name == "base_premium[]"){
checkCDAmountForBasePremium(input);
}else{
console.log("First Skip the Ajax Call these are group policies");
@ -4077,7 +4164,58 @@
$('#cop_yes').change(function() {
var selectedOption = $('#policy_type_id').find('option:selected');
var bap = selectedOption.data('bap');
var allocg = selectedOption.data('allocg');
var policy_type_id = $('#policy_type_id').val();
if(allocg == "EB"){
$('.hideter').hide();
$('.hidetp').hide();
$('.hidecoter').hide()
$('.hidecotp').hide()
} else if(allocg == "Non-EB"){
$('.hidetp').hide();
$('.hidecotp').hide();
$('.hideter').show();
if($(this).is(':checked')){
$('.hidecoter').show();
}else{
$('.hidecoter').hide();
}
} else if(policy_type_id == 8){
$('.hideter').hide();
$('.hidecoter').hide();
$('.hidetp').show();
if($(this).is(':checked')){
$('.hidecotp').show();
}else{
$('.hidecotp').hide();
}
} else{
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
$('.hideter').show();
if($(this).is(':checked')){
$('.hidecoter').show();
}else{
$('.hidecoter').hide();
}
}else{
$('.hideter').hide();
}
}
if ($(this).is(':checked')) {
$('#add_more_row').removeClass('d-none');
$('.payby').removeClass('d-none');
$('#table_tr_2').show()
@ -4085,12 +4223,6 @@
$('#table_tr_7').show()
$('#table_tr_35').show()
var selectedOption = $('#policy_type_id').find('option:selected');
var bap = selectedOption.data('bap');
var allocg = selectedOption.data('allocg');
// console.log('allocg:', allocg);
// do not remove this commented items
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
// $('.hidecoter').show()
@ -4106,31 +4238,31 @@
// }
// }
if(allocg == "EB"){
$('.hideter').hide();
$('.hidetp').hide();
$('.hidecoter').hide()
$('.hidecotp').hide()
}else{
// if(allocg == "EB"){
// $('.hideter').hide();
// $('.hidetp').hide();
// $('.hidecoter').hide()
// $('.hidecotp').hide()
// }else{
$('.hidetp').show();
if($(this).is(':checked')){
$('.hidecotp').show();
}else{
$('.hidecotp').hide();
}
// $('.hidetp').show();
// if($(this).is(':checked')){
// $('.hidecotp').show();
// }else{
// $('.hidecotp').hide();
// }
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
$('.hideter').show();
if($(this).is(':checked')){
$('.hidecoter').show();
}else{
$('.hidecoter').hide();
}
}else{
$('.hideter').hide();
}
}
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
// $('.hideter').show();
// if($(this).is(':checked')){
// $('.hidecoter').show();
// }else{
// $('.hidecoter').hide();
// }
// }else{
// $('.hideter').hide();
// }
// }
// $('input[name="co_share_per[]"], input[name="co_premium[]"]').each(function () {
// $(this).val(''); // Clear value
@ -4889,11 +5021,28 @@
// }
if(allocg == "EB"){
$('.hideter').hide();
$('.hidetp').hide();
$('.hidecoter').hide()
$('.hidecotp').hide()
}else{
} else if(allocg == "Non-EB"){
$('.hidetp').hide();
$('.hidecotp').hide();
$('.hideter').show();
if(is_co_pay_yes == 1){
$('.hidecoter').show();
}else{
$('.hidecoter').hide();
}
} else if(policy_type_id == 8){
$('.hideter').hide();
$('.hidecoter').hide();
$('.hidetp').show();
if(is_co_pay_yes == 1){
@ -4902,6 +5051,8 @@
$('.hidecotp').hide();
}
} else{
if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
$('.hideter').show();
if(is_co_pay_yes == 1){
@ -4914,6 +5065,32 @@
}
}
// if(allocg == "EB"){
// $('.hideter').hide();
// $('.hidetp').hide();
// $('.hidecoter').hide()
// $('.hidecotp').hide()
// }else{
// $('.hidetp').show();
// if(is_co_pay_yes == 1){
// $('.hidecotp').show();
// }else{
// $('.hidecotp').hide();
// }
// if(bap == 'Fire' || bap == 'Marine Cargo' || bap == 'Marine Hull'){
// $('.hideter').show();
// if(is_co_pay_yes == 1){
// $('.hidecoter').show();
// }else{
// $('.hidecoter').hide();
// }
// }else{
// $('.hideter').hide();
// }
// }
var std_bp = 0;
var std_tp = 0;
var std_tep = 0;
@ -5557,16 +5734,18 @@
});
$(document).on('change', '#insurerTable input, #insurerTable select, #insurerTable textarea', function() {
// console.log('Changed in table:', $(this).attr('name'), 'Value:', $(this).val());
getColumnIndexes()
console.log('Changed in table:', $(this).attr('name'), 'Value:', $(this).val());
getColumnIndexes(0, $(this).attr('name'))
});
function getColumnIndexes(count = 0) {
function getColumnIndexes(count = 0, name = null) {
$('#insurerTable thead th').each(function(index) {
if (index === 0) {
console.log("Premium Table columnIndexes is", index);
} else {
amountCalculation(index);
amountCalculation(index, name);
if(count == 1){
amountCalculation(index);
}

View File

@ -574,12 +574,14 @@ $(document).ready(function() {
"<'row align-items-center'<'col-5 text-start'i><'col-7 d-flex justify-content-end align-items-center'<'me-2'l>p>>",
lengthMenu: [[10, 20, 50, 100], [10, 20, 50, 100]],
buttons: [
{
{
text: '<i class="mdi mdi-plus" ></i><span class=" btn-custom"> Add </span>',
className: 'btn app-btn-primary mr-2',
action: function (e, dt, node, config) {
hide_list_show_add();
addInsurerColumn() ;
addInsurerColumn();
addHTMLInput(null, 'policy_docs_div');
$('#policy_docs').show()
}
},
{
@ -720,6 +722,7 @@ function hide_list_show_add()
$('#inception_filter').hide()
$('#policyholdernamediv').hide();
$('.branchdiv').show();
}
function show_list_hide_add()
@ -1000,23 +1003,33 @@ function getPolicyDetailsByPolicyId(input)
}
}
function addHTMLInput(data = null)
{
const container = document.getElementById('dynamic-form-container');
function addHTMLInput(data = null, container_id = 'dynamic-form-container')
{
console.log('container_id', container_id);
const container = document.getElementById(container_id);
let required = ''
let required_star = ''
if(container_id == 'dynamic-form-container'){
required = 'required';
required_star = '*';
}
console.log('container', container);
const newRow = document.createElement('div');
newRow.className = 'form-row dynamic-form-row';
newRow.innerHTML = `
<div class="form-group col-md-5">
<label for="file_name">Document Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="docs_name" name="doc_name[]" placeholder="Enter file name" required>
<label for="file_name">Document Name<span class="text-danger">${required_star}</span></label>
<input type="text" class="form-control" id="docs_name" name="doc_name[]" placeholder="Enter file name" ${required}>
</div>
<div class="form-group col-md-5">
<label for="file">Upload File<span class="text-danger">*</span></label>
<input type="file" class="form-control" id="file_name" name="file[]" required>
<label for="file">Upload File<span class="text-danger">${required_star}</span></label>
<input type="file" class="form-control" id="file_name" name="file[]" ${required}>
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(this)">+</a>
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this, '${container_id}')">x</a>
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput(null, '${container_id}')">+</a>
</div>
`;
container.appendChild(newRow);
@ -1027,9 +1040,9 @@ function addHTMLInput(data = null)
}
}
function removeHTMLInput(element)
function removeHTMLInput(element, container_id)
{
const container = document.getElementById('dynamic-form-container');
const container = document.getElementById(container_id);
const rows = container.querySelectorAll('.dynamic-form-row');
if (rows.length > 1) {
@ -1179,23 +1192,30 @@ function validateForm()
return checkInputs(); // Call checkInputs before form submission
}
function addHTMLInputForVehicleFileUpload(data = null)
{
const container = document.getElementById('dynamic-form-container-for-vehicle-file-upload');
function addHTMLInputForVehicleFileUpload(data = null, container_id = 'dynamic-form-container-for-vehicle-file-upload')
{
let required = ''
let required_star = ''
if(container_id == 'dynamic-form-container-for-vehicle-file-upload'){
required = 'required';
required_star = '*';
}
const container = document.getElementById(container_id);
const newRow = document.createElement('div');
newRow.className = 'form-row dynamic-form-row';
newRow.innerHTML = `
<div class="form-group col-md-5">
<label for="file_name">Document Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="docs_name" name="other_docs_name[]" placeholder="Enter file name" required>
<label for="file_name">Document Name<span class="text-danger">${required_star}</span></label>
<input type="text" class="form-control" id="docs_name" name="other_docs_name[]" placeholder="Enter file name" ${required}>
</div>
<div class="form-group col-md-5">
<label for="file">Upload File<span class="text-danger">*</span></label>
<input type="file" class="form-control" id="file_name" name="file_name[]" required>
<label for="file">Upload File<span class="text-danger">${required_star}</span></label>
<input type="file" class="form-control" id="file_name" name="file_name[]" ${required}>
</div>
<div class="form-group col-md-2" style="position: relative;top: 28px;">
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInputForVehicleFileUpload(this)">x</a>
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInputForVehicleFileUpload(this)">+</a>
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInputForVehicleFileUpload(this, '${container_id}')">x</a>
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInputForVehicleFileUpload(null, '${container_id}')">+</a>
</div>
`;
container.appendChild(newRow);
@ -1244,9 +1264,9 @@ function appendVehicleFileTableBody(data)
});
}
function removeHTMLInputForVehicleFileUpload(element)
function removeHTMLInputForVehicleFileUpload(element, container_id)
{
const container = document.getElementById('dynamic-form-container-for-vehicle-file-upload');
const container = document.getElementById(container_id);
const rows = container.querySelectorAll('.dynamic-form-row');
if (rows.length > 1) {

View File

@ -21,7 +21,7 @@
<li class="nav-item" id="hide_file_upload" style="display: none;">
<a href="#fileupload" data-toggle="tab" aria-expanded="true" class="nav-link px-3 py-2" id="kyc_tab">
<span class="mr-1"><i class="mdi mdi-file"></i></span>
<span class="d-none d-sm-inline-block">File Upload</span>
<span class="d-none d-sm-inline-block">Policy Docs</span>
</a>
</li>
<li class="nav-item" id="hide_vehicle_tab" style="display: none;">

View File

@ -163,10 +163,11 @@
<tr>
<th>S.No&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Client&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Client Branch&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Insurer&nbsp;&nbsp;&nbsp;&nbsp;</th>
<!-- <th>Client Branch&nbsp;&nbsp;&nbsp;&nbsp;</th> -->
<!-- <th>Insurer&nbsp;&nbsp;&nbsp;&nbsp;</th> -->
<th>Insurer Branch&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Policy&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Policy Type&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Policy No&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Endorsement No&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Premium&nbsp;&nbsp;&nbsp;&nbsp;</th>
<th>Statement Premium&nbsp;&nbsp;&nbsp;&nbsp;</th>
@ -182,10 +183,11 @@
<tr>
<td class="text-center"><?= $index + 1 ?></td>
<td><?php echo $row['client_name']; ?></td>
<td><?php echo $row['client_branch_name']; ?></td>
<td><?php echo $row['insurer_name']; ?></td>
<!-- <td><?php //echo $row['client_branch_name']; ?></td>
<td><?php //echo $row['insurer_name']; ?></td> -->
<td><?php echo $row['insurer_branch_name']; ?></td>
<td><?php echo $row['policy_type'] .' - '. $row['policy_no']; ?></td>
<td><?php echo $row['policy_type']; ?></td>
<td><?php echo $row['policy_no']; ?></td>
<td><?php echo $row['endorsement_no']; ?></td>
<td class="right-align-input"><?php echo $row['original_premium']; ?></td>
<td class="right-align-input"><?php echo isset($row['statement_premium']) ? $row['statement_premium'] : '0.00'; ?></td>
@ -198,7 +200,6 @@
<?php } ?>
</tbody>
</table>
<div>
</div>
</div><!-- end col -->
@ -206,8 +207,8 @@
</div>
</div>
<script>
let client_list = [];
let branch_list = [];
let policy_list = [];
@ -216,9 +217,7 @@
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
@ -285,237 +284,234 @@
searchPlaceholder: "Search",
emptyTable: '<div class="text-center text-muted">No Data found</div>'
},
paging: true, // Enable pagination
pageLength: 25 // Set default number of rows per page (optional)
});
} else {
console.error("Table not found.");
paging: true, // Enable pagination
pageLength: 25 // Set default number of rows per page (optional)
});
} else {
console.error("Table not found.");
}
});
$(document).ready(function() {
getClientAndBranchAndPolicy()
getURLParams()
$('#client_id').select2();
$('#client_branch_id').select2();
$('#insurer_id').select2();
$('#insurer_branch_id').select2();
$('#client_policy_id').select2();
$('#policy_type_id').select2();
})
function fetchEmpolyeeList(event){
event.preventDefault(); // Prevent default action
var start_date = $('#startDate').val();
var end_date = $('#endDate').val();
var client_id = $('#client_id').val();
var insurer_id = $('#insurer_id').val();
var policy_type_id = $('#policy_type_id').val();
var date_type = $('#date_type').val();
var issuer = $('#issuer').val();
var client_branch_id = $('#client_branch_id').val();
var insurer_branch_id = $('#insurer_branch_id').val();
var client_policy_id = $('#client_policy_id').val();
console.log(start_date + '-' + end_date);
var queryParams = {
start_date: start_date,
end_date: end_date,
client_id: client_id,
insurer_id: insurer_id,
policy_type_id: policy_type_id,
date_type: date_type,
issuer: issuer,
client_branch_id: client_branch_id,
insurer_branch_id: insurer_branch_id,
client_policy_id: client_policy_id,
};
const queryString = objectToQueryString(queryParams);
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
console.log(apiURL);
window.location.href = apiURL;
}
});
$(document).ready(function() {
getClientAndBranchAndPolicy()
getURLParams()
$('#client_id').select2();
$('#client_branch_id').select2();
$('#insurer_id').select2();
$('#insurer_branch_id').select2();
$('#client_policy_id').select2();
$('#policy_type_id').select2();
})
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
function fetchEmpolyeeList(event)
{
event.preventDefault(); // Prevent default action
function getURLParams() {
const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
var start_date = $('#startDate').val();
var end_date = $('#endDate').val();
var client_id = $('#client_id').val();
var insurer_id = $('#insurer_id').val();
var policy_type_id = $('#policy_type_id').val();
var date_type = $('#date_type').val();
var issuer = $('#issuer').val();
var client_branch_id = $('#client_branch_id').val();
var insurer_branch_id = $('#insurer_branch_id').val();
var client_policy_id = $('#client_policy_id').val();
const startDate = params.get('start_date') || 0; // Default to 0 if not found
const endDate = params.get('end_date') || 0; // Default to 0 if not found
const client_id = params.get('client_id') || 0; // Default to 0 if not found
const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
const date_type = params.get('date_type') || 0; // Default to 0 if not found
const issuer = params.get('issuer') || 0; // Default to 0 if not found
const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found
const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found
const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found
console.log(start_date + '-' + end_date);
hideDateField(date_type)
var queryParams = {
start_date: start_date,
end_date: end_date,
client_id: client_id,
insurer_id: insurer_id,
policy_type_id: policy_type_id,
date_type: date_type,
issuer: issuer,
client_branch_id: client_branch_id,
insurer_branch_id: insurer_branch_id,
client_policy_id: client_policy_id,
};
console.log('startDate', startDate)
console.log('endDate', endDate)
console.log('client_id', client_id)
console.log('insurer_id', insurer_id)
console.log('policy_type_id', policy_type_id)
console.log('date_type', date_type)
console.log('issuer', issuer)
console.log('client_branch_id', client_branch_id)
console.log('insurer_branch_id', insurer_branch_id)
console.log('client_policy_id', client_policy_id)
const queryString = objectToQueryString(queryParams);
const apiURL = $('#get-emp-list').attr('href') + "?" + queryString;
console.log(apiURL);
window.location.href = apiURL;
}
// Log the values or use them as needed
console.log('Start Date:', startDate);
console.log('End Date:', endDate);
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
function getURLParams()
{
const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
const startDate = params.get('start_date') || 0; // Default to 0 if not found
const endDate = params.get('end_date') || 0; // Default to 0 if not found
const client_id = params.get('client_id') || 0; // Default to 0 if not found
const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
const date_type = params.get('date_type') || 0; // Default to 0 if not found
const issuer = params.get('issuer') || 0; // Default to 0 if not found
const client_branch_id = params.get('client_branch_id') || 0; // Default to 0 if not found
const insurer_branch_id = params.get('insurer_branch_id') || 0; // Default to 0 if not found
const client_policy_id = params.get('client_policy_id') || 0; // Default to 0 if not found
hideDateField(date_type)
console.log('startDate', startDate)
console.log('endDate', endDate)
console.log('client_id', client_id)
console.log('insurer_id', insurer_id)
console.log('policy_type_id', policy_type_id)
console.log('date_type', date_type)
console.log('issuer', issuer)
console.log('client_branch_id', client_branch_id)
console.log('insurer_branch_id', insurer_branch_id)
console.log('client_policy_id', client_policy_id)
// Log the values or use them as needed
console.log('Start Date:', startDate);
console.log('End Date:', endDate);
if (startDate != 0 && endDate != 0) {
setTimeout(function(){
$('#start_date').val(startDate)
$('#end_date').val(endDate)
$('#client_id').val(client_id).change()
$('#insurer_id').val(insurer_id).change()
$('#policy_type_id').val(policy_type_id).change()
$('#date_type').val(date_type)
$('#issuer').val(issuer)
if (startDate != 0 && endDate != 0) {
setTimeout(function(){
$('#client_branch_id').val(client_branch_id).change()
$('#insurer_branch_id').val(insurer_branch_id).change()
$('#start_date').val(startDate)
$('#end_date').val(endDate)
$('#client_id').val(client_id).change()
$('#insurer_id').val(insurer_id).change()
$('#policy_type_id').val(policy_type_id).change()
$('#date_type').val(date_type)
$('#issuer').val(issuer)
setTimeout(function(){
$('#client_policy_id').val(client_policy_id).change();
}, 1000);
}, 2000)
},2000)
$('#client_branch_id').val(client_branch_id).change()
$('#insurer_branch_id').val(insurer_branch_id).change()
setTimeout(function(){
$('#client_policy_id').val(client_policy_id).change();
}, 1000);
}, 2000)
},2000)
}
}
$(function() {
const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
// Get start and end dates from URL parameters, or use default values
const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY');
const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY');
// Parse the dates to moment objects
var start = moment(startDateParam, 'DD-MM-YYYY');
var end = moment(endDateParam, 'DD-MM-YYYY');
// var start = moment().subtract(29, 'days');
// var end = moment();
function cb(start, end) {
$('#reportrange').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
$('#startDate').val(start.format('DD-MM-YYYY'));
$('#endDate').val(end.format('DD-MM-YYYY'));
}
$('#reportrange').daterangepicker({
startDate: start,
endDate: end,
locale: { format: 'DD-MM-YYYY' },
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
.endOf('month')
]
}
}, cb);
cb(start, end);
$('#clear-filters').on('click', function() {
// Reset all select dropdowns to the first option
$('#client_id').val('0').change();
$('#insurer_id').val('0').change();
$('#policy_type_id').val('0').change();
$('#date_type').val('0');
$('#issuer').val('0');
$('#date_div').hide()
// Reset the date range picker to default
$('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days'));
$('#reportrange').data('daterangepicker').setEndDate(moment());
cb(start, end); // Update the displayed date range
});
});
function hideDateField(input = null) {
let val = $('#date_type').val();
if (input) {
val = input;
}
if (val != 0) {
$('#date_div').show()
} else {
$('#date_div').hide()
}
}
$(function() {
function sendPolicyTransactionID(event, pt_id) {
event.preventDefault(); // Prevent default action
const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
console.log(pt_id);
// Get start and end dates from URL parameters, or use default values
const startDateParam = params.get('start_date') || moment().subtract(29, 'days').format('DD-MM-YYYY');
const endDateParam = params.get('end_date') || moment().format('DD-MM-YYYY');
var queryParams = {
pt_id: pt_id,
};
// Parse the dates to moment objects
var start = moment(startDateParam, 'DD-MM-YYYY');
var end = moment(endDateParam, 'DD-MM-YYYY');
const queryString = objectToQueryString(queryParams);
const apiURL = $('#get-policy-list').attr('href') + "?" + queryString;
console.log(apiURL);
window.location.href = apiURL;
}
// var start = moment().subtract(29, 'days');
// var end = moment();
// -------------------------------------------------------------------------------------------------
function cb(start, end) {
$('#reportrange').html(start.format('D-MM-YYYY') + ' - ' + end.format('D-MM-YYYY'));
$('#startDate').val(start.format('DD-MM-YYYY'));
$('#endDate').val(end.format('DD-MM-YYYY'));
}
//featch client, client branch, insurer, insurer branch and client policy list data
function getClientAndBranchAndPolicy()
{
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if(res.status == true){
client_list = res.client_data;
branch_list = res.branch_data;
policy_list = res.policy_data;
insurer_list = res.insurer_data;
insurer_branch_list = res.insurer_branch_data;
appendClients(res.client_data);
appendInsurer(res.insurer_data);
}else{
console.log('No data found');
$('#reportrange').daterangepicker({
startDate: start,
endDate: end,
locale: { format: 'DD-MM-YYYY' },
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month')
.endOf('month')
]
}
}, cb);
cb(start, end);
$('#clear-filters').on('click', function() {
// Reset all select dropdowns to the first option
$('#client_id').val('0').change();
$('#insurer_id').val('0').change();
$('#policy_type_id').val('0').change();
$('#date_type').val('0');
$('#issuer').val('0');
$('#date_div').hide()
// Reset the date range picker to default
$('#reportrange').data('daterangepicker').setStartDate(moment().subtract(29, 'days'));
$('#reportrange').data('daterangepicker').setEndDate(moment());
cb(start, end); // Update the displayed date range
});
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
function hideDateField(input = null) {
let val = $('#date_type').val();
if (input) {
val = input;
}
if (val != 0) {
$('#date_div').show()
} else {
$('#date_div').hide()
}
}
function sendPolicyTransactionID(event, pt_id) {
event.preventDefault(); // Prevent default action
console.log(pt_id);
var queryParams = {
pt_id: pt_id,
};
const queryString = objectToQueryString(queryParams);
const apiURL = $('#get-policy-list').attr('href') + "?" + queryString;
console.log(apiURL);
window.location.href = apiURL;
}
// -------------------------------------------------------------------------------------------------
//featch client, client branch, insurer, insurer branch and client policy list data
function getClientAndBranchAndPolicy(){
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if(res.status == true){
client_list = res.client_data;
branch_list = res.branch_data;
policy_list = res.policy_data;
insurer_list = res.insurer_data;
insurer_branch_list = res.insurer_branch_data;
appendClients(res.client_data);
appendInsurer(res.insurer_data);
}else{
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
$(document).ready(function() {
getClientAndBranchAndPolicy()

View File

@ -102,12 +102,14 @@ $("#vehicle_file_upload_form").submit(function(event) {
console.log(res);
if(res.status == true){
toastr.success(res.message, 'Success');
toastr.success(res.message, 'SUCCESS');
appendVehicleFileTableBody(res.vehicle_docs);
}else{
toastr.error(res.message, 'Error');
toastr.warning(res.message, 'WARNING');
}
$('#vehicle_file_upload_form')[0].reset();
},
error: function (xhr, status, error) {
console.error(xhr.responseText);