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

This commit is contained in:
VENKATESHWARAN 2025-02-17 09:10:30 +05:30
commit 74fb6eb556
12 changed files with 1984 additions and 1017 deletions

View File

@ -161,6 +161,7 @@ $routes->group("/employee", ["filter" => "authMVC"], function ($routes) {
$routes->get("test-rack-rate", "EmployeeController::testRackRate");
$routes->post("test-rack-rate", "EmployeeController::testRackRate");
$routes->get('test_members_list', 'EmployeeController::test_members_list');
$routes->post('get_emp_history','EmployeeController::getEmpHistory');
});
$routes->group("/master", ["filter" => "authMVC"], function ($routes) {

View File

@ -27,7 +27,7 @@ class ReimbursementClaimStatusConversation extends Conversation
$this->bot->types();
if ($data){
$this->say("The claim status for the claim Number {$data['claim_number']} is currently in {$data['claim_status']} status. <br> More Detailed Information is sent to your mail");
$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");
$this->bot->startConversation(new doYouWantToContinueConversation());
}else{
$this->say("No Claim Raised against the user.");

View File

@ -676,13 +676,15 @@ class ClientController extends AdminController
$client_id = $this->request->getPost('client_id');
$insurer_id = $this->request->getPost('insurer_id');
$record_date = $this->request->getPost('record_date');
$CD_Account_Number = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id)
->first();
// Prepare the array with data
$date = \DateTime::createFromFormat('d/m/Y', $record_date);
$record_date = $date->format('Y-m-d');
$data = [
'amount' => $this->request->getPost('amount'),
'sub_type_id' => $this->request->getPost('sub_type_id'),
@ -694,7 +696,10 @@ class ClientController extends AdminController
'description' => $this->request->getPost('description'),
'transaction_type' => $this->request->getPost('transaction_type') ?: 'Credit',
'updated_by' => 1,
'record_date' => $record_date
];
// log_message('error','data for insert'.json_encode($data));die();
// print_rr($data);die();
// Call the saveDeposit function from DepositHelper

View File

@ -25,6 +25,7 @@ use App\Models\InsurerExcelExportTemplateModel;
use App\Models\InsurerModel;
use App\Models\ClientDepositModel;
use App\Models\PolicyPremium2Model;
use App\Models\AuditHistoryModel;
use App\Controllers\Jobs;
@ -64,6 +65,7 @@ class EmployeeController extends AdminController
protected $insurerModel;
protected $cashDepositModel;
protected $PolicyPremium2Model;
protected $auditHistory;
public function __construct()
{
@ -84,6 +86,7 @@ class EmployeeController extends AdminController
$this->insurerModel = new InsurerModel();
$this->cashDepositModel = new ClientDepositModel();
$this->PolicyPremium2Model = new PolicyPremium2Model();
$this->auditHistory = new AuditHistoryModel();
}
public function list()
@ -2725,4 +2728,18 @@ class EmployeeController extends AdminController
}
}
public function getEmpHistory(){
$emp_id = $this->request->getPost('emp_id');
$data['emp_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_id)->where('table_name','employees')->findAll();
$emp_pol_pk = $this->employeePolicyModel->select('id')->where('employee_id',$emp_id)->first()['id'];
$data['emp_pol_history'] = $this->auditHistory->select('field_name,old_value,new_value,created_by,created_at')->where('pk',$emp_pol_pk)->where('table_name','employee_polices')->findAll();
return $this->respond(['status' => true, 'data' => $data],200);
}
}

View File

@ -66,6 +66,9 @@ class LeadsController extends BaseController
protected $clientType;
protected $leadType;
protected $leadsStatus;
protected $claim_type_for_gpa;
protected $cause_of_death;
public function __construct()
{
@ -98,6 +101,19 @@ class LeadsController extends BaseController
'completed_with_corrections' => 'Completed with Corrections',
'completed_without_corrections' => 'Completed w/o Corrections',
];
$this->claim_type_for_gpa = [
'accident_death' => 'Accident Death',
'permanent_total_disablement' => 'Permanent Total Disablement',
'permanent_partial_disablement' => 'Permanent Partial Disablement',
'temporary_total_disablement_benefit' => 'Temporary Total Disablement benefit'
];
$this->cause_of_death = [
'natural_death' => 'Natural Death',
'suicide' => 'Suicide',
'accident' => 'Accident'
];
}
public function viewLeadsList()
@ -125,7 +141,7 @@ class LeadsController extends BaseController
// Fetch insurer and TPA branch data
$data['insurer'] = $this->insurerBranchModel->getInsurerBranchesWithInsurerNames();
$data['tpa'] = $this->tpaBranchModel->getTpaBranchesWithTpaNames();
// print_r($data['tpa']);die();
// Fetch sales team members who are active in team 5
$data['salse_team'] = $this->userModel
->select('user_profiles.*')
@ -136,7 +152,10 @@ class LeadsController extends BaseController
->findAll();
// dd($data);
$data['lastFiveYears'] = $this->getLastFiveFinancialYears();
$data['gpaClaimType'] = $this->claim_type_for_gpa;
$data['causeOfDeath'] = $this->cause_of_death;
// dd($lastFiveYears);
if ($this->request->is('get')) {
// Fetch leads data
$data ['lead_data_list'] = $this->leadsModel->getLeadDataForLising();
@ -272,7 +291,18 @@ class LeadsController extends BaseController
$last_3_years_claims = null;
if($value != 2){
$last_3_years_claims = $data['finyear'];
$last_3_years_claims = [];
$finyear = json_decode($data['finyear']);
foreach ($finyear as $year){
$received_policy_type = ($year->finyear[0]->policy_type);
if ($value == $received_policy_type){
array_push($last_3_years_claims,$year);
}else{
continue;
}
}
$last_3_years_claims = json_encode($last_3_years_claims);
}
$processedData[] = [
@ -340,7 +370,7 @@ class LeadsController extends BaseController
'notes' => $data['notes'] ?? null,
];
}
// print_r($processedData);die();
return $processedData;
}
@ -2329,4 +2359,26 @@ class LeadsController extends BaseController
}
}
function getLastFiveFinancialYears() {
$currentYear = date('Y');
$currentMonth = date('m');
// In India, the financial year starts from April (04)
if ($currentMonth < 4) {
$currentYear--; // Adjust year if it's Jan-Mar
}
$financialYears = [];
for ($i = 0; $i < 5; $i++) {
$startYear = $currentYear - $i - 1;
$endYear = $currentYear - $i;
$financialYears[] = "$startYear-$endYear";
}
return $financialYears;
}
}

View File

@ -224,13 +224,22 @@ class ChatbotHelper
}
public static function getReimbursementClaimStatus($chat_session_info){
$client_claim_status = [
'Received' => [1,2,3,4],
'Under Process' => [5,6,7,10],
'Finished' => [9,11,12],
'Rejected' => [8],
'Cancelled' => [13,14]
];
$emp_id = $chat_session_info['emp_id'];
log_message('error','emp_id'.$emp_id);
$emp_code = $chat_session_info['emp_code'];
$client_id = $chat_session_info['client_id'];
$client_branch_id = $chat_session_info['client_branch_id'];
$ticketMaster = new TicketMasterModel();
$data = $ticketMaster->select('tcs.claim_status,ticket_master.claim_number,ticket_master.id')
$data = $ticketMaster->select('tcs.id as tcs_id,tcs.claim_status,ticket_master.claim_number,ticket_master.id,ticket_master.emp_name,ticket_master.emp_mail')
// ->join('client_policy cp',"cp.client_id = {$client_id} and cp.client_branch_id = {$client_branch_id} and cp.policy_id = {$policy_id} and cp.is_active = 1")
->join('ticket_claim_status tcs',"ticket_master.claim_status_id = tcs.id and tcs.is_active = 1")
->where('ticket_master.emp_id',$emp_id)
@ -238,14 +247,38 @@ class ChatbotHelper
->where('ticket_master.is_active',1)
->orderBy('ticket_master.created_at', 'DESC')
->first();
$server_claim_status = $data['tcs_id'];
$matched_key = null;
foreach ($client_claim_status as $key => $statuses) {
if (in_array($server_claim_status, $statuses)) {
$matched_key = $key;
break; // Stop loop once found
}
}
log_message('error','Data from ticket master'.json_encode($data));
// print_r($data);
// die();
$ticket_controller = new TicketController();
if (!empty($data)){
if (!empty($data) && !empty($matched_key)){
$ticket_id = $data['id'];
$mail_content = $ticket_controller->constructMailContent($ticket_id);
$mail_response = $ticket_controller->sendTrigger($mail_content);
return $data;
$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]);
$res = json_decode($res);
log_message('error','res: '.json_encode($res));
if($res->status == 'success')
{
$data['client_status'] = $matched_key;
return $data;
}
else
{
return false;
}
}else{
return false;
@ -253,6 +286,283 @@ class ChatbotHelper
}
public static function ReimbursementStatusMailTemplate($emp_name, $claim_number, $client_status) {
$template = '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<!--[if gte mso 9]>
<xml>
<o:OfficeDocumentSettings>
<o:AllowPNG/>
<o:PixelsPerInch>96</o:PixelsPerInch>
</o:OfficeDocumentSettings>
</xml>
<![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="x-apple-disable-message-reformatting">
<!--[if !mso]><!-->
<meta http-equiv="X-UA-Compatible" content="IE=edge"><!--<![endif]-->
<title></title>
<style type="text/css">
@media only screen and (min-width: 640px) {
.u-row {
width: 620px !important;
}
.u-row .u-col {
vertical-align: top;
}
.u-row .u-col-100 {
width: 620px !important;
}
}
@media only screen and (max-width: 640px) {
.u-row-container {
max-width: 100% !important;
padding-left: 0px !important;
padding-right: 0px !important;
}
.u-row {
width: 100% !important;
}
.u-row .u-col {
display: block !important;
width: 100% !important;
min-width: 320px !important;
max-width: 100% !important;
}
.u-row .u-col>div {
margin: 0 auto;
}
.u-row .u-col img {
max-width: 100% !important;
}
}
body {
margin: 0;
padding: 0
}
table,
td,
tr {
border-collapse: collapse;
vertical-align: top
}
.ie-container table,
.mso-container table {
table-layout: fixed
}
* {
line-height: inherit
}
a[x-apple-data-detectors=true] {
color: inherit !important;
text-decoration: none !important
}
table,
td {
color: #000000;
}
</style>
</head>
<body class="clean-body u_body" style="margin: 0;padding: 0;-webkit-text-size-adjust: 100%;background-color: #F9F9F9;color: #000000">
<!--[if IE]><div class="ie-container"><![endif]-->
<!--[if mso]><div class="mso-container"><![endif]-->
<table style="border-collapse: collapse;table-layout: fixed;border-spacing: 0;mso-table-lspace: 0pt;mso-table-rspace: 0pt;vertical-align: top;min-width: 320px;Margin: 0 auto;background-color: #F9F9F9;width:100%" cellpadding="0" cellspacing="0">
<tbody>
<tr style="vertical-align: top">
<td style="word-break: break-word;border-collapse: collapse !important;vertical-align: top">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td align="center" style="background-color: #F9F9F9;"><![endif]-->
<div class="u-row-container" style="padding: 0px;background-color: transparent">
<div class="u-row" style="margin: 0 auto;min-width: 320px;max-width: 620px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;">
<div style="border-collapse: collapse;display: table;width: 100%;height: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding: 0px;background-color: transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:620px;"><tr style="background-color: transparent;"><![endif]-->
<!--[if (mso)|(IE)]><td align="center" width="620" style="width: 620px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;" valign="top"><![endif]-->
<div class="u-col u-col-100" style="max-width: 320px;min-width: 620px;display: table-cell;vertical-align: top;">
<div style="height: 100%;width: 100% !important;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;">
<!--[if (!mso)&(!IE)]><!-->
<div style="box-sizing: border-box; height: 100%; padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;"><!--<![endif]-->
<table style="font-family:times new roman,times;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:times new roman,times;" align="left">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding-right: 0px;padding-left: 0px;" align="center">
<img align="center" border="0" src="https://assets.unlayer.com/projects/263979/1739609649412-nhance_logo.png?w=372px" alt="" title="" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: inline-block !important;border: none;height: auto;float: none;width: 31%;max-width: 186px;" width="186" />
</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
<!--[if (!mso)&(!IE)]><!-->
</div><!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
</div>
</div>
</div>
<div class="u-row-container" style="padding: 0px;background-color: transparent">
<div class="u-row" style="margin: 0 auto;min-width: 320px;max-width: 620px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;">
<div style="border-collapse: collapse;display: table;width: 100%;height: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding: 0px;background-color: transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:620px;"><tr style="background-color: transparent;"><![endif]-->
<!--[if (mso)|(IE)]><td align="center" width="620" style="width: 620px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;" valign="top"><![endif]-->
<div class="u-col u-col-100" style="max-width: 320px;min-width: 620px;display: table-cell;vertical-align: top;">
<div style="height: 100%;width: 100% !important;">
<!--[if (!mso)&(!IE)]><!-->
<div style="box-sizing: border-box; height: 100%; padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;"><!--<![endif]-->
<table style="font-family:times new roman,times;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:times new roman,times;" align="left">
<div style="font-size: 14px; line-height: 140%; text-align: left; word-wrap: break-word;">
<p style="line-height: 140%; margin: 0px;">&nbsp;</p>
<p style="line-height: 140%; margin: 0px;">Dear [[member_name]],</p>
<p style="line-height: 140%; margin: 0px;">Your Claim Number [[claim_number]] is currently in the <strong>[[status]]</strong> status with us.</p>
<p style="line-height: 140%; margin: 0px;">&nbsp;</p>
<p style="line-height: 140%; margin: 0px;">&nbsp;</p>
</div>
</td>
</tr>
</tbody>
</table>
<!--[if (!mso)&(!IE)]><!-->
</div><!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
</div>
</div>
</div>
<div class="u-row-container" style="padding: 0px;background-color: transparent">
<div class="u-row" style="margin: 0 auto;min-width: 320px;max-width: 620px;overflow-wrap: break-word;word-wrap: break-word;word-break: break-word;background-color: transparent;">
<div style="border-collapse: collapse;display: table;width: 100%;height: 100%;background-color: transparent;">
<!--[if (mso)|(IE)]><table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td style="padding: 0px;background-color: transparent;" align="center"><table cellpadding="0" cellspacing="0" border="0" style="width:620px;"><tr style="background-color: transparent;"><![endif]-->
<!--[if (mso)|(IE)]><td align="center" width="620" style="width: 620px;padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;" valign="top"><![endif]-->
<div class="u-col u-col-100" style="max-width: 320px;min-width: 620px;display: table-cell;vertical-align: top;">
<div style="height: 100%;width: 100% !important;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;">
<!--[if (!mso)&(!IE)]><!-->
<div style="box-sizing: border-box; height: 100%; padding: 0px;border-top: 0px solid transparent;border-left: 0px solid transparent;border-right: 0px solid transparent;border-bottom: 0px solid transparent;border-radius: 0px;-webkit-border-radius: 0px; -moz-border-radius: 0px;"><!--<![endif]-->
<table style="font-family:times new roman,times;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:times new roman,times;" align="left">
<div>
<img alt="Alternate image text" src="https://ci3.googleusercontent.com/meips/ADKq_NZ1tC_lDp1mJDJ6iwpQvycq0vGPIeb0bF_z4SVXl6h2csrbTBpjuVtXZuXhPHAIRyGfRvc30Y83qZtaXRsM4_p2B9-yGkYAS56f6UraLELku6bQTXbhUaAyXGeq8TndT-y0vuvSLRhMi8iS9xL62fcwJ8r-MqMCdiwLcvuYRFZHcWeuPmkC_ByeA0H0v3lVozfDHgTThXzpuzsfkMMhg4wcUoxWxVNg4GNkS9dv=s0-d-e1-ft#https://res.cloudinary.com/mailmodo/image/upload/v1731739899/editor/p/86755bd3-1482-4348-86df-ac4c01829407/93af6a8f9f9d7c81c28b1b51d9127cea_fv4fpe.gif" width="22" height="auto" class="CToWUd __web-inspector-hide-shortcut__" data-bit="iit" style="border: 0px solid transparent; height: auto; line-height: 13px; outline: 0px; text-decoration: none; object-fit: cover; border-radius: 0px; display: block; width: 21.9907px; font-size: 13px; margin-left: auto; margin-right: auto;">
</div>
</td>
</tr>
</tbody>
</table>
<table style="font-family:times new roman,times;" role="presentation" cellpadding="0" cellspacing="0" width="100%" border="0">
<tbody>
<tr>
<td style="overflow-wrap:break-word;word-break:break-word;padding:10px;font-family:times new roman,times;" align="left">
<div style="font-size: 14px; line-height: 140%; text-align: center; word-wrap: break-word;">
<p style="line-height: 140%; margin: 0px;">ⓒ2024 Nhance India Insurance Broking Pvt Ltd</p>
</div>
</td>
</tr>
</tbody>
</table>
<!--[if (!mso)&(!IE)]><!-->
</div><!--<![endif]-->
</div>
</div>
<!--[if (mso)|(IE)]></td><![endif]-->
<!--[if (mso)|(IE)]></tr></table></td></tr></table><![endif]-->
</div>
</div>
</div>
<!--[if (mso)|(IE)]></td></tr></table><![endif]-->
</td>
</tr>
</tbody>
</table>
<!--[if mso]></div><![endif]-->
<!--[if IE]></div><![endif]-->
</body>
</html>
';
// Replace placeholders with actual values
$replacedTemplate = str_replace(
['[[member_name]]', '[[claim_number]]', '[[status]]'],
[$emp_name, $claim_number, $client_status],
$template
);
return $replacedTemplate;
}
}

View File

@ -63,6 +63,7 @@ class DepositHelper
'updated_by' => $data['updated_by'],
'balance' => $newBalance, // Include the new balance in the data array
'cd_ac_pk'=> isset($data['cd_ac_pk'])?$data['cd_ac_pk']:null,
'record_date' => $data['record_date'] ?? null
];
// Insert data and get the insert ID

View File

@ -27,7 +27,8 @@ class ClientDepositModel extends Model
"endorsement_no",
"event_name",
"unit",
"cd_ac_pk"
"cd_ac_pk",
"record_date"
];

View File

@ -46,6 +46,38 @@
</style>
<style>
/* Timeline Design */
.timeline {
position: relative;
padding-left: 30px;
border-left: 3px solid #007bff;
}
.timeline-item {
position: relative;
margin-bottom: 20px;
padding-left: 20px;
}
.timeline-dot {
position: absolute;
left: -10px;
top: 5px;
width: 15px;
height: 15px;
background: #007bff;
border-radius: 50%;
}
.timeline-content {
background: #f8f9fa;
padding: 10px;
border-radius: 5px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
}
</style>
<?php $pro_rata_total = 0; $gst_total = 0 ?>
<div class="row" id="client_list">
@ -154,6 +186,8 @@
) {
?>
<a class="dropdown-item" onclick="get_emp_master_data_for_update(this, '<?= $employee['employee_id'];?>', '<?= $employee['status'];?>')" ><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" onclick="get_emp_history(this, '<?= $employee['employee_id'];?>')" > <i class="mdi mdi-history mr-2 text-muted font-18 vertical-middle"></i>Employee History</a>
<?php } ?>
<?php if(in_array($employee['policy_type_id'], [2,3,4,5]) && $employee['emp_status'] == 'active' && $employee['status'] == 'active' && !empty($employee['tpa_id'])) { ?>
@ -270,6 +304,20 @@
</div>
</div><!-- /.modal -->
<!-- Modal content for Emp History -->
<div class="modal fade" id="emp_history_modal" tabindex="-1" aria-labelledby="emp_history_modal_label" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="emp_history_modal_label">Employee History</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div id = "emp_history_content"></div>
</div>
</div>
</div>
<script>
$(document).ready(function(){
@ -543,5 +591,92 @@
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
return false;
}
function showModal() {
var myModal = new bootstrap.Modal(document.getElementById('emp_history_modal'));
myModal.show();
}
function get_emp_history(input, emp_id) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
let url = '<?= base_url("employee/get_emp_history")?>';
let requestData = { emp_id: emp_id };
sendAjaxRequestForGlobal(url, 'POST', requestData, function(response) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if (response.status === true) {
console.log('response data length', response.data.emp_history.length);
// **Clear old data**
$('#emp_history_content').html('');
// **Check if data exists**
if (response.data.emp_history.length > 0) {
let historyTable = `
<div class="card-body">
<div class="table-responsive">
<table class="table w-100">
<thead class="bg-light">
<tr>
<th>Field</th>
<th>Change</th>
<th>User</th>
<th>Date/Time</th>
</tr>
</thead>
<tbody>
`;
// **Loop through the data dynamically**
response.data.emp_history.forEach(row => {
historyTable += `
<tr>
<td>${row.field_name}</td>
<td>${row.old_value} => ${row.new_value}</td>
<td>${row.created_by}</td>
<td>${row.created_at}</td>
</tr>
`;
});
historyTable += `
</tbody>
</table>
</div>
</div>
`;
// **Append to modal**
$('#emp_history_content').append(historyTable);
} else {
$('#emp_history_content').html('<p class="text-center text-muted">No history available.</p>');
}
// **Show the modal**
showModal();
} else {
let message = response.message;
toastr.error(message, 'ERROR');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetching the report page.', 'ERROR');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
});
}
function closeModal(){
var myModalEl = document.getElementById('emp_history_modal');
var modalInstance = bootstrap.Modal.getInstance(myModalEl);
if (modalInstance) {
modalInstance.hide();
}
}
</script>

File diff suppressed because it is too large Load Diff

View File

@ -161,28 +161,29 @@ table.dataTable tbody td {
<script>
document.addEventListener("DOMContentLoaded", function () {
const table = document.getElementById("tickets-table");
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
// Clone the items but remove their original click handlers
const items = originalDropdown.querySelectorAll('.dropdown-item');
items.forEach(item => {
const newItem = item.cloneNode(true);
// Preserve the attributes but remove the onclick
newItem.removeAttribute('onclick');
customDropdown.appendChild(newItem);
});
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
@ -195,46 +196,49 @@ document.addEventListener("DOMContentLoaded", function () {
return;
}
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
}
// Get click position
const rect = event.target.getBoundingClientRect();
// Position the dropdown with some offset
customDropdown.style.display = 'block';
customDropdown.style.position = 'fixed';
customDropdown.style.left = `${rect.left}px`;
customDropdown.style.top = `${rect.bottom + 5}px`; // Add 5px gap
customDropdown.style.top = `${rect.bottom + 5}px`;
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
// Handle clicks on dropdown items
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
e.preventDefault();
e.stopPropagation();
// Get the data-id and other attributes from the original button
const originalItem = row.querySelector(`.dropdown-item[data-id="${this.getAttribute('data-id')}"]`);
// For edit functionality
if (this.classList.contains('btnEdit')) {
const id = this.getAttribute('data-id');
if (id) {
getLeadsDataForEdit(id);
}
}
// For RFQ links
const href = this.getAttribute('href');
if (href && href !== '#') {
if (href && href !== '#' && !this.classList.contains('btnEdit')) {
window.location.href = href;
}
// Close the dropdown after handling the click
// Close the dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
@ -281,7 +285,7 @@ $(document).ready(function(){
$('#client_id').select2();
$('#client_branch_id').select2();
$('#source_policy_id').select2();
// $('#source_policy_id').select2();
$('#salse_person_id').select2({
placeholder: "Select Salse Person",
});

View File

@ -107,6 +107,7 @@
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Date</th>
<th class="font-weight-medium">Record Date</th>
<th class="font-weight-medium">Unit</th>
<th class="font-weight-medium">Policy</th>
<th class="font-weight-medium">Endorsement No</th>
@ -122,6 +123,7 @@
<?php foreach($depositdata as $row) { ?>
<tr id="<?php echo $row->id;?>">
<td><?php echo date('d-M-Y h:i A', strtotime($row->created_at)); ?></td>
<td><?php echo isset($row->record_date)? date('d-M-Y', strtotime($row->record_date)):'-' ?></td>
<td><?php echo $row->unit ?? ' - '; ?></td>
<!-- <td><?php echo $row->policy_name ?? '<center> - </center>'; ?></td> -->
<td>
@ -139,8 +141,8 @@
<td><?php echo $row->endorsement_no ?? '<center> - </center>'; ?></td>
<td><?php echo isset($subTypeOptions[$row->sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?>
</td>
<td><?php echo ($row->transaction_type == 'Credit') ? $row->amount : ''; ?></td>
<td><?php echo ($row->transaction_type == 'Debit') ? $row->amount : ''; ?></td>
<td><?php echo ($row->transaction_type == 'Credit') ? $row->amount : '-'; ?></td>
<td><?php echo ($row->transaction_type == 'Debit') ? $row->amount : '-'; ?></td>
<td><?php echo $row->balance; ?></td>
<td><?php echo $row->description; ?></td>
<td><?php echo $row->username; ?></td>
@ -205,6 +207,8 @@
<div class="form-group">
<label for="field-1" class="control-label">Amount<span class="text-danger">*</span></label>
<input type="number" class="form-control" id="amount" placeholder="Amount" required>
<br><label for="record_date">Record Date <span class="text-danger"></span></label>
<input type="text" class="form-control policy_start_date" id="record_date" name="record_date" placeholder="Record Date">
</div>
</div>
@ -264,6 +268,12 @@ $(document).ready(function() {
<script>
$(document).ready(function() {
var record_date = flatpickr("#record_date",{
dateFormat: "d/m/Y",
allowInput: false,
});
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
@ -293,6 +303,8 @@ $(document).ready(function() {
paging: true ,
});
});
</script>
@ -320,6 +332,7 @@ $(document).ready(function() {
var insurerId = '<?php echo $insurerName->id; ?>';
var transactionTypeValue = $('input[name="transactionMode"]:checked').val();
var subType = "";
var record_date = $('#record_date').val();
if(amount == ""){
toastr.warning('Amount field is required')
@ -372,7 +385,8 @@ $(document).ready(function() {
transaction_type: transactionType,
sub_type_id: subType, // Include sub_type_id
client_id: clientId,
insurer_id: insurerId
insurer_id: insurerId,
record_date : record_date
},
success: function(response) {
// Handle success response