bbone/application/modules/Leave/views/manager_approvel.php
2024-01-17 10:55:20 +05:30

307 lines
9.6 KiB
PHP

<head>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
<style>
.modal_first {
display: none;
position: fixed;
/* z-index: 1;*/
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content_first {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 380px;
height: 280px;
text-align: center;
}
button {
margin-top: 10px;
}
div.dataTables_wrapper div.dataTables_filter{
margin-top: -30px !important;
}
</style>
</head>
<div class="col-md-12 col-sm-12 ">
<div class="x_panel">
<div class="x_title">
<ul class="nav navbar-right panel_toolbox">
<a href="<?php echo base_url();?>Leave/LeaveHistory" class="btn btn-sm btn-primary" style="margin-top: 20px;" >Back</a>
</ul>
<h1>My Approvals</h1>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="row">
<div class="col-sm-12" style="overflow: auto;">
<table id="datatables" class="table table-striped table-bordered" width="100%">
<thead>
<tr class="headings">
<th hidden class="column-title">id</th>
<th class="column-title">Created Date/Time</th>
<th class="column-title">Employee Name </th>
<th class="column-title">Note</th>
<th class="column-title">Leave Duration </th>
<th class="column-title">Leave Type </th>
<th class="column-title">Leave Raised By</th>
<th class="column-title">No of Days </th>
<th class="column-title">Status </th>
<th class="column-title" >Action </th>
</tr>
</thead>
<tbody>
<?php foreach ($tableData as $key => $value) { ?>
<?php
if(isset($value->delegated_to)) {
$data = $value->delegated_to;
$f_date = $value->delegate_f_date;
$t_date = $value->delegate_t_date;
}else {
$data = 0;
$f_date = 0;
$t_date = 0;
}
?>
<?php if(user()->id == $data && user()->id !== $value->emp_id && date('d-m-Y') >= $f_date && date('d-m-Y') <= $t_date || user()->id == $value->manager) { ?>
<tr class="even pointer">
<td hidden><?php echo $value->id; ?></td>
<td class=" "><?php echo $value->created_date; ?><br><?php echo $value->created_time; ?></td>
<td class=" "><?php echo $value->emp_name; ?></td>
<td class=" "><?php echo $value->comments; ?></td>
<?php if($value->from_date == "" && $value->to_date == "") { ?>
<td class="">
<?php echo dateFormat('d-m-Y',$value->perm_date);?><br>
<?php echo timeFormat('h:i a', $value->from_time); ?> to
<?php echo timeFormat('h:i a', $value->to_time);; ?>
</td>
<?php } else { ?>
<td class=" "> <?php echo dateFormat('d-m-Y',$value->from_date); echo ' to ';?> <?php echo dateFormat('d-m-Y',$value->to_date);?> </td>
<?php } ?>
<td class=" "><?php echo $value->leave_type; ?></td>
<td class=" "><?php if($value->Risedby == ''){echo 'self'; }else{echo $value->Risedby; }; ?></td>
<?php if($value->no_of_days == 0){ ?>
<td class=" ">---</td>
<?php } else { ?>
<td class=""><?php echo $value->no_of_days; ?></td>
<?php } ?>
<?php if($value->status == 'pending'){ ?>
<td style="color:#e68a00"><?php echo $value->status; ?></td>
<?php } else if($value->status == 'Approved'){ ?>
<td style="color:green"><?php echo $value->status; ?> By <?php echo $value->ApproveBy; ?><br><?php echo $value->approved_at; ?></td>
<?php } else if($value->status == 'Declined'){ ?>
<td style="color:red"><?php echo $value->status; ?> by <?php echo $value->DeclineBy; ?> <br>" <?php echo $value->DReason; ?> "</td>
<?php } else if($value->status == 'canceled'){ ?>
<td style="color:darkcyan;"><?php echo $value->status; ?></td>
<?php } ?>
<td style=" text-align: center; font-size: 16px;">
<?php if($value->status == 'pending') { ?>
<a><i class="fa fa-check approveleave" data-toggle="modal" data-target=".bs-example-modal-sm" title="Approve" id="<?php echo $value->id;?>"></i></a>&nbsp;
<a><i class="fa fa-times test" data-toggle="modal" data-target=".bs-example-modal-sm" title="Decline" id="<?php echo $value->id;?>"></i></a>&nbsp;
<?php } ?>
</td>
</tr>
<?php } } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div id="customPrompt" class="modal modal_first">
<div class="modal-content modal-content_first">
<span style="text-align: right;" onclick="$('#customPrompt').hide()"><i class="fa fa-times" aria-hidden="true"></i></span>
<h3>Decline Reason</h3>
<input list="browsers" onfocus id="decline_reason" required name="myBrowser" style="margin-top: 10%;padding: 10px;"/>
<datalist id="browsers" >
<?php foreach ($dropdown as $key => $value) { ?>
<option value="<?php echo $value->enum_value; ?>"><?php echo $value->enum_value; ?></option>
<?php } ?>
</datalist>
<button onclick="submitCustomPrompt()" type="button" class="btn btn-primary">Submit</button>
</div>
</div>
<br/>
<!-- Large modal -->
<!-- <button type="button" class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg" hidden>Large modal</button> -->
<div class="modal fade bs-example-modal-lg" id="ItemModal" tabindex="-1" role="dialog" aria-hidden="true"></div>
<div class="modal bs-example-modal-sm" tabindex="-1" role="dialog" aria-hidden="true" id="popup"> </div>
<div style="display:none" id="sub-value">
<script>
$('.approveleave').click(function() {
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Leave/ManagerLeaveApprove";
$.ajax({
url: "<?php echo base_url()?>Leave/getManagerConfirmationPopup",
type:"GET",
success:function(data){
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value',id);
$('.delete_url').attr('action',url);
}
});
});
$('.test').click(function() {
var id = $(this).attr('id');
var url = "<?php echo base_url()?>Leave/managerDecline";
$.ajax({
url: "<?php echo base_url()?>Leave/getDeclineConfirmationPopup",
type: "GET",
success: function(data) {
$('#popup').html(JSON.parse(data));
$('.delete_id').attr('value', id);
$('.delete_url').attr('action', url);
}
});
});
$(document).on('click','.bi-card-list',function(){
var id = $(this).attr("id")
$.ajax({
type: "get",
url: "<?php echo base_url()?>Employee/view_emp_history/"+id,
success: function(response) {
response = JSON.parse(response);
console.log(response);
$('.bs-example-modal-lg').html(response);
$('.bs-example-modal-lg').modal("show");
},
error: function(jqXHR, textStatus, err) { alert('text status '+textStatus+', err '+err) }
});
});
</script>
<!-- <script>
$(document).on('click','.test',function(){
var id = $(this).attr("id");
var reason = prompt("Decline Reason", "");
console.log(reason);
if(reason != null && reason != "" ){
$.ajax(
{
data:{id : id , reason : reason },
url:"<?php echo base_url('Leave/Decline');?>",
type:"get",
success: function(response) {
window.location = '<?php echo base_url('Leave/leaveList');?>';
}
});
}
else if(reason == "")
{
alert('Decline Reason is Required');
}
});
</script> -->
<script>
function showCustomPrompt() {
var customPrompt = document.getElementById("customPrompt");
customPrompt.style.display = "block";
}
function submitCustomPrompt() {
var id = $('.test').attr("id");
var reason = document.getElementById("decline_reason").value;
if( reason != "")
$.ajax(
{
data:{id : id , reason : reason },
url:"<?php echo base_url('Leave/Decline');?>",
type:"get",
success: function(response) {
window.location ='<?php echo base_url('Leave/manager_approvel');?>';
}
});
else
alert('Decline Reason is required');
// var customPrompt = document.getElementById("customPrompt");
// customPrompt.style.display = "none";
}
</script>
<script>
$(document).ready(function() {
$('#datatables').DataTable({
"order": [
[0, 'desc']
],
"dom": 'Bfrtip',
buttons: [
{
extend: 'pdfHtml5',
title: 'Leave',
text: 'PDF',
customize: function(doc) {
doc.content[1].table.body.forEach(function(row) {
// Remove the first and last columns
row.splice(0, 1);
row.pop();
});
}
},
{
extend: 'excelHtml5',
text: 'Excel',
title: 'Leave',
exportOptions: {
// columns: ':not(:last-child)'
}
}
]
});
});
</script>
</div>