CHANGE_CLAIM_MODULE : RV

This commit is contained in:
VENKATESHWARAN 2025-01-28 15:25:32 +05:30
parent 8a87addf4e
commit 5c87de3d73
8 changed files with 445 additions and 149 deletions

View File

@ -337,6 +337,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->post('unmap_employees/(:num)', 'EmployeeController::unmapEmployees/$1');
$routes->get('transformMailContent', 'LeadsController::transformMailContent');
$routes->get('getCDAmount', 'ClientController::getCDAmount');
$routes->get('getTheEmpDataForClaim/(:any)', 'ClientController::getTheEmpDataForClaim/$1');
});
$routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) {
@ -497,7 +498,7 @@ $routes->group("/ticket", ["filter" => "authMVC"], function ($routes) {
$routes->match( ['get', 'post'], 'list','TicketController::ticketList');
$routes->get('new/(:any)','TicketController::ticket_form/$1');
$routes->post('create','TicketController::createTicket');
$routes->get('update','TicketController::updateTicket');
$routes->post('update','TicketController::updateTicket');
$routes->get('view/(:any)','TicketController::view_ticket/$1');
$routes->get('mail_template','TicketController::createMailTemplate');
});

View File

@ -4138,6 +4138,46 @@ class ClientController extends AdminController
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found'], 200);
}
}
}
public function getTheEmpDataForClaim($client_policy_id)
{
$data = $this->clientPolicyModel->select("
clients.id as client_id,
clients.client_name,
insurers.id as insurer_id,
insurers.name as insurer_name,
tpa.id as tpa_id,
tpa.name as tpa_name,
employees.id as emp_id,
employees.name as emp_name,
employees.emp_code,
employees.mobile as emp_mobile,
employees.email_corporate as emp_email,
employee_polices.uhid as policy_no,
")
->join('clients', 'client_policy.client_id = clients.id', 'left')
->join('insurers', 'client_policy.insurer_id = insurers.id', 'left')
->join('tpa', 'client_policy.tpa_id = tpa.id', 'left')
->join('employees', 'clients.id = employees.client_id', 'left')
->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
->where('client_policy.id',)
->where('client_policy.is_active', 1)
->where('insurers.is_active', 1)
->where('tpa.is_active', 1)
->where('employees.is_active', 1)
->where('employee_polices.is_active', 1)
->where('client_policy.id', $client_policy_id)
->findAll();
if($data){
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'no data found', "client_policy_id" =>$client_policy_id], 200);
}
}
}

View File

@ -135,6 +135,12 @@ class TicketController extends BaseController
public function ticket_form($ticket_type)
{
$data = $this->ticket_form_data($ticket_type);
return $this->loadLayout('ticket_form_handler', $data);
}
public function ticket_form_data($ticket_type)
{
$data['ticket_form'] = 1;
$data['ticket_type'] = $this->ticketType;
$data['priorityType'] = $this->priorityType;
@ -156,12 +162,9 @@ class TicketController extends BaseController
->getResultArray();
if($ticket_type == 1){
$data['modeOFIntimate'] = $this->claimType[1];
return $this->loadLayout('ticket_form_handler', $data);
$data['claim_type'] = $this->claimType[1];
}else{
$data['modeOFIntimate'] = $this->claimType[2];
$data['claim_type'] = $this->claimType[2];
if($ticket_type == 2){
$data['ticket_form'] = 'GPA';
}else if($ticket_type = 3){
@ -169,34 +172,79 @@ class TicketController extends BaseController
}else if($ticket_type = 4){
$data['ticket_form'] = 'GTLI';
}
return $this->loadLayout('ticket_form_handler', $data);
}
return $data;
}
public function view_ticket($ticket_id)
{
$data = [];
{
$ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first();
$ticket_data = $this->formatDateForClaim($ticket_data, 'd/m/Y');
// dd($ticket_data);
$data = $this->ticket_form_data($ticket_data['ticket_type_id']);
$data['ticket_data'] = $ticket_data;
return $this->loadLayout('ticket_edit_onbording', $data);
}
public function createTicket()
{
$ticket_data = $this->request->getPost();
// print_rr($ticket_data); die;
public function formatDateForClaim($ticket_data, $out_put_format = 'Y-m-d')
{
if(empty($ticket_data['doa'])){
$ticket_data['doa'] = null;
}else{
$ticket_data['doa'] = change_date_format($ticket_data['doa']);
$ticket_data['doa'] = change_date_format($ticket_data['doa'], null, $out_put_format);
}
if(empty($ticket_data['dod'])){
$ticket_data['dod'] = null;
}else{
$ticket_data['dod'] = change_date_format($ticket_data['dod']);
$ticket_data['dod'] = change_date_format($ticket_data['dod'], null, $out_put_format);
}
if(empty($ticket_data['dob'])){
$ticket_data['dob'] = null;
}else{
$ticket_data['dob'] = change_date_format($ticket_data['dob'], null, $out_put_format);
}
if(empty($ticket_data['date_of_join'])){
$ticket_data['date_of_join'] = null;
}else{
$ticket_data['date_of_join'] = change_date_format($ticket_data['date_of_join'], null, $out_put_format);
}
if(empty($ticket_data['date_of_incep'])){
$ticket_data['date_of_incep'] = null;
}else{
$ticket_data['date_of_incep'] = change_date_format($ticket_data['date_of_incep'], null, $out_put_format);
}
if(empty($ticket_data['date_of_accident'])){
$ticket_data['date_of_accident'] = null;
}else{
$ticket_data['date_of_accident'] = change_date_format($ticket_data['date_of_accident'], null, $out_put_format);
}
if(empty($ticket_data['date_of_death'])){
$ticket_data['date_of_death'] = null;
}else{
$ticket_data['date_of_death'] = change_date_format($ticket_data['date_of_death'], null, $out_put_format);
}
if(empty($ticket_data['date_of_intimat'])){
$ticket_data['date_of_intimat'] = null;
}else{
$ticket_data['date_of_intimat'] = change_date_format($ticket_data['date_of_intimat'], null, $out_put_format);
}
return $ticket_data;
}
public function createTicket()
{
$ticket_data = $this->request->getPost();
$ticket_data = $this->formatDateForClaim($ticket_data);
// print_rr($ticket_data); die;
if($ticket_data){
@ -212,7 +260,22 @@ class TicketController extends BaseController
}
public function updateTicket()
{
{
$ticket_id = $this->request->getPost('ticket_master_id');
$ticket_data = $this->request->getPost();
$ticket_data = $this->formatDateForClaim($ticket_data);
// print_rr($ticket_data); die;
if($ticket_data){
$return_value = $this->ticketMasterModel->where('id', $ticket_id)->set($ticket_data)->update();
if($return_value){
return $this->respond(['status' => true, 'code' => 200, 'data' => $ticket_data, "message" => "Claim updated successfully"], 200);
} else {
return $this->respond(['status' => false, 'code' => 404, 'message' => 'Failed to update claim'], 200);
}
}else{
return $this->respond(['status' => false, 'code' => 404, 'message' => 'claim data not found'], 200);
}
}
public function createMailTemplate()

View File

@ -12,15 +12,6 @@ class TicketMasterModel extends Model
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
<<<<<<< HEAD
protected $allowedFields = ['id', 'ticket_type_id', 'claim_status_id', 'acm_id', 'insurer_id',
'tpa_id', 'client_id', 'priority', 'policy_no', 'emp_code', 'tpa_no', 'emp_name', 'insured_name',
'relationship', 'emp_mobile', 'emp_mail', 'mode_of_intimation', 'claim_type', 'hospital_name',
'doa', 'dod', 'claim_amount', 'pod_no', 'created_by', 'updated_by', 'created_at', 'updated_at',
'date_of_join', 'date_of_incep', 'dob', 'date_of_accident', 'date_of_death', 'date_of_intimat',
'si_amt','claim_number,is_active'
];
=======
protected $allowedFields = [
'id',
'ticket_type_id',
@ -57,10 +48,11 @@ class TicketMasterModel extends Model
'date_of_intimat',
'si_amt',
'is_active',
'claim_number'
'claim_number',
'emp_id',
'insured_emp_id',
];
>>>>>>> 3a4f7b1e836fc71f477cb6ad32a635dcae0192d0
// Callbacks
protected $allowCallbacks = true;

View File

@ -22,25 +22,29 @@
<!-- Navigation Tabs -->
<ul class="nav nav-pills navtab-bg">
<li class="nav-item">
<a href="#general-tab" data-toggle="tab" class="nav-link px-2 py-1 active" id="general_tab" aria-expanded="true">
<a href="#general-tab" data-toggle="tab" class="nav-link px-2 py-1 active" id="general_tab"
aria-expanded="true">
<i class="mdi mdi-contacts mr-1"></i>
<span class="d-none d-sm-inline-block">General</span>
</a>
</li>
<li class="nav-item">
<a href="#reply-tab" data-toggle="tab" class="nav-link px-2 py-1" id="reply_tab" aria-expanded="false">
<a href="#reply-tab" data-toggle="tab" class="nav-link px-2 py-1" id="reply_tab"
aria-expanded="false">
<i class="fa fa-file mr-1"></i>
<span class="d-none d-sm-inline-block">Reply</span>
</a>
</li>
<li class="nav-item">
<a href="#note-tab" data-toggle="tab" class="nav-link px-2 py-1" id="note_tab" aria-expanded="false">
<a href="#note-tab" data-toggle="tab" class="nav-link px-2 py-1" id="note_tab"
aria-expanded="false">
<i class="mdi mdi-account-switch mr-1"></i>
<span class="d-none d-sm-inline-block">Note</span>
</a>
</li>
<li class="nav-item">
<a href="#history-tab" data-toggle="tab" class="nav-link px-2 py-1" id="history_tab" aria-expanded="false">
<a href="#history-tab" data-toggle="tab" class="nav-link px-2 py-1" id="history_tab"
aria-expanded="false">
<i class="mdi mdi-source-branch mr-1"></i>
<span class="d-none d-sm-inline-block">History</span>
</a>
@ -50,7 +54,14 @@
<!-- Tab Content -->
<div class="tab-content">
<div class="tab-pane fade show active" id="general-tab">
<?php include('ticket_form_gpa.php'); ?>
<?php
if ($ticket_data['ticket_type_id'] == 1) {
include('ticket_form_gmc.php');
} else {
include('ticket_form_gpa.php');
}
?>
</div>
<div class="tab-pane fade" id="reply-tab">
<?php include('ticket_reply.php'); ?>
@ -69,4 +80,51 @@
<div id="ticket_conversation_div">
<?php include("ticket_conversation.php") ?>
</div>
</div>
<script>
function submitClaimForm(event, form) {
event.preventDefault();
const formAction = '<?= base_url("ticket/update"); ?>';
// Show loader
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Collect IDs and form data
const formData = new FormData(form);
// AJAX request
$.ajax({
data: formData,
url: formAction,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(response) {
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Form submitted response:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
} else {
toastr.error(response.message, 'ERROR');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
</script>

View File

@ -1,8 +1,8 @@
<div class="row">
<div class="col-12">
<div class="<?= isset($ticket_form) ? "card" : "" ?>" style="margin-right: 23px;">
<div class="<?= !isset($ticket_data) ? "card" : "" ?>" style="margin-right: 23px;">
<div class="card-body">
<?php if(isset($ticket_form)){ ?>
<?php if(!isset($ticket_data)){ ?>
<!-- Header Section -->
<div class="row mb-3">
<div class="col-6 d-flex align-items-center">
@ -15,9 +15,10 @@
</div>
</div>
<?php } ?>
<form role="form" class="parsley-examples" method="post" id="ticket_form_gmc" enctype="multipart/form-data">
<form role="form" class="parsley-examples" method="post" id="ticket_form_gmc" onsubmit="submitClaimForm(event, this)" enctype="multipart/form-data">
<input type="hidden" id="ticket_type_id" name="ticket_type_id" value="1">
<input type="hidden" id="ticket_master_id" name="ticket_master_id" value="<?= isset($ticket_data['id']) ? $ticket_data['id'] : '' ?>">
<div class="form-group">
<div class="form-row">
@ -29,7 +30,8 @@
<?php
if (isset($claim_status) && count($claim_status)) {
foreach ($claim_status as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['claim_status'] . "</option>";
$selected = (isset($ticket_data) && $ticket_data['claim_status_id'] == $value['id']) ? 'selected' : '';
echo "<option value=" . $value['id'] . " $selected>" . $value['claim_status'] . "</option>";
}
}
?>
@ -43,7 +45,8 @@
<?php
if (isset($priorityType) && count($priorityType)) {
foreach ($priorityType as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>";
$selected = (isset($ticket_data) && $ticket_data['priority'] == $key) ? 'selected' : '';
echo "<option value=" . $key . " $selected>" . $value . "</option>";
}
}
?>
@ -57,7 +60,8 @@
<?php
if (isset($acms) && count($acms)) {
foreach ($acms as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['first_name'] . "</option>";
$selected = (isset($ticket_data) && $ticket_data['acm_id'] == $value['id']) ? 'selected' : '';
echo "<option value=" . $value['id'] . " $selected >" . $value['first_name'] . "</option>";
}
}
?>
@ -67,26 +71,26 @@
<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"
value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>"
name="policy_no" placeholder="Policy Number" readonly>
value="<?= isset($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>"
name="policy_no" placeholder="Policy Number" >
</div>
<div class="form-group col-md-3">
<label for="insurer_id">Insurer<span class="text-danger"></span></label>
<input type=hidden id="insurer_id" name="insurer_id">
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" readonly>
<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'] : '' ?>">
</div>
<div class="form-group col-md-3">
<label for="tpa_id">TPA<span class="text-danger"></span></label>
<input type=hidden id="tpa_id" name="tpa_id">
<input type=text class="form-control" id="tpa_name" placeholder="TPA" readonly>
<input type=hidden id="tpa_id" name="tpa_id" value="<?= isset($ticket_data['tpa_id']) ? $ticket_data['tpa_id'] : '' ?>">
<input type=text class="form-control" id="tpa_name" placeholder="TPA" value="<?= isset($ticket_data['tpa_name']) ? $ticket_data['tpa_name'] : '' ?>">
</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">
<input type="text" class="form-control" id="client_name" placeholder="Client" readonly>
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
<input type="text" class="form-control" id="client_name" placeholder="Client" value="<?= isset($ticket_data['client_name']) ? $ticket_data['client_name'] : '' ?>">
</div>
<div class="form-group col-md-3">
@ -94,29 +98,29 @@
aria-hidden="true" onclick="openFetchEmpDataodal(this)"></i> <span
class="text-danger"></span></label>
<input type="text" class="form-control" id="emp_code" placeholder="Enter Employee ID"
value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>"
value="<?= isset($ticket_data['emp_code']) ? $ticket_data['emp_code'] : '' ?>"
name="emp_code">
</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"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['tpa_no']) ? $ticket_data['tpa_no'] : '' ?>"
name="tpa_no">
</div>
<div class="form-group col-md-3">
<label for="emp_name">Employee Name<span class="text-danger"></span></label>
<input type=hidden id="emp_id" name="emp_id">
<input type=hidden id="emp_id" name="emp_id" value="<?= isset($ticket_data['emp_id']) ? $ticket_data['emp_id'] : '' ?>">
<input type="text" class="form-control" id="emp_name" placeholder="Enter Employee Name"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['emp_name']) ? $ticket_data['emp_name'] : '' ?>"
name="emp_name">
</div>
<div class="form-group col-md-3">
<label for="insured_name"> Insured Name <span class="text-danger"></span></label>
<input type=hidden id="insured_emp_id" name="insured_emp_id">
<input class="form-control" id="insured_name" name="insured_name">
<input type=hidden id="insured_emp_id" name="insured_emp_id" value="<?= isset($ticket_data['insured_emp_id']) ? $ticket_data['insured_emp_id'] : '' ?>">
<input class="form-control" id="insured_name" name="insured_name" value="<?= isset($ticket_data['insured_name']) ? $ticket_data['insured_name'] : '' ?>">
</div>
<div class="form-group col-md-3">
@ -126,7 +130,8 @@
<?php
if (isset($relationshipType) && count($relationshipType)) {
foreach ($relationshipType as $key => $value) {
echo "<option value='" . $key . "'>" . $value . "</option>";
$selected = (isset($ticket_data) && $ticket_data['relationship'] == $key) ? 'selected' : '';
echo "<option value='$key' $selected>$value</option>";
}
}
?>
@ -134,16 +139,16 @@
</div>
<div class="form-group col-md-3">
<label for="client_name">Employee Mobile No<span class="text-danger"></span></label>
<label for="emp_mobile">Employee Mobile No<span class="text-danger"></span></label>
<input type="text" class="form-control" id="emp_mobile" placeholder="Enter EMP Mobile"
value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>"
value="<?= isset($ticket_data['emp_mobile']) ? $ticket_data['emp_mobile'] : '' ?>"
name="emp_mobile">
</div>
<div class="form-group col-md-3">
<label for="emp_mail">Employee Mail ID<span class="text-danger"></span></label>
<input type="text" class="form-control" id="emp_mail" placeholder="Enter EMP Mail"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['emp_mail']) ? $ticket_data['emp_mail'] : '' ?>"
name="emp_mail">
</div>
@ -155,7 +160,8 @@
<?php
if (isset($modeOFIntimate) && count($modeOFIntimate)) {
foreach ($modeOFIntimate as $key => $value) {
echo "<option value='" . $key . "'>" . $value . "</option>";
$selected = (isset($ticket_data) && $ticket_data['mode_of_intimation'] == $key) ? 'selected' : '';
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
}
}
?>
@ -167,8 +173,9 @@
<select class="form-control" id="claim_type" name="claim_type">
<option value="0">Select claim Type</option>
<?php
if (isset($modeOFIntimate) && count($modeOFIntimate)) {
foreach ($modeOFIntimate as $key => $value) {
if (isset($claim_type) && count($claim_type)) {
foreach ($claim_type as $key => $value) {
$selected = (isset($ticket_data) && $ticket_data['claim_type'] == $key) ? 'selected' : '';
echo "<option value='" . $key . "'>" . $value . "</option>";
}
}
@ -180,42 +187,42 @@
<label for="hospital_name">Hospital Name<span class="text-danger"></span></label>
<input type="text" class="form-control" id="hospital_name"
placeholder="Enter Hospital Name"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['hospital_name']) ? $ticket_data['hospital_name'] : '' ?>"
name="hospital_name">
</div>
<div class="form-group col-md-3">
<label for="doa">DOA<span class="text-danger"></span></label>
<input type="text" class="form-control" id="doa" placeholder="Enter DOA"
value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>"
value="<?= isset($ticket_data['doa']) ? $ticket_data['doa'] : '' ?>"
name="doa">
</div>
<div class="form-group col-md-3">
<label for="dod">DOD<span class="text-danger"></span></label>
<input type="text" class="form-control" id="dod" placeholder="Enter DOD"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>" name="dod">
value="<?= isset($ticket_data['dod']) ? $ticket_data['dod'] : '' ?>" name="dod">
</div>
<div class="form-group col-md-3">
<label for="claim_amount">Claim Amount<span class="text-danger"></span></label>
<input type="text" class="form-control" id="claim_amount"
placeholder="Enter Claim Amount"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['claim_amount']) ? $ticket_data['claim_amount'] : '' ?>"
name="claim_amount">
</div>
<div class="form-group col-md-3">
<label for="pod_no">POD No<span class="text-danger"></span></label>
<input type="text" class="form-control" id="pod_no" placeholder="Enter POD NO"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['pod_no']) ? $ticket_data['pod_no'] : '' ?>"
name="pod_no">
</div>
</div>
</div>
<div class="form-group col-md-12 text-right m-b-0" style="margin-top: 29px;">
<a href="#" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit" onclick="claimFormSubmit('ticket_form_gmc')">Submit</a>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit" >Submit</button>
</div>
</div>

View File

@ -8,9 +8,9 @@
<div class="row">
<div class="col-12">
<div class="<?= isset($ticket_form) ? "card" : "" ?>" style="margin-right: 23px;">
<div class="<?= !isset($ticket_data) ? "card" : "" ?>" style="margin-right: 23px;">
<div class="card-body">
<?php if(isset($ticket_form)){ ?>
<?php if(!isset($ticket_data)){ ?>
<!-- Header Section -->
<div class="row mb-3">
<div class="col-6 d-flex align-items-center">
@ -23,19 +23,22 @@
</div>
</div>
<?php } ?>
<form role="form" class="parsley-examples" method="post" id="ticket_form_gmc"
<form role="form" class="parsley-examples" method="post" id="ticket_form_gmc" onsubmit="submitClaimForm(event, this)"
enctype="multipart/form-data">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-3">
<input type="hidden" id="ticket_master_id" name="ticket_master_id" value="<?= isset($ticket_data['id']) ? $ticket_data['id'] : '' ?>">
<div class="form-group col-md-3">
<label for="claim_status">Status<span class="text-danger"></span></label>
<select class="form-control" id="claim_status" name="claim_status">
<select class="form-control" id="claim_status_id" name="claim_status_id">
<option value="0">Select status</option>
<?php
if (isset($claim_status) && count($claim_status)) {
foreach ($claim_status as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['status'] . "</option>";
$selected = (isset($ticket_data) && $ticket_data['claim_status_id'] == $value['id']) ? 'selected' : '';
echo "<option value=" . $value['id'] . " $selected>" . $value['claim_status'] . "</option>";
}
}
?>
@ -47,9 +50,10 @@
<select class="form-control" id="acm_id" name="acm_id">
<option value="0">Select Account Manager</option>
<?php
if (isset($claim_status) && count($claim_status)) {
foreach ($claim_status as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['status'] . "</option>";
if (isset($acms) && count($acms)) {
foreach ($acms as $key => $value) {
$selected = (isset($ticket_data) && $ticket_data['acm_id'] == $value['id']) ? 'selected' : '';
echo "<option value=" . $value['id'] . " $selected>" . $value['first_name'] . "</option>";
}
}
?>
@ -58,37 +62,21 @@
<div class="form-group col-md-3">
<label for="client_name">Corporate Name<span class="text-danger"></span></label>
<select class="form-control" id="client_id" name="client_id">
<option value="0">Select Corporate</option>
<?php
if (isset($claim_status) && count($claim_status)) {
foreach ($claim_status as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['client_name'] . "</option>";
}
}
?>
</select>
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
<input type="text" class="form-control" id="client_name" placeholder="Client" value="<?= isset($ticket_data['client_name']) ? $ticket_data['client_name'] : '' ?>">
</div>
<div class="form-group col-md-3">
<label for="acm_id">Insurer<span class="text-danger"></span></label>
<select class="form-control" id="insurer_id" name="insurer_id">
<option value="0">Select insurer</option>
<?php
if (isset($claim_status) && count($claim_status)) {
foreach ($claim_status as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['status'] . "</option>";
}
}
?>
</select>
<label for="insurer_id">Insurer<span class="text-danger"></span></label>
<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'] : '' ?>">
</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"
value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>"
name="policy_no">
value="<?= isset($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>"
name="policy_no" readonly>
</div>
<div class="form-group col-md-3">
@ -98,7 +86,8 @@
if (isset($ticket_type) && count($ticket_type)) {
foreach ($ticket_type as $key => $value) {
if($key != 1){
echo "<option value='" . $key . "'>" . $value . "</option>";
$selected = (isset($ticket_data) && $ticket_data['ticket_type_id'] == $key) ? 'selected' : '';
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
}
}
}
@ -107,13 +96,14 @@
</div>
<div class="form-group col-md-3">
<label for="ticket_type"> Claim Type <span class="text-danger"></span></label>
<select class="form-control" id="ticket_type" name="ticket_type">
<label for="claim_type"> Claim Type <span class="text-danger"></span></label>
<select class="form-control" id="claim_type" name="claim_type">
<option value="0">Select claim Type</option>
<?php
if (isset($ticket_type) && count($ticket_type)) {
foreach ($ticket_type as $key => $value) {
echo "<option value='" . $key . "'>" . $value . "</option>";
if (isset($claim_type) && count($claim_type)) {
foreach ($claim_type as $key => $value) {
$selected = (isset($ticket_data) && $ticket_data['claim_type'] == $key) ? 'selected' : '';
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
}
}
?>
@ -121,17 +111,19 @@
</div>
<div class="form-group col-md-3">
<label for="emp_code">Employee ID<span class="text-danger"></span></label>
<label for="emp_code">Employee ID &nbsp; <i class="fa fa-search text-danger"
aria-hidden="true" onclick="openFetchEmpDataodal(this)"></i> <span class="text-danger"></span></label>
<input type="text" class="form-control" id="emp_code" placeholder="Enter Employee ID"
value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>"
value="<?= isset($ticket_data['emp_code']) ? $ticket_data['emp_code'] : '' ?>"
name="emp_code">
</div>
<div class="form-group col-md-3">
<label for="emp_name">Employee Name<span class="text-danger"></span></label>
<input type=hidden id="emp_id" name="emp_id" value="<?= isset($ticket_data['emp_id']) ? $ticket_data['emp_id'] : '' ?>">
<input type="text" class="form-control" id="emp_name" placeholder="Enter Employee Name"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['emp_name']) ? $ticket_data['emp_name'] : '' ?>"
name="emp_name">
</div>
@ -140,7 +132,7 @@
<label for="date_of_join">Date of joining<span class="text-danger"></span></label>
<input type="text" class="form-control" id="date_of_join"
placeholder="Enter Joining Date"
value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>"
value="<?= isset($ticket_data['date_of_join']) ? $ticket_data['date_of_join'] : '' ?>"
name="date_of_join">
</div>
@ -148,21 +140,21 @@
<label for="date_of_incep">Date of Inception<span class="text-danger"></span></label>
<input type="text" class="form-control" id="date_of_incep"
placeholder="Enter Inception Date"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['date_of_incep']) ? $ticket_data['date_of_incep'] : '' ?>"
name="date_of_incep">
</div>
<div class="form-group col-md-3">
<label for="dob">Date of Birth<span class="text-danger"></span></label>
<input type="text" class="form-control" id="dob" placeholder="Enter Birth Date"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>" name="dob">
value="<?= isset($ticket_data['dob']) ? $ticket_data['dob'] : '' ?>" name="dob">
</div>
<div class="form-group col-md-3">
<label for="date_of_accident">Date of Accident<span class="text-danger"></span></label>
<input type="text" class="form-control" id="date_of_accident"
placeholder="Enter Accident Date"
value="<?= isset($client['client_name']) ? $client['client_name'] : '' ?>"
value="<?= isset($ticket_data['date_of_accident']) ? $ticket_data['date_of_accident'] : '' ?>"
name="date_of_accident">
</div>
@ -170,7 +162,7 @@
<label for="date_of_death">Date of Death<span class="text-danger"></span></label>
<input type="date_of_death" class="form-control" id="date_of_death"
placeholder="Enter Death Date"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['date_of_death']) ? $ticket_data['date_of_death'] : '' ?>"
name="date_of_death">
</div>
@ -178,14 +170,14 @@
<label for="date_of_intimat">Date of Intimation<span class="text-danger"></span></label>
<input type="text" class="form-control" id="date_of_intimat"
placeholder="Enter Intimation Date"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['date_of_intimat']) ? $ticket_data['date_of_intimat'] : '' ?>"
name="date_of_intimat">
</div>
<div class="form-group col-md-3">
<label for="si_amt">Sum insured<span class="text-danger"></span></label>
<input type="text" class="form-control" id="si_amt" placeholder="Enter SI"
value="<?= isset($client['short_name']) ? $client['short_name'] : '' ?>"
value="<?= isset($ticket_data['si_amt']) ? $ticket_data['si_amt'] : '' ?>"
name="si_amt">
</div>
@ -199,4 +191,39 @@
</form>
</div>
</div>
</div>
</div>
<script>
$(document).ready(function() {
var date_of_join = flatpickr("#date_of_join", {
dateFormat: "d/m/Y",
allowInput: false
});
var dob = flatpickr("#dob", {
dateFormat: "d/m/Y",
allowInput: false
});
var date_of_incep = flatpickr("#date_of_incep", {
dateFormat: "d/m/Y",
allowInput: false
});
var date_of_accident = flatpickr("#date_of_accident", {
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", {
dateFormat: "d/m/Y",
allowInput: false
});
})
</script>

View File

@ -147,8 +147,8 @@ if ($ticket_form == 1) {
<div class="col-md-4">
<div class="form-group">
<label>Branch</label>
<select id="branch" name="branch" class="form-control custom-select"
onchange="get_policies_list(this)">
<select id="emp_client_branch_data_list" name="branch"
class="form-control custom-select" onchange="get_policies_list(this)">
<option value="">Select Branch</option>
</select>
</div>
@ -156,8 +156,8 @@ if ($ticket_form == 1) {
<div class="col-md-4">
<div class="form-group">
<label>Policy</label>
<select id="policy_client_branch" name="policy_client_branch"
class="form-control custom-select" onchange="get_employee_list(this)">
<select id="emp_client_policy_data_list" name="policy_client_branch"
class="form-control custom-select" onchange="getEmpData(this)">
<option value="">Select Policy</option>
</select>
</div>
@ -267,38 +267,146 @@ function appendClients(data) {
}
function appendBranch(data) {
$('#emp_client_branch_data_list').empty();
function claimFormSubmit($form_id) {
$('#emp_client_branch_data_list').append($('<option>', {
value: '',
text: 'Select Branch'
}));
console.log('claimFormSubmit function called')
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name,
'data-name': item.branch_name,
});
console.log('$form_id ', $form_id)
let url = '<?= base_url('/ticket/create') ?>';
console.log('url ', url)
// Data to send in the AJAX request
var formData = new FormData($('#'+$form_id)[0]);
console.log('formData ', formData)
// Send AJAX request
sendAjaxRequestForGlobal(url, 'POST', formData, function(response) {
console.log('Form submitted response:', response);
if (response.status == true) {
toastr.success(response.message, 'SUCCESS');
} else {
toastr.error(response.message, 'ERROR');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while form submiting.', 'ERROR');
$('#emp_client_branch_data_list').append(option);
});
}
function appendPolicy(data) {
$('#emp_client_policy_data_list').empty();
$('#emp_client_policy_data_list').append($('<option>', {
value: '',
text: 'Select Policy'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
});
$('#emp_client_policy_data_list').append(option);
});
}
function submitClaimForm(event, form) {
event.preventDefault();
const formAction = '<?= base_url("ticket/create"); ?>';
// Show loader
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
// Collect IDs and form data
const formData = new FormData(form);
// AJAX request
$.ajax({
data: formData,
url: formAction,
type: "POST",
dataType: 'json',
processData: false,
contentType: false,
success: function(response) {
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Form submitted response:', response);
if (response.status === true) {
toastr.success(response.message, 'SUCCESS');
} else {
toastr.error(response.message, 'ERROR');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
// Hide loader
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
}
$('#emp_client_data_list').change(function() {
let client_id = $(this).val();
let client_name = $('#emp_client_data_list option:selected').data('name');
console.log('client_id', client_id);
console.log('client_name', client_name);
if (branch_list != '') {
// console.log(branch_list[client_id]);
let data = branch_list[client_id];
appendBranch(data);
}
})
$('#emp_client_branch_data_list').change(function() {
let branch_id = $(this).val();
console.log('branch_id', branch_id);
if (policy_list != '') {
// console.log(branch_list[client_id]);
let data = policy_list[branch_id];
appendPolicy(data);
}
})
function getEmpData(input) {
console.log(input)
let client_policy_id = $(input).val();
let url = '<?= base_url('util/getTheEmpDataForClaim/') ?>' + client_policy_id;
// Data to send in the AJAX request
let requestData = {
client_policy_id: client_policy_id,
};
// Send AJAX request
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status) {
toastr.success(response.message, 'SUCCESS');
} else {
toastr.warning(response.message, 'WARNING');
}
}, function(xhr, status, error) {
console.error('Error fetching data:', error);
console.error(xhr.responseText);
toastr.error('An error occurred while fetch data.', 'ERROR');
});
}
</script>