Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev

This commit is contained in:
vadivelJ96 2025-08-11 18:31:34 +05:30
commit f766def3d7
8 changed files with 310 additions and 81 deletions

View File

@ -46,6 +46,7 @@ $routes->get("frontend_content", "AppContentManagementController::frontend_conte
// $routes->get('/', 'LoginController::index');
$routes->get('/test', 'Home::index');
$routes->get('/check_gemini', 'Home::check_Gemini');
$routes->get('/login', 'LoginController::index'); ///auth/google
$routes->get('/loginPos', 'LoginController::loginPos'); //login POS team
$routes->post('/getVerifyPosMobileNo', 'LoginController::getVerifyPosMobileNo'); //Verify POS team mobile no

View File

@ -10,8 +10,11 @@ use App\Helpers\ChatbotHelper;
class EcardDownloadConversation extends Conversation
{
protected $buttonsData = [];
public function run()
{
$this->bot->types();
sleep(0.5);
$this->showEcardMenu();
}
@ -22,6 +25,7 @@ class EcardDownloadConversation extends Conversation
$chat_session_info = get_chatbot_session_info();
$policy_list = ChatbotHelper::getListOfPolicies($chat_session_info);
$buttons = [];
$question = 'Choose Policy to Download Ecard:';
// log_message('error', ('policy_list : ' . json_encode($policy_list)));
@ -34,20 +38,24 @@ class EcardDownloadConversation extends Conversation
// Button::create("🔹 $policy['policy_name']")->value("$policy['emp_policy_id']"),
// Button::create("◀️ Go Back")->value("go_back"),
// ]);
$buttons[] = Button::create("🔹 {$policy['policy_name']}")->value($policy['emp_policy_id'].'#'.$policy['rand_string']);
$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']);
}
}
else
{
$question = 'No policy found';
}
$this->buttonsData['go_back'] = ['response_text' => '◀️ Go Back'] ;
$buttons = array_merge($buttons,[Button::create("◀️ Go Back")->value("go_back")]);
$question = Question::create($question)
->addButtons($buttons);
$this->bot->ask($question, function ($answer) {
$temp = $this->buttonsData;
$this->bot->ask($question, function ($answer) use ($temp) {
log_message('error', 'showEcardMenu answer received');
log_message('error', ($answer));
$selectedOption = $answer->getText();
$this->say("You have selected {$selectedOption}");
$this->say("You have selected {$temp[$selectedOption]['response_text']}");
switch ($answer->getValue()) {
case "go_back":
$this->bot->startConversation(new MainMenuConversation());

View File

@ -2,6 +2,12 @@
namespace App\Controllers;
use GeminiAPI\Client;
use GeminiAPI\Resources\ModelName;
use GeminiAPI\Resources\Parts\TextPart;
class Home extends PublicController
{
public function index(): string
@ -28,4 +34,26 @@ class Home extends PublicController
return $payload['a'] + $payload['b'];
}
public function check_Gemini()
{
try {
$apiKey = 'AIzaSyBbx-uotRBqkYhqLpmD60420E_a0G0duP8';
// Initialize the Gemini client
$client = new Client($apiKey);
// Send a prompt to the Gemini Pro model
$response = $client->generativeModel(ModelName::GEMINI_PRO)->generateContent(
new TextPart('Write a short, creative story about a knight and a dragon.')
);
// Display the generated text
$data['gemini_response'] = $response->text();
} catch (\Exception $e) {
// Handle any errors that occur during the API call
$data['gemini_response'] = 'An error occurred: ' . $e->getMessage();
}
print_rr($data);
}
}

View File

@ -62,9 +62,15 @@ class ICICILombardController extends AdminController
//'Scope: esbgpabatchcreation'
];
#old policy info start
#"PolicyNumber" => "4016/A/51974976/00/000",
# "CDBGAccountNumber" => "CD-MUM-3344",
#"CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f",
#old policy inf end
$body = [
"PolicyNumber" => "4016/A/51974976/00/000",
"CDBGAccountNumber" => "CD-MUM-3344",
"PolicyNumber" => "4016/A/O/53077718/00/000",
"CDBGAccountNumber" => "CD-MUM-0026",
"CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f",
"MemberDetails" => [
[
@ -74,8 +80,8 @@ class ICICILombardController extends AdminController
"DOB" => "7-JUL-1983",
"Relationship" => "SELF",
"Gender" => "MALE",
"DOC" => "20-JAN-2020",
"SumInsured" => "600000",
"DOC" => "08-JUL-2025",
"SumInsured" => "400000",
"EmailId" => "ABC@GMAIL.COM",
"FlagStatus" => "A"
],
@ -86,8 +92,8 @@ class ICICILombardController extends AdminController
"DOB" => "8-AUG-1970",
"Relationship" => "MOTHER",
"Gender" => "FEMALE",
"DOC" => "20-JAN-2020",
"SumInsured" => "600000",
"DOC" => "08-JUL-2025",
"SumInsured" => "400000",
"EmailId" => "ABC@GMAIL.COM",
"FlagStatus" => "A"
],
@ -97,13 +103,13 @@ class ICICILombardController extends AdminController
"InsuredName" => "ABC28142",
"DOB" => "8-SEP-1970",
"Gender" => "MALE",
"SumInsured" => "600000",
"SumInsured" => "400000",
"EmailId" => "ABC@GMAIL.COM",
"FlagStatus" => "M"
],
[
"UHID" => "IL00688842552",
"DOL" => "20-JAN-2020",
"DOL" => "08-JUL-2025",
"FlagStatus" => "D"
]
]

View File

@ -121,6 +121,7 @@ class LeadsController extends BaseController
];
$this->claim_type_for_gpa = [
'nil' => 'Nil',
'accident_death' => 'Accident Death',
'permanent_total_disablement' => 'Permanent Total Disablement',
'permanent_partial_disablement' => 'Permanent Partial Disablement',
@ -1823,6 +1824,72 @@ class LeadsController extends BaseController
$filename = "{$rfq_data['client_name']}_{$rfq_data['policy_type']}_{$string}_" . $policy_year . '_' . '.xlsx';
}
//claim history new sheet;
if (!empty($rfq_data['fin_years_claims'])) {
$claim_details = json_decode($rfq_data['fin_years_claims'], true) ?? [];
if (!empty($claim_details['finyear'])) {
// Get headers dynamically
$headers = array_map(function ($key) {
return ucwords(str_replace('_', ' ', $key));
}, array_keys($claim_details['finyear'][0]));
$newSheet = new Worksheet($spreadsheet, 'Claims Experience');
$spreadsheet->addSheet($newSheet);
$spreadsheet->setActiveSheetIndexByName('Claims Experience');
$sheet = $spreadsheet->getActiveSheet();
// Set headers
$sheet->fromArray($headers, NULL, 'A1');
// Apply background color and bold style to headers
$headerCellRange = 'A1:' . chr(64 + count($headers)) . '1'; // e.g., A1:G1
$sheet->getStyle($headerCellRange)->getFont()->setBold(true);
$sheet->getStyle($headerCellRange)->getFill()->setFillType(Fill::FILL_SOLID)->getStartColor()->setRGB('ADD8E6');
// Add border to header
$sheet->getStyle($headerCellRange)->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
// Fill data and apply borders
$row = 2;
foreach ($claim_details['finyear'] as $record) {
$col = 'A';
foreach ($record as $value) {
$label = ucwords(str_replace('_', ' ', ($value ?? "")));
$sheet->setCellValue($col . $row, $label);
$col++;
}
// Apply border to each data row
$sheet->getStyle('A' . $row . ':' . chr(64 + count($headers)) . $row)
->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
$row++;
}
// Auto-size all columns based on header count
for ($i = 0; $i < count($headers); $i++) {
$colLetter = chr(65 + $i); // 'A', 'B', etc.
$sheet->getColumnDimension($colLetter)->setAutoSize(true);
}
// Enable wrap text for all cells
$maxColLetter = chr(64 + count($headers)); // Last column letter
$sheet->getStyle("A2:{$maxColLetter}{$row}")->getAlignment()->setWrapText(true);
// Optional: center vertically for neatness
$sheet->getStyle("A2:{$maxColLetter}{$row}")->getAlignment()->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
// Optional: Make row height auto (helps when wrap text is on)
for ($i = 2; $i < $row; $i++) {
$sheet->getRowDimension($i)->setRowHeight(-1);
}
}
}
// Save to temporary location
$uploadFilePath = WRITEPATH . 'tmp/' . $filename;
$writer = new Xlsx($spreadsheet);

46
app/Libraries/Gemini.php Normal file
View File

@ -0,0 +1,46 @@
<?php
namespace App\Libraries;
use GeminiAPI\Client;
use GeminiAPI\Resources\ModelName;
use GeminiAPI\Resources\Parts\TextPart;
class Gemini
{
private $client;
private $myLogger;
public function __construct()
{
// $this->myLogger = \Config\Services::mylogger();
// $this->client = new Google_Client();
// $this->client->setAuthConfig(ROOTPATH . 'nhance-app-google-drive.json'); // App credentials
// // putenv('GOOGLE_APPLICATION_CREDENTIALS=' . ROOTPATH . 'nhance-app-google-drive.json');
// $this->client->useApplicationDefaultCredentials();
// $this->client->addScope(Google_Service_Drive::DRIVE); // Full access to Google Drive
}
public function check()
{
try {
// Initialize the Gemini client
$client = new Client($apiKey);
// Send a prompt to the Gemini Pro model
$response = $client->generativeModel(ModelName::GEMINI_PRO)->generateContent(
new TextPart('Write a short, creative story about a knight and a dragon.')
);
// Display the generated text
$data['gemini_response'] = $response->text();
} catch (\Exception $e) {
// Handle any errors that occur during the API call
$data['gemini_response'] = 'An error occurred: ' . $e->getMessage();
}
}
}

View File

@ -2,16 +2,101 @@
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<title>Insurance ChatBot</title>
</head>
<style>
html, body {
height: 100%;
margin: 0;
}
/* body {
background-color: rgba(0, 0, 0, 0.3);
display: flex;
justify-content: center;
align-items: center;
}
h1 {
font-size: 3rem;
font-weight: bold;
animation: colorShift 2s infinite linear;
}
@keyframes colorShift {
0% { color: red; }
25% { color: orange; }
50% { color: green; }
75% { color: blue; }
100% { color: violet; }
}*/
</style>
<style>
/* Full-screen overlay */
#page-loader {
position: fixed;
inset: 0; /* top:0; right:0; bottom:0; left:0 */
display: flex;
align-items: center;
justify-content: center;
background: rgba(255,255,255,0.85);
z-index: 9999;
transition: opacity 300ms ease, visibility 300ms ease;
visibility: visible;
opacity: 1;
}
/* Hidden state */
#page-loader.hidden {
opacity: 0;
visibility: hidden;
pointer-events: none;
}
/* Optional card around GIF */
#page-loader .loader-box {
text-align: center;
padding: 18px;
border-radius: 12px;
box-shadow: 0 8px 30px rgba(0,0,0,0.12);
background: rgba(255,255,255,0.95);
backdrop-filter: blur(4px);
}
/* Restrict gif size for large screens */
#page-loader img {
display: block;
max-width: 120px;
width: 20vw;
height: auto;
}
/* Example page content styling */
body.noscroll {
overflow: hidden; /* prevent scrolling while loader is visible */
}
main { padding: 2rem; font-family: Arial, Helvetica, sans-serif; }
</style>
<body>
<h1>Loading...Please wait </h1>
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
<!-- <h1>Loading...from page</h1> -->
<!-- Page loader overlay (visible by default) -->
<div id="page-loader" aria-hidden="false">
<div class="loader-box">
<!-- Replace the src with your GIF file path -->
<img src="https://venbait.in/nhance/dev/assets/images/nhance-loader.gif" alt="Loading..." />
<!-- <div style="margin-top:8px;font-size:14px;color:#555;">Loading, please wait...</div> -->
</div>
</div>
<script>
var emp_name = 'Kumar';
// alert('start of main');
var uid = Math.floor(100000 + Math.random() * 900000);
console.log('CURRENT_USER' + uid);
@ -23,7 +108,7 @@
const calcWidth = isMobile
? (window.innerWidth)
: Math.min(400, window.innerWidth - 50);
const name = queryParams['name'];
var botmanWidget = {
// chatServer: 'https://venbait.in/nhance/chatbot/chat',
// frameEndpoint: 'https://venbait.in/nhance/chatbot/widget',
@ -33,15 +118,15 @@
placeholderText: "Type your message here...",
aboutText: "Insurance Assistant ILA",
enableAttachments: false,
introMessage:'Welcome Kumar...! Say Hi...',
introMessage: ('Welcome '+ name + '...! Say Hi...'),
bubbleAvatarUrl:"https://botman.io/img/logo.png",
parameters: {
employee_id: queryParams['employee_id'],
session_id: "XYZ789",
origin: "mobile",
origin: queryParams['origin'],
emp_code: queryParams['emp_code'],
client_id: 63,
client_branch_id: 32
client_id:queryParams['client_id'],
client_branch_id: queryParams['client_branch_id']
}
};
@ -129,35 +214,35 @@ function setupMessageObserver() {
// Set initial height based on device
const initialHeight = isMobile ? 700 : 800; // Default to keyboard closed state
// Method 1: Create style element with high specificity
const style = doc.createElement("style");
style.id = 'dynamic-chat-height';
style.textContent = `
/* High specificity selectors */
#messageArea ol.chat,
#messageArea .chat,
ol.chat {
height: ${initialHeight}px !important;
max-height: ${initialHeight}px !important;
min-height: ${initialHeight}px !important;
transition: height 0.3s ease;
}
// // Method 1: Create style element with high specificity
// const style = doc.createElement("style");
// style.id = 'dynamic-chat-height';
// style.textContent = `
// /* High specificity selectors */
// #messageArea ol.chat,
// #messageArea .chat,
// ol.chat {
// height: ${initialHeight}px !important;
// max-height: ${initialHeight}px !important;
// min-height: ${initialHeight}px !important;
// transition: height 0.3s ease;
// }
/* Additional styling to ensure proper display */
#messageArea {
height: auto !important;
}
`;
doc.head.appendChild(style);
// /* Additional styling to ensure proper display */
// #messageArea {
// height: auto !important;
// }
// `;
// doc.head.appendChild(style);
// Method 2: Direct style application as backup
setTimeout(() => {
const chatElements = doc.querySelectorAll("#messageArea .chat, #messageArea ol.chat, ol.chat");
chatElements.forEach(element => {
if (element) {
element.style.setProperty("height", initialHeight + "px", "important");
element.style.setProperty("max-height", initialHeight + "px", "important");
element.style.setProperty("min-height", initialHeight + "px", "important");
element.style.setProperty("height", 85 + "vh", "important");
element.style.setProperty("max-height", 85 + "vh", "important");
element.style.setProperty("min-height", 85 + "vh", "important");
element.style.setProperty("transition", "height 0.3s ease", "important");
console.log('Direct style applied to:', element);
}
@ -284,31 +369,31 @@ function setupMessageObserver() {
const doc = currentIframe.contentDocument || currentIframe.contentWindow.document;
if (doc) {
// Update existing style
let styleElement = doc.querySelector('#dynamic-chat-height');
if (!styleElement) {
styleElement = doc.createElement('style');
styleElement.id = 'dynamic-chat-height';
doc.head.appendChild(styleElement);
}
// let styleElement = doc.querySelector('#dynamic-chat-height');
// if (!styleElement) {
// styleElement = doc.createElement('style');
// styleElement.id = 'dynamic-chat-height';
// doc.head.appendChild(styleElement);
// }
styleElement.textContent = `
#messageArea ol.chat,
#messageArea .chat,
ol.chat {
height: ${height}px !important;
max-height: ${height}px !important;
min-height: ${height}px !important;
transition: height 0.3s ease;
}
`;
// styleElement.textContent = `
// #messageArea ol.chat,
// #messageArea .chat,
// ol.chat {
// height: ${height}px !important;
// max-height: ${height}px !important;
// min-height: ${height}px !important;
// transition: height 0.3s ease;
// }
// `;
// Direct style application as backup
const chatElements = doc.querySelectorAll("#messageArea .chat, #messageArea ol.chat, ol.chat");
chatElements.forEach(element => {
if (element) {
element.style.setProperty("height", height + "px", "important");
element.style.setProperty("max-height", height + "px", "important");
element.style.setProperty("min-height", height + "px", "important");
element.style.setProperty("height", 85 + "vh", "important");
element.style.setProperty("max-height", 85 + "vh", "important");
element.style.setProperty("min-height", 85 + "vh", "important");
}
});
@ -460,7 +545,7 @@ function setupMessageObserver() {
botmanChatWidget.open();
setTimeout(function(){
botmanChatWidget.sayAsBot('Hi ' + (typeof emp_name !== "undefined" && emp_name !== null && emp_name !== "" ? emp_name : "Guest User") + ', This is ILA your Insurance Assistant, plz choose the following options');
botmanChatWidget.sayAsBot('Hi ' + (typeof name !== "undefined" && name !== null && name !== "" ? name : "Guest User") + ', This is ILA your Insurance Assistant, plz choose the following options');
botmanChatWidget.whisper('Hi');
}, 1000);
@ -565,6 +650,11 @@ function setupMessageObserver() {
</script>
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
</body>
</html>

17
package-lock.json generated
View File

@ -1,17 +0,0 @@
{
"name": "nhance",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"x-editable": "^1.5.1"
}
},
"node_modules/x-editable": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/x-editable/-/x-editable-1.5.1.tgz",
"integrity": "sha512-eBP10/e6ETIx/TqRmwu6IR/BG0VpFyJzW+eCvAsa8ccJ+UqoYlIPslw7AulpOoym9nv04As8qROtjdU0ij8K2A=="
}
}
}