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

This commit is contained in:
VENKATESHWARAN 2025-09-15 11:47:36 +05:30
commit e17713c40b
14 changed files with 288 additions and 510 deletions

View File

@ -59,9 +59,9 @@ $routes->get('/update-emp-policy-status', 'ClientController::updateEmpAndPolicyS
$routes->get('download-e-card/(:any)', 'EmployeeController::generateIDCardForEmployee/$1');
$routes->get('download-kyc-docs/(:segment)', 'ClientController::downloadKYCDocument/$1');
$routes->get('claim-form-download/(:any)', 'TicketController::downloadClaimForm/$1');
$routes->get('downloadClaimFile/(:any)', 'TicketController::downloadClaimFile/$1');
$routes->match (['get','post'],"claims-feedback-form/(:any)/(:any)", "TicketController::viewClaimFeedbackForm/$1/$2");
$routes->match (['get','post'],"claims-feedback-form/(:any)", "TicketController::viewClaimFeedbackForm/$1");
$routes->get('downloadClaimFile/(:any)', 'TicketController::downloadClaimFile/$1');
@ -185,7 +185,8 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
$routes->post("test-rack-rate", "EmployeeController::testRackRate");
$routes->get('test_members_list', 'EmployeeController::test_members_list');
$routes->post('get_emp_history','EmployeeController::getEmpHistory');
$routes->get("retail-endorsement-list", "EmployeeController::retailendorsementList");
$routes->get("retail-endorsement-list", "EmployeeController::retailendorsementlist");
$routes->post("retail-endorsement-save", "EmployeeController::retailendorsementsave");
});
@ -504,6 +505,7 @@ $routes->get('get_ticket_data',"EmployeeRestController::get_ticket_data");
//api
$routes->group("/api", ["filter" => "authJWT"], function ($routes) {
$routes->get('get_ticket_type',"EmployeeRestController::get_ticket_type");
$routes->post("logined", "RestAuthenticationController::logined");
$routes->post("getId", "RestAuthenticationController::getUserIdFromToken");
});

View File

@ -52,25 +52,27 @@ class NetworkHospitalConversation extends Conversation
// });
$this->bot->ask($question, function ($answer) {
$path = $this->bot->userStorage()->get('path');
$path = $this->bot->userStorage()->get('path');
array_push($path,
$answer->getValue()
);
$this->bot->userStorage()->save([
'path' => $path
]);
log_message('error', ('user_reponse : ' . $answer->getValue()));
// log_message('error', ('user_reponse : ' . $answer->getValue()));
// log_message('error', ('user_reponse : ' . json_encode(explode('#',$answer->getValue()))));
switch ($answer->getValue()) {
case is_string($answer->getValue()) && is_array(explode('#',$answer->getValue())) && count((explode('#',$answer->getValue()))) == 2:
$client_poilicy_id = explode('#',$answer->getValue())[1];
$hospital_link = ChatbotHelper::getHospitalLink($client_poilicy_id);
$emp_poilicy_id = explode('#',$answer->getValue());
$emp_poilicy_id = array_shift($emp_poilicy_id);
log_message('error','EMP POL ID FOR HOSPITAL' . $emp_poilicy_id);
$hospital_link = ChatbotHelper::getHospitalLink($emp_poilicy_id);
if($hospital_link)
{
$this->say('<a href="' . $hospital_link['network_hospitals'] . '" target="_blank">Click here for hospital details</a>');
$this->say('<a href="' . $hospital_link . '" target="_blank">Click here for hospital details</a>');
}
else
{

View File

@ -24,10 +24,19 @@ class ReimbursementClaimStatusConversation extends Conversation
$chat_session_info = get_chatbot_session_info();
$data = ChatbotHelper::getReimbursementClaimStatus($chat_session_info);
log_message('error','Claim Number - ' . json_encode($data['claim_number']));
$this->bot->types();
if ($data){
$this->say("The claim status for the claim Number {$data['claim_number']} is currently in <strong>{$data['client_status']}</strong> status. <br> More Detailed Information is sent to your mail");
if(isset($data['claim_number']) && $data['claim_number'] !== null)
{
log_message('error','Claim Number YES- ' . json_encode($data['claim_number']));
$this->say("The claim status for the claim Number {$data['claim_number']} is currently in <strong>{$data['client_status']}</strong> status. <br> More Detailed Information is sent to your mail");
}
else
{
log_message('error','Claim Number NO- ' . json_encode($data['claim_number']));
$this->say("The claim status for your latest claim (ID not generated) is currently in <strong>{$data['client_status']}</strong> status. <br> More Detailed Information is sent to your mail");
}
$this->bot->startConversation(new doYouWantToContinueConversation());
}else{
$this->say("No Claim Raised against the user.");

View File

@ -77,6 +77,7 @@ class doYouWantToContinueConversation extends Conversation
$this->say("Thank you for your time! If you need anything else, feel free to reach out. Goodbye!");
$this->say("Say Hi or Help or Hello to start conversation again!");
break;
default:
$this->say("Invalid selection. Please choose an option.");

View File

@ -196,7 +196,7 @@ class vehicleFormConversation extends Conversation
// $cityName = $response->getText();
$sent_staus = ChatbotHelper::sendQuotationRequestMail($vehicle_info);
if ($sent_staus){
$this->say('Our Executive will contact you with the quotation soon.');
$this->say('Thanks.Our Executive will contact you with the quotation soon.');
$this->bot->startConversation(new doYouWantToContinueConversation());
}else{
$this->say("There was a problem while requesting for a quotation please try again later.");

View File

@ -116,7 +116,7 @@ class ChatbotControllerNew extends BaseController
// Start the Main Menu when user says "hi" or "start"
$this->botman->hears('start|hi|hello|help|help me', function (BotMan $bot) {
if ($this->isMemberLoggedIn){
$bot->reply('Hi how can i assist?');
// $bot->reply('Hi how can i assist?');
$bot->startConversation(new MainMenuConversation());
}else {
$bot->startConversation(new LoginToContiueConversation());

View File

@ -3016,25 +3016,74 @@ class EmployeeController extends AdminController
* This method retrieves filter data from the request and fetches the endorsement list
* based on the provided filters such as client ID, policy ID, and status.
*/
public function retailendorsementList()
public function retailendorsementlist()
{
// $data = [];
// $data['status'] = ['open' => 'Open', 'inprogress' => 'In-Progress', 'complete' => 'Complete'];
$data = [];
$data['status'] = ['open' => 'Open', 'inprogress' => 'In-Progress', 'complete' => 'Complete'];
$data['client'] = $this->clientModel->select('clients.id,client_name,short_name')
->where('clients.is_active',1)
->where('clients.client_type',2)
->findAll();
$data['insurer'] = $this->insurerModel->select('insurers.id,name,short_name')
->where('insurers.is_active',1)
->findAll();
// if (count($this->request->getGet())) {
// $filterData = $this->request->getGet();
// $data['employees'] = $this->partnerEndorsementRequestModel->getRetailEndorsementList(
// client_id: $filterData['client_id'],
// insurer_id: $filterData['insurer_id'],
// status: $filterData['status']
// );
// $data['getData'] = $filterData;
// // echo "<pre>";
// // print_r($data); die;
$filterData = $this->request->getGet();
$data['employees'] = $this->partnerEndorsementRequestModel->getRetailEndorsementList(
client_id: $filterData['client_id'] ?? null,
insurers_id: $filterData['insurer_id'] ?? null,
status: $filterData['status'] ?? null
);
$data['getData'] = $filterData;
// echo "<pre>";
// print_r($data); die;
// }
// $this->myLogger->logme('error', 'list called');
// $this->loadLayout('retail_endorsement_list', $data);
$this->loadLayout('retail_endorsement_list', $data);
}
public function retailendorsementsave()
{
try {
$data = $this->request->getPost();
if (!empty($data['id'])) {
$text = "update";
$updateID = $data['id'];
$result = $this->partnerEndorsementRequestModel->where('id', $updateID)->set($data)->update();
} else {
$text = "create";
$data['created_by'] = get_session_userid();
$this->thzMasterModel->insert($data);
$insertID = $this->partnerEndorsementRequestModel->insertID();
$result = true;
}
$id = isset($insertID) && !empty($insertID) ? $insertID : $updateID;
return $this->response->setJSON([
'status' => $result ? 'success' : 'error',
'message' => $result ? "Partner Endorsement Request {$text}d successfully " : "Unable to {$text} Partner Endorsement Request. Please try again.",
])->setStatusCode($result ? 200 : 400);
} catch (\Throwable $e) {
$code = ($e->getCode() && $e->getCode() >= 100 && $e->getCode() < 600) ? $e->getCode() : 500;
$isDbError = $e instanceof \CodeIgniter\Database\Exceptions\DatabaseException
|| $e instanceof \mysqli_sql_exception
|| $e instanceof \PDOException;
$context = ['title' => get_class($e), 'type' => get_class($e), 'code' => $code, 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()];
$this->myLogger->logme('error', "Exception: {message} in {file} on line {line}", $context, 0);
return $this->response->setJSON([
'status' => 'error',
'message' => $isDbError ? 'Data Access Error' : $e->getMessage(),
'ref' => $isDbError ? 'database - ' : 'application - ' . $code . ' - ' . $e->getLine()
])->setStatusCode($code);
}
}
}

View File

@ -57,8 +57,8 @@ class Home extends PublicController
$data['gemini_response'] = 'An error occurred: ' . $e->getMessage();
}
print_rr($data);
}
//print_rr($data);
}
public function check_gemini_2()
{
@ -78,8 +78,9 @@ class Home extends PublicController
$filePath = 'C:/Users/Venba/Desktop/ins stmts/NIC MDU June-2025 (1).pdf';
$filePath = 'C:/Users/Venba/Desktop/ins stmts/UIIC GR June-2025.pdf';
$filePath = 'C:/Users/Venba/Desktop/ins stmts/UIIC VLR June-2025 (2).xlsx';
$filePath = 'C:/Users/Venba/Desktop/ins stmts/pdf/2.pdf';
$filePath = 'C:\Users\Venba\Downloads\Raheja June-2025.csv';
$filePath = 'C:/Users/Venba/Desktop/ins stmts/pdf/1.pdf';
$filePath = 'C:/Users/Venba/Desktop/ins stmts/output.csv';
// $filePath = 'C:\Users\Venba\Downloads\Raheja June-2025.csv';
// $filePath = 'C:/Users/Venba/Downloads/Raheja June-2025.pdf';
// $filePath = 'C:/Users/Venba/Desktop/ins stmts/ICICI Pru June-2025 (1).xlsx';
// $filePath = 'C:/Users/Venba/Desktop/ins stmts/Digit Life June-2025.xlsx';
@ -102,7 +103,7 @@ class Home extends PublicController
$base64Content = base64_encode($fileContent);
// The prompt you want to send to the model
$prompt = "give me a json with emp data like name,age,dob,mobile and email. only json not any explanations";
$prompt = "Read the following insurer monthly statement file and convert into JSON format as sample specified.attach statement items in 'items' key and if any other data available put it in 'meta'. Give me only JSON,not any explanations. If you find the same details like insured name, policy number,endorsement no,policy start date,policy end date group it as single policy and identify base premium, third party premium and terrorism premium.";
$prompt = "Read the following insurer monthly statement file and convert into JSON format as sample specified.attach statement items in 'items' key and if any other data available put it in 'meta'. Give me only JSON,not any explanations. If you find the same details like insured name, policy number,endorsement no,policy start date,policy end date group it as single policy and identify base premium, third party premium and terrorism premium.All brokerage amount may in the same name as brokerage or commission, so pick accordingly";
$prompt .= "{\'items\': [{\'sno\': 1, \'policy_no\': \'\', \'insured_name\': \'\', \'endorsement_no\': \'\', \'policy_start_date\': \'\', \'policy_end_date\': \'\', \'actual_base_premium_amount\': \'\', \'actual_third_party_premium_amount\': \'\', \'actual_terrorism_premium_amount\': \'\', \'actual_base_premium_percentage\': \'\', \'actual_third_party_premium_percentage\': \'\', \'actual_terrorism_premium_percentage\': \'\', \'actual_bp_brokerage_amount\': \'\', \'actual_tp_brokerage_amount\': \'\', \'actual_tep_brokerage_amount\': \'\', \'reward_amount\': \'\'}]}";
$payloadPart = null;
@ -270,6 +271,7 @@ public function convertToPdf($inputFile = null)
{
// 1. Load your Excel file
$inputFile = 'C:/Users/Venba/Desktop/ins stmts/Raheja June-2025.xlsx';
$inputFile = 'C:/Users/Venba/Desktop/ins stmts/ICICI Lom June-2025.xlsx';
// $inputFile = 'C:/Users/Venba/Desktop/ins stmts/pdf/sample.pdf';
$spreadsheet = IOFactory::load($inputFile);
@ -293,7 +295,7 @@ public function convertToPdf($inputFile = null)
$mpdf->AddPage();
$mpdf->WriteHTML($html);
}
$pdfPath = 'C:/Users/Venba/Desktop/ins stmts/pdf/2.pdf';
$pdfPath = 'C:/Users/Venba/Desktop/ins stmts/pdf/1.pdf';
// $pdfPath = WRITEPATH.'tmp';
$mpdf->Output($pdfPath, \Mpdf\Output\Destination::FILE); // Save file on server
// 4. Output

View File

@ -30,16 +30,16 @@ class ChatbotHelper
$emp_code = $chat_session_info['emp_code'];
$client_id = $chat_session_info['client_id'];
$client_branch_id = $chat_session_info['client_branch_id'];
// $relationship ='Father';
$relationship ='Self';
$EmployeeModel = new EmployeeModel();
return $EmployeeModel->getEmpFamilybyEmpCode(emp_code: $emp_code,client_id: $client_id,emp_status: ['draft'],policy_status:['draft'],client_branch_id:[ $client_branch_id ]);//,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]);//,relationship:[$relationship];
}
public static function getHospitalLink($client_policy_id){
public static function getHospitalLink($emp_policy_id){
// $client_policy_id = 336;
// $emp_id = 12288;
$EmployeePolicyModel = new EmployeePolicyModel();
$res = $EmployeePolicyModel->getHospitalLinkByPolicyandEmp($client_policy_id);
$res = $EmployeePolicyModel->getHospitalLinkByPolicyandEmp($emp_policy_id);
return is_array($res) && count($res) ? $res[0]['network_hospitals'] : null;
}
@ -64,16 +64,18 @@ class ChatbotHelper
{
$message = SELF::ReimbursementProcessMailTemplate();
$attachments = [
["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"],
["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
];
// $attachments = [
// ["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"],
// ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"],
// ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"]
// ];
$common = ['mail_type'=>'reimbursement_mail_process_bot'];
$email_id = $data['email_corporate'];
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]);
// $email_id = 'vitvelz@gmail.com';
// $res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Claim Reimbursement Process', 'message' => $message,'attachments' => $attachments,'common'=>$common]);
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Claim Reimbursement Process', 'message' => $message,'common'=>$common]);
$res = json_decode($res);
if($res->status == 'success')
@ -166,7 +168,7 @@ class ChatbotHelper
<div class="steps">
<ol>
<li><strong>Gather Documents:</strong> Collect all required documents such as bills, invoices, and medical reports.</li>
<li><strong>Complete the Claim Form:</strong> Fill out the insurance claim form accurately.</li>
<li><strong>Complete the Claim Form:</strong> Fill out the insurance claim form in the portal.</li>
<li><strong>Attach Supporting Documents:</strong> Attach all necessary documents to support your claim.</li>
<li><strong>Submit Your Claim:</strong> Send the completed form and documents via email or through our online portal.</li>
<li><strong>Track Your Claim:</strong> Use our tracking system to monitor the status of your claim.</li>
@ -174,12 +176,10 @@ class ChatbotHelper
</ol>
</div>
<a href="[CLAIM_PORTAL_URL]" class="btn">Submit Your Claim</a>
<p>If you have any questions, feel free to contact our support team.</p>
<div class="footer">
<p>Best Regards,<br><strong>Insurance Support Team</strong><br><a href="mailto:support@example.com">support@example.com</a></p>
<p>Best Regards,<br><strong>NhanceIndia Support Team</strong><br><a href="mailto:support@example.com">info@nhanceindia.in</a></p>
</div>
</div>
@ -202,7 +202,8 @@ class ChatbotHelper
$common = ['mail_type'=>'request_quotation_bot'];
$email_id = getenv('email.enquiryMail');
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Quotation Request Received from bot.', 'message' => $message,'common'=>$common]);
// $res = MailHelper::send_email(['mail' => $email_id, 'bcc' => 'vitvelz@gmail.com','subject' => '(TESTING)Quotation Request Received from bot.', 'message' => $message,'common'=>$common]);
$res = MailHelper::send_email(['mail' => $email_id,'subject' => 'Quotation Request Received from bot.', 'message' => $message,'common'=>$common]);
$res = json_decode($res);
log_message('error','res: '.json_encode($res));
@ -218,7 +219,7 @@ class ChatbotHelper
}
public static function quotationRequestMailTemplate($data){
$message = 'A customer has requested for a quotation using bot,Here are all the details for it:
$message = 'A customer has requested for a quotation using bot,Here are all the details for it:<br>
'.$data;
return $message;
}
@ -266,7 +267,8 @@ class ChatbotHelper
$mail_content = Self::ReimbursementStatusMailTemplate($data['emp_name'],$data['claim_number'],$matched_key);
$common = ['mail_type'=>'Claim Status'];
$email_id = $data['emp_mail'];
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Here is your claim status you requested in bot.', 'message' => $mail_content,'common'=>$common]);
// $email_id = 'vitvelz@gmail.com';
$res = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Claim status as you requested in bot.', 'message' => $mail_content,'common'=>$common]);
$res = json_decode($res);
log_message('error','res: '.json_encode($res));

View File

@ -2072,11 +2072,15 @@ class EmployeePolicyModel extends Model
return $result[0];
}
public function getHospitalLinkByPolicyandEmp($client_policy_id){
$data = $this->db->table('client_policy')
public function getHospitalLinkByPolicyandEmp($emp_policy_id){
$data = $this->db->table('employee_polices')
->select('tpa.network_hospitals')
->where('client_policy.id', $client_policy_id)
->where('employee_polices.id', $emp_policy_id)
->where('employee_polices.is_active', 1)
->where('employee_polices.status', 'active')
// ->where('client_policy.id', $client_policy_id)
// ->where('employee_polices.is_active', 1)
->join('client_policy', 'employee_polices.client_policy_id = client_policy.id AND client_policy.is_active = 1')
->join('tpa', 'tpa.id = client_policy.tpa_id AND tpa.is_active = 1')
// ->join('employees', 'employees.id = employee_polices.employee_id AND employees.id = ' . (int) $emp_id)
->get()->getResultArray();

View File

@ -116,7 +116,7 @@
frameEndpoint: `<?=base_url('widget')?>`,
title: "Ask ILA",
placeholderText: "Type your message here...",
aboutText: "Insurance Assistant ILA",
aboutText: "Press enter to send messages",
enableAttachments: false,
introMessage: ('Welcome '+ name + '...! Say Hi...'),
bubbleAvatarUrl:"https://botman.io/img/logo.png",
@ -570,10 +570,10 @@ function setupMessageObserver() {
if (window.botmanWidget) {
botmanChatWidget.open();
setTimeout(function(){
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);
// setTimeout(function(){
// 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');
// }, 10);
applyBotManChatCSS();
@ -593,6 +593,14 @@ function setupMessageObserver() {
chatFrame.addEventListener("load", () => {
console.log('Iframe loaded event triggered');
setTimeout(() => injectCSS(chatFrame), 100);
// DADA
setTimeout(function(){
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');
}, 100);
// DADA
});
});
}
@ -677,8 +685,8 @@ 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://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</head>
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>

View File

@ -1424,74 +1424,6 @@
</li>
<?php } ?>
<!-- Enrollment process -->
<?php if (in_array(get_role_id(), [1, 2, 3, 5]) || in_array(ENROLLMENT_TEAM_ID, user_team())) { ?>
<li>
<a href="#sidebarDashboards" data-toggle="collapse" class="waves-effect img-inactive-not-working">
<img style="border-radius: 5px;"
src="<?= base_url() . "public"; ?>/assets/images/action_on_policies_sb.png" alt="Logo" height="20">
<span> Action on Policies </span>
</a>
<div class="collapse" id="sidebarDashboards">
<ul class="nav-second-level">
<li>
<a href="<?= base_url('/employee/upload') ?>">View Inception</a>
</li>
<li>
<a href="<?= base_url('/employee/list') ?>">View Members</a>
</li>
<li>
<a href="<?= base_url('/employee/endorsement-list') ?>">View Endorsement</a>
</li>
<li>
<a href="<?= base_url('/employee/enrollment-list') ?>">View Enrolment</a>
</li>
<li>
<a href="<?= base_url('/employee/test_members_list') ?>">Test Members List</a>
</li>
</ul>
</div>
</li>
<?php } ?>
<!-- Masters -->
<?php if (get_role_id() == 1 || get_role_id() == 5) { ?>
<li>
<a href="#sidebarDashboards" data-toggle="collapse" class=" img-inactive-not-working">
<img
src="<?= base_url() . "public"; ?>/assets/images/masters_sb.png" alt="Logo" height="20">
<span> Masters </span>
</a>
<div class="collapse" id="sidebarDashboards">
<ul class="nav-second-level">
<li>
<a href="<?= base_url('/master/insurer/list') ?>">Insurer</a>
</li>
<li>
<a href="<?= base_url('/master/tpa/list') ?>">TPA</a>
</li>
<li>
<a href="<?= base_url('/master/kyc/list') ?>">KYC</a>
</li>
<li>
<a href="<?= base_url('/master/policy/list') ?>">Policy</a>
</li>
<li>
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
</li>
<li>
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
</li>
<li>
<a href="<?= base_url('/user/list') ?>"> Users </a>
</li>
</ul>
</div>
</li>
<?php } ?>
<!-- Enrollment process -->
<?php if (in_array(get_role_id(), [1,2,3,5]) || in_array(ENROLLMENT_TEAM_ID, user_team())) { ?>

View File

@ -12,6 +12,18 @@
position: relative;
left: 79px;
}
.emp_data_model {
font-size: 17px; /* keep fixed size */
color: #555 !important;
cursor: pointer;
transition: transform 0.2s, color 0.2s; /* smooth hover effect */
display: inline-block; /* important for transform */
}
.emp_data_model:hover {
color: #00999E !important;
transform: scale(1.5);
}
</style>
<div class="container-fluid">
@ -33,6 +45,11 @@
<label>Client</label> <br />
<select class="form-control" id="clients">
<option value="0">Select</option>
<?php foreach ($client as $key => $value) { ?>
<option value="<?= $value['id'] ?>" <?= (($getData['client_id'] ?? '') == $value['id']) ? 'selected' : '' ?>>
<?= $value['client_name'] . (!empty($value['short_name']) ? ' ( ' . $value['short_name'] . ' )' : '') ?>
</option>
<?php } ?>
</select>
</div>
@ -40,6 +57,11 @@
<label>Insurer</label> <br />
<select class="form-control" id="insurer">
<option value="0">Select</option>
<?php foreach ($insurer as $key => $value) { ?>
<option value="<?= $value['id'] ?>" <?= (($getData['insurer_id'] ?? '') == $value['id']) ? 'selected' : '' ?>>
<?= $value['name'] . (!empty($value['short_name']) ? ' ( ' . $value['short_name'] . ' )' : '') ?>
</option>
<?php } ?>
</select>
</div>
@ -48,7 +70,7 @@
<select class="form-control" id="status1">
<option value="0">Select</option>
<?php foreach ($status as $key => $value) { ?>
<option value="<?= $key ?>" <?= (isset($getData) && $getData['status'] == $key) ? 'selected' : '' ?>>
<option value="<?= $key ?>" <?= (($getData['status'] ?? '') == $key) ? 'selected' : '' ?>>
<?= $value ?>
</option>
<?php } ?>
@ -58,7 +80,7 @@
</div>
<div class="row">
<div class="col-12" style="text-align: right;">
<a href="<?= base_url("employee/endorsement-list"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
<a href="<?= base_url("employee/retail-endorsement-list"); ?>" class="btn btn-primary waves-effect waves-light" id="get-emp-list" onclick="fetchEmpolyeeList(event);">Submit</a>
</div>
</div>
<!-- </div> -->
@ -75,9 +97,8 @@
<div class="card-body">
<div class="row" style="padding-bottom: 10px;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">Endorsement List</h4>
<h4 style="position: relative;">Endorsement</h4>
</div>
</div>
<table data-custom-table-css="table" class="table table-hover m-0 table-centered dt-responsive w-100" cellspacing="0" id="tickets-table">
<thead class="bg-light">
@ -101,16 +122,20 @@
if (isset($employees)) {
foreach ($employees as $key => $employee) { ?>
<tr>
<td><b><?php echo ($key + 1) ?></b></td>
<td><?php echo $employee['policy_number'] ?></td>
<td><?php echo $employee['endorsement_no'] ?></td>
<td><?php echo $employee['endorsement_description'] ?></td>
<td><?php echo $employee['insurer_name'] .' ( '. $employee['insurer_short_name'] .' ) ' ?></td>
<td><?php echo $employee['client_name'] .' ( '. $employee['client_short_name'] .' ) ' ?></td>
<td><?php echo $employee['agent_name'] ?></td>
<td><?php echo $employee['manager_name'] ?></td>
<td><?php echo $employee['created_at'] ?></td>
<td><?php if ($employee['status'] == 'open') {
<td class="text-center"><b><?php echo ($key + 1) ?></b></td>
<td class="text-center"><?php echo $employee['policy_number'] ?></td>
<td class="text-center"><?php echo $employee['endorsement_no'] ?></td>
<td class="text-center"><?php echo $employee['endorsement_description'] ?></td>
<td class="text-center"><?php echo $employee['client_name'] ? $employee['client_name'] .' ( '. $employee['client_short_name'] .' ) ' : 'N/A' ?></td>
<td class="text-center"><?php echo $employee['insurer_name'] ? $employee['insurer_name'] .' ( '. $employee['insurer_short_name'] .' ) ' : 'N/A' ?></td>
<td class="text-center"><?php echo $employee['agent_name'] ?? 'N/A' ?></td>
<td class="text-center"><?php echo $employee['manager_name'] ?? 'N/A' ?></td>
<td class="text-center"><?php if (!empty($employee['created_at'])):
$cd = date("j F Y", strtotime($employee['created_at']));
$ct = date("h:i a", strtotime($employee['created_at']));
echo $cd . "<br><span class='time'> " . $ct . "</span>";
endif; ?></td>
<td class="text-center"><?php if ($employee['status'] == 'open') {
echo '<span class="badge badge-primary">' . $employee['status'] . '</span>';
} elseif ($employee['status'] == 'inprogress') {
echo '<span class="badge badge-warning">' . $employee['status'] . '</span>';
@ -120,7 +145,7 @@
?>
</td>
<td class="text-center"><a href="#" data-id="<?php echo $employee['id'] ?>" data-eno="<?php echo $employee['endorsement_no'] ?>" data-status="<?php echo $employee['status'] ?>"
class="mdi mdi-eye emp_data_model" aria-hidden="true" data-toggle="modal" data-target="#centermodal"></a>
class="mdi mdi-pencil text-muted vertical-middle emp_data_model" aria-hidden="true" data-toggle="modal" data-target="#centermodal"></a>
</td>
</tr>
<?php }
@ -138,21 +163,48 @@
<div class="modal fade app-text-black " id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<form id="retailEndorsementForm">
<div class="modal-header">
<h4 class="modal-title title-text" id="myCenterModalLabel" style="font-size:27px !important">Edit Endorsement Details <span id="heading"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<!-- Center modal content -->
<div class="modal fade" id="centermodal" tabindex="-1" role="dialog" aria-hidden="true" aria-modal="true" data-backdrop="static">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header" style="background-color: gainsboro;">
<h4 class="modal-title" id="myCenterModalLabel">Edit Endorsement Details <span id="heading"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div class="modal-body">
<div class="form-row">
<input type="hidden" id="edit_id" name="id">
<input type="hidden" id="updated_by" name="updated_by" value="<?= get_session_userid(); ?>">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>"/>
<div class="form-group col-md-12">
<label for="endorsement_no" class="sub-title-text ">Endorsement Number<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="endorsement_no" placeholder="Enter Endorsement Number" name="endorsement_no" required>
</div>
<div class="modal-body" id="modal_body">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div class="form-group col-md-12">
<label for="edit_status" class="sub-title-text ">Status<span class="text-danger">*</span></label>
<select class="form-control" id="edit_status" name="status" required>
<option value="">Select Status</option>
<?php foreach ($status as $key => $value) { ?>
<option value="<?= $key ?>"><?= $value ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn app-btn-outline-secondary mr-2 " type="button" data-dismiss="modal" aria-hidden="true">Cancel</button>
<button type="submit" class="btn app-btn-secondary" id="btnSubmit" onclick="submitRetailEndorsement(event)">Save</button>
</div>
</form>
</div>
</div>
</div>
<script>
@ -162,208 +214,15 @@
$("#insurer").select2();
});
// Declare a global variable to store API response data
var clientPolicies = [];
var client_id = '<?= isset($getData) ? $getData['client_id'] : '0' ?>';
var insurer_id = '<?= isset($getData) ? $getData['insurer_id'] : '0' ?>';
var client_id = '<?= $getData['client_id'] ?? '' ?>';
var insurer_id = '<?= $getData['insurer_id'] ?? '' ?>';
var status_id = '<?= $getData['status'] ?? '' ?>';
$(window).on("load", function() {
console.log("window loaded");
fetchClientPolicies();
});
function fetchClientPolicies() {
$('#loader').show();
var apiURL = '<?php echo base_url(); ?>' + 'util/clients-with-policies';
console.log('fetchClientPolicies');
// console.log(apiURL);
$.ajax({
url: apiURL,
method: 'GET',
headers: {
"Content-Type": "application/json",
"X-Requested-With": "XMLHttpRequest"
},
success: function(response) {
// console.log(response.code);
// console.log(response.dataStatus);
// console.log(response.data);
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
try {
clientPolicies = (response.data);
response.data.forEach(policy => {
// console.log('policies', policy.policies);
policy.policies.forEach(p => {
clientPoliciesWithBranch.policies.push(p);
});
});
// console.log(clientPolicies);
appendClients(clientPolicies);
setTimeout(function() {
if (client_id) {
var foundPolicies = clientPolicies.find(function(item) {
// console.log(typeof item.id)
return item.id == client_id;
});
appendBranch(foundPolicies.branchs);
}
}, 500);
setTimeout(function() {
if (client_branch_id) {
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
// console.log('item', item);
return item.branch_id === client_branch_id;
});
if (foundPolicies) {
// console.log('foundPolicies', foundPolicies);
appendPolicies(foundPolicies);
} else {
console.log('No policies found for the selected client');
}
}
}, 500);
} catch (error) {
console.error('Error parsing API response data:', error);
}
} else if (response.code === 404 && response.dataStatus === false) {
console.error('no data found', response);
} else {
console.error('Something went wrong!');
}
},
error: function(xhr, status, error) {
console.error('Error fetching data from API:', error);
}
});
$('#loader').hide();
}
function appendClients(data) {
var clientID = <?= isset($getData) ? $getData['client_id'] : '0' ?>;
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.client_name
});
if (clientID == item.id) {
option.attr('selected', true);
}
$('#clients').append(option);
});
}
function appendBranch(data) {
$('#branch_id').empty();
$('#branch_id').append($('<option>', {
value: '0',
text: 'Select'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
if (client_branch_id == item.id) {
option.attr('selected', true);
}
$('#branch_id').append(option);
});
}
function appendPolicies(data) {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var PolicyID = <?= isset($getData) ? $getData['policy_id'] : '0' ?>;
// console.log(PolicyID)
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.client_policy_id,
// text: `${item.name ?? ''} - ${item.policy_no ?? ''} - ${item.policy_type ?? ''}`
text:`${item.policy_type ?? ''} - ${item.policy_no ?? ''}`
});
if (PolicyID == item.client_policy_id) {
option.attr('selected', true);
}
$('#policies').append(option);
});
}
$(document).ready(function() {
$('#clients').on('change', function() {
$('#policies').empty();
$('#policies').append($('<option>', {
value: '0',
text: 'Select'
}));
var selectedClient = $(this).val();
// console.log(selectedClient);
// $('#selectedOptionInfo').text('Selected option: ' + selectedOption);
// Check if the selected option exists in apiData
var foundPolicies = clientPolicies.find(function(item) {
return item.id === selectedClient;
});
// console.log(foundPolicies.branchs);
appendBranch(foundPolicies.branchs);
});
});
$(document).ready(function() {
$('#branch_id').on('change', function() {
var selectedClient = $(this).val();
// console.log('selectedBranch', selectedClient);
// console.log('clientPolicies', clientPoliciesWithBranch);
var foundPolicies = clientPoliciesWithBranch.policies.filter(function(item) {
// console.log('item', item);
return item.branch_id === selectedClient;
});
if (Array.isArray(foundPolicies) && foundPolicies.length === 0) {
appendPolicies(foundPolicies);
toastr.warning('No policies found for the selected client branch.');
} else {
// console.log('foundPolicies', foundPolicies);
appendPolicies(foundPolicies);
}
});
});
// Function to convert object to query parameters
function objectToQueryString(obj) {
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
@ -373,19 +232,12 @@
event.preventDefault(); // Prevent default action
var client_id = $('#clients').val();
var policy_id = $('#policies').val();
var insurer_id = $('#insurer').val();
var status = $('#status1').val();
var branch_id = $('#branch_id').val();
// console.log(client_id + '-' + policy_id);
if (client_id == '0' || policy_id == '0') {
alert('Please select values in both dropdowns.');
return;
}
var queryParams = {
client_id: client_id,
policy_id: policy_id,
branch_id: branch_id,
insurer_id: insurer_id,
status: status,
};
@ -408,160 +260,74 @@
var eno = $(this).data('eno');
var status = $(this).data('status');
// console.log(val);
fetchEmpEndorsementData(id,eno,status)
fetchRetailEndorsementData(id,eno,status)
});
function submitRetailEndorsement(e) {
e.preventDefault(); // stop normal form submit
var form = document.getElementById("retailEndorsementForm");
var id = form.querySelector("[name='id']").value;
var formData = new FormData(form);
form.classList.remove('was-validated');
var btn = document.getElementById("btnSubmit");
btn.disabled = true;
btn.innerText = "Saving...";
function fetchEmpEndorsementData(id,eno,status) {
alert("id");
alert(id);
alert(eno);
alert(status);
// $('.loader').fadeIn();
// $('.loader-mask').fadeIn();
// var apiURL = '<?php echo base_url(); ?>' + 'util/get-emp-endorsement/' + id;
// console.log('fetchEmpEndorsementData');
// // console.log(apiURL);
// $.ajax({
// url: apiURL,
// method: 'GET',
// headers: {
// "Content-Type": "application/json",
// "X-Requested-With": "XMLHttpRequest"
// },
// success: function(response) {
// // console.log(response);
// if (response.code === 200 && response.dataStatus === true) {
// try {
// endorsementData = (response.data);
// endorsementData2 = (response.data2);
// e_actions = endorsementData2[0]['actions'];
// var heading = "";
// if (endorsementData2[0]['actions'] == 'si') {
// heading = ' - ' + 'SI Enhancement';
// heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
// } else if (endorsementData2[0]['actions'] == 'd') {
// heading = ' - ' + 'Deletion';
// heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
// } else if (endorsementData2[0]['actions'] == 'c') {
// heading = ' - ' + 'Correction';
// heading += ' - ' + (endorsementData2[0]['endorsement_id'] !== null ? endorsementData2[0]['endorsement_id'] : endorsementData2[0]['status']);
// }
// $('#heading').html(heading);
// $('#table_data').empty();
// $('#table_head_data').empty();
// if (e_actions == 'd') {
// $.each(endorsementData, function(index, item) {
// var tableHtml = `
// <tr>
// <td>${item.field_name}</td>
// <td>${formatNumberToIndianLocale(item.data, item.field_name, e_actions)}</td>
// </tr>
// `;
// $('#table_data').append(tableHtml);
// });
// } else {
// var table_head = `
// <tr>
// <th class="font-weight-medium"></th>
// <th class="font-weight-medium">Old Value</th>
// <th class="font-weight-medium">New Value</th>
// </tr>
// `;
// $('#table_head_data').append(table_head);
// $.each(endorsementData, function(index, item) {
// var tableHtml = `
// <tr>
// <td>${item.field_name}</td>
// <td>${formatNumberToIndianLocale(item.old_value, item.field_name)}</td>
// <td>${formatNumberToIndianLocale(item.new_value, item.field_name, e_actions)}</td>
// </tr>
// `;
// $('#table_data').append(tableHtml);
// });
// }
// } catch (error) {
// console.error('Error parsing API response data:', error);
// }
// } else if (response.code === 404 && response.dataStatus === false) {
// console.error('no data found', response);
// } else {
// console.error('Something went wrong!');
// }
// },
// error: function(xhr, status, error) {
// console.error('Error fetching data from API:', error);
// }
// });
// setTimeout(function() {
// $('.loader').fadeOut();
// $('.loader-mask').delay(350).fadeOut('slow');
// }, 200);
}
function formatNumberToIndianLocale(value, field_name, action) {
// Check if the value is a valid number (either as a number or as a string)
if (!isNaN(value) && !isNaN(parseFloat(value)) && field_name != 'No of Days') {
// Convert the value to a number and format it using Indian English locale
var return_val = parseFloat(value).toLocaleString('en-IN');
if (field_name == 'Period of non coverage') {
return value + ' days';
}
if (field_name == 'Total Amount') {
return '₹ ' + return_val + ' ( To be Refunded )';
}
if (field_name == 'Total') {
if (action == 'd') {
return '₹ ' + return_val + ' ( To be Refunded )';
} else if (action == 'si') {
return '₹ ' + return_val + ' ( To be paid )';
}
}
return '₹ ' + return_val;
} else {
// Return the original value if it's not a valid number
return value;
var endorsement_no = document.getElementById('endorsement_no').value.trim();
var edit_status = document.getElementById('edit_status').value.trim();
if (endorsement_no === "" || edit_status === "") {
toastr.warning('Please fill all required fields.', 'Warning');
form.classList.add('was-validated');
return;
}
$.ajax({
url: "<?= base_url('/employee/retail-endorsement-save') ?>",
type: "POST",
data: formData,
processData: false,
contentType: false,
dataType: 'json',
success: function(response) {
if (response.status === "success") {
toastr.success(response.message, 'Success');
$('.emp_data_model').modal('hide');
form.reset();
window.location.href = "<?= base_url('/employee/retail-endorsement-list') ?>";
} else {
toastr.error(response.message, 'Error');
}
},
error: function(xhr) {
toastr.error("Something went wrong!", 'Error');
console.error(xhr.responseText);
},
complete: function() {
btn.disabled = false;
btn.innerText = "Save";
}
});
}
$('.close').click(function() {
function fetchRetailEndorsementData(id,eno,status) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var form = document.getElementById('retailEndorsementForm');
form.reset();
$("#edit_id").val(id);
$("#endorsement_no").val(eno);
$("#edit_status").val(status);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 200);
}
$('#table_data').empty();
})
$(document).ready(function() {
@ -572,7 +338,7 @@
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'Endorsement-List',
title: 'Retail-Endorsement-List',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)',
@ -590,7 +356,7 @@
initComplete: function(settings, json) {
$('.my_class').css({
"position": "relative",
"left": "79px"
"left": "15px"
});
},
language: {

View File

@ -623,6 +623,7 @@ $(document).ready(function() {
],
paging: true,
pageLength: 25,
order: [[0, 'desc']]
});
} else {