diff --git a/app/Controllers/Chatbot/EcardDownloadConversation.php b/app/Controllers/Chatbot/EcardDownloadConversation.php
index 84617af1..c38d6977 100644
--- a/app/Controllers/Chatbot/EcardDownloadConversation.php
+++ b/app/Controllers/Chatbot/EcardDownloadConversation.php
@@ -23,6 +23,8 @@ class EcardDownloadConversation extends Conversation
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
$buttons = [];
$question = 'Choose Policy to Download Ecard:';
+ log_message('error', ('policy_list : ' . json_encode($policy_list)));
+
if(is_array($policy_list) && count($policy_list))
{
foreach($policy_list as $policy)
diff --git a/app/Controllers/Chatbot/MainMenuConversation.php b/app/Controllers/Chatbot/MainMenuConversation.php
index 875ecba4..f06fd078 100644
--- a/app/Controllers/Chatbot/MainMenuConversation.php
+++ b/app/Controllers/Chatbot/MainMenuConversation.php
@@ -53,6 +53,8 @@ class MainMenuConversation extends Conversation
$user_reponse = null;
}
+ log_message('error', ('user_reponse is interactive: ' . $answer->isInteractiveMessageReply()));
+
// Get just the existing path array
$path = $this->bot->userStorage()->get('path') ?? [];
@@ -65,28 +67,35 @@ class MainMenuConversation extends Conversation
'path' => $path
]);
- log_message('error', ('user_reponse : ' . $user_reponse));
+ log_message('error', ('user_reponse after: ' . $user_reponse));
switch ($user_reponse) {
case "ecard_download":
$this->bot->startConversation(new EcardDownloadConversation());
+ log_message('error', 'ecard_download clicked ');
+
break;
case "network_hospital":
$this->bot->startConversation(new NetworkHospitalConversation());
+ log_message('error', 'network_hospital clicked ');
break;
case "reimbursement_claim":
$this->bot->startConversation(new ReimbursementClaimProcessConversation());
+ log_message('error', 'reimbursement_claim clicked ');
break;
case "reimbursement_status":
$this->bot->startConversation(new ReimbursementClaimStatusConversation());
+ log_message('error', 'reimbursement_status clicked ');
break;
case "new_policy":
case "renew_policy":
$this->bot->startConversation(new policyConversation());
+ log_message('error', 'renew_policy || new_policy clicked ');
break;
default:
+ log_message('error', 'default shown ');
$this->say("Invalid selection. Please choose an option.");
$this->bot->startConversation(new MainMenuConversation());
break;
diff --git a/app/Controllers/ChatbotControllerNew.php b/app/Controllers/ChatbotControllerNew.php
index 2f6ca404..dc38a3c9 100644
--- a/app/Controllers/ChatbotControllerNew.php
+++ b/app/Controllers/ChatbotControllerNew.php
@@ -84,6 +84,7 @@ class ChatbotControllerNew extends BaseController
public function index()
{
+
if($this->session->get('CHATBOT_RANDOM_USER_ID') == '-' || $this->session->get('CHATBOT_RANDOM_USER_ID') == '')
{
@@ -100,6 +101,7 @@ class ChatbotControllerNew extends BaseController
}
$this->botman->hears('.*', function ($bot) {
+ log_message("error","Inside Bot Type Function");
$bot->types(); // Typing indicator for the first message
sleep(0.5); // Delay
diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php
index 0a096c82..21f0afa5 100755
--- a/app/Controllers/ClientController.php
+++ b/app/Controllers/ClientController.php
@@ -1994,9 +1994,22 @@ class ClientController extends AdminController
if ($id) {
$client_policy_data = $this->clientPolicyModel->where(['id' => $id, 'is_active' => 1])->first();
+
$insurer_id = $client_policy_data['insurer_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
->select('policies.*, policy_type.policy_type')
->join('policy_type', 'policy_type.id = policies.policy_type_id')
@@ -2022,7 +2035,7 @@ class ClientController extends AdminController
'policy' => $polices,
'client_policy_list' => $client_policy_list,
'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);
} else {
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();
- // $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(125, 2);
- // // Kint::dump($RFQdata);
+ // $RFQdata = $RFQModel->getRFQTableDataWithLeadIDAndType(145, 2);
// $returnData = $LeadsController->getPlacementJson($data);
// Kint::dump($returnData);
// $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();
// 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);
+
+
}
// -------------------------------------------------------------------------------------------------------
@@ -5456,6 +5482,207 @@ class ClientController extends AdminController
$id = $InsurerModel->insert($insurerData);
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;
+ }
+
+
}
diff --git a/app/Controllers/EmployeeRestController.php b/app/Controllers/EmployeeRestController.php
index e86f5de7..9b137fda 100755
--- a/app/Controllers/EmployeeRestController.php
+++ b/app/Controllers/EmployeeRestController.php
@@ -3124,6 +3124,18 @@ class EmployeeRestController extends AdminController
$client_policy_id = $received_data['client_policy_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 = "
select
cp.policy_type_id,
@@ -3166,11 +3178,19 @@ class EmployeeRestController extends AdminController
if(!empty($emp_ticket_data)){
$fetchData = $emp_ticket_data[0];
- $fetchData['claim_status_id'] = $this->claimStatusModel
- ->select('id')
- ->where('ticket_type', $fetchData['ticket_type_id'])
- ->orderBy('id', 'asc')
- ->first()['id'];
+
+ $claimStatusQuery = $this->claimStatusModel
+ ->select('id')
+ ->where('ticket_type', $fetchData['ticket_type_id'])
+ ->orderBy('id', 'asc');
+
+ 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['mode_of_intimation'] = 3;
diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php
index 02134611..617add8f 100644
--- a/app/Controllers/LeadsController.php
+++ b/app/Controllers/LeadsController.php
@@ -40,6 +40,7 @@ use Kint\Kint;
use App\Controllers\Jobs;
use App\Controllers\JobWorker;
use Google\Service\FactCheckTools\Resource\Claims;
+use GPBMetadata\Google\Type\Datetime;
class LeadsController extends BaseController
{
@@ -101,7 +102,7 @@ class LeadsController extends BaseController
$this->leadType = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
$this->buisnessType = [1 => 'Industrial', 2 => 'Non Industrial'];
$this->leadsStatus = [
- 'queued' => 'Queued',
+ 'queued' => 'In-Queued',
'qcr_sent' => 'QCR sent',
'lost' => 'Lost',
'co_insurer_pending' => 'Co-Insurer Pending',
@@ -202,6 +203,7 @@ class LeadsController extends BaseController
} else {
$data = $this->prepareMultipleLeadData($data);
}
+
// print_r($data); die;
return $data;
}
@@ -210,8 +212,8 @@ class LeadsController extends BaseController
{
// print_r($data); die;
$index_plus_one = 1;
- $form_file_name = "file_name_".$index_plus_one;
- $form_docs_name = "docs_name_".$index_plus_one;
+ $form_file_name = "file_name_" . $index_plus_one;
+ $form_docs_name = "docs_name_" . $index_plus_one;
$leads_file_primary_key = $data['leads_file_id'] ?? [];
$files = $this->request->getFileMultiple($form_file_name);
$multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key);
@@ -252,7 +254,7 @@ class LeadsController extends BaseController
}
// $data['file_name'] = file_Upload($files, $uploadFilePath);
- $data['multi_file_data']= $multi_file_data ?? null;
+ $data['multi_file_data'] = $multi_file_data ?? null;
$processcedData[] = $data;
@@ -268,8 +270,8 @@ class LeadsController extends BaseController
foreach ($data['policy_type_id'] as $index => $value) {
$index_plus_one = $index + 1;
- $form_file_name = "file_name_".$index_plus_one;
- $form_docs_name = "docs_name_".$index_plus_one;
+ $form_file_name = "file_name_" . $index_plus_one;
+ $form_docs_name = "docs_name_" . $index_plus_one;
$leads_file_primary_key = $data['leads_file_id'] ?? [];
$files = $this->request->getFileMultiple($form_file_name);
$multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key);
@@ -323,10 +325,22 @@ class LeadsController extends BaseController
$incurred_claims_date = null;
}
- if (!empty($data['premium_date'][$index])) {
- $premium_date = change_date_format($data['premium_date'][$index], 'd/m/Y', 'Y-m-d');
+ // if (!empty($data['premium_date'][$index])) {
+ // $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 {
- $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);
@@ -383,7 +397,7 @@ class LeadsController extends BaseController
'outstanding_claims' => $data['outstanding_claims'][$index] ?? 0,
'policy_run_days' => $data['policy_run_days'][$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,
'annualised_claims' => $data['annualised_claims'][$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,
'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();
@@ -479,11 +496,11 @@ class LeadsController extends BaseController
$data['incurred_claims_date'] = null;
}
- if (!empty($data['premium_date'])) {
- $data['premium_date'] = change_date_format($data['premium_date'], 'Y-m-d', 'd/m/Y');
- } else {
- $data['premium_date'] = null;
- }
+ // if (!empty($data['premium_date'])) {
+ // $data['premium_date'] = change_date_format($data['premium_date'], 'Y-m-d', 'd/m/Y');
+ // } else {
+ // $data['premium_date'] = null;
+ // }
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->first() ?? null;
@@ -538,26 +555,25 @@ class LeadsController extends BaseController
}
public function insertMultiFilesData($data, $lead_id)
- {
+ {
// print_r($data); die;
- if(!empty($data)){
+ if (!empty($data)) {
foreach ($data as $key => $value) {
- if(!empty($value['id'])){
+ if (!empty($value['id'])) {
$lead_file_data = [
'lead_id' => $lead_id,
'docs_name' => $value['docs_name'],
];
- if(!empty($value['file_name'])) {
+ if (!empty($value['file_name'])) {
$lead_file_data['file_name'] = $value['file_name'];
}
$this->leadFilesModel->where('id', $value['id'])->set($lead_file_data)->update();
-
- }else{
+ } else {
$lead_file_data = [
'lead_id' => $lead_id,
@@ -566,8 +582,8 @@ class LeadsController extends BaseController
];
$this->leadFilesModel->insert($lead_file_data);
}
-
- if($key == 0 && !empty($value['file_name'])) {
+
+ if ($key == 0 && !empty($value['file_name'])) {
$this->leadsModel->where('id', $lead_id)->set('file_name', $value['file_name'])->update();
}
}
@@ -577,22 +593,16 @@ class LeadsController extends BaseController
}
public function removeMultiFile()
- {
+ {
$id = $this->request->getGet('lead_file_id');
- if(!empty($id)){
+ if (!empty($id)) {
$this->leadFilesModel->where('id', $id)->set(['is_active' => 0])->update();
return $this->respond(['status' => true, 'message' => 'File removed successfully'], 200);
- }else{
+ } else {
return $this->respond(['status' => false, 'message' => 'File could not be removed.'], 200);
}
}
-
- public function updateLeadTableFields()
- {
-
- }
-
- //--------RFQ-----------------------------------------------------------------------------------------------
+ //--------RFQ-----------------------------------------------------------------------------------------------
public function viewRFQ($id, $type = 1)
@@ -646,6 +656,7 @@ class LeadsController extends BaseController
$data['page_name'] = $type == 2 ? 'QCR' : 'RFQ';
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
$data['userList'] = $this->userModel->getUserListForRFQ();
+ $data['exclusiveUserList'] = $this->userModel->getexclusiveUserListForRFQ();
$data['lead_data'] = $lead_data;
$mail_content = "
@@ -654,18 +665,32 @@ class LeadsController extends BaseController
Please find attached the {{RFQ_OR_QCR}} for {{POLICY_TYPE}} policy pertaining to {{CLIENT_NAME}} .
Kindly request you to share the competitive quotes at the earliest.
In case of any query, please feel free to contact us.
- Thank You!
+ Thank You!
+ Best regards,
+
+
+
{{LOGGED_USER_NAME}}
+
Email: {{LOGGED_USER_EMAIL}}
+
Mobile: {{LOGGED_USER_MOBILE}}
+
+
+
+
";
+ if ($data['lead_data']['policy_end_date'] != null){
+ $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}} {{POLICY_END_DATE}}";
+ }else{
+ $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}";
- $subject = "{{CLIENT_NAME}} _ {{POLICY_TYPE}} _ {{RFQ_OR_QCR}} _ {{POLICY_YEAR}}";
+ }
$data['mail_content'] = $this->transformMailContent($lead_data, $mail_content, $data['page_name']);
$data['subject'] = $this->transformMailContent($lead_data, $subject, $data['page_name']);
$data['multi_file_data'] = $this->leadFilesModel->where('lead_id', $id)->where('is_active', 1)->findAll() ?? null;
$data['attachment_html'] = view('rfq/attachment_files', $data) ?? "";
-
+ $data['user_team'] = $this->userModel->select("ut.team_id")->join("user_teams ut","ut.user_id = user_profiles.id and ut.is_active = 1")->where("user_profiles.is_active",1)->first()['team_id'];
// dd($data);
if ($data['lead_data']['lead_form_type'] == 1) {
@@ -676,14 +701,14 @@ class LeadsController extends BaseController
$data['occupancy'] = $this->occupancyModel->findAll();
// dd($data['occupancy']);
- if($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0){
+ if ($lead_data['lead_type'] != 1 && $data['rfq_count'] == 0) {
$client_policy_data = $this->clientPolicyModel->where('is_active', 1)->where('id', $lead_data['source_policy_id'])->first();
$data['rfq_data']['json'] = $client_policy_data['placement_json'];
}
- if(!empty($data['question_json'])){
+ if (!empty($data['question_json'])) {
$data['policies'] = json_decode($data['question_json'], true)['policies'];
- $data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
+ $data["child_table_data"] = json_decode($data['question_json'], true)['child_table_data'];
}
// $data['lead_register_data'] = json_decode($data['lead_data']['custom_fields']);
@@ -735,15 +760,24 @@ class LeadsController extends BaseController
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;
// Deactivate existing RFQs for this lead and type
- $this->RFQModel
- ->where('lead_id', $lead_id)
- ->where('type', 1)
- ->where('is_active', 1)
- ->set('is_active', 0)
- ->update();
+ if (!isset($data['rfq_primaryKey']) && empty($data['rfq_primaryKey'])) {
+ $this->RFQModel
+ ->where('lead_id', $lead_id)
+ ->where('type', 1)
+ ->where('is_active', 1)
+ ->set('is_active', 0)
+ ->update();
+ }
// Handle registration_json
if (empty($data['registration_json'])) {
@@ -759,20 +793,29 @@ class LeadsController extends BaseController
}
}
- // Insert new RFQ
- $insertId = $this->RFQModel->insert($data);
+ // 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
+ $insertId = $this->RFQModel->insert($data);
+ }
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([
'status' => true,
'id' => $insertId,
'message' => $message,
- 'data' => $data
+ 'data' => $data,
+ 'affectedRows' => $affectedRows ?? null,
], 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([
'status' => false,
'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------------------------------------------------------------------------------------------------
@@ -880,7 +1123,7 @@ class LeadsController extends BaseController
if ($rfq_data['policy_type_id'] == 2) {
$lead_data = [
-
+ 'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'Policy Status' => $rfq_data['status'],
@@ -893,6 +1136,7 @@ class LeadsController extends BaseController
];
} else if ($rfq_data['policy_type_id'] == 1) {
$lead_data = [
+ 'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'No of Employees at Inception' => $rfq_data['incept_emp_count'],
'Total Sum Insured at Inception ' => $rfq_data['total_si_at_incept'],
@@ -905,6 +1149,7 @@ class LeadsController extends BaseController
} else {
if ($rfq_data['policy_type_id'] == 2) {
$lead_data = [
+ 'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'Policy Status' => $rfq_data['status'],
@@ -933,6 +1178,7 @@ class LeadsController extends BaseController
];
} else if ($rfq_data['policy_type_id'] == 1) {
$lead_data = [
+ 'policy_end_date' => $rfq_data['policy_end_date'],
'Insured' => $rfq_data['client_name'],
'No of Employees at Renewal' => $rfq_data['renewal_emp_count'],
'Total Sum Insured at Renewal ' => $rfq_data['total_si_at_renewal'],
@@ -966,7 +1212,7 @@ class LeadsController extends BaseController
// Start with lead_data at the top
$rowNumber = 1;
- $mergeRange1 = "A{$rowNumber}:C{$rowNumber}";
+ $mergeRange1 = "A{$rowNumber}:B{$rowNumber}";
$sheet->mergeCells($mergeRange1);
$sheet->setCellValue("A{$rowNumber}", "Nhance India Insurance Broking Pvt Ltd");
$sheet->getStyle("A{$rowNumber}")->applyFromArray([
@@ -981,13 +1227,13 @@ class LeadsController extends BaseController
]);
// 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
$drawing = new Drawing();
$path = ROOTPATH . "public/assets/images/Nhance-Logo-Final.png"; // Use FCPATH for server 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
// Center align the image in the cell
@@ -997,8 +1243,8 @@ class LeadsController extends BaseController
$drawing->setWorksheet($sheet);
// Apply center alignment to the cell
- $sheet->getStyle("D{$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()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
+ $sheet->getStyle("C{$rowNumber}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
$rowNumber = $rowNumber + 1;
@@ -1011,7 +1257,7 @@ class LeadsController extends BaseController
// Merge A:B for key and C:D for value
$mergeRangeKey = "A{$rowNumber}:B{$rowNumber}";
- $mergeRangeValue = "C{$rowNumber}:D{$rowNumber}";
+ $mergeRangeValue = "C{$rowNumber}";
$sheet->mergeCells($mergeRangeKey);
$sheet->mergeCells($mergeRangeValue);
@@ -1044,9 +1290,9 @@ class LeadsController extends BaseController
// Set column width based on max content length (adjusted for padding)
$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('D')->setWidth($maxWidthB * 1.2);
+ // $sheet->getColumnDimension('D')->setWidth($maxWidthB * 1.2);
// $rowNumber += 2;
@@ -1105,7 +1351,7 @@ class LeadsController extends BaseController
}
if ($header['parentHeader'] === 'Particulars') {
- $sheet->getColumnDimension('B')->setWidth(40);
+ $sheet->getColumnDimension('B')->setWidth(80);
}
$startColumn = $columnLetter; // Start of the current header range
@@ -1289,7 +1535,7 @@ class LeadsController extends BaseController
}
$lastRow = count($lead_data) + 1;
- $leadRange = "A1:D{$lastRow}";
+ $leadRange = "A1:C{$lastRow}";
$sheet->getStyle($leadRange)->applyFromArray([
'borders' => [
@@ -1300,9 +1546,25 @@ class LeadsController extends BaseController
],
]);
+
+
// Set filename
$string = ($type == 2) ? 'QCR' : 'RFQ';
- $filename = "{$string}_{$rfq_data['client_short_name']}_{$rfq_data['policy_type']}_" . date('YmdHis') . '.xlsx';
+ $current_year = date('Y');
+ $next_year = $current_year + 1;
+ $policy_year = "$current_year-$next_year";
+
+ if (!empty($rfq_data['policy_end_date'])){
+ $policy_expiry = strtotime($lead_data['policy_end_date']);
+
+ $formatted_policy = date("d-m-Y",$policy_expiry);
+
+ $filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" .$policy_year.'(Due On '.$formatted_policy . ')' .'.xlsx';
+
+ }else{
+ $filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_".$policy_year.'_' . '.xlsx';
+ }
+
// Save to temporary location
$uploadFilePath = WRITEPATH . 'tmp/' . $filename;
@@ -1927,13 +2189,20 @@ class LeadsController extends BaseController
// print_r($recipient_data); die;
} else if ($recipient_type == 'client') {
- $recipient_data = [['name' => $lead_data['contact_person_name'], 'email' => $lead_data['contact_person_email']]];
+
+ $mailIDS = explode(',',$params['contact_mail']);
+ $recipient_data = [];
+ foreach ($mailIDS as $mail){
+ $recipient_data[] = ['name' => $lead_data['contact_person_name'], 'email' => $mail];
+ }
+
} else {
$recipient_data = [['name' => "Team", 'email' => $params['to']]];
}
// print_r($recipient_data); die;
$subject = $file_type == 'rfq' ? 'Request for Quotation from ' . $lead_data['client_name'] . ' for ' . $lead_data['policy_type'] : 'Quotation Comparison Report for ' . $lead_data['policy_type'];
+
$original_message = '
Request for Quotation (RFQ) Dear {{RECIPIENT_NAME}}, 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.
RFQ Details Client name {{CLIENT_NAME}} Coverage Type {{POLICY_LONG_NAME}} Policy Start Date {{POLICY_START_DATE}} Policy Duration {{DURATION}}
Please note: Additional terms and details are included in the attachment for your reference.
Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.
Best regards,
Nhance India Pvt Ltd
© Nhance India Pvt Ltd. All rights reserved.
';
//for mail content
@@ -1982,7 +2251,9 @@ class LeadsController extends BaseController
'proposel_data' => json_encode($lead_update_data),
'status' => 'won',
'placement_date' => change_date_format($params['placement_date'], 'd/m/Y', 'Y-m-d'),
+ 'payment_date' => change_date_format($params['payment_date'], 'd/m/Y', 'Y-m-d'),
'utr_no' => $params['utr_no'],
+ 'is_cd' => $params['is_cd'],
'premium_amount' => $params['premium_amount'],
'total_amount' => $params['total_amount'],
'cd_amount' => $params['cd_amount'],
@@ -2394,16 +2665,15 @@ class LeadsController extends BaseController
// }
}
- if($data['lead_form_type'] == 1){
+ if ($data['lead_form_type'] == 1) {
$client_policy_data['policy_terms'] = $this->preparePolicyTermsFromRFQ($data);
- }else{
+ } else {
$placementJson = $this->getPlacementJson($data);
if ($placementJson) {
$client_policy_data['placement_json'] = $placementJson;
$client_policy_data['policy_terms'] = $this->convertNonEbQCRJsonToPolicyTerms(json_decode($placementJson, true));
}
-
}
// print_r($client_policy_data); die;
@@ -2542,12 +2812,11 @@ class LeadsController extends BaseController
}
return json_encode($terms_array);
-
} else {
return null;
}
}
-
+
public function featchClientPolicyFromLead($client_id, $branch_id, $lead_id)
{
$data = $this->leadsModel->where('leads.id', $lead_id)->where('leads.is_active', 1)->first();
@@ -2592,7 +2861,9 @@ class LeadsController extends BaseController
return $this->transformNonEbProposelData(
$jsonData,
$proposel_data['proposel_name'] ?? '',
- $proposel_data['insurer_name'] ?? '', null, 1
+ $proposel_data['insurer_name'] ?? '',
+ null,
+ 1
);
}, $jsonArray);
@@ -2612,7 +2883,7 @@ class LeadsController extends BaseController
}
unset($proposal); // Good practice after foreach by reference
}
-
+
$placement_json_data[] = $proposalData;
@@ -2629,6 +2900,13 @@ class LeadsController extends BaseController
$next_year = $current_year + 1;
$policy_year = "$current_year-$next_year";
+ $policy_expiry = strtotime($lead_data['policy_end_date']);
+
+ $formatted_policy = date("d-m-Y",$policy_expiry);
+ $logged_user_id = get_session_userid();
+
+ $logged_user_data = $this->userModel->where("id",$logged_user_id)->where("is_active",1)->first();
+
if ($lead_data) {
// Replacing placeholders with actual values
@@ -2638,6 +2916,11 @@ class LeadsController extends BaseController
$message = str_replace("{{POLICY_TYPE}}", $lead_data['policy_type'] ?? "Insurance Policy", $message);
$message = str_replace("{{RFQ_OR_QCR}}", $page_name, $message);
$message = str_replace("{{POLICY_YEAR}}", $policy_year, $message);
+ $message = str_replace("{{POLICY_END_DATE}}"," (Due On ".$formatted_policy.")",$message);
+
+ $message = str_replace("{{LOGGED_USER_NAME}}",ucfirst($logged_user_data['first_name'])." ".ucfirst($logged_user_data['last_name']),$message);
+ $message = str_replace("{{LOGGED_USER_EMAIL}}",$logged_user_data['email'],$message);
+ $message = str_replace("{{LOGGED_USER_MOBILE}}",$logged_user_data['mobile'],$message);
return $message;
} else {
@@ -2645,6 +2928,7 @@ class LeadsController extends BaseController
}
}
+
function getLastFiveFinancialYears()
{
$currentYear = date('Y');
@@ -2721,7 +3005,7 @@ class LeadsController extends BaseController
}
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])
? change_date_format($data['lead_edit_data'][$dateField], 'Y-m-d', 'd/m/Y')
: null;
@@ -2736,7 +3020,8 @@ class LeadsController extends BaseController
$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) {
@@ -2811,7 +3096,7 @@ class LeadsController extends BaseController
$lead_data = array_merge(['Insured' => $rfq_data['client_name']], $lead_data);
$policy_registration_data = [];
- if(isset($rfq_data['registration_json']) && !empty($rfq_data['registration_json'])){
+ if (isset($rfq_data['registration_json']) && !empty($rfq_data['registration_json'])) {
$policy_registration_data = json_decode($rfq_data['registration_json'], true);
}
// dd($policy_registration_data);
@@ -2959,7 +3244,7 @@ class LeadsController extends BaseController
]);
$rowNumber++;
- }else{
+ } else {
$sheet->mergeCells("A{$rowNumber}:B{$rowNumber}");
$sheet->setCellValue("A{$rowNumber}", "Policy Type");
$sheet->setCellValue("C{$rowNumber}", ucfirst($key) . " Policy");
@@ -3147,7 +3432,7 @@ class LeadsController extends BaseController
$serial_no = 1;
$maxColumnWidths = [];
$RowSpanEnable = false;
-
+
// Add table data rows
foreach ($column_data as $dataRow) {
@@ -3172,11 +3457,11 @@ class LeadsController extends BaseController
$sheet->getStyle("{$columnLetter}{$mergeStart}:{$columnLetter}{$mergeEnd}")
->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
} else {
- if(!$hasPolicy && $key == 0){
+ if (!$hasPolicy && $key == 0) {
$RowSpanEnable = true;
$columnLetter++;
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['display_content']);
- }else{
+ } else {
$sheet->setCellValue("{$columnLetter}{$rowNumber}", $cellData['display_content']);
}
}
@@ -3184,13 +3469,12 @@ class LeadsController extends BaseController
if (!($key === 0 && !$hasPolicy)) {
$columnLetter++;
}
-
}
$rowNumber++;
$serial_no++;
}
- if($key == 0 && $RowSpanEnable == true){
+ if ($key == 0 && $RowSpanEnable == true) {
$columnLetter++;
}
@@ -3493,7 +3777,7 @@ class LeadsController extends BaseController
return null;
}
- public function transformNonEbProposelData(&$data, $proposal, $insurer, $tableCount=null, $actionColumn = null)
+ public function transformNonEbProposelData(&$data, $proposal, $insurer, $tableCount = null, $actionColumn = null)
{
// Kint::dump($data, $proposal, $insurer, $tableCount);
@@ -3530,7 +3814,7 @@ class LeadsController extends BaseController
// Update the original data's headers
$data['table_data']['headers'] = $headerData;
- if(!empty($actionColumn)){
+ if (!empty($actionColumn)) {
$data['table_data']['headers'][] = [
'parentHeader' => "Action",
'subHeaders' => ['-']
@@ -3562,8 +3846,8 @@ class LeadsController extends BaseController
$filteredData[] = $item;
}
- if(!empty($actionColumn)){
- if($item['parentth'] === "Action"){
+ if (!empty($actionColumn)) {
+ if ($item['parentth'] === "Action") {
$filteredData[] = $item;
}
}
@@ -3581,24 +3865,24 @@ class LeadsController extends BaseController
return $data;
}
- public function getPreviousColumn($columnLetter, $decrement = 1)
+ public function getPreviousColumn($columnLetter, $decrement = 1)
{
$colIndex = Coordinate::columnIndexFromString($columnLetter);
$colIndex = max(1, $colIndex - $decrement); // ensure column index doesn't go below 1
return Coordinate::stringFromColumnIndex($colIndex);
}
-
+
public function handleMultiFileAttachments($json_string, $lead_id)
- {
+ {
$attachments = [];
-
+
if (!empty($json_string)) {
$fileIds = json_decode($json_string, true);
$lead_file_path = WRITEPATH . 'uploads/lead_files/';
-
+
foreach ($fileIds as $id) {
$lead_file = $this->leadFilesModel->where('lead_id', $lead_id)->where('id', $id)->where('is_active', 1)->first();
-
+
if ($lead_file) {
$attachments[] = [
'fileName' => $lead_file['file_name'],
@@ -3607,8 +3891,7 @@ class LeadsController extends BaseController
}
}
}
-
+
return $attachments;
}
-
}
diff --git a/app/Controllers/TicketController.php b/app/Controllers/TicketController.php
index ec574927..f6999bdf 100644
--- a/app/Controllers/TicketController.php
+++ b/app/Controllers/TicketController.php
@@ -774,13 +774,20 @@ class TicketController extends BaseController
{
// log_message('error','Function called');die();
// $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['user_name'] = $logged_user['first_name'] . ' ' . $logged_user['last_name'];
- $dataToSend['messages'] = $this->ticketMessageModel->where('is_active', 1)
- ->where('ticket_id', $ticket_master_id)->orderBy('created_at', 'DESC')
+
+ $user_id = get_session_userid();
+ // $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();
+
foreach ($dataToSend['messages'] as $message) {
$mail_content_converted = $this->convertHtmlToText($message['mail_content']);
$message['mail_content'] = $mail_content_converted;
@@ -1034,7 +1041,7 @@ class TicketController extends BaseController
th.old_value,
th.new_value,
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
old_status.claim_status as old_status_value,
new_status.claim_status as new_status_value,
@@ -1094,6 +1101,7 @@ class TicketController extends BaseController
ORDER BY
th.created_at DESC";
$data = $this->ticketHistoryModel->query($sql)->getResultArray();
+ // dd(db_connect()->getLastQuery());
$priorityType = $this->priorityType;
$relationshipType = $this->relationshipType;
$modeOFIntimate = $this->modeOFIntimate;
diff --git a/app/Models/LeadsModel.php b/app/Models/LeadsModel.php
index 84e9c9bf..cd516c7a 100644
--- a/app/Models/LeadsModel.php
+++ b/app/Models/LeadsModel.php
@@ -87,6 +87,12 @@ class LeadsModel extends Model
'lead_form_type',
'custom_fields',
+
+ 'source_policy_start_date',
+ 'source_policy_end_date',
+
+ 'payment_date',
+ 'is_cd'
];
diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php
index 49b84400..ed5a8ace 100755
--- a/app/Models/UserModel.php
+++ b/app/Models/UserModel.php
@@ -134,5 +134,20 @@ class UserModel extends Model
->getResultArray();
}
+ public function getexclusiveUserListForRFQ(){
+ $data = $this->db->table('user_profiles')
+ ->select('user_profiles.*,user_teams.team_id')
+ ->select('roles.role as user_role')
+ ->join('roles', 'roles.id = user_profiles.role')
+ ->join('user_teams', 'user_teams.user_id = user_profiles.id')
+ ->get()
+ ->getResultArray();
+
+
+ // dd($data);
+
+ return $data;
+ }
+
}
?>
\ No newline at end of file
diff --git a/app/Views/chatbot.php b/app/Views/chatbot.php
index 94373196..95bf5cde 100644
--- a/app/Views/chatbot.php
+++ b/app/Views/chatbot.php
@@ -41,7 +41,7 @@
origin: "mobile", // origin
emp_code:"HTL-007",
client_id:159,
- client_branch_id:125
+ client_branch_id:126
}
};
diff --git a/app/Views/layout/header.php b/app/Views/layout/header.php
index f7ccabb4..8db290b2 100755
--- a/app/Views/layout/header.php
+++ b/app/Views/layout/header.php
@@ -80,6 +80,9 @@
+
+
+
diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php
index 566aa5e4..fc2ee0f0 100644
--- a/app/Views/leads_form.php
+++ b/app/Views/leads_form.php
@@ -162,6 +162,16 @@
+
+ Source Policy Start Date
+
+
+
+
+ Source Policy End Date
+
+
+