512 lines
20 KiB
PHP
512 lines
20 KiB
PHP
<?php include('techsyn_header.php'); ?>
|
|
<!-- Main Content Container for side bar and body-->
|
|
<div class="main-container ace-save-state" id="main-container">
|
|
<script type="text/javascript">
|
|
try{ace.settings.loadState('main-container')}catch(e){}
|
|
</script>
|
|
<?php include('techsyn_sidebar.php'); ?>
|
|
|
|
<!--breadcrumb-->
|
|
|
|
|
|
<div class="main-content" style="background-color:white;">
|
|
<div class="main-content-inner" style="background-color:white;">
|
|
<div class="breadcrumbs ace-save-state" id="breadcrumbs">
|
|
<ul class="breadcrumb">
|
|
<li><i class="ace-icon fa fa-home home-icon"></i> <a href="#">Home</a>
|
|
</li>
|
|
<li><i class="ace-icon fa fa-gift"></i> <a href="#">Documents</a></li>
|
|
|
|
<li class="active">SOP Documents</li>
|
|
|
|
</ul>
|
|
</div>
|
|
<div id="image_div">
|
|
</div>
|
|
<div id="img" style="height: 0px;" type="hidden">
|
|
</div>
|
|
<!-- End of breadcrumb -->
|
|
|
|
<div class="page-content">
|
|
<div id="flexigridDiv" class="table-responsive">
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<?php
|
|
|
|
$this_script = 'techsyn_upload.php';
|
|
if (isset($acn) && $acn == 'delete') {
|
|
if ($file_name) {
|
|
unlink($file_name);
|
|
}
|
|
$msg = "File deleted successfully";
|
|
// alert($msg);
|
|
echo "<script>location.replace('$this_script?msg=$msg')</script>";
|
|
}
|
|
?>
|
|
|
|
<?php
|
|
if (isset($hid) && $hid == '1') {
|
|
// $disallowed_filetypes = array('.php','.asp','.aspx'); // These will be the types of file that will pass the validation.
|
|
$upload_path = 'files/'; // The place the files will be uploaded to (currently a 'files' directory).
|
|
|
|
$filename = $_FILES['userfile']['name']; // Get the name of the file (including file extension).
|
|
$ext = substr($filename, strpos($filename, '.'), strlen($filename) - 1); // Get the extension from the filename.
|
|
|
|
// if(in_array($ext,$disallowed_filetypes))
|
|
// die('The file you attempted to upload is not allowed.');
|
|
|
|
if (! is_writable($upload_path))
|
|
die('You cannot upload to the specified directory, please CHMOD it to 777.');
|
|
|
|
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_path . $filename))
|
|
$msg = 'Your file upload was successful';
|
|
else
|
|
$msg = 'There was an error during the file upload. Please try again.';
|
|
}
|
|
?>
|
|
|
|
|
|
|
|
<div class="table-responsive"
|
|
style="align: center; text-align: left; width: 90%; margin: 50px;">
|
|
|
|
<form role="form" id="sop_document_form" name="sop_document_form" enctype="multipart/form-data" action="#" method="post">
|
|
<!-- box-body-->
|
|
<div class="box-body">
|
|
|
|
|
|
<div class="row" >
|
|
<div class="col-sm-12">
|
|
<table id="myTable" class="table table-bordered order-list" >
|
|
<thead>
|
|
<tr>
|
|
<!-- <th>Unit</th>
|
|
<th>Site</th> -->
|
|
<th>SOP Name</th>
|
|
<th>SOP/Certificate. No</th>
|
|
<th>Last Renewal Date</th>
|
|
<th>Next Renewal Date</th>
|
|
<!-- <th>Rev No.</th> -->
|
|
<th>Select File</th>
|
|
<th>Upload File</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<!-- <td style="width:8%">
|
|
<input type="hidden" name="frequency_id<?php echo $i?>" id="frequency_id<?php echo $i?>" value="<?php echo $row['frequency_id']?>" />
|
|
|
|
|
|
<select
|
|
class="form-control" id="unit"
|
|
name="unit" placeholder="OHC Type">
|
|
<?php echo generateOption('ohc_type','ohc_type_name','ohc_type_id','',''); ?>
|
|
</select>
|
|
|
|
|
|
|
|
|
|
</td>
|
|
<td style="width:8%">
|
|
<input type="text" style="width:100%" placeholder="Enter site" id="site" name="site" />
|
|
|
|
</td> -->
|
|
</td>
|
|
<td style="width:8%">
|
|
<input type="text" style="width:100%" placeholder="Enter Document Name" id="medical_exam_document" name="medical_exam_document" />
|
|
</td>
|
|
<td style="width:8%">
|
|
<input type="text" style="width:100%" placeholder="Enter SOP Number" id="sop_number" name="sop_number" />
|
|
|
|
</td>
|
|
<td style="width:1%" >
|
|
<input type="date" name="last_renewal_date" id="last_renewal_date">
|
|
</td>
|
|
<td style="width:1%"><input type="date" name="new_renewal_date" id="new_renewal_date"></td>
|
|
|
|
|
|
<!-- <td style="width:10%" >
|
|
<input type="text" style="width:100%" placeholder="Enter Rev No." id="rev_no" name="rev_no" /> -->
|
|
|
|
</td>
|
|
<td style="width:10%" >
|
|
<input type="file" id="file_medical_exam" name="file_medical_exam" class="form-control" name="userfile"
|
|
id="file" />
|
|
<input type="hidden" name="table_id" id="table_id" value="<?php echo $row['id'];?>">
|
|
|
|
</td>
|
|
<td style="width:10%" >
|
|
|
|
<button type="button" onclick="save_sop_doc()"
|
|
class="btn btn-info btn-sm save_button" ><i class="ace-icon fa fa-floppy-o bigger-110"></i>Upload </button>
|
|
<input type="hidden" name="hid" value="1">
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
</tr>
|
|
|
|
<?php $i=0;
|
|
$row=null;
|
|
|
|
$sql="select * from sop_document ";
|
|
$result = @mysqli_query($conn,$sql);
|
|
$num_rows=@mysqli_num_rows($result);
|
|
$row=@mysqli_fetch_array($result);
|
|
|
|
do{
|
|
|
|
$i++;
|
|
}while($row=@mysqli_fetch_array($result))//end of while
|
|
?>
|
|
<input type="hidden" name="count_items" id="count_items" value="<?php echo $i?>" />
|
|
|
|
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr>
|
|
</tr>
|
|
</tfoot>
|
|
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<!-- End box-body-->
|
|
<!--box-footer-->
|
|
|
|
<!--End box-footer-->
|
|
|
|
</form>
|
|
</div>
|
|
|
|
|
|
<?php
|
|
// error_reporting(E_ERROR | E_PARSE);
|
|
if ($handle = opendir('files')) {
|
|
while (false !== ($file = readdir($handle))) {
|
|
if ($file != "." && $file != "..") {
|
|
$thelist[] = $file;
|
|
}
|
|
}
|
|
closedir($handle);
|
|
}
|
|
$arr_count = sizeof($thelist);
|
|
$upload_path = './files/';
|
|
?>
|
|
<div class="table-responsive"
|
|
style="align: center; text-align: center; width: 90%; margin: 50px;">
|
|
<form>
|
|
<h4 style="font-size: 15px; text-align: center; font-weight: bold">View SOP Documents</h4>
|
|
<table id="medical_doc_id" class="table table-bordered" style="width: 100%">
|
|
<thead>
|
|
<tr>
|
|
<th>S.No.</th>
|
|
<!-- <th>Unit</th>
|
|
<th>Site</th> -->
|
|
<th>SOP Name</th>
|
|
<th>SOP/Certificate. No</th>
|
|
<th>Last Renewal Date</th>
|
|
<th>Next Renewal Date</th>
|
|
<!-- <th>Rev No.</th> -->
|
|
<th>Uploaded Date</th>
|
|
<th>View</th>
|
|
<?php $hasExecuteAccess = isAccessible ( $_SESSION ['RoleId'], $menu_key, 'E' );
|
|
if ($hasExecuteAccess) {?>
|
|
<th>Delete</th>
|
|
<?php }?>
|
|
</tr>
|
|
</thead>
|
|
|
|
|
|
|
|
|
|
<?php if($arr_count==0){ ?>
|
|
<tr >
|
|
<td align='center' colspan='5'>No Files Found</td>
|
|
</tr>
|
|
<?php } ?>
|
|
|
|
<?php
|
|
|
|
$count = 0;
|
|
$sql="select * from sop_document";
|
|
//echo "$sql";
|
|
$result = @mysqli_query($conn,$sql);
|
|
?><?php
|
|
while ($row_medical_doc = @mysqli_fetch_array($result)) {
|
|
?>
|
|
|
|
|
|
<tr id="medical_doc_<?php echo $row_medical_doc['id']?>">
|
|
<td align="left" ><?php echo $count+1?></td>
|
|
<!-- <td align="left"><?php echo getTableFieldValue('ohc_type', 'ohc_type_name', 'ohc_type_id',$row_medical_doc['unit']);?></td> -->
|
|
<!-- <td align="left"><?php echo $row_medical_doc['site'];?></td> -->
|
|
<td align="left" ><?php echo $row_medical_doc['medical_doc_desc'];?></td>
|
|
<td align="left"><?php echo $row_medical_doc['sop_number'];?></td>
|
|
<td align="left"><?php echo date_format(date_create($row_medical_doc['last_renewal_date']),"d-M-Y ");?></td>
|
|
<td align="left"><?php echo date_format(date_create($row_medical_doc['new_renewal_date']),"d-M-Y ");?></td>
|
|
<!-- <td align="left"><?php echo $row_medical_doc['rev_no'];?></td> -->
|
|
<td align="left" ><?php echo date_format(date_create($row_medical_doc['last_modified']),"d-M-Y ");?></td>
|
|
<?php if($row_medical_doc['medical_doc_type']=='application/pdf'){?>
|
|
<td ><a href='#'><img src='images/pdf.png' width='35' height='35' onclick='$("#med_doc_<?php echo $row_medical_doc['id']?>").click()'></a>
|
|
<img id="med_doc_<?php echo $row_medical_doc['id']?>" style='display:none' <?php
|
|
echo ' src = "data:'.$row_medical_doc['medical_doc_type'].';base64,'.base64_encode( $row_medical_doc['medical_doc'] ).'"'?> alt = "pdf" onclick="pdf_preview(this,'<?php echo $row_medical_doc['medical_doc_desc']?>')"/></td>
|
|
<?php } elseif($row_medical_doc['medical_doc_type']=='image/png'){?>
|
|
<td ><img width="35" height="35" <?php
|
|
echo ' src = "data:'.$row_medical_doc['medical_doc_type'].';base64,'.base64_encode( $row_medical_doc['medical_doc'] ).'"'?> alt = "new image" onclick="image(this,'<?php echo $row_medical_doc['medical_doc_desc']?>')"/></td>
|
|
<?php } elseif($row_medical_doc['medical_doc_type']=='application/vnd.openxmlformats-officedocument.wordprocessingml.document') {?>
|
|
<td ><a href='#'><img src='images/word.png' width='35' height='35' onclick='$("#med_doc_<?php echo $row_medical_doc['id']?>").click()'> </a>
|
|
<img id="med_doc_<?php echo $row_medical_doc['id']?>" style='display:none' <?php
|
|
echo ' src = "data:'.$row_medical_doc['medical_doc_type'].';base64,'.base64_encode( $row_medical_doc['medical_doc'] ).'"'?> alt = "word_document" onclick="excel_word_preview(this,'<?php echo $row_medical_doc['medical_doc_desc']?>')"/></td>
|
|
<?php } else {?>
|
|
<td ><a href='#'><img src='images/excel_icon.gif' width='35' height='35' onclick='$("#med_doc_<?php echo $row_medical_doc['id']?>").click()'> </a>
|
|
<img id="med_doc_<?php echo $row_medical_doc['id']?>" style='display:none' <?php
|
|
echo ' src = "data:'.$row_medical_doc['medical_doc_type'].';base64,'.base64_encode( $row_medical_doc['medical_doc'] ).'"'?> alt = "pdf" onclick="excel_word_preview(this,'<?php echo $row_medical_doc['medical_doc_desc']?>')"/></td>
|
|
|
|
<?php }?> <?php $hasExecuteAccess = isAccessible ( $_SESSION ['RoleId'], $menu_key, 'E' );
|
|
if ($hasExecuteAccess) {?>
|
|
<td align="center" style="width: 15%">
|
|
<a href="#" class="btn-lg" data-toggle="tooltip" id="deletebtn" onclick="delete_opd_document('<?php echo $row_medical_doc['medical_doc_id']?>')" title="Delete"><span class="glyphicon glyphicon-trash"></span></a>
|
|
|
|
<?php }?>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
<?php $count++; } ?>
|
|
|
|
<input type="hidden" name="counter" id="counter" value="<?php echo $count?>">
|
|
|
|
|
|
|
|
|
|
</table>
|
|
</form>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<!-- /.page-content -->
|
|
</div>
|
|
|
|
<!-- /.main-content -->
|
|
<script>
|
|
//getMedicalDocData();
|
|
var num=$('#counter').val();
|
|
function getMedicalDocData(){
|
|
|
|
//var abc=num.val()+1;
|
|
|
|
|
|
$.ajax({
|
|
url:"get_sop_doc_data.php",
|
|
method:"get",
|
|
|
|
dataType:'json',
|
|
async:false,
|
|
|
|
success:function(data){
|
|
console.log(data);
|
|
var content="";
|
|
if (data.medical_doc_type=='application/pdf'){
|
|
content="<tr id='medical_doc_"+data.id+"'><td align=\"left\">"+(Number(num) + 1)+"</td><td align=\"left\">"+data.unit+"</td><td align=\"left\">"+data.site+"</td><td align=\"left\">"+data.medical_doc_desc+"</td><td align=\"left\">"+data.sop_number+"</td><td align=\"left\">"+data.rev_no+"</td><td align=\"left\">"+data.last_modified+"</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>"
|
|
<?php $hasExecuteAccess = isAccessible ( $_SESSION ['RoleId'], $menu_key, 'E' );
|
|
if ($hasExecuteAccess) {?>
|
|
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>'
|
|
<?php }?>
|
|
$("#medical_doc_id tbody").append(content);
|
|
}else if (data.medical_doc_type=='image/png' || data.medical_doc_type=='image/jpeg' || data.medical_doc_type=='image/jpg'){
|
|
content="<tr id='medical_doc_"+data.id+"'><td align=\"left\">"+(Number(num) + 1)+"</td><td align=\"left\">"+data.unit+"</td><td align=\"left\">"+data.site+"</td><td align=\"left\">"+data.medical_doc_desc+"</td><td align=\"left\">"+data.sop_number+"</td><td align=\"left\">"+data.rev_no+"</td><td align=\"left\">"+data.last_modified+"</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);
|
|
}else if (data.medical_doc_type=='application/vnd.openxmlformats-officedocument.wordprocessingml.document'){
|
|
content="<tr id='medical_doc_"+data.id+"'><td align=\"left\">"+(Number(num) + 1)+"</td><td align=\"left\">"+data.unit+"</td><td align=\"left\">"+data.site+"</td><td align=\"left\">"+data.medical_doc_desc+"</td><td align=\"left\">"+data.sop_number+"</td><td align=\"left\">"+data.rev_no+"</td><td align=\"left\">"+data.last_modified+"</td><td>"
|
|
content+="<a href= \"#\" ><img src= \"images/word.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=\"excel_word_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 align=\"left\">"+(Number(num) + 1)+"</td><td align=\"left\">"+data.unit+"</td><td align=\"left\">"+data.site+"</td><td align=\"left\">"+data.medical_doc_desc+"</td><td align=\"left\">"+data.sop_number+"</td><td align=\"left\">"+data.rev_no+"</td><td align=\"left\">"+data.last_modified+"</td><td>"
|
|
content+="<a href= \"#\" ><img src= \"images/excel_icon.gif\" 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=\"excel_word_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);
|
|
}
|
|
$('#counter').val(num++);
|
|
},
|
|
error:function(data){
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
function image(value,title){
|
|
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">'+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">'
|
|
content+='<div class="row"><a href='+src+' download><div class="form-group col-sm-12">'
|
|
|
|
content+='</div><img height="500" weight="500" src='+src+' alt="new image"/></a></div>'
|
|
content+='</div>'
|
|
content+='</div><div><div>'
|
|
|
|
|
|
|
|
$("#image_div").html(content);
|
|
$('#modal-img').modal("show");
|
|
|
|
}
|
|
|
|
function open_pdf(){
|
|
|
|
}
|
|
|
|
function pdf_preview(value, title){
|
|
var src=value.src;
|
|
|
|
window.open(src,'_blank');
|
|
window.location.reload();
|
|
|
|
// 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+='<a href='+src+' download><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></a></div>'
|
|
// // content+='</div>'
|
|
// content+='</div><div><div>'
|
|
|
|
|
|
|
|
// $("#image_div").html(content);
|
|
// $('#modal-img').modal("show");
|
|
|
|
}
|
|
|
|
function save_sop_doc(){
|
|
$.ajax({
|
|
url:"save_sop_document.php",
|
|
method:"POST",
|
|
data:new FormData(document.getElementById("sop_document_form")),
|
|
contentType:false,
|
|
processData:false,
|
|
success:function(data){
|
|
BootstrapDialog.alert('Upload Document Saved Successfully ');
|
|
|
|
getMedicalDocData();
|
|
$('#site').val("");
|
|
$('#unit').val("");
|
|
$('#medical_exam_document').val("");
|
|
$('#sop_number').val("");
|
|
$('#rev_no').val("");
|
|
$('#file_medical_exam').val("");
|
|
|
|
},
|
|
error:function(data){
|
|
BootstrapDialog.alert('Error In Saving Upload Document');
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
function delete_opd_document(delete_id){
|
|
$("#medical_doc_id").on("click", ".glyphicon-trash", function (event) {
|
|
$('#medical_doc_'+delete_id).remove();
|
|
});
|
|
$.ajax({
|
|
url:"delete_sop_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');
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
|
|
function excel_word_preview(value, title){
|
|
var src=value.src;
|
|
var content="";
|
|
|
|
var content=''
|
|
|
|
|
|
content+='<a href='+src+' download>'
|
|
|
|
content+='<object type="application/pdf" data='+src+' alt="new image"/></object></a>'
|
|
// content+='</div>'
|
|
|
|
|
|
|
|
|
|
$("#img").html(content);
|
|
|
|
|
|
}
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<?php include('techsyn_footer.php'); ?>
|