FIX_UNIT_ISSUE_LEAD_MODULE_DEVLOPMENT : RV
This commit is contained in:
parent
29857c50ce
commit
3f5795859b
@ -13,8 +13,10 @@ use App\Models\LeadsModel;
|
||||
use App\Models\PolicyTypeModel;
|
||||
use App\Models\KYCEntityTypeModel;
|
||||
use App\Models\PolicyTransactionStatusModel;
|
||||
use App\Models\InsurerBranchModel;
|
||||
use App\Models\TPABranchModel;
|
||||
|
||||
class LeadsController extends AdminController
|
||||
class LeadsController extends BaseController
|
||||
{
|
||||
use ResponseTrait;
|
||||
|
||||
@ -31,6 +33,8 @@ class LeadsController extends AdminController
|
||||
protected $policyTypeModel;
|
||||
protected $kycEntityTypeModel;
|
||||
protected $policyTransactionStatusModel;
|
||||
protected $insurerBranchModel;
|
||||
protected $tpaBranchModel;
|
||||
|
||||
//variables for storing array
|
||||
protected $issuer;
|
||||
@ -52,10 +56,12 @@ class LeadsController extends AdminController
|
||||
$this->policyTypeModel = new PolicyTypeModel();
|
||||
$this->kycEntityTypeModel = new KYCEntityTypeModel();
|
||||
$this->policyTransactionStatusModel = new PolicyTransactionStatusModel();
|
||||
$this->insurerBranchModel = new InsurerBranchModel();
|
||||
$this->tpaBranchModel = new TPABranchModel();
|
||||
|
||||
$this->issuer = [1 => 'JIBS', 2 => 'Nhance'];
|
||||
$this->clientType = [1 => 'Group', 2 => 'Individual'];
|
||||
$this->leadType = [1 => 'Fresh', 2 => 'Renewal'];
|
||||
$this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
|
||||
$this->leadsStatus = [
|
||||
'queued' => 'Queued',
|
||||
'qcr_sent' => 'QCR sent',
|
||||
@ -71,13 +77,21 @@ class LeadsController extends AdminController
|
||||
{
|
||||
$data['page_name'] = 'Leads';
|
||||
|
||||
$data['issuer'] = $this->issuer ;
|
||||
$data['client_type'] = $this->clientType;
|
||||
$data['lead_type'] = $this->leadType;
|
||||
// Set basic data
|
||||
$data['issuer'] = $this->issuer;
|
||||
$data['client_type'] = $this->clientType;
|
||||
$data['lead_type'] = $this->leadType;
|
||||
$data['lead_status'] = $this->leadsStatus;
|
||||
|
||||
// Fetch policy types and entity data
|
||||
$data['policy_type'] = $this->policyTypeModel->where('is_active', 1)->findAll();
|
||||
$data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
|
||||
$data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
|
||||
|
||||
// Fetch insurer and TPA branch data
|
||||
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
|
||||
$data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
|
||||
|
||||
// Fetch sales team members who are active in team 5
|
||||
$data['salse_team'] = $this->userModel
|
||||
->select('user_profiles.*')
|
||||
->join('user_teams', 'user_profiles.id = user_teams.user_id')
|
||||
@ -86,9 +100,13 @@ class LeadsController extends AdminController
|
||||
->where('user_profiles.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$data['lead_data_list'] = $this->leadsModel->getLeadDataForLising();
|
||||
// dd($data);
|
||||
$this->loadLayout('leads_list', $data);
|
||||
|
||||
// Fetch leads data
|
||||
$data['lead_data_list'] = $this->leadsModel->getLeadDataForLising();
|
||||
|
||||
// Load layout and pass data
|
||||
$this->loadLayout('leads_list', $data);
|
||||
}
|
||||
|
||||
public function createLead()
|
||||
@ -126,9 +144,9 @@ class LeadsController extends AdminController
|
||||
if($data['client_code'] == 2){
|
||||
$data['client_code'] = generate_client_code('IC');
|
||||
}
|
||||
|
||||
|
||||
$data = $this->prepareMultipleLeadData($data);
|
||||
|
||||
// print_r($data); die;
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -136,7 +154,41 @@ class LeadsController extends AdminController
|
||||
{
|
||||
$processedData = [];
|
||||
foreach($data['policy_type_id'] as $index => $value){
|
||||
$processedData = [
|
||||
|
||||
// Separate the insurer and insurer branch
|
||||
list($insurer_branch_id, $insurer_id) = explode('-',$data['insurer'][$index]);
|
||||
// Separate the tpa and tpa branch
|
||||
list($tpa_branch_id, $tpa_id) = explode('-',$data['tpa'][$index]);
|
||||
|
||||
// Separate the insurer and insurer branch, handle missing or invalid data
|
||||
if (isset($data['proposed_insurer'][$index]) && strpos($data['proposed_insurer'][$index], '-') !== false) {
|
||||
list($proposed_insurer_branch_id, $proposed_insurer_id) = explode('-', $data['proposed_insurer'][$index]);
|
||||
} else {
|
||||
$proposed_insurer_branch_id = 0;
|
||||
$proposed_insurer_id = 0;
|
||||
}
|
||||
|
||||
// Separate the TPA and TPA branch, handle missing or invalid data
|
||||
if (isset($data['proposed_tpa'][$index]) && strpos($data['proposed_tpa'][$index], '-') !== false) {
|
||||
list($proposed_tpa_branch_id, $proposed_tpa_id) = explode('-', $data['proposed_tpa'][$index]);
|
||||
} else {
|
||||
$proposed_tpa_branch_id = 0;
|
||||
$proposed_tpa_id = 0;
|
||||
}
|
||||
|
||||
if(!empty($data['policy_start_date'][$index])){
|
||||
$policy_start_date = change_date_format($data['policy_start_date'][$index], 'd/m/Y', 'Y-m-d');
|
||||
}else{
|
||||
$policy_start_date = null;
|
||||
}
|
||||
|
||||
if(!empty($data['policy_end_date'][$index])){
|
||||
$policy_end_date = change_date_format($data['policy_end_date'][$index], 'd/m/Y', 'Y-m-d');
|
||||
}else{
|
||||
$policy_end_date = null;
|
||||
}
|
||||
|
||||
$processedData[] = [
|
||||
'lead_type' => $data['lead_type'],
|
||||
'issuer' => $data['issuer'],
|
||||
'client_type' => $data['client_type'],
|
||||
@ -144,23 +196,34 @@ class LeadsController extends AdminController
|
||||
'client_short_name' => $data['client_short_name'],
|
||||
'entity_type_id' => $data['entity_type_id'],
|
||||
'client_code' => $data['client_code'],
|
||||
'cost_center' => $data['cost_center'],
|
||||
'pan' => $data['pan'],
|
||||
'gst' => $data['gst'],
|
||||
'branch_name' => $data['branch_name'],
|
||||
'branch_code' => $data['branch_code'],
|
||||
'contact_person_name' => $data['contact_person_name'],
|
||||
'contact_person_mobile' => $data['contact_person_mobile'],
|
||||
'client_id' => $data['client_id'],
|
||||
'client_branch_id' => $data['client_branch_id'],
|
||||
'source_policy_id' => $data['source_policy_id'],
|
||||
'client_id' => $data['client_id'] ?? 0,
|
||||
'client_branch_id' => $data['client_branch_id'] ?? 0,
|
||||
'source_policy_id' => $data['source_policy_id'] ?? 0,
|
||||
'policy_type_id' => $value,
|
||||
'salse_person_id' => $data['salse_person_id'],
|
||||
'status' => $data['status'],
|
||||
'notes' => $data['notes'],
|
||||
'created_by' => $data['created_by'],
|
||||
'updated_by' => $data['updated_by'],
|
||||
'is_active' => $data['is_active'],
|
||||
'salse_person_id' => $data['salse_person_id'] ?? 0,
|
||||
|
||||
'insurer_id' => $insurer_id ?? 0,
|
||||
'insurer_branch_id' => $insurer_branch_id ?? 0,
|
||||
'tpa_id' => $tpa_id ?? 0,
|
||||
'tpa_branch_id' => $tpa_branch_id ?? 0,
|
||||
'policy_start_date' => $policy_start_date,
|
||||
'policy_end_date' => $policy_end_date,
|
||||
'no_of_lives' => $data['no_of_lives'][$index] ?? null,
|
||||
'claims' => $data['claims'][$index] ?? null,
|
||||
'location' => $data['location'][$index] ?? null,
|
||||
'proposed_insurer_id' => $proposed_insurer_id ?? 0,
|
||||
'proposed_insurer_branch_id' => $proposed_insurer_branch_id ?? 0,
|
||||
'proposed_tpa_id' => $proposed_tpa_id ?? 0,
|
||||
'proposed_tpa_branch_id' => $proposed_tpa_branch_id ?? 0,
|
||||
|
||||
'status' => $data['status'] ?? null,
|
||||
'notes' => $data['notes'] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
@ -169,21 +232,24 @@ class LeadsController extends AdminController
|
||||
|
||||
private function insertNewLead($data)
|
||||
{
|
||||
$insert = $this->leadsModel->insert($data);
|
||||
$insertCount = [];
|
||||
foreach($data as $value){
|
||||
$insert = $this->leadsModel->insert($value);
|
||||
$insertCount[] = $insert;
|
||||
$this->insertLeadStatus($insert, $value['status'], 3);
|
||||
}
|
||||
|
||||
if ($insert) {
|
||||
$this->insertLeadStatus($insert, $data['status'], 3);
|
||||
if (count($insertCount) > 0) {
|
||||
return $this->respond(['status' => true, 'lead_id' => $insert, 'message' => 'New Lead created successfully', 'data' =>$data], 200);
|
||||
}
|
||||
|
||||
return $this->respond(['status' => true, 'lead_id' => $insert, 'message' => "Failed to create Lead", 'data' =>$data], 200);
|
||||
return $this->respond(['status' => false, 'lead_id' => $insert, 'message' => "Failed to create Lead", 'data' =>$data], 200);
|
||||
}
|
||||
|
||||
private function updateOldLead($id, $data)
|
||||
{
|
||||
if ($this->leadsModel->update($id, $data)) {
|
||||
|
||||
$this->insertLeadStatus($id, $data['status'], 3);
|
||||
if ($this->leadsModel->where('id', $id)->set($data[0])->update()) {
|
||||
$this->insertLeadStatus($id, $data[0]['status'], 3);
|
||||
return $this->respond(['status' => true, 'lead_id' => $id, 'message' => "Lead updated successfully", 'data' =>$data], 200);
|
||||
}
|
||||
return $this->respond(['status' => false, 'lead_id' => $id, 'message' => "Failed to update Lead", 'data' =>$data], 200);
|
||||
@ -197,6 +263,18 @@ class LeadsController extends AdminController
|
||||
->where('leads.id', $id)
|
||||
->where('leads.is_active', 1)
|
||||
->first();
|
||||
|
||||
if(!empty($data['policy_start_date'])){
|
||||
$data['policy_start_date'] = change_date_format($data['policy_start_date'], 'Y-m-d', 'd/m/Y');
|
||||
}else{
|
||||
$data['policy_start_date'] = null;
|
||||
}
|
||||
|
||||
if(!empty($data['policy_end_date'])){
|
||||
$data['policy_end_date'] = change_date_format($data['policy_end_date'], 'Y-m-d', 'd/m/Y');
|
||||
}else{
|
||||
$data['policy_end_date'] = null;
|
||||
}
|
||||
|
||||
if($data){
|
||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||
|
||||
@ -234,13 +234,11 @@ class sendMailNotification
|
||||
$policy_name = $inner_item['policy_name'];
|
||||
|
||||
if ($inner_item['relationship'] == 'Self') {
|
||||
$emp_code = ' (' . $inner_item['emp_code'] . ')';
|
||||
$emp_code = '(' . $inner_item['emp_code'] . ')';
|
||||
$mail = $inner_item['email_corporate'];
|
||||
} else {
|
||||
$emp_code = '';
|
||||
}
|
||||
$name = $inner_item['name'];
|
||||
}
|
||||
|
||||
|
||||
$si = '';
|
||||
$premium = '';
|
||||
$gst_forself = '';
|
||||
@ -251,7 +249,7 @@ class sendMailNotification
|
||||
}
|
||||
|
||||
$temp_data .= '<tr>';
|
||||
$temp_data .= '<td>' . $inner_item['name'] . $emp_code . '</td>';
|
||||
$temp_data .= '<td>' . $inner_item['name'] . ($inner_item['relationship'] == 'Self' ? ' (' . $inner_item['emp_code'] . ')' : '') . '</td>';
|
||||
$temp_data .= '<td>' . $inner_item['relationship'] . '</td>';
|
||||
$temp_data .= '<td>' . \DateTime::createFromFormat('Y-m-d', $inner_item['dob'])->format('d-m-Y') . '</td>';
|
||||
$temp_data .= '<td>' . $si . '</td>';
|
||||
|
||||
@ -29,6 +29,19 @@ class LeadsModel extends Model
|
||||
'source_policy_id',
|
||||
'policy_type_id',
|
||||
'salse_person_id',
|
||||
'insurer_id',
|
||||
'insurer_branch_id',
|
||||
'tpa_id',
|
||||
'tpa_branch_id',
|
||||
'policy_start_date',
|
||||
'policy_end_date',
|
||||
'no_of_lives',
|
||||
'claims',
|
||||
'location',
|
||||
'proposed_insurer_id',
|
||||
'proposed_insurer_branch_id',
|
||||
'proposed_tpa_id',
|
||||
'proposed_tpa_branch_id',
|
||||
'status',
|
||||
'notes',
|
||||
'created_at',
|
||||
@ -86,6 +99,7 @@ class LeadsModel extends Model
|
||||
->where('leads.is_active', 1)
|
||||
->where('leads.is_active', 1)
|
||||
->where('leads.is_active', 1)
|
||||
->orderBy('id', 'desc')
|
||||
->findAll();
|
||||
|
||||
}
|
||||
|
||||
@ -90,26 +90,11 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_type_id"> Policy Type <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="policy_type_id" name="policy_type_id" required>
|
||||
<option value="">Select Policy Type</option>
|
||||
<?php
|
||||
if (isset($policy_type) && count($policy_type)) {
|
||||
foreach ($policy_type as $key => $value) {
|
||||
echo "<option value='" . $value['id'] . "' >" .
|
||||
$value['policy_type'] .
|
||||
"</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- client row -->
|
||||
<div class="form-row" id="freshDiv">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -142,13 +127,13 @@
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_name">Client Name<span class="text-danger">*</span></label>
|
||||
<input class="form-control" id="client_name" name="client_name"
|
||||
<input type="text" class="form-control" id="client_name" name="client_name"
|
||||
placeholder="Enter Client Name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_short_name">Client Short Name<span class="text-danger">*</span></label>
|
||||
<input class="form-control" id="client_short_name" name="client_short_name"
|
||||
<input type="text" class="form-control" id="client_short_name" name="client_short_name"
|
||||
placeholder="Enter Client Short Name" required>
|
||||
</div>
|
||||
|
||||
@ -184,14 +169,14 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<label for="pan">PAN<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN Number"
|
||||
data-parsley-error-message="Invalid PAN Number. Example: ABCDE1234F" name="pan"
|
||||
data-parsley-trigger="change" data-parsley-pattern="^[A-Z]{5}[0-9]{4}[A-Z]$">
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN Number" data-parsley-error-message="Invalid PAN Number. Example: ABCDE1234F" name="pan" data-parsley-trigger="change" data-parsley-pattern="^[A-Z]{5}[0-9]{4}[A-Z]$">
|
||||
</div>
|
||||
</div>
|
||||
<!-- end client row -->
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- branch row-->
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -204,32 +189,36 @@
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_branch">Branch Name<span class="text-danger">*</span></label>
|
||||
<input class="form-control" id="branch_name" name="branch_name"
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name"
|
||||
placeholder="Enter Branch Name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="client_branch">Branch Code<span class="text-danger">*</span></label>
|
||||
<input class="form-control" id="branch_code" name="branch_code"
|
||||
<input type="text" class="form-control" id="branch_code" name="branch_code"
|
||||
placeholder="Enter Branch Code" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="client_branch">Contact Person Name<span class="text-danger">*</span></label>
|
||||
<input class="form-control" id="contact_person_name" name="contact_person_name"
|
||||
<input type="text" class="form-control" id="contact_person_name" name="contact_person_name"
|
||||
placeholder="Enter Contact Name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<label for="client_branch">Contact Person Mobile<span class="text-danger">*</span></label>
|
||||
<input class="form-control" id="contact_person_mobile" name="contact_person_mobile"
|
||||
<input type="text" class="form-control" id="contact_person_mobile" name="contact_person_mobile"
|
||||
placeholder="Enter Contact Mobile" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- policy row -->
|
||||
<div id="dynamic-form-container"></div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- other row -->
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
@ -287,13 +276,50 @@
|
||||
|
||||
<script>
|
||||
|
||||
//SELECT2 document ready function
|
||||
$(document).ready(function() {
|
||||
addHTMLInput()
|
||||
setTimeout(function() {
|
||||
$("textarea.select2-search__field").attr('rows', '1');
|
||||
$("textarea.select2-search__field").css('resize', 'none');
|
||||
}, 1000)
|
||||
|
||||
$('#insurer').select2();
|
||||
$('#tpa').select2();
|
||||
$('#proposed_insurer').select2();
|
||||
$('#proposed_tpa').select2();
|
||||
|
||||
})
|
||||
|
||||
//DATE document ready function
|
||||
// $(document).ready(function(){
|
||||
|
||||
// var today = new Date();
|
||||
|
||||
// var policy_start_date = flatpickr(".policy_start_date", {
|
||||
// dateFormat: "d/m/Y",
|
||||
// // defaultDate: today,
|
||||
// allowInput: false,
|
||||
// onChange: function(selectedDates, dateStr, instance) {
|
||||
// var policy_end_date = new Date(selectedDates[0]);
|
||||
// policy_end_date.setFullYear(policy_end_date.getFullYear() + 1);
|
||||
// policy_end_date.setDate(policy_end_date.getDate() - 1); // Set end date to last day of selected year
|
||||
// policy_end_datePicker.setDate(policy_end_date);
|
||||
// }
|
||||
// });
|
||||
|
||||
// // Calculate the end date (today + 1 year)
|
||||
// // var closeDate = new Date(today);
|
||||
// // closeDate.setFullYear(closeDate.getFullYear() + 1);
|
||||
// // closeDate.setDate(closeDate.getDate() - 1); // Set end date to last day of next year
|
||||
|
||||
// var policy_end_datePicker = flatpickr(".policy_end_date", {
|
||||
// dateFormat: "d/m/Y",
|
||||
// // defaultDate: closeDate,
|
||||
// allowInput: false
|
||||
// });
|
||||
// })
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
//view and edit Lead data function
|
||||
@ -313,6 +339,7 @@ function getLeadsDataForEdit(input) {
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
$('.btnDiv').hide();
|
||||
console.log('getLeadsDataForEdit', res);
|
||||
|
||||
if (res.status == true) {
|
||||
@ -330,10 +357,10 @@ function getLeadsDataForEdit(input) {
|
||||
$('#client_name').val(res.data.client_name);
|
||||
$('#client_short_name').val(res.data.client_short_name);
|
||||
$('#entity_type_id').val(res.data.entity_type_id);
|
||||
$('#policy_type_id').val(res.data.policy_type_id).change();
|
||||
$('#lead_status').val(res.data.status);
|
||||
$('#notes').val(res.data.notes);
|
||||
|
||||
|
||||
setTimeout(function() {
|
||||
$('#client_id').val(res.data.client_id).change();
|
||||
setTimeout(function() {
|
||||
@ -356,6 +383,24 @@ function getLeadsDataForEdit(input) {
|
||||
}, 1000);
|
||||
}, 1000);
|
||||
|
||||
var insurer = res.data.insurer_branch_id + '-' + res.data.insurer_id;
|
||||
var tpa = res.data.tpa_branch_id + '-' + res.data.tpa_id;
|
||||
|
||||
var proposed_insurer = res.data.proposed_insurer_branch_id + '-' + res.data.proposed_insurer_id;
|
||||
var proposed_tpa = res.data.proposed_tpa_branch_id + '-' + res.data.proposed_tpa_id;
|
||||
|
||||
$('#policy_type_id_1').val(res.data.policy_type_id).change();
|
||||
$('#insurer_1').val(insurer).select2();
|
||||
$('#tpa_1').val(tpa).select2();
|
||||
$('#proposed_insurer_1').val(proposed_insurer).select2();
|
||||
$('#proposed_tpa_1').val(proposed_tpa).select2();
|
||||
$('#policy_start_date_1').val(res.data.policy_start_date);
|
||||
$('#policy_end_date_1').val(res.data.policy_end_date);
|
||||
$('#no_of_lives').val(res.data.no_of_lives);
|
||||
$('#claims').val(res.data.claims);
|
||||
$('#location').val(res.data.location);
|
||||
|
||||
|
||||
if (res.data.salse_person_id) {
|
||||
selecSalsePerson(res.data.salse_person_id);
|
||||
}
|
||||
@ -365,11 +410,13 @@ function getLeadsDataForEdit(input) {
|
||||
$('#freshDiv').find('select, input').removeAttr('required');
|
||||
$('#renewalDiv').show();
|
||||
$('#freshDiv').hide();
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
} else {
|
||||
$('#renewalDiv').find('select, input').removeAttr('required');
|
||||
$('#freshDiv').find('select, input').attr('required', 'required');
|
||||
$('#renewalDiv').hide();
|
||||
$('#freshDiv').show();
|
||||
$('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
}
|
||||
|
||||
|
||||
@ -386,6 +433,7 @@ function getLeadsDataForEdit(input) {
|
||||
});
|
||||
}
|
||||
|
||||
//client branch data
|
||||
function getBranchData(input) {
|
||||
|
||||
var client_branch_id = $(input).val();
|
||||
@ -438,6 +486,57 @@ function getBranchData(input) {
|
||||
}
|
||||
}
|
||||
|
||||
//Client Policy Data
|
||||
function getPolicyData(input) {
|
||||
var client_policy_id = $(input).val();
|
||||
if (client_policy_id) {
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('client/policy/list/');?>' + client_policy_id,
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(res) {
|
||||
|
||||
console.log('getPolicyData response', res);
|
||||
|
||||
if (res.status == true) {
|
||||
|
||||
$('#gst').val(res.data.gst);
|
||||
$('#pan').val(res.data.pan);
|
||||
$('#branch_name').val(res.data.branch_name);
|
||||
$('#branch_code').val(res.data.branch_code);
|
||||
$('#contact_person_name').val(res.contact.name);
|
||||
$('#contact_person_mobile').val(res.contact.mobile);
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
} else {
|
||||
|
||||
$('#gst').val('');
|
||||
$('#pan').val('');
|
||||
$('#branch_name').val('');
|
||||
$('#branch_code').val('');
|
||||
$('#contact_person_name').val('');
|
||||
$('#contact_person_mobile').val('');
|
||||
|
||||
console.log(res.message, 'warning');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function selecSalsePerson(salse_person_ids) {
|
||||
|
||||
salse_person_ids = JSON.parse(salse_person_ids);
|
||||
@ -456,6 +555,187 @@ function selecSalsePerson(salse_person_ids) {
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
var increment = 1;
|
||||
|
||||
function addHTMLInput() {
|
||||
|
||||
const container = document.getElementById('dynamic-form-container');
|
||||
const newRow = document.createElement('div');
|
||||
newRow.className = 'form-row dynamic-form-row';
|
||||
|
||||
// Add an <hr> element
|
||||
const hrElement = document.createElement('hr');
|
||||
container.appendChild(hrElement);
|
||||
|
||||
// Set inner HTML with necessary input fields
|
||||
newRow.innerHTML += `
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_type_id">Policy Type <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="policy_type_id_${increment}" name="policy_type_id[]" required>
|
||||
<option value="">Select Policy Type</option>
|
||||
<?php
|
||||
if (isset($policy_type) && count($policy_type)) {
|
||||
foreach ($policy_type as $value) {
|
||||
echo "<option value='" . $value['id'] . "'>" .
|
||||
$value['policy_type'] .
|
||||
"</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="insurer">Insurer <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="insurer_${increment}" name="insurer[]" required>
|
||||
<option value="">Select Insurer</option>
|
||||
<?php if (isset($insurer)) { ?>
|
||||
<?php foreach ($insurer as $value) { ?>
|
||||
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>">
|
||||
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="tpa">TPA <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="tpa_${increment}" name="tpa[]" required>
|
||||
<option value="">Select TPA</option>
|
||||
<?php if (isset($tpa)) { ?>
|
||||
<?php foreach ($tpa as $value) { ?>
|
||||
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>">
|
||||
<?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="no_of_lives">No of Lives <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="no_of_lives" name="no_of_lives[]" placeholder="Enter Lives" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_start_date_${increment}">Date of Commencement <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control policy_start_date" id="policy_start_date_${increment}" name="policy_start_date[]" placeholder="Enter DOC" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_end_date_${increment}">Date of Expiry <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control policy_end_date" id="policy_end_date_${increment}" name="policy_end_date[]" placeholder="Enter DOE" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="claims">Claims <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="claims" name="claims[]" placeholder="Enter Claims" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="location">Location <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 proposed_div" style="display: none;">
|
||||
<label for="proposed_insurer">Proposed Insurer <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="proposed_insurer_${increment}" name="proposed_insurer[]" required>
|
||||
<option value="">Select Insurer</option>
|
||||
<?php if (isset($insurer)) { ?>
|
||||
<?php foreach ($insurer as $value) { ?>
|
||||
<option value="<?= $value['id'] . '-' . $value['insurer_id'] ?>">
|
||||
<?= $value['insurer_name'] . '-' . $value['branch_code'] ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 proposed_div" style="display: none;">
|
||||
<label for="proposed_tpa">Proposed TPA <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="proposed_tpa_${increment}" name="proposed_tpa[]" required>
|
||||
<option value="">Select TPA</option>
|
||||
<?php if (isset($tpa)) { ?>
|
||||
<?php foreach ($tpa as $value) { ?>
|
||||
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>">
|
||||
<?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12 btnDiv" style="position: relative;top: 28px;float: right;text-align: end;">
|
||||
<a class="btn btn-danger waves-effect waves-light" onclick="removeHTMLInput(this)">x</a>
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1" onclick="addHTMLInput()">+</a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
container.appendChild(newRow);
|
||||
|
||||
|
||||
var lead_type = $('#lead_type').val();
|
||||
|
||||
if (lead_type == 2) {
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
} else {
|
||||
$('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
}
|
||||
|
||||
// Scroll the newly added select into view and focus on it
|
||||
const newPolicyTypeSelect = document.getElementById(`policy_type_id_${increment}`);
|
||||
newPolicyTypeSelect.scrollIntoView({ behavior: 'smooth', block: 'end' });
|
||||
newPolicyTypeSelect.focus();
|
||||
|
||||
$('#insurer_'+ increment).select2();
|
||||
$('#tpa_'+ increment).select2();
|
||||
$('#proposed_insurer_'+ increment).select2();
|
||||
$('#proposed_tpa_'+ increment).select2();
|
||||
$('#policy_type_id_'+ increment).select2();
|
||||
|
||||
// Initialize date pickers
|
||||
var policy_start_datePicker = flatpickr("#policy_start_date_" + increment, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false,
|
||||
onChange: function(selectedDates) {
|
||||
var policy_end_date = new Date(selectedDates[0]);
|
||||
policy_end_date.setFullYear(policy_end_date.getFullYear() + 1);
|
||||
policy_end_date.setDate(policy_end_date.getDate() - 1); // Set end date to last day of selected year
|
||||
policy_end_datePicker.setDate(policy_end_date);
|
||||
}
|
||||
});
|
||||
|
||||
var policy_end_datePicker = flatpickr("#policy_end_date_" + increment, {
|
||||
dateFormat: "d/m/Y",
|
||||
allowInput: false
|
||||
});
|
||||
|
||||
increment++; // Increment after adding the input
|
||||
}
|
||||
|
||||
|
||||
function removeHTMLInput(element)
|
||||
{
|
||||
const container = document.getElementById('dynamic-form-container');
|
||||
const rows = container.querySelectorAll('.dynamic-form-row');
|
||||
|
||||
if (rows.length > 1) {
|
||||
const row = element.closest('.dynamic-form-row');
|
||||
|
||||
const hrElement = row.previousElementSibling; // Get the <hr> before the row
|
||||
console.log(hrElement);
|
||||
console.log(hrElement.tagName);
|
||||
if (hrElement && hrElement.tagName === 'HR') { // Check if it's an <hr> element
|
||||
hrElement.remove(); // Remove the <hr>
|
||||
}
|
||||
|
||||
row.remove();
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------
|
||||
|
||||
$("#leads_form_id").submit(function(event) {
|
||||
|
||||
@ -536,6 +816,7 @@ $('#lead_type').change(function() {
|
||||
$('#renewalDiv').find('select, input').attr('required', 'required');
|
||||
$('#freshDiv').find('select, input').removeAttr('required');
|
||||
$('#renewalDiv').show();
|
||||
$('.proposed_div').show().find('select, input').attr('required', 'required');
|
||||
$('#freshDiv').hide();
|
||||
|
||||
$('#gst').val('');
|
||||
@ -550,6 +831,7 @@ $('#lead_type').change(function() {
|
||||
$('#renewalDiv').find('select, input').removeAttr('required');
|
||||
$('#freshDiv').find('select, input').attr('required', 'required');
|
||||
$('#renewalDiv').hide();
|
||||
$('.proposed_div').hide().find('select, input').removeAttr('required');
|
||||
$('#freshDiv').show();
|
||||
|
||||
$('#gst').val('');
|
||||
|
||||
@ -344,7 +344,6 @@ var terms_si_amount_array = [];
|
||||
var unit_length = 0;
|
||||
var branch_units = [];
|
||||
|
||||
|
||||
$('body').on('click', '.btnPolicyModel', function()
|
||||
{
|
||||
$('#tab_content .tab-pane').not('#primary_rack_rate_tab').remove();
|
||||
@ -3063,7 +3062,7 @@ function createCheckboxes(obj, additional_relationship = [], unique_id = null, p
|
||||
|
||||
`;
|
||||
|
||||
console.log(html);
|
||||
// console.log(html);
|
||||
|
||||
$relationshipElement.append(html);
|
||||
|
||||
@ -3920,7 +3919,7 @@ function appendFourthAndSixthRackRate(data = null, uniqueId = null)
|
||||
}
|
||||
|
||||
if(unit_length == 1){
|
||||
toAddUnitInManuall(unique_id, branch_units[0], 'appendFourthAndSixthRackRate')
|
||||
toAddUnitInManuall(uniqueId, branch_units[0], 'appendFourthAndSixthRackRate')
|
||||
}
|
||||
}
|
||||
|
||||
@ -4353,21 +4352,23 @@ function applyStyles(tabId) {
|
||||
function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
|
||||
console.log('toAddUnitInManuall unique_id', unique_id)
|
||||
console.log('toAddUnitInManuall unique_id', typeof unique_id)
|
||||
console.log('toAddUnitInManuall whichFunction', whichFunction)
|
||||
|
||||
var id = $('#grid')[0];
|
||||
var id = $('#grid').val();
|
||||
console.log(id);
|
||||
var container = $('#grid_content_input');
|
||||
|
||||
if (unique_id) {
|
||||
id = $('#grid_'+unique_id)[0];
|
||||
if (unique_id !== 'null' && unique_id !== null && unique_id !== false && unique_id !== 'false') {
|
||||
id = $('#grid_'+unique_id).val();
|
||||
console.log(id);
|
||||
container = $('#grid_content_input_for_additional_'+unique_id);
|
||||
}
|
||||
|
||||
console.log('checkValideUnits id', id);
|
||||
console.log('checkValideUnits container', container);
|
||||
|
||||
if (id.value === '3') {
|
||||
if (id === '3') {
|
||||
|
||||
var units = container.find('input[name="3_unit[]"]');
|
||||
var unitValues = [];
|
||||
@ -4376,7 +4377,7 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '4') {
|
||||
} else if (id === '4') {
|
||||
|
||||
var units = container.find('input[name="4_unit[]"]');
|
||||
var unitValues = [];
|
||||
@ -4385,7 +4386,7 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '2' || id.value === '9') {
|
||||
} else if (id === '2' || id === '9') {
|
||||
|
||||
var units = container.find('input[name="gpa_unit29[]"]');
|
||||
|
||||
@ -4393,7 +4394,7 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '5') {
|
||||
} else if (id === '5') {
|
||||
|
||||
var units = container.find('input[name="5_unit[]"]');
|
||||
|
||||
@ -4401,7 +4402,7 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '6') {
|
||||
} else if (id === '6') {
|
||||
|
||||
var units = container.find('input[name="6_unit[]"]');
|
||||
|
||||
@ -4409,7 +4410,7 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '7') {
|
||||
} else if (id === '7') {
|
||||
|
||||
var units = container.find('input[name="7_unit[]"]');
|
||||
|
||||
@ -4417,7 +4418,7 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '10') {
|
||||
} else if (id === '10') {
|
||||
|
||||
var units = container.find('input[name="10_unit[]"]');
|
||||
|
||||
@ -4425,7 +4426,7 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '8') {
|
||||
} else if (id === '8') {
|
||||
|
||||
var units = container.find('input[name="8_unit[]"]');
|
||||
|
||||
@ -4433,7 +4434,7 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '11') {
|
||||
} else if (id === '11') {
|
||||
|
||||
var units = container.find('input[name="11_unit[]"]');
|
||||
|
||||
@ -4441,7 +4442,7 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '12') {
|
||||
} else if (id === '12') {
|
||||
|
||||
var units = container.find('input[name="12_unit[]"]');
|
||||
|
||||
@ -4449,7 +4450,7 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '13') {
|
||||
} else if (id === '13') {
|
||||
|
||||
var units = container.find('input[name="13_unit[]"]');
|
||||
|
||||
@ -4457,23 +4458,27 @@ function toAddUnitInManuall(unique_id = null, branch_unit = '', whichFunction) {
|
||||
var value = $(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (id.value === '1') {
|
||||
} else if (id === '1') {
|
||||
|
||||
console.log('checkValideUnits id', id);
|
||||
|
||||
var selectedValue = $('#si_or_bp').val();
|
||||
if (selectedValue == 1) {
|
||||
|
||||
console.log('checkValideUnits id 1', id);
|
||||
var units = container.find('input[name="gpa_unit_1[]"]');
|
||||
|
||||
units.each(function() {
|
||||
var value = $(this).val(branch_unit);
|
||||
$(this).val(branch_unit);
|
||||
});
|
||||
|
||||
} else if (selectedValue == 3) {
|
||||
|
||||
console.log('checkValideUnits id 3', id);
|
||||
var units = container.find('input[name="gpa_unit_3[]"]');
|
||||
|
||||
units.each(function() {
|
||||
var value = $(this).val(branch_unit);
|
||||
$(this).val(branch_unit);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user