278 lines
13 KiB
PHP
Executable File
278 lines
13 KiB
PHP
Executable File
<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="tpa_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 class="form-group col-md-4">
|
||
<label for="tpa_network_hospitals">Network Hospitals<span class="text-danger">*</span></label>
|
||
<input type="url" class="form-control" id="tpa_network_hospitals" name="network_hospitals" placeholder="Enter Network Hospitals" value="<?= isset($tpa['network_hospitals']) ? $tpa['network_hospitals'] : '' ?>" required data-parsley-type="url">
|
||
</div>
|
||
</div>
|
||
|
||
<hr>
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="tpa_ecard_template">E-Card Template<span class="text-danger"></span></label>
|
||
<textarea style="height: 380px;" class="form-control" id="ecard_content" placeholder="Enter E-card Content" name="ecard_content"><?= isset($template_data) ? $template_data : '' ?></textarea>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row" id="view_pre_btn" style="display :none">
|
||
<div class="form-group col-md-4">
|
||
<a href="<?= isset($tpa['id']) ? base_url('/util/preview-card/') . $tpa['id'] : '' ?>" class="btn btn-primary" id="preview" target="_blank">Preview</a>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-4">
|
||
<label for="tpa_logo">TPA Logo<span class="text-danger"></span></label>
|
||
<input type="file" class="form-control" onchange="PreviewImage();" id="tpa_logo" name="tpa_logo" accept="image/jpeg, image/jpg, image/png">
|
||
</div>
|
||
<div class="form-group col-md-4">
|
||
<label for="tpa_front_card_image">Front card Image<span class="text-danger"></span></label>
|
||
<input type="file" class="form-control" onchange="PreviewImage2();" id="fc" name="fc" accept="image/jpeg, image/jpg, image/png">
|
||
</div>
|
||
<div class="form-group col-md-4">
|
||
<label for="tpa_back_card_image">Back card Image<span class="text-danger"></span></label>
|
||
<input type="file" class="form-control" onchange="PreviewImage3();" id="bc" name="bc" accept="image/jpeg, image/jpg, image/png">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-4">
|
||
<label for="tpa_logo_preview">TPA Logo Preview<span class="text-danger"></span></label>
|
||
<img src="<?= isset($tpa['tpa_logo']) && !empty($tpa['tpa_logo']) ? base_url() . "public/uploads/logo/" . $tpa['tpa_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 class="form-group col-md-4">
|
||
<label for="tpa_front_card_preview">Front card Preview<span class="text-danger"></span></label>
|
||
<img src="<?= isset($tpa['front_card']) && !empty($tpa['front_card']) ? base_url() . "public/uploads/template_bg/" . $tpa['front_card'] : base_url() . "public/assets/images/avatar_2x.png" ?>" width="100" height="100" id="uploadPreview2" class="avatar img-circle img-thumbnail" alt="avatar" />
|
||
</div>
|
||
<div class="form-group col-md-4">
|
||
<label for="tpa_back_card_preview">Back card Preview<span class="text-danger"></span></label>
|
||
<img src="<?= isset($tpa['back_card']) && !empty($tpa['back_card']) ? base_url() . "public/uploads/template_bg/" . $tpa['back_card'] : base_url() . "public/assets/images/avatar_2x.png" ?>" width="100" height="100" id="uploadPreview3" 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 -->
|
||
|
||
|
||
|
||
|
||
<div id="full-width-modal-emp-list" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="fullWidthModalLabel" aria-hidden="true">
|
||
<div class="modal-dialog modal-full-width">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="fullWidthModalLabel">Preview<span id="title_header_name"></span></h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
<div class="modal-body" id="Preview_data">
|
||
|
||
</div>
|
||
<div class="modal-footer">
|
||
</div>
|
||
</div><!-- /.modal-content -->
|
||
</div><!-- /.modal-dialog -->
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
<script>
|
||
$(document).ready(function() {
|
||
|
||
if($('#tpa_General_PrimaryKey').val() != ""){
|
||
|
||
$('#view_pre_btn').show()
|
||
}
|
||
|
||
$("#tpa_general_form").submit(function(events) {
|
||
|
||
events.preventDefault();
|
||
var isValid = $('#tpa_general_form').parsley().validate();
|
||
|
||
var PrimaryKey = $('#tpa_General_PrimaryKey').val();
|
||
var form_action = '';
|
||
|
||
console.log('tpa_General_PrimaryKey', PrimaryKey);
|
||
|
||
if (isValid) {
|
||
|
||
if (PrimaryKey === "") {
|
||
form_action = '<?= base_url("master/tpa/createpost"); ?>';
|
||
} else {
|
||
form_action = '<?= base_url("master/tpa/edit"); ?>';
|
||
}
|
||
|
||
console.log('tpa_General_form_action', form_action);
|
||
|
||
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) {
|
||
|
||
if($('#tpa_General_PrimaryKey').val() == ""){
|
||
window.location.href = '<?= base_url("master/tpa/list/"); ?>' + res.data.id;
|
||
}
|
||
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
}, 1000);
|
||
|
||
console.log(res);
|
||
$('#tpa_id').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');
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
setTimeout(function() {
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
console.log('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;
|
||
}
|
||
|
||
|
||
});
|
||
|
||
function PreviewImage() {
|
||
var oFReader = new FileReader();
|
||
oFReader.readAsDataURL(document.getElementById("tpa_logo").files[0]);
|
||
|
||
oFReader.onload = function(oFREvent) {
|
||
document.getElementById("uploadPreview").src = oFREvent.target.result;
|
||
};
|
||
};
|
||
|
||
|
||
function PreviewImage2() {
|
||
var oFReader = new FileReader();
|
||
oFReader.readAsDataURL(document.getElementById("fc").files[0]);
|
||
|
||
oFReader.onload = function(oFREvent) {
|
||
document.getElementById("uploadPreview2").src = oFREvent.target.result;
|
||
};
|
||
};
|
||
|
||
function PreviewImage3() {
|
||
var oFReader = new FileReader();
|
||
oFReader.readAsDataURL(document.getElementById("bc").files[0]);
|
||
|
||
oFReader.onload = function(oFREvent) {
|
||
document.getElementById("uploadPreview3").src = oFREvent.target.result;
|
||
};
|
||
};
|
||
|
||
$('#preview').click(function() {
|
||
var ecardContent = $('#ecard_content').val();
|
||
$('#Preview_data').html(ecardContent);
|
||
});
|
||
|
||
|
||
|
||
// $(document).ready(function() {
|
||
// $('#preview').click(function() {
|
||
// // Get the value from the textarea
|
||
// var ecardContent = $('#ecard_content').val();
|
||
|
||
|
||
// var filename_front = $('#fc').val().split('\\').pop();
|
||
// var original_string_front = '{FRONT_CARD}';
|
||
// var replace_string_front = '<?= isset($tpa['front_card']) && !empty($tpa['front_card']) ? base_url() . "public/uploads/template_bg/" . $tpa['front_card'] : "" ?>';
|
||
// ecardContent = ecardContent.replace(original_string_front, replace_string_front);
|
||
|
||
// console.log(ecardContent);
|
||
|
||
|
||
// var filename_back = $('#fc').val().split('\\').pop();
|
||
// var original_string_back = '{BACK_CARD}';
|
||
// var replace_string_back = '<?= isset($tpa['back_card']) && !empty($tpa['back_card']) ? base_url() . "public/uploads/template_bg/" . $tpa['back_card'] : "" ?>';
|
||
// ecardContent = ecardContent.replace(original_string_back, replace_string_back);
|
||
|
||
// // console.log(ecardContent)
|
||
|
||
// // Open a new window for printing
|
||
// var printWindow = window.open('', '_blank');
|
||
|
||
// // Insert the textarea value into the new window
|
||
// printWindow.document.write('<html><head><title>Preview Page</title></head><body>');
|
||
// printWindow.document.write(ecardContent); // Use <pre> tag to preserve formatting
|
||
// printWindow.document.write('</body></html>');
|
||
|
||
// // Trigger the print functionality
|
||
// printWindow.print();
|
||
// printWindow.close();
|
||
// });
|
||
// });
|
||
|
||
|
||
</script>
|