MERGE_TEST_RFQ_ISSUE/ADD_REQ

This commit is contained in:
Ubuntu 2025-04-08 17:23:39 +05:30
commit 3d35fc4dfd
17 changed files with 1115 additions and 307 deletions

View File

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

View File

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

View File

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

View File

@ -1994,9 +1994,22 @@ class ClientController extends AdminController
if ($id) { if ($id) {
$client_policy_data = $this->clientPolicyModel->where(['id' => $id, 'is_active' => 1])->first(); $client_policy_data = $this->clientPolicyModel->where(['id' => $id, 'is_active' => 1])->first();
$insurer_id = $client_policy_data['insurer_id']; $insurer_id = $client_policy_data['insurer_id'];
$client_id = $client_policy_data['client_id']; $client_id = $client_policy_data['client_id'];
if (!empty($client_policy_data['policy_start_date'])) {
$client_policy_data['source_policy_start_date'] = change_date_format($client_policy_data['policy_start_date'], 'Y-m-d', 'd/m/Y');
} else {
$client_policy_data['source_policy_start_date'] = null;
}
if (!empty($client_policy_data['policy_end_date'])) {
$client_policy_data['source_policy_end_date'] = change_date_format($client_policy_data['policy_end_date'], 'Y-m-d', 'd/m/Y');
} else {
$client_policy_data['source_policy_end_date'] = null;
}
$polices = $this->policesModel $polices = $this->policesModel
->select('policies.*, policy_type.policy_type') ->select('policies.*, policy_type.policy_type')
->join('policy_type', 'policy_type.id = policies.policy_type_id') ->join('policy_type', 'policy_type.id = policies.policy_type_id')
@ -2022,7 +2035,7 @@ class ClientController extends AdminController
'policy' => $polices, 'policy' => $polices,
'client_policy_list' => $client_policy_list, 'client_policy_list' => $client_policy_list,
'end_date' => $newDate, 'end_date' => $newDate,
'new_start_date' => date('d/m/Y', strtotime($client_policy_data['policy_end_date'])) 'new_start_date' => date('d/m/Y', strtotime($client_policy_data['policy_end_date'] . ' +1 day')),
], 200); ], 200);
} else { } else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200); return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
@ -4740,8 +4753,7 @@ class ClientController extends AdminController
// } // }
// $data = $this->leadsModel->where('leads.id', 125)->where('leads.is_active', 1)->first(); // $data = $this->leadsModel->where('leads.id', 125)->where('leads.is_active', 1)->first();
// $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(125, 2); // $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(145, 2);
// // Kint::dump($RFQdata);
// $returnData = $LeadsController->getPlacementJson($data); // $returnData = $LeadsController->getPlacementJson($data);
// Kint::dump($returnData); // Kint::dump($returnData);
// $policy_terms = $LeadsController->convertNonEbQCRJsonToPolicyTerms(json_decode($returnData, true)); // $policy_terms = $LeadsController->convertNonEbQCRJsonToPolicyTerms(json_decode($returnData, true));
@ -4751,6 +4763,20 @@ class ClientController extends AdminController
// $this->clientPolicyModel->where('id', 6050)->set('policy_terms', $policy_terms)->update(); // $this->clientPolicyModel->where('id', 6050)->set('policy_terms', $policy_terms)->update();
// dd($returnData); // dd($returnData);
// Kint::dump($RFQdata['json']);
// $inputJson = json_decode($RFQdata['json'], true);
// Kint::dump($inputJson);
// // print_rr($inputJson['table_data']);
// $sortedJson = $this->reorderProposalsByInsurerTotal($inputJson);
// // If you want to convert back to JSON string
// $finalJson = json_encode($sortedJson, JSON_PRETTY_PRINT);
// // $RFQModel->insert(['lead_id' => 145, 'json' => $finalJson, 'type' => 1]);
// dd($finalJson);
} }
// ------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------
@ -5457,5 +5483,206 @@ class ClientController extends AdminController
return $id; return $id;
} }
private function reorderProposalsByInsurerTotal(array $data): array {
Kint::dump($data);
if (!isset($data['premium_data']['data'])) return $data;
$original = $data['premium_data']['data'];
$proposals = [];
$others = [];
$emptyKeyData = [];
foreach ($original as $key => $value) {
// Match only keys that look like 'Proposal X'
if (preg_match('/^Proposal\s+\d+$/', $key)) {
// Get the insurer entry (not 'Quote Asked')
foreach ($value as $subKey => $subVal) {
if ($subKey !== 'Quote Asked' && isset($subVal['Total'])) {
$proposals[$key] = $value;
break;
}else{
$proposals[$key] = $value;
}
}
} else {
if ($key === '' && isset($value['']) && is_array($value[''])) {
// Capture empty key to push it later
$emptyKeyData[$key] = $value;
}else{
$others[$key] = $value;
}
}
}
// dd($proposals, $others, $emptyKeyData);
// Sort proposals by their insurer's total
uasort($proposals, function($a, $b) {
$totalA = 0;
$totalB = 0;
foreach ($a as $key => $val) {
if ($key !== 'Quote Asked' && isset($val['Total'])) {
$totalA = floatval($val['Total']);
break;
}
}
foreach ($b as $key => $val) {
if ($key !== 'Quote Asked' && isset($val['Total'])) {
$totalB = floatval($val['Total']);
break;
}
}
return $totalA <=> $totalB;
});
// Merge back the sorted proposals into the full structure
$data['premium_data']['data'] = array_merge($others, $proposals, $emptyKeyData);
$data = $this->reorderProposalDataByPremiumOrder($data);
return $data;
}
private function reorderProposalDataByPremiumOrder(array $data): array {
if (!isset($data['premium_data']['data'], $data['proposal_data']['over_all_column_data'])) {
return $data;
}
$premiumProposals = array_keys($data['premium_data']['data']);
$filteredProposals = [];
// Collect proposal keys that match the pattern "Proposal X"
foreach ($premiumProposals as $key) {
if (preg_match('/^Proposal\s+\d+$/', $key) && isset($data['proposal_data']['over_all_column_data'][$key])) {
$filteredProposals[$key] = $data['proposal_data']['over_all_column_data'][$key];
}
}
// dd($premiumProposals, $filteredProposals);
$data['proposal_data']['over_all_column_data'] = $filteredProposals;
$data = $this->reorderProposalInHeaderAndData($data);
return $data;
}
private function reorderProposalInHeaderAndData(array $data): array {
// Kint::dump($data);
$tableData = $data['table_data'];
$sortedProposalOrder = $data['proposal_data']['over_all_column_data'];
$headers = $tableData['headers'] ?? [];
$dataRows = $tableData['data'] ?? [];
// Step 1: Separate static and proposal headers
$staticHeaders = [];
$proposalHeaders = [];
$actionHeader = [];
foreach ($headers as $header) {
if (in_array($header['parentHeader'], array_keys($sortedProposalOrder))) {
$proposalHeaders[$header['parentHeader']] = $header;
} else {
if($header['parentHeader'] == "Action"){
$actionHeader[] = $header;
}else{
$staticHeaders[] = $header;
}
}
}
// dd($staticHeaders, $proposalHeaders, $sortedProposalOrder);
// Step 2: Reorder headers
$reorderedHeaders = [];
foreach ($sortedProposalOrder as $proposalKey => $proposalValue) {
if (isset($proposalHeaders[$proposalKey])) {
$reorderedHeaders[] = $proposalHeaders[$proposalKey];
}
}
// print_rr($reorderedHeaders); die;
foreach ($reorderedHeaders as $key => &$value) {
$value['parentHeader'] = 'Proposal ' . ($key + 1);
}
unset($value);
$reorderedHeaders = array_merge($staticHeaders, $reorderedHeaders, $actionHeader);
// Step 3: Reorder each row's `data` by matching parentth
foreach ($dataRows as $dataRowIndex => &$row) {
$staticData = [];
$proposalData = [];
$actionData = [];
foreach ($row['data'] as $entry) {
if (in_array($entry['parentth'], array_keys($sortedProposalOrder))) {
$proposalData[$entry['parentth']][] = $entry;
} else {
if($entry['parentth'] == "Action"){
$actionData[] = $entry;
}else{
$staticData[] = $entry;
}
}
}
$reorderedProposalData = [];
foreach ($sortedProposalOrder as $proposalKey => $proposalValue) {
if (isset($proposalData[$proposalKey])) {
foreach ($proposalData[$proposalKey] as $entry) {
$reorderedProposalData[] = $entry;
}
}
}
$dubParTh = "";
$increament = 0;
foreach ($reorderedProposalData as $key => &$value) {
if($dubParTh == $value['parentth']){
$value['parentth'] = 'Proposal ' . ($increament);
}else{
$dubParTh = $value['parentth'];
$increament = $increament + 1;
$value['parentth'] = 'Proposal ' . ($increament);
}
}
unset($value);
$row['data'] = array_merge($staticData, $reorderedProposalData, $actionData);
}
$data['table_data']['headers'] = $reorderedHeaders;
$data['table_data']['data'] = $dataRows;
// dd('-----', $data);
$renumberedArray = $this->renumberProposalKeys($data['proposal_data']['over_all_column_data']);
$updatedDataSet = $this->renumberProposalKeys($data['premium_data']['data']);
$data['proposal_data']['over_all_column_data'] = !empty($renumberedArray) ? $renumberedArray : $data['proposal_data']['over_all_column_data'];
$data['premium_data']['data'] = !empty($updatedDataSet) ? $updatedDataSet : $data['premium_data']['data'];
return $data;
}
private function renumberProposalKeys(array $input): array {
$result = [];
$counter = 1;
foreach ($input as $key => $value) {
if (strpos($key, 'Proposal') === 0) {
$newKey = 'Proposal ' . $counter++;
$result[$newKey] = $value;
} else {
$result[$key] = $value;
}
}
return $result;
}
} }

View File

@ -3124,6 +3124,18 @@ class EmployeeRestController extends AdminController
$client_policy_id = $received_data['client_policy_id']; $client_policy_id = $received_data['client_policy_id'];
$insured_emp_id = $received_data['insured_emp_id']; $insured_emp_id = $received_data['insured_emp_id'];
if (empty($received_data['doa'])) {
$received_data['doa'] = null;
} else{
$ticket_data['doa'] = change_date_format($received_data['doa']);
}
if (empty($received_data['dod'])) {
$received_data['dod'] = null;
} else{
$ticket_data['dod'] = change_date_format($received_data['dod']);
}
$sql = " $sql = "
select select
cp.policy_type_id, cp.policy_type_id,
@ -3166,11 +3178,19 @@ class EmployeeRestController extends AdminController
if(!empty($emp_ticket_data)){ if(!empty($emp_ticket_data)){
$fetchData = $emp_ticket_data[0]; $fetchData = $emp_ticket_data[0];
$fetchData['claim_status_id'] = $this->claimStatusModel
$claimStatusQuery = $this->claimStatusModel
->select('id') ->select('id')
->where('ticket_type', $fetchData['ticket_type_id']) ->where('ticket_type', $fetchData['ticket_type_id'])
->orderBy('id', 'asc') ->orderBy('id', 'asc');
->first()['id'];
if ($fetchData['ticket_type_id'] == 1 && !empty($fetchData['tpa_no'])) {
$results = $claimStatusQuery->findAll(2);
$fetchData['claim_status_id'] = $results[1]['id'] ?? $results[0]['id'];
} else {
$fetchData['claim_status_id'] = $claimStatusQuery->first()['id'];
}
$fetchData['priority'] = 1; $fetchData['priority'] = 1;
$fetchData['mode_of_intimation'] = 3; $fetchData['mode_of_intimation'] = 3;

View File

@ -40,6 +40,7 @@ use Kint\Kint;
use App\Controllers\Jobs; use App\Controllers\Jobs;
use App\Controllers\JobWorker; use App\Controllers\JobWorker;
use Google\Service\FactCheckTools\Resource\Claims; use Google\Service\FactCheckTools\Resource\Claims;
use GPBMetadata\Google\Type\Datetime;
class LeadsController extends BaseController class LeadsController extends BaseController
{ {
@ -101,7 +102,7 @@ class LeadsController extends BaseController
$this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over']; $this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
$this->buisnessType = [1 => 'Industrial', 2 => 'Non Industrial']; $this->buisnessType = [1 => 'Industrial', 2 => 'Non Industrial'];
$this->leadsStatus = [ $this->leadsStatus = [
'queued' => 'Queued', 'queued' => 'In-Queued',
'qcr_sent' => 'QCR sent', 'qcr_sent' => 'QCR sent',
'lost' => 'Lost', 'lost' => 'Lost',
'co_insurer_pending' => 'Co-Insurer Pending', 'co_insurer_pending' => 'Co-Insurer Pending',
@ -202,6 +203,7 @@ class LeadsController extends BaseController
} else { } else {
$data = $this->prepareMultipleLeadData($data); $data = $this->prepareMultipleLeadData($data);
} }
// print_r($data); die; // print_r($data); die;
return $data; return $data;
} }
@ -323,10 +325,22 @@ class LeadsController extends BaseController
$incurred_claims_date = null; $incurred_claims_date = null;
} }
if (!empty($data['premium_date'][$index])) { // if (!empty($data['premium_date'][$index])) {
$premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d'); // $premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d');
// } else {
// $premium_date = null;
// }
if (!empty($data['source_policy_start_date'])) {
$data['source_policy_start_date'] = change_date_format($data['source_policy_start_date'], 'd/m/Y', 'Y-m-d');
} else { } else {
$premium_date = null; $data['source_policy_start_date'] = null;
}
if (!empty($data['source_policy_end_date'])) {
$data['source_policy_end_date'] = change_date_format($data['source_policy_end_date'], 'd/m/Y', 'Y-m-d');
} else {
$data['source_policy_end_date'] = null;
} }
// $file_name = file_Upload($files[$index], $uploadFilePath); // $file_name = file_Upload($files[$index], $uploadFilePath);
@ -383,7 +397,7 @@ class LeadsController extends BaseController
'outstanding_claims' => $data['outstanding_claims'][$index] ?? 0, 'outstanding_claims' => $data['outstanding_claims'][$index] ?? 0,
'policy_run_days' => $data['policy_run_days'][$index] ?? 0, 'policy_run_days' => $data['policy_run_days'][$index] ?? 0,
'premium_at_inception' => $data['premium_at_inception'][$index] ?? 0, 'premium_at_inception' => $data['premium_at_inception'][$index] ?? 0,
'premium_date' => $premium_date, 'premium_date' => $data['premium_date'][$index] ?? 0,
'earned_premium' => $data['earned_premium'][$index] ?? 0, 'earned_premium' => $data['earned_premium'][$index] ?? 0,
'annualised_claims' => $data['annualised_claims'][$index] ?? 0, 'annualised_claims' => $data['annualised_claims'][$index] ?? 0,
'incurred_claims_ratio' => $data['incurred_claims_ratio'][$index] ?? 0, 'incurred_claims_ratio' => $data['incurred_claims_ratio'][$index] ?? 0,
@ -400,6 +414,9 @@ class LeadsController extends BaseController
'lead_form_type' => $data['lead_form_type'] ?? 1, 'lead_form_type' => $data['lead_form_type'] ?? 1,
'custom_fields' => $data['custom_fields'] ?? null, 'custom_fields' => $data['custom_fields'] ?? null,
'source_policy_start_date' => $data['source_policy_start_date'] ?? null,
'source_policy_end_date' => $data['source_policy_end_date'] ?? null,
]; ];
} }
// print_r($processedData);die(); // print_r($processedData);die();
@ -479,11 +496,11 @@ class LeadsController extends BaseController
$data['incurred_claims_date'] = null; $data['incurred_claims_date'] = null;
} }
if (!empty($data['premium_date'])) { // if (!empty($data['premium_date'])) {
$data['premium_date'] = change_date_format($data['premium_date'], 'Y-m-d', 'd/m/Y'); // $data['premium_date'] = change_date_format($data['premium_date'], 'Y-m-d', 'd/m/Y');
} else { // } else {
$data['premium_date'] = null; // $data['premium_date'] = null;
} // }
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->first() ?? null; $data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->first() ?? null;
@ -556,7 +573,6 @@ class LeadsController extends BaseController
} }
$this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update(); $this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update();
} else { } else {
$lead_file_data = [ $lead_file_data = [
@ -586,12 +602,6 @@ class LeadsController extends BaseController
return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200); return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200);
} }
} }
public function updateLeadTableFields()
{
}
//--------RFQ----------------------------------------------------------------------------------------------- //--------RFQ-----------------------------------------------------------------------------------------------
@ -646,6 +656,7 @@ class LeadsController extends BaseController
$data['page_name'] = $type == 2 ? 'QCR' : 'RFQ'; $data['page_name'] = $type == 2 ? 'QCR' : 'RFQ';
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames(); $data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
$data['userList'] = $this->userModel->getUserListForRFQ(); $data['userList'] = $this->userModel->getUserListForRFQ();
$data['exclusiveUserList'] = $this->userModel->getexclusiveUserListForRFQ();
$data['lead_data'] = $lead_data; $data['lead_data'] = $lead_data;
$mail_content = " $mail_content = "
@ -654,18 +665,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>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>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>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['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
$data['subject'] = $this->transformMailContent($lead_data, $subject, $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['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
$data['attachment_html'] = view('rfq/attachment_files', $data) ?? ""; $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); // dd($data);
if ($data['lead_data']['lead_form_type'] == 1) { if ($data['lead_data']['lead_form_type'] == 1) {
@ -735,15 +760,24 @@ class LeadsController extends BaseController
return $this->respond(['status' => false, 'message' => 'Lead ID is required'], 400); return $this->respond(['status' => false, 'message' => 'Lead ID is required'], 400);
} }
$inputJson = json_decode($data['json'], true);
if (isset($inputJson['premium_data']) && !empty($inputJson['premium_data'])) {
$sortedJson = $this->reorderProposalsByInsurerTotal($inputJson);
$data['json'] = json_encode($sortedJson);
}
$data['type'] = 1; $data['type'] = 1;
// Deactivate existing RFQs for this lead and type // Deactivate existing RFQs for this lead and type
if (!isset($data['rfq_primaryKey']) && empty($data['rfq_primaryKey'])) {
$this->RFQModel $this->RFQModel
->where('lead_id', $lead_id) ->where('lead_id', $lead_id)
->where('type', 1) ->where('type', 1)
->where('is_active', 1) ->where('is_active', 1)
->set('is_active', 0) ->set('is_active', 0)
->update(); ->update();
}
// Handle registration_json // Handle registration_json
if (empty($data['registration_json'])) { if (empty($data['registration_json'])) {
@ -759,20 +793,29 @@ class LeadsController extends BaseController
} }
} }
// print_r($data); die;
// $data['json'] = "";
if (isset($data['rfq_primaryKey']) && !empty($data['rfq_primaryKey'])) {
$this->RFQModel->update($data['rfq_primaryKey'], $data);
$insertId = $data['rfq_primaryKey'];
$affectedRows = db_connect()->affectedRows();
} else {
// Insert new RFQ // Insert new RFQ
$insertId = $this->RFQModel->insert($data); $insertId = $this->RFQModel->insert($data);
}
if ($insertId) { if ($insertId) {
$message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR submitted successfully' : 'RFQ submitted successfully'; $message = ($data['submit_type'] ?? '') == 'QCR' ? 'QCR saved successfully' : 'RFQ saved successfully';
return $this->respond([ return $this->respond([
'status' => true, 'status' => true,
'id' => $insertId, 'id' => $insertId,
'message' => $message, 'message' => $message,
'data' => $data 'data' => $data,
'affectedRows' => $affectedRows ?? null,
], 200); ], 200);
} }
$message = ($data['submit_type'] ?? '') == 'QCR' ? 'Failed to create QCR' : 'Failed to create RFQ'; $message = ($data['submit_type'] ?? '') == 'QCR' ? 'Failed to save QCR' : 'Failed to save RFQ';
return $this->respond([ return $this->respond([
'status' => false, 'status' => false,
'id' => null, 'id' => null,
@ -805,6 +848,206 @@ class LeadsController extends BaseController
} }
private function reorderProposalsByInsurerTotal(array $data): array
{
if (!isset($data['premium_data']['data'])) return $data;
$original = $data['premium_data']['data'];
$proposals = [];
$others = [];
$emptyKeyData = [];
foreach ($original as $key => $value) {
// Match only keys that look like 'Proposal X'
if (preg_match('/^Proposal\s+\d+$/', $key)) {
// Get the insurer entry (not 'Quote Asked')
foreach ($value as $subKey => $subVal) {
if ($subKey !== 'Quote Asked' && isset($subVal['Total'])) {
$proposals[$key] = $value;
break;
}else{
$proposals[$key] = $value;
}
}
} else {
if ($key === '' && isset($value['']) && is_array($value[''])) {
// Capture empty key to push it later
$emptyKeyData[$key] = $value;
} else {
$others[$key] = $value;
}
}
}
// Sort proposals by their insurer's total
uasort($proposals, function ($a, $b) {
$totalA = 0;
$totalB = 0;
foreach ($a as $key => $val) {
if ($key !== 'Quote Asked' && isset($val['Total'])) {
$totalA = floatval($val['Total']);
break;
}
}
foreach ($b as $key => $val) {
if ($key !== 'Quote Asked' && isset($val['Total'])) {
$totalB = floatval($val['Total']);
break;
}
}
return $totalA <=> $totalB;
});
// Merge back the sorted proposals into the full structure
$data['premium_data']['data'] = array_merge($others, $proposals, $emptyKeyData);
$data = $this->reorderProposalDataByPremiumOrder($data);
return $data;
}
private function reorderProposalDataByPremiumOrder(array $data): array
{
if (!isset($data['premium_data']['data'], $data['proposal_data']['over_all_column_data'])) {
return $data;
}
$premiumProposals = array_keys($data['premium_data']['data']);
$filteredProposals = [];
// Collect proposal keys that match the pattern "Proposal X"
foreach ($premiumProposals as $key) {
if (preg_match('/^Proposal\s+\d+$/', $key) && isset($data['proposal_data']['over_all_column_data'][$key])) {
$filteredProposals[$key] = $data['proposal_data']['over_all_column_data'][$key];
}
}
// dd($premiumProposals, $filteredProposals);
$data['proposal_data']['over_all_column_data'] = $filteredProposals;
$data = $this->reorderProposalInHeaderAndData($data);
return $data;
}
private function reorderProposalInHeaderAndData(array $data): array
{
$tableData = $data['table_data'];
$sortedProposalOrder = $data['proposal_data']['over_all_column_data'];
$headers = $tableData['headers'] ?? [];
$dataRows = $tableData['data'] ?? [];
// Step 1: Separate static and proposal headers
$staticHeaders = [];
$proposalHeaders = [];
$actionHeader = [];
foreach ($headers as $header) {
if (in_array($header['parentHeader'], array_keys($sortedProposalOrder))) {
$proposalHeaders[$header['parentHeader']] = $header;
} else {
if ($header['parentHeader'] == "Action") {
$actionHeader[] = $header;
} else {
$staticHeaders[] = $header;
}
}
}
// dd($staticHeaders, $proposalHeaders, $sortedProposalOrder);
// Step 2: Reorder headers
$reorderedHeaders = [];
foreach ($sortedProposalOrder as $proposalKey => $proposalValue) {
if (isset($proposalHeaders[$proposalKey])) {
$reorderedHeaders[] = $proposalHeaders[$proposalKey];
}
}
// print_rr($reorderedHeaders); die;
foreach ($reorderedHeaders as $key => &$value) {
$value['parentHeader'] = 'Proposal ' . ($key + 1);
}
unset($value);
$reorderedHeaders = array_merge($staticHeaders, $reorderedHeaders, $actionHeader);
// Step 3: Reorder each row's `data` by matching parentth
foreach ($dataRows as $dataRowIndex => &$row) {
$staticData = [];
$proposalData = [];
$actionData = [];
foreach ($row['data'] as $entry) {
if (in_array($entry['parentth'], array_keys($sortedProposalOrder))) {
$proposalData[$entry['parentth']][] = $entry;
} else {
if ($entry['parentth'] == "Action") {
$actionData[] = $entry;
} else {
$staticData[] = $entry;
}
}
}
$reorderedProposalData = [];
foreach ($sortedProposalOrder as $proposalKey => $proposalValue) {
if (isset($proposalData[$proposalKey])) {
foreach ($proposalData[$proposalKey] as $entry) {
$reorderedProposalData[] = $entry;
}
}
}
$dubParTh = "";
$increament = 0;
foreach ($reorderedProposalData as $key => &$value) {
if ($dubParTh == $value['parentth']) {
$value['parentth'] = 'Proposal ' . ($increament);
} else {
$dubParTh = $value['parentth'];
$increament = $increament + 1;
$value['parentth'] = 'Proposal ' . ($increament);
}
}
unset($value);
$row['data'] = array_merge($staticData, $reorderedProposalData, $actionData);
}
$data['table_data']['headers'] = $reorderedHeaders;
$data['table_data']['data'] = $dataRows;
$renumberedArray = $this->renumberProposalKeys($data['proposal_data']['over_all_column_data']);
$updatedDataSet = $this->renumberProposalKeys($data['premium_data']['data']);
$data['proposal_data']['over_all_column_data'] = !empty($renumberedArray) ? $renumberedArray : $data['proposal_data']['over_all_column_data'];
$data['premium_data']['data'] = !empty($updatedDataSet) ? $updatedDataSet : $data['premium_data']['data'];
return $data;
}
private function renumberProposalKeys(array $input): array
{
$result = [];
$counter = 1;
foreach ($input as $key => $value) {
if (strpos($key, 'Proposal') === 0) {
$newKey = 'Proposal ' . $counter++;
$result[$newKey] = $value;
} else {
$result[$key] = $value;
}
}
return $result;
}
//-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------ //-----RFQ and QCR EXPORT------------------------------------------------------------------------------------------------
@ -880,7 +1123,7 @@ class LeadsController extends BaseController
if ($rfq_data['policy_type_id'] == 2) { if ($rfq_data['policy_type_id'] == 2) {
$lead_data = [ $lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'], 'Insured' => $rfq_data['client_name'],
'Policy Status' => $rfq_data['status'], 'Policy Status' => $rfq_data['status'],
@ -893,6 +1136,7 @@ class LeadsController extends BaseController
]; ];
} else if ($rfq_data['policy_type_id'] == 1) { } else if ($rfq_data['policy_type_id'] == 1) {
$lead_data = [ $lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'], 'Insured' => $rfq_data['client_name'],
'No of Employees at Inception' => $rfq_data['incept_emp_count'], 'No of Employees at Inception' => $rfq_data['incept_emp_count'],
'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'], 'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
@ -905,6 +1149,7 @@ class LeadsController extends BaseController
} else { } else {
if ($rfq_data['policy_type_id'] == 2) { if ($rfq_data['policy_type_id'] == 2) {
$lead_data = [ $lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'], 'Insured' => $rfq_data['client_name'],
'Policy Status' => $rfq_data['status'], 'Policy Status' => $rfq_data['status'],
@ -933,6 +1178,7 @@ class LeadsController extends BaseController
]; ];
} else if ($rfq_data['policy_type_id'] == 1) { } else if ($rfq_data['policy_type_id'] == 1) {
$lead_data = [ $lead_data = [
'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'], 'Insured' => $rfq_data['client_name'],
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'], 'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'], 'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
@ -966,7 +1212,7 @@ class LeadsController extends BaseController
// Start with lead_data at the top // Start with lead_data at the top
$rowNumber = 1; $rowNumber = 1;
$mergeRange1 = "A{$rowNumber}:C{$rowNumber}"; $mergeRange1 = "A{$rowNumber}:B{$rowNumber}";
$sheet->mergeCells($mergeRange1); $sheet->mergeCells($mergeRange1);
$sheet->setCellValue("A{$rowNumber}", "Nhance India Insurance Broking Pvt Ltd"); $sheet->setCellValue("A{$rowNumber}", "Nhance India Insurance Broking Pvt Ltd");
$sheet->getStyle("A{$rowNumber}")->applyFromArray([ $sheet->getStyle("A{$rowNumber}")->applyFromArray([
@ -981,13 +1227,13 @@ class LeadsController extends BaseController
]); ]);
// Set column width to fit the image properly // Set column width to fit the image properly
$sheet->getColumnDimension('D')->setWidth(20); // Adjust as needed $sheet->getColumnDimension('C')->setWidth(20); // Adjust as needed
$sheet->getRowDimension($rowNumber)->setRowHeight(40); // Adjust as needed $sheet->getRowDimension($rowNumber)->setRowHeight(40); // Adjust as needed
$drawing = new Drawing(); $drawing = new Drawing();
$path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server path $path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server path
$drawing->setPath($path); $drawing->setPath($path);
$drawing->setCoordinates("D{$rowNumber}"); // Set position in column B $drawing->setCoordinates("C{$rowNumber}"); // Set position in column B
$drawing->setHeight(35); // Adjust image height $drawing->setHeight(35); // Adjust image height
// Center align the image in the cell // Center align the image in the cell
@ -997,8 +1243,8 @@ class LeadsController extends BaseController
$drawing->setWorksheet($sheet); $drawing->setWorksheet($sheet);
// Apply center alignment to the cell // Apply center alignment to the cell
$sheet->getStyle("D{$rowNumber}")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER); $sheet->getStyle("C{$rowNumber}")->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
$sheet->getStyle("D{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER); $sheet->getStyle("C{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
$rowNumber = $rowNumber + 1; $rowNumber = $rowNumber + 1;
@ -1011,7 +1257,7 @@ class LeadsController extends BaseController
// Merge A:B for key and C:D for value // Merge A:B for key and C:D for value
$mergeRangeKey = "A{$rowNumber}:B{$rowNumber}"; $mergeRangeKey = "A{$rowNumber}:B{$rowNumber}";
$mergeRangeValue = "C{$rowNumber}:D{$rowNumber}"; $mergeRangeValue = "C{$rowNumber}";
$sheet->mergeCells($mergeRangeKey); $sheet->mergeCells($mergeRangeKey);
$sheet->mergeCells($mergeRangeValue); $sheet->mergeCells($mergeRangeValue);
@ -1044,9 +1290,9 @@ class LeadsController extends BaseController
// Set column width based on max content length (adjusted for padding) // Set column width based on max content length (adjusted for padding)
$sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2); $sheet->getColumnDimension('A')->setWidth($maxWidthA * 1.2);
$sheet->getColumnDimension('B')->setWidth($maxWidthA * 1.2); $sheet->getColumnDimension('B')->setWidth($maxWidthA * 5);
$sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2); $sheet->getColumnDimension('C')->setWidth($maxWidthB * 1.2);
$sheet->getColumnDimension('D')->setWidth($maxWidthB * 1.2); // $sheet->getColumnDimension('D')->setWidth($maxWidthB * 1.2);
// $rowNumber += 2; // $rowNumber += 2;
@ -1105,7 +1351,7 @@ class LeadsController extends BaseController
} }
if ($header['parentHeader'] === 'Particulars') { if ($header['parentHeader'] === 'Particulars') {
$sheet->getColumnDimension('B')->setWidth(40); $sheet->getColumnDimension('B')->setWidth(80);
} }
$startColumn = $columnLetter; // Start of the current header range $startColumn = $columnLetter; // Start of the current header range
@ -1289,7 +1535,7 @@ class LeadsController extends BaseController
} }
$lastRow = count($lead_data) + 1; $lastRow = count($lead_data) + 1;
$leadRange = "A1:D{$lastRow}"; $leadRange = "A1:C{$lastRow}";
$sheet->getStyle($leadRange)->applyFromArray([ $sheet->getStyle($leadRange)->applyFromArray([
'borders' => [ 'borders' => [
@ -1300,9 +1546,25 @@ class LeadsController extends BaseController
], ],
]); ]);
// Set filename // Set filename
$string = ($type == 2) ? 'QCR' : 'RFQ'; $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 // Save to temporary location
$uploadFilePath = WRITEPATH . 'tmp/' . $filename; $uploadFilePath = WRITEPATH . 'tmp/' . $filename;
@ -1927,13 +2189,20 @@ class LeadsController extends BaseController
// print_r($recipient_data); die; // print_r($recipient_data); die;
} else if ($recipient_type == 'client') { } 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 { } else {
$recipient_data = [['name' => "Team", 'email' => $params['to']]]; $recipient_data = [['name' => "Team", 'email' => $params['to']]];
} }
// print_r($recipient_data); die; // 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']; $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>'; $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 //for mail content
@ -1982,7 +2251,9 @@ class LeadsController extends BaseController
'proposel_data' => json_encode($lead_update_data), 'proposel_data' => json_encode($lead_update_data),
'status' => 'won', 'status' => 'won',
'placement_date' => change_date_format($params['placement_date'], 'd/m/Y', 'Y-m-d'), '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'], 'utr_no' => $params['utr_no'],
'is_cd' => $params['is_cd'],
'premium_amount' => $params['premium_amount'], 'premium_amount' => $params['premium_amount'],
'total_amount' => $params['total_amount'], 'total_amount' => $params['total_amount'],
'cd_amount' => $params['cd_amount'], 'cd_amount' => $params['cd_amount'],
@ -2403,7 +2674,6 @@ class LeadsController extends BaseController
$client_policy_data['placement_json'] = $placementJson; $client_policy_data['placement_json'] = $placementJson;
$client_policy_data['policy_terms'] = $this->convertNonEbQCRJsonToPolicyTerms(json_decode($placementJson, true)); $client_policy_data['policy_terms'] = $this->convertNonEbQCRJsonToPolicyTerms(json_decode($placementJson, true));
} }
} }
// print_r($client_policy_data); die; // print_r($client_policy_data); die;
@ -2542,7 +2812,6 @@ class LeadsController extends BaseController
} }
return json_encode($terms_array); return json_encode($terms_array);
} else { } else {
return null; return null;
} }
@ -2592,7 +2861,9 @@ class LeadsController extends BaseController
return $this->transformNonEbProposelData( return $this->transformNonEbProposelData(
$jsonData, $jsonData,
$proposel_data['proposel_name'] ?? '', $proposel_data['proposel_name'] ?? '',
$proposel_data['insurer_name'] ?? '', null, 1 $proposel_data['insurer_name'] ?? '',
null,
1
); );
}, $jsonArray); }, $jsonArray);
@ -2629,6 +2900,13 @@ class LeadsController extends BaseController
$next_year = $current_year + 1; $next_year = $current_year + 1;
$policy_year = "$current_year-$next_year"; $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) { if ($lead_data) {
// Replacing placeholders with actual values // Replacing placeholders with actual values
@ -2638,6 +2916,11 @@ class LeadsController extends BaseController
$message = str_replace("{{POLICY_TYPE}}", $lead_data['policy_type'] ?? "Insurance Policy", $message); $message = str_replace("{{POLICY_TYPE}}", $lead_data['policy_type'] ?? "Insurance Policy", $message);
$message = str_replace("{{RFQ_OR_QCR}}", $page_name, $message); $message = str_replace("{{RFQ_OR_QCR}}", $page_name, $message);
$message = str_replace("{{POLICY_YEAR}}", $policy_year, $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; return $message;
} else { } else {
@ -2645,6 +2928,7 @@ class LeadsController extends BaseController
} }
} }
function getLastFiveFinancialYears() function getLastFiveFinancialYears()
{ {
$currentYear = date('Y'); $currentYear = date('Y');
@ -2721,7 +3005,7 @@ class LeadsController extends BaseController
} }
if (!empty($data['lead_edit_data'])) { if (!empty($data['lead_edit_data'])) {
foreach (['policy_start_date', 'policy_end_date', 'incurred_claims_date', 'premium_date'] as $dateField) { foreach (['policy_start_date', 'policy_end_date', 'source_policy_start_date', 'source_policy_end_date', 'incurred_claims_date'] as $dateField) {
$data['lead_edit_data'][$dateField] = !empty($data['lead_edit_data'][$dateField]) $data['lead_edit_data'][$dateField] = !empty($data['lead_edit_data'][$dateField])
? change_date_format($data['lead_edit_data'][$dateField], 'Y-m-d', 'd/m/Y') ? change_date_format($data['lead_edit_data'][$dateField], 'Y-m-d', 'd/m/Y')
: null; : null;
@ -2736,7 +3020,8 @@ class LeadsController extends BaseController
$data $data
) ?? ""; ) ?? "";
$data['lead_edit_data']['multi_file_html'] = view('rfq/multi_files', $data) ?? ""; $html = view('rfq/multi_files', $data);
$data['lead_edit_data']['multi_file_html'] = trim($html) !== '' ? $html : null;
} }
if ($data['lead_edit_data']['lead_type'] != 1 && $data['lead_edit_data']['lead_form_type'] == 2) { if ($data['lead_edit_data']['lead_type'] != 1 && $data['lead_edit_data']['lead_form_type'] == 2) {
@ -3184,7 +3469,6 @@ class LeadsController extends BaseController
if (!($key === 0 && !$hasPolicy)) { if (!($key === 0 && !$hasPolicy)) {
$columnLetter++; $columnLetter++;
} }
} }
$rowNumber++; $rowNumber++;
$serial_no++; $serial_no++;
@ -3610,5 +3894,4 @@ class LeadsController extends BaseController
return $attachments; return $attachments;
} }
} }

View File

@ -774,13 +774,20 @@ class TicketController extends BaseController
{ {
// log_message('error','Function called');die(); // log_message('error','Function called');die();
// $ticket_master_id = $this->request->getPost('id'); // $ticket_master_id = $this->request->getPost('id');
$user_id = get_session_userid();
$logged_user = $this->userModel->select('first_name,last_name,profile')->where('id', $user_id)->first();
$dataToSend = []; $dataToSend = [];
$dataToSend['user_name'] = $logged_user['first_name'] . ' ' . $logged_user['last_name'];
$dataToSend['messages'] = $this->ticketMessageModel->where('is_active', 1) $user_id = get_session_userid();
->where('ticket_id', $ticket_master_id)->orderBy('created_at', 'DESC') // $logged_user = $this->userModel->select('first_name,last_name,profile')->where('id', $user_id)->first();
// $dataToSend['user_name'] = $logged_user['first_name'] . ' ' . $logged_user['last_name'];
$dataToSend['messages'] = $this->ticketMessageModel
->select('ticket_messages.*,up.first_name as user_name')
->join('user_profiles up', 'up.id = ticket_messages.created_by', 'left')
->where('ticket_messages.is_active', 1)
->where('ticket_messages.ticket_id', $ticket_master_id)
->orderBy('ticket_messages.created_at', 'DESC')
->findAll(); ->findAll();
foreach ($dataToSend['messages'] as $message) { foreach ($dataToSend['messages'] as $message) {
$mail_content_converted = $this->convertHtmlToText($message['mail_content']); $mail_content_converted = $this->convertHtmlToText($message['mail_content']);
$message['mail_content'] = $mail_content_converted; $message['mail_content'] = $mail_content_converted;
@ -1034,7 +1041,7 @@ class TicketController extends BaseController
th.old_value, th.old_value,
th.new_value, th.new_value,
th.created_at, th.created_at,
CONCAT(creator.first_name, ' ', creator.last_name) as modified_by, CONCAT_WS(' ', creator.first_name, creator.last_name) AS modified_by,
-- Claim Status -- Claim Status
old_status.claim_status as old_status_value, old_status.claim_status as old_status_value,
new_status.claim_status as new_status_value, new_status.claim_status as new_status_value,
@ -1094,6 +1101,7 @@ class TicketController extends BaseController
ORDER BY ORDER BY
th.created_at DESC"; th.created_at DESC";
$data = $this->ticketHistoryModel->query($sql)->getResultArray(); $data = $this->ticketHistoryModel->query($sql)->getResultArray();
// dd(db_connect()->getLastQuery());
$priorityType = $this->priorityType; $priorityType = $this->priorityType;
$relationshipType = $this->relationshipType; $relationshipType = $this->relationshipType;
$modeOFIntimate = $this->modeOFIntimate; $modeOFIntimate = $this->modeOFIntimate;

View File

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

View File

@ -134,5 +134,20 @@ class UserModel extends Model
->getResultArray(); ->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 origin: "mobile", // origin
emp_code:"HTL-007", emp_code:"HTL-007",
client_id:159, 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/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> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.js"></script>
<!-- srinivas --> <!-- 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> <script src="https://editor.unlayer.com/embed.js"></script>
<!-- MD5 Hash Start --> <!-- MD5 Hash Start -->

View File

@ -162,6 +162,16 @@
</select> </select>
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="source_policy_start_date">Source Policy Start Date<span class="text-danger"></span></label>
<input type="text" class="form-control readonly-select" id="source_policy_start_date" name="source_policy_start_date" readonly>
</div>
<div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="source_policy_end_date">Source Policy End Date<span class="text-danger"></span></label>
<input type="text" class="form-control" id="source_policy_end_date" name="source_policy_end_date" readonly>
</div>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="pan">PAN<span class="text-danger"></span></label> <label for="pan">PAN<span class="text-danger"></span></label>
<input type="text" class="form-control" id="pan" placeholder="Enter PAN Number" <input type="text" class="form-control" id="pan" placeholder="Enter PAN Number"
@ -228,9 +238,9 @@
<div class="form-row"> <div class="form-row">
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="salse_person_id">Sales Person<span class="text-danger">*</span></label> <label for="salse_person_id">Salse Person<span class="text-danger">*</span></label>
<select class="form-control" id="salse_person_id" name="salse_person_id" multiple required> <select class="form-control" id="salse_person_id" name="salse_person_id" multiple required>
<option value="">Select Sales Person</option> <option value="">Select Salse Person</option>
<?php if (isset($salse_team)) { ?> <?php if (isset($salse_team)) { ?>
<?php foreach ($salse_team as $value) { ?> <?php foreach ($salse_team as $value) { ?>
<option value="<?= $value['id']; ?>"> <option value="<?= $value['id']; ?>">
@ -343,24 +353,24 @@
1); // Set end date to last day of selected year 1); // Set end date to last day of selected year
policy_end_datePicker.setDate(policy_end_date); policy_end_datePicker.setDate(policy_end_date);
console.log('this object', this); // console.log('this object', this);
console.log('id of this element:', this.element); // console.log('id of this element:', this.element);
console.log('id of this element:', this.element.id); // console.log('id of this element:', this.element.id);
let increment = this.element.id.split('_').pop(); // let increment = this.element.id.split('_').pop();
console.log(increment); // Outputs: 1 // console.log(increment); // Outputs: 1
console.log('increment', increment); // console.log('increment', increment);
console.log('policy_start_datePicker selectedDates', selectedDates); // console.log('policy_start_datePicker selectedDates', selectedDates);
console.log('policy_start_datePicker incurred_claim_date_', $( // console.log('policy_start_datePicker incurred_claim_date_', $(
"#incurred_claim_date_" + increment).val()); // "#incurred_claim_date_" + increment).val());
// Recalculate policy_run_days if incurred claim date is already selected // Recalculate policy_run_days if incurred claim date is already selected
if ($("#incurred_claim_date_" + increment).val()) { // if ($("#incurred_claim_date_" + increment).val()) {
console.log('policy_start_datePicker selectedDates', selectedDates); // console.log('policy_start_datePicker selectedDates', selectedDates);
calculatePolicyRunDays(increment); // calculatePolicyRunDays(increment);
} // }
} }
}); });
} }
@ -369,6 +379,11 @@
dateFormat: "d/m/Y", dateFormat: "d/m/Y",
allowInput: false allowInput: false
}); });
document.getElementById('source_policy_start_date').readOnly = true;
document.getElementById('source_policy_end_date').readOnly = true;
$('#source_policy_start_date, #source_policy_end_date').addClass('readonly-select');
}); });
console.log('increment count for insurer and tpa ', increment); console.log('increment count for insurer and tpa ', increment);
@ -453,7 +468,7 @@
updateRenewalFields(dataIncrement); updateRenewalFields(dataIncrement);
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement; let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
let premium_date_id = 'premium_date_' + dataIncrement; // let premium_date_id = 'premium_date_' + dataIncrement;
var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, { var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, {
dateFormat: "d/m/Y", dateFormat: "d/m/Y",
@ -466,11 +481,7 @@
let increment = this.input.id.split('_').pop(); let increment = this.input.id.split('_').pop();
console.log('Extracted increment:', increment); console.log('Extracted increment:', increment);
var policyStartDate = $("#policy_start_date_" + increment) var policyStartDate = $("#source_policy_start_date");
.length ?
$("#policy_start_date_" + increment) :
$("#policy_start_date");
console.log('Selected Dates:', selectedDates); console.log('Selected Dates:', selectedDates);
console.log('policy start date instance', policyStartDate) console.log('policy start date instance', policyStartDate)
console.log('Policy Start Date:', policyStartDate.val()); console.log('Policy Start Date:', policyStartDate.val());
@ -482,10 +493,10 @@
} }
}); });
var premium_date_datepicker = flatpickr("#" + premium_date_id, { // var premium_date_datepicker = flatpickr("#" + premium_date_id, {
dateFormat: "d/m/Y", // dateFormat: "d/m/Y",
allowInput: false // allowInput: false
}); // });
$('#proposed_insurer_' + dataIncrement).select2(); $('#proposed_insurer_' + dataIncrement).select2();
$('#proposed_tpa_' + dataIncrement).select2(); $('#proposed_tpa_' + dataIncrement).select2();
@ -651,6 +662,12 @@
if (res.status === true && res.data) { if (res.status === true && res.data) {
console.log("res.data.source_policy_start_date", res.data.source_policy_start_date)
console.log("res.data.source_policy_end_date", res.data.source_policy_end_date)
$('#source_policy_start_date').val(res.data.source_policy_start_date);
$('#source_policy_end_date').val(res.data.source_policy_end_date);
for (let i = 1; i <= increment_count; i++) { for (let i = 1; i <= increment_count; i++) {
$(`#policy_type_id`).removeClass('readonly-select ').select2(); $(`#policy_type_id`).removeClass('readonly-select ').select2();
@ -682,6 +699,7 @@
$(`#proposed_tpa_${i}`).addClass('readonly-select ').select2('destroy'); $(`#proposed_tpa_${i}`).addClass('readonly-select ').select2('destroy');
} }
} else { } else {
console.warn('Invalid response:', res.message || 'Unknown error'); console.warn('Invalid response:', res.message || 'Unknown error');
// Reset fields if response is invalid // Reset fields if response is invalid
@ -694,6 +712,7 @@
} }
} }
// Hide loader // Hide loader
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
@ -787,7 +806,7 @@
updateRenewalFields(dataIncrement); updateRenewalFields(dataIncrement);
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement; let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
let premium_date_id = 'premium_date_' + dataIncrement; // let premium_date_id = 'premium_date_' + dataIncrement;
var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, { var incurred_claim_datepicker = flatpickr("#" + incurred_claim_date_id, {
dateFormat: "d/m/Y", dateFormat: "d/m/Y",
@ -800,10 +819,7 @@
let increment = this.input.id.split('_').pop(); let increment = this.input.id.split('_').pop();
console.log('Extracted increment:', increment); console.log('Extracted increment:', increment);
var policyStartDate = $("#policy_start_date_" + increment).length ? var policyStartDate = $("#source_policy_start_date");
$("#policy_start_date_" + increment) :
$("#policy_start_date");
console.log('Selected Dates:', selectedDates); console.log('Selected Dates:', selectedDates);
console.log('policy start date instance', policyStartDate) console.log('policy start date instance', policyStartDate)
console.log('Policy Start Date:', policyStartDate.val()); console.log('Policy Start Date:', policyStartDate.val());
@ -815,10 +831,10 @@
} }
}); });
var premium_date_datepicker = flatpickr("#" + premium_date_id, { // var premium_date_datepicker = flatpickr("#" + premium_date_id, {
dateFormat: "d/m/Y", // dateFormat: "d/m/Y",
allowInput: false // allowInput: false
}); // });
$('#proposed_insurer_' + dataIncrement).select2(); $('#proposed_insurer_' + dataIncrement).select2();
$('#proposed_tpa_' + dataIncrement).select2(); $('#proposed_tpa_' + dataIncrement).select2();
@ -968,16 +984,16 @@
console.log(increment); // Outputs: 1 console.log(increment); // Outputs: 1
console.log('increment', increment); // console.log('increment', increment);
console.log('policy_start_datePicker selectedDates', selectedDates); // console.log('policy_start_datePicker selectedDates', selectedDates);
console.log('policy_start_datePicker incurred_claim_date_', $("#incurred_claim_date_" + // console.log('policy_start_datePicker incurred_claim_date_', $("#incurred_claim_date_" +
increment).val()); // increment).val());
// Recalculate policy_run_days if incurred claim date is already selected // Recalculate policy_run_days if incurred claim date is already selected
if ($("#incurred_claim_date_" + increment).val()) { // if ($("#incurred_claim_date_" + increment).val()) {
console.log('policy_start_datePicker selectedDates', selectedDates); // console.log('policy_start_datePicker selectedDates', selectedDates);
calculatePolicyRunDays(increment); // calculatePolicyRunDays(increment);
} // }
} }
}); });
} }
@ -1051,10 +1067,7 @@
console.log('calculatePolicyRunDays function called'); console.log('calculatePolicyRunDays function called');
console.log('increment', increment); console.log('increment', increment);
var policyStartDate = $("#policy_start_date_" + increment).length ? var policyStartDate = $("#source_policy_start_date");
$("#policy_start_date_" + increment) :
$("#policy_start_date");
var policyStartDate = flatpickr.parseDate(policyStartDate.val(), "d/m/Y"); var policyStartDate = flatpickr.parseDate(policyStartDate.val(), "d/m/Y");
var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y"); var incurredClaimDate = flatpickr.parseDate($("#incurred_claim_date_" + increment).val(), "d/m/Y");
@ -1062,9 +1075,9 @@
console.log('incurredClaimDate', incurredClaimDate) console.log('incurredClaimDate', incurredClaimDate)
if (policyStartDate && incurredClaimDate) { if (policyStartDate && incurredClaimDate) {
var timeDiff = (policyStartDate - incurredClaimDate) + 1; // Time difference in milliseconds var timeDiff = Math.abs(policyStartDate - incurredClaimDate); // Time difference in milliseconds
console.log('timeDiff', timeDiff); console.log('timeDiff', timeDiff);
var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24)); // Convert to days and add 1 var daysDiff = Math.ceil(timeDiff / (1000 * 60 * 60 * 24) + 1); // Convert to days and add 1
console.log('daysDiff', daysDiff); console.log('daysDiff', daysDiff);
$("#policy_run_days_" + increment).val(daysDiff); // Set value in the policy_run_days_ input $("#policy_run_days_" + increment).val(daysDiff); // Set value in the policy_run_days_ input
} }
@ -1104,7 +1117,8 @@
// ------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------
// Prevent division by zero in incurred claim ratio calculation // Prevent division by zero in incurred claim ratio calculation
let incurred_claim_ratio = annualised_claims > 0 ? incurred_claims / annualised_claims : 0; let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
let incurred_claim_ratio = annualised_claims > 0 ? annualised_claims / premium_as_on_date : 0;
let incurred_claim_ratio_roundoff = Math.round(incurred_claim_ratio); let incurred_claim_ratio_roundoff = Math.round(incurred_claim_ratio);
console.log('incurred_claim_ratio', incurred_claim_ratio_roundoff); console.log('incurred_claim_ratio', incurred_claim_ratio_roundoff);
@ -1116,7 +1130,7 @@
console.log('earned_premium', earned_premium); console.log('earned_premium', earned_premium);
// Prevent division by zero in earned claims ratio calculation // Prevent division by zero in earned claims ratio calculation
let earned_claims_ratio = earned_premium > 0 ? incurred_claims / earned_premium : 0; let earned_claims_ratio = earned_premium > 0 ? annualised_claims / earned_premium : 0;
let earned_claims_ration_roundoff = Math.round(earned_claims_ratio); let earned_claims_ration_roundoff = Math.round(earned_claims_ratio);
console.log('earned_claims_ratio', earned_claims_ratio); console.log('earned_claims_ratio', earned_claims_ratio);
@ -1128,6 +1142,8 @@
let increment = input.id.split('_').pop(); // Extract the increment part let increment = input.id.split('_').pop(); // Extract the increment part
console.log('increment', increment); console.log('increment', increment);
let premium_as_on_date = Number($('#premium_date_' + increment).val()) || 0;
// Retrieve and convert the values to numbers, fallback to 0 if empty or invalid // Retrieve and convert the values to numbers, fallback to 0 if empty or invalid
let premium_at_inception = Number($('#premium_at_inception_' + increment).val()) || 0; let premium_at_inception = Number($('#premium_at_inception_' + increment).val()) || 0;
console.log('premium_at_inception', premium_at_inception); console.log('premium_at_inception', premium_at_inception);
@ -1136,7 +1152,7 @@
console.log('policy_run_days', policy_run_days); console.log('policy_run_days', policy_run_days);
// Prevent division by zero and calculate earned premium // Prevent division by zero and calculate earned premium
let earned_premium = policy_run_days > 0 ? premium_at_inception / policy_run_days : 0; let earned_premium = premium_as_on_date > 0 ? (premium_as_on_date / 365) * 364 : 0;
console.log('earned_premium', earned_premium); console.log('earned_premium', earned_premium);
let earned_premium_roundoff = Math.round(earned_premium); let earned_premium_roundoff = Math.round(earned_premium);
// Set the calculated value with two decimal places // Set the calculated value with two decimal places
@ -1513,7 +1529,7 @@
$('.freshFields').find('select, input').attr('required', 'required'); $('.freshFields').find('select, input').attr('required', 'required');
$('.freshFields').show(); $('.freshFields').show();
$('.proposed_div').hide().find('select, input').removeAttr('required'); // $('.proposed_div').hide().find('select, input').removeAttr('required');
if (resetValues) { if (resetValues) {
@ -1547,11 +1563,15 @@
$('.renewalFields').show(); $('.renewalFields').show();
$('.renewalFields').find('select, input').attr('required', 'required'); $('.renewalFields').find('select, input').attr('required', 'required');
$('.proposed_div').show().find('select, input').attr('required', 'required'); // $('.proposed_div').show().find('select, input').attr('required', 'required');
$('#policy_end_date').removeAttr('required'); $('#policy_end_date').removeAttr('required');
$('#policy_start_date').removeAttr('required'); $('#policy_start_date').removeAttr('required');
$('#claims').removeAttr('required'); $('#claims').removeAttr('required');
$('#source_policy_start_date').attr('readonly', 'readonly');
$('#source_policy_end_date').attr('readonly', 'readonly');
console.log('readonly set', $('#source_policy_start_date').prop('readonly')); // should print true
if (resetValues) { if (resetValues) {

View File

@ -346,6 +346,11 @@ if (isset($selected_lead_type)) {
let placeholder = isFirstField ? 'First file must be Demography.' : ''; let placeholder = isFirstField ? 'First file must be Demography.' : '';
let accept = isFirstField ? '.xls,.xlsx' : ''; let accept = isFirstField ? '.xls,.xlsx' : '';
if(selected_lead_form_type != 1){
placeholder = '';
accept = '';
}
div.innerHTML = ` div.innerHTML = `
<div class="form-group col-md-5"> <div class="form-group col-md-5">
<label>Document Name<span class="text-danger"></span></label> <label>Document Name<span class="text-danger"></span></label>
@ -452,10 +457,11 @@ if (isset($selected_lead_type)) {
<?php if (isset($lead_edit_data)) { ?> <?php if (isset($lead_edit_data)) { ?>
<script> <script>
setTimeout(function(){ $(document).ready(async function () {
handleEbAndNonEbEdit( handleEbAndNonEbEdit(
<?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>); <?= json_encode($lead_edit_data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>
}, 2000) );
});
function handleEbAndNonEbEdit(data){ function handleEbAndNonEbEdit(data){
if(data.lead_form_type == 1){ if(data.lead_form_type == 1){
@ -467,6 +473,10 @@ if (isset($selected_lead_type)) {
function dynamicLeadsDataForEdit(data) { function dynamicLeadsDataForEdit(data) {
try { try {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
console.log('########### THIS IS EB LEAD ###############') console.log('########### THIS IS EB LEAD ###############')
console.log('Received data:', data); console.log('Received data:', data);
@ -480,7 +490,7 @@ if (isset($selected_lead_type)) {
$('.btnDiv').hide(); $('.btnDiv').hide();
$('#appendArea_' + dataIncrement).empty(); $('#appendArea_' + dataIncrement).empty();
$('#multiFileAppendArea_' + dataIncrement).empty();
if (data.html) { if (data.html) {
$('#appendArea_' + dataIncrement).append(data.html); $('#appendArea_' + dataIncrement).append(data.html);
@ -488,8 +498,8 @@ if (isset($selected_lead_type)) {
console.warn('HTML content missing in data.'); console.warn('HTML content missing in data.');
} }
if (data.multi_file_html) { if (data.multi_file_html && data.multi_file_html != '') {
console.log(data.multi_file_html); $('#multiFileAppendArea_' + dataIncrement).empty();
setTimeout(function(){ setTimeout(function(){
$('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html); $('#multiFileAppendArea_' + dataIncrement).append(data.multi_file_html);
}, 2000) }, 2000)
@ -507,6 +517,10 @@ if (isset($selected_lead_type)) {
leadTypeBsedHideAndShow(lead_type); leadTypeBsedHideAndShow(lead_type);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
if (lead_type == 1) { if (lead_type == 1) {
$('.claim-row').hide(); $('.claim-row').hide();
} else { } else {
@ -518,10 +532,10 @@ if (isset($selected_lead_type)) {
$('.gpaClaimFileds').hide(); $('.gpaClaimFileds').hide();
$('.lifeClaimFields').show(); $('.lifeClaimFields').show();
} else { } else {
updateRenewalFields(dataIncrement); // updateRenewalFields(dataIncrement);
let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement; let incurred_claim_date_id = 'incurred_claim_date_' + dataIncrement;
let premium_date_id = 'premium_date_' + dataIncrement; // let premium_date_id = 'premium_date_' + dataIncrement;
if ($('#' + incurred_claim_date_id).length) { if ($('#' + incurred_claim_date_id).length) {
flatpickr("#" + incurred_claim_date_id, { flatpickr("#" + incurred_claim_date_id, {
@ -530,10 +544,7 @@ if (isset($selected_lead_type)) {
onChange: function (selectedDates) { onChange: function (selectedDates) {
try { try {
let increment = this.input.id.split('_').pop(); let increment = this.input.id.split('_').pop();
let policyStartDate = $("#policy_start_date_" + increment).length let policyStartDate = $("#source_policy_start_date");
? $("#policy_start_date_" + increment)
: $("#policy_start_date");
if (policyStartDate.val()) { if (policyStartDate.val()) {
calculatePolicyRunDays(increment); calculatePolicyRunDays(increment);
} }
@ -546,15 +557,16 @@ if (isset($selected_lead_type)) {
console.warn(`Incurred claim date field #${incurred_claim_date_id} not found.`); console.warn(`Incurred claim date field #${incurred_claim_date_id} not found.`);
} }
if ($('#' + premium_date_id).length) { // if ($('#' + premium_date_id).length) {
flatpickr("#" + premium_date_id, { // flatpickr("#" + premium_date_id, {
dateFormat: "d/m/Y", // dateFormat: "d/m/Y",
allowInput: false // allowInput: false
}); // });
} else { // } else {
console.warn(`Premium date field #${premium_date_id} not found.`); // console.warn(`Premium date field #${premium_date_id} not found.`);
} // }
// console.log($('#proposed_insurer_' + dataIncrement).length);
$('#proposed_insurer_' + dataIncrement).select2(); $('#proposed_insurer_' + dataIncrement).select2();
$('#proposed_tpa_' + dataIncrement).select2(); $('#proposed_tpa_' + dataIncrement).select2();
} }
@ -580,6 +592,8 @@ if (isset($selected_lead_type)) {
$('#client_branch_id').val(data.client_branch_id || '').change(); $('#client_branch_id').val(data.client_branch_id || '').change();
setTimeout(() => { setTimeout(() => {
$('#source_policy_id').val(data.source_policy_id || ''); $('#source_policy_id').val(data.source_policy_id || '');
$('#source_policy_end_date').val(data.source_policy_end_date || '');
$('#source_policy_start_date').val(data.source_policy_start_date || '');
$('#pan').val(data.pan || ''); $('#pan').val(data.pan || '');
$('#gst').val(data.gst || ''); $('#gst').val(data.gst || '');
$('#branch_name').val(data.branch_name || ''); $('#branch_name').val(data.branch_name || '');
@ -592,7 +606,7 @@ if (isset($selected_lead_type)) {
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
}, 1000); }, 1000);
}, 1000); }, 1000);
}, 1000); }, 5000);
let insurer = (data.insurer_branch_id && data.insurer_id) let insurer = (data.insurer_branch_id && data.insurer_id)
? `${data.insurer_branch_id}-${data.insurer_id}` ? `${data.insurer_branch_id}-${data.insurer_id}`
@ -619,6 +633,8 @@ if (isset($selected_lead_type)) {
} }
} catch (error) { } catch (error) {
console.error('Error in dynamicLeadsDataForEdit function:', error); console.error('Error in dynamicLeadsDataForEdit function:', error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
} }
} }

View File

@ -1,80 +1,80 @@
<?php $increment = isset($lead_edit_data) ? "_1" : ''; ?>
<hr> <hr>
<div class="form-row renewalCalculation"> <div class="form-row renewalCalculation">
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="incurred_claim_date">Incurred Claim Date<span class="text-danger"></span></label> <label for="incurred_claim_date">Incurred Claim Date<span class="text-danger"></span></label>
<input value="<?= isset($lead_edit_data['incurred_claim_date']) ? $lead_edit_data['incurred_claim_date'] : '' ?>" type="text" class="form-control incurred_claim" id="incurred_claim_date" <input value="<?= isset($lead_edit_data['incurred_claims_date']) ? $lead_edit_data['incurred_claims_date'] : '' ?>" type="text" class="form-control incurred_claim" id="incurred_claim_date<?= $increment ?>"
name="incurred_claim_date[]" placeholder="Enter DOE"> name="incurred_claim_date[]" placeholder="Enter DOE">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="paid_claims">Paid Claims<span class="text-danger">*</span></label> <label for="paid_claims">Paid Claims<span class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['paid_claims']) ? $lead_edit_data['paid_claims'] : '' ?>" type="text" class="form-control" id="paid_claims" name="paid_claims[]" <input value="<?= isset($lead_edit_data['paid_claims']) ? $lead_edit_data['paid_claims'] : '' ?>" type="text" class="form-control" id="paid_claims<?= $increment ?>" name="paid_claims[]"
placeholder="Enter Paid Claims" oninput="incurredClaimSum(this)"> placeholder="Enter Paid Claims" oninput="incurredClaimSum(this)">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="outstanding_claims">Outstanding Claims<span class="text-danger">*</span></label> <label for="outstanding_claims">Outstanding Claims<span class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['outstanding_claims']) ? $lead_edit_data['outstanding_claims'] : '' ?>" type="text" class="form-control" id="outstanding_claims" name="outstanding_claims[]" <input value="<?= isset($lead_edit_data['outstanding_claims']) ? $lead_edit_data['outstanding_claims'] : '' ?>" type="text" class="form-control" id="outstanding_claims<?= $increment ?>" name="outstanding_claims[]"
placeholder="Enter Outstanding Claims" oninput="incurredClaimSum(this)"> placeholder="Enter Outstanding Claims" oninput="incurredClaimSum(this)">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="incurred_claims">Incurred Claim<span class="text-danger">*</span></label> <label for="incurred_claims">Incurred Claim<span class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['incurred_claims']) ? $lead_edit_data['incurred_claims'] : '' ?>" type="text" class="form-control" id="incurred_claims" name="incurred_claims[]" <input value="<?= isset($lead_edit_data['incurred_claims']) ? $lead_edit_data['incurred_claims'] : '' ?>" type="text" class="form-control" id="incurred_claims<?= $increment ?>" name="incurred_claims[]"
placeholder="Enter Incurred Claim" oninput="incurredClaimSum(this)"> placeholder="Enter Incurred Claim" oninput="incurredClaimSum(this)">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="policy_run_days">Policy Run Days<span class="text-danger">*</span></label> <label for="policy_run_days">Policy Run Days<span class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['policy_run_days']) ? $lead_edit_data['policy_run_days'] : '' ?>" type="text" class="form-control" id="policy_run_days" name="policy_run_days[]" <input value="<?= isset($lead_edit_data['policy_run_days']) ? $lead_edit_data['policy_run_days'] : '' ?>" type="text" class="form-control" id="policy_run_days<?= $increment ?>" name="policy_run_days[]"
placeholder="Enter Policy Run Days" oninput="earnedPremiumCalc(this)" onkeyup="incurredClaimSum(this)"> placeholder="Enter Policy Run Days" oninput="earnedPremiumCalc(this)" onkeyup="incurredClaimSum(this)">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="premium_at_inception">Premium Paid at Inception<span <label for="premium_at_inception">Premium Paid at Inception<span
class="text-danger">*</span></label> class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['premium_at_inception']) ? $lead_edit_data['premium_at_inception'] : '' ?>" type="text" class="form-control" id="premium_at_inception" name="premium_at_inception[]" <input value="<?= isset($lead_edit_data['premium_at_inception']) ? $lead_edit_data['premium_at_inception'] : '' ?>" type="text" class="form-control" id="premium_at_inception<?= $increment ?>" name="premium_at_inception[]"
placeholder="Enter Premium Paid" oninput="earnedPremiumCalc(this)"> placeholder="Enter Premium Paid" oninput="earnedPremiumCalc(this)">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="premium_date">Premium Date<span class="text-danger"></span></label> <label for="premium_date">Premium as on Date<span class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['premium_date']) ? $lead_edit_data['premium_date'] : '' ?>" type="text" class="form-control" id="premium_date" name="premium_date[]" <input value="<?= isset($lead_edit_data['premium_date']) ? $lead_edit_data['premium_date'] : '' ?>" type="text" class="form-control" id="premium_date<?= $increment ?>" name="premium_date[]"
placeholder="Enter Premium Date"> placeholder="Enter Premium Date">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="earned_premium">Earned Premium<span class="text-danger">*</span></label> <label for="earned_premium">Earned Premium<span class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['earned_premium']) ? $lead_edit_data['earned_premium'] : '' ?>" type="text" class="form-control" id="earned_premium" name="earned_premium[]" <input value="<?= isset($lead_edit_data['earned_premium']) ? $lead_edit_data['earned_premium'] : '' ?>" type="text" class="form-control" id="earned_premium<?= $increment ?>" name="earned_premium[]"
placeholder="Enter Earned Premium" oninput="incurredClaimSum(this)"> placeholder="Enter Earned Premium" oninput="incurredClaimSum(this)">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="annualised_claims">Annualised Claims<span class="text-danger">*</span></label> <label for="annualised_claims">Annualised Claims<span class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['annualised_claims']) ? $lead_edit_data['annualised_claims'] : '' ?>" type="text" class="form-control" id="annualised_claims" name="annualised_claims[]" <input value="<?= isset($lead_edit_data['annualised_claims']) ? $lead_edit_data['annualised_claims'] : '' ?>" type="text" class="form-control" id="annualised_claims<?= $increment ?>" name="annualised_claims[]"
placeholder="Enter Annualised Claims"> placeholder="Enter Annualised Claims">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="incurred_claims_ratio">Incurred Claims Ratio<span <label for="incurred_claims_ratio">Incurred Claims Ratio<span
class="text-danger">*</span></label> class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['incurred_claims_ratio']) ? $lead_edit_data['incurred_claims_ratio'] : '' ?>" type="text" class="form-control" id="incurred_claims_ratio" <input value="<?= isset($lead_edit_data['incurred_claims_ratio']) ? $lead_edit_data['incurred_claims_ratio'] : '' ?>" type="text" class="form-control" id="incurred_claims_ratio<?= $increment ?>"
name="incurred_claims_ratio[]" placeholder="Enter Incurred Claims Ratio"> name="incurred_claims_ratio[]" placeholder="Enter Incurred Claims Ratio">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="earned_claims_ratio">Earned Claims Ratio<span class="text-danger">*</span></label> <label for="earned_claims_ratio">Earned Claims Ratio<span class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['earned_claims_ratio']) ? $lead_edit_data['earned_claims_ratio'] : '' ?>" type="text" class="form-control" id="earned_claims_ratio" name="earned_claims_ratio[]" <input value="<?= isset($lead_edit_data['earned_claims_ratio']) ? $lead_edit_data['earned_claims_ratio'] : '' ?>" type="text" class="form-control" id="earned_claims_ratio<?= $increment ?>" name="earned_claims_ratio[]"
placeholder="Enter Earned Claims Ratio"> placeholder="Enter Earned Claims Ratio">
</div> </div>
<div class="form-group col-md-3 renewalFields" style="display: none;"> <!-- <div class="form-group col-md-3 renewalFields" style="display: none;">
<label for="location">Location <span class="text-danger">*</span></label> <label for="location">Location <span class="text-danger">*</span></label>
<input value="<?= isset($lead_edit_data['location']) ? $lead_edit_data['location'] : '' ?>" type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location"> <input value="<?php //echo isset($lead_edit_data['location']) ? $lead_edit_data['location'] : '' ?>" type="text" class="form-control" id="location" name="location[]" placeholder="Enter Location">
</div> </div> -->
<div class="form-group col-md-3 proposed_div" style="display: none;"> <div class="form-group col-md-3 proposed_div" style="display: none;">
<label for="proposed_insurer">Proposed Insurer <span class="text-danger"></span></label> <label for="proposed_insurer">Proposed Insurer <span class="text-danger"></span></label>

View File

@ -49,7 +49,7 @@
<div class="row"> <div class="row">
<img src="https://venbait.in/nhance/helpdesk/dev/assets/helpdeskz/images/agent.jpg" <img src="https://venbait.in/nhance/helpdesk/dev/assets/helpdeskz/images/agent.jpg"
class="user-avatar rounded-circle img-fluid col-mb-6" style="max-width: 70px"> class="user-avatar rounded-circle img-fluid col-mb-6" style="max-width: 70px">
<div style="padding-left: 10px;padding-top: 15px;" class="col-mb-6"><?= $message_data['user_name'] ?></div> <div style="padding-left: 10px;padding-top: 15px;" class="col-mb-6"><?= $message['user_name'] ?? "Auto Mail" ?></div>
</div> </div>
<span style="text-align: center; position: relative;text-align: center;bottom: 28px;left: 15px;" class="badge badge-primary">Staff</span> <span style="text-align: center; position: relative;text-align: center;bottom: 28px;left: 15px;" class="badge badge-primary">Staff</span>

View File

@ -20,7 +20,7 @@
<td><?php echo $row['display_name']; ?></td> <td><?php echo $row['display_name']; ?></td>
<td><?php echo $row['old_value'].' => '.$row['new_value']; ?></td> <td><?php echo $row['old_value'].' => '.$row['new_value']; ?></td>
<!-- <td><?php //echo $row['new_value']; ?></td> --> <!-- <td><?php //echo $row['new_value']; ?></td> -->
<td><?php echo $row['modified_by'] ?? "Created by employee"; ?></td> <td><?php echo !empty($row['modified_by'])? $row['modified_by'] : "Created by employee"; ?></td>
<!-- <td><?php //echo $row['created_at']; ?></td> --> <!-- <td><?php //echo $row['created_at']; ?></td> -->
<td><?php echo date("d-m-Y H:i:s a", strtotime($row['created_at'])) ?? " - "; ?></td> <td><?php echo date("d-m-Y H:i:s a", strtotime($row['created_at'])) ?? " - "; ?></td>
</tr> </tr>

View File

@ -225,14 +225,18 @@
<button id="addQuote" class="btn btn-custom">Add New Proposal</button> <button id="addQuote" class="btn btn-custom">Add New Proposal</button>
<button id="submitData" class="btn btn-primary">Save RFQ</button> <button id="submitData" class="btn btn-primary">Save RFQ</button>
<?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> <button id="submitQCRData" onclick="checkTheTableDataChanged(5)" class="btn btn-primary">Procced to QCR</button>
<?php } ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <?php } ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary" id>Export Excel</a> <a id="submitExcel" onclick="checkTheTableDataChanged(2)" class="btn btn-primary" id>Export Excel</a>
<button id="submitInternalMail" class="btn btn-primary" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button> <button id="submitInternalMail" class="btn btn-primary" onclick="checkTheTableDataChanged(4)">Send Internal Mail</button>
<button id="submitMail" class="btn btn-primary" onclick="checkTheTableDataChanged(3)">Send Insurer Mail</button> <?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> <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="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 ?>"> <input type="hidden" id="qcr_count" value="<?= isset($qcr_count) ? $qcr_count : 0 ?>">
<!-- <button id="openDialogBtn">Open Dialog</button> --> <!-- <button id="openDialogBtn">Open Dialog</button> -->
@ -421,13 +425,16 @@
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="cc">CC </label> <label for="cc">CC </label>
<select class="form-control" id="cc" name="cc" required multiple> <select class="form-control" id="cc" name="cc" required multiple>
<?php if (isset($userList)) { ?> <?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php foreach ($userList as $user) { ?> <?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'];?>"> <option value="<?= $user['id'];?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'].' - '.$user['email'];?>
</option> </option>
<?php } ?> <?php } ?>
<?php } ?> <?php } ?>
<?php } ?>
</select> </select>
</div> </div>
@ -484,30 +491,45 @@
<div class="form-row"> <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"> <div class="form-group col-md-3">
<label for="utr_no">UTR No.</label> <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>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="placement_date">Placement Date</label> <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>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="premium_amount">Premium Amount</label> <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>
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="total_amount">Total Amount</label> <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>
<div class="form-group col-md-3"> <?php } ?>
<label for="cd_amount">CD Amount</label>
<input type="text" class="form-control" id="cd_amount" name="cd_amount" placeholder="Enter CD Amount">
</div>
</div> </div>
<hr> <hr>
@ -530,12 +552,15 @@
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="placement_cc">CC </label> <label for="placement_cc">CC </label>
<select class="form-control" id="placement_cc" name="placement_cc" required multiple> <select class="form-control" id="placement_cc" name="placement_cc" required multiple>
<?php if (isset($userList)) { ?> <?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php foreach ($userList as $user) { ?> <?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'];?>"> <option value="<?= $user['id'];?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'].' - '.$user['email'];?>
</option> </option>
<?php } ?> <?php } }?>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
@ -797,6 +822,11 @@
allowInput: false, allowInput: false,
}); });
var payment_date_datePicker = flatpickr("#payment_date", {
dateFormat: "d/m/Y",
allowInput: false,
});
}) })
@ -804,6 +834,13 @@
<script> <script>
$(document).ready(function () {
setInterval(function () {
submitData(1);
}, 15000);
});
const openDialogBtn = document.getElementById('openDialogBtn'); const openDialogBtn = document.getElementById('openDialogBtn');
const closeDialogBtn = document.getElementById('closeDialogBtn'); const closeDialogBtn = document.getElementById('closeDialogBtn');
@ -830,6 +867,24 @@ var over_all_column_data = {
'insurers': [] '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 () { // document.addEventListener("DOMContentLoaded", function () {
const rfqTable = document.getElementById('rfqTable'); const rfqTable = document.getElementById('rfqTable');
@ -1283,6 +1338,17 @@ function moveAddRowButton() {
rfqTable.addEventListener('click', function(e) { rfqTable.addEventListener('click', function(e) {
if (e.target.classList.contains('removeRow')) { if (e.target.classList.contains('removeRow')) {
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 row = e.target.closest('tr'); // Get the row to be removed
const rowKey = row.getAttribute('id'); const rowKey = row.getAttribute('id');
@ -1297,6 +1363,10 @@ rfqTable.addEventListener('click', function(e) {
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 +1511,6 @@ function showSuggestions(input) {
// Function to handle answers suggestion box // Function to handle answers suggestion box
function showAnswersSuggestions(input) { function showAnswersSuggestions(input) {
console.log(input.parentElement.id); console.log(input.parentElement.id);
console.log(input); console.log(input);
//return; //return;
@ -2142,7 +2211,17 @@ function removeProposal(event) {
let rfqTable = document.getElementById('rfqTable'); let rfqTable = document.getElementById('rfqTable');
console.log(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 headerRows = rfqTable.querySelectorAll('thead tr');
const parentTh = headerRows[0].children[colIndex]; const parentTh = headerRows[0].children[colIndex];
@ -2187,11 +2266,23 @@ function removeProposal(event) {
console.log(`${proposal_name} does not exist.`); console.log(`${proposal_name} does not exist.`);
} }
} }
})
} }
function removeInsurer(event) { function removeInsurer(event) {
if (confirm("Are you sure you want to remove this column?")) { 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) { // function removeSubColumnByIndex(tableId, subThIndex) {
const table = document.getElementById('rfqTable'); const table = document.getElementById('rfqTable');
const headerRows = table.querySelectorAll('thead tr'); const headerRows = table.querySelectorAll('thead tr');
@ -2250,6 +2341,8 @@ function removeInsurer(event) {
isFormDataModified = true; // if any value changeing in the table to set true isFormDataModified = true; // if any value changeing in the table to set true
} }
})
} }
function showThreeDottedMenu(event) { function showThreeDottedMenu(event) {
@ -2739,7 +2832,7 @@ function handleChildQuestions(target) {
let childCell = childRow.cells[currentColumnIndex]; let childCell = childRow.cells[currentColumnIndex];
if (childCell) { if (childCell) {
console.log('found cell'); console.log('found cell',inputValue);
if (inputValue.key == disable_at.key) { if (inputValue.key == disable_at.key) {
childCell.innerHTML = ''; childCell.innerHTML = '';
@ -2759,6 +2852,21 @@ function handleChildQuestions(target) {
console.log(child.default_answer.display_value) console.log(child.default_answer.display_value)
childCell.contentEditable = false; childCell.contentEditable = false;
} else { } 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; childCell.contentEditable = true;
} }
} }
@ -3136,7 +3244,7 @@ function ajaxRequestForGetMailData(url) {
function appendInput(data) { function appendInput(data) {
console.log(data); console.log("append data:",data);
var lead_id = $('#lead_id').val(); var lead_id = $('#lead_id').val();
$('#input_for_row').empty(); $('#input_for_row').empty();
let html = ''; let html = '';
@ -3146,9 +3254,9 @@ function appendInput(data) {
const url = '<?= base_url('leads/list') ?>?lead_id=' + lead_id; const url = '<?= base_url('leads/list') ?>?lead_id=' + lead_id;
html += ` html += `
<div class="form-group col-md-4"> <div class="form-group col-md-12">
<label for="contact_mail">Client Contact Mail</label> <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> </div>
`; `;
@ -3164,28 +3272,32 @@ function appendInput(data) {
html += ` html += `
<div class="form-group col-md-4"> <div class="form-group col-md-6">
<label for="client_cc">CC </label> <label for="client_cc">CC </label>
<select class="form-control" id="client_cc" name="client_cc" required multiple> <select class="form-control" id="client_cc" name="client_cc" required multiple>
<?php if (isset($userList)) { ?> <?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php foreach ($userList as $user) { ?> <?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'];?>"> <option value="<?= $user['id'];?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'].' - '.$user['email'];?>
</option> </option>
<?php } ?> <?php } } ?>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-6">
<label for="client_bcc">BCC </label> <label for="client_bcc">BCC </label>
<select class="form-control" id="client_bcc" name="client_bcc" required multiple> <select class="form-control" id="client_bcc" name="client_bcc" required multiple>
<?php if (isset($userList)) { ?> <?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php foreach ($userList as $user) { ?> <?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'];?>"> <option value="<?= $user['id'];?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'].' - '.$user['email'];?>
</option> </option>
<?php } ?> <?php } } ?>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
@ -3196,7 +3308,7 @@ function appendInput(data) {
html += ` html += `
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="mail_subject">Subject</label> <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> </div>
`; `;
@ -3229,25 +3341,28 @@ function appendInput(data) {
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="client_cc">CC </label> <label for="client_cc">CC </label>
<select class="form-control" id="client_cc" name="client_cc" required multiple> <select class="form-control" id="client_cc" name="client_cc" required multiple>
<?php if (isset($userList)) { ?> <?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php foreach ($userList as $user) { ?> <?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'];?>"> <option value="<?= $user['id'];?>">
<?= $user['first_name'].' - '.$user['email'];?> <?= $user['first_name'].' - '.$user['email'];?>
</option> </option>
<?php } ?> <?php } ?>
<?php } ?> <?php } }?>
</select> </select>
</div> </div>
<div class="form-group col-md-4"> <div class="form-group col-md-4">
<label for="client_bcc">BCC </label> <label for="client_bcc">BCC </label>
<select class="form-control" id="client_bcc" name="client_bcc" required multiple> <select class="form-control" id="client_bcc" name="client_bcc" required multiple>
<?php if (isset($userList)) { ?> <?php if($page_name == "RFQ") { $exclusiveUserList = $userList; } ?>
<?php foreach ($userList as $user) { ?> <?php if (isset($exclusiveUserList)) { ?>
<option value="<?= $user['id'];?>"> <?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'];?> <?= $user['first_name'].' - '.$user['email'];?>
</option> </option>
<?php } ?> <?php } } ?>
<?php } ?> <?php } ?>
</select> </select>
</div> </div>
@ -3307,7 +3422,13 @@ function appendInput(data) {
function constructURL(url_type) { function constructURL(url_type) {
if(url_type == 1){ 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){ }else if(url_type == 2){
constructURL_ForInternalMailSend() constructURL_ForInternalMailSend()
}else if(url_type == 3){ }else if(url_type == 3){
@ -3470,6 +3591,7 @@ function constructURL_ForInsurerAndClientMailSend() {
var subject = $('#mail_subject').val(); var subject = $('#mail_subject').val();
var bcc = $('#client_bcc').val(); var bcc = $('#client_bcc').val();
var cc = $('#client_cc').val(); var cc = $('#client_cc').val();
var contact_mail = $("#contact_mail").val();
console.log('lead_id', lead_id) console.log('lead_id', lead_id)
console.log('subject', subject) console.log('subject', subject)
@ -3501,6 +3623,7 @@ function constructURL_ForInsurerAndClientMailSend() {
if (RFQ_or_QCR == 2) { if (RFQ_or_QCR == 2) {
formData.append('contact_mail',contact_mail);
formData.append('file_type', 'qcr'); formData.append('file_type', 'qcr');
formData.append('recipient_type', 'client'); formData.append('recipient_type', 'client');
formData.append('recipient_mail', ''); formData.append('recipient_mail', '');
@ -3560,6 +3683,8 @@ function constructURL_ForPlacementMailSend() {
var lead_id = $('#lead_id').val(); var lead_id = $('#lead_id').val();
let to = $('#placement_to').val(); let to = $('#placement_to').val();
let placement_date = $('#placement_date').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 utr_no = $('#utr_no').val();
let premium_amount = $('#premium_amount').val(); let premium_amount = $('#premium_amount').val();
let total_amount = $('#total_amount').val(); let total_amount = $('#total_amount').val();
@ -3590,6 +3715,8 @@ function constructURL_ForPlacementMailSend() {
formData.append('proposal_insurer', proposal_insurer); formData.append('proposal_insurer', proposal_insurer);
formData.append('insurer_and_branch', insurer_and_branch); formData.append('insurer_and_branch', insurer_and_branch);
formData.append('placement_date', placement_date); 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('utr_no', utr_no);
formData.append('premium_amount', premium_amount); formData.append('premium_amount', premium_amount);
formData.append('total_amount', total_amount); formData.append('total_amount', total_amount);
@ -3661,7 +3788,7 @@ function ajaxRequest(formData) {
$('#placement_cc').val('').select2({ $('#placement_cc').val('').select2({
placeholder : 'select CC Mail' placeholder : 'select CC Mail'
}); });
$('#placement_subject').val(''); // $('#placement_subject').val('');
$("textarea.select2-search__field").attr('rows', '1'); $("textarea.select2-search__field").attr('rows', '1');
$("textarea.select2-search__field").css('resize', 'none'); $("textarea.select2-search__field").css('resize', 'none');
@ -3738,7 +3865,7 @@ $('.close').click(function(){
$('#placement_cc').val('').select2({ $('#placement_cc').val('').select2({
placeholder : 'select CC Mail' placeholder : 'select CC Mail'
}); });
$('#placement_subject').val(''); // $('#placement_subject').val('');
$("textarea.select2-search__field").attr('rows', '1'); $("textarea.select2-search__field").attr('rows', '1');
$("textarea.select2-search__field").css('resize', 'none'); $("textarea.select2-search__field").css('resize', 'none');
@ -5220,7 +5347,8 @@ function appendMultiFileData(data) {
<script> <script>
async function submitData(json) { async function submitData(input) {
console.log(over_all_column_data); console.log(over_all_column_data);
try { try {
@ -5235,6 +5363,7 @@ function appendMultiFileData(data) {
// Create a FormData object // Create a FormData object
const formData = new FormData(); const formData = new FormData();
let lead_id = $('#lead_id').val(); let lead_id = $('#lead_id').val();
let rfq_primaryKey = $('#rfq_primaryKey').val();
let submit_type = "RFQ" let submit_type = "RFQ"
if(RFQ_or_QCR == 2){submit_type = 'QCR'} if(RFQ_or_QCR == 2){submit_type = 'QCR'}
@ -5243,6 +5372,10 @@ function appendMultiFileData(data) {
formData.append('lead_id', lead_id); formData.append('lead_id', lead_id);
formData.append('submit_type', submit_type); formData.append('submit_type', submit_type);
if(input == 1){
formData.append('rfq_primaryKey', rfq_primaryKey);
}
const postUrl = '<?= base_url('rfq/create')?>'; const postUrl = '<?= base_url('rfq/create')?>';
console.log(postUrl); console.log(postUrl);
@ -5258,11 +5391,14 @@ function appendMultiFileData(data) {
if (response.status == true) { if (response.status == true) {
toastr.success(response.message, 'SUCCESS'); toastr.success(response.message, 'SUCCESS');
$('#rfq_primaryKey').val(response.id);
} else { } else {
toastr.warning(response.message, 'WARNING'); toastr.warning(response.message, 'WARNING');
} }
if(input != 1){
window.location.reload(); window.location.reload();
}
} catch (error) { } catch (error) {
console.error('An error occurred during the AJAX request:'); console.error('An error occurred during the AJAX request:');
@ -5733,4 +5869,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> </script>