MERGE_UAT_CLAIMS_FEEDBACK_AFTER_FINAL_RELEASE

This commit is contained in:
Venba 2025-02-26 13:14:08 +00:00
commit 095d3f357c
24 changed files with 2539 additions and 1359 deletions

View File

@ -31,6 +31,7 @@ $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderM
$routes->get("sendextraparam", "ClientController::sendextraparam");
$routes->get("updateRenewalData", "ClientController::updateRenewalData");
$routes->get("updateRenewalDataNotExistingClient", "ClientController::updateRenewalDataNotExistingClient");
$routes->get("updateRenewalInsurerData", "ClientController::updateRenewalInsurerData");
// $routes->post("iAgreeForAddOn", "EmployeeRestController::iAgreeForAddOn");
// $routes->get("sendCroneRemainderMail", "DashboardController::sendCroneRemainderMail");
// $routes->post("employeeUpload", "EmployeeRestController::employeeUpload");
@ -441,13 +442,19 @@ $routes->post("/employeeRest/getVerifiedHrData", "RestAuthenticationController::
// Test initiate Claim
$routes->post('initiateClaim',"EmployeeRestController::initiateClaim");
$routes->get('departments',"EmployeeRestController::get_ticket_type");
$routes->get('get_ticket_data',"EmployeeRestController::get_ticket_data");
//api
$routes->group("/api", ["filter" => "authJWT"], function ($routes) {
$routes->post("logined", "RestAuthenticationController::logined");
$routes->post("getId", "RestAuthenticationController::getUserIdFromToken");
$routes->post('initiateClaim',"EmployeeRestController::initiateClaim");
$routes->get('get_ticket_type',"EmployeeRestController::get_ticket_type");
$routes->get('get_ticket_data',"EmployeeRestController::get_ticket_data");
});
$routes->get("getEmployeePolicy", "EmployeeRestController::getEmployeePolicy");
$routes->get("getAddOnPolicy", "EmployeeRestController::getAddOnPolicy");
$routes->group("employeeRest", ["filter" => "authJWT"], function ($routes) {

File diff suppressed because it is too large Load Diff

View File

@ -2539,10 +2539,19 @@ class EmployeeRestController extends AdminController
if($ClientPolicyValue['policy_type_id'] == 1)
{
$data['policy_terms'] = $this->policyTermsFiter($terms,'gpa');
$data['department_id'] = 3;
}else{
$data['ticket_type_id'] = 2;
}else if($ClientPolicyValue['policy_type_id'] == 6)
{
$data['policy_terms'] = $this->policyTermsFiter($terms,'gpa');
$data['ticket_type_id'] = 3;
}else if($ClientPolicyValue['policy_type_id'] == 7)
{
$data['policy_terms'] = $this->policyTermsFiter($terms,'gpa');
$data['ticket_type_id'] = 4;
}else
{
$data['policy_terms'] = $this->policyTermsFiter($terms,'gmc');
$data['department_id'] = 4;
$data['ticket_type_id'] = 1;
}
$data['client_id'] = $ClientPolicyValue['client_id'];
@ -2720,9 +2729,7 @@ class EmployeeRestController extends AdminController
}
return $finalarray;
return $finalarray;
}
@ -3103,90 +3110,195 @@ class EmployeeRestController extends AdminController
return false;
}
//Get Data from post for inserting ticket and message
public function initiateClaim()
{
$received_data = $this->request->getPost();
// print_r($received_data); die;
$employee_id = $received_data['emp_id'];
$client_policy_id = $received_data['client_policy_id'];
$insured_emp_id = $received_data['insured_emp_id'];
$sql = "select cp.policy_type_id as ticket_type_id,
cl_rm.user_id as acm_id,
cp.insurer_id as insurer_id,
cp.tpa_id as tpa_id,
emp.client_id ,
emp.id as emp_id,
emp_pol.uhid as policy_no,
emp.emp_code,
emp_pol.tpa_id as tpa_no,
emp.name as emp_name,
emp.email_corporate as emp_mail,
emp.mobile as emp_mobile,
empl.id as insured_emp_id,
empl.name as insured_name,
empl.relationship
$sql = "
select
cp.policy_type_id,
cl_rm.user_id as acm_id,
cp.insurer_id as insurer_id,
cp.tpa_id as tpa_id,
emp.client_id ,
emp.id as emp_id,
emp_pol.uhid as policy_no,
emp.emp_code,
emp_pol.tpa_id as tpa_no,
emp.name as emp_name,
emp.email_corporate as emp_mail,
emp.mobile as emp_mobile,
empl.id as insured_emp_id,
empl.name as insured_name,
empl.relationship,
CASE
WHEN cp.policy_type_id IN (2, 3, 4, 5) THEN 1
WHEN cp.policy_type_id = 1 THEN 2
WHEN cp.policy_type_id = 6 THEN 3
WHEN cp.policy_type_id = 7 THEN 4
ELSE NULL
END AS ticket_type_id
from employees emp
from employees emp
left join employees empl on empl.id = $insured_emp_id and empl.is_active = 1 and empl.emp_status = 'active'
left join employee_polices emp_pol on empl.id = emp_pol.employee_id and emp_pol.client_policy_id = $client_policy_id and emp_pol.is_active = 1
left join client_policy cp on cp.id = emp_pol.client_policy_id and cp.is_active = 1
left join client_rm cl_rm on cl_rm.client_id = empl.client_id and cl_rm.is_active = 1 and cl_rm.level = 3
left join employees empl on empl.id = $insured_emp_id and empl.is_active = 1 and empl.emp_status = 'active'
left join employee_polices emp_pol on empl.id = emp_pol.employee_id and emp_pol.client_policy_id = $client_policy_id and emp_pol.is_active = 1
left join client_policy cp on cp.id = emp_pol.client_policy_id and cp.is_active = 1
left join client_rm cl_rm on cl_rm.client_id = empl.client_id and cl_rm.is_active = 1 and cl_rm.level = 3
where emp.id = $employee_id and emp.is_active = 1 and emp.emp_status = 'active'
limit 1 ";
$fetchData = $this->employeeModel->query($sql)->getResultArray()[0];
$fetchData['claim_status_id'] = $this->claimStatusModel->select('id')->where('ticket_type', $fetchData['ticket_type_id'])->first()['id'];
$fetchData['priority'] = 1;
$fetchData['mode_of_intimation'] = 1;
$fetchData['hospital_name'] = $received_data['hospital_name'];
$emp_ticket_data = $this->employeeModel->query($sql)->getResultArray();
// print_r(db_connect()->getLastQuery()); die;
$insert_status = $this->ticketMaster->insert($fetchData);
$ticket_id = $this->ticketMaster->insertID();
if(!empty($emp_ticket_data)){
if ($insert_status && !empty($ticket_id)) {
$mail_sent_status = ($this->ticketController->sendAutoMailTrigger($ticket_id));
if (gettype($mail_sent_status) == 'array') {
$message = 'Claim Iniated Successfully';
return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200);
} else {
$mail_sent_status = json_decode($mail_sent_status);
}
// dd(gettype($mail_sent_status));
$fetchData = $emp_ticket_data[0];
$fetchData['claim_status_id'] = $this->claimStatusModel
->select('id')
->where('ticket_type', $fetchData['ticket_type_id'])
->orderBy('id', 'asc')
->first()['id'];
if ($mail_sent_status->status == 'success') {
$sent_message_data['ticket_id'] = $ticket_id;
$sent_message_data['sender'] = 'staff';
$sent_message_data['emp_mail'] = $mail_sent_status->data->params->mail;
$sent_message_data['mail_subject'] = $mail_sent_status->data->params->subject;
$sent_message_data['mail_content'] = $mail_sent_status->data->params->message;
$fetchData['priority'] = 1;
$fetchData['mode_of_intimation'] = 1;
$fetchData = array_merge($fetchData, $received_data);
$message_insert_status = $this->ticketMessage->insert($sent_message_data);
// print_r($fetchData); die;
$insert_status = $this->ticketMaster->insert($fetchData);
$ticket_id = $this->ticketMaster->insertID();
if ($message_insert_status) {
$message = 'Claim Initiated Successfully';
if ($insert_status && !empty($ticket_id)) {
$messagesData = [
'ticket_id' => $ticket_id ?? null,
'sender' => 'user',
'claim_status' => $fetchData['claim_status_id'] ?? null,
'emp_mail' => $fetchData['emp_mail'] ?? null,
'mail_subject' => $fetchData['subject'] ?? null,
'mail_content' => $fetchData['message'] ?? null,
];
if (!empty($messagesData['ticket_id'])) {
$TicketMessageModel = new TicketMessageModel();
$TicketMessageModel->insert($messagesData);
}
$mail_sent_status = ($this->ticketController->sendAutoMailTrigger($ticket_id));
if (gettype($mail_sent_status) == 'array') {
$message = 'Claim Iniated Successfully';
return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200);
} else {
$message = 'Claim Initiated, Mail Sent Successfully';
$this->myLogger->logme('error', "Claim initiated, Mail sent Successfully, Failed to store message:$ticket_id ");
$mail_sent_status = json_decode($mail_sent_status);
}
// dd(gettype($mail_sent_status));
if ($mail_sent_status->status == 'success') {
$sent_message_data['ticket_id'] = $ticket_id;
$sent_message_data['sender'] = 'staff';
$sent_message_data['emp_mail'] = $mail_sent_status->data->params->mail;
$sent_message_data['mail_subject'] = $mail_sent_status->data->params->subject;
$sent_message_data['mail_content'] = $mail_sent_status->data->params->message;
$message_insert_status = $this->ticketMessage->insert($sent_message_data);
if ($message_insert_status) {
$message = 'Claim Initiated Successfully';
return $this->respond(['status' => true, 'code' => 200, 'message' => $message], 200);
} else {
$message = 'Claim Initiated, Mail Sent Successfully';
$this->myLogger->logme('error', "Claim initiated, Mail sent Successfully, Failed to store message:$ticket_id ");
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
}
} else {
$message = 'Claim Initiated, Failed to send Mail ';
$this->myLogger->logme('error', "Claim initiated, Failed to send Mail :$ticket_id ");
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
}
} else {
$message = 'Claim Initiated, Failed to send Mail ';
$this->myLogger->logme('error', "Claim initiated, Failed to send Mail :$ticket_id ");
$message = 'Something Went Wrong';
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
}
} else {
$message = 'Something Went Wrong';
return $this->respond(['status' => false, 'code' => 400, 'message' => $message], 200);
}else{
return $this->response->setJSON(['status' => false, 'code' => 200, 'message' => 'The employee is not active.'])->setStatusCode(404);
}
}
//department
public function get_ticket_type()
{
$ticket_type = $this->ticketController->ticketType;
$ticket_type = array_map(fn($value, $key) => (object) ['id' => $key, 'name' => $value], array_values($ticket_type), array_keys($ticket_type));
// print_r($ticket_type); die;
return $this->response->setJSON(['ticket_type' => $ticket_type])->setStatusCode(200);
}
//ticket data
public function get_ticket_data()
{
$priorityType = $this->ticketController->priorityType;
$modeOFIntimate = $this->ticketController->modeOFIntimate;
$claimType = $this->ticketController->claimType;
$relationshipType = $this->ticketController->relationshipType;
$ticketTypeArray = $this->ticketController->ticketType;
$emp_id = $this->request->getGet('emp_id');
$ticket_type = $this->request->getGet('ticket_type') ?? null;
$ticket_id = $this->request->getGet('ticket_id') ?? null;
// dd($emp_id);
if (empty($emp_id)) {
return $this->response->setJSON(['status' => false, 'code' => 200, 'message' => 'emp_id is required.'])->setStatusCode(404);
}
$TicketMasterModel = new TicketMasterModel();
$ticket_data = $TicketMasterModel->get_ticket_data($emp_id, $ticket_type, $ticket_id);
if (!empty($ticket_data)) {
$client_claim_status = [
'Received' => [1, 2, 3, 4, 15, 16, 17, 18, 25, 26, 27, 28, 35, 36, 37, 38],
'Rejected' => [8, 49, 55, 60],
'Cancelled' => [13, 47, 53, 58],
'Returned' => [14, 48, 54, 59],
'Closed' => [12, 22, 32, 42],
'Approved' => [9, 20, 30, 40],
'Settled' => [11, 24, 34],
'Under Process' => [5, 6, 7, 10, 19, 23, 45, 50, 29, 33, 51, 39, 43, 56],
];
foreach ($ticket_data as $key => $value) {
foreach ($client_claim_status as $claim_key => $claim_value) {
if (in_array($value['claim_status_id'], $claim_value)) { // Corrected argument order
$ticket_data[$key]['claim_status'] = $claim_key ?? null; // Assign back to the main array
}
}
$ticket_data[$key]['priority_type'] = $priorityType[$value['priority']] ?? null;
$ticket_data[$key]['mode_of_intimate_type'] = $modeOFIntimate[$value['mode_of_intimation']] ?? null;
$ticket_data[$key]['relationship_type'] = ucfirst($value['relationship']) ?? null;
$claimPrimaryTypey = "1";
if (in_array($value['claim_type'], [2, 3, 4])) {
$claimPrimaryTypey = "2";
}
$ticket_data[$key]['claim_type_value'] = $claimType[$claimPrimaryTypey][$value['claim_type']] ?? null;
$ticket_data[$key]['ticket_policy_type'] = $ticketTypeArray[$value['ticket_type_id']] ?? null;
}
}
return $this->response->setJSON(['ticket_data' => $ticket_data])->setStatusCode(200);
}
}

View File

@ -287,6 +287,10 @@ class MasterController extends AdminController
$data['deletion_add_day'] = 1;
}
if($this->request->getPost('is_multi_event')){
$data['is_multi_event'] = 1;
}
$data['created_by'] = get_session_userid();
$data['insurer_logo'] = $file_name;
@ -371,6 +375,12 @@ class MasterController extends AdminController
$data['deletion_add_day'] = 0;
}
if($this->request->getPost('is_multi_event')){
$data['is_multi_event'] = 1;
}else{
$data['is_multi_event'] = 0;
}
$update = $this->insurerModel->update($id,$data);
if($update){
echo json_encode(array("status" => true , 'data' => $data));
@ -1723,7 +1733,8 @@ class MasterController extends AdminController
'excel' => WRITEPATH . 'uploads/excel/',
'statements' => WRITEPATH . 'uploads/statements/',
'import_excel' => WRITEPATH . 'uploads/import_excel/',
'logs' => WRITEPATH . 'uploads/logs/',
'logs' => WRITEPATH . 'logs',
'session' => WRITEPATH . 'session',
'client_kyc_documents' => WRITEPATH . 'uploads/client_kyc_documents/',
'tmp' => WRITEPATH . 'tmp/',
'e_card_imgs' => ROOTPATH . 'public/e_card_imgs',
@ -1732,6 +1743,7 @@ class MasterController extends AdminController
'logo' => ROOTPATH . 'public/uploads/logo/',
'template_bg' => ROOTPATH . 'public/uploads/template_bg/',
'attachments' => WRITEPATH . 'uploads/attachments/',
'cache' => WRITEPATH . 'cache',
'sample_import_excel' => ROOTPATH . 'public/sample_import_excel',
'lead_files' => WRITEPATH . 'uploads/lead_files/',
];

View File

@ -274,7 +274,7 @@ class PolicyTransactionController extends BaseController
// Separate Insurer and TPA Branch IDs and IDs
if(isset($data['insurer_id']) && !empty($data['insurer_id'])){
list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']);
if (isset($data['tpa'])) {
if (isset($data['tpa']) && !empty($data['tpa'])) {
list($data['tpa_branch_id'], $data['tpa_id']) = explode('-', $data['tpa']);
}
}
@ -1117,7 +1117,7 @@ class PolicyTransactionController extends BaseController
// Separate Insurer and TPA Branch IDs and IDs
if(isset($data['insurer_id']) && !empty($data['insurer_id'])){
list($data['insurer_branch_id'], $data['insurer_id']) = explode('-', $data['insurer_id']);
if (isset($data['tpa'])) {
if (isset($data['tpa']) && !empty($data['tpa'])) {
list($data['tpa_branch_id'], $data['tpa_id']) = explode('-', $data['tpa']);
}
}
@ -2700,7 +2700,7 @@ class PolicyTransactionController extends BaseController
// Build query
$db = db_connect();
$builder = $db->table("cash_deposit")
->where('cd_ac_no', $cd_ac_no)
->where('cd_ac_pk', $cd_ac_no)
->where('is_active', 1)
->orderBy('id', 'desc')
->limit(1);
@ -2715,6 +2715,8 @@ class PolicyTransactionController extends BaseController
'status' => true,
'code' => 200,
'data' => $result,
'base_premium' => $base_premium,
'cd_ac_no' => $cd_ac_no,
'base_premium_greater_than_balance' => $base_premium_greater_than_balance,
], 200);
}

View File

@ -26,14 +26,15 @@ class TicketController extends BaseController
use ResponseTrait;
protected $myLogger;
protected $ticketType;
protected $priorityType;
protected $relationshipType;
protected $modeOFIntimate;
protected $claimType;
protected $claimStatus;
protected $placeHolders;
protected $extraFields;
public $ticketType;
public $priorityType;
public $relationshipType;
public $modeOFIntimate;
public $claimType;
public $claimStatus;
public $placeHolders;
public $extraFields;
public $nonIDReason;
protected $clientModel;
protected $ticketMasterModel;
@ -98,7 +99,8 @@ class TicketController extends BaseController
4 => "Trigger 4",
5 => "Trigger 5",
6 => "Trigger 6",
7 => "Trigger 7"
7 => "Trigger 7",
8 => "Trigger 8",
];
$this->placeHolders = [
@ -114,7 +116,8 @@ class TicketController extends BaseController
'((AUTO_QUERY_CONTENT))' => 'auto_query_content',
];
$this->extraFields = [
1 => ['non_id_reason'],
10 => ['pay_initiate_date'],
3 => ['raised_date'],
4 => ['raised_date'],
5 => ['claim_number', 'registration_date'],
@ -137,6 +140,13 @@ class TicketController extends BaseController
53 => ['cancel_remark'],
58 => ['cancel_remark'],
];
$this->nonIDReason = [
"Newborn Baby" => "Newborn Baby",
"Newly Wedded Spouse" => "Newly Wedded Spouse",
"Policy Pending" => "Policy Pending",
"New Joinee" => "New Joinee",
"Exceptional Case" => "Exceptional Case"
];
$this->ticketMasterModel = new TicketMasterModel();
$this->claimStatus = new TicketClaimStatusModel();
@ -296,7 +306,8 @@ class TicketController extends BaseController
'ticket_type' => $this->ticketType,
'priorityType' => $this->priorityType,
'relationshipType' => $this->relationshipType,
'modeOFIntimate' => $this->modeOFIntimate
'modeOFIntimate' => $this->modeOFIntimate,
'nonIDReason' => $this->nonIDReason
];
switch ($ticket_type) {
@ -528,6 +539,12 @@ class TicketController extends BaseController
$ticket_data['settled_date'] = change_date_format($ticket_data['settled_date'], null, $out_put_format);
}
if (empty($ticket_data['pay_initiate_date'])) {
$ticket_data['pay_initiate_date'] = null;
} else {
$ticket_data['pay_initiate_date'] = change_date_format($ticket_data['pay_initiate_date'], null, $out_put_format);
}
return $ticket_data;
}
@ -593,6 +610,17 @@ class TicketController extends BaseController
$data['policy_type'] = $this->ticketType;
$data['placeHolders'] = $this->placeHolders;
$data['ticket_data'] = $this->ticketMailTemplateModel->where('is_active', 1)->findAll();
foreach ($data['ticket_data'] as $key => $ticket_data) {
$tooltip_array = $this->claimStatus->select('claim_status')->where('ticket_type',$data['ticket_data'][$key]['ticket_type'])->where('trigger_type',$data['ticket_data'][$key]['trigger_type'])->where('is_active',1)->first();
if (isset($tooltip_array) && $tooltip_array != null){
$data['ticket_data'][$key]['tool_tip'] = $tooltip_array['claim_status'];
}else{
$data['ticket_data'][$key]['tool_tip'] =$data['ticket_data'][$key]['template_name'];
}
}
// dd($data['ticket_data']);
$data['ticket_type'] = $this->ticketType;
$data['trigger_type'] = $this->triggerType;
return $this->loadLayout('ticket_mail_template', $data);
@ -621,6 +649,21 @@ class TicketController extends BaseController
} elseif ($action == 2) {
$table_id = (int)$this->request->getPost('id');
$data = $this->ticketMailTemplateModel->where('id', $table_id)->where('is_active', 1)->first();
if ($data && isset($data['ticket_type']) && isset($data['trigger_type'])) {
$tooltip_array = $this->claimStatus->select('claim_status')
->where('ticket_type', $data['ticket_type'])
->where('trigger_type', $data['trigger_type'])
->where('is_active', 1)
->first();
$data['tool_tip'] = (isset($tooltip_array['claim_status']))
? $tooltip_array['claim_status']
: $data['template_name'];
} else {
// Handle case where $data is null or missing required fields
$data = $data ?: []; // Ensure $data is an array if null
$data['tool_tip'] = $data['template_name'];
}
if ($data) {
return $this->respond(['status' => true, 'data' => $data], 200);
} else {
@ -1381,6 +1424,12 @@ class TicketController extends BaseController
$lastMatchedStatus = $status;
}
}
if($lastMatchedStatus == 1){
if(!empty($incoming_form_values['tpa_no'])){
$lastMatchedStatus = 2;
}
}
return $lastMatchedStatus;
}

View File

@ -259,6 +259,7 @@ class ClientPolicyModel extends Model
->select('SUM(CASE WHEN sub_type = 3 THEN amount ELSE 0 END) AS total_refund')
->where('client_id', $clientId)
->where('insurer_id', $insurerId)
->where('cash_deposit.is_active', 1)
->get()
->getRow();
}

View File

@ -240,9 +240,9 @@ class EmployeeModel extends Model
return $results;
}
public function getEmployeeByEmployeeCode($emp_code)
public function getEmployeeByEmployeeCode($emp_code, $client_policy_id = null, $client_id = null)
{
return $this->select("
$query = $this->select("
employees.id AS emp_id,
employees.name AS emp_name,
employees.emp_code,
@ -255,9 +255,22 @@ class EmployeeModel extends Model
->join('employee_polices', 'employees.id = employee_polices.employee_id', 'left')
->where('employees.is_active', 1)
->where('employee_polices.is_active', 1)
->where('employees.emp_code', $emp_code)
->groupBy('employees.id')
->findAll();
->where('employees.emp_code', $emp_code);
if(!empty($client_id)){
$query->where('employees.client_id', $client_id);
}
if(!empty($client_policy_id)){
$query->where('employee_polices.client_policy_id', $client_policy_id);
}
$query->groupBy('employees.id');
$data = $query->findAll();
return $data;
}
}

View File

@ -501,8 +501,8 @@ class PolicyTransactionModel extends Model
->join('user_profiles', 'policy_transaction.created_by = user_profiles.id', 'left')
->join('vehicle', 'policy_transaction.vehicle_id = vehicle.id', 'left')
->join('policy_type', 'policy_transaction.policy_type_id = policy_type.id', 'left')
->join('insurers', 'policy_transaction.insurer_id = insurers.id', 'left')
->join('insurer_branch', 'policy_transaction.insurer_branch_id = insurer_branch.id', 'left')
->join('insurers', 'pt_co_share_details.insurer_id = insurers.id', 'left')
->join('insurer_branch', 'pt_co_share_details.insurer_branch_id = insurer_branch.id', 'left')
->join('tpa', 'policy_transaction.tpa_id = tpa.id', 'left')
->join('tpa_branch', 'policy_transaction.tpa_branch_id = tpa_branch.id', 'left')
->join('user_profiles AS sales_user', 'policy_transaction.sales_generated_by = sales_user.id', 'left')

View File

@ -68,6 +68,10 @@ class TicketMasterModel extends Model
'return_remark',
'cancel_remark',
'awb_no_courier_name',
'non_id_reason',
'head_rejection_reason',
'pay_initiate_date',
];
@ -676,5 +680,27 @@ class TicketMasterModel extends Model
return $result;
}
}
//api
public function get_ticket_data($emp_id, $ticket_type = null, $ticket_id = null)
{
$query = $this->select('ticket_master.*, tms.mail_subject as subject')
->join('ticket_messages tms', 'ticket_master.id = tms.ticket_id', 'left')
->where('ticket_master.is_active', 1)
->where('ticket_master.emp_id', $emp_id);
if (!empty($ticket_id)) {
$query->where('ticket_master.id', $ticket_id);
}
if (!empty($ticket_type)) {
$query->where('ticket_master.ticket_type_id', $ticket_type);
}
$data = $query->findAll();
// dd($data, db_connect()->getLastQuery());
return $data;
}
}

View File

@ -103,7 +103,8 @@ input:checked + .slider:before {
</div>
<div class="form-row">
<div class="form-group col-md-4">
<div class="form-group col-md-2">
<label for="html">Insurer Type</label><br>
<div style="margin-top: 10px;">
<input type="radio" id="html" name="type" value="pvt" <?= isset($insurer['type']) && $insurer['type'] == 'pvt' ? 'checked' : '' ?>>
@ -112,6 +113,15 @@ input:checked + .slider:before {
<label for="css">PSU</label>
</div>
</div>
<div class="form-group col-md-2">
<label class="switch" style="position: absolute;top: 34px;left: 17px;">
<input id="is_multi_event" type="checkbox" name="is_multi_event" <?= (isset($insurer['is_multi_event']) && $insurer['is_multi_event'] == 1) ? 'checked' : '' ?>>
<span class="slider round" style="height: 27px;"></span>
</label>
<label for="deletion_add_day" style="position: relative;top: 30px;left: 82px;">Multievent Export</label>
</div>
</div>
<div class="form-row">
@ -133,7 +143,7 @@ input:checked + .slider:before {
<input type="file" class="form-control" onchange="PreviewImage();" id="insurer_logo" name="insurer_logo" accept="image/jpeg, image/jpg, image/png">
</div>
<div class="form-group col-md-4 float-right" style="position: relative;left: 40px;bottom: 28px;">
<div class="form-group col-md-4 float-right" style="position: relative;left: 90px;top: 30px;">
<img src="<?= isset($insurer['insurer_logo']) && !empty($insurer['insurer_logo']) ? base_url() . "public/uploads/logo/" . $insurer['insurer_logo'] : base_url() . "public/assets/images/avatar_2x.png" ?>" width="100" height="100" id="uploadPreview" class="avatar img-circle img-thumbnail" alt="avatar" />
</div>

View File

@ -804,7 +804,7 @@
$(`#tpa_${i}`).val(tpa).trigger('change');
$(`#proposed_insurer_${i}`).val(insurer).trigger('change');
$(`#proposed_tpa_${i}`).val(tpa).trigger('change');
$('#policy_start_date').val(res.data.policy_end_date);
$('#policy_start_date').val(res.new_start_date);
$('#policy_end_date').val(res.end_date);
console.log($(`#policy_type_id_${i}_${random_id}`));
console.log($(`#insurer_${i}`));

View File

@ -1012,11 +1012,29 @@ $("#policyJsonForm").submit(function(event) {
return;
}
var specialConditions = [];
$(".removeDom").each(function () {
var isChecked = $(this).find("input[name='special_condition_display[]']").is(":checked");
if (isChecked) {
var label = $(this).find("input[name='special_condition_label[]']").val();
var input = $(this).find("input[name='special_condition_input[]']").val();
specialConditions.push({ [label]: input });
}
});
console.log("specialConditions", specialConditions);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var formData = new FormData($('#policyJsonForm')[0]);
var policy_form_action = '<?= base_url("client/policy/policyGMCTerms") ?>';
formData.append("special_condition_display_value", JSON.stringify(specialConditions));
$.ajax({
data: formData,
@ -1140,6 +1158,25 @@ $('body').on('click', '.btnPolicyMaster', function() {
element.value = " ";
} else {
element.value = jsonObject[key][index];
if (key.includes("special_condition_label")) {
let checkbox = $(element).closest('.form-group').find('input[name="special_condition_display[]"]');
console.log("First element:", element);
if (checkbox.length) {
console.log("Checkbox found:", checkbox);
// Correct way to set the 'id' attribute
let formattedValue = jsonObject[key][index].replace(/[\s\-\/,&]+/g, '').toLowerCase();
console.log('formattedValue', formattedValue);
checkbox.attr('id', formattedValue + '_display');
console.log("Updated Checkbox:", checkbox);
} else {
console.log("Checkbox not found for:", element);
}
}
}
});
}
@ -1534,7 +1571,7 @@ function specialCondition(count = 0) {
var index = $('.modifyclassinput').length;
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
<div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="special_condition_display_input[]" id="special_condition_display_input" class="unchecked" checked>
<input type="checkbox" style="margin-top: 12px" name="special_condition_display[]" id="special_condition_display" class="unchecked" checked>
</div>
<label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;">
<input class="form-control" name="special_condition_label[]" id="special_condition_label[]" style="position: relative;right: 5px;">
@ -1736,8 +1773,8 @@ function processJsonObject(jsonObject) {
for (let key in jsonObject) {
if (typeof jsonObject[key] === 'object' && !Array.isArray(jsonObject[key])) {
console.log('enrollment_display_key');
console.log(jsonObject[key]);
// console.log('enrollment_display_key');
// console.log(jsonObject[key]);
for (let innerKey in jsonObject[key]) {
@ -1759,13 +1796,13 @@ function processJsonObject(jsonObject) {
let base_id = innerKey.replace(/[\s\-\/,&]+/g, '').toLowerCase();
if (keysToCheck.includes(innerKey)) {
console.log("Key found: " + innerKey);
// console.log("Key found: " + innerKey);
base_id = innerKey.replace(/[\s\-\/]+/g, '_').toLowerCase();
} else if (innerKey == "Claim Intimation Clause") {
console.log("Key found: " + innerKey);
// console.log("Key found: " + innerKey);
base_id = "days_of_discharge";
} else if (innerKey == "Claim Submission") {
console.log("Key found: " + innerKey);
// console.log("Key found: " + innerKey);
base_id = "days_from_dod";
}
@ -1778,4 +1815,5 @@ function processJsonObject(jsonObject) {
}
}
}
</script>

View File

@ -567,11 +567,28 @@ $("#policyGPATerms").submit(function(event) {
return;
}
var specialConditions = [];
$(".removeDom").each(function () {
var isChecked = $(this).find("input[name='gpa_special_condition_display[]']").is(":checked");
if (isChecked) {
var label = $(this).find("input[name='gpa_special_condition_label[]']").val();
var input = $(this).find("input[name='gpa_special_condition_input[]']").val();
specialConditions.push({ [label]: input });
}
});
console.log("gpa_specialConditions", specialConditions);
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var formData = new FormData($('#policyGPATerms')[0]);
var policy_form_action = '<?= base_url("client/terms/gpa_create") ?>';
formData.append("gpa_special_condition_display_value", JSON.stringify(specialConditions));
$.ajax({
data: formData,
@ -691,6 +708,24 @@ $('body').on('click', '.btnPolicyMaster', function() {
gpaJsonObjectForSpecialCondition[key][
index
];
if (key.includes("gpa_special_condition_label")) {
let checkbox = $(element).closest('.form-group').find('input[name="gpa_special_condition_display[]"]');
console.log("First element:", element);
if (checkbox.length) {
console.log("Checkbox found:", checkbox);
// Correct way to set the 'id' attribute
let formattedValue = gpaJsonObjectForSpecialCondition[key][index].replace(/[\s\-\/,&]+/g, '').toLowerCase();
console.log('formattedValue', formattedValue);
checkbox.attr('id', formattedValue + '_display');
console.log("Updated Checkbox:", checkbox);
} else {
console.log("Checkbox not found for:", element);
}
}
}
});
}
@ -713,7 +748,7 @@ $('body').on('click', '.btnPolicyMaster', function() {
console.log('enrollment_display_key');
console.log(gpaJsonObjectForSpecialCondition[key]);
processJsonObject(gpaJsonObjectForSpecialCondition);
processJsonObject2(gpaJsonObjectForSpecialCondition);
}
@ -838,7 +873,9 @@ function specialConditionForGPA(count = 0) {
var index = $('.modifyclassinput').length;
var appendElement = `<div class="form-group col-md-6 form-group-client-policy-masters removeDom">
<div class="col-md-1">
<input type="checkbox" style="margin-top: 12px" name="gpa_special_condition_display[]" id="special_condition_display" class="unchecked" checked>
</div>
<label for="specialconditionlabel" class="special_condition_label[]" style="width: 450px;position: relative;bottom: 6px;">
<input class="form-control" name="gpa_special_condition_label[]" id="gpa_special_condition_label[]" style="position: relative;right: 5px;">
<span class="specialConditionClose" style="color: red; float: right;position: relative;bottom: 28px;left: 15px;">X</span>
@ -951,7 +988,7 @@ function inArray(key, array) {
return array.includes(key);
}
function processJsonObject(jsonObject) {
function processJsonObject2(jsonObject) {
if (typeof jsonObject !== 'object' || Array.isArray(jsonObject)) {
console.log("jsonObject Input is not a valid object.");
@ -962,8 +999,8 @@ function processJsonObject(jsonObject) {
for (let key in jsonObject) {
if (typeof jsonObject[key] === 'object' && !Array.isArray(jsonObject[key])) {
console.log('enrollment_display_key');
console.log(jsonObject[key]);
// console.log('enrollment_display_key');
// console.log(jsonObject[key]);
for (let innerKey in jsonObject[key]) {
@ -983,20 +1020,20 @@ function processJsonObject(jsonObject) {
base_id = base_id.charAt(0).toLowerCase() + base_id.slice(1);
if (keysToCheck.includes(innerKey)) {
console.log("Key found: " + innerKey);
// console.log("Key found: " + innerKey);
base_id = innerKey.replace(/[\s\-\/]+/g, '_').toLowerCase();
} else if (innerKey == "Medical Expenses / Medical Extension (IPD)") {
console.log("Key found: " + innerKey);
// console.log("Key found: " + innerKey);
base_id = "medical_expenses_medical_extension";
} else if (innerKey == "Terrorism") {
console.log("Key found: " + innerKey);
// console.log("Key found: " + innerKey);
base_id = "gpa_terrorism";
}
let display_id = base_id + "_display";
$('#' + display_id).prop('checked', true);
console.log('display_id : ', display_id);
console.log($('#' + display_id))
// console.log('display_id : ', display_id);
// console.log($('#' + display_id))
}
} else {
console.log(`${key} is not an object.`);

View File

@ -1314,8 +1314,8 @@ $(document).ready(function(){
$(document).on('change', 'input[type="checkbox"][name="co_share_type[]"]', function() {
$('[name="base_premium[]"]').val("");
$('[name="co_premium[]"]').val("");
// $('[name="base_premium[]"]').val("");
// $('[name="co_premium[]"]').val("");
let isAnyChecked = $('input[type="checkbox"][name="co_share_type[]"]:checked').length > 1;
@ -1764,7 +1764,7 @@ function checkAndDistributeTax(input)
function amountCalculation(input) {
console.log('amountCalculation - ' + input);
console.log('amountCalculation : ' + input);
let selectedOption = $('#policy_type_id').find('option:selected');
let bap = selectedOption.data('bap');
@ -1816,10 +1816,8 @@ function amountCalculation(input) {
// Calculate GST percentage
let gst_per = igst;
if (igst === 0) {
console.log('called' + cgst + sgst);
gst_per = parseFloat(cgst) + parseFloat(sgst);
// gst_per = (cgst) + (sgst);
console.log(gst_per);
}
console.log('gst_per', gst_per);
@ -3543,7 +3541,7 @@ $('#setInsurerCount').on('click', function() {
function addInsurerColumn() {
insurerCount++;
insurerCount = insurerCount + 1;
// hidePermiumDetailsBasedOnTheTeam()
@ -4087,6 +4085,7 @@ function populateTable(dataArray, cd_ac_pk) {
// console.log('data.cd_ac_pk', cd_ac_pk)
if(data.co_share_type == 1){
if(index == 0) { index = 1;}
getCdAmount(cd_ac_pk, index);
}
});
@ -4232,7 +4231,7 @@ function checkCDAmountForBasePremium(input) {
function getCdAmount(cd_ac_pk, increment){
increment = increment + 1
// increment = increment + 1
console.log('cd_ac_pk', cd_ac_pk);
console.log('increment', increment);
@ -4266,4 +4265,34 @@ function getCdAmount(cd_ac_pk, increment){
}
$('#bro_payable_by').on('change', function(){
var columnIndexes = [];
$('#insurerTable thead th').each(function(index) {
if(index == 0){
console.log("columnIndexes is ", index);
}else{
amountCalculation(index);
}
columnIndexes.push(index);
});
console.log("columnIndexes", columnIndexes);
});
$(document).on('change', '#insurerTable input, #insurerTable select, #insurerTable textarea', function() {
console.log('Changed in table:', $(this).attr('name'), 'Value:', $(this).val());
getColumnIndexes()
});
function getColumnIndexes() {
$('#insurerTable thead th').each(function(index) {
if (index === 0) {
console.log("columnIndexes is", index);
} else {
amountCalculation(index);
}
});
}
</script>

View File

@ -319,7 +319,7 @@ table.dataTable tbody td {
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" onclick="getPolicyTransactionDataForEdit('<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
</a>
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<a class="dropdown-item delete" data-id="<?= $row['id'];?>" onclick="removePolicyTransaction(this, '<?= htmlspecialchars($row['id'], ENT_QUOTES) ?>')">
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
</a>
</div>
@ -370,25 +370,25 @@ table.dataTable tbody td {
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;
const items = originalDropdown.querySelectorAll('.dropdown-item');
items.forEach(item => {
const newItem = item.cloneNode(true);
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;
@ -401,51 +401,56 @@ document.addEventListener("DOMContentLoaded", function () {
return;
}
// Hide any active dropdown
if (activeDropdown) {
// Close any existing dropdown
if (activeDropdown && activeDropdown !== customDropdown) {
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();
const id = this.getAttribute('data-id');
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
// Handle edit button
if (this.classList.contains('btnEdit') && id) {
getPolicyTransactionDataForEdit(id);
}
// Handle delete button
else if (this.classList.contains('delete') && id) {
removePolicyTransaction(this, id);
}
// Handle other links
else {
const href = this.getAttribute('href');
if (href && href !== '#' && href !== 'javascript: void(0);') {
window.location.href = href;
}
}
// Close the dropdown after handling the click
// Close dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
}, { once: true });
});
});
// Close dropdown when clicking outside
// Close dropdown on outside click
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
@ -1486,7 +1491,7 @@ function onlyNumbers(event)
<script>
$(document).ready(function() {
getURLParams()
// getURLParams()
$('#client_id_for_search').select2();
$('#insurer_id_for_search').select2();
$('#policy_type_for_search').select2();
@ -1531,50 +1536,50 @@ function objectToQueryString(obj)
return Object.keys(obj).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`).join('&');
}
function getURLParams()
{
const url = new URL(window.location.href);
const params = new URLSearchParams(url.search);
// function getURLParams()
// {
// const url = new URL(window.location.href);
// const params = new URLSearchParams(url.search);
const startDate = params.get('start_date') || 0; // Default to 0 if not found
const endDate = params.get('end_date') || 0; // Default to 0 if not found
const client_id = params.get('client_id') || 0; // Default to 0 if not found
const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found
const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
const date_type = params.get('date_type') || 0; // Default to 0 if not found
const issuer = params.get('issuer') || 0; // Default to 0 if not found
const status = params.get('status') || 0; // Default to 0 if not found
// const startDate = params.get('start_date') || 0; // Default to 0 if not found
// const endDate = params.get('end_date') || 0; // Default to 0 if not found
// const client_id = params.get('client_id') || 0; // Default to 0 if not found
// const insurer_id = params.get('insurer_id') || 0; // Default to 0 if not found
// const policy_type_id = params.get('policy_type_id') || 0; // Default to 0 if not found
// const date_type = params.get('date_type') || 0; // Default to 0 if not found
// const issuer = params.get('issuer') || 0; // Default to 0 if not found
// const status = params.get('status') || 0; // Default to 0 if not found
hideDateField(date_type)
// hideDateField(date_type)
// console.log('startDate', startDate)
// console.log('endDate', endDate)
// console.log('client_id', client_id)
// console.log('insurer_id', insurer_id)
// console.log('policy_type_id', policy_type_id)
// console.log('date_type', date_type)
// console.log('issuer', issuer)
// console.log('status', status)
// // console.log('startDate', startDate)
// // console.log('endDate', endDate)
// // console.log('client_id', client_id)
// // console.log('insurer_id', insurer_id)
// // console.log('policy_type_id', policy_type_id)
// // console.log('date_type', date_type)
// // console.log('issuer', issuer)
// // console.log('status', status)
// Log the values or use them as needed
// console.log('Start Date:', startDate);
// console.log('End Date:', endDate);
// // Log the values or use them as needed
// // console.log('Start Date:', startDate);
// // console.log('End Date:', endDate);
if (startDate != 0 && endDate != 0) {
setTimeout(function(){
$('#start_date').val(startDate)
$('#end_date').val(endDate)
$('#client_id_for_search').val(client_id).change()
$('#insurer_id_for_search').val(insurer_id).change()
$('#policy_type_for_search').val(policy_type_id).change()
$('#date_type').val(date_type)
$('#issuer_for_search').val(issuer)
$('#policy_status_for_search').val(status)
},1000)
// if (startDate != 0 && endDate != 0) {
// setTimeout(function(){
// $('#start_date').val(startDate)
// $('#end_date').val(endDate)
// $('#client_id_for_search').val(client_id).change()
// $('#insurer_id_for_search').val(insurer_id).change()
// $('#policy_type_for_search').val(policy_type_id).change()
// $('#date_type').val(date_type)
// $('#issuer_for_search').val(issuer)
// $('#policy_status_for_search').val(status)
// },1000)
}
// }
}
// }
$(function() {

View File

@ -24,28 +24,28 @@
<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">
<i class="mdi mdi-contacts mr-1"></i>
<i class="mdi mdi-ticket-account"></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">
<i class="fa fa-file mr-1"></i>
<i class="mdi mdi-message-processing"></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">
<i class="mdi mdi-account-switch mr-1"></i>
<span class="d-none d-sm-inline-block">Note</span>
<i class="mdi mdi-note-text"></i>
<span class="d-none d-sm-inline-block">Notes</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">
<i class="mdi mdi-source-branch mr-1"></i>
<i class="mdi mdi-history"></i>
<span class="d-none d-sm-inline-block">History</span>
</a>
</li>
@ -235,9 +235,44 @@ function showConfirmationModal(event) {
console.log($('#ticket_form_data')[0])
submitClaimForm(event, $('#ticket_form_data')[0]); // Fixed selector
} else if (result.isDenied) {
$('#is_head_approved').val(2);
console.log($('#ticket_form_data')[0])
submitClaimForm(event, $('#ticket_form_data')[0]); // Fixed selector
// Show second Swal for rejection reason
Swal.fire({
title: "Rejection Reason",
text: "Please provide a reason for rejection",
input: "textarea",
inputPlaceholder: "Enter your reason here...",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#6c757d",
confirmButtonText: "Submit",
cancelButtonText: "Back"
}).then((reasonResult) => {
if (reasonResult.isConfirmed) {
// Check if reason is not empty
if (reasonResult.value && reasonResult.value.trim() !== "") {
$('#is_head_approved').val(2);
$('#rejection_reason').val(reasonResult.value.trim());
console.log($('#ticket_form_data')[0]);
$('#head_rejection_reason').val(reasonResult.value.trim());
submitClaimForm(event, $('#ticket_form_data')[0]);
} else {
// Alert if reason is empty
Swal.fire({
title: "Error",
text: "Rejection reason cannot be empty",
icon: "error",
confirmButtonColor: "#3085d6"
}).then(() => {
// Go back to the rejection reason dialog
showConfirmationModal(event);
});
}
} else {
// If canceled, go back to first Swal
showConfirmationModal(event);
}
});
} else {
$('#is_head_approved').val(0);
return false;

View File

@ -2,18 +2,18 @@
<div class="col-12">
<div class="<?= !isset($ticket_data) ? "card" : "" ?>" style="margin-right: 23px;">
<div class="card-body">
<?php if(!isset($ticket_data)){ ?>
<!-- Header Section -->
<div class="row mb-3">
<div class="col-6 d-flex align-items-center">
<h4 class="mb-0">Claim GMC</h4>
<?php if (!isset($ticket_data)) { ?>
<!-- Header Section -->
<div class="row mb-3">
<div class="col-6 d-flex align-items-center">
<h4 class="mb-0">Claim GMC</h4>
</div>
<div class="col-6 text-right">
<a href="<?= base_url('ticket/list'); ?>" aria-label="Back to ticket list">
<i class="fas fa-arrow-left" style="font-size: 17px;"></i>
</a>
</div>
</div>
<div class="col-6 text-right">
<a href="<?= base_url('ticket/list'); ?>" aria-label="Back to ticket list">
<i class="fas fa-arrow-left" style="font-size: 17px;"></i>
</a>
</div>
</div>
<?php } ?>
<form role="form" class="parsley-examples" method="post" id="ticket_form_data" onsubmit="submitClaimForm(event, this)" enctype="multipart/form-data">
@ -21,8 +21,122 @@
<input type="hidden" id="ticket_master_id" name="ticket_master_id" value="<?= isset($ticket_data['id']) ? $ticket_data['id'] : '' ?>">
<input type="hidden" id="is_head_approved" name="is_head_approved" value="<?= isset($ticket_data['is_head_approved']) ? $ticket_data['is_head_approved'] : '' ?>">
<input type="hidden" id="extra_fields_array_for_validate" name="extra_fields_array_for_validate" value='<?= isset($extra_fields_array_for_validate) && !empty($extra_fields_array_for_validate) ? json_encode($extra_fields_array_for_validate) : "[]" ?>'>
<input type="hidden" id="head_rejection_reason" name="head_rejection_reason">
<div class="form-group">
<h5>Employee Details</h5>
<hr>
<!-- first_data_points -->
<div class="form-row">
<div class="form-group col-md-3">
<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($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($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" 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">
<label for="relationship"> Relationship <span class="text-danger"></span></label>
<select class="form-control" id="relationship" name="relationship">
<option value="0">Select Relationship</option>
<?php
if (isset($relationshipType) && count($relationshipType)) {
foreach ($relationshipType as $key => $value) {
$selected = (isset($ticket_data) && $ticket_data['relationship'] == $key) ? 'selected' : '';
echo "<option value='$key' $selected>$value</option>";
}
}
?>
</select>
</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($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>"
name="policy_no" placeholder="Policy Number" >
</div>
<div class="form-group col-md-3">
<label for="tpa_id">TPA ID<span class="text-danger"></span></label>
<input type="text" class="form-control" id="tpa_no" placeholder="Enter TPA ID"
value="<?= isset($ticket_data['tpa_no']) ? $ticket_data['tpa_no'] : '' ?>"
name="tpa_no">
</div>
<div class="form-group col-md-3">
<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($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($ticket_data['emp_mail']) ? $ticket_data['emp_mail'] : '' ?>"
name="emp_mail">
</div>
<div class="form-group col-md-3">
<label for="client_name">Corporate Name<span class="text-danger"></span></label>
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
<input type="text" class="form-control" id="client_name" placeholder="Client" value="<?= isset($ticket_data['client_name']) ? $ticket_data['client_name'] : '' ?>" readonly>
</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" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly>
</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" 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'] : '' ?>" readonly>
</div>
<div class="form-group col-md-3">
<label for="acm_id">Account Manager<span class="text-danger"></span></label>
<select class="form-control" id="acm_id" name="acm_id">
<!-- <option value="0">Select Account Manager</option> -->
<?php
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>";
}
}
?>
</select>
</div>
</div>
<!-- end first_data_points -->
<h5>Claim Details</h5>
<hr>
<!-- second_data_points -->
<div class="form-row">
<div class="form-group col-md-3">
@ -55,117 +169,18 @@
</select>
</div>
<div class="form-group col-md-3">
<label for="acm_id">Account Manager<span class="text-danger"></span></label>
<select class="form-control" id="acm_id" name="acm_id">
<!-- <option value="0">Select Account Manager</option> -->
<?php
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>";
}
}
?>
</select>
</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($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" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly>
</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" 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'] : '' ?>" readonly>
</div>
<div class="form-group col-md-3">
<label for="client_name">Corporate Name<span class="text-danger"></span></label>
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
<input type="text" class="form-control" id="client_name" placeholder="Client" value="<?= isset($ticket_data['client_name']) ? $ticket_data['client_name'] : '' ?>" readonly>
</div>
<div class="form-group col-md-3">
<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($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($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" 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($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" 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">
<label for="relationship"> Relationship <span class="text-danger"></span></label>
<select class="form-control" id="relationship" name="relationship">
<option value="0">Select Relationship</option>
<?php
if (isset($relationshipType) && count($relationshipType)) {
foreach ($relationshipType as $key => $value) {
$selected = (isset($ticket_data) && $ticket_data['relationship'] == $key) ? 'selected' : '';
echo "<option value='$key' $selected>$value</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<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($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($ticket_data['emp_mail']) ? $ticket_data['emp_mail'] : '' ?>"
name="emp_mail">
</div>
<div class="form-group col-md-3">
<label for="mode_of_intimation"> Mode of Intimation <span
class="text-danger"></span></label>
<select class="form-control" id="mode_of_intimation" name="mode_of_intimation">
<!-- <option value="0">Select Mode</option> -->
<?php
if (isset($modeOFIntimate) && count($modeOFIntimate)) {
foreach ($modeOFIntimate as $key => $value) {
$selected = (isset($ticket_data) && $ticket_data['mode_of_intimation'] == $key) ? 'selected' : '';
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
}
if (isset($modeOFIntimate) && count($modeOFIntimate)) {
foreach ($modeOFIntimate as $key => $value) {
$selected = (isset($ticket_data) && $ticket_data['mode_of_intimation'] == $key) ? 'selected' : '';
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
}
}
?>
</select>
</div>
@ -175,12 +190,12 @@
<select class="form-control" id="claim_type" name="claim_type">
<!-- <option value="0">Select claim Type</option> -->
<?php
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>";
}
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>";
}
}
?>
</select>
</div>
@ -215,12 +230,21 @@
</div>
<div class="form-group col-md-3">
<label for="pod_no">POD No<span class="text-danger"></span></label>
<label id="pod_no_label_1" for="pod_no">POD No<span id="pod_no_label_1_span" class="text-danger"></span></label>
<input type="text" class="form-control" id="pod_no" placeholder="Enter POD NO"
value="<?= isset($ticket_data['pod_no']) ? $ticket_data['pod_no'] : '' ?>"
name="pod_no">
</div>
</div>
<!-- end second_data_points -->
<h5>Additional Details</h5>
<hr>
<!-- third_data_points -->
<div class="form-row">
<div class="form-group col-md-3 up_cnu" style="display: none;">
<label for="claim_number">Claim Number<span class="text-danger"></span></label>
<input type="text" class="form-control" id="claim_number" placeholder="Enter Claim NO"
@ -294,16 +318,21 @@
value="<?= isset($ticket_data['settle_letter']) ? $ticket_data['settle_letter'] : '' ?>" name="settle_letter">
</div>
<div class="form-group col-md-3 returned" style="display: none;">
<label for="return_remark">Return Remark</label>
<textarea class="form-control" id="return_remark" placeholder="Enter Return Remark" name="return_remark"><?= isset($ticket_data['return_remark']) ? $ticket_data['return_remark'] : '' ?></textarea>
<div class="form-group col-md-3 payment" style="display: none;">
<label for="pay_initiate_date">Payment Initiate Date</label>
<input type="text" class="form-control datepicker" id="pay_initiate_date" placeholder="Select Payment Initiate Date"
value="<?= isset($ticket_data['pay_initiate_date']) ? $ticket_data['pay_initiate_date'] : '' ?>" name="pay_initiate_date">
</div>
<div class="form-group col-md-3 canceled" style="display: none;">
<label for="cancel_remark">Cancel Remark</label>
<textarea class="form-control" id="cancel_remark" placeholder="Enter Cancel Remark" name="cancel_remark"><?= isset($ticket_data['cancel_remark']) ? $ticket_data['cancel_remark'] : '' ?></textarea>
<textarea class="form-control" id="cancel_remark" rows="1" placeholder="Enter Cancel Remark" name="cancel_remark"><?= isset($ticket_data['cancel_remark']) ? $ticket_data['cancel_remark'] : '' ?></textarea>
</div>
<div class="form-group col-md-3 returned" style="display: none;">
<label for="return_remark">Return Remark</label>
<textarea class="form-control" id="return_remark" rows="1" placeholder="Enter Return Remark" name="return_remark"><?= isset($ticket_data['return_remark']) ? $ticket_data['return_remark'] : '' ?></textarea>
</div>
<div class="form-group col-md-6 returned" style="display: none;">
<label for="awb_no_courier_name">AWB No with Courier Name</label>
@ -311,11 +340,28 @@
value="<?= isset($ticket_data['awb_no_courier_name']) ? $ticket_data['awb_no_courier_name'] : '' ?>" name="awb_no_courier_name">
</div>
<div class="form-group col-md-3 non_id" style="display: none;">
<label for="non_id_reason">Non ID Reason</label>
<select class="form-control" id="non_id_reason" name="non_id_reason">
<option value="">Select Reason</option>
<?php
if (isset($nonIDReason) && count($nonIDReason)) {
foreach ($nonIDReason as $key => $value) {
$selected = (isset($ticket_data) && $ticket_data['non_id_reason'] == $key) ? 'selected' : '';
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
}
}
?>
</select>
</div>
</div>
<!-- end third_data_points -->
</div>
<div class="form-group col-md-12 text-right m-b-0" style="margin-top: 29px;">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit" >Submit</button>
<?php if(get_role_id() == 5 && isset($ticket_data) && $ticket_data['claim_status_id'] == 8) { ?>
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1" id="btnSubmit">Submit</button>
<?php if (get_role_id() == 5 && isset($ticket_data) && $ticket_data['claim_status_id'] == 8) { ?>
<a class="btn btn-secondary waves-effect waves-light mr-1" onclick="showConfirmationModal(event)">Approve Claim Rejection</a>
<?php } ?>
<!-- <button type="button" class="btn btn-primary waves-effect waves-light mr-1" id="btnApprove" >Approve</button> -->
@ -337,190 +383,299 @@
// }
// });
</script>
<script>
let GlobelExtraFields = [];
let GlobelExtraFields = [];
$(document).ready(function() {
$(document).ready(function() {
var doa = flatpickr("#doa", {
dateFormat: "d/m/Y",
allowInput: false
});
var doa = flatpickr("#doa", {
dateFormat: "d/m/Y",
allowInput: false
});
var dod = flatpickr("#dod", {
dateFormat: "d/m/Y",
allowInput: false
});
var dod = flatpickr("#dod", {
dateFormat: "d/m/Y",
allowInput: false
});
flatpickr("#raised_date", {
dateFormat: "d/m/Y",
allowInput: false
});
flatpickr("#registration_date", {
dateFormat: "d/m/Y",
allowInput: false
});
flatpickr("#query_received_date", {
dateFormat: "d/m/Y",
allowInput: false
});
flatpickr("#denial_date", {
dateFormat: "d/m/Y",
allowInput: false
});
flatpickr("#approved_date", {
dateFormat: "d/m/Y",
allowInput: false
});
flatpickr("#settled_date", {
dateFormat: "d/m/Y",
allowInput: false
});
flatpickr("#pay_initiate_date", {
dateFormat: "d/m/Y",
allowInput: false
});
flatpickr("#raised_date", { dateFormat: "d/m/Y", allowInput: false });
flatpickr("#registration_date", { dateFormat: "d/m/Y", allowInput: false });
flatpickr("#query_received_date", { dateFormat: "d/m/Y", allowInput: false });
flatpickr("#denial_date", { dateFormat: "d/m/Y", allowInput: false });
flatpickr("#approved_date", { dateFormat: "d/m/Y", allowInput: false });
flatpickr("#settled_date", { dateFormat: "d/m/Y", allowInput: false });
// updateClaimStatusDisplay("<?= isset($ticket_data['claim_status_id']) ? $ticket_data['claim_status_id'] : 0 ?>")
var extraFields = <?= json_encode(isset($extra_fields) ? $extra_fields : []); ?>;
GlobelExtraFields = extraFields;
console.log("extraFields", extraFields);
claimStatusFieldChanges(extraFields);
// updateClaimStatusDisplay("<?= isset($ticket_data['claim_status_id']) ? $ticket_data['claim_status_id'] : 0 ?>")
var extraFields = <?= json_encode(isset($extra_fields) ? $extra_fields : []); ?>;
GlobelExtraFields = extraFields;
console.log("extraFields", extraFields);
claimStatusFieldChanges(extraFields);
})
})
// function updateClaimStatusDisplay(value) {
// // Hide all sections first
// $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled, .returned').hide();
// $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled, .returned').hide().find('input, textarea').removeAttr('required');
// function updateClaimStatusDisplay(value) {
// // Hide all sections first
// $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled, .returned').hide();
// $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled, .returned').hide().find('input, textarea').removeAttr('required');
// // Show relevant section based on value
// if (value == 3 || value == 4) { // CDA & INFORMATION REQUIRED
// $('.cda_ir').show();
// $('.settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled, .returned').find('input, textarea').removeAttr('required');
// } else if (value == 5) { // UNDER PROCESS - CLAIM NO. UPDATION
// $('.up_cnu').show();
// $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .canceled, .returned').find('input, textarea').removeAttr('required');
// } else if (value == 7) { // UNDER PROCESS - QUERY DOCUMENT RECEIVED
// $('.up_qdr').show();
// $('.cda_ir, .settled, .approved, .rejected, .up_cnu, .canceled, .returned').find('input, textarea').removeAttr('required');
// } else if (value == 8) { // REJECTED
// $('.rejected').show();
// $('.cda_ir, .settled, .approved, .up_qdr, .up_cnu, .canceled, .returned').find('input, textarea').removeAttr('required');
// } else if (value == 9) { // APPROVED
// $('.approved').show();
// $('.cda_ir, .settled, .rejected, .up_qdr, .up_cnu, .canceled, .returned').find('input, textarea').removeAttr('required');
// } else if (value == 11) { // SETTLED
// $('.settled').show();
// $('.cda_ir, .approved, .rejected, .up_qdr, .up_cnu, .canceled, .returned').find('input, textarea').removeAttr('required');
// }else if (value == 13) { // CANCELLED
// $('.canceled').show();
// $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .returned').find('input, textarea').removeAttr('required');
// }else if (value == 14) { // RETURNED
// $('.returned').show();
// $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled').find('input, textarea').removeAttr('required');
// }
// }
// // Show relevant section based on value
// if (value == 3 || value == 4) { // CDA & INFORMATION REQUIRED
// $('.cda_ir').show();
// $('.settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled, .returned').find('input, textarea').removeAttr('required');
// } else if (value == 5) { // UNDER PROCESS - CLAIM NO. UPDATION
// $('.up_cnu').show();
// $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .canceled, .returned').find('input, textarea').removeAttr('required');
// } else if (value == 7) { // UNDER PROCESS - QUERY DOCUMENT RECEIVED
// $('.up_qdr').show();
// $('.cda_ir, .settled, .approved, .rejected, .up_cnu, .canceled, .returned').find('input, textarea').removeAttr('required');
// } else if (value == 8) { // REJECTED
// $('.rejected').show();
// $('.cda_ir, .settled, .approved, .up_qdr, .up_cnu, .canceled, .returned').find('input, textarea').removeAttr('required');
// } else if (value == 9) { // APPROVED
// $('.approved').show();
// $('.cda_ir, .settled, .rejected, .up_qdr, .up_cnu, .canceled, .returned').find('input, textarea').removeAttr('required');
// } else if (value == 11) { // SETTLED
// $('.settled').show();
// $('.cda_ir, .approved, .rejected, .up_qdr, .up_cnu, .canceled, .returned').find('input, textarea').removeAttr('required');
// }else if (value == 13) { // CANCELLED
// $('.canceled').show();
// $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .returned').find('input, textarea').removeAttr('required');
// }else if (value == 14) { // RETURNED
// $('.returned').show();
// $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled').find('input, textarea').removeAttr('required');
// }
// }
function updateClaimStatusDisplay(value) {
function updateClaimStatusDisplay(value) {
// Hide all sections and remove required attribute from their inputs and textareas
let sections = $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled, .returned, .payment, .non_id');
sections.hide().find('input, textarea').removeAttr('required');
// Hide all sections and remove required attribute from their inputs and textareas
let sections = $('.cda_ir, .settled, .approved, .rejected, .up_qdr, .up_cnu, .canceled, .returned');
sections.hide().find('input, textarea').removeAttr('required');
// Determine which section to show
let showClass = '';
if (value == 3 || value == 4) { // CDA & INFORMATION REQUIRED
showClass = '.cda_ir';
} else if (value == 5) { // UNDER PROCESS - CLAIM NO. UPDATION
showClass = '.up_cnu';
} else if (value == 7) { // UNDER PROCESS - QUERY DOCUMENT RECEIVED
showClass = '.up_qdr';
} else if (value == 8) { // REJECTED
showClass = '.rejected';
} else if (value == 9) { // APPROVED
showClass = '.approved';
} else if (value == 11) { // SETTLED
showClass = '.settled';
} else if (value == 13) { // CANCELLED
showClass = '.canceled';
} else if (value == 14) { // RETURNED
showClass = '.returned';
}
// Show the relevant section and enable required attributes
if (showClass) {
$(showClass).show().find('input, textarea').attr('required', true);
}
}
$('#claim_status_id').on('change', function() {
updateClaimStatusDisplay($(this).val());
// claimStatusFieldChanges()
});
function claimStatusFieldChanges(fields) {
fields.forEach(function(fieldId) {
var $field = $("#" + fieldId);
if ($field.length) {
$field.prop('required', true);
var $parentDiv = $field.closest("div");
$parentDiv.show();
var $label = $parentDiv.find("label[for='" + fieldId + "']");
if ($label.length && !$label.find(".text-danger").length) {
$label.append(' <span class="text-danger">*</span>');
}
// Determine which section to show
let showClass = '';
if (value == 3 || value == 4) { // CDA & INFORMATION REQUIRED
showClass = '.cda_ir';
} else if (value == 5) { // UNDER PROCESS - CLAIM NO. UPDATION
showClass = '.up_cnu';
} else if (value == 7) { // UNDER PROCESS - QUERY DOCUMENT RECEIVED
showClass = '.up_qdr';
} else if (value == 8) { // REJECTED
showClass = '.rejected';
} else if (value == 9) { // APPROVED
showClass = '.approved';
} else if (value == 11) { // SETTLED
showClass = '.settled';
} else if (value == 13) { // CANCELLED
showClass = '.canceled';
} else if (value == 14) { // RETURNED
showClass = '.returned';
} else if (value == 1) { // NON ID
showClass = '.non_id';
} else if (value == 10) { // PAYMENT INITIATED
showClass = '.payment';
}
});
}
function claimStatusFieldRemoveREquired(fields, remove_or_add, thirdClass) {
console.log('--------------------------- claimStatusFieldRemoveREquired ---------------------------');
console.log('fields', fields);
console.log('remove_or_add', remove_or_add);
fields.forEach(function(fieldId) {
var $field = $("#" + fieldId);
if ($field.length) {
$field.prop('required', remove_or_add);
var $parentDiv = $field.closest("div");
console.log('parentDiv', $parentDiv);
var $label = $parentDiv.find("label[for='" + fieldId + "']");
// if(remove_or_add == false){
// $parentDiv.find("label[for='" + fieldId + "'] .text-danger").remove();
// console.log('one', remove_or_add);
// }else{
// if ($label.length && !$label.find(".text-danger").length) {
// $label.append(' <span class="text-danger">*</span>');
// }
// }
}
});
$('.'+thirdClass).find('input, textarea').attr('required', true);
}
$(document).on("input", function (event) {
let fields = GlobelExtraFields;
console.log('fields', fields);
let targetId = event.target.id;
console.log('targetId', targetId);
console.log('fields.includes(targetId)', fields.includes(targetId));
if (fields.includes(targetId)) {
let $field = $("#" + targetId);
console.log('$field id', $field);
let $parentDiv = $field.closest("div");
console.log('$parentDiv', $parentDiv);
if ($parentDiv.length) {
let thirdClass = $parentDiv.attr("class").split(" ")[2] || "";
console.log('thirdClass', thirdClass);
if (thirdClass) {
claimStatusFieldRemoveREquired(fields, false, thirdClass);
let $label = $(thirdClass).find("label");
if ($label.length && !$label.find(".text-danger").length) {
// Show the relevant section and enable required attributes
if (showClass) {
// $(showClass).show().find('input, textarea').attr('required', true);
$(showClass).show().find('input, textarea').attr('required', true).each(function() {
var $label = $("label[for='" + $(this).attr('id') + "']");
if ($label.length && !$label.find('.text-danger').length) {
$label.append(' <span class="text-danger">*</span>');
}
} else {
claimStatusFieldRemoveREquired($field, false, '');
}
});
}
}
});
$('#claim_status_id').on('change', function() {
updateClaimStatusDisplay($(this).val());
// claimStatusFieldChanges()
});
function claimStatusFieldChanges(fields) {
fields.forEach(function(fieldId) {
var $field = $("#" + fieldId);
if ($field.length) {
// $field.prop('required', true);
var $parentDiv = $field.closest("div");
$parentDiv.show();
var $label = $parentDiv.find("label[for='" + fieldId + "']");
if ($label.length && !$label.find(".text-danger").length) {
// $label.append(' <span class="text-danger">*</span>');
}
}
});
}
function claimStatusFieldRemoveREquired(fields, remove_or_add, thirdClass) {
console.log('--------------------------- claimStatusFieldRemoveREquired ---------------------------');
console.log('fields', fields);
console.log('remove_or_add', remove_or_add);
fields.forEach(function(fieldId) {
var $field = $("#" + fieldId);
if ($field.length) {
$field.prop('required', remove_or_add);
var $parentDiv = $field.closest("div");
console.log('parentDiv', $parentDiv);
var $label = $parentDiv.find("label[for='" + fieldId + "']");
// if(remove_or_add == false){
// $parentDiv.find("label[for='" + fieldId + "'] .text-danger").remove();
// // console.log('one', remove_or_add);
// }else{
// if ($label.length && !$label.find(".text-danger").length) {
// $label.append(' <span class="text-danger">*</span>');
// }
// }
}
});
$('.' + thirdClass).find('input, textarea').attr('required', true);
}
$(document).on("input", function(event) {
let fields = GlobelExtraFields;
console.log('fields', fields);
let targetId = event.target.id;
console.log('targetId', targetId);
console.log('fields.includes(targetId)', fields.includes(targetId));
if (fields.includes(targetId)) {
let $field = $("#" + targetId);
console.log('$field id', $field);
let $parentDiv = $field.closest("div");
console.log('$parentDiv', $parentDiv);
if ($parentDiv.length) {
let thirdClass = $parentDiv.attr("class").split(" ")[2] || "";
console.log('thirdClass', thirdClass);
addRequiredFieldSymbolByClass(thirdClass);
// addRequiredFieldSymbol(targetId);
if (thirdClass) {
// console.log("fields",fields);
claimStatusFieldRemoveREquired(fields, false, thirdClass);
$(thirdClass).each(function() {
let $label = $(this).find("label");
$label.each(function() {
if (!$(this).find(".text-danger").length) {
$(this).append(' <span class="text-danger">*</span>');
}
});
});
} else {
claimStatusFieldRemoveREquired($field, false, '');
console.log("In Else Condition");
}
}
}
});
function addRequiredFieldSymbol(field_name) {
// Find the field with the given name
var $field = $(`[name="${field_name}"]`);
if ($field.length) {
// Find the parent div of this field
var $parentDiv = $field.closest('div');
if ($parentDiv.length) {
// Get the classes as an array
var classes = $parentDiv.attr('class') ? $parentDiv.attr('class').split(/\s+/) : [];
if (classes.length > 0) {
// Get the last class in the array
var lastClass = classes[classes.length - 1];
// Find all divs with this last class
var $allDivsWithClass = $(`.${lastClass}`);
// Add asterisk to all labels within these divs
$allDivsWithClass.each(function() {
var $label = $(this).find('label');
if ($label.length && !$label.find('.text-danger').length) {
$label.append(' <span class="text-danger">*</span>');
}
});
console.log(`Added required symbol to ${$allDivsWithClass.length} labels with class "${lastClass}"`);
} else {
console.warn(`Parent div for field "${field_name}" has no classes`);
}
} else {
console.warn(`No parent div found for field name="${field_name}"`);
}
} else {
console.warn(`No field found with name="${field_name}"`);
}
}
function addRequiredFieldSymbolByClass(className) {
// Find all divs with the specified class
var $divsWithClass = $(`.${className}`);
if ($divsWithClass.length) {
// Add asterisk to all labels within these divs
$divsWithClass.each(function() {
var $label = $(this).find('label');
if ($label.length && !$label.find('.text-danger').length) {
$label.append(' <span class="text-danger">*</span>');
}
});
console.log(`Added required symbol to ${$divsWithClass.length} labels with class "${className}"`);
} else {
console.warn(`No divs found with class="${className}"`);
}
}
$('#mode_of_intimation').change(function(){
console.log("function called");
var mode_of_intimation = $('#mode_of_intimation').val();
console.log('mode of ',mode_of_intimation);
if (mode_of_intimation == 2){
$('#pod_no').attr('required', 'required');
$('#pod_no_label_1_span').text("*");
}else{
$('#pod_no').removeAttr('required', false);
$('#pod_no_label_1_span').text("");
}
})
</script>

View File

@ -25,92 +25,18 @@
<?php } ?>
<form role="form" class="parsley-examples" method="post" id="ticket_form_data" onsubmit="submitClaimForm(event, this)"
enctype="multipart/form-data">
<div class="form-group">
<div class="form-row">
<input type="hidden" id="ticket_master_id" name="ticket_master_id" value="<?= isset($ticket_data['id']) ? $ticket_data['id'] : '' ?>">
<input type="hidden" id="ticket_master_id" name="ticket_master_id" value="<?= isset($ticket_data['id']) ? $ticket_data['id'] : '' ?>">
<input type="hidden" id="is_head_approved" name="is_head_approved" value="<?= isset($ticket_data['is_head_approved']) ? $ticket_data['is_head_approved'] : '' ?>">
<input type="hidden" id="extra_fields_array_for_validate" name="extra_fields_array_for_validate" value='<?= isset($extra_fields_array_for_validate) && !empty($extra_fields_array_for_validate) ? json_encode($extra_fields_array_for_validate) : "[]" ?>'>
<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_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) {
$selected = (isset($ticket_data) && $ticket_data['claim_status_id'] == $value['id']) ? 'selected' : '';
echo "<option value=" . $value['id'] . " $selected>" . $value['claim_status'] . "</option>";
}
}
?>
</select>
</div>
<div class="form-group">
<div class="form-group col-md-3">
<label for="acm_id">Account Manager<span class="text-danger"></span></label>
<select class="form-control" id="acm_id" name="acm_id">
<!-- <option value="0">Select Account Manager</option> -->
<?php
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>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="client_name">Corporate Name<span class="text-danger"></span></label>
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
<input type="text" class="form-control" id="client_name" placeholder="Client" value="<?= isset($ticket_data['client_name']) ? $ticket_data['client_name'] : '' ?>" readonly>
</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" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly>
</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($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>"
name="policy_no">
</div>
<div class="form-group col-md-3">
<label for="ticket_type_id"> Policy Type <span class="text-danger"></span></label>
<select class="form-control readonly-select" id="ticket_type_id" name="ticket_type_id" readonly>
<?php
if (isset($ticket_type) && count($ticket_type)) {
foreach ($ticket_type as $key => $value) {
if($key != 1){
$selected = (isset($ticket_data) && $ticket_data['ticket_type_id'] == $key) ? 'selected' : ((isset($selected_ticket_type) && $selected_ticket_type == $key) ? 'selected' : '');
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
}
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<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($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>";
}
}
?>
</select>
</div>
<h5>Employee Details</h5>
<hr>
<!-- first_data_points -->
<div class="form-row">
<div class="form-group col-md-3">
<label for="emp_code">Employee ID &nbsp; <i class="fa fa-search text-danger"
@ -120,7 +46,6 @@
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'] : '' ?>">
@ -143,6 +68,94 @@
name="emp_mail">
</div>
<div class="form-group col-md-3">
<label for="policy_no">Policy No<span class="text-danger"></span></label>
<input type="text" class="form-control" id="policy_no"
value="<?= isset($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>"
name="policy_no">
</div>
<div class="form-group col-md-3">
<label for="client_name">Corporate Name<span class="text-danger"></span></label>
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
<input type="text" class="form-control" id="client_name" placeholder="Client" value="<?= isset($ticket_data['client_name']) ? $ticket_data['client_name'] : '' ?>" readonly>
</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" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
<input type=text class="form-control" id="insurer_name" placeholder="Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly>
</div>
<div class="form-group col-md-3">
<label for="acm_id">Account Manager<span class="text-danger"></span></label>
<select class="form-control" id="acm_id" name="acm_id">
<!-- <option value="0">Select Account Manager</option> -->
<?php
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>";
}
}
?>
</select>
</div>
</div>
<!-- end first_data_points -->
<h5>Claim Details</h5>
<hr>
<!-- second_data_points -->
<div class="form-row">
<div class="form-group col-md-3">
<label for="ticket_type_id"> Policy Type <span class="text-danger"></span></label>
<select class="form-control readonly-select" id="ticket_type_id" name="ticket_type_id" readonly>
<?php
if (isset($ticket_type) && count($ticket_type)) {
foreach ($ticket_type as $key => $value) {
if($key != 1){
$selected = (isset($ticket_data) && $ticket_data['ticket_type_id'] == $key) ? 'selected' : ((isset($selected_ticket_type) && $selected_ticket_type == $key) ? 'selected' : '');
echo "<option value='" . $key . "' $selected>" . $value . "</option>";
}
}
}
?>
</select>
</div>
<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_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) {
$selected = (isset($ticket_data) && $ticket_data['claim_status_id'] == $value['id']) ? 'selected' : '';
echo "<option value=" . $value['id'] . " $selected>" . $value['claim_status'] . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<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($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>";
}
}
?>
</select>
</div>
<div class="form-group col-md-3">
<label for="date_of_join">Date of joining<span class="text-danger"></span></label>
@ -196,6 +209,14 @@
value="<?= isset($ticket_data['si_amt']) ? $ticket_data['si_amt'] : '' ?>"
name="si_amt">
</div>
</div>
<!-- end second_data_points -->
<h5>Additional Details</h5>
<hr>
<!-- third_data_points -->
<div class="form-row">
<div class="form-group col-md-3 approved" style="display: none;">
<label for="approved_amount">Approved Amount</label>
@ -233,16 +254,15 @@
value="<?= isset($ticket_data['settle_letter']) ? $ticket_data['settle_letter'] : '' ?>" name="settle_letter">
</div>
<div class="form-group col-md-3 returned" style="display: none;">
<label for="return_remark">Return Remark</label>
<textarea class="form-control" id="return_remark" placeholder="Enter Return Remark" name="return_remark"><?= isset($ticket_data['return_remark']) ? $ticket_data['return_remark'] : '' ?></textarea>
</div>
<div class="form-group col-md-3 canceled" style="display: none;">
<label for="cancel_remark">Cancel Remark</label>
<textarea class="form-control" id="cancel_remark" placeholder="Enter Cancel Remark" name="cancel_remark"><?= isset($ticket_data['cancel_remark']) ? $ticket_data['cancel_remark'] : '' ?></textarea>
<textarea class="form-control" id="cancel_remark" rows="1" placeholder="Enter Cancel Remark" name="cancel_remark"><?= isset($ticket_data['cancel_remark']) ? $ticket_data['cancel_remark'] : '' ?></textarea>
</div>
<div class="form-group col-md-3 returned" style="display: none;">
<label for="return_remark">Return Remark</label>
<textarea class="form-control" id="return_remark" rows="1" placeholder="Enter Return Remark" name="return_remark"><?= isset($ticket_data['return_remark']) ? $ticket_data['return_remark'] : '' ?></textarea>
</div>
<div class="form-group col-md-6 returned" style="display: none;">
<label for="awb_no_courier_name">AWB No with Courier Name</label>
@ -250,7 +270,10 @@
value="<?= isset($ticket_data['awb_no_courier_name']) ? $ticket_data['awb_no_courier_name'] : '' ?>" name="awb_no_courier_name">
</div>
</div>
<!-- end third_data_points -->
</div>
<div class="form-group col-md-12 text-right m-b-0" style="margin-top: 29px;">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
@ -342,7 +365,7 @@ function claimStatusFieldChanges(fields) {
var $field = $("#" + fieldId);
if ($field.length) {
$field.prop('required', true);
// $field.prop('required', true);
var $parentDiv = $field.closest("div");
$parentDiv.show();
@ -399,9 +422,10 @@ console.log('fields', fields);
console.log('$field id', $field);
let $parentDiv = $field.closest("div");
console.log('$parentDiv', $parentDiv);
// addRequiredFieldSymbol(targetId);
if ($parentDiv.length) {
let thirdClass = $parentDiv.attr("class").split(" ")[2] || "";
addRequiredFieldSymbolByClass(thirdClass);
console.log('thirdClass', thirdClass);
if (thirdClass) {
@ -416,5 +440,61 @@ console.log('fields', fields);
}
}
});
// function addRequiredFieldSymbol(field_name) {
// // Find the field with the given name
// var $field = $(`[name="${field_name}"]`);
// if ($field.length) {
// // Find the parent div of this field
// var $parentDiv = $field.closest('div');
// if ($parentDiv.length) {
// // Get the classes as an array
// var classes = $parentDiv.attr('class') ? $parentDiv.attr('class').split(/\s+/) : [];
// if (classes.length > 0) {
// // Get the last class in the array
// var lastClass = classes[classes.length - 1];
// // Find all divs with this last class
// var $allDivsWithClass = $(`.${lastClass}`);
// // Add asterisk to all labels within these divs
// $allDivsWithClass.each(function() {
// var $label = $(this).find('label');
// if ($label.length && !$label.find('.text-danger').length) {
// $label.append(' <span class="text-danger">*</span>');
// }
// });
// console.log(`Added required symbol to ${$allDivsWithClass.length} labels with class "${lastClass}"`);
// } else {
// console.warn(`Parent div for field "${field_name}" has no classes`);
// }
// } else {
// console.warn(`No parent div found for field name="${field_name}"`);
// }
// } else {
// console.warn(`No field found with name="${field_name}"`);
// }
// }
function addRequiredFieldSymbolByClass(className) {
// Find all divs with the specified class
var $divsWithClass = $(`.${className}`);
if ($divsWithClass.length) {
// Add asterisk to all labels within these divs
$divsWithClass.each(function() {
var $label = $(this).find('label');
if ($label.length && !$label.find('.text-danger').length) {
$label.append(' <span class="text-danger">*</span>');
}
});
console.log(`Added required symbol to ${$divsWithClass.length} labels with class "${className}"`);
} else {
console.warn(`No divs found with class="${className}"`);
}
}
</script>

View File

@ -76,48 +76,37 @@ if(!isset($view_ticket_page)){
<div id="mobileSearch" class="search-method">
<div class="row">
<div class="col-md-5" style="display:true;">
<div class="col-md-3" style="display:true;">
<div class="form-group">
<label>Employee Data Points</label>
<select name="employee_data_points" id="employee_data_points"
class="form-control">
<option value="mobile">Employee Mobile Number</option>
<option value="mobile">Mobile Number</option>
<option value="emp_code">Employee ID</option>
</select>
</div>
</div>
<div class="col-md-5">
<div class="col-md-3">
<div class="form-group">
<label id="employee_data_points_label">Employee Mobile Number</label>
<label>Client</label>
<select id="mobile_emp_client_data_list" name="client"
class="form-control custom-select">
<option value="0">Select Client</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label id="employee_data_points_label">Mobile Number</label>
<input class="form-control" type="text" id="emp_mobile_number_for_claim"
name="mobile_numbers" onkeypress="return onlyNumbers(event)"
maxlength="10">
</div>
<div class="text-danger" id="error_dis"></div>
</div>
<div class="col-md-2">
<div class="form-group" style="margin-top: 9px;">
<br>
<button class="btn btn-primary"
onclick="getTheEmpDataForClaimSearchByMobile(this)">Search</button>
</div>
</div>
</div>
</div>
<div id="emp_member_policy_div" style="display:true;">
<div class="row">
<div class="col-md-5" style="display:none;">
<div class="form-group">
<label>Employee</label>
<select name="employee_by_number" id="employee_by_number"
class="form-control SelExample">
<option value="0">Select Employee</option>
</select>
</div>
</div>
<div class="col-md-5">
<div class="col-md-6">
<div class="form-group">
<label>Insured List</label>
<select name="employee_by_number" id="member_by_number"
@ -126,81 +115,93 @@ if(!isset($view_ticket_page)){
</select>
</div>
</div>
</div>
</div>
</div>
<!-- Search by Client, Branch, and Policy -->
<div class="mt-4">
<h4 onclick="toggleAccordion('clientBranchAccordion')">
Search by Client, Branch, and Policy
<span class="arrow" id="clientBranchArrow"></span>
</h4>
<div class="accordion-content" id="clientBranchAccordion">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Client</label>
<select id="emp_client_data_list" name="client"
class="form-control custom-select">
<option value="0">Select Client</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Branch</label>
<select id="emp_client_branch_data_list" name="branch"
class="form-control custom-select">
<option value="0">Select Branch</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Policy</label>
<select id="emp_client_policy_data_list" name="policy_client_branch"
class="form-control custom-select" onchange="getEmpData(this)">
<option value="0">Select Policy</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Employee</label>
<select name="search_by_client_employee" id="search_by_client_employee"
class="form-control SelExample"
onchange="getTheEmpDataForClaimSearchByMobile(this, 'client')">
<option value="0">Select Employee</option>
</select>
</div>
<div class="col-md-4">
</div>
<div class="col-md-6">
<div class="form-group">
<label>Insured List</label>
<select name="member" id="search_by_client_member"
class="form-control SelExample" onchange="setMemberData(this)">
<option value="0">Select Member</option>
</select>
<div class="col-md-2">
<div class="form-group" style="margin-top: 9px; float:right;">
<br>
<button class="btn btn-primary"
onclick="getTheEmpDataForClaimSearchByMobile(this)">Search</button>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Search by Client, Branch, and Policy -->
<div class="mt-4">
<h4 onclick="toggleAccordion('clientBranchAccordion')">
Search by Client, Branch, and Policy
<span class="arrow" id="clientBranchArrow"></span>
</h4>
<div class="accordion-content" id="clientBranchAccordion">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Client</label>
<select id="emp_client_data_list" name="client"
class="form-control custom-select">
<option value="0">Select Client</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Branch</label>
<select id="emp_client_branch_data_list" name="branch"
class="form-control custom-select">
<option value="0">Select Branch</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Policy</label>
<select id="emp_client_policy_data_list" name="policy_client_branch"
class="form-control custom-select" onchange="getEmpData(this)">
<option value="0">Select Policy</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>Employee</label>
<select name="search_by_client_employee" id="search_by_client_employee"
class="form-control SelExample"
onchange="getTheEmpDataForClaimSearchByMobile(this, 'client')">
<option value="0">Select Employee</option>
</select>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Insured List</label>
<select name="member" id="search_by_client_member"
class="form-control SelExample" onchange="setMemberData(this)">
<option value="0">Select Member</option>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-primary close" data-dismiss="modal" aria-label="Close"
onclick="toResetTheModelFields()">Submit</a>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-primary close" data-dismiss="modal" aria-label="Close"
onclick="toResetTheModelFields()">Submit</a>
</div>
</div>
</div>
</div>
</div>
<script>
var client_list = ''; // local variable for storing the client branch list
@ -296,6 +297,7 @@ function getClientAndBranchAndPolicy() {
branch_list = res.branch_data;
policy_list = res.policy_data;
appendClients(res.client_data);
appendClientsForMobileSearch(res.client_data);
} else {
console.log('No data found');
}
@ -329,6 +331,26 @@ function appendClients(data) {
}
//append the clients data for mobile search to the modal
function appendClientsForMobileSearch(data) {
$('#mobile_emp_client_data_list').empty();
$('#mobile_emp_client_data_list').append($('<option>', {
value: '0',
text: 'Select Client'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.short_name,
});
$('#mobile_emp_client_data_list').append(option).select2();
});
}
//append the clients branch data to the modal
function appendBranch(data) {
$('#emp_client_branch_data_list').empty();
@ -363,47 +385,48 @@ function appendPolicy(data) {
$.each(data, function(index, item) {
if(ticket_type == 1){
if (ticket_type == 1) {
if(item.policy_type_id == 2 || item.policy_type_id == 3 || item.policy_type_id == 4 ||item.policy_type_id == 5) {
if (item.policy_type_id == 2 || item.policy_type_id == 3 || item.policy_type_id == 4 || item
.policy_type_id == 5) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
});
$('#emp_client_policy_data_list').append(option).select2();
}
}else if(ticket_type == 2){
} else if (ticket_type == 2) {
if(item.policy_type_id == 1) {
if (item.policy_type_id == 1) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
});
$('#emp_client_policy_data_list').append(option).select2();
}
}else if(ticket_type == 3){
} else if (ticket_type == 3) {
if(item.policy_type_id == 6) {
if (item.policy_type_id == 6) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
});
$('#emp_client_policy_data_list').append(option).select2();
}
}else if(ticket_type == 4){
} else if (ticket_type == 4) {
if(item.policy_type == 7) {
if (item.policy_type == 7) {
var option = $('<option>', {
value: item.id,
text: item.policy_type + '-' + item.policy_no,
});
$('#emp_client_policy_data_list').append(option).select2();
}
@ -512,17 +535,23 @@ function getTheEmpDataForClaimSearchByMobile(input, searchType = null) {
console.log(input)
let type = $('#employee_data_points').val()
let param = $('#emp_mobile_number_for_claim').val()
let client_policy_id = $('#emp_client_policy_data_list').val()
let client_id = $('#mobile_emp_client_data_list').val()
if (searchType == 'client') {
type = 'emp_code';
param = $(input).val();
client_id = $('#emp_client_data_list').val()
}
let url = '<?= base_url('util/getTheEmpDataForClaimSearchByMobile/') ?>' + param + '/' + type;
let url = '<?= base_url('util/getTheEmpDataForClaimSearchByMobile/') ?>' + param + '/' + type + '/' +
client_policy_id + '/' + client_id;
// Data to send in the AJAX request
let requestData = {
param: param,
type: type,
client_policy_id: client_policy_id,
client_id: client_id,
};
// Show loader
@ -534,7 +563,7 @@ function getTheEmpDataForClaimSearchByMobile(input, searchType = null) {
sendAjaxRequestForGlobal(url, 'GET', requestData, function(response) {
console.log('Data fetched successfully:', response);
if (response.status) {
if (response.status == true) {
console.log(response.message, 'SUCCESS');
if (searchType == 'client') {
appendMember(response.memberData, 'search_by_client_member');
@ -712,22 +741,45 @@ function setMemberData(input) {
}
});
if(tpaNo == ""){
if (tpaNo == "") {
$('#claim_status_id').val(1)
}else{
$('#non_id_reason').attr('required', true);
var $label = $("label[for='non_id_reason']");
if ($label.length && !$label.find('.text-danger').length) {
$label.append(' <span class="text-danger">*</span>');
}
} else {
$('#claim_status_id').val(2)
$('#non_id_reason').attr('required', false);
var $label = $("label[for='non_id_reason']");
$label.text("");
}
}
$('#employee_data_points').on('change', function() {
// $('#employee_data_points').on('change', function() {
// let value = $(this).val()
// if (value == "mobile") {
// $('#employee_data_points_label').text('Employee Mobile Number')
// } else {
// $('#employee_data_points_label').text('Employee ID')
// }
// })
$('#employee_data_points').on('change', function() {
let value = $(this).val();
let $label = $('#employee_data_points_label');
let $input = $('#emp_mobile_number_for_claim');
let value = $(this).val()
if (value == "mobile") {
$('#employee_data_points_label').text('Employee Mobile Number')
$label.text('Employee Mobile Number');
$input.attr('onkeypress', 'return onlyNumbers(event)').attr('maxlength', '10');
} else {
$('#employee_data_points_label').text('Employee ID')
$label.text('Employee ID');
$input.removeAttr('onkeypress maxlength');
}
})
});
function toResetTheModelFields() {

View File

@ -5,7 +5,7 @@
<table id="scroll-horizontal-datatable" class="table w-100">
<thead class="bg-light">
<tr>
<th>Field</th>
<th>Label</th>
<!-- <th>Old Value</th>
<th>New Value</th> -->
<th>Change</th>

View File

@ -74,11 +74,11 @@ table.dataTable tbody td {
title=" <?php
if ($row['claim_status_id'] == 8) {
if ($row['is_head_approved'] == 0) {
echo 'Waiting For Head Approvel';
echo 'Waiting for approvel';
} elseif ($row['is_head_approved'] == 1) {
echo 'Head Approved';
echo 'Rejection approved';
} elseif ($row['is_head_approved'] == 2) {
echo 'Head Rejected';
echo 'Rejection not approved';
} else {
echo $row['status'];
}

View File

@ -1,56 +1,56 @@
<style>
.table th,
.table td {
padding: 8px;
}
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
.col-12 {
.col-12 {
max-width: 98% !important;
}
max-width: 98% !important;
}
.dataTables_filter {
position: absolute;
}
.dataTables_filter {
position: absolute;
}
.right-align-input {
text-align: right;
}
.right-align-input {
text-align: right;
}
.addbtnStyle {
margin-left: 20px !important;
}
.addbtnStyle {
margin-left: 20px !important;
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu {
display: none;
position: absolute;
background-color: #ffffff !important;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 0.25rem;
padding: 0.5rem 0;
min-width: 10rem;
z-index: 9999;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item {
display: block !important;
width: 100% !important;
padding: 0.5rem 1rem !important;
color: #212529 !important;
text-decoration: none !important;
background-color: transparent !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
.custom-dropdown-menu .dropdown-item:hover {
background-color: #f8f9fa !important;
color: #16181b !important;
cursor: pointer !important;
}
</style>
<div class="col-12">
@ -75,28 +75,37 @@ table.dataTable tbody td {
</thead>
<tbody>
<?php if (isset($ticket_data)) { ?>
<?php foreach($ticket_data as $index => $row){ ?>
<tr>
<td><?php echo $row['template_name'] ?? ""; ?></td>
<td><?php echo $ticket_type[$row['ticket_type']] ?? ""; ?></td>
<td><?php echo $trigger_type[$row['trigger_type']] ?? ""; ?></td>
<td><?=$row['is_auto_mail'] == 1?'Auto':"Manual" ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);"
class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"
aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#"
onclick="getMailTemplateData(<?=$row['id']?>)"><i
class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" onclick="deleteTemplate(<?=$row['id']?>)"><i
class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php foreach ($ticket_data as $index => $row) { ?>
<tr>
<td> <?php echo $row['template_name'] ?? ""; ?> &nbsp;
<i class="fe-alert-circle"
style="color: #000;"
aria-hidden="true"
data-toggle="tooltip"
data-placement="top"
title="<?php echo "Status : ". ($row['tool_tip'] ?? ''); ?>"></i>
</td>
<td><?php echo $ticket_type[$row['ticket_type']] ?? ""; ?></td>
<td><?php echo $trigger_type[$row['trigger_type']] ?? ""; ?></td>
<td><?= $row['is_auto_mail'] == 1 ? 'Auto' : "Manual" ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);"
class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"
aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item" href="#"
onclick="getMailTemplateData(<?= $row['id'] ?>)"><i
class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" onclick="deleteTemplate(<?= $row['id'] ?>)"><i
class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
</div>
</div>
</td>
</tr>
<?php } ?>
<?php } ?>
</tbody>
</table>
@ -135,11 +144,11 @@ table.dataTable tbody td {
<select class="form-control" id="policy_type" name="ticket_type" required>
<option value="">Select Policy Type</option>
<?php
if (isset($policy_type) && count($policy_type)) {
foreach ($policy_type as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>";
}
if (isset($policy_type) && count($policy_type)) {
foreach ($policy_type as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>";
}
}
?>
</select>
</div>
@ -149,11 +158,11 @@ table.dataTable tbody td {
<select class="form-control" id="trigger_type" name="trigger_type" required>
<option value="">Select status</option>
<?php
if (isset($trigger_type) && count($trigger_type)) {
foreach ($trigger_type as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>";
}
if (isset($trigger_type) && count($trigger_type)) {
foreach ($trigger_type as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>";
}
}
?>
</select> <input id="primaryKey" type="hidden">
</div>
@ -171,6 +180,12 @@ table.dataTable tbody td {
</div>
<div class="form-group col-md-6">
<label for="claim_status_for_template">Claim Status</label>
<input type="text" readonly id="claim_status_for_template" class="form-control" />
</div>
</div>
<div class="form-row">
@ -191,12 +206,15 @@ table.dataTable tbody td {
<select id="ticket_mail_customButton" class="form-control"
style="border:none;right: 6px;width: auto;position: absolute;z-index: 1;top: 17px;height: 32px;float: right;">
<option value="">PlaceHolders</option>
<?php foreach ($placeHolders as $key => $value): ?>
<?php // if($value == 'member_name' || $value == 'member_mobile' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){ ?>member_mobile
<?php $valueChange = str_replace('_', ' ', $value); $valueChange = ucwords($valueChange); ?>
<option value="<?php echo $key; ?>"><?php echo $valueChange; ?></option>
</option>
<?php //} ?>
<?php foreach ($placeHolders as $key => $value): ?>
<?php // if($value == 'member_name' || $value == 'member_mobile' || $value == 'nhance_logo' || $value == 'client_logo' || $value == 'app_link' || $value == 'client_name'){
?>member_mobile
<?php $valueChange = str_replace('_', ' ', $value);
$valueChange = ucwords($valueChange); ?>
<option value="<?php echo $key; ?>"><?php echo $valueChange; ?></option>
</option>
<?php //}
?>
<?php endforeach; ?>
</select>
</div>
@ -216,392 +234,397 @@ table.dataTable tbody td {
</div><!-- /.modal -->
<!-------------------------------------------------------------------------------------------------->
<script>
// Datatable document ready
$(document).ready(function() {
var ticketsTable = $('#scroll-horizontal-datatable');
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
buttons: [{
text: 'Add Template',
className: 'buttons-html5 addbtnStyle',
action: function(e, dt, node, config) {
openModal()
}
}],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 25, // Set default number of rows per page (optional)
ordering: false,
});
} else {
console.error("Table atet found.");
}
var toolbar = "bold,italic,strikethrough,|,superscript,subscript,|,align,";
const editorConfig = {
buttons: toolbar.concat(['fontsize']),
fontsize: [8, 10, 12, 14, 16, 18, 20, 22, 24], // Customize font sizes
showPlaceholder: false,
toolbarButtonSize: 'small',
toolbarAdaptive: false,
saveHeightInStorage: true,
minHeight: 400,
extraButtons: [{
name: 'info',
iconURL: '<?= base_url()."public"; ?>/assets/images/image-solid.svg', // Replace with the actual icon URL
exec: function(editor) {
const fileInput = document.getElementById("Question_title_fileInput");
fileInput.click();
},
}, ],
};
const editor = Jodit.make("#ticket_mail_editor", editorConfig);
let lastActiveField = null;
// Track last active input field
$("#template_subject").on("focus", function() {
lastActiveField = this;
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
});
// Track Jodit editor focus separately
editor.events.on("focus", function() {
lastActiveField = editor;
});
document.addEventListener('change', function(event) {
var target = event.target;
if (target.matches('#ticket_mail_customButton')) {
let placeholderValue = $(target).val();
if (!placeholderValue) return;
if (lastActiveField) {
if (lastActiveField.id === "template_subject") {
insertAtCursor(lastActiveField, placeholderValue);
} else {
editor.selection.insertHTML(placeholderValue);
}
}
$(target).val('');
}
});
function insertAtCursor(input, textToInsert) {
if (document.selection) {
input.focus();
var sel = document.selection.createRange();
sel.text = textToInsert;
} else if (input.selectionStart || input.selectionStart === 0) {
let startPos = input.selectionStart;
let endPos = input.selectionEnd;
input.value = input.value.substring(0, startPos) + textToInsert + input.value.substring(endPos,
input.value.length);
input.selectionStart = input.selectionEnd = startPos + textToInsert.length;
} else {
input.value += textToInsert;
}
}
$('.close').click(function() {
$('#template_subject').val('');
$('#template_name').val('');
$('#primaryKey').val('');
$('#policy_type').val('').change();
$('#trigger_type').val('').change();
editor.setEditorValue('');
$('#primaryKey').val(null);
$('#statusSwitch').prop('checked', false);
})
$('#ticket_mail_editor_modal').submit(function(event) {
event.preventDefault();
let isValid = true;
$('#ticket_mail_editor_modal [required]').each(function() {
if (!this.value.trim()) {
isValid = false;
$(this).addClass('is-invalid'); // Add a red border for visibility
} else {
$(this).removeClass('is-invalid');
}
});
if (!isValid) {
toastr.error('Please fill all required fields.', 'Validation Error');
return; // Prevent submission
}
var joditEditor = editor;
if (joditEditor) {
var mailContent = $(joditEditor.currentPlace.container).find('.jodit-wysiwyg').html();
var formData = $(this).serializeArray();
formData.push({
name: 'mail_content',
value: mailContent
});
// formData.push({ name: 'client_id', value: $('#general_PrimaryKey').val() });
var isAutoMailEnabled = $('#statusSwitch').is(':checked') ? 1 : 0;
formData.push({
name: 'is_auto_mail',
value: isAutoMailEnabled
});
var primary_key = $('#primaryKey').val();
if (primary_key != null && primary_key != '') {
formData.push({
name: 'id',
value: primary_key
});
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var form_action = '<?= base_url("ticket/crud_mail_template/1") ?>';
$.ajax({
url: form_action,
type: "POST",
data: formData,
dataType: 'json',
success: function(res) {
if (res.status == true) {
$('#new_mail_template').find('.close').click();
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.success('Template saved successfully!', 'Success');
location.reload();
} else if (res.status == false) {
toastr.error('Failed to Save Data', 'error');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.error('Something Wrong!', 'warning');
}, 1000);
}
});
} else {
console.error("Jodit editor instance is not defined.");
}
})
});
function openModal() {
var myModal = new bootstrap.Modal(document.getElementById('new_mail_template'));
myModal.show();
}
function deleteTemplate(id) {
const url = '<?= base_url("ticket/crud_mail_template/3") ?>';
const data = {
id: id
}; // Ensure data is passed as an object
Swal.fire({
title: "Are you sure?",
text: "You need to remove this template.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: url,
type: "POST",
data: data,
success: function(res) {
if (res.status === true) {
location.reload();
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.success('Template Deleted successfully!', 'Success');
} else if (res.status === false) {
toastr.error('Failed to Delete Template', 'Error');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.error('Something went wrong!', 'Warning');
}, 1000);
}
});
}
});
}
function getMailTemplateData(id) {
const template_name = 'new_mail_template';
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var form_action = '<?= base_url("ticket/crud_mail_template/2") ?>';
var data = {
id: id
};
$.ajax({
url: form_action,
type: "POST",
data: data,
success: function(res) {
console.log('get Mail Template Data', res);
if (res) {
if (res.status == true) {
// Open the modal
openModal();
// Populate the form fields
$('#template_subject').val(res.data.subject);
$('#template_name').val(res.data.template_name);
$('#primaryKey').val(res.data.id);
$('#policy_type').val(res.data.ticket_type).change();
$('#trigger_type').val(res.data.trigger_type).change();
$('.jodit-wysiwyg').html(res.data.mail_content);
// Set the auto mail switch
if (res.data.is_auto_mail == 1) {
$('#statusSwitch').prop('checked', true);
} else {
$('#statusSwitch').prop('checked', false);
}
// Populate any additional fields if necessary, like placeholders
// Assuming `placeholders` is an array in the response
if (res.placeholders) {
res.placeholders.forEach(function(placeholder) {
// You can populate any dropdown or field as required
$('#ticket_mail_customButton').val(placeholder);
});
}
} else {
toastr.error('Data Not Found', 'error');
}
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Went Wrong!', 'warning');
}, 1000);
}
});
}
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
const table = document.getElementById("scroll-horizontal-datatable");
// Datatable document ready
$(document).ready(function() {
// Create custom dropdown
function createCustomDropdown(row) {
// Get the original dropdown items
const originalDropdown = row.querySelector('.dropdown-menu');
if (!originalDropdown) return null;
var ticketsTable = $('#scroll-horizontal-datatable');
// Create new dropdown with proper background and spacing
const customDropdown = document.createElement('div');
customDropdown.className = 'custom-dropdown-menu';
if (ticketsTable.length) {
// Copy inner content while maintaining icon alignment
customDropdown.innerHTML = originalDropdown.innerHTML;
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector
buttons: [{
text: 'Add Template',
className: 'buttons-html5 addbtnStyle',
action: function(e, dt, node, config) {
openModal()
}
}],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true, // Enable pagination
pageLength: 25, // Set default number of rows per page (optional)
ordering: false,
});
} else {
console.error("Table atet found.");
}
var toolbar = "bold,italic,strikethrough,|,superscript,subscript,|,align,";
const editorConfig = {
buttons: toolbar.concat(['fontsize']),
fontsize: [8, 10, 12, 14, 16, 18, 20, 22, 24], // Customize font sizes
showPlaceholder: false,
toolbarButtonSize: 'small',
toolbarAdaptive: false,
saveHeightInStorage: true,
minHeight: 400,
extraButtons: [{
name: 'info',
iconURL: '<?= base_url() . "public"; ?>/assets/images/image-solid.svg', // Replace with the actual icon URL
exec: function(editor) {
const fileInput = document.getElementById("Question_title_fileInput");
fileInput.click();
},
}, ],
};
return customDropdown;
const editor = Jodit.make("#ticket_mail_editor", editorConfig);
let lastActiveField = null;
// Track last active input field
$("#template_subject").on("focus", function() {
lastActiveField = this;
});
// Track Jodit editor focus separately
editor.events.on("focus", function() {
lastActiveField = editor;
});
document.addEventListener('change', function(event) {
var target = event.target;
if (target.matches('#ticket_mail_customButton')) {
let placeholderValue = $(target).val();
if (!placeholderValue) return;
if (lastActiveField) {
if (lastActiveField.id === "template_subject") {
insertAtCursor(lastActiveField, placeholderValue);
} else {
editor.selection.insertHTML(placeholderValue);
}
}
$(target).val('');
}
});
function insertAtCursor(input, textToInsert) {
if (document.selection) {
input.focus();
var sel = document.selection.createRange();
sel.text = textToInsert;
} else if (input.selectionStart || input.selectionStart === 0) {
let startPos = input.selectionStart;
let endPos = input.selectionEnd;
input.value = input.value.substring(0, startPos) + textToInsert + input.value.substring(endPos,
input.value.length);
input.selectionStart = input.selectionEnd = startPos + textToInsert.length;
} else {
input.value += textToInsert;
}
}
$('.close').click(function() {
$('#template_subject').val('');
$('#template_name').val('');
$('#primaryKey').val('');
$('#policy_type').val('').change();
$('#trigger_type').val('').change();
editor.setEditorValue('');
$('#primaryKey').val(null);
$('#statusSwitch').prop('checked', false);
})
$('#ticket_mail_editor_modal').submit(function(event) {
event.preventDefault();
let isValid = true;
$('#ticket_mail_editor_modal [required]').each(function() {
if (!this.value.trim()) {
isValid = false;
$(this).addClass('is-invalid'); // Add a red border for visibility
} else {
$(this).removeClass('is-invalid');
}
});
if (!isValid) {
toastr.error('Please fill all required fields.', 'Validation Error');
return; // Prevent submission
}
var joditEditor = editor;
if (joditEditor) {
var mailContent = $(joditEditor.currentPlace.container).find('.jodit-wysiwyg').html();
var formData = $(this).serializeArray();
formData.push({
name: 'mail_content',
value: mailContent
});
// formData.push({ name: 'client_id', value: $('#general_PrimaryKey').val() });
var isAutoMailEnabled = $('#statusSwitch').is(':checked') ? 1 : 0;
formData.push({
name: 'is_auto_mail',
value: isAutoMailEnabled
});
var primary_key = $('#primaryKey').val();
if (primary_key != null && primary_key != '') {
formData.push({
name: 'id',
value: primary_key
});
}
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var form_action = '<?= base_url("ticket/crud_mail_template/1") ?>';
$.ajax({
url: form_action,
type: "POST",
data: formData,
dataType: 'json',
success: function(res) {
if (res.status == true) {
$('#new_mail_template').find('.close').click();
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.success('Template saved successfully!', 'Success');
location.reload();
} else if (res.status == false) {
toastr.error('Failed to Save Data', 'error');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.error('Something Wrong!', 'warning');
}, 1000);
}
});
} else {
console.error("Jodit editor instance is not defined.");
}
})
});
function openModal() {
var myModal = new bootstrap.Modal(document.getElementById('new_mail_template'));
myModal.show();
}
let activeDropdown = null;
function deleteTemplate(id) {
const url = '<?= base_url("ticket/crud_mail_template/3") ?>';
const data = {
id: id
}; // Ensure data is passed as an object
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
Swal.fire({
title: "Are you sure?",
text: "You need to remove this template.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: url,
type: "POST",
data: data,
success: function(res) {
if (res.status === true) {
location.reload();
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.success('Template Deleted successfully!', 'Success');
} else if (res.status === false) {
toastr.error('Failed to Delete Template', 'Error');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.error('Something went wrong!', 'Warning');
}, 1000);
}
});
}
// 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
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
}
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
function getMailTemplateData(id) {
const template_name = 'new_mail_template';
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var form_action = '<?= base_url("ticket/crud_mail_template/2") ?>';
var data = {
id: id
};
$.ajax({
url: form_action,
type: "POST",
data: data,
success: function(res) {
console.log('get Mail Template Data', res);
if (res) {
if (res.status == true) {
// Open the modal
openModal();
// Populate the form fields
$('#template_subject').val(res.data.subject);
$('#template_name').val(res.data.template_name);
$('#primaryKey').val(res.data.id);
$('#policy_type').val(res.data.ticket_type).change();
$('#trigger_type').val(res.data.trigger_type).change();
$('#claim_status_for_template').val(res.data.tool_tip);
$('.jodit-wysiwyg').html(res.data.mail_content);
// Set the auto mail switch
if (res.data.is_auto_mail == 1) {
$('#statusSwitch').prop('checked', true);
} else {
$('#statusSwitch').prop('checked', false);
}
// Populate any additional fields if necessary, like placeholders
// Assuming `placeholders` is an array in the response
if (res.placeholders) {
res.placeholders.forEach(function(placeholder) {
// You can populate any dropdown or field as required
$('#ticket_mail_customButton').val(placeholder);
});
}
} else {
toastr.error('Data Not Found', 'error');
}
}
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
setTimeout(function() {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
toastr.warning('Something Went Wrong!', 'warning');
}, 1000);
}
});
}
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
const table = document.getElementById("scroll-horizontal-datatable");
// 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;
return customDropdown;
}
let activeDropdown = null;
// Add click event listener to rows
table.querySelectorAll("tbody tr").forEach(row => {
const customDropdown = createCustomDropdown(row);
if (!customDropdown) return;
document.body.appendChild(customDropdown);
row.addEventListener("click", function(event) {
// Ignore clicks on the action column
if (event.target.closest('td:last-child')) {
return;
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
// Hide any active dropdown
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
// 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
// Set as active dropdown
activeDropdown = customDropdown;
event.stopPropagation();
});
// Preserve click handlers and add auto-close
customDropdown.querySelectorAll('.dropdown-item').forEach(item => {
item.addEventListener('click', function(e) {
const onclickAttr = this.getAttribute('onclick');
if (onclickAttr) {
eval(onclickAttr);
}
const href = this.getAttribute('href');
if (href && href !== '#') {
window.location.href = href;
}
// Close the dropdown after handling the click
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
e.stopPropagation();
});
});
});
});
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
// Close dropdown when clicking outside
document.addEventListener("click", function() {
if (activeDropdown) {
activeDropdown.style.display = 'none';
activeDropdown = null;
}
});
});
});
</script>

View File

@ -19,7 +19,7 @@
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="submitToRedirectTicketNewUrl(this)">submit</button>
<button type="button" class="btn btn-primary" onclick="submitToRedirectTicketNewUrl(this)">Submit</button>
</div>
</div>
</div>