FIX_Motor Claims 3
This commit is contained in:
parent
9307155156
commit
69edb165e7
@ -731,7 +731,7 @@ class TicketController extends BaseController
|
||||
$data['claim_type'] = $this->claimType[2];
|
||||
}
|
||||
|
||||
$data['client_for_motor'] = $this->clientModel->select('id,client_name')->where('client_type', 2)->where('is_active', 1)->findAll();
|
||||
$data['client_for_motor'] = $this->clientModel->select('id,client_name,phone')->where('client_type', 2)->where('is_active', 1)->findAll();
|
||||
|
||||
$this->myLogger->logme('error', "Ticket form data fetched successfully for Ticket Type: $ticket_type");
|
||||
|
||||
@ -875,15 +875,7 @@ class TicketController extends BaseController
|
||||
{
|
||||
// $ticket_data = $this->ticketMasterModel->where('id', $ticket_id)->where('is_active', 1)->first();
|
||||
$ticket_data = $this->ticketMasterModel->getTicketDataByTicketID($ticket_id);
|
||||
if($ticket_data['ticket_type_id'] == 8){
|
||||
$this->motor_claim($ticket_data,$ticket_id);
|
||||
}else{
|
||||
$this->other_claim($ticket_data,$ticket_id);
|
||||
}
|
||||
}
|
||||
|
||||
public function other_claim($ticket_data,$ticket_id)
|
||||
{
|
||||
|
||||
$ticket_data = $this->formatDateForClaim($ticket_data, 'd/m/Y');
|
||||
|
||||
if (in_array($ticket_data['claim_status_id'], [15, 25, 35])) {
|
||||
@ -942,22 +934,15 @@ class TicketController extends BaseController
|
||||
// print_rr($data); die;
|
||||
}
|
||||
|
||||
return $this->loadLayout('ticket_edit_onbording', $data);
|
||||
}
|
||||
// 8TH TYPE is Motor - so do not remove it....
|
||||
if($ticket_data['ticket_type_id'] == 8){
|
||||
$claim_status_id = $ticket_data['claim_status_id'];
|
||||
$ticket_type = $ticket_data['ticket_type_id'];
|
||||
$data['claim_status'] = $this->transFormClaimStatus($claim_status_id, $ticket_type);
|
||||
$data['client_for_motor'] = $this->clientModel->select('id,client_name,phone')->where('client_type', 2)->where('is_active', 1)->findAll();
|
||||
}
|
||||
|
||||
public function motor_claim($ticket_data,$ticket_id)
|
||||
{
|
||||
$claim_status_id = $ticket_data['claim_status_id'];
|
||||
$ticket_type = $ticket_data['ticket_type_id'];
|
||||
|
||||
$data['selected_ticket_type'] = $ticket_type;
|
||||
$data['ticket_type'] = [ 8 => 'Motor' ];
|
||||
$data['ticket_data'] = $ticket_data;
|
||||
// print_r($ticket_data);die;
|
||||
$data['claim_status'] = $this->transFormClaimStatus($claim_status_id, $ticket_type);
|
||||
$data['client_for_motor'] = $this->clientModel->select('id,client_name')->where('client_type', 2)->where('is_active', 1)->findAll();
|
||||
// print_r($data);die;
|
||||
return $this->loadLayout('ticket_form_motor', $data);
|
||||
return $this->loadLayout('ticket_edit_onbording', $data);
|
||||
}
|
||||
|
||||
public function formatDateForClaim($ticket_data, $out_put_format = 'Y-m-d')
|
||||
|
||||
@ -54,6 +54,7 @@
|
||||
<span class="d-none d-sm-inline-block">History</span>
|
||||
</a>
|
||||
</li>
|
||||
<?php if(in_array($ticket_data['ticket_type_id'], [1,2,3,4,5,6,7])){ ?>
|
||||
<li class="nav-item">
|
||||
<a href="#autoQuery-tab" data-toggle="tab" class="nav-link px-2 py-1 label-font-size" id="auto_query_tab"
|
||||
aria-expanded="false">
|
||||
@ -61,6 +62,7 @@
|
||||
<span class="d-none d-sm-inline-block">Auto Query Content</span>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li class="nav-item">
|
||||
<a href="#uploads-tab" data-toggle="tab" class="nav-link px-2 py-1 label-font-size" id="uploads_tab"
|
||||
aria-expanded="false">
|
||||
@ -68,6 +70,7 @@
|
||||
<span class="d-none d-sm-inline-block">Claim Files</span>
|
||||
</a>
|
||||
</li>
|
||||
<?php if(in_array($ticket_data['ticket_type_id'], [1,2,3,4,5,6,7])){ ?>
|
||||
<li class="nav-item">
|
||||
<a href="#viewpolicyterms-tab" data-toggle="tab" class="nav-link px-2 py-1 label-font-size" id="viewpolicyterms_tab"
|
||||
aria-expanded="false">
|
||||
@ -75,6 +78,7 @@
|
||||
<span class="d-none d-sm-inline-block">View Policy Terms</span>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
|
||||
<!-- Tab Content -->
|
||||
@ -84,9 +88,11 @@
|
||||
|
||||
if ($ticket_data['ticket_type_id'] == 1) {
|
||||
include('ticket_form_gmc.php');
|
||||
} else if($ticket_data['ticket_type_id'] == 8){
|
||||
include('ticket_form_motor.php');
|
||||
} else {
|
||||
include('ticket_form_gpa.php');
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="reply-tab">
|
||||
@ -98,15 +104,19 @@
|
||||
<div class="tab-pane fade" id="history-tab">
|
||||
<?php include('ticket_history.php'); ?>
|
||||
</div>
|
||||
<?php if(in_array($ticket_data['ticket_type_id'], [1,2,3,4,5,6,7])){ ?>
|
||||
<div class="tab-pane fade" id="autoQuery-tab">
|
||||
<?php include('ticket_auto_query.php'); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="tab-pane fade" id="uploads-tab">
|
||||
<?php include('claim_files_upload.php'); ?>
|
||||
</div>
|
||||
<?php if(in_array($ticket_data['ticket_type_id'], [1,2,3,4,5,6,7])){ ?>
|
||||
<div class="tab-pane fade" id="viewpolicyterms-tab">
|
||||
<?php include('view_policy_terms.php'); ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -27,11 +27,11 @@
|
||||
<div class="col-12">
|
||||
<div class="<?= !isset($ticket_data) ? "card" : "" ?>" style="margin-right: 23px;">
|
||||
<div class="card-body">
|
||||
<?php // if (!isset($ticket_data)) { ?>
|
||||
<?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"> Motor </h4>
|
||||
<h4 class="mb-0">Claim <?= $ticket_form ?></h4>
|
||||
</div>
|
||||
<div class="col-6 text-right">
|
||||
<a href="<?= base_url('ticket/list'); ?>" aria-label="Back to ticket list">
|
||||
@ -39,16 +39,21 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php // } ?>
|
||||
<form role="form" class="parsley-examples" method="post" id="ticket_form_data" onsubmit="submitClaimForm(event, this)"
|
||||
<?php } ?>
|
||||
<form role="form" class="parsley-examples" method="post" id="ticket_form_data"
|
||||
onsubmit="return validateBeforeSubmit(event, this)"
|
||||
enctype="multipart/form-data">
|
||||
|
||||
<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">
|
||||
<h5>General Details</h5>
|
||||
<hr>
|
||||
<!-- Hide_data_points -->
|
||||
<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="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
|
||||
<input type="hidden" id="emp_id" name="emp_id" value="<?= isset($ticket_data['emp_id']) ? $ticket_data['emp_id'] : '' ?>">
|
||||
<input type="hidden" id="emp_name" name="emp_name" value="<?= isset($ticket_data['emp_name']) ? $ticket_data['emp_name'] : '' ?>">
|
||||
<!-- first_data_points -->
|
||||
<div class="form-row">
|
||||
|
||||
@ -70,62 +75,60 @@
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="label-font-size" for="client_name">Client Name <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="client_name" name="client_name" required onchange="fetchOtherDetails(this,1)">
|
||||
<select class="form-control" id="client_name" name="client_name" required onchange="fetchOtherDetails(this,1)" data-parsley-trigger="change" data-parsley-required-message="Please select a option">
|
||||
<option value="0">Select Client</option>
|
||||
<?php
|
||||
if (isset($client_for_motor) && count($client_for_motor)) {
|
||||
foreach ($client_for_motor as $value) {
|
||||
$selected = (isset($ticket_data) && $ticket_data['client_name'] == $value['client_name']) ? 'selected' : '';
|
||||
echo '<option data-cid="'.$value['id'].'" data-cname="'.$value['client_name'].'" value="'.$value['client_name'].'" '.$selected.'>'.$value['client_name'].'</option>';
|
||||
echo '<option data-cid="'.$value['id'].'" data-cname="'.$value['client_name'].'" value="'.$value['client_name'].'" '.$selected.'>'.$value['client_name'] .' - '.$value['phone'] .'</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<input type="hidden" id="client_id" name="client_id" value="<?= isset($ticket_data['client_id']) ? $ticket_data['client_id'] : '' ?>">
|
||||
<input type="hidden" id="emp_id" name="emp_id" value="<?= isset($ticket_data['emp_id']) ? $ticket_data['emp_id'] : '' ?>">
|
||||
<input type="hidden" id="emp_name" name="emp_name" value="<?= isset($ticket_data['emp_name']) ? $ticket_data['emp_name'] : '' ?>">
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="label-font-size" for="vehicle_id">Vehicle <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="vehicle_id" name="vehicle_id" required>
|
||||
<option value="0">Select Vehicle Number</option>
|
||||
<select class="form-control" id="vehicle_id" name="vehicle_id" required data-parsley-trigger="change" data-parsley-required-message="Please select a option">
|
||||
<option value="0">Select Vehicle</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label class="label-font-size">Policy <span class="text-danger">*</span></label>
|
||||
<select id="emp_client_policy" name="client_policy_id" onchange="fetchOtherDetails(this,2)">
|
||||
<option value=""
|
||||
<label class="label-font-size" for="emp_client_policy">Policy <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="emp_client_policy" name="client_policy_id" required onchange="fetchOtherDetails(this,2)" data-parsley-trigger="change" data-parsley-required-message="Please select a option">
|
||||
<option value="0"
|
||||
data-policynumber="" data-managerid=""
|
||||
data-insuredname="" data-agentid=""
|
||||
data-insurerid="" data-insurername="" >Select Policy Number</option>
|
||||
data-insurerid="" data-insurername="" >Select Policy</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="label-font-size" for="insurer_name">Insurer </label>
|
||||
<input type=text class="form-control" id="insurer_name" placeholder="Enter Insurer" value="<?= isset($ticket_data['insurer_name']) ? $ticket_data['insurer_name'] : '' ?>" readonly>
|
||||
<input type="hidden" id="insurer_id" name="insurer_id" value="<?= isset($ticket_data['insurer_id']) ? $ticket_data['insurer_id'] : '' ?>">
|
||||
<input type="hidden" id="agent_id" name="agent_id" value="<?= isset($ticket_data['agent_id']) ? $ticket_data['agent_id'] : '' ?>">
|
||||
<input type="hidden" id="manager_id" name="manager_id" value="<?= isset($ticket_data['manager_id']) ? $ticket_data['manager_id'] : '' ?>">
|
||||
<input type="hidden" id="policy_no" name="policy_no" value="<?= isset($ticket_data['policy_no']) ? $ticket_data['policy_no'] : '' ?>">
|
||||
<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 class="label-font-size" for="emp_mobile"> Mobile No </label>
|
||||
<input type="text" class="form-control" id="emp_mobile" placeholder="Enter EMP Mobile"
|
||||
<input type="text" class="form-control" id="emp_mobile" placeholder="Enter Mobile No"
|
||||
value="<?= isset($ticket_data['emp_mobile']) ? $ticket_data['emp_mobile'] : '' ?>"
|
||||
name="emp_mobile" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="label-font-size" for="emp_mail"> Mail ID </label>
|
||||
<input type="text" class="form-control" id="emp_mail" placeholder="Enter EMP Mail"
|
||||
<input type="text" class="form-control" id="emp_mail" placeholder="Enter Mail ID"
|
||||
value="<?= isset($ticket_data['emp_mail']) ? $ticket_data['emp_mail'] : '' ?>"
|
||||
name="emp_mail" readonly>
|
||||
</div>
|
||||
@ -179,10 +182,11 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label class="label-font-size" for="claim_status">Status <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="claim_status_id" name="claim_status_id" required>
|
||||
<option value="0">Select status</option>
|
||||
<label class="label-font-size" for="claim_status_id">Status <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="claim_status_id" name="claim_status_id" required data-parsley-trigger="change" data-parsley-required-message="Please select a status">
|
||||
<option value="0">Select Status</option>
|
||||
<?php
|
||||
if (isset($claim_status) && count($claim_status)) {
|
||||
foreach ($claim_status as $key => $value) {
|
||||
@ -1012,6 +1016,11 @@
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
|
||||
// window.onload = function() {
|
||||
// document.getElementById("ticket_form_data").reset();
|
||||
// };
|
||||
|
||||
$("#emp_client_policy").select2();
|
||||
$("#vehicle_id").select2();
|
||||
$("#client_name").select2();
|
||||
@ -1077,7 +1086,7 @@
|
||||
success: function (res) {
|
||||
// Vehicle dropdown
|
||||
let $vehicleSelect = $('#vehicle_id');
|
||||
$vehicleSelect.empty().append('<option value="0">Select vehicle</option>');
|
||||
$vehicleSelect.empty().append('<option value="0">Select Vehicle</option>');
|
||||
$.each(res.data.vehicle_list, function(index, item) {
|
||||
let selected = (vehicleId && vehicleId == item.id) ? "selected" : "";
|
||||
$vehicleSelect.append('<option value="'+ item.id +'" '+selected+'>'+ item.vehicle_no +'</option>');
|
||||
@ -1086,7 +1095,7 @@
|
||||
|
||||
// Policy dropdown
|
||||
let $policySelect = $('#emp_client_policy');
|
||||
$policySelect.empty().append('<option value="0">Select policy</option>');
|
||||
$policySelect.empty().append('<option value="0">Select Policy</option>');
|
||||
$.each(res.data.partner_policy_list, function(index, item) {
|
||||
let selected = (policyId && policyId == item.id) ? "selected" : "";
|
||||
$policySelect.append(
|
||||
@ -1110,13 +1119,73 @@
|
||||
});
|
||||
}
|
||||
|
||||
function setReadonlyField(fieldId, value, labelText) {
|
||||
if (value && value.trim() !== "") {
|
||||
$("#" + fieldId).val(value).prop("readonly", true).prop("required", false);
|
||||
$('label[for="' + fieldId + '"]').html(labelText);
|
||||
} else {
|
||||
$("#" + fieldId).val("").prop("readonly", false).prop("required", true);
|
||||
$('label[for="' + fieldId + '"]').html(labelText + ' <span class="text-danger">*</span>');
|
||||
function setReadonlyField(fieldId, value, labelText) {
|
||||
let $field = $("#" + fieldId);
|
||||
let $label = $('label[for="' + fieldId + '"]');
|
||||
|
||||
if (value && value.trim() !== "") {
|
||||
// Not required, readonly
|
||||
$field.val(value).prop("readonly", true).prop("required", false)
|
||||
.removeAttr("data-parsley-trigger")
|
||||
.removeAttr("data-parsley-required-message");
|
||||
$label.html(labelText);
|
||||
} else {
|
||||
$field.val("").prop("readonly", false).prop("required", true)
|
||||
.attr("data-parsley-trigger", "change")
|
||||
.attr("data-parsley-required-message", "Please Enter " + labelText.toLowerCase());
|
||||
$label.html(labelText + ' <span class="text-danger">*</span>');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validateBeforeSubmit(e, form) {
|
||||
e.preventDefault();
|
||||
var $form = $(form);
|
||||
|
||||
// Remove old error messages (only for selects)
|
||||
$form.find(".field-error").remove();
|
||||
$form.find("select").removeClass("is-invalid");
|
||||
|
||||
let isValid = true;
|
||||
|
||||
|
||||
// $form.find("input[required], select[required]").each(function ()
|
||||
$form.find("select[required]").each(function () {
|
||||
let $field = $(this);
|
||||
let value = $field.val().trim();
|
||||
|
||||
if (value === "" || value === "0" || value === undefined) {
|
||||
isValid = false;
|
||||
$field.addClass("is-invalid");
|
||||
|
||||
let errorMessage = $field.attr("data-parsley-required-message") || "This field is required";
|
||||
|
||||
$field.closest(".form-group").append(
|
||||
'<p class="field-error text-danger d-block mt-1">' +
|
||||
errorMessage +
|
||||
'</p>'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
if (!isValid) {
|
||||
let $firstError = $form.find(".is-invalid").first();
|
||||
$("html, body").animate(
|
||||
{ scrollTop: $firstError.offset().top - 100 },
|
||||
500
|
||||
);
|
||||
$firstError.focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
// ✅ Let Parsley validate inputs automatically
|
||||
if (!$form.parsley().validate()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// All good
|
||||
submitClaimForm(e, form);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user