281 lines
12 KiB
PHP
Executable File
281 lines
12 KiB
PHP
Executable File
<style>
|
|
.switch {
|
|
position: relative;
|
|
display: inline-block;
|
|
width: 54px;
|
|
height: 34px;
|
|
}
|
|
|
|
.switch input {
|
|
opacity: 0;
|
|
width: 0;
|
|
height: 0;
|
|
}
|
|
|
|
.slider {
|
|
position: absolute;
|
|
cursor: pointer;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: #ccc;
|
|
-webkit-transition: .4s;
|
|
transition: .4s;
|
|
}
|
|
|
|
.slider:before {
|
|
position: absolute;
|
|
content: "";
|
|
height: 19px;
|
|
width: 19px;
|
|
left: 4px;
|
|
bottom: 4px;
|
|
background-color: white;
|
|
-webkit-transition: .4s;
|
|
transition: .4s;
|
|
}
|
|
|
|
input:checked + .slider {
|
|
background-color: #2196F3;
|
|
}
|
|
|
|
input:focus + .slider {
|
|
box-shadow: 0 0 1px #2196F3;
|
|
}
|
|
|
|
input:checked + .slider:before {
|
|
-webkit-transform: translateX(26px);
|
|
-ms-transform: translateX(26px);
|
|
transform: translateX(26px);
|
|
}
|
|
|
|
/* Rounded sliders */
|
|
.slider.round {
|
|
border-radius: 34px;
|
|
}
|
|
|
|
.slider.round:before {
|
|
border-radius: 50%;
|
|
}
|
|
</style>
|
|
|
|
<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="insurer_general_form" enctype="multipart/form-data">
|
|
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
|
<input type="hidden" name="PrimaryKey" id="insurer_General_PrimaryKey" value="<?= isset($insurer['id']) ? $insurer['id'] : '' ?>" />
|
|
<input type="hidden" name="insurer_id" id="insurer_id" />
|
|
<div class="form-group">
|
|
|
|
<div class="form-row">
|
|
<div class="form-group col-md-4">
|
|
<label for="insurer_name">Insurer Name<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="insurer_name" placeholder="Enter Insurer Name" value="<?= isset($insurer['name']) ? $insurer['name'] : '' ?>" name="name" required>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-2">
|
|
<label for="short_name">Insurer Short Name<span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="short_name" placeholder="Enter Short Name" value="<?= isset($insurer['short_name']) ? $insurer['short_name'] : '' ?>" name="short_name" required minlength="3" maxlength="8">
|
|
</div>
|
|
|
|
<div class="form-group col-md-4">
|
|
<label class="switch" style="position: absolute;top: 32px;left: 17px;">
|
|
<input id="addition_add_day" type="checkbox" name="addition_add_day" <?= (isset($insurer['addition_add_day']) && $insurer['addition_add_day'] == 1) ? 'checked' : '' ?>>
|
|
<span class="slider round" style="height: 27px;"></span>
|
|
</label>
|
|
<label for="addition_add_day" style="position: relative;top: 30px;left: 82px;">Add one day to date of coverage when Addition/Dependent addition</label>
|
|
</div>
|
|
|
|
<div class="form-group col-md-2">
|
|
<label class="switch" style="position: absolute;top: 32px;left: 17px;">
|
|
<input id="deletion_add_day" type="checkbox" name="deletion_add_day" <?= (isset($insurer['deletion_add_day']) && $insurer['deletion_add_day'] == 1) ? 'checked' : '' ?>>
|
|
<span class="slider round" style="height: 27px;"></span>
|
|
</label>
|
|
<label for="deletion_add_day" style="position: relative;top: 30px;left: 82px;">Add one day to date of Deletion </label>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<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' : '' ?>>
|
|
<label for="html">PVT</label>
|
|
<input type="radio" id="css" name="type" value="psu" <?= isset($insurer['type']) && $insurer['type'] == 'psu' ? 'checked' : '' ?>>
|
|
<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">
|
|
<div class="form-group col-md-4" style="position: relative;right: 0px;">
|
|
<label for="html">Insurer Category</label><br>
|
|
<div style="margin-top: 10px;">
|
|
<input type="radio" id="html" name="category" value="life" <?= isset($insurer['category']) && $insurer['category'] == 'life' ? 'checked' : '' ?>>
|
|
<label for="html">Life</label>
|
|
<input type="radio" id="css" name="category" value="general" <?= isset($insurer['category']) && $insurer['category'] == 'general' ? 'checked' : '' ?>>
|
|
<label for="css" style="position: absolute;left: 70px;">General(Non Life)</label>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<div class="form-group col-md-4">
|
|
<label for="short_name">Insurer Logo<span class="text-danger"></span></label>
|
|
<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: 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>
|
|
|
|
</div>
|
|
|
|
</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() {
|
|
|
|
$("#insurer_general_form").submit(function(events) {
|
|
|
|
events.preventDefault();
|
|
|
|
var isValid = $('#insurer_General_PrimaryKey').parsley().validate();
|
|
if (!isValid) {
|
|
console.log('Form is Empty', 'Warning');
|
|
return ;
|
|
}
|
|
|
|
var PrimaryKey = $('#insurer_General_PrimaryKey').val();
|
|
var form_action = '';
|
|
if (isValid) {
|
|
|
|
if (PrimaryKey === '') {
|
|
form_action = '<?= base_url("master/insurer/createpost"); ?>';
|
|
} else {
|
|
form_action = '<?= base_url("master/insurer/edit"); ?>';
|
|
}
|
|
|
|
var formData = new FormData($('#insurer_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);
|
|
$('#insurer_id').val(res.data.id);
|
|
$('#insurer_General_PrimaryKey').val(res.data.id);
|
|
$('#insurer_id_branch').val(res.data.id);
|
|
// $('#insurer_branch_contacts_id').click();
|
|
|
|
$('#btnBranchAdd').show();
|
|
var message = "Insurer General Info";
|
|
toastr.success(message, 'Success');
|
|
|
|
if (PrimaryKey === '') {
|
|
setTimeout(function(){
|
|
window.location.href = '<?= base_url('master/insurer/list/')?>' + res.data.id
|
|
}, 100)
|
|
}else{
|
|
window.location.reload();
|
|
}
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
console.error(xhr.responseText);
|
|
console.error(status, error);
|
|
$('.loader').fadeOut();
|
|
$('.loader-mask').delay(350).fadeOut('slow');
|
|
console.log('Something Wrong!', 'warning');
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
function validateForm() {
|
|
var isValid = true;
|
|
|
|
// Perform validation for each field
|
|
$('#insurer_general_form input, #insurer_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;
|
|
}
|
|
|
|
|
|
});
|
|
|
|
function PreviewImage()
|
|
{
|
|
var oFReader = new FileReader();
|
|
oFReader.readAsDataURL(document.getElementById("insurer_logo").files[0]);
|
|
|
|
oFReader.onload = function(oFREvent) {
|
|
document.getElementById("uploadPreview").src = oFREvent.target.result;
|
|
};
|
|
};
|
|
|
|
//-----------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
</script>
|