FEAT_RECORD_DATE_CD_TRANSACTIONS, CHANGE_MAIL_TEMPLATE_CHATBOT_SRI

This commit is contained in:
Srinivas-Saravanan 2025-02-15 15:49:20 +05:30
parent 497da87793
commit c388877b3f
7 changed files with 342 additions and 18 deletions

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

@ -301,15 +301,8 @@ class LeadsController extends BaseController
}else{
continue;
}
// print_r($last_3_years_claims);
// $last_3_years_claims = json_encode($last_3_years_claims);
}
$last_3_years_claims = json_encode($last_3_years_claims);
// print_r($last_3_years_claims);
// die();
// $last_3_years_claims = $data['finyear'];
}
$processedData[] = [

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

@ -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