286 lines
9.7 KiB
PHP
286 lines
9.7 KiB
PHP
|
|
<?php
|
|
// $query = "SELECT * FROM sickness ";
|
|
// $result = @mysqli_query($conn,$query);
|
|
// while( $row = mysqli_fetch_assoc($result)){
|
|
// $sickness_id=$row['sickness_id'];
|
|
// }
|
|
$id = ($_REQUEST['flex_opd_id']!=''?$_REQUEST['flex_opd_id']:$_REQUEST['flex_patient_id']);
|
|
$query = "select * from patient_master where id = '".$id."' ";
|
|
//echo $query;
|
|
error_log("query: 11: ".$query);
|
|
if (!$result = @mysqli_query($conn,$query)) {
|
|
die(error_log(mysqli_error($conn)));
|
|
|
|
} else{
|
|
if (mysqli_num_rows($result)>0) {
|
|
|
|
$row=mysqli_fetch_array($result);
|
|
extract($row);
|
|
}
|
|
}
|
|
|
|
$sickness_id = ($_REQUEST['sickness_id'] != '')?($_REQUEST['sickness_id']):($_REQUEST['flex_sickness_id']);
|
|
|
|
|
|
?>
|
|
|
|
<style>
|
|
#modal-add-document{
|
|
overflow-y:scroll;
|
|
}
|
|
</style>
|
|
<div id="image_div">
|
|
</div>
|
|
<div class="modal fade" id="modal-add-document" name="modal-add-document" role="dialog" aria-hidden="true">
|
|
<form role="form" id="medical_exam_document_form" name="medical_exam_document_form" enctype="multipart/form-data" action="#" method="post">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="widget-header">
|
|
<h5 class="widget-title">Upload Supporting Document </h5>
|
|
<div class="widget-toolbar">
|
|
<div class="widget-menu">
|
|
<button type="button" class="close" data-dismiss="modal"
|
|
><i class="ace-icon fa fa-times"></i>
|
|
</button>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal-body">
|
|
|
|
<div class="row">
|
|
<div class="col-xs-3">
|
|
|
|
</div>
|
|
|
|
<input type="hidden" class="form-control" name="sickness_id" id="sickness_id" value="<?php echo $sickness_id?>"/>
|
|
<input type="hidden" id="emp_id" name="emp_id" value="<?php echo $row['id']?>" />
|
|
<div class="col-xs-6">
|
|
<select style="width: 271px;" name= "medical_exam_document_opt" id="medical_exam_document_opt" onclick="load()">
|
|
<?php
|
|
$query = "SELECT id, document_name, code FROM document_type_master";
|
|
$result = @mysqli_query($conn,$query);
|
|
while( $row = mysqli_fetch_assoc($result)){
|
|
echo '<option value="'.$row['document_name'].'" >'.$row['document_name'].'</option>';
|
|
}
|
|
?>
|
|
</select>
|
|
<input type="text" style="width:100%; margin-top: 5px;" placeholder="Enter Document Name" id="medical_exam_document" name="medical_exam_document" />
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row" style="margin-top: 10px">
|
|
<div class="form-group">
|
|
<div class="col-xs-3">
|
|
</div>
|
|
<div class="col-xs-6">
|
|
<div class="form-group">
|
|
<input type="file" id="file_medical_exam" name="file_medical_exam" onchange="return fileValidation()" />
|
|
</div>
|
|
|
|
<input type="hidden" name="medical_exam_id_doc" id="medical_exam_id_doc" value="<?php echo $_REQUEST['medical_exam_id']; ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="widget-toolbox padding-8 clearfix" >
|
|
<button type="button" onclick="save_medical_exam_doc()"
|
|
class="btn btn-info btn-sm save_button" ><i class="ace-icon fa fa-floppy-o bigger-110"></i>Upload </button>
|
|
<button type="button" class="btn btn-danger btn-sm" data-dismiss="modal"><i class="ace-icon fa fa-times bigger-110"></i>Cancel</button>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<style>
|
|
|
|
|
|
.clickable{
|
|
cursor: pointer;
|
|
}
|
|
|
|
.panel-heading span {
|
|
margin-top: -20px;
|
|
font-size: 15px;
|
|
}
|
|
img {
|
|
max-width: 100%;
|
|
height: auto;
|
|
width: auto\9; /* ie8 */
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
function open_popup_img(){
|
|
$("#fitness_form_employee").submit(function(e){
|
|
e.preventDefault();
|
|
});
|
|
$('#medical_exam_document').val("");
|
|
$('#file_medical_exam').val("");
|
|
$('#modal-add-document').modal("show");
|
|
}
|
|
function image(value){
|
|
var src=value.src;
|
|
var content="";
|
|
|
|
var content='<div class="modal fade" id="modal-img" role="dialog" aria-hidden="true">'
|
|
content+='<div class="modal-dialog modal-lg">'
|
|
|
|
content+='<div class="modal-content">'
|
|
content+='<div class="modal-header">'
|
|
content+='<h5 class="modal-title" style="text-align: center">Image '
|
|
content+='<button type="button" class="close" data-dismiss="modal"'
|
|
content+='aria-label="Close">'
|
|
content+='<span aria-hidden="true">×</span>'
|
|
content+='</button></h5>'
|
|
content+='</div>'
|
|
content+='<div class="modal-body">'
|
|
content+='<div class="row"><a href='+src+' download><div class="form-group col-sm-12">'
|
|
|
|
content+='</div><img height="300" weight="300" src='+src+' alt="new image"/></a></div>'
|
|
content+='</div>'
|
|
content+='</div><div><div>'
|
|
|
|
|
|
|
|
$("#image_div").html(content);
|
|
$('#modal-img').modal("show");
|
|
|
|
}
|
|
function pdf_preview(value_field, title){
|
|
var src=value_field.src;
|
|
var content="";
|
|
|
|
var content='<div class="modal fade" id="modal-img" role="dialog" aria-hidden="true">'
|
|
content+='<div class="modal-dialog modal-lg" style="width:80%;height:100%" >'
|
|
|
|
content+='<div class="modal-content" style="width:100%;height:100%">'
|
|
content+='<div class="modal-header">'
|
|
content+='<h5 class="modal-title" style="text-align: center">'+title
|
|
content+='<button type="button" class="close" data-dismiss="modal"'
|
|
content+='aria-label="Close">'
|
|
content+='<span aria-hidden="true">×</span>'
|
|
content+='</button></h5>'
|
|
content+='</div>'
|
|
content+='<div class="modal-body" style="width:100%;height:100%">'
|
|
content+='<div class="form-group col-sm-12">'
|
|
|
|
content+='</div style="width:100%;height:100%" ><object type="application/pdf" style="width:100%;height:100%" data='+src+' alt="new image"/></object></div>'
|
|
// content+='</div>'
|
|
content+='</div><div><div>'
|
|
|
|
|
|
|
|
$("#image_div").html(content);
|
|
$('#modal-img').modal("show");
|
|
|
|
}
|
|
|
|
function save_medical_exam_doc(){
|
|
$.ajax({
|
|
url:"save_sickness_document.php",
|
|
method:"POST",
|
|
data:new FormData(document.getElementById("medical_exam_document_form")),
|
|
contentType:false,
|
|
processData:false,
|
|
success:function(data){
|
|
BootstrapDialog.alert('Document Uploaded Successfully ');
|
|
|
|
|
|
getMedicalDocData();
|
|
|
|
$("#modal-add-document").modal('hide');
|
|
},
|
|
error:function(data){
|
|
BootstrapDialog.alert('Error Uploading The Document');
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
function fileValidation(){
|
|
var fileInput = document.getElementById('file_medical_exam');
|
|
var filePath = fileInput.value;
|
|
var allowedExtensions = /(\.jpg|\.jpeg|\.png|\.pdf)$/i;
|
|
if(!allowedExtensions.exec(filePath)){
|
|
BootstrapDialog.alert('Please upload only image and pdf file ');
|
|
fileInput.value = '';
|
|
return false;
|
|
}else{
|
|
return;
|
|
}
|
|
}
|
|
var counter=0;
|
|
function getMedicalDocData(){
|
|
|
|
$.ajax({
|
|
url:"get_sickness_document.php",
|
|
method:"get",
|
|
data:{sickness_id:$('#sickness_id').val()},
|
|
dataType:'json',
|
|
async:false,
|
|
|
|
success:function(data){
|
|
var content="";
|
|
if (data.medical_doc_type=='application/pdf'){
|
|
content="<tr id='medical_doc_"+data.id+"'><td>"+data.medical_doc_desc+"</td><td>"
|
|
content+="<a href= \"#\" ><img src= \"images/pdf.png\" width=\"35\" height=\"35\" onclick=\"$('#med_doc_"+data.id+"').click()\" /></a> <img id=\"med_doc_"+data.id+"\" style= \"display:none\" src = \"data:"+data.medical_doc_type+";base64,"+data.medical_doc+"\" alt = \"pdf\" onclick=\"pdf_preview(this,'"+data.medical_doc_desc+"')\" /> </td>"
|
|
content+='<td align="center"><a href="#" class="btn-lg" data-toggle="tooltip" id="deletebtn" onclick="delete_opd_document('+data.id+')" title="Delete"><span class="glyphicon glyphicon-trash"></span></a></td></tr>'
|
|
$("#medical_doc_id tbody").append(content);
|
|
}else{
|
|
content="<tr id='medical_doc_"+data.id+"'><td>"+data.medical_doc_desc+"</td><td>"
|
|
content+="<img width=\"35\" height=\"35\" src = \"data:"+data.medical_doc_type+";base64,"+data.medical_doc+"\" alt = \"new image\" onclick=\"image(this,'"+data.medical_doc_desc+"')\" /></td>"
|
|
content+='<td align="center"><a href="#" class="btn-lg" data-toggle="tooltip" id="deletebtn" onclick="delete_opd_document('+data.id+')" title="Delete"><span class="glyphicon glyphicon-trash"></span></a></td></tr>'
|
|
$("#medical_doc_id tbody").append(content);
|
|
}
|
|
counter++;
|
|
},
|
|
error:function(data){
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
function delete_opd_document(delete_id){
|
|
$("#medical_doc_id").on("click", ".glyphicon-trash", function (event) {
|
|
$('#medical_doc_'+delete_id).remove();
|
|
});
|
|
$.ajax({
|
|
url:"delete_sickness_document.php",
|
|
data:{delete_id:delete_id},
|
|
method:"POST",
|
|
|
|
success:function(data){
|
|
BootstrapDialog.alert('Document Deleted Successfully ');
|
|
|
|
|
|
//getMedicalDocData();
|
|
},
|
|
error:function(data){
|
|
BootstrapDialog.alert('Error In deleting Upload Document');
|
|
}
|
|
});
|
|
}
|
|
document.getElementById("medical_exam_document").style.display = "none";
|
|
function load(){
|
|
var option = document.getElementById("medical_exam_document_opt").value;
|
|
|
|
if(option == "Other"){
|
|
document.getElementById("medical_exam_document").value = "";
|
|
document.getElementById("medical_exam_document").style.display = "block";
|
|
|
|
}else{
|
|
document.getElementById("medical_exam_document").style.display = "none";
|
|
document.getElementById("medical_exam_document").value = document.getElementById("medical_exam_document_opt").value;
|
|
}
|
|
|
|
}
|
|
</script>
|