MERGE_TEST_RFQ_TAIL_CONNECT

This commit is contained in:
Venba 2024-11-26 04:05:05 +00:00
commit 153fedb211
16 changed files with 613 additions and 80 deletions

View File

@ -360,6 +360,7 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
$routes->get("sendMail", "LeadsController::sendMailWithAttachement");
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
$routes->get("featchLeadDataAndInsertClient/(:any)", "LeadsController::featchLeadDataAndInsertClient/$1");
$routes->get("featchClientPolicyFromLead/(:any)", "LeadsController::featchClientPolicyFromLead/$1");
});
$routes->group("rfq", ["filter" => "authMVC"], function ($routes) {

View File

@ -287,7 +287,7 @@ class ClientController extends AdminController
$headerData['page_name'] = 'Client List';
$data['clientList'] = $this->clientModel->getCreatedByUserName();
$data['client_rm'] = $this->clientRMModel->getAllClientRM();
// $data['lead_data'] = $this->leadsModel->getLeadForInsertClientList();
$data['lead_data'] = $this->leadsModel->getLeadForInsertClientList();
// dd($data);
@ -553,6 +553,7 @@ class ClientController extends AdminController
$editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
$editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
$editData['client_branch']['role'] = get_role_id();
$editData['lead_data'] = $this->leadsModel->getLeadForInsertClientList(2, $id);
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id);
foreach ($clientPoliceData as $key => $value) {

View File

@ -1900,6 +1900,8 @@ class EmployeeController extends AdminController
if (is_dir($logPath)) {
$files = array_diff(scandir($logPath), ['.', '..']); // Exclude '.' and '..'
$files = array_reverse($files);
foreach ($files as $file) {
if (is_file($logPath . $file)) {
$logs[] = $file; // Add log files to the list
@ -1907,8 +1909,11 @@ class EmployeeController extends AdminController
}
}
$data['logs'] = $logs;
$data['server_details'] = get_server_details();
// Pass log files to the view
return view('log_view', ['logs' => $logs]);
return $this->loadLayout('log_view', $data);
}
public function downloadLog($fileName)
@ -1931,7 +1936,11 @@ class EmployeeController extends AdminController
if (file_exists($logPath)) {
$content = file_get_contents($logPath);
return view('log_content_view', ['fileName' => $fileName, 'content' => $content]);
$data['fileName'] = $fileName;
$data['content'] = $content;
$data['server_details'] = get_server_details();
return $this->loadLayout('log_content_view', $data);
}
return redirect()->back()->with('error', 'Log file not found.');

View File

@ -1690,7 +1690,7 @@ class EmployeeServiceController extends AdminController
{
$log_message = $file['action'].' - endorsement'. $value['emp_code'].' - '.$value['name'].' - with policy id'.$emp_policy_id;
$this->myLogger->logme('error',$log_message);
$actions = ($file['action'] == 'dependent_addition' ? 'da' : ($file['action'] == 'addition' ? 'a' : NULL));
$actions = ($file['action'] == 'dependent_addition' ? 'da' : ($file['action'] == 'addition' ? 'a' : 'a'));
$addition_endorse_data = ['pk' => $emp_policy_id,'group_key' => rand(100000, 999999),'emp_code' => $value['emp_code'],'table_name' => 'employee_polices','actions' => $actions,'name' => $value['name'],'field_name' => 'basic_cover_si','old_value' => NULL,'new_value' => $policy_data['basic_cover_si'],'remarks' => 'addition endorsement','file_id' => $file['id'],'created_by' => $file['created_by']];
$this->employeeEndorsementforAddtionAndDependentAddition($addition_endorse_data);
}
@ -2011,7 +2011,7 @@ public function employeesEnrollmentInsert($params)
$relation = 'parent';
} else if(strtolower(trim($value['relationship'])) === 'son' || strtolower(trim($value['relationship'])) === 'daughter'){
$relation = 'child';
}else if(strtolower(trim($value['relationship'])) === 'father in Law' || strtolower(trim($value['relationship'])) === 'mother in Law'){
}else if(strtolower(trim($value['relationship'])) === 'father in law' || strtolower(trim($value['relationship'])) === 'mother in law'){
$relation = 'parent_in_law';
}else if(strtolower(trim($value['relationship'])) === 'spouse'){
$relation = 'spouse';

View File

@ -390,7 +390,7 @@ class LeadsController extends BaseController
$result = $this->RFQModel->insert($data);
if ($result) {
return $this->respond(['status' => true, 'id' => $result, 'message' => 'New RFQ created successfully', 'data' =>$data], 200);
return $this->respond(['status' => true, 'id' => $result, 'message' => 'RFQ created successfully', 'data' =>$data], 200);
}
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create RFQ", 'data' =>$data], 200);
@ -413,7 +413,7 @@ class LeadsController extends BaseController
$result = $this->RFQModel->insert($data);
if ($result) {
return $this->respond(['status' => true, 'id' => $result, 'message' => 'New QCR created successfully', 'data' =>$data], 200);
return $this->respond(['status' => true, 'id' => $result, 'message' => 'QCR created successfully', 'data' =>$data], 200);
}
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create QCR", 'data' =>$data], 200);
@ -456,9 +456,11 @@ class LeadsController extends BaseController
//Construct excel file and save the file to the folder and return file path
public function constructExcelToSaveTemp($lead_id, $type, $propsal_and_insurer = null)
{
{
$rfq_data = $this->RFQModel->getRFQTableDataWithLeadIDAndType($lead_id, $type);
// dd($rfq_data, $lead_id, $type);
$lead_data = [
'Insured' => $rfq_data['client_name'],
'Insurer' => $rfq_data['insurer_name'] . ' - ' . $rfq_data['insurer_branch_name'],
@ -769,9 +771,9 @@ class LeadsController extends BaseController
$message = str_replace("{{CLIENT_NAME}}", $lead_data['client_name'], $message);
$message = str_replace("{{POLICY_LONG_NAME}}", $lead_data['long_name'], $message);
$message = str_replace("{{POLICY_START_DATE}}", change_date_format($lead_data['policy_start_date'], 'Y-m-d', 'd-m-Y'), $message);
$message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'], $lead_data['policy_start_date'])->days, $message);
$message = str_replace("{{DURATION}}", calculate_days_bw_dates($lead_data['policy_end_date'] ?? "", $lead_data['policy_start_date'] ?? "")->days, $message) ?? '--';
// print_rr($message);
// print_rr($message);calculate_days_bw_dates
$res = MailHelper::send_email(['mail' => $recipient['email'], 'cc'=> $cc_mails, 'subject' => $subject, 'message' => $message, 'attachments' => $attachments, 'reply_to' => $reply_to]);
// !dd($res);
@ -789,8 +791,12 @@ class LeadsController extends BaseController
'insurer' => $params['insurer_and_branch'],
] ;
$lead_update_data = json_encode($lead_update_data);
$this->leadsModel->where('id', $lead_id)->set('proposel_data', $lead_update_data)->update();
$data = [
'proposel_data' => json_encode($lead_update_data),
'status' => 'won'
];
$this->leadsModel->where('id', $lead_id)->set($data)->update();
}
//delete attachment file
@ -1035,7 +1041,9 @@ class LeadsController extends BaseController
$result = $this->createClientWithLeadData($data);
if ($result) {
return $this->respond(['status' => true, 'message' => 'New Client created successfully', 'client_id' => $result, 'data' => $data], 200);
$policy_data = $this->clientPolicyModel->where('client_id', $result)->where('is_active', 1)->first();
return $this->respond(['status' => true, 'message' => 'New Client created successfully', 'client_id' => $result, 'data' => $data, 'client_policy_id' => $policy_data['id']], 200);
}
return $this->respond(['status' => false, 'message' => 'Failed to create client', 'data' => $data], 200);
@ -1048,6 +1056,7 @@ class LeadsController extends BaseController
if ($client_id) {
$this->createClientBranchAndContactWithLeadData($data, $client_id);
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
}
return $client_id;
@ -1071,7 +1080,7 @@ class LeadsController extends BaseController
$branch_id = $this->clientBranchModel->insert($branch_data);
if ($branch_id) {
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
$contact_data = $this->prepareContactData($data, $branch_id);
$this->levelContactModel->insert($contact_data);
@ -1081,7 +1090,6 @@ class LeadsController extends BaseController
return $branch_id;
}
private function prepareClientBranchData($data, $client_id)
{
$default_unit = trim(($data['client_short_name'] ?? '') . '-' . ($data['branch_code'] ?? ''), '-');
@ -1109,24 +1117,37 @@ class LeadsController extends BaseController
public function createClientPolicyWithLeadData($data, $client_id, $branch_id)
{
$client_policy_data = $this->prepareClientPolicyData($data, $client_id, $branch_id);
return $this->clientPolicyModel->insert($client_policy_data);
$client_policy_id = $this->clientPolicyModel->insert($client_policy_data);
if($client_policy_id){
$this->leadsModel->where('id', $data['id'])->set('is_client_created', $client_id)->update();
}
return $client_policy_id;
}
private function prepareClientPolicyData($data, $client_id, $branch_id)
{
{
$proposel_data = json_decode($data['proposel_data'], true);
// print_r($proposel_data); die;
list($insurer_branch_id, $insurer_id) = explode('-', $proposel_data['insurer'], 2);
$client_policy_data = [
'client_id' => $client_id,
'client_branch_id' => $branch_id,
'policy_type_id' => $data['policy_type_id'],
'insurer_id' => $data['insurer_id'],
'insurer_branch_id' => $data['insurer_branch_id'],
'insurer_id' => $insurer_id,
'insurer_branch_id' => $insurer_branch_id,
'tpa_id' => $data['tpa_id'],
'tpa_branch_id' => $data['tpa_branch_id'],
'policy_start_date' => $data['policy_start_date'],
'policy_end_date' => $data['policy_end_date'],
'policy_status' => 1,
];
$terms = $this->preparePolicyTermsFromRFQ($data);
$policy_type_id = $data['policy_type_id'];
if (in_array($policy_type_id, [1, 2, 6, 7])) {
$client_policy_data['is_addon'] = 1; // Base Policy
@ -1139,15 +1160,146 @@ class LeadsController extends BaseController
$data['is_addon'] = 1;
// }
}
$client_policy_data['policy_terms'] = $this->preparePolicyTermsFromRFQ($data);
// print_r($client_policy_data); die;
return $client_policy_data;
}
private function preparePolicyTermsFromRFQ($data)
{
{
$proposel_data = json_decode($data['proposel_data'], true);
$QCRData = $this->RFQModel->where('is_active', 1)->where('type', 2)->where('lead_id', $data['id'])->first();
$JSON = json_decode($QCRData['json'], true);
$converted_json = $this->transformProposelData($JSON, $proposel_data['proposel_name'], $proposel_data['insurer_name']);
return $this->convertQCRJsonToPolicyTerms($converted_json, $data['policy_type_id'], $proposel_data['proposel_name'], $proposel_data['insurer_name']);
}
private function convertQCRJsonToPolicyTerms($data, $policy_type, $proposel_name, $insurer_name)
{
$GMC_Keys = [
"sum_insured", "family_floater", "family_floaters", "age_ratio", "waiverofpreexistingdiseases",
"maternitycoverage", "twindelivery", "preandpostnatal", "babyday1cover", "9monthwaitingperiodwaived",
"coverfromthedateofjoining", "waiverof1,2,3&4thyearexclusions", "waiverof30dayswaitingperiod",
"prehospitalizationcover", "congenitaldiseasesinternal", "copayzonewisecopay",
"bioabsorbablestenttoriclensmultifocallens", "roomrentlimit", "proportionatedeductionclause",
"ailmentcapping", "ambulancecharges", "airambulance", "familytransportationbenefit",
"reasonableandcustomarycharges", "ayudhtreatmentcover", "congenitaldiseasesexternal",
"optionalparentalcopay", "posthospitalizationcover", "corporatebuffer", "sublimitofcorporatebuffer",
"ayushTreatmentCoverData", "armdcovered", "suminsuredenhancement", "automaticsuminsuredreinstatement",
"additionalsicknessbenefit", "lasiksurgery", "midterminclusion", "capd", "organdonorexpenses",
"moderntreatmentsasperirdai", "Wellness", "days_of_discharge", "days_from_dod",
"special_condition_label", "special_condition_input", "multiple_sum_insured",
"cataract", "cataractData"
];
$GPA_Keys = [
"sumInsured2", "totalSumInsured", "age_ratio", "accidentalDeathBenefit", "permanentTotalDisablement",
"permanentPartialDisablement", "temporaryTotalDisablementBenefit", "accidentalHospitalizationExpenses",
"childrenEducationWelfareFund", "compassionateVisitExpenses", "compassionateVisitExpensesData",
"brokenBoneExpenses", "brokenBoneExpensesData", "ambulanceCharges", "ambulanceChargesData",
"burnExpenses", "burnExpensesData", "carriageOfDeadBody", "carriageOfDeadBodyData",
"animalSnakeInsectBite", "terrorism", "worldwideCover", "gpa_special_condition_label",
"gpa_special_condition_input", "multiple_sum_insured"
];
// Select keys based on policy type
$termsKey = $policy_type == 1 ? $GPA_Keys : $GMC_Keys;
// Initialize terms_array with default empty values
$terms_array = array_fill_keys($termsKey, "");
$specialKeys = ['special_condition_label', 'special_condition_input', 'gpa_special_condition_label', 'gpa_special_condition_input', 'multiple_sum_insured'];
foreach ($specialKeys as $key) {
$terms_array[$key] = [];
}
// Initialize age_ratio based on policy type
$terms_array['age_ratio'] = $policy_type == 2 ? [
"self" => ["min" => "18", "max" => "60"],
"spouse" => ["min" => 0, "max" => 0],
"child" => ["min" => 0, "max" => "25"],
"elders" => ["min" => 0, "max" => 0],
] : ["self" => ["min" => "18", "max" => "60"]];
foreach ($data['table_data']['data'] as $dataRow) {
}
$item = $dataRow['items'] ?? '';
foreach ($dataRow['data'] as $cellData) {
$parentth = $cellData['parentth'] ?? '';
$subth = $cellData['subth'] ?? '';
$input_value = $cellData['input_value'] ?? '';
$value = $cellData['value'] ?? '';
// Skip unwanted keys
if (in_array($parentth, ['Sno', 'Item Key', 'Particulars', 'Action']) ||
in_array($subth, ['Quote Asked'])) {
continue;
}
// Handle special conditions
if (str_starts_with($item, "special_condition") && $parentth === $proposel_name && $subth === $insurer_name) {
$parts = explode("-", $input_value);
$question = $parts[0] ?? '';
$answer = $parts[1] ?? '';
$labelKey = $policy_type == 1 ? 'gpa_special_condition_label' : 'special_condition_label';
$inputKey = $policy_type == 1 ? 'gpa_special_condition_input' : 'special_condition_input';
$terms_array[$labelKey][] = $question;
$terms_array[$inputKey][] = $answer;
continue;
}
// Handle sum insured
if (in_array($item, ['sum_insured', 'sumInsured2'])) {
$si_amt = explode(",", $value);
$terms_array[$item] = $si_amt[0] ?? "";
$terms_array['multiple_sum_insured'] = array_slice($si_amt, 1);
continue;
}
// Handle family floaters
if ($item === 'family_composition') {
$terms_array['family_floaters'] = isJsonString($input_value) ? json_decode($input_value, true) : $input_value;
continue;
}
// Decode JSON if valid
$terms_array[$item] = isJsonString($input_value) ?
(json_decode($input_value, true)['key'] ?? '') :
$input_value;
}
}
return json_encode($terms_array);
}
public function featchClientPolicyFromLead($client_id, $branch_id, $lead_id)
{
$data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first();
if (!$data) {
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => null], 200);
}
$result = $this->createClientPolicyWithLeadData($data, $client_id, $branch_id);
// print_r($result); die;
if ($result) {
$policy_data = $this->clientPolicyModel->where('id', $result)->where('is_active', 1)->first();
return $this->respond(['status' => true, 'message' => 'New Policy created successfully', 'client_policy_id' => $result, 'data' => $data, 'client_id' => $policy_data['client_id']], 200);
}
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => $data], 200);
}
}

View File

@ -474,4 +474,30 @@ if (!function_exists('print_rr')) {
print_r($data);
echo "</pre>";
}
}
}
if (!function_exists('get_server_details')) {
/**
* Get the hostname and server name.
*
* @return array
*/
function get_server_details(): array
{
$hostname = gethostname(); // Get the hostname of the server
$serverName = $_SERVER['SERVER_NAME'] ?? 'Unknown'; // Get the server name
return [
'hostname' => $hostname,
'server_name' => $serverName,
];
}
}
if (!function_exists('isJsonString')) {
function isJsonString($input)
{
json_decode($input); // Decode the string
return (json_last_error() === JSON_ERROR_NONE); // Check if the last JSON error is "no error"
}
}

View File

@ -51,6 +51,7 @@ class LeadsModel extends Model
'updated_at',
'updated_by',
'is_active',
'is_client_created',
];
@ -120,12 +121,28 @@ class LeadsModel extends Model
}
public function getLeadForInsertClientList()
public function getLeadForInsertClientList($type = null, $client_id = null)
{
return $this
$query = $this->db->table('leads')
->select('leads.*, user_profiles.first_name as user_name')
->join('user_profiles', 'leads.created_by = user_profiles.id')
->where('leads.is_active', 1)
->where('leads.status', 'won')
->findAll();
->where("leads.proposel_data IS NOT NULL AND leads.proposel_data <> ''")
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)");
if ($type) {
$query->where('leads.lead_type', $type);
}
if ($client_id) {
$query->where('leads.client_id', $client_id);
}
$result = $query->get()->getResultArray();
return $result;
}

View File

@ -71,10 +71,10 @@ class RFQModel extends Model
')
->join('leads', 'rfq.lead_id = leads.id')
->join('policy_type', 'leads.policy_type_id = policy_type.id')
->join('insurers', 'leads.insurer_id = insurers.id')
->join('insurer_branch', 'leads.insurer_branch_id = insurer_branch.id')
->join('tpa', 'leads.tpa_id = tpa.id')
->join('tpa_branch', 'leads.tpa_branch_id = tpa_branch.id')
->join('insurers', 'leads.insurer_id = insurers.id', 'left')
->join('insurer_branch', 'leads.insurer_branch_id = insurer_branch.id', 'left')
->join('tpa', 'leads.tpa_id = tpa.id', 'left')
->join('tpa_branch', 'leads.tpa_branch_id = tpa_branch.id', 'left')
->where('rfq.lead_id', $lead_id)
->where('rfq.type', $type)
->where('rfq.is_active', 1)

View File

@ -100,14 +100,14 @@ table.dataTable thead th {
<option value="">Select Lead</option>
<?php if(isset($lead_data)) { ?>
<?php foreach ($lead_data as $value) { ?>
<option value="<?= $value['id']?>"><?= $value['client_name'] ?></option>
<option value="<?= $value['id']?>"><?= $value['client_name'] ?> - <?= $value['branch_name'] ?> - <?= $value['user_name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
<button type="submit" class="btn btn-primary" onclick="featchClient()">Featch Client</button>
<button type="submit" class="btn btn-primary" onclick="featchClient()">Fetch Client</button>
</div>
</div>
</div><!-- /.modal-content -->
@ -275,7 +275,7 @@ function featchClient(){
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == true){
let client_url = '<?= base_url('client/list/') ?>'+res.client_id;
let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' + res.client_policy_id+'#police-tab';
toastr.success(res.message, 'SUCCESS')
window.location.href = client_url
}else{
@ -294,4 +294,5 @@ function featchClient(){
}
});
}
</script>

View File

@ -2,7 +2,8 @@
<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"><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" style="position: relative;right: 10px;"><span class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy</button>
<button type="button" id="BtnAddSuccess" class="btn btn-success waves-effect waves-light BtnAddSuccess btn-sm" onclick="showModal()"><span class="fa fa-plus-square" aria-hidden="true" style="padding: 5px 10px;"></span>Add Policy From Lead</button>
</div>
<div class="table-responsive" id="table_list">
@ -193,6 +194,36 @@
<?php include('policy_gpa_terms.php'); ?>
<?php include('other_policy_terms.php'); ?>
<!-- Center modal content -->
<div class="modal fade" id="lead_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">Lead List</h4>
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="form-group col-md-12">
<label for="lead_id"> Lead List <span class="text-danger">*</span></label>
<select class="form-control" id="lead_id" name="lead_id" required>
<option value="">Select Lead</option>
<?php if(isset($lead_data)) { ?>
<?php foreach ($lead_data as $value) { ?>
<option value="<?= $value['id']?>" data-clientid="<?= $value['client_id']?>", data-branchid="<?= $value['client_branch_id']?>"><?= $value['client_name'] ?> - <?= $value['branch_name'] ?> - <?= $value['user_name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
<button type="submit" class="btn btn-primary" onclick="featchClient()">Fetch Client</button>
</div>
</div>
</div><!-- /.modal-content -->
</div>
</div><!-- /.modal -->
<script>
$('#inception_type').change(function () {
@ -394,6 +425,7 @@
$('#table_list').hide();
$('.btnBack').show();
$('.btnAdd').hide();
$('.BtnAddSuccess').hide();
$('#insurer').val('').change();
$('#tpa').val('').change();
$('#policy_no').val('').change();
@ -426,6 +458,7 @@
$('#table_list').show();
$('.btnBack').hide();
$('.btnAdd').show();
$('.BtnAddSuccess').show();
$('#insurer').val('').change();
$('#tpa').val('').change();
$('#policy_no').val('').change();
@ -515,6 +548,7 @@
$('#table_list').show();
$('.btnBack').hide();
$('.btnAdd').show();
$('.BtnAddSuccess').show();
var message = (policy_PrimaryKey === '') ?
'Policy Created successfully' : 'Policy Updated Successfully';
toastr.success(message, 'Success');
@ -695,7 +729,6 @@
// get the client policy data for edit
$('body').on('click', '.btnPolicyEdit', function() {
var policy_form_action = '';
var policy_id = $(this).attr('data-id');
@ -730,6 +763,7 @@
$('#table_list').hide();
$('.btnBack').show();
$('.btnAdd').hide();
$('.BtnAddSuccess').hide();
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id).change();
var tpaValue = '';
@ -1724,5 +1758,258 @@
});
})
$(document).ready(function () {
// Check if the URL contains a hash
const hash = window.location.hash;
// If hash is '#police-tab', trigger a click on the tab
if (hash === '#police-tab') {
$(`a[href="${hash}"]`).click();
// Get the `client_policy_id` from the URL
const urlParams = new URLSearchParams(window.location.search);
const clientPolicyId = urlParams.get('client_policy_id');
if (clientPolicyId) {
// Call your function with the `client_policy_id`
setTimeout(function() {
getClientPolicyDataForEdit(clientPolicyId);
}, 3000);
}
}
});
function getClientPolicyDataForEdit(client_policy_id){
var policy_form_action = '';
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
fetchClientBranch()
$.ajax({
url: '<?= base_url("client/policy/list/") ?>' + client_policy_id,
type: "GET",
dataType: 'json',
success: function(res) {
console.log('client_policy_res', res);
var gst = (res.data.gst == 0.00) ? 18 : res.data.gst;
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1100);
$('#policy_form_action').val('<?= base_url("client/policy/edit"); ?>');
if (res.status === false) {
toastr.error(res.message);
return;
}
$('#add_form').show();
$('#table_list').hide();
$('.btnBack').show();
$('.btnAdd').hide();
$('.BtnAddSuccess').hide();
$('#insurer').val(res.data.insurer_branch_id + '-' + res.data.insurer_id).change();
var tpaValue = '';
if (res.data.tpa_branch_id && res.data.tpa_id) {
tpaValue = res.data.tpa_branch_id + '-' + res.data.tpa_id;
}
$('#tpa').val(tpaValue).change();
$('#policy_type').val(res.data.policy_type_id).change();
$('#base_policy').val(res.data.base_policy);
$('#policy_type_id').val(res.data.policy_type_id);
$('#policy_PrimaryKey').val(res.data.id);
$('#insurer_policy_id').val(res.data.policy_id);
$('#policy_no').val(res.data.policy_no);
$('#start_date').val(rearrangeDateFormat(res.data.policy_start_date));
$('#open_date').val(rearrangeDateFormat(res.data.open_date));
$('#end_date').val(rearrangeDateFormat(res.data.policy_end_date));
$('#close_date').val(rearrangeDateFormat(res.data.close_date));
$('#reminder_date').val(rearrangeDateFormat(res.data.reminder_date));
$('#disclaimer').val(res.data.disclaimer);
$('#gst_no').val(gst);
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
$('#policy_status_field').show();
if (res.data.inception_type == 2) {
$('#inception_type').prop('checked', true);
$('#open_date').parent().show();
$('#close_date').parent().show();
$('#reminder_date').parent().show();
$('.dateofdata').attr('required', true);
} else {
$('#inception_type').prop('checked', false);
$('#open_date').parent().hide();
$('#close_date').parent().hide();
$('#reminder_date').parent().hide();
$('.dateofdata').attr('required', false);
}
if (res.data.enrolment_visibility == 1) {
$('#policy_visibility').prop('checked', true);
} else {
$('#policy_visibility').prop('checked', false);
}
if (res.data.policy_type_id == '4' || res.data.policy_type_id == '5') {
$('#base_policy_id').show();
$('#base_policy').prop('required', true);
$('#first').show();
$('#second').show();
$('#third').show();
} else if (res.data.policy_type_id == '0') {
$('#first').hide();
$('#second').hide();
$('#third').hide();
$('#base_policy_id').hide();
$('#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') {
$('#first').show();
$('#second').show();
$('#third').show();
$('#base_policy_id').hide();
$('#base_policy').prop('required', false);
}else if(res.data.policy_type_id == '3'){
$('#first').show();
$('#second').show();
$('#third').show();
$('#base_policy_id').show();
$('#base_policy').prop('required', false);
$('#base_danger').hide();
}
if (res.data.is_addon == 2 || res.data.is_addon == 3) {
$("#insurer").next(".select2-container").css({
'pointer-events': 'none',
});
$('#select2-insurer-container').css({
'background-color': '#ebebe0',
});
$("#tpa").next(".select2-container").css({
'pointer-events': 'none',
});
$('#select2-tpa-container').css({
'background-color': '#ebebe0',
});
} else {
$("#insurer").next(".select2-container").css({
'pointer-events': 'auto',
});
$('#select2-insurer-container').css({
'background-color': 'transparent',
});
$("#tpa").next(".select2-container").css({
'pointer-events': 'auto',
});
$('#select2-tpa-container').css({
'background-color': 'transparent',
});
}
if (res.data.policy_type_id == '1' || res.data.policy_type_id == '6' || res.data.policy_type_id == '7') {
$('#tpa').prop('required', false);
$('#tpa_danger').hide()
} else {
$('#tpa').prop('required', true);
$('#tpa_danger').show()
}
setTimeout(() => {
$('#client_branch').val(res.data.client_branch_id).select2();
}, 1000);
setTimeout(function(){
appendCDACNO(res.cd_data, res.data.cd_ac_no) // append and select the current CD Account Number
appendBasePolicyList(res.client_policy_list, res.data.base_policy, res.data.client_branch_id); // append and select the Base palicy
}, 2000)
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
//console.log('Something Wrong!', 'warning');
}, 1000);
}
});
}
function showModal(){
var myModal = new bootstrap.Modal(document.getElementById('lead_modal'));
myModal.show();
}
function featchClient(){
let lead_id = $('#lead_id').val();
let client_id = $('#lead_id option:selected').data('clientid');
let branch_id = $('#lead_id option:selected').data('branchid');
console.log('lead_id : ', lead_id)
let url = '<?= base_url('leads/featchClientPolicyFromLead/') ?>' + client_id + '/' + branch_id + '/' + lead_id
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: url,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == true){
let client_url = '<?= base_url('client/list/') ?>' + res.client_id + '?client_policy_id=' + res.client_policy_id+'#police-tab';
toastr.success(res.message, 'SUCCESS')
window.location.href = client_url;
}else{
toastr.success(res.message, 'WARNING');
}
$('.close').click()
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('.close').click()
}
});
}
</script>

View File

@ -74,7 +74,7 @@ table.dataTable tbody td {
</thead>
<tbody>
<?php if(isset($lead_data_list) && count($lead_data_list) > 0) { ?>
<?php if(isset($lead_data_list)) { ?>
<?php foreach($lead_data_list as $index => $row){ ?>
<tr>
<td><?php echo $index + 1; ?></td>

View File

@ -6,11 +6,26 @@
<title>View Log: <?= esc($fileName) ?></title>
</head>
<body>
<h1>Log File: <?= esc($fileName) ?></h1>
<div class="row">
<div class="form-group col-10">
<h3> <?= $server_details['hostname'] . '/' . $server_details['server_name'] . ' - ' ?> Log File: <?= esc($fileName) ?></h3>
</div>
<div class="form-group col-2">
<a href="<?= base_url('util/log_list') ?>" class="btn btn-primary float-md-right">Back to Logs</a>
</div>
</div>
<pre style="background-color: #f5f5f5; padding: 15px; border: 1px solid #ccc;">
<?= esc($content) ?>
</pre>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<pre style="background-color: #f5f5f5; padding: 15px; border: 1px solid #ccc;">
<?= esc($content) ?>
</pre>
</div>
</div>
</div>
</div>
<a href="<?= base_url('util/log_list') ?>">Back to Logs</a>
</body>

View File

@ -1,41 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Log Files</title>
</head>
<body>
<h1>Log Files</h1>
<?php if (session()->getFlashdata('error')): ?>
<p style="color: red;"><?= session()->getFlashdata('error') ?></p>
<?php endif; ?>
<title>Log Files</title>
<style>
<table border="1" cellpadding="10">
<thead>
<tr>
<th>Log File</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if (!empty($logs)): ?>
<?php foreach ($logs as $log): ?>
<tr>
<td><?= esc($log) ?></td>
<td>
<a href="<?= base_url('util/view_log/' . urlencode($log)) ?>">View</a> |
<a href="<?= base_url('util/download_log/' . urlencode($log)) ?>">Download</a>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
</style>
<h3> <?= $server_details['hostname'] . '/' . $server_details['server_name'] . ' - ' ?> Log Files</h3>
<?php if (session()->getFlashdata('error')): ?>
<p style="color: red;"><?= session()->getFlashdata('error') ?></p>
<?php endif; ?>
<table class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
<th>S.No.</th>
<th>Log File</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php if (!empty($logs)): ?>
<?php foreach ($logs as $index => $log): ?>
<tr>
<td colspan="2">No log files found.</td>
<td><?= $index + 1 . '.' ?></td>
<td><?= esc($log) ?></td>
<td>
<a href="<?= base_url('util/view_log/' . urlencode($log)) ?>">View</a> |
<a href="<?= base_url('util/download_log/' . urlencode($log)) ?>">Download</a>
</td>
</tr>
<?php endif; ?>
</tbody>
</table>
</body>
</html>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="2">No log files found.</td>
</tr>
<?php endif; ?>
</tbody>
</table>

View File

@ -1293,7 +1293,7 @@
var index = $('.modifyclassinput').length;
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
<label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;">
<input class="form-control" name="special_condition_label[]" id="special_condition_label[]" style="position: relative;right: 15px;">
<input class="form-control" name="special_condition_label[]" id="special_condition_label[]" style="position: relative;right: 5px;">
<span class="specialConditionClose" style="color: red; float: right;position: relative;bottom: 28px;left: 15px;">X</span>
</label>
<input type="text" name="special_condition_input[]" id="special_condition_input[]" class="form-control s special_condition_input[]">

View File

@ -705,7 +705,7 @@
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
<label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;">
<input class="form-control" name="gpa_special_condition_label[]" id="gpa_special_condition_label[]" style="position: relative;right: 15px;">
<input class="form-control" name="gpa_special_condition_label[]" id="gpa_special_condition_label[]" style="position: relative;right: 5px;">
<span class="specialConditionClose" style="color: red; float: right;position: relative;bottom: 28px;left: 15px;">X</span>
</label>

View File

@ -496,6 +496,7 @@
var insurer_count = 0
var proposalDataForDropDown = {};
var policy_terms = {};
var premium_data_check = false;
$(document).ready(function() {
@ -545,8 +546,13 @@
if(data){
proposalDataForDropDown = data.proposal_data;
if(!data.premium_data){
premium_data_check = true;
}
}
console.log('policy_terms', policy_terms);
console.log('JSON DATA', data);
console.log('suggestions data', suggestions);
@ -3220,6 +3226,8 @@ function constructInsurerNameWithVersion(proposal_name, insurerName) {
function checkTheTableDataChanged(redirect_type, url){
console.log('isFormDataModified', isFormDataModified);
if(isFormDataModified){
SweertAlert()
}else{
@ -3709,7 +3717,9 @@ function jsonToTable(json) {
hideQCR()
isFormDataModified = false;
populateTable(json)
if(RFQ_or_QCR == 2){
populateTable(json)
}
}
function populateTable(json) {
@ -3803,6 +3813,10 @@ function populateTable(json) {
// Append tbody to table
table.appendChild(tbody);
if(premium_data_check){
isFormDataModified = true;
}
}
// function generateJSONFromTable() {
@ -4281,6 +4295,7 @@ function removeProposalForPremiumTable(secondRowIndex) {
async function submitQCRData() {
console.log(over_all_column_data);
let qcr_count = $('#qcr_count').val();
@ -4294,6 +4309,7 @@ function removeProposalForPremiumTable(secondRowIndex) {
console.log('QCR not found');
try {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();