<?php
/** ensure this file is being included by a parent file */
defined( '_VALID_' ) or die( 'Direct Access to this location is not allowed.' );
?>
<?php
//print_r($_REQUEST);
//print_r($_FILES);
//print_r($_SESSION);
foreach($_REQUEST as $key=>$value)
{
$$key=$value;
}
?>
<?php
if($index==4){
//Upload file Ref Doc.
//$target_dir = "./signature/";
if(!empty($_FILES['UploadedFile']['tmp_name'][$j])) {
$target_file = $target_dir . basename($_FILES["UploadedFile"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
$rename_file = "./signature/". $bookto_id .".". strtolower($imageFileType);
if (move_uploaded_file($_FILES["UploadedFile"]["tmp_name"], $rename_file)) {
}
}
echo "<script>document.location.href='?option=".$_REQUEST['option']."&task=main/signature&index=1&bookto_id=$bookto_id'; </script>\n";
}
?>
<?php
if($index==1){
//echo $bookto_id;
?>
<br>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"> แนบลายเซ็น </h3>
</div>
<div class="panel-body">
<form data-toggle="validator" role="form" name="form" enctype="multipart/form-data" class="form-horizontal" method="POST" action="?option=<?php echo $_REQUEST['option'];?>&task=main/signature&index=2">
<div class="form-group">
<label for="workgroup" class="col-sm-2 control-label">เลือกบุคลากร</label>
<div class="col-sm-10">
<div class="form-group">
<div class="col-sm-4">
<input type="text" class="form-control" name="booktotxt" id="booktotxt" placeholder="เลือกบุคคลที่ต้องการแนบลายเซ็น" readonly>
<input type="text" class="form-control " name="bookto_id" id="bookto_id" readonly>
</div>
<div class="col-sm-4">
<input type="button" class="form-control btn-info" name="SelectBookto" id="SelectBookto" value="เลือกบุคคลที่ต้องการแนบลายเซ็น" data-toggle="modal" data-target="#ModalSelectBookto">
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-6">
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> ยืนยันบุคลากรนี้ </button>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- Validate Form-->
<!-- Bootstrap Popover -->
<script>
$(function () {
$('[data-toggle="popover"]').popover()
})
</script>
<!-- Bootstrap Confirmation -->
<script>
$('[data-toggle="confirmation"]').confirmation()
</script>
<!-- Bootstrap Confirmation -->
<script>
$('[data-toggle="validator"]').validator()
</script>
<!-- End Content -->
<!-- Modal -->
<div class="modal fade" id="ModalSelectBookto" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">เลือกบุคลากรที่ต้องการแนบ</h5>
</div>
<div class="modal-body">
<table class="table table-striped table-bordered table-hover" style="width:100%" id="dataPerson">
<thead>
<tr>
<th width = "50%"> ชื่อ - สกุล </th>
<th width = "50%"> ตำแหน่ง </th>
<th width = "0"> รหัสตำแหน่ง </th>
</tr>
</thead>
<tbody>
<?php
$strSQL = "SELECT * FROM `person_main` where status = '0' ORDER BY position_code, person_order, name";
$Dbquery = mysqli_query($connect,$strSQL);
while($dataPerson = mysqli_fetch_assoc($Dbquery)){
?>
<tr>
<td>
<div class="form-group">
<div class="col-sm-12">
<label class="radio-inline"><input type="radio" name="bookPersonid" id="bookPersonid<?php echo $dataPerson['id']; ?>" value="<?php echo $dataPerson['person_id']; ?>"><?php echo $dataPerson['prename']."".$dataPerson['name']." ".$dataPerson['surname']; ?></label>
</div>
</div>
</td>
<td><?php echo $Position[$dataPerson['position_code']]; ?></td>
<td><?php echo $dataPerson['position_code']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<script>
$(document).ready(function() {
$('#dataPerson').DataTable({
"aoColumnDefs": [
{ "iDataSort": 2, "aTargets": [ 0 ] },
{"visible": false, "targets":2}
]
});
} );
$("[name='bookPersonid']").change(function(){
document.getElementById('booktotxt').value = $('[name="bookPersonid"]:checked').closest('label').text();
document.getElementById('bookto_id').value = $('[name="bookPersonid"]:checked').val();
$('#ModalSelectBookto').modal('hide');
alert(document.getElementById('bookto_id').value);
});
</script>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php
}
?>
<?php
if($index==2){
//echo $bookto_id;
?>
<br>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"> แนบลายเซ็น </h3>
</div>
<div class="panel-body">
<form data-toggle="validator" role="form" name="form" enctype="multipart/form-data" class="form-horizontal" method="POST" action="?option=<?php echo $_REQUEST['option'];?>&task=main/signature&index=4">
<div class="form-group">
<label for="workgroup" class="col-sm-2 control-label">เลือกบุคลากร</label>
<div class="col-sm-10">
<div class="form-group">
<div class="col-sm-4">
<input type="text" class="form-control" name="booktotxt" id="booktotxt" value="<?php echo $booktotxt;?>"readonly>
<input type="text" class="form-control " name="bookto_id" id="bookto_id" value="<?php echo $bookto_id;?>" readonly>
</div>
<div class="col-sm-4">
<input type="button" class="form-control btn-info" name="SelectBookto" id="SelectBookto" value="เลือกบุคคลที่ต้องการแนบลายเซ็น" data-toggle="modal" data-target="#ModalSelectBookto">
</div>
</div>
</div>
</div>
<div class="form-group">
<input name="cntrow" type="hidden" id="cntrow" value="0">
<label for="file" class="col-sm-2 control-label">แนบลานเซ็น</label>
<div class="col-sm-10">
<table border="0" cellspacing="0" cellpadding="0" id="myTable">
<tr>
<td width="80%">
<div class="col-xs-6" id="UploadedFile" >
<input class="form-control" name="UploadedFile" type="file" accept="image/png, image/jpeg" class="BrowsFile" size="300" OnChange="showPreview(this)">
</div>
<div class='col-sm-4'>
<script language="JavaScript">
function showPreview(ele)
{
$('#imgAvatar').attr('src', ele.value); // for IE
if (ele.files && ele.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#imgAvatar').attr('src', e.target.result);
}
reader.readAsDataURL(ele.files[0]);
}
}
</script>
ลายเซ็นใหม่
<img id="imgAvatar" border='0' width='150'>
<hr>
<?php
// Add signature
$sigFileComment = "./signature/". $bookto_id .".png";
//$sigFile = "./signature/3700300113267.png";
if($sigFileComment == "" ){
?>
ลายเซ็นเดิม
<img src='./signature/00.png' border='0' width='150'>
<?php
}
if(file_exists($sigFileComment)){
echo "ลายเซ็นเดิม";
echo "<img src='". $sigFileComment ."' border='0' width='150'>";
}
?>
</div>
</td>
</tr>
</table>
</div>
</div>
<hr>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-6">
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-ok"></span> Upload </button> <a href="?option=idocument&task=main/signature&index=1&bookto_id=$bookto_id" class="btn btn-warning">
<span class="glyphicon glyphicon-chevron-left"><font face="Sarabun" size="3"> ย้อนกลับ </span></a>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- Validate Form-->
<!-- Bootstrap Popover -->
<script>
$(function () {
$('[data-toggle="popover"]').popover()
})
</script>
<!-- Bootstrap Confirmation -->
<script>
$('[data-toggle="confirmation"]').confirmation()
</script>
<!-- Bootstrap Confirmation -->
<script>
$('[data-toggle="validator"]').validator()
</script>
<!-- End Content -->
<!-- Modal -->
<div class="modal fade" id="ModalSelectBookto" tabindex="-1" role="dialog" aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLongTitle">เลือกบุคลากรที่ต้องการแนบ</h5>
</div>
<div class="modal-body">
<table class="table table-striped table-bordered table-hover" style="width:100%" id="dataPerson">
<thead>
<tr>
<th width = "50%"> ชื่อ - สกุล </th>
<th width = "50%"> ตำแหน่ง </th>
<th width = "0"> รหัสตำแหน่ง </th>
</tr>
</thead>
<tbody>
<?php
$strSQL = "SELECT * FROM `person_main` where status = '0' ORDER BY position_code, person_order, name";
$Dbquery = mysqli_query($connect,$strSQL);
while($dataPerson = mysqli_fetch_assoc($Dbquery)){
?>
<tr>
<td>
<div class="form-group">
<div class="col-sm-12">
<label class="radio-inline"><input type="radio" name="bookPersonid" id="bookPersonid<?php echo $dataPerson['id']; ?>" value="<?php echo $dataPerson['person_id']; ?>"><?php echo $dataPerson['prename']."".$dataPerson['name']." ".$dataPerson['surname']; ?></label>
</div>
</div>
</td>
<td><?php echo $Position[$dataPerson['position_code']]; ?></td>
<td><?php echo $dataPerson['position_code']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<script>
$(document).ready(function() {
$('#dataPerson').DataTable({
"aoColumnDefs": [
{ "iDataSort": 2, "aTargets": [ 0 ] },
{"visible": false, "targets":2}
]
});
} );
$("[name='bookPersonid']").change(function(){
document.getElementById('booktotxt').value = $('[name="bookPersonid"]:checked').closest('label').text();
document.getElementById('bookto_id').value = $('[name="bookPersonid"]:checked').val();
$('#ModalSelectBookto').modal('hide');
alert(document.getElementById('bookto_id').value);
});
</script>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php
}
//print_r($_SESSION);
?>