Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
533359b2b3
@ -18,7 +18,59 @@ class EcardDownloadConversation extends Conversation
|
||||
$this->showEcardMenu();
|
||||
}
|
||||
|
||||
protected function showEcardMenu()
|
||||
protected function showEcardMenu()
|
||||
{
|
||||
// Log entry for debugging
|
||||
log_message('error', 'showEcardMenu function called');
|
||||
|
||||
|
||||
// Get chat session and policies
|
||||
$chat_session_info = get_chatbot_session_info();
|
||||
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
|
||||
|
||||
// If policies found, build an HTML list of links (and raw URLs as fallback)
|
||||
if (is_array($policy_list) && count($policy_list)) {
|
||||
$parts = [];
|
||||
foreach ($policy_list as $policy) {
|
||||
// Resolve rand string (defensive)
|
||||
$randString = '';
|
||||
if (isset($policy['rand_string']) && $policy['rand_string'] !== '') {
|
||||
$randString = $policy['rand_string'];
|
||||
} elseif (isset($policy['rand']) && $policy['rand'] !== '') {
|
||||
$randString = $policy['rand'];
|
||||
} elseif (isset($policy['emp_policy_id'])) {
|
||||
// As a last resort, use emp_policy_id (not ideal but prevents broken links)
|
||||
$randString = $policy['emp_policy_id'];
|
||||
}
|
||||
|
||||
// Build link; make sure base_url produces correct path
|
||||
$link = base_url('/download-e-card/' . $randString . '/1');
|
||||
|
||||
// Escape policy name to avoid HTML injection
|
||||
$safeName = isset($policy['policy_name']) ? htmlspecialchars($policy['policy_name'], ENT_QUOTES, 'UTF-8') : 'Policy';
|
||||
|
||||
// Add to parts; include anchor and raw URL fallback
|
||||
$parts[] = "🔹 <a href=\"{$link}\" target=\"_blank\">{$safeName}</a><br>";
|
||||
}
|
||||
|
||||
$message = "Choose a policy to download (click the policy name below):<br><br>" . implode('<br><br>', $parts);
|
||||
log_message('error', 'Ecard links displayed: ' . json_encode(array_column($policy_list, 'policy_name')));
|
||||
$this->say($message);
|
||||
} else {
|
||||
log_message('error', 'No policies found for ecard download');
|
||||
$this->say('No policy found.');
|
||||
}
|
||||
|
||||
// After showing links, move to confirmation conversation (Do you want to continue?)
|
||||
// This keeps the UX identical to previous flow where we asked the user if they want to continue.
|
||||
$this->bot->startConversation(new doYouWantToContinueConversation());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function showEcardMenuOLD()
|
||||
{
|
||||
log_message('error', ('showEcardMenu function called'));
|
||||
|
||||
@ -27,17 +79,13 @@ class EcardDownloadConversation extends Conversation
|
||||
$buttons = [];
|
||||
|
||||
$question = 'Choose Policy to Download Ecard:';
|
||||
// log_message('error', ('policy_list : ' . json_encode($policy_list)));
|
||||
log_message('error', ('policy_list : ' . json_encode($policy_list)));
|
||||
|
||||
if(is_array($policy_list) && count($policy_list))
|
||||
{
|
||||
foreach($policy_list as $policy)
|
||||
{
|
||||
// $question = Question::create("Choose Policy to Download Ecard:")
|
||||
// ->addButtons([
|
||||
// Button::create("🔹 $policy['policy_name']")->value("$policy['emp_policy_id']"),
|
||||
// Button::create("◀️ Go Back")->value("go_back"),
|
||||
// ]);
|
||||
|
||||
$this->buttonsData[$policy['emp_policy_id'].'#'.$policy['rand_string']] = ['response_text' => "🔹 {$policy['policy_name']}"] ;
|
||||
$buttons[] = Button::create("{$policy['policy_name']}")->value($policy['emp_policy_id'].'#'.$policy['rand_string']);
|
||||
}
|
||||
@ -63,10 +111,9 @@ class EcardDownloadConversation extends Conversation
|
||||
case is_string($answer->getValue()) && is_array(explode('#',$answer->getValue())) && count((explode('#',$answer->getValue()))) == 2:
|
||||
|
||||
$link = base_url().'/download-e-card/' . explode('#',$answer->getValue())[1].'/1';
|
||||
$this->say('Click here to downlad: <a href="'.$link.'" target="_blank">Ecard</a>');
|
||||
|
||||
log_message('error', $link);
|
||||
$this->say('Click here to downlad: <a href="'.$link.'" target="_blank">GMC</a><br>Click here to downlad: <a href="'.$link.'" target="_blank">GMC Parent</a>');
|
||||
$this->bot->startConversation(new doYouWantToContinueConversation()); // ✅ Restart the
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -76,4 +123,7 @@ class EcardDownloadConversation extends Conversation
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ class MainMenuConversation extends Conversation
|
||||
{
|
||||
$this->bot->userStorage()->delete();
|
||||
$this->bot->types(); // Typing indicator for the first message
|
||||
sleep(0.5); // Delay
|
||||
// sleep(0.5); // Delay
|
||||
$this->showMainMenu();
|
||||
}
|
||||
|
||||
|
||||
@ -16,11 +16,11 @@ class NetworkHospitalConversation extends Conversation
|
||||
public function run()
|
||||
{
|
||||
$this->bot->types(); // Typing indicator for the first message
|
||||
sleep(0.5); // Delay
|
||||
// sleep(0.5); // Delay
|
||||
$this->showHospitalMenu();
|
||||
}
|
||||
|
||||
protected function showHospitalMenu()
|
||||
protected function showHospitalMenuOLD()
|
||||
{
|
||||
$chat_session_info = get_chatbot_session_info();
|
||||
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
|
||||
@ -92,4 +92,54 @@ class NetworkHospitalConversation extends Conversation
|
||||
});
|
||||
}
|
||||
|
||||
protected function showHospitalMenu()
|
||||
{
|
||||
log_message('error', 'showHospitalMenu function called');
|
||||
|
||||
|
||||
// Get chat session and policies
|
||||
$chat_session_info = get_chatbot_session_info();
|
||||
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
|
||||
|
||||
if (is_array($policy_list) && count($policy_list)) {
|
||||
$parts = [];
|
||||
foreach ($policy_list as $policy) {
|
||||
// Resolve rand string (defensive)
|
||||
$randString = '';
|
||||
if (isset($policy['rand_string']) && $policy['rand_string'] !== '') {
|
||||
$randString = $policy['rand_string'];
|
||||
} elseif (isset($policy['rand']) && $policy['rand'] !== '') {
|
||||
$randString = $policy['rand'];
|
||||
} elseif (isset($policy['emp_policy_id'])) {
|
||||
$randString = $policy['emp_policy_id'];
|
||||
}
|
||||
|
||||
$emp_policy_id = isset($policy['emp_policy_id']) ? $policy['emp_policy_id'] : '';
|
||||
$hospital_link = ChatbotHelper::getHospitalLink($emp_policy_id);
|
||||
|
||||
$safeName = isset($policy['policy_name']) ? htmlspecialchars($policy['policy_name'], ENT_QUOTES, 'UTF-8') : 'Policy';
|
||||
|
||||
if ($hospital_link) {
|
||||
$parts[] = "🔹 <a href=\"{$hospital_link}\" target=\"_blank\">{$safeName}</a><br>";
|
||||
} else {
|
||||
$parts[] = "🔹 {$safeName} — No Data found, please contact support team";
|
||||
}
|
||||
|
||||
log_message('error', 'Hospital link for policy ' . $emp_policy_id . ': ' . $hospital_link);
|
||||
}
|
||||
|
||||
$message = "Access hospital details for your policies below:<br><br>" . implode('<br><br>', $parts);
|
||||
$this->say($message);
|
||||
} else {
|
||||
log_message('error', 'No policies found for hospital menu');
|
||||
$this->say('No policy found.');
|
||||
}
|
||||
|
||||
// After showing links, move to confirmation conversation
|
||||
$this->bot->startConversation(new doYouWantToContinueConversation());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ class ChatbotHelper
|
||||
$client_branch_id = $chat_session_info['client_branch_id'];
|
||||
$relationship ='Self';
|
||||
$EmployeeModel = new EmployeeModel();
|
||||
return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['active'],policy_status:['active'],client_branch_id:[ $client_branch_id ],relationship:[$relationship]);//,relationship:[$relationship];
|
||||
return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['active'],policy_status:['active'],client_branch_id:[ $client_branch_id ],relationship:[$relationship],policy_type_id:[2,3,4,5]);//,relationship:[$relationship];
|
||||
}
|
||||
|
||||
public static function getHospitalLink($emp_policy_id){
|
||||
|
||||
@ -106,9 +106,9 @@ class EmployeeModel extends Model
|
||||
}
|
||||
|
||||
|
||||
public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = [],array $relationship = [],array $client_branch_id = [])
|
||||
public function getEmpFamilybyEmpCode(string $client_policy_id = null,string $emp_code = null,string $client_id = null,array $emp_status = [],array $policy_status = [],array $relationship = [],array $client_branch_id = [],array $policy_type_id = [])
|
||||
{
|
||||
$result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employees.file_id','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.is_addon', 'employee_polices.payable_employee','employee_polices.rand_string','employee_polices.claim_status'])
|
||||
$result = $this->select(['employees.id as emp_id', 'employees.client_id','employees.client_branch_id', 'employees.relationship', 'employees.relationship_code', 'employees.change_event', 'employees.emp_code', 'employees.name', 'employees.email_personal', 'employees.email_corporate', 'employees.mobile', 'employees.gender', 'employees.dob', 'employees.doj', 'employees.basic_pay', 'employees.band', 'employees.designation', 'employees.emp_status','employees.unit','employees.file_id','employee_polices.id as emp_policy_id', 'employee_polices.employee_id', 'employee_polices.client_policy_id', 'employee_polices.tpa_id', 'employee_polices.uhid', 'employee_polices.batch_code', 'employee_polices.status', 'employee_polices.pre_existing_alignments', 'employee_polices.basic_cover_si', 'employee_polices.date_coverage', 'employee_polices.policy_end_date', 'employee_polices.days', 'employee_polices.premium', 'employee_polices.rata_premimum', 'employee_polices.gst', 'employee_polices.date_of_exit', 'employee_polices.reason_for_exit','policy_type.long_name as policy_name','client_policy.policy_type_id','client_policy.is_addon', 'employee_polices.payable_employee','employee_polices.rand_string','employee_polices.claim_status'])
|
||||
->join('employee_polices', 'employee_polices.employee_id = employees.id')
|
||||
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id','left')
|
||||
@ -135,6 +135,9 @@ class EmployeeModel extends Model
|
||||
})
|
||||
->when(count($policy_status), function($query) use ($policy_status){
|
||||
return $query->whereIn('employee_polices.status', $policy_status);
|
||||
})
|
||||
->when(count($policy_type_id), function($query) use ($policy_type_id){
|
||||
return $query->whereIn('client_policy.policy_type_id', $policy_type_id);
|
||||
})
|
||||
->when($client_id, function($query) use ($client_id){
|
||||
return $query->where('employees.client_id',$client_id);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user