FEAT_RFQ_NEW_REQ_SRI

This commit is contained in:
Srinivas-Saravanan 2025-04-08 14:08:54 +05:30
parent dffc1a8508
commit cad50efdf2
9 changed files with 384 additions and 114 deletions

View File

@ -23,6 +23,8 @@ class EcardDownloadConversation extends Conversation
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
$buttons = [];
$question = 'Choose Policy to Download Ecard:';
log_message('error', ('policy_list : ' . json_encode($policy_list)));
if(is_array($policy_list) && count($policy_list))
{
foreach($policy_list as $policy)

View File

@ -53,6 +53,8 @@ class MainMenuConversation extends Conversation
$user_reponse = null;
}
log_message('error', ('user_reponse is interactive: ' . $answer->isInteractiveMessageReply()));
// Get just the existing path array
$path = $this->bot->userStorage()->get('path') ?? [];
@ -65,28 +67,35 @@ class MainMenuConversation extends Conversation
'path' => $path
]);
log_message('error', ('user_reponse : ' . $user_reponse));
log_message('error', ('user_reponse after: ' . $user_reponse));
switch ($user_reponse) {
case "ecard_download":
$this->bot->startConversation(new EcardDownloadConversation());
log_message('error', 'ecard_download clicked ');
break;
case "network_hospital":
$this->bot->startConversation(new NetworkHospitalConversation());
log_message('error', 'network_hospital clicked ');
break;
case "reimbursement_claim":
$this->bot->startConversation(new ReimbursementClaimProcessConversation());
log_message('error', 'reimbursement_claim clicked ');
break;
case "reimbursement_status":
$this->bot->startConversation(new ReimbursementClaimStatusConversation());
log_message('error', 'reimbursement_status clicked ');
break;
case "new_policy":
case "renew_policy":
$this->bot->startConversation(new policyConversation());
log_message('error', 'renew_policy || new_policy clicked ');
break;
default:
log_message('error', 'default shown ');
$this->say("Invalid selection. Please choose an option.");
$this->bot->startConversation(new MainMenuConversation());
break;

View File

@ -84,6 +84,7 @@ class ChatbotControllerNew extends BaseController
public function index()
{
if($this->session->get('CHATBOT_RANDOM_USER_ID') == '-' || $this->session->get('CHATBOT_RANDOM_USER_ID') == '')
{
@ -100,6 +101,7 @@ class ChatbotControllerNew extends BaseController
}
$this->botman->hears('.*', function ($bot) {
log_message("error","Inside Bot Type Function");
$bot->types(); // Typing indicator for the first message
sleep(0.5); // Delay

View File

@ -40,6 +40,7 @@ use Kint\Kint;
use App\Controllers\Jobs;
use App\Controllers\JobWorker;
use Google\Service\FactCheckTools\Resource\Claims;
use GPBMetadata\Google\Type\Datetime;
class LeadsController extends BaseController
{
@ -646,6 +647,7 @@ class LeadsController extends BaseController
$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;
$mail_content = "
@ -654,18 +656,32 @@ class LeadsController extends BaseController
<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>
<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>Email: {{LOGGED_USER_EMAIL}}</div>
<div>Mobile: {{LOGGED_USER_MOBILE}}</div>
</div>
";
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}}";
$subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}";
}
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
$data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']);
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? 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) {
@ -880,7 +896,7 @@ class LeadsController extends BaseController
if ($rfq_data['policy_type_id'] == 2) {
$lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'Policy Status' => $rfq_data['status'],
@ -893,6 +909,7 @@ class LeadsController extends BaseController
];
} else if ($rfq_data['policy_type_id'] == 1) {
$lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
@ -905,6 +922,7 @@ class LeadsController extends BaseController
} else {
if ($rfq_data['policy_type_id'] == 2) {
$lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'Policy Status' => $rfq_data['status'],
@ -933,6 +951,7 @@ class LeadsController extends BaseController
];
} else if ($rfq_data['policy_type_id'] == 1) {
$lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
@ -1300,9 +1319,25 @@ class LeadsController extends BaseController
],
]);
// Set filename
$string = ($type == 2) ? 'QCR' : 'RFQ';
$filename = "{$string}_{$rfq_data['client_short_name']}_{$rfq_data['policy_type']}_" . date('YmdHis') . '.xlsx';
$current_year = date('Y');
$next_year = $current_year + 1;
$policy_year = "$current_year-$next_year";
if (!empty($rfq_data['policy_end_date'])){
$policy_expiry = strtotime($lead_data['policy_end_date']);
$formatted_policy = date("d-m-Y",$policy_expiry);
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" .$policy_year.'(Due On '.$formatted_policy . ')' .'.xlsx';
}else{
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_".$policy_year.'_' . '.xlsx';
}
// Save to temporary location
$uploadFilePath = WRITEPATH . 'tmp/' . $filename;
@ -1927,13 +1962,20 @@ class LeadsController extends BaseController
// print_r($recipient_data); die;
} else if ($recipient_type == 'client') {
$recipient_data = [['name' => $lead_data['contact_person_name'], 'email' => $lead_data['contact_person_email']]];
$mailIDS = explode(',',$params['contact_mail']);
$recipient_data = [];
foreach ($mailIDS as $mail){
$recipient_data[] = ['name' => $lead_data['contact_person_name'], 'email' => $mail];
}
} else {
$recipient_data = [['name' => "Team", 'email' => $params['to']]];
}
// print_r($recipient_data); die;
$subject = $file_type == 'rfq' ? 'Request for Quotation from ' . $lead_data['client_name'] . ' for ' . $lead_data['policy_type'] : 'Quotation Comparison Report for ' . $lead_data['policy_type'];
$original_message = '<div style="width:100%;max-width:600px;margin:0 auto;padding:20px;border:1px solid #e0e0e0;background-color:#f9f9f9;font-family:Arial,sans-serif;color:#333;line-height:1.6"><div style=background-color:#4a90e2;color:#fff;padding:15px;text-align:center><h1 style=margin:0;font-size:24px>Request for Quotation (RFQ)</h1></div><div style=padding:20px;background-color:#fff><h2 style=color:#4a90e2;font-size:20px;margin-top:0>Dear {{RECIPIENT_NAME}},</h2><p>We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.<h2 style=color:#4a90e2;font-size:20px;margin-top:20px>RFQ Details</h2><table style=width:100%;border-collapse:collapse;margin-top:20px><tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Client name<td style="border:1px solid #ddd;padding:10px;text-align:left">{{CLIENT_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Coverage Type<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_LONG_NAME}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Start Date<td style="border:1px solid #ddd;padding:10px;text-align:left">{{POLICY_START_DATE}}<tr><th style="border:1px solid #ddd;padding:10px;text-align:left;background-color:#f2f2f2">Policy Duration<td style="border:1px solid #ddd;padding:10px;text-align:left">{{DURATION}}</table><div style="margin-top:20px;padding:10px;background-color:#f7f7f7;border-left:4px solid #4a90e2;font-style:italic">Please note: Additional terms and details are included in the attachment for your reference.</div><p>Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.<p>Best regards,<p><strong>Nhance India Pvt Ltd</strong><br></div><div style=margin-top:20px;font-size:12px;color:#777;text-align:center><p>© Nhance India Pvt Ltd. All rights reserved.</div></div>';
//for mail content
@ -1982,7 +2024,9 @@ class LeadsController extends BaseController
'proposel_data' => json_encode($lead_update_data),
'status' => 'won',
'placement_date' => change_date_format($params['placement_date'], 'd/m/Y', 'Y-m-d'),
'payment_date' => change_date_format($params['payment_date'], 'd/m/Y', 'Y-m-d'),
'utr_no' => $params['utr_no'],
'is_cd' => $params['is_cd'],
'premium_amount' => $params['premium_amount'],
'total_amount' => $params['total_amount'],
'cd_amount' => $params['cd_amount'],
@ -2629,6 +2673,13 @@ class LeadsController extends BaseController
$next_year = $current_year + 1;
$policy_year = "$current_year-$next_year";
$policy_expiry = strtotime($lead_data['policy_end_date']);
$formatted_policy = date("d-m-Y",$policy_expiry);
$logged_user_id = get_session_userid();
$logged_user_data = $this->userModel->where("id",$logged_user_id)->where("is_active",1)->first();
if ($lead_data) {
// Replacing placeholders with actual values
@ -2638,6 +2689,11 @@ class LeadsController extends BaseController
$message = str_replace("{{POLICY_TYPE}}", $lead_data['policy_type'] ?? "Insurance Policy", $message);
$message = str_replace("{{RFQ_OR_QCR}}", $page_name, $message);
$message = str_replace("{{POLICY_YEAR}}", $policy_year, $message);
$message = str_replace("{{POLICY_END_DATE}}"," (Due On ".$formatted_policy.")",$message);
$message = str_replace("{{LOGGED_USER_NAME}}",ucfirst($logged_user_data['first_name'])." ".ucfirst($logged_user_data['last_name']),$message);
$message = str_replace("{{LOGGED_USER_EMAIL}}",$logged_user_data['email'],$message);
$message = str_replace("{{LOGGED_USER_MOBILE}}",$logged_user_data['mobile'],$message);
return $message;
} else {
@ -2645,6 +2701,7 @@ class LeadsController extends BaseController
}
}
function getLastFiveFinancialYears()
{
$currentYear = date('Y');

View File

@ -87,6 +87,8 @@ class LeadsModel extends Model
'lead_form_type',
'custom_fields',
'payment_date',
'is_cd'
];

View File

@ -134,5 +134,20 @@ class UserModel extends Model
->getResultArray();
}
public function getexclusiveUserListForRFQ(){
$data = $this->db->table('user_profiles')
->select('user_profiles.*,user_teams.team_id')
->select('roles.role as user_role')
->join('roles', 'roles.id = user_profiles.role')
->join('user_teams', 'user_teams.user_id = user_profiles.id')
->get()
->getResultArray();
// dd($data);
return $data;
}
}
?>

View File

@ -41,7 +41,7 @@
origin: "mobile", // origin
emp_code:"HTL-007",
client_id:159,
client_branch_id:125
client_branch_id:126
}
};

View File

@ -80,6 +80,9 @@
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>
<!-- srinivas -->
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>
<script src="https://editor.unlayer.com/embed.js"></script>
<!-- MD5 Hash Start -->

View File

@ -225,12 +225,15 @@
<button id="addQuote" class="btn btn-custom">Add New Proposal</button>
<button id="submitData" class="btn btn-primary">Save RFQ</button>
<?php if (in_array(get_role_id(), [1,2,3,5]) || in_array(BUSINESS_SUPPORT_TEAM_ID, user_team())) { ?>
<?php if (in_array(get_role_id(), [1,2,5]) || in_array(BUSINESS_SUPPORT_TEAM_ID, user_team())) { ?>
<button id="submitQCRData" onclick="checkTheTableDataChanged(5)" class="btn btn-primary">Procced to QCR</button>
<?php } ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary" id>Export Excel</a>
<button id="submitInternalMail" class="btn btn-primary" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button>
<button id="submitMail" class="btn btn-primary" onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button>
<?php if (get_role_id() == 1 || in_array($user_team,[6,7])) { ?>
<button id="submitMail" class="btn btn-primary"
onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button>
<?php } ?>
<button id="submitPlacement" class="btn btn-primary" onclick="checkTheTableDataChanged(6)">Placement</button>
<input type="hidden" id="lead_id" name="lead_id" value="<?= isset($lead_id) ? $lead_id : '' ?>">
<input type="hidden" id="qcr_count" value="<?= isset($qcr_count) ? $qcr_count : 0 ?>">
@ -421,12 +424,15 @@
<div class="form-group col-md-4">
<label for="cc">CC </label>
<select class="form-control" id="cc" name="cc" required multiple>
<?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?>
<?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php if (isset($exclusiveUserList)) { ?>
<?php foreach ($exclusiveUserList as $user) { ?>
<?php if ($page_name == "RFQ" || in_array($user['role'],[1,5]) || in_array($user['team_id'],[6,7])) { ?>
<option value="<?= $user['id'];?>">
<?= $user['first_name'].' - '.$user['email'];?>
</option>
<?php } ?>
<?php } ?>
<?php } ?>
</select>
</div>
@ -484,30 +490,45 @@
<div class="form-row">
<div class="form-group col-md-3">
<label for="payment_date">Payment Date</label>
<input type="text" class="form-control" id="payment_date" name="payment_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['payment_date']) ? date('d/m/Y', strtotime($lead_data['payment_date'])) : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="utr_no">UTR No.</label>
<input type="text" class="form-control" id="utr_no" name="utr_no" placeholder="Enter UTR No.">
<input type="text" class="form-control" id="utr_no" name="utr_no" placeholder="Enter UTR No." value="<?= isset($lead_data['utr_no']) ? $lead_data['utr_no'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="placement_date">Placement Date</label>
<input type="text" class="form-control" id="placement_date" name="placement_date" placeholder="DD/MM/YYY">
<input type="text" class="form-control" id="placement_date" name="placement_date" placeholder="DD/MM/YYY" value="<?= isset($lead_data['placement_date']) ? date('d/m/Y', strtotime($lead_data['placement_date'])) : "" ?>">
</div>
<div class="form-group col-md-3">
<label style = "padding-left: 15px;padding-top: 33px;" for="is_cd_switch">CD </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="dark" data-style="border" data-width="150" <?= 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>
<input type="text" class="form-control" id="premium_amount" name="premium_amount" placeholder="Enter Premium Amount">
<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'])) { ?>
<div class="form-group col-md-3">
<label for="cd_amount">CD Amount</label>
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="total_amount">Total Amount</label>
<input type="text" class="form-control" id="total_amount" name="total_amount" placeholder="Enter Total Amount">
<input type="text" class="form-control" id="total_amount" name="total_amount" placeholder="Enter Total Amount" value="<?= isset($lead_data['cd_amount']) ? $lead_data['cd_amount'] : "" ?>">
</div>
<div class="form-group col-md-3">
<label for="cd_amount">CD Amount</label>
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount">
</div>
<?php } ?>
</div>
<hr>
@ -530,12 +551,15 @@
<div class="form-group col-md-6">
<label for="placement_cc">CC </label>
<select class="form-control" id="placement_cc" name="placement_cc" required multiple>
<?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?>
<?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php if (isset($exclusiveUserList)) { ?>
>
<?php foreach ($exclusiveUserList as $user) { ?>
<?php if ($page_name == "RFQ" || in_array($user['role'],[1,5]) || in_array($user['team_id'],[6,7])) { ?>
<option value="<?= $user['id'];?>">
<?= $user['first_name'].' - '.$user['email'];?>
</option>
<?php } ?>
<?php } }?>
<?php } ?>
</select>
</div>
@ -797,6 +821,11 @@
allowInput: false,
});
var payment_date_datePicker = flatpickr("#payment_date", {
dateFormat: "d/m/Y",
allowInput: false,
});
})
@ -830,6 +859,24 @@ var over_all_column_data = {
'insurers': []
}
};
document.addEventListener('DOMContentLoaded', function () {
const textarea = document.getElementById('placement_mail_content');
const textarea2 = document.getElementById("placement_subject");
if (textarea) {
let content = textarea.value;
if (content.includes('QCR')) {
textarea.value = content.replace(/QCR/g, 'Placement');
}
}
if (textarea2){
let content = textarea2.value;
if (content.includes('QCR')) {
textarea2.value = content.replace(/QCR/g, 'Placement');
}
}
});
// document.addEventListener("DOMContentLoaded", function () {
const rfqTable = document.getElementById('rfqTable');
@ -1283,19 +1330,34 @@ function moveAddRowButton() {
rfqTable.addEventListener('click', function(e) {
if (e.target.classList.contains('removeRow')) {
const row = e.target.closest('tr'); // Get the row to be removed
const rowKey = row.getAttribute('id');
Swal.fire({
title: 'Are you sure?',
text: "Do you want to remove the row?",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: 'Yes, remove it!',
cancelButtonText: 'Cancel'
}).then((result) => {
if (result.isConfirmed) {
const row = e.target.closest('tr'); // Get the row to be removed
const rowKey = row.getAttribute('id');
console.log(suggestionKeys);
// Remove the key from suggestionKeys
suggestionKeys = suggestionKeys.filter(key => key !== rowKey);
row.remove();
console.log(suggestionKeys);
updateRowNumbers(); // Update row numbers
moveAddRowButton(); // Move the add row button to the last row
realignSpecialConditions();
console.log(suggestionKeys);
// Remove the key from suggestionKeys
suggestionKeys = suggestionKeys.filter(key => key !== rowKey);
row.remove();
console.log(suggestionKeys);
updateRowNumbers(); // Update row numbers
moveAddRowButton(); // Move the add row button to the last row
realignSpecialConditions();
isFormDataModified = true; // if any value changeing in the table to set true
isFormDataModified = true; // if any value changeing in the table to set true
}
})
}
});
@ -1441,7 +1503,6 @@ function showSuggestions(input) {
// Function to handle answers suggestion box
function showAnswersSuggestions(input) {
console.log(input.parentElement.id);
console.log(input);
//return;
@ -2142,7 +2203,17 @@ function removeProposal(event) {
let rfqTable = document.getElementById('rfqTable');
console.log(rfqTable)
if (confirm("Are you sure you want to remove this column?")) {
Swal.fire({
title: 'Are you sure?',
text: "Do you want to remove the Proposal?",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: 'Yes, remove it!',
cancelButtonText: 'Cancel'
}).then((result) => {
if (result.isConfirmed) {
const headerRows = rfqTable.querySelectorAll('thead tr');
const parentTh = headerRows[0].children[colIndex];
@ -2187,69 +2258,83 @@ function removeProposal(event) {
console.log(`${proposal_name} does not exist.`);
}
}
})
}
function removeInsurer(event) {
if (confirm("Are you sure you want to remove this column?")) {
// function removeSubColumnByIndex(tableId, subThIndex) {
const table = document.getElementById('rfqTable');
const headerRows = table.querySelectorAll('thead tr');
Swal.fire({
title: 'Are you sure?',
text: "Do you want to remove the insurer?",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: 'Yes, remove it!',
cancelButtonText: 'Cancel'
}).then((result) => {
if (result.isConfirmed) {
// function removeSubColumnByIndex(tableId, subThIndex) {
const table = document.getElementById('rfqTable');
const headerRows = table.querySelectorAll('thead tr');
const closestTh = event.target.closest('th');
let insurerName = closestTh.innerText.split('⋮')[0]
// alert(insurerName);return;
let subThIndex = closestTh.cellIndex;
console.log('subThIndex', subThIndex);
const closestTh = event.target.closest('th');
let insurerName = closestTh.innerText.split('⋮')[0]
// alert(insurerName);return;
let subThIndex = closestTh.cellIndex;
console.log('subThIndex', subThIndex);
// Get the sub TH from the second header row
const subTh = headerRows[1].children[subThIndex];
console.log('subTh', subTh);
// Get the sub TH from the second header row
const subTh = headerRows[1].children[subThIndex];
console.log('subTh', subTh);
let accumulatedColspan = 0;
let parentTh = null;
const firstHeaderRow = headerRows[0];
// Find the parent TH for the specified sub TH index
for (let i = 0; i < firstHeaderRow.children.length; i++) {
const currentParentTh = firstHeaderRow.children[i];
const currentColspan = parseInt(currentParentTh.getAttribute('colspan')) || 1;
let accumulatedColspan = 0;
let parentTh = null;
const firstHeaderRow = headerRows[0];
// Find the parent TH for the specified sub TH index
for (let i = 0; i < firstHeaderRow.children.length; i++) {
const currentParentTh = firstHeaderRow.children[i];
const currentColspan = parseInt(currentParentTh.getAttribute('colspan')) || 1;
accumulatedColspan += currentColspan;
accumulatedColspan += currentColspan;
if (subThIndex < accumulatedColspan) {
parentTh = currentParentTh;
break;
if (subThIndex < accumulatedColspan) {
parentTh = currentParentTh;
break;
}
}
console.log('parentth' + parentTh);
console.log('sub col indexOf' + subThIndex);
// Get the starting position of the sub TH
const startIndex = Array.from(headerRows[1].children).indexOf(subTh);
// Remove the sub TH
headerRows[1].removeChild(subTh);
// Reduce colspan of parent TH
const parentColspan = parseInt(parentTh.getAttribute('colspan')) || 1;
console.log('existing colspan' + parentColspan);
parentTh.setAttribute('colspan', parentColspan - 1);
console.log('new colspan' + (parentColspan - 1));
// Remove the corresponding TDs from each row
table.querySelectorAll('tbody tr').forEach(row => {
row.removeChild(row.children[startIndex]);
});
removeInsurerFromPremiumTable(event, subThIndex)
//remove the insurer from gobal array
let proposal_name = parentTh.innerText.split('⋮')[0];
popInsurerInArray(proposal_name, insurerName);
isFormDataModified = true; // if any value changeing in the table to set true
}
}
console.log('parentth' + parentTh);
console.log('sub col indexOf' + subThIndex);
// Get the starting position of the sub TH
const startIndex = Array.from(headerRows[1].children).indexOf(subTh);
// Remove the sub TH
headerRows[1].removeChild(subTh);
// Reduce colspan of parent TH
const parentColspan = parseInt(parentTh.getAttribute('colspan')) || 1;
console.log('existing colspan' + parentColspan);
parentTh.setAttribute('colspan', parentColspan - 1);
console.log('new colspan' + (parentColspan - 1));
// Remove the corresponding TDs from each row
table.querySelectorAll('tbody tr').forEach(row => {
row.removeChild(row.children[startIndex]);
});
removeInsurerFromPremiumTable(event, subThIndex)
//remove the insurer from gobal array
let proposal_name = parentTh.innerText.split('⋮')[0];
popInsurerInArray(proposal_name, insurerName);
isFormDataModified = true; // if any value changeing in the table to set true
}
})
}
function showThreeDottedMenu(event) {
@ -2739,8 +2824,8 @@ function handleChildQuestions(target) {
let childCell = childRow.cells[currentColumnIndex];
if (childCell) {
console.log('found cell');
console.log('found cell',inputValue);
if (inputValue.key == disable_at.key) {
childCell.innerHTML = '';
childCell.innerText = '';
@ -2759,6 +2844,21 @@ function handleChildQuestions(target) {
console.log(child.default_answer.display_value)
childCell.contentEditable = false;
} else {
childCell.innerHTML = '';
childCell.innerText = '';
//hidden text box for store choosed answers object
const hiddenInputBox = document.createElement('input');
hiddenInputBox.type = 'hidden';
hiddenInputBox.value = JSON.stringify(inputValue.display_value);
childCell.appendChild(hiddenInputBox);
// alert(input.innerText);
childCell.appendChild(document.createTextNode(inputValue.display_value));
// Set the default answer in the child cell
// childCell.innerHTML = child.default_answer.display_value;
// console.log('setting default value');
// console.log(child.default_answer.display_value)
childCell.contentEditable = true;
}
}
@ -3136,7 +3236,7 @@ function ajaxRequestForGetMailData(url) {
function appendInput(data) {
console.log(data);
console.log("append data:",data);
var lead_id = $('#lead_id').val();
$('#input_for_row').empty();
let html = '';
@ -3146,9 +3246,9 @@ function appendInput(data) {
const url = '<?= base_url('leads/list') ?>?lead_id=' + lead_id;
html += `
<div class="form-group col-md-4">
<div class="form-group col-md-12">
<label for="contact_mail">Client Contact Mail</label>
<input value="${data.contact_person_email || ''}" type="text" id="contact_mail" class="form-control" placeholder="Contact Mail" readonly>
<input value="${data.contact_person_email || ''}" type="text" id="contact_mail" class="form-control" placeholder="Contact Mail">
</div>
`;
@ -3164,29 +3264,33 @@ function appendInput(data) {
html += `
<div class="form-group col-md-4">
<div class="form-group col-md-6">
<label for="client_cc">CC </label>
<select class="form-control" id="client_cc" name="client_cc" required multiple>
<?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?>
<?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php if (isset($exclusiveUserList)) { ?>
<?php foreach ($exclusiveUserList as $user) { ?>
<?php if ($page_name == "RFQ" || in_array($user['role'],[1,5]) || in_array($user['team_id'],[6,7])) { ?>
<option value="<?= $user['id'];?>">
<?= $user['first_name'].' - '.$user['email'];?>
</option>
<?php } ?>
<?php } } ?>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<div class="form-group col-md-6">
<label for="client_bcc">BCC </label>
<select class="form-control" id="client_bcc" name="client_bcc" required multiple>
<?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?>
<?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php if (isset($exclusiveUserList)) { ?>
<?php foreach ($exclusiveUserList as $user) { ?>
<?php if ($page_name == "RFQ" || in_array($user['role'],[1,5]) || in_array($user['team_id'],[6,7])) { ?>
<option value="<?= $user['id'];?>">
<?= $user['first_name'].' - '.$user['email'];?>
</option>
<?php } ?>
<?php } ?>
<?php } } ?>
<?php } ?>
</select>
</div>
`;
@ -3196,7 +3300,7 @@ function appendInput(data) {
html += `
<div class="form-group col-md-12">
<label for="mail_subject">Subject</label>
<input type="text" id="mail_subject" class="form-control" value="'<?= isset($subject) ? $subject : " " ?>'" placeholder="Subject">
<input type="text" id="mail_subject" class="form-control" value="<?= isset($subject) ? $subject : " " ?>" placeholder="Subject">
</div>
`;
@ -3229,25 +3333,28 @@ function appendInput(data) {
<div class="form-group col-md-4">
<label for="client_cc">CC </label>
<select class="form-control" id="client_cc" name="client_cc" required multiple>
<?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?>
<?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php if (isset($exclusiveUserList)) { ?>
<?php foreach ($exclusiveUserList as $user) { ?>
<?php if ($page_name == "RFQ" || in_array($user['role'],[1,5]) || in_array($user['team_id'],[6,7])) { ?>
<option value="<?= $user['id'];?>">
<?= $user['first_name'].' - '.$user['email'];?>
</option>
<?php } ?>
<?php } ?>
<?php } }?>
</select>
</div>
<div class="form-group col-md-4">
<label for="client_bcc">BCC </label>
<select class="form-control" id="client_bcc" name="client_bcc" required multiple>
<?php if (isset($userList)) { ?>
<?php foreach ($userList as $user) { ?>
<option value="<?= $user['id'];?>">
<?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php if (isset($exclusiveUserList)) { ?>
<?php foreach ($exclusiveUserList as $user) { ?>
<?php if ($page_name == "RFQ" || in_array($user['role'],[1,5]) || in_array($user['team_id'],[6,7])) { ?>
<?= $user['first_name'].' - '.$user['email'];?>
</option>
<?php } ?>
<?php } } ?>
<?php } ?>
</select>
</div>
@ -3307,7 +3414,13 @@ function appendInput(data) {
function constructURL(url_type) {
if(url_type == 1){
constructURL_ForInsurerAndClientMailSend()
var validationStatus = checkMailValidation();
if (validationStatus){
constructURL_ForInsurerAndClientMailSend();
}else{
toastr.error("All Client Mail ID's Should Contain Same Domain","ERROR");
}
}else if(url_type == 2){
constructURL_ForInternalMailSend()
}else if(url_type == 3){
@ -3470,6 +3583,7 @@ function constructURL_ForInsurerAndClientMailSend() {
var subject = $('#mail_subject').val();
var bcc = $('#client_bcc').val();
var cc = $('#client_cc').val();
var contact_mail = $("#contact_mail").val();
console.log('lead_id', lead_id)
console.log('subject', subject)
@ -3501,6 +3615,7 @@ function constructURL_ForInsurerAndClientMailSend() {
if (RFQ_or_QCR == 2) {
formData.append('contact_mail',contact_mail);
formData.append('file_type', 'qcr');
formData.append('recipient_type', 'client');
formData.append('recipient_mail', '');
@ -3560,6 +3675,8 @@ function constructURL_ForPlacementMailSend() {
var lead_id = $('#lead_id').val();
let to = $('#placement_to').val();
let placement_date = $('#placement_date').val();
let payment_date = $('#payment_date').val();
let is_cd = $("#is_cd_switch").is(":checked") ? 1 : 0;
let utr_no = $('#utr_no').val();
let premium_amount = $('#premium_amount').val();
let total_amount = $('#total_amount').val();
@ -3590,6 +3707,8 @@ function constructURL_ForPlacementMailSend() {
formData.append('proposal_insurer', proposal_insurer);
formData.append('insurer_and_branch', insurer_and_branch);
formData.append('placement_date', placement_date);
formData.append('payment_date', payment_date);
formData.append("is_cd",is_cd);
formData.append('utr_no', utr_no);
formData.append('premium_amount', premium_amount);
formData.append('total_amount', total_amount);
@ -3661,7 +3780,7 @@ function ajaxRequest(formData) {
$('#placement_cc').val('').select2({
placeholder : 'select CC Mail'
});
$('#placement_subject').val('');
// $('#placement_subject').val('');
$("textarea.select2-search__field").attr('rows', '1');
$("textarea.select2-search__field").css('resize', 'none');
@ -3738,7 +3857,7 @@ $('.close').click(function(){
$('#placement_cc').val('').select2({
placeholder : 'select CC Mail'
});
$('#placement_subject').val('');
// $('#placement_subject').val('');
$("textarea.select2-search__field").attr('rows', '1');
$("textarea.select2-search__field").css('resize', 'none');
@ -5733,4 +5852,65 @@ function appendMultiFileData(data) {
}
$("#is_cd_switch").change(function (){
var switch_status = ($("#is_cd_switch").is(":checked")? "on" : "off");
console.log("Switch status",switch_status);
if (switch_status == "on"){
$("#cd_amount").show();
$("#total_amount").show();
$("#cd_amount").closest('.form-group').show();
$("#total_amount").closest('.form-group').show();
}else{
$("#cd_amount").hide();
$("#total_amount").hide();
$("#cd_amount").closest('.form-group').hide();
$("#total_amount").closest('.form-group').hide();
}
})
$(document).on("input", "#cd_amount, #premium_amount", function() {
// alert("Function called");
var cd_amount = parseInt($("#cd_amount").val()) || 0;
var premium_amount = parseInt($("#premium_amount").val()) || 0;
var total_amount = (cd_amount + premium_amount);
$("#total_amount").val(total_amount);
});
function checkMailValidation(){
emailString = $("#contact_mail").val();
if (RFQ_or_QCR == 1){
if (typeof emailString !== 'string' || !emailString.includes(',')) return true;
}else{
if (typeof emailString !== 'string') return false;
}
const invalidChars = /[;|]/;
if (invalidChars.test(emailString)) return false;
const emails = emailString.split(',').map(email => email.trim());
if (emails.length === 0) return false;
const getDomain = email => email.split('@')[1]?.toLowerCase();
const firstDomain = getDomain(emails[0]);
if (!firstDomain) return false;
return emails.every(email => getDomain(email) === firstDomain);
}
</script>