FEAT_AUTO_SI : RV

This commit is contained in:
VENKATESHWARAN 2025-01-08 15:28:58 +05:30
parent 4f5f117aa6
commit f76c356729
7 changed files with 2262 additions and 1667 deletions

View File

@ -335,6 +335,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->post('get_data_for_mapping', 'EmployeeController::getDataForMapping'); $routes->post('get_data_for_mapping', 'EmployeeController::getDataForMapping');
$routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1'); $routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1');
$routes->get('transformMailContent', 'LeadsController::transformMailContent'); $routes->get('transformMailContent', 'LeadsController::transformMailContent');
$routes->get('getRackRateSIAmountAndAutoSiDataForAutoSI', 'ClientController::getRackRateSIAmountAndAutoSiDataForAutoSI');
$routes->post('createAutoSI', 'ClientController::createAutoSI');
}); });
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {

View File

@ -39,6 +39,7 @@ use App\Models\PolicyTransactionModel;
use App\Models\PolicyTransactionStatusModel; use App\Models\PolicyTransactionStatusModel;
use App\Models\VehicleModel; use App\Models\VehicleModel;
use App\Models\LeadsModel; use App\Models\LeadsModel;
use App\Models\AutoSIModel;
use App\Controllers\EmpDataServiceController; use App\Controllers\EmpDataServiceController;
use App\Controllers\GoogleDriveController; use App\Controllers\GoogleDriveController;
@ -80,6 +81,7 @@ class ClientController extends AdminController
protected $policyTransactionStatusModel; protected $policyTransactionStatusModel;
protected $vehicleModel; protected $vehicleModel;
protected $leadsModel; protected $leadsModel;
protected $AutoSIModel;
@ -116,6 +118,7 @@ class ClientController extends AdminController
$this->policyTransactionStatusModel = new PolicyTransactionStatusModel(); $this->policyTransactionStatusModel = new PolicyTransactionStatusModel();
$this->vehicleModel = new VehicleModel(); $this->vehicleModel = new VehicleModel();
$this->leadsModel = new LeadsModel(); $this->leadsModel = new LeadsModel();
$this->AutoSIModel = new AutoSIModel();
} }
//-------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------
@ -3876,28 +3879,29 @@ class ClientController extends AdminController
// $EmpDataServiceController = new EmpDataServiceController(); // $EmpDataServiceController = new EmpDataServiceController();
// $EmpDataServiceController->importInceptionFileValidation(['file_id' => 160]); // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 160]);
$EmpDataServiceController = new EmpDataServiceController(); // $EmpDataServiceController = new EmpDataServiceController();
// $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 162]); // $EmpDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 162]);
// $EmpDataServiceController->importInceptionFileValidation(['file_id' => 162]); // $EmpDataServiceController->importInceptionFileValidation(['file_id' => 162]);
// $EmpDataServiceController->importDeletionValidation(['file_id' => 171]); // $EmpDataServiceController->importDeletionValidation(['file_id' => 171]);
// $EmpDataServiceController->importDeletionUpdateEndorsementID(['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(); // $EmpDataServiceController->cashDepositCalculationForDeletion($array);
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 757]);
$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);
}
}
} }

View File

@ -2,6 +2,8 @@
use App\Models\EmployeeModel; use App\Models\EmployeeModel;
use App\Models\InsurerModel; use App\Models\InsurerModel;
use App\Models\ClientPolicyModel;
use App\Models\AutoSIModel;
use Kint\Kint; use Kint\Kint;
@ -900,7 +902,7 @@ if (!function_exists('calculate_premium_new'))
// dd($slab); // dd($slab);
$res = compare_incoming_family_slab_with_configured_slab($slab,$incoming_familiy_composition); $res = compare_incoming_family_slab_with_configured_slab($slab,$incoming_familiy_composition);
// kint::dump($key); // kint::dump($key);
// kint::dump($res); kint::dump($res);
if($res['is_applicable']) if($res['is_applicable'])
{ {
@ -940,7 +942,7 @@ if (!function_exists('calculate_premium_new'))
$temp_slab_rates[$key]['is_applicable'] = false; $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 //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 // // Final combined condition
if ($conditions['isEmployeeSourceEnrollment'] || $conditions['isEmployeeSourceExcelFile'] || $primaryGridTypeCondition ) { 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); $transformed_familiy_member_data = premium_calculation_manager($transformed_familiy_member_data,$policy_terms,$temp_slab_rates,$default_si);
// dd($transformed_familiy_member_data); // dd($transformed_familiy_member_data);
$result[] = $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)
{
}
}

View 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;
}
}

View File

@ -52,7 +52,8 @@ class ClientPolicyModel extends Model
"disclaimer", "disclaimer",
"is_active", "is_active",
"is_member_modify_allowed", "is_member_modify_allowed",
"cd_ac_pk" "cd_ac_pk",
"is_auto_si",
]; ];
// Callbacks // Callbacks

View File

@ -1,9 +1,12 @@
<div class="tab-pane fade" id="police-tab"> <div class="tab-pane fade" id="police-tab">
<div class="row float-right" style="padding-bottom: 10px; position: relative;right: 13px;"> <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="BtnAdd" class="btn btn-primary waves-effect waves-light btnAdd btn-sm"
<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> 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('lead_modal')"><span class="fa fa-plus-square" aria-hidden="true"
style="padding: 5px 10px;"></span>Add Policy From Lead</button>
</div> </div>
<div class="table-responsive" id="table_list"> <div class="table-responsive" id="table_list">
@ -31,7 +34,9 @@
<div class="card-body"> <div class="card-body">
<div class="row float-right" style="position: relative; bottom: 20px; right: 13px;"> <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> </div>
<hr> <hr>
@ -43,7 +48,8 @@
<input type="hidden" id="policy_form_action" /> <input type="hidden" id="policy_form_action" />
<input type="hidden" name="policy_type_id" id="policy_type_id" /> <input type="hidden" name="policy_type_id" id="policy_type_id" />
<input type="hidden" id="insurer_policy_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"> <div class="form-group">
@ -68,7 +74,8 @@
</div> </div>
<div class="form-group col-md-4" id="base_policy_id" style="display: none;"> <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"> <select class="form-control" id="base_policy" name="base_policy">
<option value="" selected>Select Base Policy</option> <option value="" selected>Select Base Policy</option>
</select> </select>
@ -102,30 +109,36 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="policy_no">Policy No<span class="text-danger">*</span></label> <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> <input value="" type="text" class="form-control" placeholder="Enter Policy Number "
name="policy_no" id="policy_no" required>
</div> </div>
</div> </div>
<div class="form-row" id="second" style="display: none;"> <div class="form-row" id="second" style="display: none;">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="policy_start_date">Policy Start Date<span class="text-danger">*</span></label> <label for="policy_start_date">Policy Start Date<span
<input value="" type="text" class="form-control" placeholder="Enter Start Date " name="policy_start_date" id="start_date" required> 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>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="policy_end_date">Policy End Date<span class="text-danger">*</span></label> <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>
<div class="form-group col-md-4" id="policy_status_field"> <div class="form-group col-md-4" id="policy_status_field">
<label for="policy_status">Policy Status</label> <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>
</div> </div>
<div class="form-row" id="third" style="display: none; position: relative;top: 22px;"> <div class="form-row" id="third" style="display: none; position: relative;top: 22px;">
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="cd_ac_no">CD Account Number<span id="tpa_danger" class="text-danger">*</span></label> <label for="cd_ac_no">CD Account Number<span id="tpa_danger"
class="text-danger">*</span></label>
<select class="form-control" id="cd_ac_no" name="cd_ac_no" required> <select class="form-control" id="cd_ac_no" name="cd_ac_no" required>
<option value="">Select CD Account Number</option> <option value="">Select CD Account Number</option>
</select> </select>
@ -133,7 +146,8 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="gst_no">GST ( % )<span id="tpa_danger" class="text-danger">*</span></label> <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>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
@ -148,22 +162,27 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="open_date">Open Date<span class="text-danger">*</span></label> <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>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="close_date">Close Date<span class="text-danger">*</span></label> <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>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="reminder_date">Reminder Date<span class="text-danger">*</span></label> <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"> <div class="form-group col-md-12">
<label for="disclaimer">Disclaimer<span class="text-danger">*</span></label> <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>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
@ -172,7 +191,8 @@
<span class="slider round" style="height: 27px;"></span> <span class="slider round" style="height: 27px;"></span>
</label> </label>
<label for="policy_visibility" style="position: relative;bottom: 5px;left: 85px;">Policy Visibilty in Enrollment App</label> <label for="policy_visibility" style="position: relative;bottom: 5px;left: 85px;">Policy
Visibilty in Enrollment App</label>
</div> </div>
<!-- <div class="form-group col-md-4"> <!-- <div class="form-group col-md-4">
@ -190,8 +210,10 @@
</div> </div>
<div class="form-group text-right m-b-0"> <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="submit" class="btn btn-primary waves-effect waves-light mr-1"
<button type="button" class="btn btn-secondary waves-effect btnBack" id="btnBack">Cancel</button> id="btnSubmit">Submit</button>
<button type="button" class="btn btn-secondary waves-effect btnBack"
id="btnBack">Cancel</button>
</div> </div>
</form> </form>
@ -206,9 +228,11 @@
<?php include('policy_gmc_terms.php'); ?> <?php include('policy_gmc_terms.php'); ?>
<?php include('policy_gpa_terms.php'); ?> <?php include('policy_gpa_terms.php'); ?>
<?php include('other_policy_terms.php'); ?> <?php include('other_policy_terms.php'); ?>
<?php include('rack_rate_auto_si.php'); ?>
<!-- Center modal content --> <!-- 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-dialog modal-dialog-centered">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -223,7 +247,9 @@
<option value="">Select Lead</option> <option value="">Select Lead</option>
<?php if(isset($lead_data)) { ?> <?php if(isset($lead_data)) { ?>
<?php foreach ($lead_data as $value) { ?> <?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 } ?>
<?php } ?> <?php } ?>
</select> </select>
@ -237,8 +263,8 @@
</div> </div>
</div><!-- /.modal --> </div><!-- /.modal -->
<script>
<script>
$('#inception_type').change(function() { $('#inception_type').change(function() {
var open_data = $('#open_date').parent(); var open_data = $('#open_date').parent();
var close_data = $('#close_date').parent(); var close_data = $('#close_date').parent();
@ -379,9 +405,14 @@
var policy_name_data = `${item.policy_type_name ?? ''}` + ' - ' + `${item.policy_no ?? ''}`; 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'); checkCDAmountForBasePremium('${item.id}')"><i class="mdi mdi-autorenew mr-2 text-muted font-18 vertical-middle"></i>Auto SI</a>`;
}
policyTable += ` policyTable +=
`
<tr> <tr>
<td>${item.insurer_short} - ${item.insurer_branch_name}</td> <td>${item.insurer_short} - ${item.insurer_branch_name}</td>
<td>${policy_name_data}</td> <td>${policy_name_data}</td>
@ -396,11 +427,12 @@
<div class="dropdown-menu dropdown-menu-right"> <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="${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 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 // Conditionally render the delete option based on the role
if (role !== 3 && role !== 4) { 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>`; <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>`;
} }
@ -622,9 +654,16 @@
tpaValue = item.tpa_short + '-' + item.tpa_branch_code; 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'); checkCDAmountForBasePremium('${item.id}')"><i class="mdi mdi-autorenew mr-2 text-muted font-18 vertical-middle"></i>Auto SI</a>`;
}
policyTable +=
`
<tr> <tr>
<td>${item.insurer_short} - ${item.insurer_branch_name}</td> <td>${item.insurer_short} - ${item.insurer_branch_name}</td>
<td>${policy_name_data}</td> <td>${policy_name_data}</td>
@ -640,11 +679,14 @@
<div class="dropdown-menu dropdown-menu-right"> <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="${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 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>
<a href="#" data-id="${item.id}" data-typeid="${item.policy_type_id}" class="dropdown-item" onclick="showModal('rack_rate_auto_si_modal'); checkCDAmountForBasePremium('${item.id}')"><i class="mdi mdi-autorenew mr-2 text-muted font-18 vertical-middle"></i>Auto SI</a>
${auto_si_menu}`;
// Conditionally render the delete option based on the role // Conditionally render the delete option based on the role
if (role !== 3 && role !== 4) { 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>`; <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>`;
} }
@ -871,7 +913,8 @@
$('#base_policy').prop('required', false); $('#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(); $('#first').show();
$('#second').show(); $('#second').show();
@ -924,7 +967,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').prop('required', false);
$('#tpa_danger').hide() $('#tpa_danger').hide()
} else { } else {
@ -937,8 +981,10 @@
}, 1000); }, 1000);
setTimeout(function() { setTimeout(function() {
appendCDACNO(res.cd_data, res.data.cd_ac_no) // append and select the current CD Account Number appendCDACNO(res.cd_data, res.data
appendBasePolicyList(res.client_policy_list, res.data.base_policy, res.data.client_branch_id); // append and select the Base palicy .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) }, 2000)
@ -1184,7 +1230,6 @@
return word.trim(); return word.trim();
} }
function convertCommaNumberToWords(input) { function convertCommaNumberToWords(input) {
let number; let number;
@ -1224,7 +1269,6 @@
return result.trim(); return result.trim();
} }
function onlyNumbers(event) { function onlyNumbers(event) {
var charcode; var charcode;
charcode = event.which || event.keyCode; charcode = event.which || event.keyCode;
@ -1232,7 +1276,6 @@
return false; return false;
} }
function formatNumber(input, maxLength) { function formatNumber(input, maxLength) {
//console.log("input", input); //console.log("input", input);
@ -1324,7 +1367,6 @@
} }
$('#policy_type').change(function() { $('#policy_type').change(function() {
$('#insurer').val('').change(); $('#insurer').val('').change();
@ -1338,7 +1380,8 @@
var client_id = $('#client_id_policy').val(); var client_id = $('#client_id_policy').val();
var client_branch_id = $('#client_branch').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) {
@ -1443,7 +1486,6 @@
} }
}) })
// featch client policy to list in the Base policy Dropdown list // featch client policy to list in the Base policy Dropdown list
function fetchClientPolicyList() { function fetchClientPolicyList() {
@ -1487,7 +1529,8 @@
} }
} else { } else {
OptionsHTML += '<option data-id="' + item.policy_type_id + '" value="' + item OptionsHTML += '<option data-id="' + item.policy_type_id + '" value="' +
item
.id + .id +
'">' + item.name + '( ' + item.policy_type + ' )</option>'; '">' + item.name + '( ' + item.policy_type + ' )</option>';
} }
@ -1546,7 +1589,8 @@
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(); $('#tpa').val(res.data.tpa_branch_id + '-' + res.data.tpa_id).change();
$('#policy_no').val(res.data.policy_no).change(); $('#policy_no').val(res.data.policy_no).change();
// $('#open_date').val(rearrangeDateFormat(res.data.open_date)).change(); // $('#open_date').val(rearrangeDateFormat(res.data.open_date)).change();
@ -1663,8 +1707,7 @@
} }
// append Base Policy to the dropdown for edit only // append Base Policy to the dropdown for edit only
function appendBasePolicyList(data, select = null) function appendBasePolicyList(data, select = null) {
{
// console.log('appendBasePolicyList', 'function called'); // console.log('appendBasePolicyList', 'function called');
// console.log('appendBasePolicyList data', data); // console.log('appendBasePolicyList data', data);
@ -1691,8 +1734,7 @@
}); });
} }
function removepolicy(element) function removepolicy(element) {
{
Swal.fire({ Swal.fire({
title: "Are you sure?", title: "Are you sure?",
@ -1904,7 +1946,8 @@
$('#base_policy').prop('required', false); $('#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(); $('#first').show();
$('#second').show(); $('#second').show();
@ -1957,7 +2000,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').prop('required', false);
$('#tpa_danger').hide() $('#tpa_danger').hide()
} else { } else {
@ -1970,8 +2014,10 @@
}, 1000); }, 1000);
setTimeout(function() { setTimeout(function() {
appendCDACNO(res.cd_data, res.data.cd_ac_no) // append and select the current CD Account Number appendCDACNO(res.cd_data, res.data
appendBasePolicyList(res.client_policy_list, res.data.base_policy, res.data.client_branch_id); // append and select the Base palicy .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) }, 2000)
@ -1988,9 +2034,12 @@
}); });
} }
function showModal(){ function showModal($opener) {
if($opener == 'lead_modal'){
var myModal = new bootstrap.Modal(document.getElementById('lead_modal')); var myModal = new bootstrap.Modal(document.getElementById('lead_modal'));
myModal.show(); myModal.show();
}else if($opener == 'rack_rate_auto_si_modal'){
}
} }
function featchClient() { function featchClient() {
@ -2014,7 +2063,8 @@
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
if (res.status == true) { if (res.status == true) {
let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' + res.client_policy_id+'#police-tab'; let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' +
res.client_policy_id + '#police-tab';
toastr.success(res.message, 'SUCCESS') toastr.success(res.message, 'SUCCESS')
window.location.href = client_url; window.location.href = client_url;
} else { } else {
@ -2034,4 +2084,7 @@
}); });
} }
//----------------------------------------------------------------------------------------------------
</script> </script>

View 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>