MERGE_UAT_BDS_LIVE_ISSUES_FINAL
This commit is contained in:
commit
40b74ec1f2
@ -21,6 +21,7 @@ $routes->get("view", "EmployeeController::viewECard/$1");
|
||||
// $routes->get("exportQCRandRFQ", "LeadsController::exportQCRandRFQ");
|
||||
$routes->get("smapletest", "ClientController::smapletest");
|
||||
$routes->get("testMailAttachments", "ClientController::testMailAttachments");
|
||||
$routes->get("updatePolicyTermsKey", "ClientController::updatePolicyTermsKey");
|
||||
|
||||
$routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image");
|
||||
$routes->get("add_image_index", "AppContentManagementController::add_image_index");
|
||||
@ -314,6 +315,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('log_list', 'EmployeeController::listLogs');
|
||||
$routes->get('view_log/(:any)', 'EmployeeController::viewLog/$1');
|
||||
$routes->get('download_log/(:any)', 'EmployeeController::downloadLog/$1');
|
||||
$routes->post('checkDuplicateTableFieldValue', 'ClientController::checkDuplicateTableFieldValue');
|
||||
});
|
||||
|
||||
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
@ -323,6 +325,7 @@ $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post("create", "PolicyTransactionController::createInceptionPolicy");
|
||||
$routes->get("list/(:any)", "PolicyTransactionController::getInceptionDataForEdit/$1");
|
||||
$routes->get("remove/(:any)", "PolicyTransactionController::removeCDMaster/$1");
|
||||
$routes->get("removePolicyTransaction/(:any)", "PolicyTransactionController::removePolicyTransaction/$1");
|
||||
});
|
||||
|
||||
$routes->group("endorsement", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
@ -118,6 +118,23 @@ class ClientController extends AdminController
|
||||
$this->leadsModel = new LeadsModel();
|
||||
}
|
||||
|
||||
public function checkDuplicateTableFieldValue()
|
||||
{
|
||||
$table = $this->request->getPost('table');
|
||||
$field = $this->request->getPost('field');
|
||||
$value = $this->request->getPost('value');
|
||||
|
||||
// Load the database if not already loaded
|
||||
$db = db_connect();
|
||||
|
||||
// Perform the query
|
||||
$builder = $db->table($table);
|
||||
$isDuplicate = $builder->where($field, $value)->countAllResults() > 0;
|
||||
|
||||
// Return the result
|
||||
return $this->response->setJSON(['isDuplicate' => $isDuplicate]);
|
||||
}
|
||||
|
||||
public function smapletest()
|
||||
{
|
||||
$headers = [
|
||||
@ -3562,4 +3579,101 @@ class ClientController extends AdminController
|
||||
dd($result);
|
||||
}
|
||||
|
||||
public function updatePolicyTermsKey()
|
||||
{
|
||||
|
||||
$data = $this->clientPolicyModel
|
||||
->where("policy_terms IS NOT NULL AND policy_terms <> ''")
|
||||
->where('policy_type_id', 2)
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
for ($i = 0; $i < count($data); $i++) {
|
||||
|
||||
if (isset($data[$i]['policy_terms']) && !empty($data[$i]['policy_terms'])) {
|
||||
$policyTerms = json_decode($data[$i]['policy_terms'], true);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Set default value of copayzonewisecopay to "empty"
|
||||
$ans = isset($policyTerms['copayzonewisecopay']) ? $policyTerms['copayzonewisecopay'] : 'empty';
|
||||
|
||||
|
||||
// Initialize an empty array for the ordered policy terms
|
||||
$orderedPolicyTerms = [];
|
||||
|
||||
// Add copayzonewisecopay and copayzonewisecopaydata if they exist_
|
||||
if (isset($policyTerms['copayzonewisecopay'])) {
|
||||
|
||||
$orderedPolicyTerms['copayzonewisecopay'] = $policyTerms['copayzonewisecopay'];
|
||||
$orderedPolicyTerms['co_pay_details'] = isset($policyTerms['co_pay_details']) ? $policyTerms['co_pay_details'] : '';
|
||||
}
|
||||
|
||||
|
||||
// Add ailmentcapping and ailmentcappingdata if they exist_
|
||||
if (isset($policyTerms['ailmentcapping'])) {
|
||||
$orderedPolicyTerms['ailmentcapping'] = $policyTerms['ailmentcapping'];
|
||||
$orderedPolicyTerms['ailment_capping_details'] = isset($policyTerms['ailment_capping_details']) ? $policyTerms['ailment_capping_details'] : '';
|
||||
}
|
||||
|
||||
|
||||
// Now add the rest of the policy terms that are not copayzonewisecopay, copayzonewisecopaydata, ailmentcapping, or ailmentcapping_data_
|
||||
foreach ($policyTerms as $key => $value) {
|
||||
if (!in_array($key, ['copayzonewisecopay', 'co_pay_details', 'ailmentcapping', 'ailment_capping_details'])) {
|
||||
$orderedPolicyTerms[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Re-encode the ordered policy terms
|
||||
$updatedPolicyTerms = json_encode($orderedPolicyTerms);
|
||||
|
||||
|
||||
// Update the policyterms in the database_
|
||||
$this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]);
|
||||
|
||||
|
||||
// Handle different conditions for copayzonewisecopay
|
||||
if (strtolower($ans) == "nil" || $ans == 0) {
|
||||
// If copayzonewisecopay is "nil" or 0, reset it to 0 and add copayzonewisecopaydata as empty_
|
||||
if (isset($orderedPolicyTerms['copayzonewisecopay'])) {
|
||||
$orderedPolicyTerms['copayzonewisecopay'] = 0;
|
||||
$orderedPolicyTerms['co_pay_details'] = "";
|
||||
}
|
||||
|
||||
|
||||
// Rebuild the array after modification
|
||||
foreach ($policyTerms as $key => $value) {
|
||||
if (!in_array($key, ['copayzonewisecopay', 'co_pay_details'])) {
|
||||
$orderedPolicyTerms[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$updatedPolicyTerms = json_encode($orderedPolicyTerms);
|
||||
$this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]);
|
||||
continue;
|
||||
} elseif ($ans != 'empty' && $ans !== 'Nil' && $ans !== null && $ans != '' && $ans != 0) {
|
||||
// If copayzonewisecopay has a valid value, update it
|
||||
if (isset($orderedPolicyTerms['copayzonewisecopay'])) {
|
||||
$orderedPolicyTerms['copayzonewisecopay'] = 1;
|
||||
$orderedPolicyTerms['co_pay_details'] = $ans;
|
||||
}
|
||||
|
||||
|
||||
// Rebuild the array after modification
|
||||
foreach ($policyTerms as $key => $value) {
|
||||
if (!in_array($key, ['copayzonewisecopay', 'co_pay_details'])) {
|
||||
$orderedPolicyTerms[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$updatedPolicyTerms = json_encode($orderedPolicyTerms);
|
||||
$this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -690,6 +690,7 @@ class PolicyTransactionController extends BaseController
|
||||
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id', 'left')
|
||||
->where('policy_transaction.id', $id)
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->first();
|
||||
|
||||
// $data['policy_issue_date'] = (isset($data['policy_issue_date']) && $data['policy_issue_date'] !== null && $data['policy_issue_date'] !== '')
|
||||
@ -810,6 +811,21 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function removePolicyTransaction($id)
|
||||
{
|
||||
if ($id) {
|
||||
|
||||
$data['is_active'] = 0;
|
||||
$this->policyTransactionModel->where('id', $id)->set($data)->update();
|
||||
$this->PTCOShareDetailsModel->where('pt_id', $id)->set($data)->update();
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Policy Transaction removed successfully'], 200);
|
||||
|
||||
} else {
|
||||
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to remove policy transaction'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
// Policy Transaction Endorsement
|
||||
@ -962,6 +978,7 @@ class PolicyTransactionController extends BaseController
|
||||
->where('action_type', 'inception')
|
||||
->where('client_id', $this->request->getPost('client_id'))
|
||||
->where('client_policy_id', $this->request->getPost('client_policy_id'))
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->first();
|
||||
|
||||
$data['tsi'] = generate_tsi_code($issue_type['issue_type'] ?? 1);
|
||||
@ -1089,6 +1106,7 @@ class PolicyTransactionController extends BaseController
|
||||
->join('clients', 'clients.id = policy_transaction.client_id')
|
||||
->join('client_policy', 'policy_transaction.client_policy_id = client_policy.id', 'left')
|
||||
->where('policy_transaction.id', $id)
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->first();
|
||||
|
||||
// $data['policy_start_date'] = empty($data['policy_start_date']) ? '' : date('d/m/Y', strtotime($data['s_date']));
|
||||
@ -1278,6 +1296,8 @@ class PolicyTransactionController extends BaseController
|
||||
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id')
|
||||
->join('insurer_statements', 'pt_co_share_details.statement_id = insurer_statements.id')
|
||||
->where('policy_transaction.id', $pt_id)
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('pt_co_share_details.is_active', 1)
|
||||
->where('pt_co_share_details.statement_id IS NOT NULL')
|
||||
->where('insurer_statements.invoice_no IS NOT NULL')
|
||||
->countAllResults();
|
||||
|
||||
@ -386,7 +386,11 @@ class PolicyTransactionModel extends Model
|
||||
|
||||
$builder->orderBy('policy_transaction.id', 'desc');
|
||||
|
||||
return $builder->get()->getResultArray();
|
||||
$result = $builder->get()->getResultArray();
|
||||
|
||||
// dd($this->db->getLastQuery());
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getEndorsementTranctionListData($start_date = 0, $end_date = 0, $client_id = 0, $insurer_id = 0, $policy_type_id = 0, $date_type = 0, $issuer = 0, $status = 0)
|
||||
|
||||
@ -862,6 +862,69 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
function checkDuplicateTableFieldValue(tableName, fieldName, value, callback) {
|
||||
$.ajax({
|
||||
url: '<?= base_url('util/checkDuplicateTableFieldValue') ?>', // Adjust this to your endpoint in CodeIgniter
|
||||
type: 'POST',
|
||||
data: {
|
||||
table: tableName,
|
||||
field: fieldName,
|
||||
value: value
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (typeof callback === 'function') {
|
||||
callback(response.isDuplicate); // Pass the result to the callback
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('AJAX Error:', error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function sendAjaxRequestForGlobal(url, method, data = {}, successCallback = null, errorCallback = null) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: method,
|
||||
data: data,
|
||||
dataType: 'json', // Expected response type
|
||||
success: function(response) {
|
||||
// If a success callback is provided, call it with the response
|
||||
if (successCallback) {
|
||||
successCallback(response);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle errors if provided error callback
|
||||
if (errorCallback) {
|
||||
errorCallback(xhr, status, error);
|
||||
} else {
|
||||
console.error('AJAX Error:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function confirmActionSweertAlert(message = "Are you sure?", confirmText = "Yes, Proceed!", cancelText = "Cancel", icon = "warning") {
|
||||
return Swal.fire({
|
||||
title: message,
|
||||
icon: icon,
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: confirmText,
|
||||
cancelButtonText: cancelText
|
||||
}).then((result) => {
|
||||
return result.isConfirmed; // Returns true if confirmed, false otherwise
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@ -317,7 +317,7 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3" id="renewal" style="display: none;">
|
||||
<label for="addon_policy"> Renewal Source Policy <span id="base_danger"class="text-danger">*</span></label>
|
||||
<label for="addon_policy"> Renewal Source Policy <span id="base_danger"class="text-danger"></span></label>
|
||||
<select class="form-control" id="source_client_policy_id"name="source_client_policy_id" onchange="setRenewalPolicyData(this)">
|
||||
<option value="" selected>Select Renewal Source Policy</option>
|
||||
</select>
|
||||
@ -748,7 +748,7 @@
|
||||
<!-- end form row -->
|
||||
|
||||
<!-- Client form content modal-->
|
||||
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false" data-backdrop="static" data-keyboard="false">
|
||||
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -759,7 +759,6 @@
|
||||
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="client_name">Client Name<span class="text-danger">*</span></label>
|
||||
@ -772,7 +771,7 @@
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="cost_center">PAN<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan">
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInput(this, 'clients', 'pan')" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -789,7 +788,7 @@
|
||||
<div class="form-group col-md-6">
|
||||
<label for="cost_center">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
|
||||
onkeypress="return onlyNumbers(event)">
|
||||
onkeypress="return onlyNumbers(event)" onchange="validateInput(this, 'clients', 'phone')">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
@ -799,7 +798,7 @@
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="aadhar">Aadhar<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar">
|
||||
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInput(this, 'clients', 'aadhar')">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -809,7 +808,7 @@
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Entity Type<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="entity_type_id" name="entity_type_id">
|
||||
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
||||
<option value="" selected>Select Entity</option>
|
||||
<?php
|
||||
if (isset($entity) && count($entity)) {
|
||||
@ -843,7 +842,8 @@
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="gst">GST<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
|
||||
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" onchange="validateInput(this, 'client_branch', 'gst')"
|
||||
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -859,21 +859,21 @@
|
||||
</div>
|
||||
|
||||
<!-- Vehicle form content modal-->
|
||||
<div class="modal fade" id="vehicle_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
|
||||
<div class="modal fade" id="vehicle_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Add New Vehicle</h4>
|
||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<button type="button" id="vehicle_close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
||||
<form class="parsley-examples" method="post" id="vehicle_form" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-6 client_type_div">
|
||||
<label for="client_type">Owner Type<span class="text-danger">*</span></label>
|
||||
<label for="Owner_type">Owner Type<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="Owner_type" name="Owner_type" required>
|
||||
<option value="">Select Owner type</option>
|
||||
<option value="1">Group</option>
|
||||
@ -883,12 +883,12 @@
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="cost_center">Vehicle No<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="modal_vehicle_no" placeholder="Enter Vehicle No" name="vehicle_no" required>
|
||||
<input type="text" class="form-control" id="modal_vehicle_no" placeholder="Enter Vehicle No" name="vehicle_no" onchange="validateInput(this, 'vehicle', 'vehicle_no')" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="rc">RC Book <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="rc" placeholder="Enter RC Book No" name="rc" required>
|
||||
<input type="text" class="form-control" id="rc" placeholder="Enter RC Book No" name="rc" onchange="validateInput(this, 'vehicle', 'rc')" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
@ -946,7 +946,7 @@
|
||||
</div>
|
||||
|
||||
<!-- CD No form content modal-->
|
||||
<div class="modal fade" id="cd_form_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
|
||||
<div class="modal fade" id="cd_form_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -994,7 +994,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
var team_id = [];
|
||||
@ -1020,7 +1019,7 @@ $(document).ready(function(){
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
team_id = <?php echo json_encode(user_team()); ?>;
|
||||
@ -1089,6 +1088,7 @@ $(document).ready(function(){
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#vehicle_no').change(function(){
|
||||
|
||||
var val = $(this).val()
|
||||
var selectedOption = $(this).find('option:selected');
|
||||
var client_id = selectedOption.data('cid')
|
||||
@ -1116,9 +1116,12 @@ $(document).ready(function(){
|
||||
}
|
||||
|
||||
if(val == 'add_vehicle'){
|
||||
|
||||
$('#modal_vehicle_no').val('');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
myModal.show();
|
||||
|
||||
$(this).val('').select2();
|
||||
}
|
||||
})
|
||||
|
||||
@ -1127,6 +1130,65 @@ $(document).ready(function(){
|
||||
let owner_id = $(this).val();
|
||||
console.log('owner_id', owner_id);
|
||||
|
||||
if(owner_id == 'add_client'){
|
||||
|
||||
if($('#client_type').val()){
|
||||
|
||||
$('#vehicle_close_btn').click();
|
||||
|
||||
if ($('#client_type').val() == 2) {
|
||||
|
||||
$('.branchdiv').hide();
|
||||
$('.clienttypediv').show();
|
||||
$('#entity_type_id_for_client').prop('required', false);
|
||||
$('#branch_name').prop('required', false);
|
||||
$('#client_branch_id').prop('required', false);
|
||||
$('#branch_code').prop('required', false);
|
||||
$('#name').prop('required', false);
|
||||
$('#mobile').prop('required', false);
|
||||
$('#gst').prop('required', false);
|
||||
|
||||
$('#dob').prop('required', true);
|
||||
$('#phone').prop('required', true);
|
||||
$('#email').prop('required', true);
|
||||
$('#aadhar').prop('required', true);
|
||||
|
||||
} else {
|
||||
|
||||
$('.branchdiv').show();
|
||||
$('.clienttypediv').hide();
|
||||
$('#entity_type_id_for_client').prop('required', true);
|
||||
$('#branch_name').prop('required', true);
|
||||
$('#client_branch_id').prop('required', true);
|
||||
$('#branch_code').prop('required', true);
|
||||
$('#name').prop('required', true);
|
||||
$('#mobile').prop('required', true);
|
||||
$('#gst').prop('required', true);
|
||||
|
||||
$('#dob').prop('required', false);
|
||||
$('#phone').prop('required', false);
|
||||
$('#email').prop('required', false);
|
||||
$('#aadhar').prop('required', false);
|
||||
|
||||
}
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||||
myModal.show();
|
||||
|
||||
}else{
|
||||
|
||||
toastr.warning('Please select the Owner type', 'WARNING');
|
||||
}
|
||||
|
||||
|
||||
$('#client_form').attr('data-id', 1);
|
||||
|
||||
// Save form data from the #vehicle_form to localStorage
|
||||
saveFormDataToLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(branch_list != '') {
|
||||
// console.log(branch_list[client_id]);
|
||||
let data = branch_list[owner_id];
|
||||
@ -1552,10 +1614,10 @@ function getPolicyTransactionDataForEdit(input) {
|
||||
// Additional form handling logic
|
||||
if (res.data.issue_type == 2) {
|
||||
$('#renewal').show();
|
||||
$('#source_client_policy_id').attr('required', true);
|
||||
// $('#source_client_policy_id').attr('required', true);
|
||||
} else {
|
||||
$('#renewal').hide();
|
||||
$('#source_client_policy_id').attr('required', false);
|
||||
// $('#source_client_policy_id').attr('required', false);
|
||||
}
|
||||
|
||||
// Handle base policy visibility
|
||||
@ -1680,6 +1742,7 @@ function checkAndDistributeTax(input)
|
||||
let cgst = parseFloat($('#cgst_' + input).val());
|
||||
let sgst = parseFloat($('#sgst_' + input).val());
|
||||
let igst = parseFloat($('#igst_' + input).val());
|
||||
|
||||
if(((event.target.id).startsWith('cgst') || (event.target.id).startsWith('sgst') ))
|
||||
{
|
||||
if(cgst !== 0) { $('#sgst_' + input).val(cgst.toFixed(2)); }
|
||||
@ -1687,7 +1750,7 @@ function checkAndDistributeTax(input)
|
||||
|
||||
$('#igst_' + input).val(0.00);
|
||||
}
|
||||
else
|
||||
else if((event.target.id).startsWith('igst'))
|
||||
{
|
||||
$('#cgst_' + input).val(0.00);
|
||||
$('#sgst_' + input).val(0.00);
|
||||
@ -2177,12 +2240,21 @@ function removeRemoveInsured(element) {
|
||||
}
|
||||
|
||||
function appendOwner(data) {
|
||||
|
||||
$('#owner').empty();
|
||||
|
||||
$('#owner').append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select Owner'
|
||||
}));
|
||||
}));
|
||||
|
||||
$('#owner').append(
|
||||
$('<option>', {
|
||||
value: 'add_client',
|
||||
text: ' + Add Owner',
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
@ -2707,6 +2779,12 @@ $("#inception_form_id").submit(function(event) {
|
||||
|
||||
$("#client_form").submit(function(event) {
|
||||
|
||||
let form_type = $(this).data('id') || 0;
|
||||
|
||||
console.log('onsubmit event', this)
|
||||
console.log('onsubmit event get data value',form_type)
|
||||
console.log('client_type', $('#client_type').val());
|
||||
|
||||
event.preventDefault();
|
||||
isClientFormSubmitting = true;
|
||||
var isValid = $('#client_form').parsley().validate();
|
||||
@ -2719,10 +2797,13 @@ $("#client_form").submit(function(event) {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
var client_type = $('#client_type').val();
|
||||
|
||||
var client_type = $('#client_type').val() || $('#Owner_type').val();
|
||||
console.log('client_type:', client_type);
|
||||
|
||||
//FORM Data
|
||||
var formData = new FormData($('#client_form')[0]);
|
||||
formData.append('client_type', client_type)
|
||||
formData.append('client_type', client_type);
|
||||
|
||||
$.ajax({
|
||||
data:formData,
|
||||
@ -2740,21 +2821,48 @@ $("#client_form").submit(function(event) {
|
||||
|
||||
if(res.status == true){
|
||||
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
setTimeout(function(){
|
||||
$('#client_id').val(res.client_id).change();
|
||||
|
||||
if(form_type != 1){
|
||||
|
||||
setTimeout(function(){
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
}, 1000)
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 2000)
|
||||
$('#client_id').val(res.client_id).change();
|
||||
setTimeout(function(){
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
}, 1000)
|
||||
}, 2000)
|
||||
|
||||
}else{
|
||||
|
||||
setTimeout(function(){
|
||||
$('#owner').val(res.client_id).change();
|
||||
$('#owner_branch').val(res.branch_id).change();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
toastr.success(res.message, 'Success');
|
||||
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
}
|
||||
|
||||
$('#client_form')[0].reset();
|
||||
$('.close').click();
|
||||
|
||||
if(form_type == 1){
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
myModal.show();
|
||||
|
||||
$('#client_form').removeAttr('data-id');
|
||||
|
||||
// Load form data into #vehicle_form from localStorage
|
||||
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
}
|
||||
|
||||
isClientFormSubmitting = false;
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
@ -2898,6 +3006,7 @@ $("#CDMasterForm").submit(function(event) {
|
||||
//-----------------------------------------------------------------------------------------------------------
|
||||
|
||||
$('#cop_yes').change(function() {
|
||||
|
||||
if ($(this).is(':checked')) {
|
||||
$('#add_more_row').removeClass('d-none');
|
||||
$('.payby').removeClass('d-none');
|
||||
@ -2927,9 +3036,10 @@ $('#client_type').change(function() {
|
||||
}
|
||||
|
||||
if ($(this).val() == 2) {
|
||||
|
||||
$('.branchdiv').hide();
|
||||
$('.clienttypediv').show();
|
||||
$('#entity_type_id').prop('required', false);
|
||||
$('#entity_type_id_for_client').prop('required', false);
|
||||
$('#branch_name').prop('required', false);
|
||||
$('#client_branch_id').prop('required', false);
|
||||
$('#branch_code').prop('required', false);
|
||||
@ -2949,7 +3059,7 @@ $('#client_type').change(function() {
|
||||
} else {
|
||||
$('.branchdiv').show();
|
||||
$('.clienttypediv').hide();
|
||||
$('#entity_type_id').prop('required', true);
|
||||
$('#entity_type_id_for_client').prop('required', true);
|
||||
$('#branch_name').prop('required', true);
|
||||
$('#client_branch_id').prop('required', true);
|
||||
$('#branch_code').prop('required', true);
|
||||
@ -3025,6 +3135,8 @@ $('#Owner_type').on('change', function() {
|
||||
|
||||
var selectedClientType = $(this).val();
|
||||
|
||||
$('#client_type').val(selectedClientType).change();
|
||||
|
||||
if ($(this).val() == 2) {
|
||||
$('.ownerbranchdiv').hide();
|
||||
$('#owner_branch').prop('required', false);
|
||||
@ -3040,17 +3152,40 @@ $('#Owner_type').on('change', function() {
|
||||
value: '',
|
||||
text: 'Select Owner'
|
||||
}))
|
||||
|
||||
$('#owner').append(
|
||||
$('<option>', {
|
||||
value: 'add_client',
|
||||
text: ' + Add Owner',
|
||||
})
|
||||
);
|
||||
|
||||
// Populate client options based on selected client type
|
||||
if (selectedClientType) {
|
||||
// Populate vehicle options based on selected client type
|
||||
$.each(client_list, function(index, owner) {
|
||||
|
||||
if (owner.client_type == selectedClientType) {
|
||||
var option = $('<option>', {
|
||||
value: owner.id,
|
||||
text: owner.client_name,
|
||||
});
|
||||
$('#owner').append(option);
|
||||
|
||||
if(selectedClientType == '2'){
|
||||
|
||||
var option = $('<option>', {
|
||||
value: owner.id,
|
||||
text: (owner.client_name + ' - ' + (owner.pan ?? ''))
|
||||
});
|
||||
|
||||
$('#owner').append(option);
|
||||
|
||||
}else{
|
||||
|
||||
var option = $('<option>', {
|
||||
value: owner.id,
|
||||
text: owner.client_name,
|
||||
});
|
||||
$('#owner').append(option);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -3945,4 +4080,69 @@ function getURLParamsForReport() {
|
||||
console.log('pt_id', pt_id); // Retain the log if necessary
|
||||
}
|
||||
|
||||
function validateInput(input, table, field){
|
||||
|
||||
let value = $(input).val();
|
||||
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||
|
||||
let message = "Value is duplicate!";
|
||||
if(label){
|
||||
message = label + " already exists!";
|
||||
}
|
||||
|
||||
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||
if (isDuplicate) {
|
||||
toastr.warning(message, 'WARNING');
|
||||
$(input).val('')
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function saveFormDataToLocalStorage(formSelector, storageKey) {
|
||||
// Initialize an empty object to store form data
|
||||
let formData = {};
|
||||
|
||||
// Iterate over all inputs in the form
|
||||
$(formSelector + " :input").each(function() {
|
||||
let input = $(this);
|
||||
let name = input.attr("name"); // Get the input's name attribute
|
||||
let value = input.val(); // Get the input's value
|
||||
|
||||
if (name) {
|
||||
if (name !== 'owner' && name !== 'branch_id') {
|
||||
formData[name] = value; // Add to the formData object if the input has a name
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// Save the form data to local storage with the provided key
|
||||
localStorage.setItem(storageKey, JSON.stringify(formData));
|
||||
|
||||
console.log("Form data saved to local storage:", formData);
|
||||
}
|
||||
|
||||
function setFormDataFromLocalStorage(formSelector, storageKey) {
|
||||
// Retrieve the saved form data from localStorage
|
||||
let savedData = JSON.parse(localStorage.getItem(storageKey));
|
||||
|
||||
// If there's no saved data, do nothing
|
||||
if (!savedData) return;
|
||||
|
||||
// Iterate through the saved data and set the form inputs accordingly
|
||||
$.each(savedData, function(name, value) {
|
||||
let input = $(formSelector + " :input[name='" + name + "']");
|
||||
|
||||
// Check if the input is a checkbox or radio button
|
||||
if (input.is(':checkbox') || input.is(':radio')) {
|
||||
input.prop('checked', value); // Set the checked property
|
||||
} else {
|
||||
input.val(value); // Set the value for other input types
|
||||
}
|
||||
});
|
||||
|
||||
console.log("Form data loaded from local storage:", savedData);
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -289,6 +289,9 @@ table.dataTable tbody td {
|
||||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
||||
</a>
|
||||
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@ -1071,6 +1074,7 @@ $(document).ready(function(){
|
||||
$('#policy_holder_name').val(client_name);
|
||||
|
||||
if(client_id == 'add_client') {
|
||||
|
||||
if($('#client_type').val()){
|
||||
$('#client_id').val('').change();
|
||||
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||||
@ -1118,11 +1122,11 @@ $('#issue_type').change(function(){
|
||||
$('#revenue_type').val('EA')
|
||||
$('#renewal').show()
|
||||
// $('.sded_dates').show()
|
||||
$('#source_client_policy_id').attr('required', true)
|
||||
// $('#source_client_policy_id').attr('required', true)
|
||||
}else{
|
||||
$('#renewal').hide()
|
||||
// $('.sded_dates').hide()
|
||||
$('#source_client_policy_id').attr('required', false)
|
||||
// $('#source_client_policy_id').attr('required', false)
|
||||
$('#policy_start_date').val('');
|
||||
$('#policy_end_date').val('');
|
||||
}
|
||||
@ -1243,7 +1247,7 @@ $('#cd_ac_no_data').change(function(){
|
||||
|
||||
// $('#policy_type_id').change(function() {
|
||||
|
||||
// var policy_type_id = $(this).val();
|
||||
// var policy_type_id = $(this).val();
|
||||
|
||||
// var client_id = $('#client_id').val();
|
||||
// var client_branch_id = $('#client_branch_id').val();
|
||||
@ -1501,4 +1505,32 @@ function hideDateField(input = null)
|
||||
}
|
||||
}
|
||||
|
||||
function removePolicyTransaction(input, pt_id) {
|
||||
|
||||
confirmActionSweertAlert("Do you want to delete this transaction?", "Yes, Proceed!", "No, Cancel").then((confirmed) => {
|
||||
if (confirmed) {
|
||||
let url = '<?= base_url('policy_tranction/inception/removePolicyTransaction/') ?>' + pt_id;
|
||||
|
||||
// Include `pt_id` in the AJAX request if necessary
|
||||
let requestData = { pt_id: pt_id };
|
||||
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status === true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
window.location.reload();
|
||||
} else {
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user