Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
9d5dbbcfb7
@ -386,6 +386,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->get('getClaimDumpFileErrorData', 'TicketController::getClaimDumpFileErrorData');
|
||||
$routes->get("claim_dump_excel_error/(:any)", "TicketController::getClaimDumpExcelFileErrors/$1");
|
||||
$routes->get("download_claim_dump_file/(:any)", "TicketController::downloadClaimDumpFile/$1");
|
||||
$routes->post('uploadMultiFileFromRfq', 'LeadsController::uploadMultiFileFromRfq');
|
||||
$routes->get('downloadMemberFile/(:any)', 'LeadsController::downloadMemberFile/$1');
|
||||
});
|
||||
|
||||
$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail");
|
||||
@ -695,6 +697,9 @@ $routes->group('test', function($routes) {
|
||||
$routes->get('viewPDF', 'TestingController::viewPDF');
|
||||
$routes->get('generate-pdf-view', 'TestingController::generatePDFWithView');
|
||||
$routes->get('param/(:any)', 'TestingController::ptedfitdata/$1');
|
||||
$routes->get('viewrfq', 'TestingController::viewRFQNonEb');
|
||||
$routes->get('exportexcel', 'TestingController::exportExcel');
|
||||
$routes->post('saverfq', 'TestingController::saverfq');
|
||||
});
|
||||
$routes->cli('cli/testcli', 'TestingController::testcli');
|
||||
|
||||
|
||||
@ -4564,11 +4564,11 @@ class ClientController extends AdminController
|
||||
// Additional logic for non-individual clients (client_type != 2)
|
||||
$branch_insert = null;
|
||||
if ($client_type != 2) {
|
||||
$unit[] = $postData['short_name'] . '-' . 001;
|
||||
$unit[] = $postData['short_name'] . '-' . $postData['branch_code'] ?? 001;
|
||||
$branch_data = [
|
||||
'client_id' => $client_insert,
|
||||
'branch_name' => $postData['branch_name'],
|
||||
'branch_code' => 001,
|
||||
'branch_code' => $postData['branch_code'] ?? 001,
|
||||
'gst' => $postData['gst'],
|
||||
'units' => json_encode($unit) ?? null,
|
||||
];
|
||||
@ -4580,6 +4580,7 @@ class ClientController extends AdminController
|
||||
'contact_type' => 'client',
|
||||
'name' => $postData['name'],
|
||||
'email' => $postData['email'],
|
||||
'mobile' => $postData['mobile'] ?? null,
|
||||
];
|
||||
$this->levelContactModel->insert($contact_data);
|
||||
}
|
||||
|
||||
@ -529,7 +529,7 @@ class LeadsController extends BaseController
|
||||
return $this->respond(['status' => false, 'lead_id' => $id, 'message' => "Failed to update Lead", 'data' => $data], 200);
|
||||
}
|
||||
|
||||
// Get the Single Lead data for edit uisng ajax ( do not delete)
|
||||
// Get the Single Lead data for edit uisng ajax (do not delete)
|
||||
public function getLeadDataForEdit($id)
|
||||
{
|
||||
|
||||
@ -604,7 +604,7 @@ class LeadsController extends BaseController
|
||||
}
|
||||
|
||||
public function uploadMultiFiles($files, $docs_names, $primaryKey)
|
||||
{
|
||||
{
|
||||
$uploadFilePath = WRITEPATH . 'uploads/lead_files/';
|
||||
|
||||
$multi_file_data = [];
|
||||
@ -697,64 +697,288 @@ class LeadsController extends BaseController
|
||||
|
||||
//--------RFQ-----------------------------------------------------------------------------------------------
|
||||
|
||||
// public function viewRFQ($id, $type = 1)
|
||||
// {
|
||||
|
||||
// $data['rfq_data'] = $this->RFQModel
|
||||
// ->where('lead_id', $id)
|
||||
// // ->where('type', $type)
|
||||
// ->where('is_active', 1)
|
||||
// ->orderBy('id', 'desc')
|
||||
// ->first();
|
||||
// // dd($data);
|
||||
|
||||
// $data['rfq_count'] = $this->RFQModel
|
||||
// ->where('lead_id', $id)
|
||||
// // ->where('type', 1)
|
||||
// ->where('is_active', 1)
|
||||
// ->countAllResults();
|
||||
|
||||
// $data['qcr_count'] = $this->RFQModel
|
||||
// ->where('lead_id', $id)
|
||||
// ->where('type', 2)
|
||||
// ->where('is_active', 1)
|
||||
// ->countAllResults();
|
||||
|
||||
// // dd(count($data['rfq_data']));
|
||||
|
||||
// $data['lead_id'] = $id;
|
||||
// $lead_data = $this->leadsModel
|
||||
// ->select('
|
||||
// leads.*,
|
||||
// policy_type.question_json,
|
||||
// policy_type.policy_type,
|
||||
// policy_type.long_name,
|
||||
// user_profiles.email as created_person_email
|
||||
// ')
|
||||
// ->join('policy_type', 'leads.policy_type_id = policy_type.id')
|
||||
// ->join('user_profiles', 'leads.created_by = user_profiles.id', 'left')
|
||||
// ->where('leads.id', $id)
|
||||
// ->where('leads.is_active', 1)
|
||||
// ->first();
|
||||
|
||||
// // dd($lead_data);
|
||||
|
||||
// if ($lead_data['lead_type'] != 1) {
|
||||
// $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
|
||||
// if (isset($client_policy_data)) {
|
||||
// $data['policy_terms'] = $client_policy_data['policy_terms'];
|
||||
// }
|
||||
// }
|
||||
|
||||
// $data['question_json'] = $lead_data['question_json'];
|
||||
// $data['page_name'] = $type == 2 ? 'QCR' : 'RFQ';
|
||||
// $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
|
||||
// $data['userList'] = $this->userModel->getUserListForRFQ();
|
||||
// $data['exclusiveUserList'] = $this->userModel->getexclusiveUserListForRFQ();
|
||||
// $data['lead_data'] = $lead_data;
|
||||
// $data['tpa_list'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
|
||||
// $data['account_manager'] = $this->userModel->where('is_active', 1)->where('role', 3)->findAll();
|
||||
|
||||
|
||||
// $mail_content = '
|
||||
// <p>Dear Sir,</p>
|
||||
// <p>Greetings From Nhance India!</p>
|
||||
// <p>Please find attached the {{RFQ_OR_QCR}} for <strong>{{POLICY_TYPE}}</strong> policy pertaining to <strong>{{CLIENT_NAME}}</strong>.</p>
|
||||
// <p>Kindly request you to share the competitive quotes at the earliest.</p>
|
||||
// <p>In case of any query, please feel free to contact us.</p>
|
||||
// <p>Thank You!</p><br>
|
||||
// <p>Best regards,</p>
|
||||
|
||||
// <div style=\"margin: 0; padding: 0; line-height: 1.2;\">
|
||||
// <div>{{LOGGED_USER_NAME}}</div>
|
||||
// <div>Mobile: {{LOGGED_USER_MOBILE}}</div>
|
||||
// </div>
|
||||
|
||||
// <img src="{{LOGO_PATH}}" alt="Nhance Logo" width="100" style="margin-top:10px;">
|
||||
// ';
|
||||
|
||||
// if ($data['lead_data']['policy_end_date'] != null) {
|
||||
// $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}} {{POLICY_END_DATE}}";
|
||||
// } else {
|
||||
// $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}";
|
||||
// }
|
||||
|
||||
// if ($lead_data['policy_type_id'] == 1) {
|
||||
// $data['totalSumAssured'] = $this->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => $id]);
|
||||
// } else {
|
||||
// $data['totalSumAssured'] = [];
|
||||
// }
|
||||
|
||||
// $data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
|
||||
// $data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']);
|
||||
|
||||
// $data['placement_mail_content'] = $this->transformMailContent($lead_data, $mail_content, 'Placement');
|
||||
// $data['placement_subject'] = $this->transformMailContent($lead_data, $subject, 'Placement');
|
||||
|
||||
// $data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
|
||||
// $installment_data['installments'] = $this->leadInstallmentPaymentDetails->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
|
||||
// $data['lead_data']['installment_data'] = view('rfq/installment_fields', $installment_data) ?? null;
|
||||
// $data['attachment_html'] = view('rfq/attachment_files', $data) ?? "";
|
||||
// $data['user_team'] = $this->userModel->select("ut.team_id")->join("user_teams ut", "ut.user_id = user_profiles.id and ut.is_active = 1")->where("user_profiles.is_active", 1)->first()['team_id'];
|
||||
// $data['multi_file_data_html'] = $this->renderFileFields($data['multi_file_data']);
|
||||
// // dd($data);
|
||||
|
||||
// if ($data['lead_data']['lead_form_type'] == 1) {
|
||||
// $data['demogrphy_html_data'] = $this->generateDemographyDataTable(['lead_id' => $id]);
|
||||
// $this->loadLayout('view_rfq.php', $data);
|
||||
// } else if ($data['lead_data']['lead_form_type'] == 2) {
|
||||
|
||||
// $data['occupancy'] = $this->occupancyModel->findAll();
|
||||
// // dd($data['occupancy']);
|
||||
|
||||
// if ($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0) {
|
||||
// $client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
|
||||
// if (isset($client_policy_data)) {
|
||||
|
||||
// $data['rfq_data']['json'] = $client_policy_data['placement_json'];
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (!empty($data['question_json'])) {
|
||||
// $data['policies'] = json_decode($data['question_json'], true)['policies'];
|
||||
// $data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
|
||||
// }
|
||||
|
||||
// $data['product'] = $this->leadsModel->select("policy_type.policy_type")->join('policy_type', 'leads.policy_type_id = policy_type.id')->where('leads.id', $id)->first()['policy_type'];
|
||||
// // $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']);
|
||||
// // dd($data['lead_register_data']);
|
||||
// // $data['entity_type'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
|
||||
// $data['buisness_type'] = $this->buisnessType;
|
||||
|
||||
// // dd($data);
|
||||
// $data['client_type'] = $this->clientType;
|
||||
// $this->loadLayout('view_rfq_non_eb', $data);
|
||||
// }
|
||||
// }
|
||||
|
||||
public function viewRFQ($id, $type = 1)
|
||||
{
|
||||
// 1. Combine RFQ queries into a single query
|
||||
$rfqStats = $this->RFQModel
|
||||
->select('
|
||||
COUNT(*) as total_count,
|
||||
SUM(CASE WHEN type != 2 THEN 1 ELSE 0 END) as rfq_count,
|
||||
SUM(CASE WHEN type = 2 THEN 1 ELSE 0 END) as qcr_count
|
||||
')
|
||||
->where('lead_id', $id)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
$data['rfq_count'] = $rfqStats['rfq_count'] ?? 0;
|
||||
$data['qcr_count'] = $rfqStats['qcr_count'] ?? 0;
|
||||
|
||||
// 2. Get RFQ data separately (only if needed)
|
||||
$data['rfq_data'] = $this->RFQModel
|
||||
->where('lead_id', $id)
|
||||
// ->where('type', $type)
|
||||
->where('is_active', 1)
|
||||
->orderBy('id', 'desc')
|
||||
->first();
|
||||
// dd($data);
|
||||
|
||||
$data['rfq_count'] = $this->RFQModel
|
||||
->where('lead_id', $id)
|
||||
// ->where('type', 1)
|
||||
->where('is_active', 1)
|
||||
->countAllResults();
|
||||
|
||||
$data['qcr_count'] = $this->RFQModel
|
||||
->where('lead_id', $id)
|
||||
->where('type', 2)
|
||||
->where('is_active', 1)
|
||||
->countAllResults();
|
||||
|
||||
// dd(count($data['rfq_data']));
|
||||
|
||||
$data['lead_id'] = $id;
|
||||
|
||||
// 3. Optimize lead data query with specific field selection
|
||||
$lead_data = $this->leadsModel
|
||||
->select('
|
||||
leads.*,
|
||||
policy_type.question_json,
|
||||
policy_type.policy_type,
|
||||
policy_type.long_name,
|
||||
user_profiles.email as created_person_email
|
||||
')
|
||||
leads.id, leads.policy_type_id, leads.lead_type, leads.source_policy_id,
|
||||
leads.policy_end_date, leads.lead_form_type, leads.created_by, leads.client_name,
|
||||
policy_type.question_json, policy_type.policy_type, policy_type.long_name,
|
||||
user_profiles.email as created_person_email
|
||||
')
|
||||
->join('policy_type', 'leads.policy_type_id = policy_type.id')
|
||||
->join('user_profiles', 'leads.created_by = user_profiles.id', 'left')
|
||||
->where('leads.id', $id)
|
||||
->where('leads.is_active', 1)
|
||||
->first();
|
||||
|
||||
// dd($lead_data);
|
||||
if (!$lead_data) {
|
||||
// Handle case where lead doesn't exist
|
||||
throw new \Exception('Lead not found');
|
||||
}
|
||||
|
||||
// 4. Conditional query - only fetch if needed
|
||||
if ($lead_data['lead_type'] != 1) {
|
||||
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
|
||||
if (isset($client_policy_data)) {
|
||||
$client_policy_data = $this->clientPolicyModel
|
||||
->select('policy_terms, placement_json')
|
||||
->where('is_active', 1)
|
||||
->where('id', $lead_data['source_policy_id'])
|
||||
->first();
|
||||
|
||||
if ($client_policy_data) {
|
||||
$data['policy_terms'] = $client_policy_data['policy_terms'];
|
||||
|
||||
// Store for later use in lead_form_type == 2 condition
|
||||
if ($lead_data['lead_form_type'] == 2 && $data['rfq_count'] == 0) {
|
||||
$data['rfq_data']['json'] = $client_policy_data['placement_json'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Cache decoded JSON to avoid multiple decodes
|
||||
$question_json_decoded = !empty($lead_data['question_json'])
|
||||
? json_decode($lead_data['question_json'], true)
|
||||
: null;
|
||||
|
||||
$data['question_json'] = $lead_data['question_json'];
|
||||
$data['tab_name'] = $type == 2 ? 'QCR' : 'RFQ';
|
||||
$data['page_name'] = $type == 2 ? 'QCR' : 'RFQ';
|
||||
$data['lead_data'] = $lead_data;
|
||||
|
||||
// 6. Parallel/batch data fetching for independent queries
|
||||
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
|
||||
$data['userList'] = $this->userModel->getUserListForRFQ();
|
||||
$data['exclusiveUserList'] = $this->userModel->getexclusiveUserListForRFQ();
|
||||
$data['lead_data'] = $lead_data;
|
||||
$data['tpa_list'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
|
||||
$data['account_manager'] = $this->userModel
|
||||
->where('is_active', 1)
|
||||
->where('role', 3)
|
||||
->findAll();
|
||||
|
||||
$mail_content = '
|
||||
// 7. Define mail templates as constants or config
|
||||
$mail_content = $this->getMailTemplate();
|
||||
$subject = $this->getSubjectTemplate($lead_data);
|
||||
|
||||
// 8. Pre-calculate sum assured only for GPA
|
||||
$data['totalSumAssured'] = ($lead_data['policy_type_id'] == 1) ? $this->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => $id]) : [];
|
||||
|
||||
// 9. Transform mail content once
|
||||
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
|
||||
$data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']);
|
||||
$data['placement_mail_content'] = $this->transformMailContent($lead_data, $mail_content, 'Placement');
|
||||
$data['placement_subject'] = $this->transformMailContent($lead_data, $subject, 'Placement');
|
||||
|
||||
// 10. Combine related queries
|
||||
$data['multi_file_data'] = $this->leadFilesModel
|
||||
->where('lead_id', $id)
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$installment_data['installments'] = $this->leadInstallmentPaymentDetails
|
||||
->where('lead_id', $id)
|
||||
->where('is_active', 1)
|
||||
->findAll();
|
||||
|
||||
// 11. Generate views efficiently
|
||||
$data['lead_data']['installment_data'] = !empty($installment_data['installments'])
|
||||
? view('rfq/installment_fields', $installment_data)
|
||||
: null;
|
||||
|
||||
$data['attachment_html'] = view('rfq/attachment_files', $data);
|
||||
|
||||
$user_team = $this->userModel
|
||||
->select("ut.team_id")
|
||||
->join("user_teams ut", "ut.user_id = user_profiles.id and ut.is_active = 1")
|
||||
->where("user_profiles.is_active", 1)
|
||||
->first();
|
||||
$data['user_team'] = $user_team['team_id'] ?? null;
|
||||
|
||||
$data['multi_file_data_html'] = $this->renderFileFields($data['multi_file_data']);
|
||||
|
||||
// 12. Conditional rendering based on lead_form_type
|
||||
if ($lead_data['lead_form_type'] == 1) {
|
||||
$data['demogrphy_html_data'] = $this->generateDemographyDataTable(['lead_id' => $id]);
|
||||
$this->loadLayout('view_rfq.php', $data);
|
||||
} else if ($lead_data['lead_form_type'] == 2) {
|
||||
$data['occupancy'] = $this->occupancyModel->findAll();
|
||||
|
||||
// Use cached decoded JSON
|
||||
if ($question_json_decoded) {
|
||||
$data['policies'] = $question_json_decoded['policies'] ?? [];
|
||||
$data["child_table_data"] = $question_json_decoded['child_table_data'] ?? [];
|
||||
}
|
||||
|
||||
$data['product'] = $lead_data['policy_type'];
|
||||
$data['buisness_type'] = $this->buisnessType;
|
||||
$data['client_type'] = $this->clientType;
|
||||
|
||||
$this->loadLayout('view_rfq_non_eb', $data);
|
||||
}
|
||||
}
|
||||
|
||||
// 13. Extract mail template to separate method for reusability
|
||||
private function getMailTemplate()
|
||||
{
|
||||
return '
|
||||
<p>Dear Sir,</p>
|
||||
<p>Greetings From Nhance India!</p>
|
||||
<p>Please find attached the {{RFQ_OR_QCR}} for <strong>{{POLICY_TYPE}}</strong> policy pertaining to <strong>{{CLIENT_NAME}}</strong>.</p>
|
||||
@ -763,70 +987,21 @@ class LeadsController extends BaseController
|
||||
<p>Thank You!</p><br>
|
||||
<p>Best regards,</p>
|
||||
|
||||
<div style=\"margin: 0; padding: 0; line-height: 1.2;\">
|
||||
<div style="margin: 0; padding: 0; line-height: 1.2;">
|
||||
<div>{{LOGGED_USER_NAME}}</div>
|
||||
<div>Mobile: {{LOGGED_USER_MOBILE}}</div>
|
||||
</div>
|
||||
|
||||
<img src="{{LOGO_PATH}}" alt="Nhance Logo" width="100" style="margin-top:10px;">
|
||||
<img src="{{LOGO_PATH}}" alt="Nhance Logo" width="100" style="margin-top:10px;">
|
||||
';
|
||||
}
|
||||
|
||||
if ($data['lead_data']['policy_end_date'] != null) {
|
||||
$subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}} {{POLICY_END_DATE}}";
|
||||
} else {
|
||||
$subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}";
|
||||
}
|
||||
|
||||
if ($lead_data['policy_type_id'] == 1) {
|
||||
$data['totalSumAssured'] = $this->handleMemberDataGPATotalSumInsurerFromExcel(['lead_id' => $id]);
|
||||
} else {
|
||||
$data['totalSumAssured'] = [];
|
||||
}
|
||||
|
||||
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
|
||||
$data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']);
|
||||
|
||||
$data['placement_mail_content'] = $this->transformMailContent($lead_data, $mail_content, 'Placement');
|
||||
$data['placement_subject'] = $this->transformMailContent($lead_data, $subject, 'Placement');
|
||||
|
||||
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
|
||||
$installment_data['installments'] = $this->leadInstallmentPaymentDetails->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
|
||||
$data['lead_data']['installment_data'] = view('rfq/installment_fields', $installment_data) ?? null;
|
||||
$data['attachment_html'] = view('rfq/attachment_files', $data) ?? "";
|
||||
$data['user_team'] = $this->userModel->select("ut.team_id")->join("user_teams ut", "ut.user_id = user_profiles.id and ut.is_active = 1")->where("user_profiles.is_active", 1)->first()['team_id'];
|
||||
// dd($data);
|
||||
|
||||
if ($data['lead_data']['lead_form_type'] == 1) {
|
||||
$data['demogrphy_html_data'] = $this->generateDemographyDataTable(['lead_id' => $id]);
|
||||
$this->loadLayout('view_rfq.php', $data);
|
||||
} else if ($data['lead_data']['lead_form_type'] == 2) {
|
||||
|
||||
$data['occupancy'] = $this->occupancyModel->findAll();
|
||||
// dd($data['occupancy']);
|
||||
|
||||
if ($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0) {
|
||||
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
|
||||
if (isset($client_policy_data)) {
|
||||
|
||||
$data['rfq_data']['json'] = $client_policy_data['placement_json'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($data['question_json'])) {
|
||||
$data['policies'] = json_decode($data['question_json'], true)['policies'];
|
||||
$data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
|
||||
}
|
||||
|
||||
$data['product'] = $this->leadsModel->select("policy_type.policy_type")->join('policy_type', 'leads.policy_type_id = policy_type.id')->where('leads.id', $id)->first()['policy_type'];
|
||||
// $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']);
|
||||
// dd($data['lead_register_data']);
|
||||
// $data['entity_type'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
|
||||
$data['buisness_type'] = $this->buisnessType;
|
||||
|
||||
// dd($data);
|
||||
$data['client_type'] = $this->clientType;
|
||||
$this->loadLayout('view_rfq_non_eb', $data);
|
||||
}
|
||||
// 14. Extract subject template to separate method
|
||||
private function getSubjectTemplate($lead_data)
|
||||
{
|
||||
return $lead_data['policy_end_date'] != null
|
||||
? "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}} {{POLICY_END_DATE}}"
|
||||
: "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}";
|
||||
}
|
||||
|
||||
public function savePolicyInfo()
|
||||
@ -1454,20 +1629,22 @@ class LeadsController extends BaseController
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
];
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (in_array($rfq_data['policy_type_id'], [2, 3, 4, 5])) {
|
||||
$lead_data = [
|
||||
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
|
||||
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
'No of Dependents at Inception' => $rfq_data['incept_dept_count'],
|
||||
'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'],
|
||||
// 'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
// 'No of Dependents at Inception' => $rfq_data['incept_dept_count'],
|
||||
// 'Total Lives at Inception ' => $rfq_data['incept_no_of_lives'],
|
||||
|
||||
'No of Employees at Expiry' => $rfq_data['exp_emp_count'],
|
||||
'No of Dependents at Expiry' => $rfq_data['exp_dept_count'],
|
||||
'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'],
|
||||
// 'No of Employees at Expiry' => $rfq_data['exp_emp_count'],
|
||||
// 'No of Dependents at Expiry' => $rfq_data['exp_dept_count'],
|
||||
// 'Total Lives at Expiry ' => $rfq_data['exp_no_of_lives'],
|
||||
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'No of Dependents at Renewal' => $rfq_data['renewal_dept_count'],
|
||||
@ -1476,30 +1653,32 @@ class LeadsController extends BaseController
|
||||
'Period of Insurance ' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
|
||||
'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']),
|
||||
'Earned Premium' => formatIndianCurrency(intval($rfq_data['earned_premium'])),
|
||||
'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']),
|
||||
'Annualised Claims' => formatIndianCurrency(intval($rfq_data['annualised_claims'])),
|
||||
'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %",
|
||||
'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %",
|
||||
|
||||
// 'Policy Run Days' => $rfq_data['policy_run_days'],
|
||||
// 'Inception Premium' => formatIndianCurrency($rfq_data['premium_at_inception']),
|
||||
// 'Premium as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['premium_date']),
|
||||
// 'Earned Premium' => formatIndianCurrency(intval($rfq_data['earned_premium'])),
|
||||
// 'Incurred Claims as on (' . date('d-m-Y', strtotime($rfq_data['incurred_claims_date'])) . ')' => formatIndianCurrency($rfq_data['incurred_claims']),
|
||||
// 'Annualised Claims' => formatIndianCurrency(intval($rfq_data['annualised_claims'])),
|
||||
// 'Incurred Claims Ratio' => $rfq_data['incurred_claims_ratio'] . " %",
|
||||
// 'Earned Claims Ratio' => $rfq_data['earned_claims_ratio'] . " %",
|
||||
];
|
||||
} else if (in_array($rfq_data['policy_type_id'], [1, 6, 7])) {
|
||||
|
||||
$lead_data = [
|
||||
'Insured' => $rfq_data['client_name'],
|
||||
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
|
||||
'Total Lives at Inception' => $rfq_data['total_lives_at_incept'],
|
||||
'Total Sum Insured at Inception' => $rfq_data['total_si_at_incept'],
|
||||
'Premium at inception' => $rfq_data['premium_at_incept'],
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
|
||||
'Policy Period' => !empty($rfq_data['policy_start_date']) && !empty($rfq_data['policy_end_date']) ? date('d-m-Y', strtotime($rfq_data['policy_start_date'])) . ' to ' . date('d-m-Y', strtotime($rfq_data['policy_end_date'])) : "To be decided",
|
||||
// 'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
// 'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
'Policy Type' => $this->leadType[$rfq_data['lead_type']] ?? "",
|
||||
'Existing Insurer' => $rfq_data['insurer_name'],
|
||||
// 'TPA ' => $rfq_data['tpa_name'],
|
||||
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
|
||||
'Total Sum Insured at Renewal' => $rfq_data['total_si_at_renewal'],
|
||||
'Claims Experience for last 3 years' => "Mentioned in Claims sheet",
|
||||
// 'Insurer' => $rfq_data['insurer_name'] ?? " - ",
|
||||
// 'TPA' => $rfq_data['tpa_name'] ?? " - ",
|
||||
// 'Total Lives at Inception' => $rfq_data['total_lives_at_incept'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -2827,6 +3006,22 @@ class LeadsController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
if($recipient_type == 'placement' && isset($params['acm_email']) && !empty($params['acm_email'])){
|
||||
|
||||
$common['mail_type'] = "internal acm";
|
||||
$acm_mail_content = '
|
||||
<p>Dear Sir,</p>
|
||||
<p>The placement for the <strong>{{POLICY_TYPE}}</strong> policy pertaining to <strong>{{CLIENT_NAME}}</strong> has been successfully won.</p>
|
||||
<p>Please proceed with the next steps accordingly.</p>
|
||||
<p>Thank You!</p><br>
|
||||
<p>Best regards,</p>
|
||||
|
||||
<img src="{{LOGO_PATH}}" alt="Nhance Logo" width="100" style="margin-top:10px;">
|
||||
';
|
||||
$acm_mail_content = $this->transformMailContent($lead_data, $acm_mail_content, $data['page_name'] = 'QCR');
|
||||
$res = MailHelper::send_email(['from_mail' => $from_mail, 'mail' => $params['acm_email'], 'subject' => $subject, 'message' => $acm_mail_content, 'attachments' => $attachments, 'common' => $common]);
|
||||
}
|
||||
|
||||
$is_placement = false;
|
||||
if ($recipient_type == 'placement') {
|
||||
|
||||
@ -2852,8 +3047,16 @@ class LeadsController extends BaseController
|
||||
'cd_amount' => $params['cd_amount'] ?? null,
|
||||
'no_of_installment' => $params['no_of_installment'] ?? null,
|
||||
'is_installment' => $params['is_installment'] ?? null,
|
||||
'is_installment' => $params['is_installment'] ?? null,
|
||||
'acm_id' => $params['acm_pk'] ?? null,
|
||||
];
|
||||
|
||||
if(isset($params['tpa_id']) && !empty($params['tpa_id'])){
|
||||
list($tpaBranchId, $tpaId) = explode('-', $params['tpa_id']);
|
||||
$data['tpa_branch_id'] = $tpaBranchId;
|
||||
$data['tpa_id'] = $tpaId;
|
||||
}
|
||||
|
||||
$this->leadsModel->where('id', $lead_id)->set($data)->update();
|
||||
|
||||
if (isset($params['installments']) && !empty($params['installments'])) {
|
||||
@ -3641,7 +3844,7 @@ class LeadsController extends BaseController
|
||||
$this->loadLayout('view_rfq_non_eb');
|
||||
}
|
||||
|
||||
// get lead data for edit bot EB and NON-EB
|
||||
// get lead data for edit both EB and NON-EB
|
||||
public function getLeadNonEB($type, $id = null)
|
||||
{
|
||||
// Set basic data
|
||||
@ -4901,7 +5104,7 @@ class LeadsController extends BaseController
|
||||
|
||||
$lower_headers = array_map('strtolower', $members_heading);
|
||||
foreach ($lower_headers as $index => $header) {
|
||||
if (preg_match('/^sa\s*-\s*option\s*\d*$/i', $header)) {
|
||||
if (preg_match('/^(sa\s*-\s*option|proposed\s+sum\s+insured)\s+\d+$/i', $header)) {
|
||||
$column_name = $members_heading[$index];
|
||||
$sum = 0;
|
||||
|
||||
@ -5168,5 +5371,182 @@ class LeadsController extends BaseController
|
||||
return ['status' => true, "data" => $reminder_sended_lead];
|
||||
}
|
||||
|
||||
public function uploadMultiFileFromRfq()
|
||||
{
|
||||
try {
|
||||
|
||||
$this->myLogger->logme('error', "uploadMultiFileFromRfq START");
|
||||
$this->myLogger->logme('error', "Files received: " . json_encode($this->request->getPost() ?? []));
|
||||
|
||||
$lead_id = $this->request->getPost('lead_id');
|
||||
$lead_form_type = $this->request->getPost('lead_form_type');
|
||||
$leads_file_primary_key = $this->request->getPost('leads_file_id') ?? [];
|
||||
$docs_name = $this->request->getPost('docs_name') ?? [];
|
||||
$files = $this->request->getFileMultiple('file_name');
|
||||
|
||||
if (empty($files) || empty($docs_name)) {
|
||||
$this->myLogger->logme('error', "No files or document names provided");
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 400,
|
||||
'message' => 'No files or document names provided'
|
||||
], 400);
|
||||
}
|
||||
|
||||
// Upload process
|
||||
$multi_file_data = $this->uploadMultiFiles($files, $docs_name, $leads_file_primary_key) ?? [];
|
||||
|
||||
$this->myLogger->logme('error', "uploadMultiFiles result: " . json_encode($multi_file_data ?? []));
|
||||
|
||||
if (!empty($multi_file_data)) {
|
||||
$this->insertMultiFilesData($multi_file_data, $lead_id, $lead_form_type);
|
||||
$this->myLogger->logme('error', "Files inserted successfully into DB");
|
||||
|
||||
// update lead file name if change
|
||||
if(isset($multi_file_data[0]['file_name']) && !empty($multi_file_data[0]['file_name'])){
|
||||
$this->leadsModel->where('id', $lead_id)->set('file_name', $multi_file_data[0]['file_name'])->update();
|
||||
}
|
||||
|
||||
} else {
|
||||
$this->myLogger->logme('error', "uploadMultiFiles returned empty");
|
||||
}
|
||||
|
||||
|
||||
// Get the updated lead file data
|
||||
$lead_file_data = $this->leadFilesModel
|
||||
->where('is_active', 1)
|
||||
->where('lead_id', $lead_id)
|
||||
->findAll();
|
||||
|
||||
$this->myLogger->logme('error', "Fetched " . count($lead_file_data) . " lead file records");
|
||||
|
||||
$document_data = $this->renderFileFields($lead_file_data);
|
||||
$attch_data['multi_file_data'] = $lead_file_data;
|
||||
$attachment_html = view('rfq/attachment_files', $attch_data) ?? "";
|
||||
|
||||
$this->myLogger->logme('error', "uploadMultiFileFromRfq END");
|
||||
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'message' => "File uploaded Successfully",
|
||||
'document_data' => $document_data,
|
||||
'attachment_html' => $attachment_html,
|
||||
], 200);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
$errorDetails = [
|
||||
'error_message' => $e->getMessage(),
|
||||
'file' => $e->getFile(),
|
||||
'line' => $e->getLine(),
|
||||
'stack_trace' => $e->getTraceAsString(),
|
||||
];
|
||||
|
||||
// Catch any error/exception and log with trace
|
||||
$this->myLogger->logme('error', "Exception in uploadMultiFileFromRfq: " . json_encode($errorDetails));
|
||||
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 500,
|
||||
'message' => "File upload failed: " . $e->getMessage(),
|
||||
'errorDetails' => $errorDetails,
|
||||
], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function renderFileFields($multi_file_data = [])
|
||||
{
|
||||
$uploadFilePath = WRITEPATH . 'uploads/lead_files/';
|
||||
$html = '';
|
||||
|
||||
// If data exists (edit mode)
|
||||
if (!empty($multi_file_data)) {
|
||||
|
||||
foreach ($multi_file_data as $index => $value) {
|
||||
|
||||
$sample_dwn_link = ' [ <a href="' . base_url("util/downloadMemberFile/") . $value['file_name'] . '" data-toggle="tooltip" data-placement="top" title="Download Member List" target="_blank">Download</a> ]';
|
||||
$isFirstField = ($index === 0);
|
||||
$placeholder = $isFirstField ? 'First file must be Demography.' : '';
|
||||
$first_file_name = $isFirstField ? 'Member List' : '';
|
||||
$member_data_link = $isFirstField ? $sample_dwn_link : '';
|
||||
$read_only = $isFirstField ? 'readonly' : '';
|
||||
$accept = $isFirstField ? '.xls,.xlsx' : '';
|
||||
$displayIndex = $index + 1;
|
||||
|
||||
$html .= '
|
||||
<div class="form-row d-flex align-items-end" id="fileField_' . $displayIndex . '">
|
||||
<input type="hidden" name="leads_file_id[]" value="' . htmlspecialchars($value['id']) . '" id="file_id_' . $displayIndex . '">
|
||||
|
||||
<div class="form-group col-md-5">
|
||||
<label>Document Name</label>
|
||||
<input type="text" class="form-control" name="docs_name[]"
|
||||
placeholder="' . $placeholder . '"
|
||||
value="' . htmlspecialchars(!empty($first_file_name) ? $first_file_name : $value['docs_name']) . '" id="docs_name_' . $displayIndex . '" '.$read_only.'>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-5">
|
||||
<label>
|
||||
File Upload<br>
|
||||
<small id="file_name_display_' . $displayIndex . '" class="text-muted">' .
|
||||
(!empty($value['file_name']) ? htmlspecialchars($value['file_name']) : 'No file chosen') .
|
||||
'</small> '.$member_data_link.'
|
||||
</label>
|
||||
<input type="file" class="form-control" id="file_name_' . $displayIndex . '"
|
||||
name="file_name[]" accept="' . $accept . '"
|
||||
onchange="showFileName(this, ' . $displayIndex . ')">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2" style="position: relative; bottom: 16px;">
|
||||
<button type="button" class="btn btn-danger" onclick="removeFileField(' . $displayIndex . ', ' . htmlspecialchars($value['id']) . ')">x</button>
|
||||
<button type="button" class="btn btn-primary" onclick="addFileField()">+</button>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
} else {
|
||||
// Default (add mode)
|
||||
$html .= '
|
||||
<div class="form-row d-flex align-items-end" id="fileField_1">
|
||||
<input type="hidden" name="leads_file_id[]" value="">
|
||||
|
||||
<div class="form-group col-md-5">
|
||||
<label>Document Name</label>
|
||||
<input type="text" class="form-control" name="docs_name[]"
|
||||
placeholder="First file must be Demography." id="docs_name_1">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-5">
|
||||
<label>
|
||||
File Upload<br>
|
||||
<small id="file_name_display_1" class="text-muted">No file chosen</small>
|
||||
</label>
|
||||
<input type="file" class="form-control" id="file_name_1"
|
||||
name="file_name[]" accept=".xls,.xlsx" onchange="showFileName(this, 1)">
|
||||
</div>
|
||||
|
||||
<div class="col-md-2" style="position: relative; bottom: 16px;">
|
||||
<button type="button" class="btn btn-danger" onclick="removeFileField(1, \'\')">x</button>
|
||||
<button type="button" class="btn btn-primary" onclick="addFileField()">+</button>
|
||||
</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function downloadMemberFile($fileName)
|
||||
{
|
||||
$filePath = WRITEPATH . 'uploads/lead_files/' . $fileName;
|
||||
|
||||
if (!file_exists($filePath)) {
|
||||
$data['message'] = 'The Physical File Not Found';
|
||||
echo view('errors/404', $data);
|
||||
}
|
||||
|
||||
// force download
|
||||
return $this->response->download($filePath, null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1243,7 +1243,8 @@ class PolicyTransactionController extends BaseController
|
||||
$issue_type = $this->policyTransactionModel
|
||||
->where('action_type', 'inception')
|
||||
->where('client_id', $this->request->getPost('client_id'))
|
||||
->where('client_policy_id', $this->request->getPost('client_policy_id'))
|
||||
// ->where('client_policy_id', $this->request->getPost('client_policy_id'))
|
||||
->where('id', $this->request->getPost('client_policy_id'))
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->first();
|
||||
|
||||
@ -3062,9 +3063,28 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
$clientIds = array_column($clients, 'id');
|
||||
|
||||
$policies = $this->clientPolicyModel
|
||||
// $policies = $this->clientPolicyModel
|
||||
// ->select("
|
||||
// client_policy.*,
|
||||
// policy_type.policy_type,
|
||||
// policy_type.ebp,
|
||||
// policy_type.etp,
|
||||
// policy_type.iep,
|
||||
// policy_type.itp,
|
||||
// policy_type.bap,
|
||||
// policy_type.allocg,
|
||||
// DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
|
||||
// DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
|
||||
// ")
|
||||
// ->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
// ->join('policy_transaction pt', 'pt.client_policy_id = client_policy.id and pt.action_type = "inception" and pt.is_active = 1 and pt.client_policy_id is not null')
|
||||
// ->whereIn('client_policy.client_id', $clientIds)
|
||||
// ->where('client_policy.is_active', 1)
|
||||
// ->findAll();
|
||||
|
||||
$policies = $this->policyTransactionModel
|
||||
->select("
|
||||
client_policy.*,
|
||||
policy_transaction.*,
|
||||
policy_type.policy_type,
|
||||
policy_type.ebp,
|
||||
policy_type.etp,
|
||||
@ -3072,14 +3092,14 @@ class PolicyTransactionController extends BaseController
|
||||
policy_type.itp,
|
||||
policy_type.bap,
|
||||
policy_type.allocg,
|
||||
DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
|
||||
DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
|
||||
DATE_FORMAT(policy_transaction.policy_start_date, '%d/%m/%Y') as policy_start_date,
|
||||
DATE_FORMAT(policy_transaction.policy_end_date, '%d/%m/%Y') as policy_end_date
|
||||
")
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
->join('policy_transaction pt', 'pt.client_policy_id = client_policy.id and pt.action_type = "inception" and pt.is_active = 1 and pt.client_policy_id is not null')
|
||||
->whereIn('client_policy.client_id', $clientIds)
|
||||
->where('client_policy.is_active', 1)
|
||||
->findAll();
|
||||
->join('policy_type', 'policy_type.id = policy_transaction.policy_type_id')
|
||||
->whereIn('policy_transaction.client_id', $clientIds)
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->where('policy_transaction.action_type', "inception")
|
||||
->findAll();
|
||||
|
||||
foreach ($policies as $policy) {
|
||||
$policyList[$policy['client_branch_id']][] = $policy;
|
||||
|
||||
@ -503,14 +503,14 @@ class RestAuthenticationController extends AdminController
|
||||
log_message('error', ' ');
|
||||
log_message('error', '************************ POST END ********************************');
|
||||
log_message('error', ' ');
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => []],200);
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "", 'message' => 'No data found'],200);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - getVerifiedUserData: Exception: " . $e->getMessage() . " --- Line: " . $e->getLine() . " --- Trace: " . $e->getTraceAsString());
|
||||
log_message('error', ' ');
|
||||
log_message('error', ' ************************************* POST END **************************************** ');
|
||||
log_message('error', ' ');
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' =>[], 'error' => $e->getMessage()],500);
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => "", 'message' => $e->getMessage()],500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -862,7 +862,7 @@ class RestAuthenticationController extends AdminController
|
||||
log_message('error', ' ');
|
||||
log_message('error', ' ************************************* POST END **************************************** ');
|
||||
log_message('error', ' ');
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => "", 'message' => $th],500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -966,7 +966,7 @@ class RestAuthenticationController extends AdminController
|
||||
log_message('error', ' ');
|
||||
log_message('error', ' ************************************* POST END **************************************** ');
|
||||
log_message('error', ' ');
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => "", 'message' => $th],500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1200,13 +1200,13 @@ class RestAuthenticationController extends AdminController
|
||||
log_message('error', ' ');
|
||||
log_message('error', ' ************************************* POST END **************************************** ');
|
||||
log_message('error', ' ');
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => "Mpin - exist" , 'Mpin' =>$employeeData["mpin"], 'is_mpin_skipped' => $employeeData['is_mpin_skipped'], 'is_biometric_enabled' => $employeeData['is_biometric_enabled']],200);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => "", 'message' => "Mpin - exist" , 'Mpin' =>$employeeData["mpin"], 'is_mpin_skipped' => $employeeData['is_mpin_skipped'], 'is_biometric_enabled' => $employeeData['is_biometric_enabled']],200);
|
||||
} else {
|
||||
$this->myLogger->logme("error", "REST-AUTH-CONTROLLER - checkMpin: Mpin - not found");
|
||||
log_message('error', ' ');
|
||||
log_message('error', ' ************************************* POST END **************************************** ');
|
||||
log_message('error', ' ');
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "Mpin - not found", 'Mpin' =>null],200);
|
||||
return $this->respond(['status' => 'failed','code' => 404,'data' => "", 'message' => "Mpin - not found", 'Mpin' =>null],200);
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
@ -1215,7 +1215,7 @@ class RestAuthenticationController extends AdminController
|
||||
log_message('error', ' ************************************* POST END **************************************** ');
|
||||
log_message('error', ' ');
|
||||
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e->getMessage()],500);
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => "", 'message' => $e->getMessage()],500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ namespace App\Controllers;
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\InsurerBranchModel;
|
||||
use App\Models\RFQModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use Dompdf\Dompdf;
|
||||
@ -313,4 +314,36 @@ class TestingController extends BaseController
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function viewRFQNonEb()
|
||||
{
|
||||
$insurerBranchModel = new InsurerBranchModel();
|
||||
$data['page_name'] = "RFQ NON EB";
|
||||
$data['insurer'] = $insurerBranchModel->getInsurerBranchesWithInsurerNames();
|
||||
// dd($data);
|
||||
return $this->loadLayout('view_rfq_non_eb_new', $data);
|
||||
}
|
||||
|
||||
public function saverfq(){
|
||||
$json = $this->request->getPost('json');
|
||||
$json = json_encode($json);
|
||||
print_r($json);
|
||||
|
||||
// $data['lead_id'] = 10000;
|
||||
// $data['json'] = $json;
|
||||
// $rfq = new RFQModel();
|
||||
|
||||
// $rfq->insert($data);
|
||||
}
|
||||
|
||||
public function exportExcel()
|
||||
{
|
||||
$rfq = new RFQModel();
|
||||
$policy_data = $rfq->where('lead_id', 10000)->first();
|
||||
// print_rr($policy_data['json']); die;
|
||||
$policy_data = json_decode($policy_data['json'], true);
|
||||
$policy_data = array_slice($policy_data, 0, -2);
|
||||
print_rr($policy_data); die;
|
||||
dd($policy_data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -105,6 +105,7 @@ class LeadsModel extends Model
|
||||
'next_reminder_date',
|
||||
'is_insurer_auto_mail',
|
||||
'quote_received_insurer',
|
||||
'acm_id',
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -1751,41 +1751,53 @@
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
||||
<!-- Masters -->
|
||||
<?php if (get_role_id() == 1 || get_role_id() == 5) { ?>
|
||||
<!-- Masters -->
|
||||
<?php if (get_role_id() == 1 || get_role_id() == 5 || get_role_id() == 4) { ?>
|
||||
|
||||
<li class="li-seperate" id="masters-li">
|
||||
<a href="#sidebarPolicies" data-toggle="collapse" class=" img-inactive">
|
||||
<img
|
||||
src="<?= base_url() . "public"; ?>/assets/images/masters_sb.png" alt="Logo" height="20">
|
||||
<span> Masters </span>
|
||||
</a>
|
||||
<div class="collapse" id="sidebarPolicies">
|
||||
<ul class="nav-second-level">
|
||||
<li>
|
||||
<a href="<?= base_url('/master/insurer/list') ?>">Insurer</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/tpa/list') ?>">TPA</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/kyc/list') ?>">KYC</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/policy/list') ?>">Policy</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/user/list') ?>"> Users </a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
<span> Masters </span>
|
||||
</a>
|
||||
<div class="collapse" id="sidebarDashboards">
|
||||
<ul class="nav-second-level">
|
||||
|
||||
<?php if (get_role_id() == 1 || get_role_id() == 5 || ( get_role_id() == 4 && (in_array(BUSINESS_SUPPORT_TEAM_ID, user_team()) || in_array(SALES_TEAM_ID, user_team())))) { ?>
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/master/insurer/list') ?>">Insurer</a>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if (get_role_id() == 1 || get_role_id() == 5) { ?>
|
||||
|
||||
<li>
|
||||
<a href="<?= base_url('/master/tpa/list') ?>">TPA</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/kyc/list') ?>">KYC</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/policy/list') ?>">Policy</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/user/list') ?>"> Users </a>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
@ -189,7 +189,7 @@ if (isset($selected_lead_type)) {
|
||||
$('#leads_form').hide()
|
||||
}
|
||||
|
||||
function getClientAndBranchAndPolicy() {
|
||||
function getClientAndBranchAndPolicy(append = true) {
|
||||
|
||||
console.log('getClientAndBranchAndPolicy function called')
|
||||
|
||||
@ -204,7 +204,9 @@ if (isset($selected_lead_type)) {
|
||||
client_list = res.client_data;
|
||||
branch_list = res.branch_data;
|
||||
policy_list = res.policy_data;
|
||||
appendClients(res.client_data);
|
||||
if(append == true){
|
||||
appendClients(res.client_data);
|
||||
}
|
||||
} else {
|
||||
console.log('No data found');
|
||||
}
|
||||
@ -217,7 +219,7 @@ if (isset($selected_lead_type)) {
|
||||
});
|
||||
}
|
||||
|
||||
function appendClients(data) {
|
||||
function appendClients(data, client_id = null) {
|
||||
// console.log("lead_type",lead_type.value);
|
||||
|
||||
$('#client_id').empty();
|
||||
@ -238,22 +240,28 @@ if (isset($selected_lead_type)) {
|
||||
}));
|
||||
|
||||
$.each(data, function(index, item) {
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.client_name,
|
||||
'data-cn': item.client_name,
|
||||
'data-csn': item.short_name,
|
||||
'data-ct': item.client_type,
|
||||
'data-cet': item.entity_type_id,
|
||||
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
|
||||
});
|
||||
if(item.client_type == 1){
|
||||
var option = $('<option>', {
|
||||
value: item.id,
|
||||
text: item.client_name,
|
||||
'data-cn': item.client_name,
|
||||
'data-csn': item.short_name,
|
||||
'data-ct': item.client_type,
|
||||
'data-cet': item.entity_type_id,
|
||||
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
|
||||
});
|
||||
|
||||
$('#client_id').append(option);
|
||||
if (client_id == item.id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
|
||||
$('#client_id').append(option);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function appendBranch(data) {
|
||||
function appendBranch(data, branch_id = null) {
|
||||
|
||||
$('#client_branch_id').empty();
|
||||
|
||||
@ -268,6 +276,11 @@ if (isset($selected_lead_type)) {
|
||||
value: item.id,
|
||||
text: item.branch_name
|
||||
});
|
||||
|
||||
if (branch_id == item.id) {
|
||||
option.attr('selected', true);
|
||||
}
|
||||
|
||||
$('#client_branch_id').append(option);
|
||||
});
|
||||
}
|
||||
@ -334,6 +347,8 @@ if (isset($selected_lead_type)) {
|
||||
$("#client_short_name").val(shortName);
|
||||
|
||||
if (client_id == 'add_client') {
|
||||
|
||||
$(this).val("").select2();
|
||||
// alert("Hello");
|
||||
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||||
myModal.show();
|
||||
|
||||
312
app/Views/newClientModal-old.php
Normal file
312
app/Views/newClientModal-old.php
Normal file
@ -0,0 +1,312 @@
|
||||
<!-- Client form content modal-->
|
||||
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="myCenterModalLabel">Add New Client</h4>
|
||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body" style="overflow-y: auto;height: 90vh;">
|
||||
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
|
||||
<div class="form-group">
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="client_name">Client Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="client_name" name="client_name" required>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Client Short name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="short_name" name="short_name" onkeyup="validateInputForClient(this, 'clients', 'short_name')" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="cost_center">PAN</label>
|
||||
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan" onchange="validateInputForClient(this, 'clients', 'pan')">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<!-- Client Type -->
|
||||
<div class="form-row clienttypediv" style="display: none;">
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="dob" placeholder="DD/MM/YYYY" name="dob" >
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="cost_center">Mobile<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number" maxlength="10" name="phone"
|
||||
onkeypress="return onlyNumbers(event)" onchange="validateInputForClient(this, 'clients', 'phone')">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="email2">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email2" placeholder="Enter Email" name="email2">
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="aadhar">Aadhar</label>
|
||||
<input type="text" class="form-control" id="aadhar" placeholder="Enter Aadher No" name="aadhar" maxlength="12" onchange="validateInputForClient(this, 'clients', 'aadhar')">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- branch -->
|
||||
<div class="form-row branchdiv">
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Entity Type<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
||||
<option value="" selected>Select Entity</option>
|
||||
<?php
|
||||
if (isset($entity) && count($entity)) {
|
||||
foreach ($entity as $key => $value) {
|
||||
echo "<option value=" . $value['id'] . ">" . $value['name'] . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="client_name">Branch Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_code" name="branch_code" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="name" name="name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)" required>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="email">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email" placeholder="Enter Email" name="email" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="gst">GST<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number" oninput="validateInputForClient(this, 'client_branch', 'gst')"
|
||||
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst" data-parsley-trigger="change" data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}$" required>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
|
||||
<button type="submit" id="client_add_modal_submit_btn" class="btn btn-primary waves-effect waves-light mr-1 your">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
<script>
|
||||
let isGSTValidating = false;
|
||||
let isGSTValid = false;
|
||||
|
||||
function validateInputForClient(input, table, field) {
|
||||
|
||||
let owner_type = $('#Owner_type').val();
|
||||
let client_type = $('#client_type').val();
|
||||
|
||||
console.log('owner_type', owner_type);
|
||||
console.log('client_type', client_type);
|
||||
|
||||
if((client_type == 2 || owner_type == 2) && field == 'short_name'){
|
||||
return;
|
||||
}
|
||||
|
||||
let value = $(input).val();
|
||||
if (!value) return;
|
||||
|
||||
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||
let message = label ? label + " already exists!" : "Value is duplicate!";
|
||||
|
||||
// Set validating state
|
||||
isGSTValidating = true;
|
||||
isGSTValid = false;
|
||||
$('#hide_smbt_btn button').prop('disabled', true);
|
||||
|
||||
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||
isGSTValidating = false;
|
||||
if (isDuplicate) {
|
||||
toastr.warning(message, 'WARNING');
|
||||
// $(input).val('');
|
||||
isGSTValid = false;
|
||||
$('#client_add_modal_submit_btn').prop('disabled', true);
|
||||
} else {
|
||||
isGSTValid = true;
|
||||
$('#client_add_modal_submit_btn').prop('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
$('#hide_smbt_btn button').prop('disabled', false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$("#client_form").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
// If GST is currently validating, wait for it to complete
|
||||
if (isGSTValidating) {
|
||||
if($('#Owner_type').val() == 1){
|
||||
toastr.info('Please wait while we validate your GST number...', 'Validating');
|
||||
return;
|
||||
}else if ($('#client_type').val() == 1){
|
||||
toastr.info('Please wait while we validate your GST number...', 'Validating');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// If GST validation failed, prevent submission
|
||||
if ($('#gst').val() && !isGSTValid) {
|
||||
toastr.warning('Please fix the GST number before submitting', 'Validation Error');
|
||||
return;
|
||||
}
|
||||
|
||||
let form_type = $(this).data('id') || 0;
|
||||
|
||||
console.log('onsubmit event', this);
|
||||
console.log('onsubmit event get data value',form_type);
|
||||
console.log('client_type', $('#client_type').val());
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
$('#aadhar').attr('data-parsley-required', 'false');
|
||||
$('#aadhar').removeAttr('required');
|
||||
|
||||
if($('#Owner_type').val() == 2){
|
||||
$('#gst').removeAttr('required');
|
||||
}
|
||||
|
||||
var isValid = $('#client_form').parsley().validate();
|
||||
|
||||
if (!isValid) {
|
||||
var emptyFieldIds = [];
|
||||
|
||||
$('#client_form').parsley().fields.forEach(function(field) {
|
||||
if (!field.isValid()) {
|
||||
var elem = field.$element;
|
||||
var id = elem.attr('id') || elem.attr('name');
|
||||
emptyFieldIds.push(id);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Empty/Invalid Fields:', emptyFieldIds);
|
||||
return;
|
||||
}
|
||||
|
||||
isClientFormSubmitting = true;
|
||||
|
||||
form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
var client_type = $('#client_type').val() || $('#Owner_type').val() || 1;
|
||||
console.log('client_type:', client_type);
|
||||
|
||||
//FORM Data
|
||||
var formData = new FormData($('#client_form')[0]);
|
||||
formData.append('client_type', client_type);
|
||||
console.log("formData : ",formData);
|
||||
// return
|
||||
$.ajax({
|
||||
data:formData,
|
||||
url: form_action,
|
||||
type: "POST",
|
||||
dataType: 'json',
|
||||
processData: false,
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.log('create_Client_With_Minimal_Data', res)
|
||||
|
||||
if(res.status == true){
|
||||
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
|
||||
if(form_type != 1){
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
$('#client_id').val(res.client_id).change();
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, 1000)
|
||||
|
||||
}, 3000)
|
||||
|
||||
}else{
|
||||
|
||||
console.log("Couldn't Add Client","Error");
|
||||
}
|
||||
|
||||
toastr.success(res.message, 'Success');
|
||||
|
||||
}else{
|
||||
toastr.error(res.message, 'Error');
|
||||
}
|
||||
|
||||
$('#client_form')[0].reset();
|
||||
$('.close').click();
|
||||
|
||||
if(form_type == 1){
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
myModal.show();
|
||||
|
||||
$('#client_form').removeAttr('data-id');
|
||||
|
||||
// Load form data into #vehicle_form from localStorage
|
||||
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData", res.client_id);
|
||||
|
||||
setTimeout(function(){
|
||||
$('#owner').val(res.client_id).change();
|
||||
$('#owner_branch').val(res.branch_id).change();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, 2000)
|
||||
}
|
||||
|
||||
isClientFormSubmitting = false;
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.error(xhr.responseText);
|
||||
console.error(status, error);
|
||||
isClientFormSubmitting = false;
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -57,7 +57,7 @@
|
||||
<div class="form-row branchdiv">
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="short_name">Entity Type<span class="text-danger">*</span></label>
|
||||
<label for="short_name">Entity Type<span class="text-danger"></span></label>
|
||||
<select class="form-control" id="entity_type_id_for_client" name="entity_type_id">
|
||||
<option value="" selected>Select Entity</option>
|
||||
<?php
|
||||
@ -72,22 +72,22 @@
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="client_name">Branch Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name">
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_code" name="branch_code">
|
||||
<input type="text" class="form-control" id="branch_code" name="branch_code" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="name" name="name">
|
||||
<input type="text" class="form-control" id="name" name="name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="branch_code">Mobile<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)">
|
||||
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile" onkeypress="return onlyNumbers(event)" required>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="email">Email<span class="text-danger">*</span></label>
|
||||
@ -113,6 +113,7 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
let isGSTValidating = false;
|
||||
let isGSTValid = false;
|
||||
|
||||
@ -155,8 +156,6 @@
|
||||
$('#hide_smbt_btn button').prop('disabled', false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$("#client_form").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
@ -224,7 +223,7 @@
|
||||
//FORM Data
|
||||
var formData = new FormData($('#client_form')[0]);
|
||||
formData.append('client_type', client_type);
|
||||
console.log("formData : ",formData);
|
||||
|
||||
// return
|
||||
$.ajax({
|
||||
data:formData,
|
||||
@ -235,37 +234,38 @@
|
||||
contentType: false,
|
||||
success: function(res) {
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
console.log('create_Client_With_Minimal_Data', res)
|
||||
|
||||
if(res.status == true){
|
||||
getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
|
||||
if(form_type != 1){
|
||||
getClientAndBranchAndPolicy(false);
|
||||
|
||||
setTimeout(function(){
|
||||
appendClients(res.clients, res.client_id);
|
||||
appendBranch(res.branches, res.branch_id);
|
||||
|
||||
$('#client_id').val(res.client_id).change();
|
||||
$('#client_id').prepend($('<option>', {
|
||||
value: 'add_client',
|
||||
text: '+ Add Client'
|
||||
}));
|
||||
$('#gst').val(res.data.gst);
|
||||
$('#branch_name').val(res.data.branch_name);
|
||||
$('#branch_code').val(res.data.branch_code);
|
||||
$('#contact_person_mobile').val(res.data.mobile);
|
||||
$('#contact_person_email').val(res.data.email);
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
$('#client_branch_id').val(res.branch_id).change();
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$('#contact_person_summary').empty();
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select a Contact"
|
||||
}));
|
||||
|
||||
}, 1000)
|
||||
|
||||
}, 3000)
|
||||
if (res.data.name && res.data.email) {
|
||||
|
||||
}else{
|
||||
// let display_value = `${res.data.name} - ${res.data.email} - ${res.data.mobile}`;
|
||||
let display_value = res.data.name;
|
||||
|
||||
$('#contact_person_summary').append($('<option>', {
|
||||
value: 0, // index or key in array/object
|
||||
text: display_value,
|
||||
selected: true
|
||||
}));
|
||||
|
||||
console.log("Couldn't Add Client","Error");
|
||||
}
|
||||
|
||||
toastr.success(res.message, 'Success');
|
||||
@ -277,25 +277,8 @@
|
||||
$('#client_form')[0].reset();
|
||||
$('.close').click();
|
||||
|
||||
if(form_type == 1){
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
myModal.show();
|
||||
|
||||
$('#client_form').removeAttr('data-id');
|
||||
|
||||
// Load form data into #vehicle_form from localStorage
|
||||
setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData", res.client_id);
|
||||
|
||||
setTimeout(function(){
|
||||
$('#owner').val(res.client_id).change();
|
||||
$('#owner_branch').val(res.branch_id).change();
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, 2000)
|
||||
}
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
isClientFormSubmitting = false;
|
||||
},
|
||||
|
||||
@ -339,6 +339,7 @@
|
||||
<?php } ?>
|
||||
<button id="submitPlacement" class="btn btn-primary" onclick="checkTheTableDataChanged(6)">Placement</button>
|
||||
<button id="viewDemography" class="btn btn-primary" onclick="viewDemography()">Demography</button>
|
||||
<button id="viewDocs" class="btn btn-primary" onclick="viewDocs()">Docs</button>
|
||||
<input type="hidden" id="lead_id" name="lead_id" value="<?= isset($lead_id) ? $lead_id : '' ?>">
|
||||
<input type="hidden" id="rfq_primaryKey" name="rfq_primaryKey" value="<?= isset($rfq_data['id']) ? $rfq_data['id'] : '' ?>">
|
||||
<input type="hidden" id="qcr_count" value="<?= isset($qcr_count) ? $qcr_count : 0 ?>">
|
||||
@ -492,7 +493,7 @@
|
||||
<hr>
|
||||
|
||||
<div class="form-group" id="insurer_or_clinet_mail_attachment">
|
||||
<div class="form-row" >
|
||||
<div class="form-row attachmet_row">
|
||||
<?php echo isset($attachment_html) && !empty($attachment_html) ? $attachment_html : ''; ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -565,7 +566,7 @@
|
||||
<hr>
|
||||
|
||||
<div class="form-group" id="internal_mail_attachment">
|
||||
<div class="form-row" >
|
||||
<div class="form-row attachmet_row">
|
||||
<?php echo isset($attachment_html) && !empty($attachment_html) ? $attachment_html : ''; ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -600,6 +601,22 @@
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="tpa">TPA <span class="text-danger"></span></label>
|
||||
<select class="form-control" id="tpa_id" name="tpa">
|
||||
<option value="">Select TPA</option>
|
||||
<?php if (isset($tpa_list)) {
|
||||
$tpa_id = isset($lead_data['tpa_id']) ? $lead_data['tpa_id'] : "";
|
||||
$tpa_branch_id = isset($lead_data['tpa_branch_id']) ? $lead_data['tpa_branch_id'] : "";
|
||||
foreach ($tpa_list as $value) { ?>
|
||||
<option value="<?= $value['id'] . '-' . $value['tpa_id'] ?>"
|
||||
<?= ($tpa_id == $value['tpa_id'] && $tpa_branch_id == $value['id']) ? 'selected' : '' ?>>
|
||||
<?= $value['tpa_short_name'] . '-' . $value['branch_code'] ?>
|
||||
</option>
|
||||
<?php } } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="policy_start_date">Policy Start Date</label>
|
||||
<input type="text" class="form-control" id="policy_start_date" name="policy_start_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['policy_start_date']) ? date('d-m-Y', strtotime($lead_data['policy_start_date'])) : "" ?>">
|
||||
@ -617,15 +634,15 @@
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="is_cd_switch">CD Entry</label>
|
||||
<input id="is_cd_switch" type="checkbox" name = "is_cd" value = "1" data-toggle="toggle" data-on="With CD" data-off="Without CD" data-onstyle="info" data-offstyle="primary" data-style="border" data-width="218" <?= isset($lead_data['is_cd']) && $lead_data['is_cd'] != 1 ? '' : 'checked' ?>>
|
||||
<input id="is_cd_switch" type="checkbox" name = "is_cd" value = "1" data-toggle="toggle" data-on="With CD" data-off="Without CD" data-onstyle="info" data-offstyle="primary" data-style="border" data-width="219" <?= isset($lead_data['is_cd']) && $lead_data['is_cd'] != 1 ? '' : 'checked' ?>>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="premium_amount">Premium Amount</label>
|
||||
<label for="premium_amount">Pre Amount include GST</label>
|
||||
<input type="text" class="form-control" id="premium_amount" name="premium_amount" placeholder="Enter Premium Amount" value="<?= isset($lead_data['premium_amount']) ? $lead_data['premium_amount'] : "" ?>">
|
||||
</div>
|
||||
|
||||
<?php if (isset($lead_data['is_cd']) && $lead_data['is_cd'] == 1 || !isset($lead_data['is_cd'])) { ?>
|
||||
<?php if (isset($lead_data['is_cd']) && $lead_data['is_cd'] == 1 || !isset($lead_data['is_cd']) || $lead_data['is_cd'] == null) { ?>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="cd_amount">CD Amount</label>
|
||||
@ -706,6 +723,22 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<label for="acm_id">Account Manager</label>
|
||||
<select class="form-control" id="acm_id" name="acm_id" required>
|
||||
<option value="">Select Account Manager Mail</option>
|
||||
<?php if (isset($account_manager)) { ?>
|
||||
<?= $acm_id = isset($lead_data['acm_id']) ? $lead_data['acm_id'] : ""; ?>
|
||||
<?php foreach ($account_manager as $user) { ?>
|
||||
<option value="<?= $user['email'];?>" data-id="<?= $user['id'] ?>"
|
||||
<?= ($acm_id == $user['id']) ? 'selected' : '' ?>>
|
||||
<?= $user['first_name'].' - '.$user['email'];?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="subject">Subject</label>
|
||||
<input type="text" class="form-control" id="placement_subject" name="placement_subject" value="<?= isset($placement_subject) ? $placement_subject : " " ?>" placeholder="Enter Subject">
|
||||
@ -727,7 +760,7 @@
|
||||
<hr>
|
||||
|
||||
<div class="form-group" id="placement_mail_attachment">
|
||||
<div class="form-row" >
|
||||
<div class="form-row attachmet_row" >
|
||||
<?php echo isset($attachment_html) && !empty($attachment_html) ? $attachment_html : ''; ?>
|
||||
</div>
|
||||
</div>
|
||||
@ -741,7 +774,7 @@
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<!-- Modal content for View Demography Mail -->
|
||||
<!-- Modal content for View Demography Modal -->
|
||||
<div class="modal fade" id="view_demography_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
aria-hidden="false">
|
||||
<div class="modal-dialog modal-full-width">
|
||||
@ -765,6 +798,31 @@
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<!-- Modal content for Other Docs Upload Modal -->
|
||||
<div class="modal fade" id="other_docs_upload_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
|
||||
aria-hidden="false">
|
||||
<div class="modal-dialog modal-full-width">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="docsCenterModalLabel">Documents</h4>
|
||||
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="multiFileForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="lead_id" value="<?= isset($lead_id) ? $lead_id : '' ?>">
|
||||
<input type="hidden" name="lead_form_type" value="1">
|
||||
<div id="multiFileAppendArea">
|
||||
<?php echo isset($multi_file_data_html) && !empty($multi_file_data_html) ? $multi_file_data_html : ''; ?>
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0 mt-3">
|
||||
<button type="submit" class="btn btn-primary">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
|
||||
<script>
|
||||
|
||||
var isFormDataModified = false;
|
||||
@ -948,6 +1006,8 @@
|
||||
placeholder: 'Select CC Mail',
|
||||
});
|
||||
|
||||
$('#acm_id').select2();
|
||||
|
||||
$('#proposals').select2({
|
||||
placeholder: 'Select proposal',
|
||||
});
|
||||
@ -1031,6 +1091,11 @@ $(document).ready(function () {
|
||||
} else {
|
||||
console.log("Lead status is 'won', submitData will not be called");
|
||||
}
|
||||
|
||||
<?php if (!isset($multi_file_data_html) || empty($multi_file_data_html)) : ?>
|
||||
addFileField();
|
||||
<?php endif; ?>
|
||||
|
||||
});
|
||||
|
||||
function startInterval() {
|
||||
@ -3964,8 +4029,10 @@ function constructURL_ForPlacementMailSend() {
|
||||
let insurer_and_branch = $('#proposals').val();
|
||||
let cc = $('#placement_cc').val();
|
||||
let no_of_installment = $('#no_of_installment').val();
|
||||
let tpa_id = $('#tpa_id').val();
|
||||
let acm_email = $('#acm_id').val();
|
||||
let acm_pk = $('#acm_id option:selected').data('id');
|
||||
let is_installment = $("#is_installment_switch").is(":checked") ? 1 : 0;
|
||||
console.log("cc1", cc);
|
||||
|
||||
// Process `to` field
|
||||
to = to.split(',').map(email => email.trim());
|
||||
@ -4025,6 +4092,9 @@ function constructURL_ForPlacementMailSend() {
|
||||
formData.append('installments', JSON.stringify(data));
|
||||
formData.append('no_of_installment', no_of_installment);
|
||||
formData.append('is_installment', is_installment);
|
||||
formData.append('tpa_id', tpa_id);
|
||||
formData.append('acm_email', acm_email);
|
||||
formData.append('acm_pk', acm_pk);
|
||||
|
||||
|
||||
ajaxRequest(formData);
|
||||
@ -6805,6 +6875,12 @@ function appendMultiFileData(data) {
|
||||
const myModal = new bootstrap.Modal(document.getElementById('view_demography_modal'));
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
function viewDocs(){
|
||||
// Show the modal
|
||||
const myModal = new bootstrap.Modal(document.getElementById('other_docs_upload_modal'));
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
@ -6819,4 +6895,178 @@ function appendMultiFileData(data) {
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
let fileIndex = 1;
|
||||
function addFileField() {
|
||||
|
||||
console.log('addFileField function called');
|
||||
|
||||
const container = document.getElementById('multiFileAppendArea');
|
||||
if (!container) return;
|
||||
|
||||
const div = document.createElement("div");
|
||||
div.className = "form-row d-flex align-items-end";
|
||||
div.setAttribute("id", `fileField_${fileIndex}`);
|
||||
|
||||
let isFirstField = container.childElementCount === 0; // Check if it's the first field
|
||||
let placeholder = isFirstField ? 'First file must be Demography.' : '';
|
||||
let accept = isFirstField ? '.xls,.xlsx' : '';
|
||||
|
||||
|
||||
if(isFirstField == 1){
|
||||
placeholder = '';
|
||||
accept = '';
|
||||
}
|
||||
|
||||
let sample_dwn_link = "";
|
||||
if(isFirstField == 1){
|
||||
sample_dwn_link = ' [ <a href="<?= base_url("util/download-excel/member_data"); ?>" id="excel_download" data-toggle="tooltip" data-placement="top" title="Download Sample Excel">Sample Excel</a> ]';
|
||||
}
|
||||
|
||||
|
||||
div.innerHTML = `
|
||||
<div class="form-group col-md-5">
|
||||
<label>Document Name ${sample_dwn_link}<span class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" name="docs_name[]" placeholder="${placeholder}">
|
||||
</div>
|
||||
<div class="form-group col-md-5">
|
||||
<label>File Upload<span class="text-danger"></span></label>
|
||||
<input type="file" class="form-control" id="file_name_${fileIndex}" name="file_name[]" accept="${accept}">
|
||||
</div>
|
||||
<div class="col-md-2" style="position: relative; bottom: 16px;">
|
||||
<button type="button" class="btn btn-danger" onclick="removeFileField(${fileIndex})">x</button>
|
||||
<button type="button" class="btn btn-primary" onclick="addFileField()">+</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
container.appendChild(div);
|
||||
fileIndex++;
|
||||
}
|
||||
|
||||
function removeFileField(index, lead_file_id = null) {
|
||||
|
||||
if(index == 1){
|
||||
toastr.warning("You can't remove the first file field", 'WARNING');
|
||||
return false;
|
||||
}
|
||||
|
||||
if(lead_file_id != null) {
|
||||
|
||||
Swal.fire({
|
||||
title: "Do you want to remove this file?",
|
||||
// text: "Do you want Save this!",
|
||||
icon: "warning",
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: "#3085d6",
|
||||
cancelButtonColor: "#d33",
|
||||
confirmButtonText: "Yes, Procced!"
|
||||
}).then((result) => {
|
||||
|
||||
if (result.isConfirmed) {
|
||||
|
||||
let url = '<?= base_url('util/removeMultiFile') ?>';
|
||||
|
||||
let requestData = {
|
||||
lead_file_id: lead_file_id
|
||||
};
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status == true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
|
||||
//remove the file field
|
||||
const field = document.getElementById(`fileField_${index}`);
|
||||
if(index != 1){
|
||||
if (field) field.remove();
|
||||
}
|
||||
|
||||
} else {
|
||||
toastr.error(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
||||
});
|
||||
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}else{
|
||||
const field = document.getElementById(`fileField_${index}`);
|
||||
if(index != 1){
|
||||
if (field) field.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function showFileName(input, index) {
|
||||
if (input.files.length > 0) {
|
||||
document.getElementById(`file_name_display_${index}`).textContent = input.files[0].name;
|
||||
} else {
|
||||
document.getElementById(`file_name_display_${index}`).textContent = "No file chosen";
|
||||
}
|
||||
}
|
||||
|
||||
// Submit form
|
||||
$("#multiFileForm").on("submit", function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
let formData = new FormData(this);
|
||||
|
||||
// Show loader
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
$.ajax({
|
||||
url: "<?= base_url('util/uploadMultiFileFromRfq'); ?>",
|
||||
type: "POST",
|
||||
data: formData,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (res) {
|
||||
|
||||
console.log('uploadMultiFileFromRfq reponse', res);
|
||||
|
||||
if(res.status == true){
|
||||
toastr.success(res.message, 'SUCCESS');
|
||||
$('#multiFileAppendArea').empty();
|
||||
$('.attachmet_row').empty();
|
||||
$('#multiFileAppendArea').append(res.document_data);
|
||||
$('.attachmet_row').html(res.attachment_html);
|
||||
}else{
|
||||
toastr.warning(res.message, 'WARNING');
|
||||
}
|
||||
|
||||
// Hide loader
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
$('.close').click();
|
||||
|
||||
},
|
||||
error: function (xhr) {
|
||||
console.error("Upload error:", xhr.responseText);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
BIN
public/sample_excel/Sample_Member_Data_1.xlsx
Normal file
BIN
public/sample_excel/Sample_Member_Data_1.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user