136 lines
5.3 KiB
PHP
136 lines
5.3 KiB
PHP
<div class="tab-pane fade active show" id="general-q-tab">
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card-body">
|
|
<form role="form" class="parsley-examples" method="post" id="tpa_general_form" enctype="multipart/form-data">
|
|
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
|
<input type="hidden" name="PrimaryKey" id="tpa_General_PrimaryKey" value="<?= isset($tpa['id']) ? $tpa['id'] : '' ?>"/>
|
|
<input type="hidden" name="tpa_id" id="tpa_id" />
|
|
<div class="form-group">
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="tpa_name">TPA Name<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="tpa_name" placeholder="Enter TPA Name" value="<?= isset($tpa['name']) ? $tpa['name'] : '' ?>" name="name" required>
|
|
</div>
|
|
<div class="form-group col-md-4">
|
|
<label for="short_name">TPA Short Name<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="short_name" placeholder="Enter Short Name" value="<?= isset($tpa['short_name']) ? $tpa['short_name'] : '' ?>" name="short_name" required>
|
|
</div>
|
|
</div>
|
|
|
|
<hr>
|
|
</div>
|
|
|
|
<div class="form-group text-right m-b-0">
|
|
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
|
id="btnSubmit">Submit</button>
|
|
<button type="button" class="btn btn-secondary waves-effect btnBack"
|
|
id="btnBack">Cancel</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div> <!-- end col-->
|
|
</div>
|
|
</div>
|
|
<!-- end -->
|
|
|
|
<script>
|
|
|
|
$(document).ready(function () {
|
|
|
|
$("#tpa_general_form").submit(function(events) {
|
|
|
|
events.preventDefault();
|
|
var isValid = $('#tpa_general_form').parsley().validate();
|
|
|
|
var PrimaryKey = $('#tpa_General_PrimaryKey').val();
|
|
var form_action = '';
|
|
if (isValid) {
|
|
|
|
if(PrimaryKey === ''){
|
|
form_action = '<?= base_url("master/tpa/createpost"); ?>';
|
|
}else{
|
|
form_action = '<?= base_url("master/tpa/edit"); ?>';
|
|
}
|
|
|
|
var formData = new FormData($('#tpa_general_form')[0]);
|
|
var OptionsHTML1 = '';
|
|
$('.loader').fadeIn();
|
|
$('.loader-mask').fadeIn();
|
|
$.ajax({
|
|
data: formData,
|
|
url: form_action,
|
|
type: "POST",
|
|
dataType: 'json',
|
|
processData: false,
|
|
contentType: false,
|
|
success: function(res) {
|
|
setTimeout(function() {
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
}, 1000);
|
|
|
|
console.log(res);
|
|
$('#tpa_id').val(res.data.id);
|
|
$('#tpa_General_PrimaryKey').val(res.data.id);
|
|
$('#tpa_id_branch').val(res.data.id);
|
|
$('#tpa_branch_contacts_id').click();
|
|
|
|
$('#btnBranchAdd').show();
|
|
var message = "TPA General Info";
|
|
toastr.success(message, 'Success');
|
|
|
|
// $.toast({
|
|
// text: 'Insurer General Info',
|
|
// heading: "Submitted Sucessfully",
|
|
// position: 'top-right',
|
|
// icon: 'success',
|
|
// bgColor: !1,
|
|
// });
|
|
|
|
},
|
|
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 Wrong!', 'warning');
|
|
}, 1000);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
function validateForm() {
|
|
var isValid = true;
|
|
|
|
// Perform validation for each field
|
|
$('#tpa_general_form input, #tpa_general_form select').each(function() {
|
|
// Check for empty text inputs and selects
|
|
if ($(this).is('input[type="text"]') || $(this).is('select')) {
|
|
if ($.trim($(this).val()) == '') {
|
|
alert('Please fill in all fields');
|
|
isValid = false;
|
|
return false; // Exit the loop early
|
|
}
|
|
}
|
|
|
|
// Check for file inputs (assuming image files)
|
|
if ($(this).is('input[type="file"]')) {
|
|
var fileInput = $(this)[0];
|
|
if (fileInput.files.length === 0) {
|
|
alert('Please select an image file');
|
|
isValid = false;
|
|
return false; // Exit the loop early
|
|
}
|
|
}
|
|
});
|
|
|
|
return isValid;
|
|
}
|
|
|
|
|
|
});
|
|
|
|
</script> |