MERGE_TEST_CLAIMS_LIVE_FEEDBACK

This commit is contained in:
Venba 2025-03-06 06:38:45 +00:00
commit e64b5563a8
25 changed files with 1920 additions and 1202 deletions

View File

@ -531,6 +531,8 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
$routes->post('note/(:any)','TicketController::crudNote/$1');
$routes->post('reply','TicketController::saveReply');
$routes->match( ['get', 'post'], 'ticket_reports','TicketController::ticketReports');
$routes->post('getPolicyStartDate','TicketController::getPolicyStartDate');
$routes->post("getPoliciesbyEmpID","TicketController::getPoliciesbyEmpID");
// $routes->post('ticket_messages','TicketController::getTicketMessage');
});

View File

@ -1,110 +0,0 @@
<?php
namespace App\Controllers\Chatbot;
use BotMan\BotMan\BotMan;
class BotService
{
public static function sendMainOptions(BotMan $bot)
{
$bot->reply('Welcome! Please choose an option:', [
'reply_markup' => json_encode([
'keyboard' => [
['Card Download'],
['Network Hospital'],
['Reimbursement Claim Process'],
['Reimbursement Claim Status'],
['New Policy'],
['Renew Policy']
],
'resize_keyboard' => true,
'one_time_keyboard' => true
])
]);
}
public static function handleCardDownload(BotMan $bot)
{
$bot->reply('Please choose an option:', [
'reply_markup' => json_encode([
'keyboard' => [
['Download Card'],
['Go Back']
],
'resize_keyboard' => true,
'one_time_keyboard' => true
])
]);
}
public static function handleNetworkHospital(BotMan $bot)
{
$bot->reply('Please choose an option:', [
'reply_markup' => json_encode([
'keyboard' => [
['Find Hospital'],
['Go Back']
],
'resize_keyboard' => true,
'one_time_keyboard' => true
])
]);
}
public static function handleReimbursementClaimProcess(BotMan $bot)
{
$bot->reply('Please choose an option:', [
'reply_markup' => json_encode([
'keyboard' => [
['Submit Claim'],
['Go Back']
],
'resize_keyboard' => true,
'one_time_keyboard' => true
])
]);
}
public static function handleReimbursementClaimStatus(BotMan $bot)
{
$bot->reply('Please choose an option:', [
'reply_markup' => json_encode([
'keyboard' => [
['Check Status'],
['Go Back']
],
'resize_keyboard' => true,
'one_time_keyboard' => true
])
]);
}
public static function handleNewPolicy(BotMan $bot)
{
$bot->reply('Please choose an option:', [
'reply_markup' => json_encode([
'keyboard' => [
['Get Quote'],
['Go Back']
],
'resize_keyboard' => true,
'one_time_keyboard' => true
])
]);
}
public static function handleRenewPolicy(BotMan $bot)
{
$bot->reply('Please choose an option:', [
'reply_markup' => json_encode([
'keyboard' => [
['Renew Now'],
['Go Back']
],
'resize_keyboard' => true,
'one_time_keyboard' => true
])
]);
}
}

View File

@ -1,34 +0,0 @@
<?php
namespace App\Controllers\Chatbot;
use BotMan\BotMan\BotMan;
use BotMan\BotMan\Messages\Outgoing\Actions\ButtonTemplate;
use BotMan\BotMan\Messages\Outgoing\Actions\ElementButton;
class ClaimHandler
{
public static function handle(BotMan $bot, $option)
{
$responses = [
'reimbursement_claim_process' => "Reimbursement Claim Process: Here is a dummy response.",
'reimbursement_claim_status' => "Reimbursement Claim Status: Here is a dummy response."
];
if (isset($responses[$option])) {
$bot->reply($responses[$option]);
} else {
$bot->reply("Unknown claim option.");
}
// Send Back Button
self::sendBackButton($bot);
}
private static function sendBackButton(BotMan $bot)
{
$bot->reply(ButtonTemplate::create("Would you like to return?")
->addButton(ElementButton::create("Go Back")->type('postback')->payload("main_menu"))
);
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace App\Controllers\Chatbot;
use App\Helpers\ChatbotHelper;
use BotMan\BotMan\Messages\Conversations\Conversation;
use BotMan\BotMan\Messages\Outgoing\Question;
use BotMan\BotMan\Messages\Outgoing\Actions\Button;
use BotMan\Drivers\Web\WebDriver;
class LoginToContiueConversation extends Conversation
{
public function run()
{
$this->bot->userStorage()->delete();
$this->bot->types(); // Typing indicator for the first message
sleep(0.5); // Delay
$this->showLoginMessage();
}
protected function showLoginMessage()
{
$this->say("Kindly Login to use the chatbot");
}
}

View File

@ -1,36 +0,0 @@
<?php
namespace App\Controllers\Chatbot;
use BotMan\BotMan\BotMan;
use BotMan\BotMan\Messages\Outgoing\Actions\ButtonTemplate;
use BotMan\BotMan\Messages\Outgoing\Actions\ElementButton;
class PolicyHandler
{
public static function handle(BotMan $bot, $option)
{
$responses = [
'ecard_download' => "Ecard Download: Here is a dummy response.",
'network_hospital' => "Network Hospital: Here is a dummy response.",
'new_policy' => "New Policy: Here is a dummy response.",
'renew_policy' => "Renew Policy: Here is a dummy response."
];
if (isset($responses[$option])) {
$bot->reply($responses[$option]);
} else {
$bot->reply("Unknown policy option.");
}
// Send Back Button
self::sendBackButton($bot);
}
private static function sendBackButton(BotMan $bot)
{
$bot->reply(ButtonTemplate::create("Would you like to return?")
->addButton(ElementButton::create("Go Back")->type('postback')->payload("main_menu"))
);
}
}

View File

@ -1,27 +0,0 @@
<?php
namespace App\Controllers\Chatbot;
use BotMan\BotMan\BotMan;
class TypingMiddleware
{
/**
* Handle the middleware logic.
*
* @param BotMan $bot
* @param callable $next
* @return mixed
*/
public function handle($bot, $next)
{
$this->myLogger = \Config\Services::mylogger();
$this->myLogger->logme('error', 'MIDDLEWARE');
// Simulate typing indicator
$bot->types();
sleep(0.1); // Cap delay at 5 seconds (convert to microseconds)
// Proceed to the next middleware or response
return $next($bot);
}
}

View File

@ -2,6 +2,7 @@
namespace App\Controllers;
use App\Controllers\Chatbot\LoginToContiueConversation;
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\BotMan\Drivers\DriverManager;
@ -19,6 +20,7 @@ class ChatbotControllerNew extends BaseController
protected $myLogger;
protected $session;
protected $botman;
protected $isMemberLoggedIn;
public function __construct()
{
@ -91,6 +93,12 @@ class ChatbotControllerNew extends BaseController
$this->session->set('CHATBOT_RANDOM_USER_ID', $id);
}
$this->isMemberLoggedIn = false;
$chat_session_info = get_chatbot_session_info();
if (!empty($chat_session_info['emp_id']) && !empty($chat_session_info['emp_code'] )){
$this->isMemberLoggedIn = true;
}
$this->botman->hears('.*', function ($bot) {
$bot->types(); // Typing indicator for the first message
@ -98,8 +106,13 @@ class ChatbotControllerNew extends BaseController
});
// Start the Main Menu when user says "hi" or "start"
$this->botman->hears('start|hi|hello', function (BotMan $bot) {
if ($this->isMemberLoggedIn){
$bot->reply('Hi how can i assist?');
$bot->startConversation(new MainMenuConversation());
}else {
$bot->startConversation(new LoginToContiueConversation());
}
});

View File

@ -4295,7 +4295,7 @@ class ClientController extends AdminController
// dd($policyTerms);
// Re-encode the ordered policy terms
$updatedPolicyTerms = json_encode($policyTerms);
dd($updatedPolicyTerms);
// dd($updatedPolicyTerms);
// dd($orderedPolicyTerms, $updatedPolicyTerms);
$this->clientPolicyModel->update($data[$i]['id'], ['policy_terms' => $updatedPolicyTerms]);
@ -4574,7 +4574,7 @@ class ClientController extends AdminController
$employeeRestController = new EmployeeServiceController();
// $employeeRestController->excelFileDataValidation(['file_id' => 823]);
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 644]);
// $employeeRestController->employeesOnboardPreprocess(['file_id' => 726]);
// $employeeRestController->employeesOnboardProcess(['file_id' => 835]);
// $employeeRestController->employeesEnrollmentInsert(['file_id' => 836]);
// $r = Jobs::addJob(['job_name' => 'employeesEnrollmentInsert','payload' => ['file_id' => 721]]);
@ -4705,6 +4705,9 @@ class ClientController extends AdminController
// $this->loadLayout('tat_report_band_wise_list', $reportData);
// $data = $ticketModel->getTATReport(1);
// $empmodel = new EmployeeModel();
// $data = $empmodel->getEmployeePolicy(348);
// dd($data);
}
// -------------------------------------------------------------------------------------------------------

View File

@ -104,65 +104,63 @@ class RestAuthenticationController extends AdminController
$email = $this->request->getJSON()->email;
$employeeData = $this->employeeModel->select('employees.relationship,EP.employee_id')
$employeeData = $this->employeeModel->select('
employees.relationship,
EP.employee_id,
employees.client_id,
employees.client_branch_id,
employees.email_corporate
')
->join('employee_polices EP', 'EP.employee_id = employees.id', 'inner')
->where('employees.is_active', 1)
->where('employees.relationship', 'self')
->where('employees.relationship', 'Self')
->where('employees.emp_status !=', 'truncated')
->where('employees.email_corporate', $email)
->where('EP.is_active', 1)
->whereIn('EP.status', ['active'])
->whereIn('EP.status', ['draft', 'enrolled'])
->first();
if (isset($employeeData['employee_id']))
{
if (isset($employeeData['employee_id'])) {
$otp = random_int(100000, 999999);
$update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'self')
->where('is_active', 1)->set(array('otp' => $otp ))
$update = $this->employeeModel->where('email_corporate', $email)->where('relationship', 'Self')
->where('is_active', 1)->set(array('otp' => $otp))
->update();
if($update)
{
if ($update) {
$common = [
'client_id' => $employeeData['client_id'],
'client_branch_id' => $employeeData['client_branch_id'],
'client_policy_id' => null,
'employee_policy_id' => null,
'employee_id' => $employeeData['id'],
'employee_id' => $employeeData['employee_id'],
'mail_type' => 'otp_mail',
];
$subject = 'Nhance user verification - OTP';
$mail_content = $otp.' is your verification code for Nhance.';
$res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject ,'common'=>$common ,'message' => $mail_content]);
$mail_content = $otp . ' is your verification code for Nhance.';
$res = MailHelper::send_email(['mail' => $employeeData['email_corporate'], 'subject' => $subject, 'common' => $common, 'message' => $mail_content]);
$this->myLogger->logme("info", $res);
if(json_decode($res)->status == 'success')
{
$result = ['user_verification' => true ,'message' => "Verified Successfully"];
return $this->respond(['status' => 'success','code' => 200,'data' => $result],200);
}else{
$result = ['user_verification' => false , 'message' => "Mail sending failed , try again"];
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
}
}else{
$result = ['user_verification' => false , 'message' => "Verification failed , try again"];
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
}
if (json_decode($res)->status == 'success') {
$result = ['user_verification' => true, 'message' => "Verified Successfully"];
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $result], 200);
} else {
$result = ['user_verification' => false, 'message' => "Mail sending failed , try again"];
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
}
} else {
$result = ['user_verification' => false , 'message' => "User not found"];
return $this->respond(['status' => 'failed','code' => 404,'data' => $result],200);
$result = ['user_verification' => false, 'message' => "Verification failed , try again"];
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
}
} else {
$result = ['user_verification' => false, 'message' => "User not found"];
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => $result], 200);
}
} catch (\Throwable $th) {
return $this->respond(['status' => 'failed','code' => 500,'data' => $th],500);
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $th], 500);
}
}

View File

@ -12,6 +12,9 @@ use App\Models\TicketMailTemplateModel;
use App\Models\TicketMessageModel;
use App\Models\TicketNoteModel;
use App\Models\UserModel;
use App\Models\ClientPolicyModel;
use App\Models\EmployeePolicyModel;
use DOMDocument;
use Psr\Log\LoggerInterface;
use Kint\Kint;
@ -45,6 +48,8 @@ class TicketController extends BaseController
protected $triggerType;
protected $userModel;
protected $employeeModel;
protected $clientPolicyModel;
protected $employeePolicyModel;
public function __construct()
{
@ -80,10 +85,10 @@ class TicketController extends BaseController
];
$this->claimType = [
1 => [
1 => "Main",
1 => "Main Hospitalization",
3 => "Pre / Post",
2 => "OPD",
3 => "Pre ReOpen",
4 => "Post ReOpen",
4 => "ReOpen",
],
2 => [
1 => "TTD",
@ -157,6 +162,8 @@ class TicketController extends BaseController
$this->ticketMessageModel = new TicketMessageModel();
$this->userModel = new UserModel();
$this->employeeModel = new EmployeeModel();
$this->clientPolicyModel = new ClientPolicyModel();
$this->employeePolicyModel = new EmployeePolicyModel();
}
public function ticketList()
@ -439,7 +446,6 @@ class TicketController extends BaseController
$template_data['subject'] = $this->replacePlaceholders($template_data['subject'], $ticket_data);
}
$data = $this->ticket_form_data($ticket_data['ticket_type_id'], $ticket_data['claim_status_id']);
$data['ticket_data'] = $ticket_data;
$data['reply_data'] = $template_data;
$data['placeHolders'] = $this->placeHolders;
$data['message_data'] = $this->getTicketMessage($ticket_id);
@ -447,6 +453,12 @@ class TicketController extends BaseController
$data['member_data'] = $this->employeeModel->getEmployeeByEmployeeCode($ticket_data['emp_code']);
$data['ticket_history'] = $this->ticketHistory($ticket_id);
$data['ticket_check_list'] = db_connect()->table('ticket_check_list')->where('is_active', 1)->where('ticket_type_id', $ticket_data['ticket_type_id'])->get()->getResultArray();
if (!empty($ticket_data['client_policy_id'])){
$ticket_data['client_policy_id_text'] = $this->clientPolicyModel->select('concat(policy_type.policy_type,"-",client_policy.policy_no) as client_policy_name')->join('policy_type','policy_type.id = client_policy.policy_type_id and policy_type.is_active = 1')->where('client_policy.id',$ticket_data['client_policy_id'])->first()['client_policy_name'];
}
// dd($ticket_data);
$data['ticket_data'] = $ticket_data;
// dd($data);
return $this->loadLayout('ticket_edit_onbording', $data);
@ -841,8 +853,16 @@ class TicketController extends BaseController
$replaceData = $ticket_data[$value] ?? '';
} else if ($value == "policy_type") {
$replaceData = str_replace("Claim-", "", $this->ticketType[$ticket_data['ticket_type_id']] ?? "");
} else {
$replaceData = isset($ticket_data[$value]) ? strtoupper($ticket_data[$value]) : '';
} else if ($value == 'emp_name'){
if(empty($ticket_data['emp_id'])){
$replaceData = $ticket_data['emp_name']??"";
}
}else if ($value == 'insured_name'){
if(empty($ticket_data['insured_emp_id'])){
$replaceData = $ticket_data['insured_name']?? "";
}
}else {
$replaceData = isset($ticket_data[$value]) ? $ticket_data[$value] : '';
}
$content = str_replace($key, $replaceData, $content);
@ -1434,4 +1454,72 @@ class TicketController extends BaseController
return $lastMatchedStatus;
}
public function getPolicyStartDate()
{
$data = $this->request->getPost();
$client_policy_id = $data['policy_id'];
$policy_start_date = $this->clientPolicyModel->select('policy_start_date')->where('id', $client_policy_id)->first()['policy_start_date'];
// dd($data);
if (isset($data['employeeId']) && $data['employeeId'] != "" && $data['employeeId'] != null) {
// dd($data);
$emp_id = $data['employeeId'];
$empData = $this->employeeModel->select('dob,doj')->where('id',$emp_id)->findAll();
if (!empty($empData) && $empData != "" && $empData != null ) {
foreach ($empData as &$emp) { // Loop through the data
$emp['dob'] = date('d/m/Y', strtotime($emp['dob']));
$emp['doj'] = date('d/m/Y', strtotime($emp['doj']));
}
}
if ($empData){
return $this->respond(['status' => true, 'minDate' => $policy_start_date,'empData'=> $empData], 200);
}else{
return $this->respond(['status' => false, 'message' => "Policy Not Found"]);
}
} else {
// dd($policy_start_date);
if ($policy_start_date) {
return $this->respond(['status' => true, 'minDate' => $policy_start_date], 200);
} else {
return $this->respond(['status' => false, 'message' => "Policy Not Found"]);
}
}
}
public function getPoliciesbyEmpID() {
$received_data = $this->request->getPost();
$emp_id = $received_data['emp_id'];
// Get all client policy IDs for the given employee
$policies = $this->employeePolicyModel
->select('client_policy_id')
->where('employee_id', $emp_id)
->findAll();
if (empty($policies)) {
return []; // Return empty if no policies found
}
// Extract client policy IDs into an array
$policy_ids = array_column($policies, 'client_policy_id');
// Fetch all policy names and IDs in one query
$policyNameandID = $this->clientPolicyModel
->select('CONCAT(policy_type.policy_type, "-", client_policy.policy_no) as client_policy_name, client_policy.id as client_policy_value,client_policy.policy_type_id')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id AND policy_type.is_active = 1')
->whereIn('client_policy.id', $policy_ids)
->findAll();
// dd($policyNameandID);
if ($policyNameandID){
return $this->respond(['status'=>true,'policy_data'=> $policyNameandID]);
}else{
return $this->respond(['status'=>false,'message'=> "Policy Not Found"]);
}
}
}

View File

@ -682,7 +682,7 @@ if (!function_exists('generate_relationship_code'))
$slug = \Config\Services::slug();
$relationship_code = $slug->slugify($arr['relationship']);
$emp_type_code = ($relationship_code == 'self' ? 'EMP_TYP_01' : 'EMP_TYP_03');
$relationship_code = $gender[ $arr['gender'] ] . $relationship[ $relationship_code ] ;
$relationship_code = $gender[ trim($arr['gender']) ] . $relationship[ trim($relationship_code) ];
return ['relationship_code' => $relationship_code,'emp_type_code' => $emp_type_code];
}
}

View File

@ -1247,7 +1247,7 @@ class sendMailNotification
$subject = $notification['subject'];
$rand_string = 'HX3kUh';
$link = generate_download_link($rand_string);
$link = generate_download_link($rand_string).'/1';
$name = 'John Doe';
$mobile = 9080706050;

View File

@ -149,7 +149,21 @@ class EmployeeModel extends Model
{
return $this->db->table('employee_polices')
->select(' policy_type.long_name as Policy_Name , client_policy.policy_terms as Policy_Terms, client_policy.client_id as ClientId, client_policy.policy_id as PolicyId,client_policy.id as ClientPolicyId, client_policy.open_for_enrollment as OpenForEnrollment,client_policy.disclaimer,client_policy.policy_type_id , employee_polices.tpa_id as tpa_id , employee_polices.rand_string as rand_string') // Select all columns from both tables
->select('
policy_type.long_name as Policy_Name ,
client_policy.policy_terms as Policy_Terms,
client_policy.client_id as ClientId,
client_policy.policy_id as PolicyId,
client_policy.id as ClientPolicyId,
CASE
WHEN client_policy.open_for_enrollment IS NULL THEN 0
ELSE client_policy.open_for_enrollment
END AS OpenForEnrollment,
client_policy.disclaimer,
client_policy.policy_type_id ,
employee_polices.tpa_id as tpa_id ,
employee_polices.rand_string as rand_string
', FALSE) // Select all columns from both tables
->join('client_policy', 'client_policy.id = employee_polices.client_policy_id')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.policy_status', 1)

View File

@ -607,7 +607,8 @@ class PolicyTransactionModel extends Model
policy_type.policy_type,
pt_co_share_details.agreed_amt AS amount,
pt_co_share_details.bp_amt AS bp,
pt_co_share_details.tp_amt AS tp
pt_co_share_details.tp_amt AS tp,
clients.pan
')
->join('pt_co_share_details', 'policy_transaction.id = pt_co_share_details.pt_id', 'left')
->join('clients', 'clients.id = policy_transaction.client_id', 'left')

View File

@ -72,6 +72,8 @@ class TicketMasterModel extends Model
'non_id_reason',
'head_rejection_reason',
'pay_initiate_date',
'emp_personal_mail',
'client_policy_id'
];

View File

@ -63,7 +63,7 @@
if (window.botmanWidget) {
botmanChatWidget.open();
setTimeout(function(){
botmanChatWidget.sayAsBot('Hi '+ emp_name +',This is ILA your Insurance Assistant, plz choose the following options')
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.whisper('Hi');
},3000);

View File

@ -691,7 +691,7 @@
</a>
</li>
<?php if ((get_role_id() == 1 || get_role_id() == 5) && (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()))) { ?>
<?php if ((get_role_id() == 1 || get_role_id() == 5) || (in_array(BUSINESS_TEAM_ID, user_team()) || in_array(FINANCE_TEAM_ID, user_team()) || in_array(MANAGEMENT_TEAM_ID, user_team()))) { ?>
<li>
<a href="#policyTransactions" data-toggle="collapse" class="waves-effect">
@ -702,12 +702,11 @@
<div class="collapse" id="policyTransactions">
<ul class="nav-second-level">
<li>
<a href="#policyTransactions" data-toggle="collapse" class="waves-effect">
<a href="#policyTransactionsSub" data-toggle="collapse" class="waves-effect">
<i class="mdi mdi-format-list-bulleted"></i>
<span>Policy Transactions</span>
</a>
<div class="collapse" id="policyTransactions">
<div class="collapse" id="policyTransactionsSub">
<ul>
<li>
<a href="<?= base_url('/policy_tranction/inception/list') ?>">Policy</a>
@ -720,9 +719,12 @@
<li>
<a href="<?= base_url('/policy_tranction/statement/list') ?>">Statement Upload</a>
</li>
<?php } ?>
</ul>
</div>
</li>
<?php if (in_array(MANAGEMENT_TEAM_ID, user_team())) { ?>
<li>
<a href="#policyReports" data-toggle="collapse" class="waves-effect">
<i class="ri-file-chart-fill"></i>
@ -745,19 +747,20 @@
<li>
<a href="<?= base_url('/bdsReport/renewal_report') ?>">Renewal Reports</a>
</li>
<?php } ?>
</ul>
</div>
</li>
<?php } ?>
<li>
<li>
<a href="#policyMasters" data-toggle="collapse" class="waves-effect">
<a href="#policyPendingActions" data-toggle="collapse" class="waves-effect">
<i class="mdi mdi-timer-sand"></i>
<span> Policy Pending Actions </span>
</a>
<div class="collapse" id="policyReports">
<div class="collapse" id="policyPendingActions">
<ul class="nav-third-level">
<?php if (in_array(FINANCE_TEAM_ID, user_team())) { ?>
<li>
<a href="<?= base_url('/policy_tranction/report/report-finance-list') ?>">Finance Team</a>
</li>
<?php } ?>
@ -766,16 +769,17 @@
<li>
<a href="<?= base_url('/policy_tranction/report/report-business-list') ?>">Business Team</a>
</li>
</li>
<?php } ?>
</ul>
</div>
</li>
<li>
<a href="#policyMasters" data-toggle="collapse" class="waves-effect">
<i class="ri-database-2-line"></i>
<span> Masters </span>
</a>
<div class="collapse" id="policyReports">
<div class="collapse" id="policyMasters">
<ul class="nav-third-level">
<li>
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
@ -788,11 +792,17 @@
</li>
<li>
<a href="<?= base_url('/dmsSearch') ?>"><i class="ri-book-open-line"></i><span> Documents</span></a>
<a href="<?= base_url('/dmsSearch') ?>">
<i class="ri-book-open-line"></i>
<span> Documents</span>
</a>
</li>
</ul>
</div>
</li>
</div>
</li>
<?php } ?>

View File

@ -480,7 +480,7 @@
<input id="policy_end_date" type="text" class="form-control" name="policy_end_date" placeholder="DD/MM/YYYY" >
</div>
<div class="form-group col-md-3">
<div class="form-group col-md-3" id="tpa_div">
<label for="tpa"> TPA <span id="tpa_danger"class="text-danger"></span></label>
<select class="form-control" id="tpa" name="tpa" >
<option value="" selected>Select TPA</option>
@ -1307,6 +1307,12 @@ $(document).ready(function(){
$('#client_type option[value="2"]').show();
}
if(value == 1 || value == 2 || value == 3 || value == 4 || value == 5 || value == 38 || value == 40){
$('#tpa_div').hide();
}else{
$('#tpa_div').show();
}
});
@ -1507,6 +1513,13 @@ function getPolicyTransactionDataForEdit(input) {
$('#tpa').val(tpaValue).change();
let policy_type_id_for_hide_tpa = res.data.master_policy_type_id;
if(policy_type_id_for_hide_tpa == 1 || policy_type_id_for_hide_tpa == 2 || policy_type_id_for_hide_tpa == 3 || policy_type_id_for_hide_tpa == 4 || policy_type_id_for_hide_tpa == 5 || policy_type_id_for_hide_tpa == 38 || policy_type_id_for_hide_tpa == 40){
$('#tpa_div').hide();
}else{
$('#tpa_div').show();
}
if(res.data.client_policy_id != 0 && res.data.client_policy_id != null){
$('#hide_file_upload').show();
}else{
@ -2484,9 +2497,15 @@ function appendOwner(data) {
$.each(data, function(index, item) {
let client_show_name = item.client_name;
if (item.client_type == 2) {
client_show_name = item.client_name + ' - ' + (item.pan ?? 'N/A');
}
var option = $('<option>', {
value: item.id,
text: item.client_name,
text: client_show_name,
});
$('#owner').append(option);
@ -3362,9 +3381,14 @@ $('#client_type').on('change', function() {
$.each(client_list, function(index, item) {
if (item.client_type == selectedClientType) {
let client_show_name = item.client_name;
if (item.client_type == 2) {
client_show_name = item.client_name + ' - ' + (item.pan ?? 'N/A');
}
var option = $('<option>', {
value: item.id,
text: item.client_name,
text: client_show_name,
'data-cn': item.client_name,
'data-ct': item.client_type
});
@ -3418,7 +3442,7 @@ $('#Owner_type').on('change', function() {
var option = $('<option>', {
value: owner.id,
text: (owner.client_name + ' - ' + (owner.pan ?? ''))
text: (owner.client_name + ' - ' + (owner.pan ?? 'N/A'))
});
$('#owner').append(option);
@ -3450,6 +3474,7 @@ $('#policy_status').change(function(){
var client_branch_id = $('#client_branch_id').val();
if(status == 'completed'){
if(pt_id == ''){
removeAllColumnsExceptFirst('insurerTable');
}
@ -3482,6 +3507,12 @@ $('#policy_status').change(function(){
});
}
if(policy_type_id == 1 || policy_type_id == 2 || policy_type_id == 3 || policy_type_id == 4 || policy_type_id == 5 || policy_type_id == 38 || policy_type_id == 40){
$('#tpa_div').hide();
}else{
$('#tpa_div').show();
}
}else{
$('#sales_row').hide()
$('#policy_no').prop('required', false)

View File

@ -302,7 +302,7 @@ table.dataTable tbody td {
<td><?php echo $issuer[$row['issuer']]; ?></td>
<td><?php echo $issuing_type[$row['issue_type']]; ?></td>
<td><?php echo $client_type[$row['client_type']] ?? '-'; ?></td>
<td><?php echo $row['client_type'] == 2 ? $row['client_name'] : $row['client_short_name'] . ' - ' . $row['client_branch_name']; ?></td>
<td><?php echo $row['client_type'] == 2 ? $row['client_name'] . " - " . (!empty($row['pan']) ? $row['pan'] : 'N/A') : $row['client_short_name'] . ' - ' . $row['client_branch_name']; ?></td>
<td><?php echo $row['insurer_short_name']; ?></td>
<td><?php echo $row['policy_type']; ?></td>
<td><?php echo $row['policy_no']; ?></td>
@ -734,17 +734,22 @@ function appendClients(data)
}));
$.each(data, function(index, item) {
let client_show_name = item.client_name;
if (item.client_type == 2) {
client_show_name = item.client_name + ' - ' + (item.pan ?? 'N/A');
}
var option = $('<option>', {
value: item.id,
text: item.client_name,
text: client_show_name,
'data-cn': item.client_name,
'data-ct': item.client_type,
class: (item.client_type == 1) ? 'group' : (item.client_type == 2) ? 'individual' : ''
class: item.client_type == 1 ? 'group' : item.client_type == 2 ? 'individual' : ''
});
$('#client_id').append(option);
});
}
function appendVehicles(data, vehicle_id)

View File

@ -1,3 +1,15 @@
<style>
.select2-selection__choice {
background-color: #0a8794 !important;
color: white !important;
font-weight: bold;
}
.select2-selection__choice__remove {
color: white !important;
margin-right: 5px;
}
</style>
<div class="row">
<div class="col-12">
<div class="card-body">
@ -8,32 +20,93 @@
<div class="form-group col-md-12">
<!-- <label for="ticket_auto_query_note">Add Notes</label> -->
<div class="form-row" id="rac_rate_dropdown">
<div class="form-group col-md-12">
<select id="ticket_mail_auto_query_customButton" class="form-control"
style="border:none;right: 13px;width: auto;position: absolute;z-index: 1;top: -19px;height: 32px;float: right;">
<option value="">Documents</option>
<div class="form-group col-md-9">
<label>Documents</label> <br />
<select class="form-control" name="documents[]" id="ticket_mail_auto_query_customButton" multiple>
<?php foreach ($ticket_check_list as $value): ?>
<option value="<?= $value['document']; ?>"><?= $value['document']; ?></option>
<option value="<?= $value['document']; ?>"
<?php //
// if (!isset($getData) || (isset($getData['documents']) && in_array($value['document'], $getData['documents']))) {
// echo 'selected';
// }
?>>
<?= $value['document']; ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div style="padding-top:30px;padding-left:20px;" class="col-md-3">
<button type="button" class="btn btn-primary" id="insertSelectedDocumnets">Insert Documents</button>
</div>
</div>
<textarea class="form-control" id="ticket_auto_query_note" name="note" rows="3"
placeholder="Enter Text"><?= isset($ticket_note['note']) ? $ticket_note['note'] : '' ?></textarea>
placeholder="Enter Text"></textarea>
</div>
</div>
</div><input type="hidden" id="query_note_id"><input type="hidden" <div
class="form-group text-right m-b-0">
</div><input type="hidden" id="query_note_id">
<div class="form-group text-right">
<button type="submit" class="btn btn-primary" id="ticket_auto_query_submit">Submit</button>
</div>
</form>
</div>
</div> <!-- end col-->
</div> <!-- end col-->
</div>
<!-- end -->
<script>
$(document).ready(function() {
$(document).ready(function() {
// $('#ticket_mail_auto_query_customButton').select2();
$('#ticket_mail_auto_query_customButton').select2({
placeholder: "Select Documents",
allowClear: true,
closeOnSelect: false, // This is the key option to keep the dropdown open
tags: true
});
$("textarea.select2-search__field").attr('rows', '1');
$("textarea.select2-search__field").css('resize', 'none');
const auto_query_editor = Jodit.make("#ticket_auto_query_note", editorConfig);
let lastActiveField = null;
auto_query_editor.events.on("focus", function() {
lastActiveField = auto_query_editor;
});
$("#insertSelectedDocumnets").on("click", function() {
// Get all selected documents
const selectedDocuments = $("#ticket_mail_auto_query_customButton").val();
if (!selectedDocuments || selectedDocuments.length === 0) {
toastr.warning('Please select documents first', 'Warning');
return;
}
if (lastActiveField === auto_query_editor) {
// Insert each document on a new line
selectedDocuments.forEach(document => {
auto_query_editor.selection.insertHTML(document + '<br>');
});
// Clear the selection
$("#ticket_mail_auto_query_customButton").val(null).trigger('change');
} else {
toastr.warning('Please focus on the text area first', 'Warning');
}
});
})
// $("#ticket_mail_auto_query_customButton").change(function (){
// event.stopPropagation();
// })
$(document).ready(function() {
url = '<?= base_url('ticket/note/1') ?>';
data = {
id: $('#ticket_master_id').val(),
@ -44,8 +117,9 @@ $(document).ready(function() {
data: data,
type: 'POST',
success: function(res) {
console.log('auto query res', res)
if (res.status == true) {
$('#ticket_auto_query_note').val(res.data.note);
$('.jodit-wysiwyg').html(res.data.note);
$('#query_note_id').val(res.data.id);
}
},
@ -115,49 +189,5 @@ $(document).ready(function() {
});
});
});
let lastActiveField = null;
$("#ticket_auto_query_note").on("focus", function() {
lastActiveField = this;
});
document.addEventListener('change', function(event) {
var target = event.target;
if (target.matches('#ticket_mail_auto_query_customButton')) {
let placeholderValue = $(target).val();
if (!placeholderValue) return;
if (lastActiveField) {
if (lastActiveField.id === "ticket_auto_query_note") {
insertAtCursor(lastActiveField, placeholderValue);
}
}
$(target).val('');
}
});
function insertAtCursor(input, textToInsert) {
textToInsert += '\n';
if (document.selection) {
input.focus();
var sel = document.selection.createRange();
sel.text = textToInsert;
} else if (input.selectionStart || input.selectionStart === 0) {
let startPos = input.selectionStart;
let endPos = input.selectionEnd;
input.value = input.value.substring(0, startPos) + textToInsert + input.value.substring(endPos, input.value
.length);
input.selectionStart = input.selectionEnd = startPos + textToInsert.length;
} else {
input.value += textToInsert;
}
}
});
</script>

View File

@ -1,3 +1,17 @@
<style>
.readonly-color {
background-color: #e0e0e0;
/* Darker background */
color: #666;
/* Darker text color */
}
.readonly-select {
pointer-events: none;
background-color: #f0f0f0;
color: #666;
}
</style>
<div class="row">
<div class="col-12">
<div class="<?= !isset($ticket_data) ? "card" : "" ?>" style="margin-right: 23px;">
@ -73,9 +87,8 @@
<label for="policy_no">Policy No <span class="text-danger"></span></label>
<input type="text" class="form-control" id="policy_no"
value="<?= isset($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>"
name="policy_no" placeholder="Policy Number" >
name="policy_no" placeholder="Policy Number">
</div>
<div class="form-group col-md-3">
<label for="tpa_id">TPA ID <span class="text-danger"></span></label>
<input type="text" class="form-control" id="tpa_no" placeholder="Enter TPA ID"
@ -97,6 +110,13 @@
name="emp_mail" required>
</div>
<div class="form-group col-md-3">
<label for="emp_personal_mail">Employee Personal Mail ID</label>
<input type="text" class="form-control" id="emp_personal_mail" placeholder="Enter EMP Personal Mail"
value="<?= isset($ticket_data['emp_personal_mail']) ? $ticket_data['emp_personal_mail'] : '' ?>"
name="emp_personal_mail">
</div>
<div class="form-group col-md-3">
<label for="client_name">Corporate Name <span class="text-danger">*</span></label>
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
@ -108,6 +128,20 @@
<input type=hidden id="insurer_id" name="insurer_id" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly required>
</div>
<input type="hidden" id="empIDHidden" onchange="getClientPolicy()">
<div class="col-md-3">
<div class="form-group">
<label>Policy <span class="text-danger">*</span></label>
<select id="emp_client_policy" name="client_policy_id"
class="form-control custom-select" required onchange="setMinDateDOA(this.value)">
<?php if (!empty($ticket_data['client_policy_id'])) { ?>
<option value="<?= $ticket_data['client_policy_id'] ?>"><?= $ticket_data['client_policy_id_text'] ?></option>
<?php } else { ?>
<option value="">Policy</option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group col-md-3">
<label for="tpa_id">TPA <span class="text-danger"></span></label>
@ -343,7 +377,7 @@
</div>
<div class="form-group col-md-3 non_id" style="display: none;">
<label for="non_id_reason">Non ID Reason</label>
<label for="non_id_reason">Non ID Reason <span id="non_id_reason_lable_id" class="text-danger"></span></label>
<select class="form-control" id="non_id_reason" name="non_id_reason">
<option value="">Select Reason</option>
<?php
@ -389,12 +423,23 @@
<script>
let GlobelExtraFields = [];
var doa;
$(document).ready(function() {
$("#emp_client_policy").select2();
var policy_id = $("#emp_client_policy").val();
if (policy_id != null && policy_id != "") {
$("#emp_client_policy").addClass('readonly-select').select2('destroy');
}
// getClientPolicy();
var doa = flatpickr("#doa", {
dateFormat: "d/m/Y",
allowInput: false
allowInput: false,
onChange: function(selectedDates) {
let selectedDOA = selectedDates[0]; // Get selected DOA date
dod.set("minDate", selectedDOA); // Set DOD minDate to DOA
}
});
var dod = flatpickr("#dod", {
@ -576,11 +621,11 @@
var selectedClaimStatus = $('#claim_status_id').val();
var $thirdClass = $(`.${thirdClass}`);
var hasValue = $thirdClass.find('input, textarea, select').filter(function () {
var hasValue = $thirdClass.find('input, textarea, select').filter(function() {
return $(this).val().trim() !== ''; // Check if at least one field is not empty
}).length > 0;
$thirdClass.each(function () {
$thirdClass.each(function() {
var id = $(this).find('[id]').first().attr('id');
var $label = $(this).find('label');
var $thisDiv = $(this);
@ -595,12 +640,12 @@
if ($label.length && !$label.find('.text-danger').length) {
$label.append(' <span class="text-danger">*</span>');
}
console.log("input from if ",$inputs);
console.log("input from if ", $inputs);
// $inputs.attr('required', true);
$('.' + thirdClass).find('input, textarea,select').attr('required', true);
} else {
$label.find('.text-danger').remove();
console.log("input ",$inputs);
console.log("input ", $inputs);
// $inputs.prop('required', false);
$('.' + thirdClass).find('input, textarea,select').attr('required', false);
}
@ -647,46 +692,46 @@
}
});
// function addRequiredFieldSymbol(field_name) {
// // Find the field with the given name
// var $field = $(`[name="${field_name}"]`);
// function addRequiredFieldSymbol(field_name) {
// // Find the field with the given name
// var $field = $(`[name="${field_name}"]`);
// if ($field.length) {
// // Find the parent div of this field
// var $parentDiv = $field.closest('div');
// if ($field.length) {
// // Find the parent div of this field
// var $parentDiv = $field.closest('div');
// if ($parentDiv.length) {
// // Get the classes as an array
// var classes = $parentDiv.attr('class') ? $parentDiv.attr('class').split(/\s+/) : [];
// if ($parentDiv.length) {
// // Get the classes as an array
// var classes = $parentDiv.attr('class') ? $parentDiv.attr('class').split(/\s+/) : [];
// if (classes.length > 0) {
// // Get the last class in the array
// var lastClass = classes[classes.length - 1];
// if (classes.length > 0) {
// // Get the last class in the array
// var lastClass = classes[classes.length - 1];
// // Find all divs with this last class
// var $allDivsWithClass = $(`.${lastClass}`);
// // Find all divs with this last class
// var $allDivsWithClass = $(`.${lastClass}`);
// // Add asterisk to all labels within these divs
// $allDivsWithClass.each(function() {
// var $label = $(this).find('label');
// if ($label.length && !$label.find('.text-danger').length) {
// $label.append(' <span class="text-danger">*</span>');
// }
// });
// // Add asterisk to all labels within these divs
// $allDivsWithClass.each(function() {
// var $label = $(this).find('label');
// if ($label.length && !$label.find('.text-danger').length) {
// $label.append(' <span class="text-danger">*</span>');
// }
// });
// console.log(`Added required symbol to ${$allDivsWithClass.length} labels with class "${lastClass}"`);
// } else {
// console.warn(`Parent div for field "${field_name}" has no classes`);
// }
// } else {
// console.warn(`No parent div found for field name="${field_name}"`);
// }
// } else {
// console.warn(`No field found with name="${field_name}"`);
// }
// }
// console.log(`Added required symbol to ${$allDivsWithClass.length} labels with class "${lastClass}"`);
// } else {
// console.warn(`Parent div for field "${field_name}" has no classes`);
// }
// } else {
// console.warn(`No parent div found for field name="${field_name}"`);
// }
// } else {
// console.warn(`No field found with name="${field_name}"`);
// }
// }
function addRequiredFieldSymbolByClass(className) {
function addRequiredFieldSymbolByClass(className) {
var $divsWithClass = $(`.${className}`);
if ($divsWithClass.length) {
@ -735,21 +780,237 @@ function addRequiredFieldSymbolByClass(className) {
} else {
console.warn(`No divs found with class="${className}"`);
}
}
}
$('#mode_of_intimation').change(function(){
$('#mode_of_intimation').change(function() {
console.log("function called");
var mode_of_intimation = $('#mode_of_intimation').val();
console.log('mode of ',mode_of_intimation);
console.log('mode of ', mode_of_intimation);
if (mode_of_intimation == 2){
if (mode_of_intimation == 2) {
$('#pod_no').attr('required', 'required');
$('#pod_no_label_1_span').text("*");
}else{
} else {
$('#pod_no').removeAttr('required', false);
$('#pod_no_label_1_span').text("");
}
})
});
$("#empIDHidden").change(function() {
console.log("change is detected in hidden branch id");
getClientPolicy();
})
function getClientPolicy() {
console.log("get policy function called");
hiddenData = $("#empIDHidden").val();
hiddenData = JSON.parse(hiddenData);
console.log('employee id ', hiddenData['emp_id']);
data = {
emp_id: hiddenData['emp_id']
}
$.ajax({
url: '<?= base_url("/ticket/getPoliciesbyEmpID") ?>',
type: "POST",
data: data,
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if (res.status == true) {
console.log("data is received2");
policyList = res.policy_data;
// appendClients(res.client_data);
// appendClientsFoerMobileSearch(res.client_data);
appendPolicyDropdown(policyList);
console.log("after function");
} else {
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
//append the clients policy data to the modal
// function appendPolicyDropdown(data) {
// console.log("second function is called : ", data);
// let ticket_type = $('#ticket_type_id').val();
// hiddenData = $("#empIDHidden").val();
// hiddenData = JSON.parse(hiddenData);
// let branch_id = hiddenData['branch_id'];
// let policy_id = hiddenData['policy_id'];
// let searchType = hiddenData['searchType'];
// data = data[branch_id];
// console.log("branch filtered data ", data);
// $('#emp_client_policy').empty();
// $('#emp_client_policy').append($('<option>', {
// value: '',
// text: 'Select Client Policy'
// }));
// $.each(data, function(index, item) {
// // console.log('inside the loop for this time count : ',item);
// console.log("debugging policy type id : ", item.id);
// if (ticket_type == 1) {
// console.log("inside if condition 1");
// if (item.policy_type_id == 2 || item.policy_type_id == 3 || item.policy_type_id == 4 || item
// .policy_type_id == 5) {
// console.log("inside if condition 2");
// if (policy_id == item.id) {
// console.log("inside if condition 3");
// var option = $('<option>', {
// value: item.id,
// text: item.policy_type + '-' + item.policy_no,
// });
// $('#emp_client_policy').append(option).select2();
// if (searchType != null && searchType != "") {
// $('#emp_client_policy').val(item.id).addClass('readonly-select').select2('destroy');
// }
// }
// }
// } else if (ticket_type == 2) {
// if (item.policy_type_id == 1) {
// var option = $('<option>', {
// value: item.id,
// text: item.policy_type + '-' + item.policy_no,
// });
// $('#emp_client_policy').append(option).select2();
// }
// } else if (ticket_type == 3) {
// if (item.policy_type_id == 6) {
// var option = $('<option>', {
// value: item.id,
// text: item.policy_type + '-' + item.policy_no,
// });
// $('#emp_client_policy').append(option).select2();
// }
// } else if (ticket_type == 4) {
// if (item.policy_type == 7) {
// var option = $('<option>', {
// value: item.id,
// text: item.policy_type + '-' + item.policy_no,
// });
// $('#emp_client_policy').append(option).select2();
// }
// }
// });
// console.log("loop is completed");
// setMinDateDOA(policy_id);
// }
function appendPolicyDropdown(data) {
hiddenData = $("#empIDHidden").val();
hiddenData = JSON.parse(hiddenData);
console.log("second function is called : ", data);
let ticket_type = $('#ticket_type_id').val();
$('#emp_client_policy').empty();
$('#emp_client_policy').append($('<option>', {
value: '',
text: 'Select Client Policy'
}));
var policyAppendCount = 0;
$.each(data, function(index, item) {
// console.log(item);
if (ticket_type == 1 && item.policy_type_id != 1) {
$('#emp_client_policy').append($('<option>', {
value: item.client_policy_value,
text: item.client_policy_name
}));
policyAppendCount++;
if (hiddenData['searchType'] != null && hiddenData['searchType'] != "" && hiddenData['policy_id'] != null && hiddenData['policy_id'] != "") {
// $('#emp_client_policy').select2();
$("#emp_client_policy").select2();
$('#emp_client_policy').val(hiddenData['policy_id']).addClass('readonly-select').select2('destroy').trigger("change");
} else {
// $('#emp_client_policy').append($('<option>', {
// value: item.client_policy_value,
// text: item.client_policy_name
// }));
}
}
})
console.log('policy append count ',policyAppendCount);
if (policyAppendCount == 0){
toastr.warning("No Policies found for the Employee","Warning");
}
}
// $('#emp_client_policy').select2();
$("#emp_client_policy").on('change', function() {
console.log("change function called ");
policy_id = $("#emp_client_policy").val();
setMinDateDOA(policy_id);
})
function setMinDateDOA(policy_id) {
console.log("Function set min date called ");
console.log("Existing DOA instance: ", doa);
console.log('sent data ',policy_id);
$.ajax({
url: '<?= base_url("ticket/getPolicyStartDate") ?>',
method: "POST",
data: {
policy_id: policy_id
},
success: function(response) {
console.log("mindate response ", response);
if (response.status) {
let minDate = new Date(response.minDate);
// If doa is not initialized, create the instance
if (!doa) {
console.log("doa not found, initializing");
doa = flatpickr("#doa", {
dateFormat: "d/m/Y",
allowInput: false,
onChange: function(selectedDates) {
let selectedDOA = selectedDates[0]; // Get selected DOA date
dod.set("minDate", selectedDOA); // Set DOD minDate to DOA
},
minDate: minDate
});
var dod = flatpickr("#dod", {
dateFormat: "d/m/Y",
allowInput: false
});
} else {
// If already initialized, just set the minDate
doa.set("minDate", minDate);
}
} else {
console.error(response.message);
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
</script>

View File

@ -68,6 +68,13 @@
name="emp_mail" required>
</div>
<div class="form-group col-md-3">
<label for="emp_personal_mail">Employee Personal Mail ID</label>
<input type="text" class="form-control" id="emp_personal_mail" placeholder="Enter EMP Personal Mail"
value="<?= isset($ticket_data['emp_personal_mail']) ? $ticket_data['emp_personal_mail'] : '' ?>"
name="emp_personal_mail">
</div>
<div class="form-group col-md-3">
<label for="policy_no">Policy No <span class="text-danger"></span></label>
<input type="text" class="form-control" id="policy_no"
@ -86,6 +93,23 @@
<input type=hidden id="insurer_id" name="insurer_id" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly required>
</div>
<input type="hidden" id="empIDHidden" onchange="getClientPolicy()">
<div class="col-md-3">
<div class="form-group">
<label>Policy <span class="text-danger">*</span></label>
<select id="emp_client_policy" name="client_policy_id"
class="form-control custom-select" required onchange="setDateValidation(this.value,true)"
<?= isset($ticket_data['client_policy_id'])?" class = 'readonly-select'":'' ?>
>
<?php if (!empty($ticket_data['client_policy_id'])) { ?>
<option value="<?= $ticket_data['client_policy_id'] ?>"><?= $ticket_data['client_policy_id_text'] ?></option>
<?php } else { ?>
<option value="">Select Policy</option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group col-md-3">
<label for="acm_id">Account Manager <span class="text-danger">*</span></label>
@ -293,14 +317,22 @@
<script>
let GlobelExtraFields = [];
var date_of_join;
var dob;
var date_of_accident;
var date_of_death;
var date_of_intimat;
$(document).ready(function() {
var date_of_join = flatpickr("#date_of_join", {
$("#emp_client_policy").select2();
date_of_join = flatpickr("#date_of_join", {
dateFormat: "d/m/Y",
allowInput: false
});
var dob = flatpickr("#dob", {
dob = flatpickr("#dob", {
dateFormat: "d/m/Y",
allowInput: false
});
@ -310,17 +342,22 @@
allowInput: false
});
var date_of_accident = flatpickr("#date_of_accident", {
date_of_accident = flatpickr("#date_of_accident", {
dateFormat: "d/m/Y",
allowInput: false,
onChange: function(selectedDates) {
let selectedDOA = selectedDates[0]; // Get selected DOA date
date_of_death.set("minDate", selectedDOA); // Set DOD minDate to DOA
date_of_intimat.set("minDate",selectedDOA);
}
});
date_of_death = flatpickr("#date_of_death", {
dateFormat: "d/m/Y",
allowInput: false
});
var date_of_death = flatpickr("#date_of_death", {
dateFormat: "d/m/Y",
allowInput: false
});
var date_of_intimat = flatpickr("#date_of_intimat", {
date_of_intimat = flatpickr("#date_of_intimat", {
dateFormat: "d/m/Y",
allowInput: false
});
@ -425,7 +462,7 @@
var hasValue = $thirdClass.find('input, textarea, select').filter(function() {
return $(this).val().trim() !== ''; // Check if at least one field is not empty
}).length > 0;
console.log ("has value ",hasValue);
console.log("has value ", hasValue);
$thirdClass.each(function() {
var id = $(this).find('[id]').first().attr('id');
var $label = $(this).find('label');
@ -435,7 +472,7 @@
// ✅ Condition 1: Check if this ID is in extraFieldsArray (required by status)
var shouldAddRequired = extrafieldsArray[selectedClaimStatus] && extrafieldsArray[selectedClaimStatus].includes(id);
console.log ("shouldAddRequired ",shouldAddRequired);
console.log("shouldAddRequired ", shouldAddRequired);
// ✅ Condition 2: If any field in the class has a value, make all required
if (shouldAddRequired || hasValue) {
@ -546,4 +583,194 @@
// console.warn(`No divs found with class="${className}"`);
// }
// }
$("#empIDHidden").change(function() {
console.log("change is detected in hidden branch id");
getClientPolicy();
})
var employeeId = "";
function getClientPolicy() {
console.log("get policy function called");
hiddenData = $("#empIDHidden").val();
hiddenData = JSON.parse(hiddenData);
console.log('employee id ', hiddenData['emp_id']);
employeeId = hiddenData['emp_id'];
data = {
emp_id: hiddenData['emp_id']
}
$.ajax({
url: '<?= base_url("/ticket/getPoliciesbyEmpID") ?>',
type: "POST",
data: data,
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if (res.status == true) {
console.log("data is received2");
policyList = res.policy_data;
// appendClients(res.client_data);
// appendClientsFoerMobileSearch(res.client_data);
appendPolicyDropdown(policyList);
console.log("after function");
} else {
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
function appendPolicyDropdown(data) {
// var ticket_type = $('#ticket_type').val();
hiddenData = $("#empIDHidden").val();
hiddenData = JSON.parse(hiddenData);
console.log("second function is called : ", data);
let ticket_type = $('#ticket_type_id').val();
$('#emp_client_policy').empty();
$('#emp_client_policy').append($('<option>', {
value: '',
text: 'Select Client Policy'
}));
var policyAppendCount = 0;
$.each(data, function(index, item) {
// console.log(item);
if (ticket_type != 1 && item.policy_type_id != 2) {
$('#emp_client_policy').append($('<option>', {
value: item.client_policy_value,
text: item.client_policy_name
}));
policyAppendCount++;
if (hiddenData['searchType'] != null && hiddenData['searchType'] != "" && hiddenData['policy_id'] != null && hiddenData['policy_id'] != "") {
// $('#emp_client_policy').select2();
$("#emp_client_policy").select2();
$('#emp_client_policy').val(hiddenData['policy_id']).addClass('readonly-select').select2('destroy').trigger("change");
} else {
// $('#emp_client_policy').append($('<option>', {
// value: item.client_policy_value,
// text: item.client_policy_name
// }));
}
}
})
if (policyAppendCount == 0) {
toastr.warning("No Policies found for the Employee", "Warning");
}
}
// $('#emp_client_policy').select2();
$("#emp_client_policy").on('change', function() {
console.log("change function called ");
policy_id = $("#emp_client_policy").val();
// setMinDateDOA(policy_id);
setDateValidation(policy_id, true);
})
function setDateValidation(policy_id, memberset = null) {
$.ajax({
url: '<?= base_url("ticket/getPolicyStartDate") ?>',
method: "POST",
data: {
policy_id: policy_id,
employeeId: employeeId ?? null
},
success: function(response) {
console.log(response);
if (response.status) {
if (memberset) {
var dobValue = response.empData[0].dob;
var doj = response.empData[0].doj;
console.log('data received fro controller ', dob, doj);
if (dobValue) {
$("#dob").val(dobValue);
$("#dob").addClass('readonly-select');
}
if (doj) {
$("#date_of_join").val(doj);
$("#date_of_join").addClass('readonly-select');
}
}else{
if ($("#dob").hasClass('readonly-select')){
$("#dob").removeClass('readonly-select')
$("#dob").val("");
}
if ($("#date_of_join").hasClass('readonly-select')){
$("#date_of_join").removeClass('readonly-select')
$("#date_of_join").val("");
}
}
if (response.minDate) {
// var formatMinDate = response.minDate;
var formatMinDate = new Date(response.minDate);
date_of_accident.set("minDate", formatMinDate)
date_of_death.set("minDate", formatMinDate)
date_of_intimat.set("minDate", formatMinDate)
}
} else {
console.error(response.message);
}
}
});
}
// function setMinDateDOA(policy_id) {
// console.log("Function set min date called ");
// console.log("Existing DOA instance: ", doa);
// $.ajax({
// url: '<?= base_url("ticket/getPolicyStartDate") ?>',
// method: "POST",
// data: {
// policy_id: policy_id
// },
// success: function(response) {
// console.log("mindate response ", response);
// if (response.status) {
// let minDate = new Date(response.minDate);
// // If doa is not initialized, create the instance
// if (!doa) {
// console.log("doa not found, initializing");
// doa = flatpickr("#doa", {
// dateFormat: "d/m/Y",
// allowInput: false,
// onChange: function(selectedDates) {
// let selectedDOA = selectedDates[0]; // Get selected DOA date
// dod.set("minDate", selectedDOA); // Set DOD minDate to DOA
// },
// minDate: minDate
// });
// var dod = flatpickr("#dod", {
// dateFormat: "d/m/Y",
// allowInput: false
// });
// } else {
// // If already initialized, just set the minDate
// doa.set("minDate", minDate);
// }
// } else {
// console.error(response.message);
// }
// },
// error: function(xhr, status, error) {
// console.error(xhr.responseText);
// console.error(status, error);
// }
// });
// }
</script>

View File

@ -1,9 +1,9 @@
<style>
.accordion {
.accordion {
margin-bottom: 1rem;
}
}
.accordion h4 {
.accordion h4 {
font-weight: bold;
cursor: pointer;
display: flex;
@ -17,33 +17,33 @@
padding-top: 3px;
padding-bottom: 3px;
padding-right: 12px;
}
}
.accordion-content {
.accordion-content {
display: none;
padding: 10px;
background-color: #bfe0e2;
margin-top: 5px;
border-radius: 7px;
margin: 5px;
}
}
.accordion-content.show {
.accordion-content.show {
display: block;
}
}
.arrow {
.arrow {
transition: transform 0.2s;
}
}
.arrow.rotate {
.arrow.rotate {
transform: rotate(90deg);
}
}
</style>
<?php
if(!isset($view_ticket_page)){
if (!isset($view_ticket_page)) {
if ($selected_ticket_type == 1) {
include('ticket_form_gmc.php');
} else {
@ -204,11 +204,11 @@ if(!isset($view_ticket_page)){
</div>
<script>
var client_list = ''; // local variable for storing the client branch list
var branch_list = ''; // local variable for storing the client branch list
var policy_list = ''; // local variable for storing the client policy list
var client_list = ''; // local variable for storing the client branch list
var branch_list = ''; // local variable for storing the client branch list
var policy_list = ''; // local variable for storing the client policy list
$(document).ready(function() {
$(document).ready(function() {
getClientAndBranchAndPolicy();
$('#emp_client_data_list').select2();
$('#emp_client_branch_data_list').select2();
@ -217,10 +217,10 @@ $(document).ready(function() {
$('#search_by_client_employee').select2();
$('#employee_by_number').select2();
$('#member_by_number').select2();
})
})
//on change functions
$(document).ready(function() {
//on change functions
$(document).ready(function() {
$('#emp_client_data_list').change(function() {
@ -247,14 +247,15 @@ $(document).ready(function() {
if (policy_list != '') {
// console.log(branch_list[client_id]);
let data = policy_list[branch_id];
console.log(data);
appendPolicy(data);
}
})
})
})
function toggleAccordion(id) {
function toggleAccordion(id) {
const content = document.getElementById(id);
const arrow = document.querySelector(`#${id === 'mobileAccordion' ? 'mobileArrow' : 'clientBranchArrow'}`);
@ -275,16 +276,16 @@ function toggleAccordion(id) {
content.classList.add('show');
arrow.classList.add('rotate');
}
}
}
function openFetchEmpDataodal() {
function openFetchEmpDataodal() {
var myModal = new bootstrap.Modal(document.getElementById('empDetailsModal'));
myModal.show();
}
}
//get client , branch, policy data
function getClientAndBranchAndPolicy() {
//get client , branch, policy data
function getClientAndBranchAndPolicy() {
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
@ -308,10 +309,10 @@ function getClientAndBranchAndPolicy() {
console.error(status, error);
}
});
}
}
//append the clients data to the modal
function appendClients(data) {
//append the clients data to the modal
function appendClients(data) {
$('#emp_client_data_list').empty();
$('#emp_client_data_list').append($('<option>', {
@ -329,10 +330,10 @@ function appendClients(data) {
$('#emp_client_data_list').append(option).select2();
});
}
}
//append the clients data for mobile search to the modal
function appendClientsForMobileSearch(data) {
//append the clients data for mobile search to the modal
function appendClientsForMobileSearch(data) {
$('#mobile_emp_client_data_list').empty();
$('#mobile_emp_client_data_list').append($('<option>', {
@ -349,10 +350,10 @@ function appendClientsForMobileSearch(data) {
$('#mobile_emp_client_data_list').append(option).select2();
});
}
}
//append the clients branch data to the modal
function appendBranch(data) {
//append the clients branch data to the modal
function appendBranch(data) {
$('#emp_client_branch_data_list').empty();
$('#emp_client_branch_data_list').append($('<option>', {
@ -370,11 +371,12 @@ function appendBranch(data) {
$('#emp_client_branch_data_list').append(option).select2();
});
}
}
//append the clients policy data to the modal
function appendPolicy(data) {
//append the clients policy data to the modal
function appendPolicy(data) {
console.log("function called appendPOlicy : ", data);
let ticket_type = $('#ticket_type_id').val();
$('#emp_client_policy_data_list').empty();
@ -386,9 +388,10 @@ function appendPolicy(data) {
$.each(data, function(index, item) {
if (ticket_type == 1) {
console.log("inside if 1");
if (item.policy_type_id == 2 || item.policy_type_id == 3 || item.policy_type_id == 4 || item
.policy_type_id == 5) {
console.log("inside if 2");
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
@ -398,8 +401,9 @@ function appendPolicy(data) {
}
} else if (ticket_type == 2) {
console.log("inside if 3");
if (item.policy_type_id == 1) {
console.log("inside if 4");
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
@ -430,13 +434,15 @@ function appendPolicy(data) {
$('#emp_client_policy_data_list').append(option).select2();
}
} else {
console.log("inside else condition");
}
});
}
}
function submitClaimForm(event, form) {
function submitClaimForm(event, form) {
event.preventDefault();
@ -476,6 +482,8 @@ function submitClaimForm(event, form) {
} else {
toastr.error(response.message, 'ERROR');
}
window.location.href = '<?= base_url('ticket/list') ?>';
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
@ -486,9 +494,9 @@ function submitClaimForm(event, form) {
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
}
function getEmpData(input) {
function getEmpData(input) {
console.log(input)
let param = $(input).val();
@ -511,6 +519,7 @@ function getEmpData(input) {
console.log(response.message, 'SUCCESS');
appendEmployee(response.data, 'search_by_client_employee');
setClientAndInsurerData(response.dataForClientAndInsurer);
setClientPolicyData(input);
} else {
toastr.warning(response.message, 'WARNING');
}
@ -528,11 +537,11 @@ function getEmpData(input) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
}
function getTheEmpDataForClaimSearchByMobile(input, searchType = null) {
function getTheEmpDataForClaimSearchByMobile(input, searchType = null) {
console.log(input)
console.log(input);
let type = $('#employee_data_points').val()
let param = $('#emp_mobile_number_for_claim').val()
let client_policy_id = $('#emp_client_policy_data_list').val()
@ -570,12 +579,17 @@ function getTheEmpDataForClaimSearchByMobile(input, searchType = null) {
} else {
appendMember(response.memberData, 'member_by_number');
}
// if (response.data.emp_id == null || response.data.emp_id == ''){
unSetClientPolicy();
// }
setClientAndInsurerData(response.data);
setClientBranchPolicy(response.data.emp_id, searchType ?? null, response.data.policy_id ?? null);
appendACMS(response.acms)
} else {
toastr.warning(response.message, 'WARNING');
appendACMS(response.acms);
unSetClientPolicy();
unSetClientAndInsurerData()
}
@ -591,9 +605,27 @@ function getTheEmpDataForClaimSearchByMobile(input, searchType = null) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
}
function appendEmployee(data, attrId) {
function setClientBranchPolicy(emp_id, searchType = null, policy_id = null) {
data = {
// branch_id : branch_id,
// policy_id : policy_id,
emp_id: emp_id,
searchType: searchType ?? null,
policy_id: policy_id ?? null
}
data = JSON.stringify(data);
console.log("set client branch function is called : ", data);
console.log("hidden input value before is ", $("#empIDHidden").val());
$("#empIDHidden").val(data).trigger('change');;
console.log("hidden input value after is ", $("#empIDHidden").val());
}
function appendEmployee(data, attrId) {
console.log('data', data)
@ -613,9 +645,9 @@ function appendEmployee(data, attrId) {
$('#' + attrId).append(option).select2();
});
}
}
function appendMember(data, attrId) {
function appendMember(data, attrId) {
console.log('data', data);
@ -656,9 +688,9 @@ function appendMember(data, attrId) {
// Reinitialize select2
$('#' + attrId).select2();
}
}
function appendACMS(data) {
function appendACMS(data) {
console.log(data);
@ -678,16 +710,39 @@ function appendACMS(data) {
$('#acm_id').append(option);
});
}
}
function onlyNumbers(event) {
function onlyNumbers(event) {
var charcode;
charcode = event.which || event.keyCode;
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
return false;
}
}
function setClientAndInsurerData(data) {
function setClientPolicyData(input) {
// console.log('policy_value ',input);
var selectedValue = $(input).val(); // Get selected value
var selectedText = $(input).find(":selected").text();
console.log('Selected value ', selectedValue, " selected text ", selectedText);
var targetDropdown = $("#emp_client_policy");
targetDropdown.select2();
targetDropdown.empty();
targetDropdown.append(new Option(selectedText, selectedValue));
targetDropdown.addClass('readonly-select ').select2('destroy');
let ticket_type = $('#ticket_type_id').val();
if (ticket_type == 1) {
setMinDateDOA(selectedValue);
}else{
setDateValidation(selectedValue,false);
}
// targetDropdown.attr("readonly");
}
function setClientAndInsurerData(data) {
$('#insurer_id').val(data.insurer_id);
$('#insurer_name').val(data.insurer_name);
@ -701,9 +756,38 @@ function setClientAndInsurerData(data) {
$('#emp_name').val(data.emp_name);
$('#emp_mobile').val(data.emp_mobile);
$('#emp_mail').val(data.emp_email);
}
}
function unSetClientAndInsurerData() {
function unSetClientPolicy() {
var targetDropdown = $("#emp_client_policy");
if (targetDropdown.hasClass("readonly-select")) {
console.log("Class exists, removing...");
targetDropdown.removeClass("readonly-select");
targetDropdown.select2();
} else {
console.log("Class not found.");
}
var targetDropdown2 = $("#doa");
if (targetDropdown2.hasClass("readonly-select")) {
console.log("Class exists, removing...");
targetDropdown2.removeClass("readonly-select");
// targetDropdown.select2();
} else {
console.log("Class not found.");
}
var targetDropdown3 = $("#date_of_joininig");
if (targetDropdown3.hasClass("readonly-select")) {
console.log("Class exists, removing...");
targetDropdown3.removeClass("readonly-select");
// targetDropdown.select2();
} else {
console.log("Class not found.");
}
}
function unSetClientAndInsurerData() {
$('#insurer_id').val("");
$('#insurer_name').val("");
@ -717,9 +801,9 @@ function unSetClientAndInsurerData() {
$('#emp_name').val("");
$('#emp_mobile').val("");
$('#emp_mail').val("");
}
}
function setMemberData(input) {
function setMemberData(input) {
var selectedOption = $(input).find(':selected');
@ -742,31 +826,31 @@ function setMemberData(input) {
});
if (tpaNo == "") {
$('#claim_status_id').val(1)
$('#non_id_reason').attr('required', true);
var $label = $("label[for='non_id_reason']");
if ($label.length && !$label.find('.text-danger').length) {
$label.append(' <span class="text-danger">*</span>');
}
var $label = $("#non_id_reason_lable_id");
$label.text('*');
} else {
$('#claim_status_id').val(2)
$('#non_id_reason').attr('required', false);
var $label = $("label[for='non_id_reason']");
var $label = $("#non_id_reason_lable_id");
$label.text("");
}
}
// $('#employee_data_points').on('change', function() {
// $('#employee_data_points').on('change', function() {
// let value = $(this).val()
// if (value == "mobile") {
// $('#employee_data_points_label').text('Employee Mobile Number')
// } else {
// $('#employee_data_points_label').text('Employee ID')
// }
// })
// let value = $(this).val()
// if (value == "mobile") {
// $('#employee_data_points_label').text('Employee Mobile Number')
// } else {
// $('#employee_data_points_label').text('Employee ID')
// }
// })
$('#employee_data_points').on('change', function() {
$('#employee_data_points').on('change', function() {
let value = $(this).val();
let $label = $('#employee_data_points_label');
let $input = $('#emp_mobile_number_for_claim');
@ -778,10 +862,10 @@ $('#employee_data_points').on('change', function() {
$label.text('Employee ID');
$input.removeAttr('onkeypress maxlength');
}
});
});
function toResetTheModelFields() {
function toResetTheModelFields() {
$('#emp_mobile_number_for_claim').val('');
$('#employee_data_points').val();
@ -793,4 +877,15 @@ function toResetTheModelFields() {
$('#search_by_client_employee').val('0').select2();
$('#search_by_client_member').val('0').select2();
}
$('#tpa_no').on('input', function() {
let tpaNo = $(this).val().trim();
console.log('tpaNo:', tpaNo);
let isEmpty = tpaNo === "";
$('#claim_status_id').val(isEmpty ? 1 : 2);
$('#non_id_reason').prop('required', isEmpty);
$('#non_id_reason_lable_id').text(isEmpty ? '*' : '');
});
</script>

View File

@ -47,8 +47,33 @@
</div>
<script>
var toolbar = "bold,italic,strikethrough,|,superscript,subscript,|,align,";
const editorConfig = {
buttons: toolbar.concat(['fontsize']),
fontsize: [8, 10, 12, 14, 16, 18, 20, 22, 24], // Customize font sizes
showPlaceholder: false,
toolbarButtonSize: 'small',
toolbarAdaptive: false,
saveHeightInStorage: true,
minHeight: 400,
extraButtons: [
{
name: 'info',
iconURL: '<?= base_url()."public"; ?>/assets/images/image-solid.svg', // Replace with the actual icon URL
exec: function (editor) {
const fileInput = document.getElementById("Question_title_fileInput");
fileInput.click();
},
},
],
};
$(document).ready(function() {
var toolbar = "bold,italic,strikethrough,|,superscript,subscript,|,align,";
const editorConfig = {
buttons: toolbar.concat(['fontsize']),
fontsize: [8, 10, 12, 14, 16, 18, 20, 22, 24], // Customize font sizes
@ -75,8 +100,8 @@ $(document).ready(function() {
let lastActiveField = null;
// Track last active input field
$("#mail_subject").on("focus", function() {
// Track last active input field
$("#mail_subject").on("focus", function() {
lastActiveField = this;
});
@ -85,7 +110,7 @@ $("#mail_subject").on("focus", function() {
lastActiveField = editor;
});
document.addEventListener('change', function(event) {
document.addEventListener('change', function(event) {
var target = event.target;
if (target.matches('#ticket_mail_customButton')) {
let placeholderValue = $(target).val();
@ -176,6 +201,7 @@ document.addEventListener('change', function(event) {
});
});
</script>
<script>
function reloadTicket_conversation() {

View File

@ -13,7 +13,8 @@
word-wrap: break-word;
}
th,td {
th,
td {
font-size: smaller !important;
}
@ -28,13 +29,13 @@
th:nth-child(1),
td:nth-child(1) {
width: 150px;
width: 110px;
/* Adjust first column width */
}
th:nth-child(2),
td:nth-child(2) {
width: 550px;
width: 720px;
/* Adjust first column width */
}
@ -921,7 +922,7 @@
}
],
"public_liability": [{
table_type: "append",
table_type: "new",
table_name: "Public Liability Coverage",
table_id: "public_liability_addOnCoverage",
table_editable: true,
@ -1897,9 +1898,101 @@
element.appendChild(icon);
}
$('#saveRFQ').click( () => saveRFQ());
$('#saveRFQ').click(() => saveRFQ());
// $("#saveRFQ").click(function (){
// console.log("Hello the save req button is clicked");
// })
function saveRFQ(){
console.log("save rfq clicked");
function saveRFQ() {
const rfqData = {
table_data: {
headers: [],
data: []
}
};
// Get all tables
const tables = document.querySelectorAll('table');
if (tables.length === 0) return;
// Extract headers from the first table
const headerRow1 = tables[0].querySelector('thead tr:first-child');
const headerRow2 = tables[0].querySelector('thead tr:last-child');
const headers = [];
headerRow1.querySelectorAll('th').forEach((th, index) => {
const parentHeader = th.textContent.trim();
const subHeaders = [];
const subHeaderTh = headerRow2.children[index];
if (subHeaderTh) {
subHeaders.push(subHeaderTh.textContent.trim());
}
headers.push({
parentHeader,
subHeaders
});
});
rfqData.table_data.headers = headers;
// Process all tables
tables.forEach(table => {
const rows = table.querySelectorAll('tbody tr');
rows.forEach(row => {
const cells = row.querySelectorAll('td');
const rowData = {
SNO: '',
items: '',
data: []
};
// Extract SNO (first cell)
if (cells[0]) {
rowData.SNO = cells[0].textContent.replace(/\D/g, '') || '1';
}
// Extract items (row ID)
rowData.items = row.id || '';
// Process each cell
cells.forEach((cell, cellIndex) => {
const header = headers[cellIndex];
if (!header) return;
const parentHeader = header.parentHeader;
const subHeader = header.subHeaders[0] || '-';
// Get displayed value
const value = cell.textContent.trim();
// Get input value (hidden field or checkbox state)
let inputValue = value;
const hiddenInput = cell.querySelector('input[type="hidden"]');
if (hiddenInput) {
inputValue = hiddenInput.value;
}
// Handle Action column checkboxes
if (parentHeader === 'Action') {
const qcrChecked = cell.querySelector('.qcr-checkbox')?.checked ?? false;
const clientChecked = cell.querySelector('.client-checkbox')?.checked ?? false;
inputValue = {
qcr: qcrChecked ? 1 : 0,
stc: clientChecked ? 1 : 0
};
}
rowData.data.push({
parentth: parentHeader,
subth: subHeader,
value,
input_value: inputValue
});
});
rfqData.table_data.data.push(rowData);
});
});
console.log(JSON.stringify(rfqData, null, 2));
}
</script>