Merge branch 'dev' of bitbucket.org:jubilian/nhance-enrollment into dev Srinivas
This commit is contained in:
commit
180812a544
@ -335,6 +335,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post('get_data_for_mapping', 'EmployeeController::getDataForMapping');
|
||||
$routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1');
|
||||
$routes->get('transformMailContent', 'LeadsController::transformMailContent');
|
||||
$routes->get('getRackRateSIAmountAndAutoSiDataForAutoSI', 'ClientController::getRackRateSIAmountAndAutoSiDataForAutoSI');
|
||||
$routes->post('createAutoSI', 'ClientController::createAutoSI');
|
||||
});
|
||||
|
||||
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
|
||||
|
||||
@ -39,6 +39,7 @@ use App\Models\PolicyTransactionModel;
|
||||
use App\Models\PolicyTransactionStatusModel;
|
||||
use App\Models\VehicleModel;
|
||||
use App\Models\LeadsModel;
|
||||
use App\Models\AutoSIModel;
|
||||
|
||||
use App\Controllers\EmpDataServiceController;
|
||||
use App\Controllers\GoogleDriveController;
|
||||
@ -80,6 +81,7 @@ class ClientController extends AdminController
|
||||
protected $policyTransactionStatusModel;
|
||||
protected $vehicleModel;
|
||||
protected $leadsModel;
|
||||
protected $AutoSIModel;
|
||||
|
||||
|
||||
|
||||
@ -116,6 +118,7 @@ class ClientController extends AdminController
|
||||
$this->policyTransactionStatusModel = new PolicyTransactionStatusModel();
|
||||
$this->vehicleModel = new VehicleModel();
|
||||
$this->leadsModel = new LeadsModel();
|
||||
$this->AutoSIModel = new AutoSIModel();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
@ -3876,28 +3879,29 @@ class ClientController extends AdminController
|
||||
// $EmpDataServiceController = new EmpDataServiceController();
|
||||
// $EmpDataServiceController->importInceptionFileValidation(['file_id' => 160]);
|
||||
|
||||
$EmpDataServiceController = new EmpDataServiceController();
|
||||
// $EmpDataServiceController = new EmpDataServiceController();
|
||||
// $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 162]);
|
||||
// $EmpDataServiceController->importInceptionFileValidation(['file_id' => 162]);
|
||||
// $EmpDataServiceController->importDeletionValidation(['file_id' => 171]);
|
||||
// $EmpDataServiceController->importDeletionUpdateEndorsementID(['file_id' => 171]);
|
||||
$array = [
|
||||
"employeeIds" => ["12800", "12798", "12797", "12799"],
|
||||
"client_id" => "159",
|
||||
"client_policy_id" => "336",
|
||||
"client_branch_id" => "126",
|
||||
"cd_ac_no" => "Apple_123",
|
||||
"endorsement_no" => "ENDORSEMENT_ID",
|
||||
"count" => 4,
|
||||
"event_name" => "deletion",
|
||||
"policy_name" => "GMC",
|
||||
"user_id" => "1"
|
||||
];
|
||||
|
||||
$EmpDataServiceController->cashDepositCalculationForDeletion($array);
|
||||
// $array = [
|
||||
// "employeeIds" => ["12800", "12798", "12797", "12799"],
|
||||
// "client_id" => "159",
|
||||
// "client_policy_id" => "336",
|
||||
// "client_branch_id" => "126",
|
||||
// "cd_ac_no" => "Apple_123",
|
||||
// "endorsement_no" => "ENDORSEMENT_ID",
|
||||
// "count" => 4,
|
||||
// "event_name" => "deletion",
|
||||
// "policy_name" => "GMC",
|
||||
// "user_id" => "1"
|
||||
// ];
|
||||
|
||||
// $employeeRestController = new EmployeeServiceController();
|
||||
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 757]);
|
||||
// $EmpDataServiceController->cashDepositCalculationForDeletion($array);
|
||||
|
||||
$employeeRestController = new EmployeeServiceController();
|
||||
$employeeRestController->employeesOnboardPreprocess(['file_id' => 756]);
|
||||
|
||||
}
|
||||
|
||||
@ -3943,4 +3947,95 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------AUTO SI ----------------------------------------------------------------------------------------------
|
||||
|
||||
// Function to insert and update the auto si data and update the client policy table for auto si enableor disable
|
||||
public function createAutoSI()
|
||||
{
|
||||
try {
|
||||
|
||||
$postData = $this->request->getPost();
|
||||
if (empty($postData)) {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 400,
|
||||
'message' => 'No data provided.',
|
||||
], 400);
|
||||
}
|
||||
|
||||
$id = $postData['id'] ?? null;
|
||||
$auto_si_enable = isset($postData['is_auto_si']) ? 1 : 0;
|
||||
$affectedRows = 0;
|
||||
$message = '';
|
||||
|
||||
$this->clientPolicyModel->where('id', $postData['client_policy_id'])->set('is_auto_si', $auto_si_enable)->update();
|
||||
|
||||
if ($id) {
|
||||
$affectedRows = $this->AutoSIModel->where('id', $id)->set($postData)->update();
|
||||
$message = "Auto SI data updated successfully.";
|
||||
} else {
|
||||
$affectedRows = $this->AutoSIModel->insert($postData);
|
||||
$message = "Auto SI data submitted successfully.";
|
||||
}
|
||||
|
||||
if ($affectedRows) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'message' => $message,
|
||||
'data' => $affectedRows,
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 500,
|
||||
'message' => 'Failed to save data.',
|
||||
], 500);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 500,
|
||||
'message' => 'An error occurred.',
|
||||
'error' => $e->getMessage(),
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
//Function to get the data from Policy Premium 2 table data for the SI Dropdown, and Auto SI table data for edit auto_si
|
||||
public function getRackRateSIAmountAndAutoSiDataForAutoSI()
|
||||
{
|
||||
$client_policy_id = $this->request->getGet('client_policy_id');
|
||||
|
||||
if(!empty($client_policy_id)){
|
||||
|
||||
$rack_rate_count = $this->policyPremium2Model
|
||||
->where('client_policy_id', $client_policy_id)
|
||||
->where('is_active', 1)
|
||||
->groupBy('rack_rate_name')
|
||||
->countAllResults();
|
||||
|
||||
$si_amounts = $this->policyPremium2Model
|
||||
->where('client_policy_id', $client_policy_id)
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$auto_si = $this->AutoSIModel
|
||||
->select('auto_si.*, client_policy.is_auto_si')
|
||||
->join('client_policy', 'auto_si.client_policy_id = client_policy.id')
|
||||
->where('client_policy_id', $client_policy_id)
|
||||
->where('auto_si.is_active', 1)
|
||||
->first();
|
||||
|
||||
if($rack_rate_count <= 1){
|
||||
return $this->respond(['status' => true, 'code' => 200, 'si_amount' => $si_amounts, "auto_si_amount" => $auto_si], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 200, 'message' => 'The policy has more than one rack rates. Auto SI create only one rack rate.', 'si_amount' => $si_amounts, "auto_si_amount" => $auto_si], 200);
|
||||
}
|
||||
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 404, 'message' => 'No data to found. Client Policy Not found'], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
use App\Models\EmployeeModel;
|
||||
use App\Models\InsurerModel;
|
||||
use App\Models\ClientPolicyModel;
|
||||
use App\Models\AutoSIModel;
|
||||
use Kint\Kint;
|
||||
|
||||
|
||||
@ -900,7 +902,7 @@ if (!function_exists('calculate_premium_new'))
|
||||
// dd($slab);
|
||||
$res = compare_incoming_family_slab_with_configured_slab($slab,$incoming_familiy_composition);
|
||||
// kint::dump($key);
|
||||
// kint::dump($res);
|
||||
kint::dump($res);
|
||||
|
||||
if($res['is_applicable'])
|
||||
{
|
||||
@ -940,7 +942,7 @@ if (!function_exists('calculate_premium_new'))
|
||||
$temp_slab_rates[$key]['is_applicable'] = false;
|
||||
}
|
||||
}
|
||||
// dd();
|
||||
dd($family_data);
|
||||
|
||||
//4. if macthed then the current rack rate is applicable and find common variables link max age,max count,grade, basic pay,SI, self/acting self for current rack rate
|
||||
|
||||
@ -983,7 +985,7 @@ if (!function_exists('calculate_premium_new'))
|
||||
|
||||
// // Final combined condition
|
||||
if ($conditions['isEmployeeSourceEnrollment'] || $conditions['isEmployeeSourceExcelFile'] || $primaryGridTypeCondition ) {
|
||||
// dd($transformed_familiy_member_data);
|
||||
dd($transformed_familiy_member_data);
|
||||
$transformed_familiy_member_data = premium_calculation_manager($transformed_familiy_member_data,$policy_terms,$temp_slab_rates,$default_si);
|
||||
// dd($transformed_familiy_member_data);
|
||||
$result[] = $transformed_familiy_member_data;
|
||||
@ -2174,3 +2176,40 @@ if(!function_exists('generate_family_floater_key'))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(!function_exists('update_si_with_auto_si'))
|
||||
{
|
||||
function update_si_with_auto_si($client_id, $client_policy_id, $client_branch_id, $emp_code)
|
||||
{
|
||||
|
||||
$clientPolicy = new ClientPolicyModel();
|
||||
$policy_data = $clientPolicy->getPolicyDetails($client_id, $client_policy_id);
|
||||
|
||||
if(empty($policy_data) || $policy_data['is_auto_si']){
|
||||
return null;
|
||||
}else{
|
||||
|
||||
$autoSiModel = new AutoSIModel();
|
||||
$auto_si_amounts = $autoSiModel
|
||||
->where('client_policy_id', $client_policy_id)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
$params = [
|
||||
'auto_si' => $auto_si_amounts,
|
||||
];
|
||||
|
||||
$modified_si = modify_si_for_the_family($params);
|
||||
return $modified_si;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!function_exists('modify_si_for_the_family'))
|
||||
{
|
||||
function modify_si_for_the_family($params)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
53
app/Models/AutoSIModel.php
Normal file
53
app/Models/AutoSIModel.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class AutoSIModel extends Model
|
||||
{
|
||||
protected $table = 'auto_si';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'client_policy_id',
|
||||
'family_composition',
|
||||
'created_by',
|
||||
'created_at',
|
||||
'updated_by',
|
||||
'updated_at',
|
||||
'is_active'
|
||||
];
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
|
||||
protected function checkAndADDCreatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['created_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['created_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function checkAndUpdateUpdatedByValue(array $data)
|
||||
{
|
||||
// Check if 'updated_by' value is null or empty
|
||||
if (empty($data['data']['updated_by'])) {
|
||||
// Set 'updated_by' value to the current session user ID
|
||||
$data['data']['updated_by'] = get_session_userid();
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@ -52,7 +52,8 @@ class ClientPolicyModel extends Model
|
||||
"disclaimer",
|
||||
"is_active",
|
||||
"is_member_modify_allowed",
|
||||
"cd_ac_pk"
|
||||
"cd_ac_pk",
|
||||
"is_auto_si",
|
||||
];
|
||||
|
||||
// Callbacks
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
<div class="tab-pane fade" id="police-tab">
|
||||
|
||||
|
||||
<div class="row float-right" style="padding-bottom: 10px; position: relative;right: 13px;">
|
||||
<button type="button" id="BtnAdd" class="btn btn-primary waves-effect waves-light btnAdd btn-sm" style="position: relative;right: 10px;"><span class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy</button>
|
||||
<!-- <button type="button" id="BtnAddSuccess" class="btn btn-success waves-effect waves-light BtnAddSuccess btn-sm" onclick="showModal()"><span class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy From Lead</button> -->
|
||||
@ -31,7 +30,9 @@
|
||||
<div class="card-body">
|
||||
|
||||
<div class="row float-right" style="position: relative; bottom: 20px; right: 13px;">
|
||||
<button type="button" id="btnPolicyBack" class="btn btn-primary waves-effect waves-light btn-sm btnBack btn-sm"><span class="fa fa-list" aria-hidden="true" style="padding: 5px 10px;"></span>Back To List</button>
|
||||
<button type="button" id="btnPolicyBack"
|
||||
class="btn btn-primary waves-effect waves-light btn-sm btnBack btn-sm"><span class="fa fa-list"
|
||||
aria-hidden="true" style="padding: 5px 10px;"></span>Back To List</button>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
@ -43,7 +44,8 @@
|
||||
<input type="hidden" id="policy_form_action" />
|
||||
<input type="hidden" name="policy_type_id" id="policy_type_id" />
|
||||
<input type="hidden" id="insurer_policy_id" />
|
||||
<input type="hidden" name="client_id" id="client_id_policy" value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
|
||||
<input type="hidden" name="client_id" id="client_id_policy"
|
||||
value="<?= isset($client['id']) ? $client['id'] : '' ?>" />
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
@ -52,7 +54,7 @@
|
||||
<div class="form-group col-md-4">
|
||||
<label for="client_branch">Client Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="client_branch" name="client_branch_id">
|
||||
<option selected >Select Client Branch</option>
|
||||
<option selected>Select Client Branch</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@ -68,7 +70,8 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4" id="base_policy_id" style="display: none;">
|
||||
<label for="base_policy">Base Policy<span id="base_danger" class="text-danger">*</span></label>
|
||||
<label for="base_policy">Base Policy<span id="base_danger"
|
||||
class="text-danger">*</span></label>
|
||||
<select class="form-control" id="base_policy" name="base_policy">
|
||||
<option value="" selected>Select Base Policy</option>
|
||||
</select>
|
||||
@ -104,22 +107,30 @@
|
||||
</select>
|
||||
</div> -->
|
||||
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="policy_no">Policy No<span class="text-danger">*</span></label>
|
||||
<input value="" type="text" class="form-control" placeholder="Enter Policy Number "
|
||||
name="policy_no" id="policy_no" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row" id="second" style="display: none;">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="policy_start_date">Policy Start Date<span class="text-danger">*</span></label>
|
||||
<input value="" type="text" class="form-control" placeholder="Enter Start Date " name="policy_start_date" id="start_date" required>
|
||||
<label for="policy_start_date">Policy Start Date<span
|
||||
class="text-danger">*</span></label>
|
||||
<input value="" type="text" class="form-control" placeholder="Enter Start Date "
|
||||
name="policy_start_date" id="start_date" required>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="policy_end_date">Policy End Date<span class="text-danger">*</span></label>
|
||||
<input value="" type="text" class="form-control" placeholder="Enter End Date " name="policy_end_date" id="end_date" required>
|
||||
<input value="" type="text" class="form-control" placeholder="Enter End Date "
|
||||
name="policy_end_date" id="end_date" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4" id="policy_status_field">
|
||||
<label for="policy_status">Policy Status</label>
|
||||
<input value="" type="text" class="form-control" placeholder="Policy Status" id="policy_status" readonly>
|
||||
<input value="" type="text" class="form-control" placeholder="Policy Status"
|
||||
id="policy_status" readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -134,7 +145,8 @@
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="gst_no">GST ( % )<span id="tpa_danger" class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" placeholder="GST (%)" id="gst_no" name="gst" required>
|
||||
<input type="text" class="form-control" placeholder="GST (%)" id="gst_no" name="gst"
|
||||
required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
@ -149,22 +161,27 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="open_date">Open Date<span class="text-danger">*</span></label>
|
||||
<input value="" type="text" class="form-control dateofdata" placeholder="Enter Open Date " name="open_date" id="open_date" >
|
||||
<input value="" type="text" class="form-control dateofdata"
|
||||
placeholder="Enter Open Date " name="open_date" id="open_date">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="close_date">Close Date<span class="text-danger">*</span></label>
|
||||
<input value="" type="text" class="form-control dateofdata" placeholder="Enter Close Date " name="close_date" id="close_date" >
|
||||
<input value="" type="text" class="form-control dateofdata"
|
||||
placeholder="Enter Close Date " name="close_date" id="close_date">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="reminder_date">Reminder Date<span class="text-danger">*</span></label>
|
||||
<input value="" type="text" class="form-control dateofdata" placeholder="Enter Remainder Dates( eg, 28,29,30 )" name="reminder_date" id="reminder_date" >
|
||||
<input value="" type="text" class="form-control dateofdata"
|
||||
placeholder="Enter Remainder Dates( eg, 28,29,30 )" name="reminder_date"
|
||||
id="reminder_date">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="disclaimer">Disclaimer<span class="text-danger">*</span></label>
|
||||
<textarea class="form-control" placeholder="Enter Disclaimer" name="disclaimer" id="disclaimer" ></textarea>
|
||||
<textarea class="form-control" placeholder="Enter Disclaimer" name="disclaimer"
|
||||
id="disclaimer"></textarea>
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group col-md-4">
|
||||
@ -191,8 +208,10 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect btnBack" id="btnBack">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||||
id="btnSubmit">Submit</button>
|
||||
<button type="button" class="btn btn-secondary waves-effect btnBack"
|
||||
id="btnBack">Cancel</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
@ -207,9 +226,11 @@
|
||||
<?php include('policy_gmc_terms.php'); ?>
|
||||
<?php include('policy_gpa_terms.php'); ?>
|
||||
<?php include('other_policy_terms.php'); ?>
|
||||
<?php include('rack_rate_auto_si.php'); ?>
|
||||
|
||||
<!-- Center modal content -->
|
||||
<div class="modal fade" id="lead_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
|
||||
<div class="modal fade" id="lead_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
aria-hidden="false">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
@ -224,7 +245,9 @@
|
||||
<option value="">Select Lead</option>
|
||||
<?php if(isset($lead_data)) { ?>
|
||||
<?php foreach ($lead_data as $value) { ?>
|
||||
<option value="<?= $value['id']?>" data-clientid="<?= $value['client_id']?>", data-branchid="<?= $value['client_branch_id']?>"><?= $value['client_name'] ?> - <?= $value['branch_name'] ?> - <?= $value['user_name'] ?></option>
|
||||
<option value="<?= $value['id']?>" data-clientid="<?= $value['client_id']?>" ,
|
||||
data-branchid="<?= $value['client_branch_id']?>"><?= $value['client_name'] ?> -
|
||||
<?= $value['branch_name'] ?> - <?= $value['user_name'] ?></option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
@ -238,39 +261,39 @@
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
|
||||
$('#inception_type').change(function () {
|
||||
<script>
|
||||
$('#inception_type').change(function() {
|
||||
var open_data = $('#open_date').parent();
|
||||
var close_data = $('#close_date').parent();
|
||||
var reminder_data = $('#reminder_date').parent();
|
||||
if($(this).prop('checked')){
|
||||
if ($(this).prop('checked')) {
|
||||
$(open_data).show();
|
||||
$(close_data).show();
|
||||
$(reminder_data).show();
|
||||
$('.dateofdata').attr('required', true);
|
||||
}else{
|
||||
} else {
|
||||
$(open_data).hide();
|
||||
$(close_data).hide();
|
||||
$(reminder_data).hide();
|
||||
$('.dateofdata').attr('required', false);
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
var policy_PrimaryKey = $('#client_id_policy').val();
|
||||
var policy_client = $('#policy_PrimaryKey').val();
|
||||
var policy_PrimaryKey = $('#client_id_policy').val();
|
||||
var policy_client = $('#policy_PrimaryKey').val();
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
// Initialize select2
|
||||
$("#insurer").select2();
|
||||
$("#policy").select2();
|
||||
$("#tpa").select2();
|
||||
$("#base_policy").select2();
|
||||
$("#client_branch").select2();
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#policy_status_field').hide()
|
||||
|
||||
@ -328,7 +351,7 @@
|
||||
if (policy_PrimaryKey !== '') {
|
||||
var policyTable = '';
|
||||
var data = <?= isset($client_policy) ? json_encode($client_policy) : '[]' ?>;
|
||||
console.log('client_policy_data',data)
|
||||
console.log('client_policy_data', data)
|
||||
var role = data.role
|
||||
delete data.role;
|
||||
|
||||
@ -380,9 +403,14 @@
|
||||
|
||||
var policy_name_data = `${item.policy_type_name ?? ''}` + ' - ' + `${item.policy_no ?? ''}`;
|
||||
|
||||
let auto_si_menu = '';
|
||||
if(item.policy_type_id == 2){
|
||||
auto_si_menu = `<a href="#" data-id="${item.id}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="showModal('rack_rate_auto_si_modal'); getRackRateSIAmountAndAutoSiDataForAutoSI('${item.id}')"><i class="mdi mdi-autorenew mr-2 text-muted font-18 vertical-middle"></i>Auto SI</a>`;
|
||||
}
|
||||
|
||||
|
||||
policyTable += `
|
||||
policyTable +=
|
||||
`
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${policy_name_data}</td>
|
||||
@ -397,11 +425,12 @@
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
|
||||
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>
|
||||
${auto_si_menu}`;
|
||||
// Conditionally render the delete option based on the role
|
||||
if (role !== 3 && role !== 4) {
|
||||
policyTable += `
|
||||
policyTable +=
|
||||
`
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="removepolicy(this)"><i class="fa fa-trash mr-2 text-muted font-18 vertical-middle"></i>Delete</a>`;
|
||||
}
|
||||
|
||||
@ -427,9 +456,9 @@
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$('.btnAdd').click(function() {
|
||||
$('.btnAdd').click(function() {
|
||||
|
||||
fetchClientBranch()
|
||||
|
||||
@ -462,9 +491,9 @@
|
||||
$('#base_policy').prop('required', false);
|
||||
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
$('.btnBack').click(function() {
|
||||
$('.btnBack').click(function() {
|
||||
|
||||
$('#policy_form')[0].reset();
|
||||
$('#add_form').hide();
|
||||
@ -483,10 +512,10 @@
|
||||
$('#base_policy_id').hide();
|
||||
$('#client_branch').val('').change();
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
/******** for form submit using AJAX *******/
|
||||
$("#policy_form").submit(function(event) {
|
||||
/******** for form submit using AJAX *******/
|
||||
$("#policy_form").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
@ -534,7 +563,7 @@
|
||||
|
||||
var formData = new FormData($('#policy_form')[0]);
|
||||
var policy_form_action = $('#policy_form_action').val();
|
||||
console.log(formData+'form data');
|
||||
console.log(formData + 'form data');
|
||||
$.ajax({
|
||||
data: formData,
|
||||
url: policy_form_action,
|
||||
@ -623,9 +652,16 @@
|
||||
tpaValue = item.tpa_short + '-' + item.tpa_branch_code;
|
||||
}
|
||||
|
||||
var policy_name_data = `${item.policy_type_name ?? ''}` + ' - ' + `${item.policy_no ?? ''}`;
|
||||
var policy_name_data = `${item.policy_type_name ?? ''}` + ' - ' +
|
||||
`${item.policy_no ?? ''}`;
|
||||
|
||||
policyTable += `
|
||||
let auto_si_menu = '';
|
||||
if(item.policy_type_id == 2){
|
||||
auto_si_menu = `<a href="#" data-id="${item.id}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="showModal('rack_rate_auto_si_modal'); getRackRateSIAmountAndAutoSiDataForAutoSI('${item.id}')"><i class="mdi mdi-autorenew mr-2 text-muted font-18 vertical-middle"></i>Auto SI</a>`;
|
||||
}
|
||||
|
||||
policyTable +=
|
||||
`
|
||||
<tr>
|
||||
<td>${item.insurer_short} - ${item.insurer_branch_name}</td>
|
||||
<td>${policy_name_data}</td>
|
||||
@ -641,11 +677,13 @@
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a href="#" data-id="${item.id}" id="${item.policy_id}" class="dropdown-item btnPolicyEdit"><i class="mdi mdi-lead-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyMaster" data-toggle="modal"><i class="mdi mdi-wrench mr-2 text-muted font-18 vertical-middle"></i>Terms</a>
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>`;
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item btnPolicyModel" data-toggle="modal" data-target="#bs-example-modal-lg"><i class="mdi mdi-book-open mr-2 text-muted font-18 vertical-middle"></i>Rack Rate</a>
|
||||
${auto_si_menu}`;
|
||||
|
||||
// Conditionally render the delete option based on the role
|
||||
if (role !== 3 && role !== 4) {
|
||||
policyTable += `
|
||||
policyTable +=
|
||||
`
|
||||
<a href="#" data-id="${item.id}" id="${search_term}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="removepolicy(this)"><i class="fa fa-trash mr-2 text-muted font-18 vertical-middle"></i>Delete</a>`;
|
||||
}
|
||||
|
||||
@ -684,9 +722,9 @@
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
/********* To get the POLICY base on Insurer *******/
|
||||
$('#insurer').change(function() {
|
||||
|
||||
@ -701,12 +739,12 @@
|
||||
var base_policy_data_id = selectedOption.data('id');
|
||||
|
||||
|
||||
$.get(url_for_cd, function(response){
|
||||
$.get(url_for_cd, function(response) {
|
||||
|
||||
// console.log(response)
|
||||
// console.log(response.data)
|
||||
|
||||
if(response.status == false && response.insurer_id != 'undefined'){
|
||||
if (response.status == false && response.insurer_id != 'undefined') {
|
||||
toastr.warning('The CD Account Number not found.', 'Warning');
|
||||
return;
|
||||
}
|
||||
@ -721,9 +759,9 @@
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function() {
|
||||
/********* set the Policy_Type_id for Form Submit *******/
|
||||
$('#policy_type').change(function() {
|
||||
|
||||
@ -737,10 +775,10 @@
|
||||
$('#tpa_danger').show()
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// get the client policy data for edit
|
||||
$('body').on('click', '.btnPolicyEdit', function() {
|
||||
// get the client policy data for edit
|
||||
$('body').on('click', '.btnPolicyEdit', function() {
|
||||
|
||||
var policy_form_action = '';
|
||||
var policy_id = $(this).attr('data-id');
|
||||
@ -872,7 +910,8 @@
|
||||
$('#base_policy').prop('required', false);
|
||||
|
||||
|
||||
} else if (res.data.policy_type_id == '1' || res.data.policy_type_id == '2' || res.data.policy_type_id == '6' || res.data.policy_type_id == '7') {
|
||||
} else if (res.data.policy_type_id == '1' || res.data.policy_type_id == '2' || res.data
|
||||
.policy_type_id == '6' || res.data.policy_type_id == '7') {
|
||||
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
@ -880,7 +919,7 @@
|
||||
$('#base_policy_id').hide();
|
||||
$('#base_policy').prop('required', false);
|
||||
|
||||
}else if(res.data.policy_type_id == '3'){
|
||||
} else if (res.data.policy_type_id == '3') {
|
||||
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
@ -925,7 +964,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (res.data.policy_type_id == '1' || res.data.policy_type_id == '6' || res.data.policy_type_id == '7') {
|
||||
if (res.data.policy_type_id == '1' || res.data.policy_type_id == '6' || res.data
|
||||
.policy_type_id == '7') {
|
||||
$('#tpa').prop('required', false);
|
||||
$('#tpa_danger').hide()
|
||||
} else {
|
||||
@ -937,9 +977,11 @@
|
||||
$('#client_branch').val(res.data.client_branch_id).select2();
|
||||
}, 1000);
|
||||
|
||||
setTimeout(function(){
|
||||
appendCDACNO(res.cd_data, res.data.cd_ac_no) // append and select the current CD Account Number
|
||||
appendBasePolicyList(res.client_policy_list, res.data.base_policy, res.data.client_branch_id); // append and select the Base palicy
|
||||
setTimeout(function() {
|
||||
appendCDACNO(res.cd_data, res.data
|
||||
.cd_ac_no) // append and select the current CD Account Number
|
||||
appendBasePolicyList(res.client_policy_list, res.data.base_policy, res.data
|
||||
.client_branch_id); // append and select the Base palicy
|
||||
}, 2000)
|
||||
|
||||
|
||||
@ -954,9 +996,9 @@
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('click', '.btnOpenEnroll', function() {
|
||||
$('body').on('click', '.btnOpenEnroll', function() {
|
||||
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
@ -1056,10 +1098,10 @@
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
//for date convert to indian formate like this 'yyyy-mm-dd' to this 'dd-mm-yyyy'
|
||||
function rearrangeDateFormat(inputDate) {
|
||||
//for date convert to indian formate like this 'yyyy-mm-dd' to this 'dd-mm-yyyy'
|
||||
function rearrangeDateFormat(inputDate) {
|
||||
|
||||
console.log('inputDate', inputDate)
|
||||
// Check if inputDate is a string and not empty
|
||||
@ -1078,10 +1120,10 @@
|
||||
// Handle the case where inputDate is not a valid string
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkDateStatus(inputDate, bg = false) {
|
||||
function checkDateStatus(inputDate, bg = false) {
|
||||
|
||||
var givenDate = new Date(inputDate);
|
||||
var currentDate = new Date();
|
||||
@ -1100,9 +1142,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const numberWords = {
|
||||
const numberWords = {
|
||||
0: "Zero",
|
||||
1: "One",
|
||||
2: "Two",
|
||||
@ -1131,9 +1173,9 @@
|
||||
70: "Seventy",
|
||||
80: "Eighty",
|
||||
90: "Ninety"
|
||||
};
|
||||
};
|
||||
|
||||
function convertNumberToWords(number) {
|
||||
function convertNumberToWords(number) {
|
||||
if (number === 0) {
|
||||
return numberWords[number];
|
||||
}
|
||||
@ -1183,10 +1225,9 @@
|
||||
}
|
||||
}
|
||||
return word.trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function convertCommaNumberToWords(input) {
|
||||
function convertCommaNumberToWords(input) {
|
||||
|
||||
let number;
|
||||
|
||||
@ -1223,18 +1264,16 @@
|
||||
}
|
||||
|
||||
return result.trim();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function onlyNumbers(event) {
|
||||
function onlyNumbers(event) {
|
||||
var charcode;
|
||||
charcode = event.which || event.keyCode;
|
||||
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function formatNumber(input, maxLength) {
|
||||
function formatNumber(input, maxLength) {
|
||||
|
||||
//console.log("input", input);
|
||||
//console.log("input value", input.value);
|
||||
@ -1250,14 +1289,14 @@
|
||||
|
||||
|
||||
// Format the number with commas using Indian numbering system
|
||||
value = parseFloat(value).toLocaleString("en-IN",{
|
||||
value = parseFloat(value).toLocaleString("en-IN", {
|
||||
maximumFractionDigits: 2
|
||||
});
|
||||
|
||||
// console.log('formatNumber function formetted value', value);
|
||||
// console.log('formatNumber function formetted value type',typeof value);
|
||||
|
||||
if(value == 'NaN' || value == 'null' || value == 'undefined'){
|
||||
if (value == 'NaN' || value == 'null' || value == 'undefined') {
|
||||
value = '';
|
||||
}
|
||||
|
||||
@ -1323,10 +1362,9 @@
|
||||
return;
|
||||
// }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$('#policy_type').change(function() {
|
||||
$('#policy_type').change(function() {
|
||||
|
||||
$('#insurer').val('').change();
|
||||
$('#tpa').val('').change();
|
||||
@ -1339,9 +1377,10 @@
|
||||
var client_id = $('#client_id_policy').val();
|
||||
var client_branch_id = $('#client_branch').val();
|
||||
|
||||
var url_for_get_policy_type_list = '<?php echo base_url('util/get_policy_type_for_base_policy/') ?>' + client_id + '/' + client_branch_id;
|
||||
var url_for_get_policy_type_list = '<?php echo base_url('util/get_policy_type_for_base_policy/') ?>' +
|
||||
client_id + '/' + client_branch_id;
|
||||
|
||||
$.get(url_for_get_policy_type_list, function(response){
|
||||
$.get(url_for_get_policy_type_list, function(response) {
|
||||
|
||||
console.log(response)
|
||||
// console.log(response.data)
|
||||
@ -1425,7 +1464,7 @@
|
||||
$('#base_policy').prop('required', false);
|
||||
$('#base_danger').show();
|
||||
|
||||
}else if($(this).val() == '3'){
|
||||
} else if ($(this).val() == '3') {
|
||||
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
@ -1435,18 +1474,17 @@
|
||||
$('#base_danger').hide();
|
||||
}
|
||||
|
||||
if($('#inception_type').prop('checked')){
|
||||
if ($('#inception_type').prop('checked')) {
|
||||
|
||||
}else{
|
||||
} else {
|
||||
$('#open_date').parent().hide();
|
||||
$('#close_date').parent().hide();
|
||||
$('#reminder_date').parent().hide();
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
// featch client policy to list in the Base policy Dropdown list
|
||||
function fetchClientPolicyList() {
|
||||
// featch client policy to list in the Base policy Dropdown list
|
||||
function fetchClientPolicyList() {
|
||||
|
||||
var client_id = $('#client_id_policy').val()
|
||||
var client_branch_id = $('#client_branch').val()
|
||||
@ -1488,7 +1526,8 @@
|
||||
}
|
||||
|
||||
} else {
|
||||
OptionsHTML += '<option data-id="' + item.policy_type_id + '" value="' + item
|
||||
OptionsHTML += '<option data-id="' + item.policy_type_id + '" value="' +
|
||||
item
|
||||
.id +
|
||||
'">' + item.name + '( ' + item.policy_type + ' )</option>';
|
||||
}
|
||||
@ -1508,10 +1547,10 @@
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var dataId = 0;
|
||||
$(document).ready(function() {
|
||||
var dataId = 0;
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#base_policy').change(function() {
|
||||
|
||||
@ -1545,9 +1584,10 @@
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 500);
|
||||
|
||||
if(res.status == true){
|
||||
if (res.status == true) {
|
||||
|
||||
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id).change();
|
||||
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data
|
||||
.insurer_id).change();
|
||||
$('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change();
|
||||
$('#policy_no').val(res.data.policy_no).change();
|
||||
// $('#open_date').val(rearrangeDateFormat(res.data.open_date)).change();
|
||||
@ -1566,10 +1606,10 @@
|
||||
});
|
||||
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
// fetch the client branch list for the dropdown
|
||||
function fetchClientBranch() {
|
||||
// fetch the client branch list for the dropdown
|
||||
function fetchClientBranch() {
|
||||
|
||||
//console.log('function called');
|
||||
|
||||
@ -1612,10 +1652,10 @@
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//append the client branch list for the dropdown
|
||||
function appendClientBranch(data) {
|
||||
//append the client branch list for the dropdown
|
||||
function appendClientBranch(data) {
|
||||
|
||||
$('#client_branch').empty();
|
||||
|
||||
@ -1634,10 +1674,10 @@
|
||||
$('#client_branch').append(option);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//append the CD Account number for the dropdown
|
||||
function appendCDACNO(data, select = null) {
|
||||
//append the CD Account number for the dropdown
|
||||
function appendCDACNO(data, select = null) {
|
||||
|
||||
//console.log('appendCDACNO', data);
|
||||
//console.log('appendCDACNO', select);
|
||||
@ -1661,11 +1701,10 @@
|
||||
|
||||
$('#cd_ac_no').append(option);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// append Base Policy to the dropdown for edit only
|
||||
function appendBasePolicyList(data, select = null)
|
||||
{
|
||||
// append Base Policy to the dropdown for edit only
|
||||
function appendBasePolicyList(data, select = null) {
|
||||
|
||||
// console.log('appendBasePolicyList', 'function called');
|
||||
// console.log('appendBasePolicyList data', data);
|
||||
@ -1681,7 +1720,7 @@
|
||||
|
||||
const option = $('<option>', {
|
||||
value: item.client_policy_id,
|
||||
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}`,
|
||||
text: `${item.policy_type ?? ''} - ${item.policy_no ?? ''}`,
|
||||
'data-id': item.id
|
||||
});
|
||||
|
||||
@ -1690,10 +1729,9 @@
|
||||
}
|
||||
$('#base_policy').append(option);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function removepolicy(element)
|
||||
{
|
||||
function removepolicy(element) {
|
||||
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
@ -1726,7 +1764,7 @@
|
||||
|
||||
console.log('removepolicy function response', res)
|
||||
|
||||
if(res){
|
||||
if (res) {
|
||||
if (res.status == true) {
|
||||
toastr.success('Policy removed successfully.', 'success');
|
||||
location.reload();
|
||||
@ -1740,7 +1778,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
@ -1752,37 +1790,37 @@
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$('#policy_no').change(function(){
|
||||
$('#policy_no').change(function() {
|
||||
|
||||
var policy_no = $(this).val();
|
||||
console.log(policy_no +'-'+policy_no.length);
|
||||
console.log(policy_no + '-' + policy_no.length);
|
||||
policy_no = policy_no.trim();
|
||||
console.log(policy_no +'-'+policy_no.length);
|
||||
console.log(policy_no + '-' + policy_no.length);
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('util/check_policy_no/');?>'+policy_no,
|
||||
url: '<?php echo base_url('util/check_policy_no/');?>' + policy_no,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
success: function(res) {
|
||||
|
||||
console.log(res)
|
||||
if(res.status == true){
|
||||
if (res.status == true) {
|
||||
toastr.warning(res.message, 'warning');
|
||||
$('#policy_no').val('');
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
})
|
||||
|
||||
$(document).ready(function () {
|
||||
$(document).ready(function() {
|
||||
// Check if the URL contains a hash
|
||||
const hash = window.location.hash;
|
||||
|
||||
@ -1801,9 +1839,9 @@
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function getClientPolicyDataForEdit(client_policy_id){
|
||||
function getClientPolicyDataForEdit(client_policy_id) {
|
||||
|
||||
var policy_form_action = '';
|
||||
|
||||
@ -1905,7 +1943,8 @@
|
||||
$('#base_policy').prop('required', false);
|
||||
|
||||
|
||||
} else if (res.data.policy_type_id == '1' || res.data.policy_type_id == '2' || res.data.policy_type_id == '6' || res.data.policy_type_id == '7') {
|
||||
} else if (res.data.policy_type_id == '1' || res.data.policy_type_id == '2' || res.data
|
||||
.policy_type_id == '6' || res.data.policy_type_id == '7') {
|
||||
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
@ -1913,7 +1952,7 @@
|
||||
$('#base_policy_id').hide();
|
||||
$('#base_policy').prop('required', false);
|
||||
|
||||
}else if(res.data.policy_type_id == '3'){
|
||||
} else if (res.data.policy_type_id == '3') {
|
||||
|
||||
$('#first').show();
|
||||
$('#second').show();
|
||||
@ -1958,7 +1997,8 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (res.data.policy_type_id == '1' || res.data.policy_type_id == '6' || res.data.policy_type_id == '7') {
|
||||
if (res.data.policy_type_id == '1' || res.data.policy_type_id == '6' || res.data
|
||||
.policy_type_id == '7') {
|
||||
$('#tpa').prop('required', false);
|
||||
$('#tpa_danger').hide()
|
||||
} else {
|
||||
@ -1970,9 +2010,11 @@
|
||||
$('#client_branch').val(res.data.client_branch_id).select2();
|
||||
}, 1000);
|
||||
|
||||
setTimeout(function(){
|
||||
appendCDACNO(res.cd_data, res.data.cd_ac_no) // append and select the current CD Account Number
|
||||
appendBasePolicyList(res.client_policy_list, res.data.base_policy, res.data.client_branch_id); // append and select the Base palicy
|
||||
setTimeout(function() {
|
||||
appendCDACNO(res.cd_data, res.data
|
||||
.cd_ac_no) // append and select the current CD Account Number
|
||||
appendBasePolicyList(res.client_policy_list, res.data.base_policy, res.data
|
||||
.client_branch_id); // append and select the Base palicy
|
||||
}, 2000)
|
||||
|
||||
|
||||
@ -1987,14 +2029,17 @@
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function showModal(){
|
||||
function showModal($opener) {
|
||||
if($opener == 'lead_modal'){
|
||||
var myModal = new bootstrap.Modal(document.getElementById('lead_modal'));
|
||||
myModal.show();
|
||||
}else if($opener == 'rack_rate_auto_si_modal'){
|
||||
}
|
||||
}
|
||||
|
||||
function featchClient(){
|
||||
function featchClient() {
|
||||
|
||||
let lead_id = $('#lead_id').val();
|
||||
let client_id = $('#lead_id option:selected').data('clientid');
|
||||
@ -2009,22 +2054,23 @@
|
||||
url: url,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function (res) {
|
||||
success: function(res) {
|
||||
console.log(res);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
if(res.status == true){
|
||||
let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' + res.client_policy_id+'#police-tab';
|
||||
if (res.status == true) {
|
||||
let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' +
|
||||
res.client_policy_id + '#police-tab';
|
||||
toastr.success(res.message, 'SUCCESS')
|
||||
window.location.href = client_url;
|
||||
}else{
|
||||
} else {
|
||||
toastr.success(res.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('.close').click()
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
$('.loader').fadeOut();
|
||||
@ -2033,6 +2079,9 @@
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
</script>
|
||||
352
app/Views/rack_rate_auto_si.php
Normal file
352
app/Views/rack_rate_auto_si.php
Normal file
@ -0,0 +1,352 @@
|
||||
<div id="rack_rate_auto_si_modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog modal-full-width">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="fullWidthModalLabel">Rack Rate Auto SI</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form role="form" class="parsley-examples" method="post" id="auto_si_form"
|
||||
enctype="multipart/form-data">
|
||||
<input type="hidden" id="auto_si_pk" name="id">
|
||||
<input type="hidden" id="client_policy_pk" name="client_policy_id">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label class="switch" style="position: relative;">
|
||||
<input id="auto_si_enable" type="checkbox" name="is_auto_si">
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
</label>
|
||||
<label for="auto_si_enable" style="position: relative;bottom: 5px;left: 10px;">Enable Auto
|
||||
SI</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="dynamicForm">
|
||||
<div class="formGroupContainer"></div>
|
||||
</div> <br><br>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
|
||||
<button type="button" class="btn btn-primary" id="submitFormButton">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
let rowIndex = 0;
|
||||
var SIAMOUNT = []; //policy_premium_2 table data, rack rate si amount
|
||||
|
||||
$(document).ready(function() {
|
||||
// Attach change event listener to check for duplicates
|
||||
$('#dynamicForm').on('change', '.form-row input, .form-row select', function() {
|
||||
checkForDuplicate($(this).closest('.form-row'), $(this));
|
||||
});
|
||||
});
|
||||
|
||||
// Function to add a new row
|
||||
function addRow(button = null, data = null) {
|
||||
rowIndex++;
|
||||
|
||||
// Hide the "Add More" button for the current row (if button is provided)
|
||||
if (button) {
|
||||
$(button).hide();
|
||||
}
|
||||
|
||||
// Create a new row
|
||||
const formGroupContainer = document.querySelector('#dynamicForm .formGroupContainer');
|
||||
const newRow = document.createElement('div');
|
||||
newRow.className = 'row form-row';
|
||||
newRow.innerHTML = `
|
||||
<div class="col-md-1" style="margin-top: 45px;">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input family-checkbox" type="checkbox" id="selfCheckbox${rowIndex}" name="self" ${data && data.self == 1 ? 'checked' : ''}>
|
||||
<label class="form-check-label" for="selfCheckbox${rowIndex}">Self</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2" style="margin-top: 45px;">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input family-checkbox" type="checkbox" id="spouseCheckbox${rowIndex}" name="spouse" ${data && data.spouse == 1 ? 'checked' : ''}>
|
||||
<label class="form-check-label" for="spouseCheckbox${rowIndex}">Spouse</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<label class="form-label" for="childrenInput${rowIndex}">Children</label>
|
||||
<input type="number" class="form-control sm-input family-input" id="childrenInput${rowIndex}" placeholder="0" value="${data && data.children ? data.children : 0}" min="0">
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<label class="form-label" for="eldersInput${rowIndex}">Elders</label>
|
||||
<input type="number" class="form-control sm-input family-input" id="eldersInput${rowIndex}" placeholder="0" value="${data && data.elders ? data.elders : 0}" min="0">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label" for="siAmountSelect${rowIndex}">Choose SI Amount</label>
|
||||
<select class="form-select form-control si-select" id="siAmountSelect${rowIndex}">
|
||||
<option value="">Select SI</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2" style="margin-top: 45px;">
|
||||
<button type="button" class="btn btn-success addMoreBtn" onclick="addRow(this)">+</button>
|
||||
<button type="button" class="btn btn-danger" onclick="removeRow(this)">-</button>
|
||||
</div>
|
||||
`;
|
||||
formGroupContainer.appendChild(newRow);
|
||||
let selectedValue = data && data.si ? data.si : null;
|
||||
appendSIAmount(SIAMOUNT, selectedValue, rowIndex)
|
||||
}
|
||||
|
||||
// Function to remove a row
|
||||
function removeRow(button) {
|
||||
const row = button.closest('.form-row');
|
||||
const formGroupContainer = document.querySelector('.formGroupContainer');
|
||||
|
||||
// Prevent deletion of the first row
|
||||
if (formGroupContainer.children.length === 1) {
|
||||
alert("The first row cannot be deleted.");
|
||||
return;
|
||||
}
|
||||
|
||||
// If the removed row had the "Add More" button visible, show it for the previous row
|
||||
if ($(button).siblings('.addMoreBtn').is(':visible')) {
|
||||
const previousRow = row.previousElementSibling;
|
||||
if (previousRow) {
|
||||
$(previousRow).find('.addMoreBtn').show();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the row
|
||||
row.remove();
|
||||
}
|
||||
|
||||
// Function to check for duplicates
|
||||
function checkForDuplicate(currentRow, changedElement) {
|
||||
const currentValues = {
|
||||
self: currentRow.find('input[name="self"]').is(':checked'),
|
||||
spouse: currentRow.find('input[name="spouse"]').is(':checked'),
|
||||
children: currentRow.find('input[id^="childrenInput"]').val(),
|
||||
elders: currentRow.find('input[id^="eldersInput"]').val(),
|
||||
// siAmount: currentRow.find('select[id^="siAmountSelect"]').val(),
|
||||
};
|
||||
|
||||
let isDuplicate = false;
|
||||
|
||||
$('.form-row').not(currentRow).each(function() {
|
||||
const otherRow = $(this);
|
||||
const otherValues = {
|
||||
self: otherRow.find('input[name="self"]').is(':checked'),
|
||||
spouse: otherRow.find('input[name="spouse"]').is(':checked'),
|
||||
children: otherRow.find('input[id^="childrenInput"]').val(),
|
||||
elders: otherRow.find('input[id^="eldersInput"]').val(),
|
||||
// siAmount: otherRow.find('select[id^="siAmountSelect"]').val(),
|
||||
};
|
||||
|
||||
if (
|
||||
currentValues.self === otherValues.self &&
|
||||
currentValues.spouse === otherValues.spouse &&
|
||||
currentValues.children === otherValues.children &&
|
||||
currentValues.elders === otherValues.elders
|
||||
// && currentValues.siAmount === otherValues.siAmount
|
||||
) {
|
||||
isDuplicate = true;
|
||||
return false; // Exit the loop if duplicate is found
|
||||
}
|
||||
});
|
||||
|
||||
if (isDuplicate) {
|
||||
alert("Duplicate values are not allowed!");
|
||||
// currentRow.find('input, select').val('').prop('checked', false);
|
||||
if (changedElement.is('input[type="checkbox"]')) {
|
||||
changedElement.prop('checked', false);
|
||||
} else {
|
||||
changedElement.val('');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Function to form submit
|
||||
$(document).ready(function() {
|
||||
$('#submitFormButton').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData($('#auto_si_form')[0])
|
||||
const familyComposition = getFormDataWithJSON();
|
||||
|
||||
console.log(formData);
|
||||
console.log('familyComposition', familyComposition);
|
||||
|
||||
formData.append('family_composition', JSON.stringify(familyComposition));
|
||||
|
||||
let url = '<?= base_url('util/createAutoSI') ?>';
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(response) {
|
||||
|
||||
console.log(response);
|
||||
|
||||
if (response.status) {
|
||||
if (response.status == true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
} else {
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
} else {
|
||||
toastr.error(response.message || 'Unable to get responce', 'ERROR');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while Auto SI Form Submit.', 'ERROR');
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Function to gather form data with JSON structure
|
||||
function getFormDataWithJSON() {
|
||||
|
||||
const familyComposition = [];
|
||||
|
||||
$('#dynamicForm .form-row').each(function() {
|
||||
const row = $(this);
|
||||
const self = row.find('input[name="self"]').is(':checked') ? 1 : 0;
|
||||
const spouse = row.find('input[name="spouse"]').is(':checked') ? 1 : 0;
|
||||
const children = parseInt(row.find('input[id^="childrenInput"]').val()) || 0;
|
||||
const elders = parseInt(row.find('input[id^="eldersInput"]').val()) || 0;
|
||||
const si = row.find('select[id^="siAmountSelect"]').val() || null;
|
||||
|
||||
// if (si) {
|
||||
familyComposition.push({
|
||||
self: self,
|
||||
spouse: spouse,
|
||||
children: children,
|
||||
elders: elders,
|
||||
si: si,
|
||||
});
|
||||
// }
|
||||
});
|
||||
|
||||
console.log('familyComposition', JSON.stringify(familyComposition))
|
||||
return familyComposition;
|
||||
}
|
||||
|
||||
function checkCDAmountForBasePremium(client_policy_id) {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$('.formGroupContainer').empty();
|
||||
|
||||
console.log('client_policy_id', client_policy_id);
|
||||
$('#client_policy_pk').val(client_policy_id);
|
||||
let url = '<?= base_url('util/getRackRateSIAmountAndAutoSiDataForAutoSI') ?>';
|
||||
|
||||
// Data to send in the AJAX request
|
||||
let requestData = {
|
||||
client_policy_id: client_policy_id,
|
||||
};
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status == true) {
|
||||
|
||||
SIAMOUNT = response.si_amount;
|
||||
|
||||
if (response.auto_si_amount !== null) {
|
||||
|
||||
console.log(response.auto_si_amount.family_composition)
|
||||
let familyComp = JSON.parse(response.auto_si_amount.family_composition)
|
||||
console.log('familyComp', familyComp)
|
||||
familyComp.forEach((item) => {
|
||||
addRow(null, item);
|
||||
});
|
||||
|
||||
$('#auto_si_pk').val(response.auto_si_amount.id);
|
||||
|
||||
if (response.auto_si_amount.is_auto_si == 1) {
|
||||
$('#auto_si_enable').prop('checked', true);
|
||||
} else {
|
||||
$('#auto_si_enable').prop('checked', false);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
addRow();
|
||||
}
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('rack_rate_auto_si_modal'));
|
||||
myModal.show();
|
||||
|
||||
} else {
|
||||
if (response.status == false && response.code == 200) {
|
||||
Swal.fire({
|
||||
title: response.message,
|
||||
icon: 'warning',
|
||||
})
|
||||
} else {
|
||||
toastr.error(response.message || 'Unable to fetch data', 'ERROR');
|
||||
addRow();
|
||||
}
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while checking the SI amount.', 'ERROR');
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
// addRow();
|
||||
});
|
||||
}
|
||||
|
||||
function appendSIAmount(data, selectedValue = null, rowIndex = 0) {
|
||||
|
||||
console.log('data', data)
|
||||
console.log('selectedValue', selectedValue)
|
||||
console.log('rowIndex', rowIndex)
|
||||
|
||||
// Dynamically target the SI Amount Select element based on the rowIndex
|
||||
const selectElement = $(`#siAmountSelect${rowIndex}`);
|
||||
|
||||
// Empty the current options
|
||||
selectElement.empty();
|
||||
|
||||
// Add the default "Select SI" option
|
||||
selectElement.append($('<option>', {
|
||||
value: '',
|
||||
text: 'Select SI'
|
||||
}));
|
||||
|
||||
// Loop through the data to create the option elements
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.si,
|
||||
text: item.si,
|
||||
});
|
||||
|
||||
// If selectedValue matches the item.id, set this option as selected
|
||||
if (selectedValue == item.si) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
|
||||
// Append the option to the select element
|
||||
selectElement.append(option);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user