MERGE_TEST_BDS_ROLE

This commit is contained in:
velz 2025-03-25 17:33:01 +05:30
commit e412673c45
8 changed files with 63 additions and 52 deletions

View File

@ -594,7 +594,7 @@ class ClientController extends AdminController
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
$data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames(); $data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
$data['state'] = $this->stateModel->getAllStates(); $data['state'] = $this->stateModel->getAllStates();
$data['RM'] = $this->userModel->findAll(); $data['RM'] = $this->userModel->where('is_active', 1)->findAll();
$data['policyGridData'] = $this->policyGridModel->findAll(); $data['policyGridData'] = $this->policyGridModel->findAll();
$data['policy_types'] = $this->policyTypeModel->findAll(); $data['policy_types'] = $this->policyTypeModel->findAll();
$data['policy_type'] = ['1' => 'Base Policy', '2' => 'SI Topup', '3' => 'Dependent Addon']; $data['policy_type'] = ['1' => 'Base Policy', '2' => 'SI Topup', '3' => 'Dependent Addon'];
@ -717,7 +717,7 @@ class ClientController extends AdminController
$this->myLogger->logme('error', 'Edit Client Onboarding function called'); $this->myLogger->logme('error', 'Edit Client Onboarding function called');
$headerData['page_name'] = 'Edit Client Onboarding'; $headerData['page_name'] = 'Edit Client Onboarding';
$editData['RM'] = $this->userModel->findAll(); $editData['RM'] = $this->userModel->where('is_active', 1)->findAll();
$editData['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames(); $editData['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
$editData['state'] = $this->stateModel->getAllStates(); $editData['state'] = $this->stateModel->getAllStates();
$editData['police'] = $this->policesModel->findAll(); $editData['police'] = $this->policesModel->findAll();

View File

@ -2532,10 +2532,6 @@ class EmployeeRestController extends AdminController
$result = []; $result = [];
foreach ($ClientPolicyData as $key => $ClientPolicyValue) { foreach ($ClientPolicyData as $key => $ClientPolicyValue) {
if($ClientPolicyValue['policy_type_id'] == 1) if($ClientPolicyValue['policy_type_id'] == 1)
{ {
$policyGroup = 'gpa'; $policyGroup = 'gpa';
@ -2555,11 +2551,7 @@ class EmployeeRestController extends AdminController
} }
$terms = json_decode($ClientPolicyValue['policy_terms'] , true); $terms = json_decode($ClientPolicyValue['policy_terms'] , true);
$data['policy_terms'] = isset($terms['enrollment_display_key']) $data['policy_terms'] = isset($terms['enrollment_display_key']) && !empty($terms['enrollment_display_key']) ? $terms['enrollment_display_key'] : $this->policyTermsFiter($terms, $policyGroup);
&& !empty($terms['enrollment_display_key'])
? $terms['enrollment_display_key']
: $this->policyTermsFiter($terms, $policyGroup);
$terms = json_decode($ClientPolicyValue['policy_terms']);
$data['client_id'] = $ClientPolicyValue['client_id']; $data['client_id'] = $ClientPolicyValue['client_id'];

View File

@ -628,12 +628,16 @@ class LeadsController extends BaseController
public function createRFQ() public function createRFQ()
{ {
// print_r($this->request->getPost('json')); die();
$data = $this->request->getPost(); $data = $this->request->getPost();
$lead_id = $data['lead_id']; $lead_id = $data['lead_id'] ?? null;
if (!$lead_id) {
return $this->respond(['status' => false, 'message' => 'Lead ID is required'], 400);
}
$data['type'] = 1; $data['type'] = 1;
// Deactivate existing RFQs for this lead and type
$this->RFQModel $this->RFQModel
->where('lead_id', $lead_id) ->where('lead_id', $lead_id)
->where('type', 1) ->where('type', 1)
@ -641,41 +645,40 @@ class LeadsController extends BaseController
->set('is_active', 0) ->set('is_active', 0)
->update(); ->update();
$registrationJson = $data['registration_json'] ?? null; // Use null coalescing operator for safety // Handle registration_json
if (empty($data['registration_json'])) {
// Fetch the latest registration_json if not provided
$latest = $this->RFQModel
->select('registration_json')
->where('lead_id', $lead_id)
->orderBy('id', 'DESC')
->first();
if ($registrationJson) { if (!empty($latest['registration_json'])) {
// If registration_json is provided, insert the data directly $data['registration_json'] = $latest['registration_json'];
$result = $this->RFQModel->insert($data);
} else {
// If registration_json is not provided, fetch the latest registration_json from the database
$this->RFQModel->select('registration_json')
->where("lead_id", $lead_id)
->order_by('id', 'DESC') // Assuming 'id' is an auto-increment field
->limit(1);
$query = $this->RFQModel->get();
$latestRegistrationJson = $query->row()->registration_json ?? null;
if ($latestRegistrationJson) {
// If a valid registration_json is found, update the data and insert
$data['registration_json'] = $latestRegistrationJson;
$result = $this->RFQModel->insert($data);
} else {
// If no registration_json is found, insert the data as-is
$result = $this->RFQModel->insert($data);
} }
} }
if ($result) { // Insert new RFQ
$insertId = $this->RFQModel->insert($data);
$message = "RFQ submitted successfully"; if ($insertId) {
if ($data['submit_type'] == 'QCR') { $message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR submitted successfully' : 'RFQ submitted successfully';
$message = "QCR submitted successfully"; return $this->respond([
} 'status' => true,
return $this->respond(['status' => true, 'id' => $result, 'message' => $message, 'data' => $data], 200); 'id' => $insertId,
'message' => $message,
'data' => $data
], 200);
} }
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create RFQ", 'data' => $data], 200); $message = ($data['submit_type'] ?? '') == 'QCR' ? 'Failed to create QCR' : 'Failed to create RFQ';
return $this->respond([
'status' => false,
'id' => null,
'message' => $message,
'data' => $data
], 200);
} }
public function createQCR() public function createQCR()
@ -2575,15 +2578,19 @@ class LeadsController extends BaseController
public function constructNonEbExcelToSaveTemp($lead_id, $type, $propsal_and_insurer = null) public function constructNonEbExcelToSaveTemp($lead_id, $type, $propsal_and_insurer = null)
{ {
$rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type); $rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
$lead_data = json_decode($rfq_data['custom_fields'], true) ?? []; $lead_data = json_decode($rfq_data['custom_fields'], true) ?? [];
if (!is_array($lead_data)) { if (!is_array($lead_data)) {
$lead_data = []; $lead_data = [];
} }
$lead_data = array_merge(['Insured' => $rfq_data['client_name']], $lead_data); $lead_data = array_merge(['Insured' => $rfq_data['client_name']], $lead_data);
$policy_registration_data = [];
if(isset($rfq_data['registration_json']) && !empty($rfq_data['registration_json'])){
$policy_registration_data = json_decode($rfq_data['registration_json'], true);
}
// dd($policy_registration_data);
// if(!empty($rfq_data['fin_years_claims'])){ // if(!empty($rfq_data['fin_years_claims'])){
// $claim_details = json_decode($rfq_data['fin_years_claims'], true) ?? []; // $claim_details = json_decode($rfq_data['fin_years_claims'], true) ?? [];
// if(!empty($claim_details['finyear'])){ // if(!empty($claim_details['finyear'])){

View File

@ -118,7 +118,7 @@ class RestAuthenticationController extends AdminController
->where('employees.emp_status !=', 'truncated') ->where('employees.emp_status !=', 'truncated')
->where('employees.email_corporate', $email) ->where('employees.email_corporate', $email)
->where('EP.is_active', 1) ->where('EP.is_active', 1)
->whereIn('EP.status', ['draft', 'enrolled']) ->whereIn('EP.status', ['active'])
->first(); ->first();
if (isset($employeeData['employee_id'])) { if (isset($employeeData['employee_id'])) {

View File

@ -68,6 +68,7 @@ class RFQModel extends Model
tpa_branch.branch_name as tpa_branch_name, tpa_branch.branch_name as tpa_branch_name,
policy_type.policy_type, policy_type.policy_type,
rfq.json, rfq.json,
rfq.registration_json
') ')
->join('leads', 'rfq.lead_id = leads.id') ->join('leads', 'rfq.lead_id = leads.id')
->join('policy_type', 'leads.policy_type_id = policy_type.id') ->join('policy_type', 'leads.policy_type_id = policy_type.id')

View File

@ -563,7 +563,7 @@
<?php } ?> <?php } ?>
<!-- Enrollment process --> <!-- Enrollment process -->
<?php if (in_array(get_role_id(), [1,2,3,5])) { ?> <?php if (in_array(get_role_id(), [1,2,3,5]) || in_array(ENROLLMENT_TEAM_ID, user_team())) { ?>
<li> <li>
<a href="#sidebarDashboards" data-toggle="collapse" class="waves-effect"> <a href="#sidebarDashboards" data-toggle="collapse" class="waves-effect">
<i class="fas fa-user-tie"></i> <i class="fas fa-user-tie"></i>
@ -674,7 +674,7 @@
<?php } ?> <?php } ?>
<!-- leads --> <!-- leads -->
<?php if (in_array(get_role_id(), [1,2,3,5]) || in_array(BUSINESS_SUPPORT_TEAM_ID, user_team())) { ?> <?php if (in_array(get_role_id(), [1,2,3,5]) || in_array(BUSINESS_SUPPORT_TEAM_ID, user_team()) || in_array(SALES_TEAM_ID, user_team())) { ?>
<li> <li>
<a href="<?= base_url('/leads/list') ?>"> <a href="<?= base_url('/leads/list') ?>">
<i class="mdi mdi-chart-bar"></i> <i class="mdi mdi-chart-bar"></i>

View File

@ -225,7 +225,9 @@
<button id="addQuote" class="btn btn-custom">Add New Proposal</button> <button id="addQuote" class="btn btn-custom">Add New Proposal</button>
<button id="submitData" class="btn btn-primary">Save RFQ</button> <button id="submitData" class="btn btn-primary">Save RFQ</button>
<button id="submitQCRData" onclick="checkTheTableDataChanged(5)" class="btn btn-primary">Procced to QCR</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <?php if (in_array(get_role_id(), [1,2,3,5]) || in_array(BUSINESS_SUPPORT_TEAM_ID, user_team())) { ?>
<button id="submitQCRData" onclick="checkTheTableDataChanged(5)" class="btn btn-primary">Procced to QCR</button>
<?php } ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary" id>Export Excel</a> <a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary" id>Export Excel</a>
<button id="submitInternalMail" class="btn btn-primary" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button> <button id="submitInternalMail" class="btn btn-primary" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button>
<button id="submitMail" class="btn btn-primary" onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button> <button id="submitMail" class="btn btn-primary" onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button>

View File

@ -182,7 +182,9 @@
<div class="row" style="margin-bottom: 1rem;margin-left: 0px;"> <div class="row" style="margin-bottom: 1rem;margin-left: 0px;">
<button class="btn btn-custom rfqbtn" id="addProposal" style="margin-right: 10px;">Add New Proposal</button> <button class="btn btn-custom rfqbtn" id="addProposal" style="margin-right: 10px;">Add New Proposal</button>
<button id="saveRFQ" onclick="saveRFQ()" class="btn btn-primary" style="margin-right: 10px;">Save RFQ</button> <button id="saveRFQ" onclick="saveRFQ()" class="btn btn-primary" style="margin-right: 10px;">Save RFQ</button>
<?php if (in_array(get_role_id(), [1,2,3,5]) || in_array(BUSINESS_SUPPORT_TEAM_ID, user_team())) { ?>
<button id="openQCR" onclick="openQCR()" class="btn btn-primary rfqbtn actionBtns" style="margin-right: 20px;">Proceed to QCR</button> <button id="openQCR" onclick="openQCR()" class="btn btn-primary rfqbtn actionBtns" style="margin-right: 20px;">Proceed to QCR</button>
<?php } ?>
<a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary actionBtns" style="margin-right: 10px;">Export Excel</a> <a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary actionBtns" style="margin-right: 10px;">Export Excel</a>
<button id="submitInternalMail" class="btn btn-primary actionBtns" style="margin-right: 10px;" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button> <button id="submitInternalMail" class="btn btn-primary actionBtns" style="margin-right: 10px;" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button>
<button id="submitMail" class="btn btn-primary actionBtns" style="margin-right: 10px;" onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button> <button id="submitMail" class="btn btn-primary actionBtns" style="margin-right: 10px;" onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button>
@ -1987,10 +1989,13 @@
function saveRFQTODB(tableJSON, policyJson) { function saveRFQTODB(tableJSON, policyJson) {
let submit_type = "RFQ"
if(rfq_or_qcr == 2){submit_type = 'QCR'}
var formData = { var formData = {
lead_id: $("#lead_id").val(), lead_id: $("#lead_id").val(),
json: JSON.stringify(tableJSON), json: JSON.stringify(tableJSON),
submit_type: "RFQ", submit_type: submit_type,
registration_json: policyJson registration_json: policyJson
} }
@ -3207,7 +3212,11 @@
} else if (redirect_type == 2) { } else if (redirect_type == 2) {
//EXCEL EXPORT //EXCEL EXPORT
let url = $('#submitExcel').data('url'); // let url = $('#submitExcel').data('url');
let lead_id = $('#lead_id').val();
let url = '<?= base_url('leads/exportQCRandRFQ/') ?>' + lead_id + '/' + rfq_or_qcr + '/' + 2
window.location.href = url; window.location.href = url;
} else if (redirect_type == 3) { } else if (redirect_type == 3) {