diff --git a/app/Controllers/Chatbot/ReimbursementClaimStatusConversation.php b/app/Controllers/Chatbot/ReimbursementClaimStatusConversation.php index db8831bc..fd6e3337 100644 --- a/app/Controllers/Chatbot/ReimbursementClaimStatusConversation.php +++ b/app/Controllers/Chatbot/ReimbursementClaimStatusConversation.php @@ -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.
More Detailed Information is sent to your mail"); + $this->say("The claim status for the claim Number {$data['claim_number']} is currently in {$data['client_status']} status.
More Detailed Information is sent to your mail"); $this->bot->startConversation(new doYouWantToContinueConversation()); }else{ $this->say("No Claim Raised against the user."); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 1cb8e029..4252cff6 100755 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -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 diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 30ada663..b5f31223 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -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[] = [ diff --git a/app/Helpers/ChatbotHelper.php b/app/Helpers/ChatbotHelper.php index 6dff5c6c..08fcbb83 100644 --- a/app/Helpers/ChatbotHelper.php +++ b/app/Helpers/ChatbotHelper.php @@ -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 = ' + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ + + + + +
+ + + +
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +
+

 

+

Dear [[member_name]],

+

Your Claim Number [[claim_number]] is currently in the [[status]] status with us.

+

 

+

 

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + + +
+
+
+ + + +
+
+ +
+ + + + + + + +
+ +
+ Alternate image text +
+ +
+ + + + + + + +
+ +
+

ⓒ2024 Nhance India Insurance Broking Pvt Ltd

+
+ +
+ + +
+
+
+ + +
+
+
+ + + + +
+ + + + + + '; + + // Replace placeholders with actual values + $replacedTemplate = str_replace( + ['[[member_name]]', '[[claim_number]]', '[[status]]'], + [$emp_name, $claim_number, $client_status], + $template + ); + + return $replacedTemplate; + } + + } diff --git a/app/Helpers/DepositHelper.php b/app/Helpers/DepositHelper.php index 0ee54530..d225f71f 100755 --- a/app/Helpers/DepositHelper.php +++ b/app/Helpers/DepositHelper.php @@ -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 diff --git a/app/Models/ClientDepositModel.php b/app/Models/ClientDepositModel.php index 91bdf1c4..9d45f38f 100755 --- a/app/Models/ClientDepositModel.php +++ b/app/Models/ClientDepositModel.php @@ -27,7 +27,8 @@ class ClientDepositModel extends Model "endorsement_no", "event_name", "unit", - "cd_ac_pk" + "cd_ac_pk", + "record_date" ]; diff --git a/app/Views/view_deposit.php b/app/Views/view_deposit.php index 7abbf0aa..306fe72b 100755 --- a/app/Views/view_deposit.php +++ b/app/Views/view_deposit.php @@ -107,6 +107,7 @@ Date + Record Date Unit Policy Endorsement No @@ -122,6 +123,7 @@ created_at)); ?> + record_date)? date('d-M-Y', strtotime($row->record_date)):'-' ?> unit ?? ' - '; ?> @@ -139,8 +141,8 @@ endorsement_no ?? '
-
'; ?> sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?> - transaction_type == 'Credit') ? $row->amount : ''; ?> - transaction_type == 'Debit') ? $row->amount : ''; ?> + transaction_type == 'Credit') ? $row->amount : '-'; ?> + transaction_type == 'Debit') ? $row->amount : '-'; ?> balance; ?> description; ?> username; ?> @@ -205,6 +207,8 @@
+
+
@@ -264,6 +268,12 @@ $(document).ready(function() { @@ -320,6 +332,7 @@ $(document).ready(function() { var insurerId = '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