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

This commit is contained in:
VENKATESHWARAN 2025-08-13 13:56:16 +05:30
commit a0630d9468
8 changed files with 330 additions and 82 deletions

View File

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

View File

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

View File

@ -2,6 +2,12 @@
namespace App\Controllers; namespace App\Controllers;
use GeminiAPI\Client;
use GeminiAPI\Resources\ModelName;
use GeminiAPI\Resources\Parts\TextPart;
class Home extends PublicController class Home extends PublicController
{ {
public function index(): string public function index(): string
@ -28,4 +34,26 @@ class Home extends PublicController
return $payload['a'] + $payload['b']; 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' //'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 = [ $body = [
"PolicyNumber" => "4016/A/51974976/00/000", "PolicyNumber" => "4016/A/O/53077718/00/000",
"CDBGAccountNumber" => "CD-MUM-3344", "CDBGAccountNumber" => "CD-MUM-0026",
"CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f", "CorrelationId" => "86383c78-4c67-4e4d-9aa0-8f926fb0d55f",
"MemberDetails" => [ "MemberDetails" => [
[ [
@ -74,8 +80,8 @@ class ICICILombardController extends AdminController
"DOB" => "7-JUL-1983", "DOB" => "7-JUL-1983",
"Relationship" => "SELF", "Relationship" => "SELF",
"Gender" => "MALE", "Gender" => "MALE",
"DOC" => "20-JAN-2020", "DOC" => "08-JUL-2025",
"SumInsured" => "600000", "SumInsured" => "400000",
"EmailId" => "ABC@GMAIL.COM", "EmailId" => "ABC@GMAIL.COM",
"FlagStatus" => "A" "FlagStatus" => "A"
], ],
@ -86,8 +92,8 @@ class ICICILombardController extends AdminController
"DOB" => "8-AUG-1970", "DOB" => "8-AUG-1970",
"Relationship" => "MOTHER", "Relationship" => "MOTHER",
"Gender" => "FEMALE", "Gender" => "FEMALE",
"DOC" => "20-JAN-2020", "DOC" => "08-JUL-2025",
"SumInsured" => "600000", "SumInsured" => "400000",
"EmailId" => "ABC@GMAIL.COM", "EmailId" => "ABC@GMAIL.COM",
"FlagStatus" => "A" "FlagStatus" => "A"
], ],
@ -97,13 +103,13 @@ class ICICILombardController extends AdminController
"InsuredName" => "ABC28142", "InsuredName" => "ABC28142",
"DOB" => "8-SEP-1970", "DOB" => "8-SEP-1970",
"Gender" => "MALE", "Gender" => "MALE",
"SumInsured" => "600000", "SumInsured" => "400000",
"EmailId" => "ABC@GMAIL.COM", "EmailId" => "ABC@GMAIL.COM",
"FlagStatus" => "M" "FlagStatus" => "M"
], ],
[ [
"UHID" => "IL00688842552", "UHID" => "IL00688842552",
"DOL" => "20-JAN-2020", "DOL" => "08-JUL-2025",
"FlagStatus" => "D" "FlagStatus" => "D"
] ]
] ]

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"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <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> <title>Insurance ChatBot</title>
</head> </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> <body>
<h1>Loading...Please wait </h1> <!-- <h1>Loading...from page</h1> -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js" integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script> <!-- Page loader overlay (visible by default) -->
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script> <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> <script>
var emp_name = 'Kumar'; // alert('start of main');
var uid = Math.floor(100000 + Math.random() * 900000); var uid = Math.floor(100000 + Math.random() * 900000);
console.log('CURRENT_USER' + uid); console.log('CURRENT_USER' + uid);
@ -23,7 +108,7 @@
const calcWidth = isMobile const calcWidth = isMobile
? (window.innerWidth) ? (window.innerWidth)
: Math.min(400, window.innerWidth - 50); : Math.min(400, window.innerWidth - 50);
const name = queryParams['name'];
var botmanWidget = { var botmanWidget = {
// chatServer: 'https://venbait.in/nhance/chatbot/chat', // chatServer: 'https://venbait.in/nhance/chatbot/chat',
// frameEndpoint: 'https://venbait.in/nhance/chatbot/widget', // frameEndpoint: 'https://venbait.in/nhance/chatbot/widget',
@ -33,15 +118,15 @@
placeholderText: "Type your message here...", placeholderText: "Type your message here...",
aboutText: "Insurance Assistant ILA", aboutText: "Insurance Assistant ILA",
enableAttachments: false, enableAttachments: false,
introMessage:'Welcome Kumar...! Say Hi...', introMessage: ('Welcome '+ name + '...! Say Hi...'),
bubbleAvatarUrl:"https://botman.io/img/logo.png", bubbleAvatarUrl:"https://botman.io/img/logo.png",
parameters: { parameters: {
employee_id: queryParams['employee_id'], employee_id: queryParams['employee_id'],
session_id: "XYZ789", session_id: "XYZ789",
origin: "mobile", origin: queryParams['origin'],
emp_code: queryParams['emp_code'], emp_code: queryParams['emp_code'],
client_id: 63, client_id:queryParams['client_id'],
client_branch_id: 32 client_branch_id: queryParams['client_branch_id']
} }
}; };
@ -129,35 +214,35 @@ function setupMessageObserver() {
// Set initial height based on device // Set initial height based on device
const initialHeight = isMobile ? 700 : 800; // Default to keyboard closed state const initialHeight = isMobile ? 700 : 800; // Default to keyboard closed state
// Method 1: Create style element with high specificity // // Method 1: Create style element with high specificity
const style = doc.createElement("style"); // const style = doc.createElement("style");
style.id = 'dynamic-chat-height'; // style.id = 'dynamic-chat-height';
style.textContent = ` // style.textContent = `
/* High specificity selectors */ // /* High specificity selectors */
#messageArea ol.chat, // #messageArea ol.chat,
#messageArea .chat, // #messageArea .chat,
ol.chat { // ol.chat {
height: ${initialHeight}px !important; // height: ${initialHeight}px !important;
max-height: ${initialHeight}px !important; // max-height: ${initialHeight}px !important;
min-height: ${initialHeight}px !important; // min-height: ${initialHeight}px !important;
transition: height 0.3s ease; // transition: height 0.3s ease;
} // }
/* Additional styling to ensure proper display */ // /* Additional styling to ensure proper display */
#messageArea { // #messageArea {
height: auto !important; // height: auto !important;
} // }
`; // `;
doc.head.appendChild(style); // doc.head.appendChild(style);
// Method 2: Direct style application as backup // Method 2: Direct style application as backup
setTimeout(() => { setTimeout(() => {
const chatElements = doc.querySelectorAll("#messageArea .chat, #messageArea ol.chat, ol.chat"); const chatElements = doc.querySelectorAll("#messageArea .chat, #messageArea ol.chat, ol.chat");
chatElements.forEach(element => { chatElements.forEach(element => {
if (element) { if (element) {
element.style.setProperty("height", initialHeight + "px", "important"); element.style.setProperty("height", 85 + "vh", "important");
element.style.setProperty("max-height", initialHeight + "px", "important"); element.style.setProperty("max-height", 85 + "vh", "important");
element.style.setProperty("min-height", initialHeight + "px", "important"); element.style.setProperty("min-height", 85 + "vh", "important");
element.style.setProperty("transition", "height 0.3s ease", "important"); element.style.setProperty("transition", "height 0.3s ease", "important");
console.log('Direct style applied to:', element); console.log('Direct style applied to:', element);
} }
@ -284,31 +369,31 @@ function setupMessageObserver() {
const doc = currentIframe.contentDocument || currentIframe.contentWindow.document; const doc = currentIframe.contentDocument || currentIframe.contentWindow.document;
if (doc) { if (doc) {
// Update existing style // Update existing style
let styleElement = doc.querySelector('#dynamic-chat-height'); // let styleElement = doc.querySelector('#dynamic-chat-height');
if (!styleElement) { // if (!styleElement) {
styleElement = doc.createElement('style'); // styleElement = doc.createElement('style');
styleElement.id = 'dynamic-chat-height'; // styleElement.id = 'dynamic-chat-height';
doc.head.appendChild(styleElement); // doc.head.appendChild(styleElement);
} // }
styleElement.textContent = ` // styleElement.textContent = `
#messageArea ol.chat, // #messageArea ol.chat,
#messageArea .chat, // #messageArea .chat,
ol.chat { // ol.chat {
height: ${height}px !important; // height: ${height}px !important;
max-height: ${height}px !important; // max-height: ${height}px !important;
min-height: ${height}px !important; // min-height: ${height}px !important;
transition: height 0.3s ease; // transition: height 0.3s ease;
} // }
`; // `;
// Direct style application as backup // Direct style application as backup
const chatElements = doc.querySelectorAll("#messageArea .chat, #messageArea ol.chat, ol.chat"); const chatElements = doc.querySelectorAll("#messageArea .chat, #messageArea ol.chat, ol.chat");
chatElements.forEach(element => { chatElements.forEach(element => {
if (element) { if (element) {
element.style.setProperty("height", height + "px", "important"); element.style.setProperty("height", 85 + "vh", "important");
element.style.setProperty("max-height", height + "px", "important"); element.style.setProperty("max-height", 85 + "vh", "important");
element.style.setProperty("min-height", height + "px", "important"); element.style.setProperty("min-height", 85 + "vh", "important");
} }
}); });
@ -460,7 +545,7 @@ function setupMessageObserver() {
botmanChatWidget.open(); botmanChatWidget.open();
setTimeout(function(){ 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'); botmanChatWidget.whisper('Hi');
}, 1000); }, 1000);
@ -565,6 +650,11 @@ function setupMessageObserver() {
</script> </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> <script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
</body> </body>
</html> </html>

View File

@ -125,7 +125,7 @@
</div> </div>
<div class="form-group col-md-12 text-right m-b-0" style="margin-bottom: -15px;"> <div class="form-group col-md-12 text-right m-b-0" style="margin-bottom: -15px;">
<a href="<?= base_url("/ticket/list"); ?>" class="btn btn-secondary"id="clear-filters">Clear</a> <a href="#" class="btn btn-secondary" id="clear-filters">Clear</a>
<a class="btn btn-primary" id="get-emp-list" onclick="fetchTicketListData();">Submit</a> <a class="btn btn-primary" id="get-emp-list" onclick="fetchTicketListData();">Submit</a>
</div> </div>
@ -204,11 +204,15 @@ function fetchTicketListData() {
tpa_id: tpa_id, tpa_id: tpa_id,
}; };
let filterData = requestData;
localStorage.setItem('filterData', JSON.stringify(filterData));
console.log("requestData", requestData); console.log("requestData", requestData);
var url = '<?= base_url('/ticket/list') ?>'; var url = '<?= base_url('/ticket/list') ?>';
$('.loader').fadeIn(); $('.loader').fadeIn();
$('.loader-mask').fadeIn(); $('.loader-mask').fadeIn();
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) { sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
console.log('Filter Responce', response); console.log('Filter Responce', response);
@ -234,6 +238,88 @@ function fetchTicketListData() {
$('.loader').fadeOut(); $('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow'); $('.loader-mask').delay(350).fadeOut('slow');
}); });
} }
</script>
<script>
$(document).ready(function(){
let filterData = localStorage.getItem('filterData');
filterData = filterData ? JSON.parse(filterData) : null;
console.log('Filter Data', filterData);
if(filterData){
var url = '<?= base_url('/ticket/list') ?>';
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
sendAjaxRequestForGlobal(url, 'POST', filterData, function(response) {
console.log('Filter Responce', response);
if (response.status == true) {
$('#ticket_list_div').empty();
$('#ticket_list_div').html(response.html);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
} else {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
let message = response.message;
toastr.error(message, 'ERROR');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the data.', 'ERROR');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
$('#ticket_type').val(filterData.ticket_type_id);
$('#pod_no').val(filterData.pod_no);
$('#claim_no').val(filterData.claim_number);
$('#emp_code').val(filterData.emp_code);
$('#claim_status').val(filterData.claim_status_id);
$('#emp_mobile_no').val(filterData.emp_mobile);
$('#tpa_id').val(filterData.tpa_id);
$('#client_id').val(filterData.client_id);
$('#insurer_id').val(filterData.insurer_id);
$('#tpa_id').val(filterData.tpa_id);
}
})
</script>
<script>
$(document).on('click', '#clear-filters', function (e) {
e.preventDefault(); // Stops the browser from following the link
console.log('Clear Filters Area');
localStorage.removeItem('filterData');
$('#ticket_type').val('0');
$('#pod_no').val('');
$('#claim_no').val('');
$('#emp_code').val('');
$('#claim_status').val('0');
$('#emp_mobile_no').val('');
$('#tpa_id').val('0');
$('#client_id').val('0');
$('#insurer_id').val('0');
window.location.href = "<?= base_url("/ticket/list")?>";
});
</script> </script>

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=="
}
}
}